miztaken

10-06-2010, 11:12 PM

I am generating a triangular mesh and trying to display in proper lighting condition.

but i have having two problems while doing so:-

1. some of my triangles are rendered very bright than the neighbor triangles ( as shown in fig1 attached).

2. and when i rotate the object, i get a claw like artifact as shown in fig2 attached.

what can be my problem and how to eliminate it.

BionicBytes

10-07-2010, 02:25 AM

Can you post how you actually rotate the normals and or object? At the moment you are expecting us to guess all the details!

miztaken

10-07-2010, 08:56 AM

Here is the simple version of how i computed normal but get the same error.

Initially lets assume we have the triangular mesh. While displaying those triangles... i find out the vector between the two edges and compute the cross product the get the normals at each vertex of the triangle. For triangle ABC, i get the vector AB and AC, the get the cross product between them to get the normal at point A. likewise for B and C.

I am computing this one time only and storing it on display list and displaying by calling display list.

The triangular meshes are for dataset 64 x 64 x 64 so i have taken center[3] as {32,32,32}

I am rotating and translating the object in both x and y direction with zooming facility

here is the code for that:-

glTranslatef(cube_center[0], cube_center[1], cube_center[2]);

glTranslatef(-(cube_center[0] * zoomfactor), -(cube_center[1] * zoomfactor),-(cube_center[2] * zoomfactor));

glScalef(zoomfactor, zoomfactor, zoomfactor);

glTranslatef(deltax, deltay, deltaz);

glTranslatef(cube_center[0], cube_center[1], cube_center[2]);

glRotatef(rX, 1, 0, 0);

glRotatef(rY, 0, 1, 0);

glTranslatef(-cube_center[0], -cube_center[1], -cube_center[2]);

variables meaning:

zoomfactor is initially 1.

rX and rY stores the rotation in x and y direction.

deltax and deltay stores the translation on x and y direction.

I am calling the display list that draws my object after calling this code above.

I have attached the figures for this configuration of mine.

Problem 1: fig3.png -> showing problem where some triangles are very bright or very dark as compared to its neighbouring triangles.

Problem 2: fig4.png -> claws like artifact.

For problem 1, i have tried to make the z value of normal negative if its positive but it didn't helped.

I dont have any clue about the problem 2 but i see those artifacts when rX goes from 90 to 100,and also for any combination rotation of rX and rY.

i would be very grateful if anyone can help me with this...

thank you

Powered by vBulletin® Version 4.2.3 Copyright © 2018 vBulletin Solutions, Inc. All rights reserved.