Original Post
Alright i am _very_ irritated by this problem.
I am using DJGPP and working on a simple 3d engine of my own. i have a stuct for a model (which i dont mean external model, i mean like anything in the game, including objects, levels, and so on). it is defined as follows:
(first you need VERTEX):
typedef struct _VERTEX {
float x,y,z;
}VERTEX;
(then triangle):
typedef struct _TRIANGLE {
VERTEX verticies[3];
VERTEX normal;
}TRIANGLE;
(then face):
typedef struct _FACE {
VERTEX normal;
TRIANGLE *triangles;
int num_triangles;
}FACE;
(then model):
typedef struct _MODEL {
VERTEX pos;
float rx,ry,rz;
FACE *faces;
int num_faces;
}MODEL;
go back and look at the code, so you can look at what of the members are pointers. all right, and here is my function, which is really giving me a headache:
int FindNormal(FACE* face)
{
VERTEX v1,v2;
VERTEX out;
v1.x = face->triangles[0]->v[0].x - face->triangles[0].v[1].x;
v1.y = face->triangles[0]->v[0].y - face->triangles[0].v[1].y;
v1.z = face->triangles[0]->v[0].z - face->triangles[0].v[1].z;
v2.x = face->triangles[0]->v[1].x - face->triangles[0]->v[2].x;
v2.y = face->triangles[0]->v[1].y - face->triangles[0]->v[2].y;
v2.z = face->triangles[0]->v[1].z - face->triangles[0]->v[2].z;
out.x = v1.y*v2.z - v1.z*v2.y;
out.y = v1.z*v2.x - v1.x*v2.z;
out.z = v1.x*v2.y - v1.y*v2.x;
if(out.x > 0)
{
out.x/=out.x;
}
if(out.y > 0)
{
out.y/=out.y;
}
if(out.z > 0)
{
out.z/=out.z;
}
face.normal.x = out.x;
face.normal.y = out.y;
face.normal.z = out.z;
return(0);
}
and my compiler makes an error saying for almost each line of code complaining about the face->triangles part:
"invalid argument type ''->''"
so i tried making all of the ''->'' for the face->triangles part, and then it says:
"request for member ''triangles'' in something not a struct or union"
i am really stumped