• What is your GameDev Story?

Archived

This topic is now archived and is closed to further replies.

vertex normals

This topic is 5388 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

I'm calculating normals from a hiehgtmap for cubemapping... and when i render, the reflections dont connect at the polygons, so im assuming there is something wrong with my vertex normal calculation, here is the code:
v1 = m_points[polyCount][1] - m_points[polyCount][0];
v2 = m_points[polyCount][2] - m_points[polyCount][0];
normal = cross(v1, v2);
normal = normalize(normal);

glNormal3f(normal.x, normal.y, normal.z); glVertex3f(m_points[polyCount][0].x, m_points[polyCount][0].y, m_points[polyCount][0].z);

v1 = m_points[polyCount][2] - m_points[polyCount][1];
v2 = m_points[polyCount][0] - m_points[polyCount][1];
normal = cross(v1, v2);
normal = normalize(normal);

glNormal3f(normal.x, normal.y, normal.z); glVertex3f(m_points[polyCount][1].x, m_points[polyCount][1].y, m_points[polyCount][1].z);

v1 = m_points[polyCount][0] - m_points[polyCount][2];
v2 = m_points[polyCount][1] - m_points[polyCount][2];
normal = cross(v1, v2);
normal = normalize(normal);

glNormal3f(normal.x, normal.y, normal.z); glVertex3f(m_points[polyCount][2].x, m_points[polyCount][2].y, m_points[polyCount][2].z);

v1 = m_points[polyCount][2] - m_points[polyCount][0];
v2 = m_points[polyCount][3] - m_points[polyCount][0];
normal = cross(v1, v2);
normal = normalize(normal);

glNormal3f(normal.x, normal.y, normal.z); glVertex3f(m_points[polyCount][0].x, m_points[polyCount][0].y, m_points[polyCount][0].z);

v1 = m_points[polyCount][3] - m_points[polyCount][2];
v2 = m_points[polyCount][0] - m_points[polyCount][2];
normal = cross(v1, v2);
normal = normalize(normal);

glNormal3f(normal.x, normal.y, normal.z); glVertex3f(m_points[polyCount][2].x, m_points[polyCount][2].y, m_points[polyCount][2].z);

v1 = m_points[polyCount][0] - m_points[polyCount][3];
v2 = m_points[polyCount][2] - m_points[polyCount][3];
normal = cross(v1, v2);
normal = normalize(normal);

glNormal3f(normal.x, normal.y, normal.z); glVertex3f(m_points[polyCount][3].x, m_points[polyCount][3].y, m_points[polyCount][3].z);
polyCount++;

im drawing clockwise.... whats wrong with this!? [edited by - colinisinhere on April 14, 2004 6:42:47 PM] [edited by - colinisinhere on April 14, 2004 6:43:10 PM]

Share on other sites
Although I''d like to help, its often difficult and frustrating to offer assistance when a Code Block of Significant Size is just dumped into your post. Some members will even resort to flaming.

Let me see if I can be of any help without actually stepping through your code line by line. The first thing I''d ask is, have you done so? If you''re using an IDE with a debugger, step through the code very carefully and see if you can''t determine just where the problem lies.

If that doesn''t work, and you''ve exhausted all other resources at your disposal, maybe you could re-post your code, but comment it very thoroughly this time. That way whoever tries to help will be able to understand precisely what you''re trying to do.

Hope that helps.

****************************************

Brian Lacy
ForeverDream Studios

"I create. Therefore I am."

Share on other sites
ive been working on this all day, but i have figured out the problem, now my question is... how can i calculate vertex normals without calculating the face normal first?

Share on other sites
Hmm...i remember doing a terrain generator and setting the terrain vertex normals.

My approach/conclusion was the following:

1) I calculated the vertex normals on loadtime since i couldnt efficiently calculate them each frame in runtime (atleast not the way i was doing it).

2) Vertex normals were sufficient...i didnt need to calculate surface normals. (why would you want that...anyone???)

.......

So, i simply calculated the vertex normals of every vertex in my terrain mesh. And to do that, i simply did a crossproduct of two vectors. simple, dirty, but it was sufficient to give the look i wanted.

• What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

(You must login to your GameDev.net account.)

• 13
• 9
• 15
• 14
• 46
• Forum Statistics

• Total Topics
634059
• Total Posts
3015291
×