[LDPartEditor] First Alpha Version News (until 2014-09-19)


Re: [LDPartEditor] Optional Lines
#38
Imagine an optional line with the four points A2, B2, C2 and D2.

1. Take these points and multiply them by their perspective and modelview matrix M.
As a result you'll get A, B, C and D in screen coordinates.

Code:
Matrix4f.transform(M, A2, A);
Matrix4f.transform(M, B2, B);
Matrix4f.transform(M, C2, C);
Matrix4f.transform(M, D2, D);

2. Calculate the line normal

Code:
N.x = A.y - B.y;
N.y = B.x - A.x;

3. Calculate the discriminant r by

Code:
[b]r[/b] = Vector4f.dot(N, Vector4f.sub(C, A)) * Vector4f.dot(N, Vector4f.sub(D, A));

where Vector4f.dot() calculates the dot product of these two vectors and Vector4f.sub() the difference vector.

4. draw the line between A2 and B2 only if r > 0
Reply
« Next Oldest | Next Newest »



Messages In This Thread
Deadline Change - by Nils Schmidt - 2012-12-25, 11:19
Re: Deadline Change - by Philippe Hurbain - 2012-12-25, 14:30
First Alpha Screenshots - by Nils Schmidt - 2012-12-27, 19:00
Grid implementation done - by Nils Schmidt - 2013-01-08, 23:47
Text Editor Impression - by Nils Schmidt - 2013-01-13, 18:58
Re: Text Editor Impression - by Nils Schmidt - 2014-03-24, 17:54
Startup dialog - by Nils Schmidt - 2013-01-18, 15:25
Re: Startup dialog - by Philippe Hurbain - 2013-01-18, 18:37
Syntax Highlighting - by Nils Schmidt - 2013-01-27, 20:04
Test Environments - by Nils Schmidt - 2014-03-24, 17:32
Another Text Editor Teaser - by Nils Schmidt - 2014-03-24, 17:50
Re: [LDPartEditor] Optional Lines - by Nils Schmidt - 2014-04-07, 21:58
[LDPartEditor] Anaglyph Car - by Nils Schmidt - 2014-05-10, 22:58

Forum Jump:


Users browsing this thread: 3 Guest(s)