Click here to Skip to main content
15,891,607 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Unresolved token error Pin
Cedric Moonen18-Jan-07 0:52
Cedric Moonen18-Jan-07 0:52 
GeneralRe: Unresolved token error Pin
73Zeppelin18-Jan-07 0:58
73Zeppelin18-Jan-07 0:58 
AnswerRe: Unresolved token error Pin
73Zeppelin18-Jan-07 1:56
73Zeppelin18-Jan-07 1:56 
GeneralRe: Unresolved token error Pin
Cedric Moonen18-Jan-07 2:35
Cedric Moonen18-Jan-07 2:35 
GeneralRe: Unresolved token error Pin
73Zeppelin18-Jan-07 2:43
73Zeppelin18-Jan-07 2:43 
GeneralRe: Unresolved token error Pin
jhwurmbach18-Jan-07 2:47
jhwurmbach18-Jan-07 2:47 
GeneralRe: Unresolved token error Pin
73Zeppelin18-Jan-07 3:04
73Zeppelin18-Jan-07 3:04 
QuestionDereferencing an normal array [modified] Pin
zqueezy18-Jan-07 0:36
zqueezy18-Jan-07 0:36 
heyhey

I've got a simple question. I read that you can dereference an vertex array like this:
<br />
int i;<br />
glBegin (mode);<br />
for (i = 0; i < count; i++)<br />
   glArrayElement(indices[i]);<br />
glEnd();<br />

which should be equal to a glDrawElements()-call
but what if I want to get the normal which is related to this vertex-list. So I have a glNormalPointer()-call before???

<br />
...<br />
glNormalPointer(GL_FLOAT, 0, ModelToDraw.Objects[i].Normals);<br />
glVertexPointer(3, GL_FLOAT, 0, ModelToDraw.Objects[i].Vertexes);<br />
float *pNormal = ModelToDraw.Objects[i].Normals;<br />
float *pVertex = ModelToDraw.Objects[i].Vertexes;<br />
...<br />
for (int j=0; j < ModelToDraw.Objects[i].numMatFaces; j++)<br />
{<br />
  {...}<- set up material here<br />
  glDrawElements(GL_TRIANGLES, ModelToDraw.Objects[i].MatFaces[j].numSubFaces, GL_UNSIGNED_SHORT, ModelToDraw.Objects[i].MatFaces[j].subFaces);<br />
}<br />


I can simply extract the vertex from the glDrawElements or respectively 3 elements to draw a triangle. but how to extract the normal, so I don't need to recalculate it?

thx
zqueezy


-- modified at 10:41 Thursday 18th January, 2007
Adding: The problem is that the iteration here is through the materials and not in the correct order.
I replace the glDrawElements-Call with a call to my own function where I need the normal to each triangle. reading out the correct triangles from p.Vertex is no problem:
<br />
vector4 a,b,c;<br />
int i;		// Laufvariable<br />
unsigned short index;<br />
float* _tempArray;		<br />
glDisable(GL_LIGHTING);<br />
	<br />
for(i=0; i < numSubFaces; i+=3)<br />
{<br />
index = subFaces[i]; // pointer to first vector of triangle<br />
_tempArray=(float*)(((char*)k) + index * 12);	// 12 = size of 3 floats<br />
<br />
// Get First Triangle Vector<br />
a.x = _tempArray[0];<br />
a.y = _tempArray[1];<br />
a.z = _tempArray[2];<br />
a.w = 1.0f;<br />
<br />
index = subFaces[i+1];		<br />
_tempArray=(float*)(((char*)k) + index * 12);<br />
b.x = _tempArray[0];<br />
b.y = _tempArray[1];<br />
b.z = _tempArray[2];<br />
b.w = 1.0f;<br />
<br />
// and the same for c<br />
<br />
// Then read out the normal for the face:<br />
_tempArray=&(pNormal[i]);  // <---- Here must be something wrong<br />
<br />
d.x = _tempArray[0];<br />
d.y = _tempArray[1];<br />
d.z = _tempArray[2];<br />
d.w = 1.0f;<br />

Then I want to show the normal:
<br />
if (showNormal)<br />
{<br />
	glColor3f(1.0, 0.0, 0.0);<br />
	glBegin(GL_LINES);<br />
		glVertex3f(a.x, a.y, a.z);<br />
		glVertex3f(a.x + d.x, a.y + d.y, a.z + d.z);<br />
	glEnd();<br />
}<br />


a little clearer what the problem is??
AnswerRe: Dereferencing an normal array Pin
Iain Clarke, Warrior Programmer18-Jan-07 1:54
Iain Clarke, Warrior Programmer18-Jan-07 1:54 
GeneralNONONO need still help! Pin
zqueezy18-Jan-07 4:35
zqueezy18-Jan-07 4:35 
GeneralRe: NONONO need still help! Pin
El Corazon18-Jan-07 4:58
El Corazon18-Jan-07 4:58 
AnswerRe: Dereferencing an normal array Pin
El Corazon18-Jan-07 5:20
El Corazon18-Jan-07 5:20 
GeneralWow Pin
zqueezy18-Jan-07 11:24
zqueezy18-Jan-07 11:24 
GeneralRe: Wow Pin
El Corazon18-Jan-07 11:43
El Corazon18-Jan-07 11:43 
QuestionHow to create nice toolbar in CDialog app Pin
PatrykDabrowski18-Jan-07 0:04
PatrykDabrowski18-Jan-07 0:04 
AnswerRe: How to create nice toolbar in CDialog app Pin
Nibu babu thomas18-Jan-07 0:28
Nibu babu thomas18-Jan-07 0:28 
AnswerRe: How to create nice toolbar in CDialog app Pin
Hamid_RT18-Jan-07 0:41
Hamid_RT18-Jan-07 0:41 
AnswerRe: How to create nice toolbar in CDialog app Pin
Hamid_RT18-Jan-07 6:27
Hamid_RT18-Jan-07 6:27 
AnswerRe: How to create nice toolbar in CDialog app Pin
Mark Salsbery18-Jan-07 6:32
Mark Salsbery18-Jan-07 6:32 
Questionthe exception breakpoint... Pin
shivapriyak18-Jan-07 0:03
shivapriyak18-Jan-07 0:03 
AnswerRe: the exception breakpoint... Pin
toxcct18-Jan-07 0:11
toxcct18-Jan-07 0:11 
QuestionNeed to help in file reading in win32 Pin
amitmistry_petlad 17-Jan-07 23:54
amitmistry_petlad 17-Jan-07 23:54 
AnswerRe: Need to help in file reading in win32 Pin
Roger Stoltz18-Jan-07 0:23
Roger Stoltz18-Jan-07 0:23 
GeneralRe: Need to help in file reading in win32 Pin
amitmistry_petlad 18-Jan-07 0:30
amitmistry_petlad 18-Jan-07 0:30 
GeneralRe: Need to help in file reading in win32 Pin
Roger Stoltz18-Jan-07 0:41
Roger Stoltz18-Jan-07 0:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.