Solved

Order of triangles's vertices

Posted on 2006-11-06
6
911 Views
Last Modified: 2013-12-06
I plot some 3D functions and extract triangles, but some draw clockwise and other counter-clockwise so they are falsely colored (but all normal vector are directed to same direction)

For example, I use v=sign(x0*y1-x1*y0 + x1*y2-x2*y1 + x2*y0-x0*y2) to determine how triangle is shown:

(-0.422 -0.100 0.900)
(-0.400 -0.167 0.900)
(-0.400 -0.100 0.911)
0.001481 - clockwise

(-0.422 0.100 0.900)
(-0.400 0.167 0.900)
(-0.400 0.100 0.911)
-0.001481 - counterclockwise

I am looking for the method that will allow sorting of triangle vertices that they are all shown in right direction (counterclockwise for instance).

Thank you.
0
Comment
Question by:Neoliten
  • 3
  • 3
6 Comments
 
LVL 84

Expert Comment

by:ozo
ID: 17887449
Is that clockwise when looking in the z direction?
0
 

Author Comment

by:Neoliten
ID: 17887473
Actually it not directly visible. I see on the display that some triangles colored on front, but other colored on the back, however normals are pointer to the same direction, so all triangles should be colored on front.
I made calculations and I see that v=sign(... gives negative and positive results, which means that triangles drawn in clockwise/counterclockwise order. I am trying to sort vertices so they are all drawn in clockwise direction.
In this way coloring will depend on direction of normal vector.
0
 
LVL 84

Accepted Solution

by:
ozo earned 125 total points
ID: 17887489
Can you just swap a pair of vertices when v is negative?
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

Author Comment

by:Neoliten
ID: 17887500
I am trying...
However, which pair? Or swap until v become positive?
0
 
LVL 84

Expert Comment

by:ozo
ID: 17887549
It doesn't matter, swaping any pair will change the sign
0
 

Author Comment

by:Neoliten
ID: 17887570
Yes, works. Thank you.

However seems that I need to organize vertices according normal direction. For example, if I plot sphere, then one half colored on front and other half also on front (which is wrong, second half should be colored on back - inside the sphere).

I need sort of check, if normal points back, then color front (v < 0); if normal points front, then color back (v > 0). (just different checks for v, greater then 0 or less than 0)
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Questions about virtual reality solution 8 320
How would I store peoples passwords 5 84
Video Game Storyline Theory and Development 4 92
count8 challlenge 13 144
As game developers, we quickly learn that Artificial Intelligence (AI) doesn’t need to be so tough.  To reference Space Ghost: “Moltar, I have a giant brain that is able to reduce any complex machine into a simple yes or no answer. (http://www.youtu…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question