-
invalid initializer
hello!
i declared these types:
Code:
typedef struct fVector2D {
float x;
float y;
}tVector2D;
...
typedef struct fVector3D {
float x;
float y;
float z;
}tVector3D;
...
typedef struct tDreieck *pDreieck;
struct tDreieck {
unsigned int punkte[3];
...
};
...
typedef struct koerper{
...
unsigned int anzDreieck;
pDreieck dreiecke;
tVector3D *p_punkte;
...
}tKoerper;
typedef struct koerper *pKoerper;
...
typedef struct objekt {
...
pKoerper p_koerper;
...
}tObjekt;
...
typedef struct szenenGraph *pSzenenGraph;
struct szenenGraph
{
tObjekt objekt;
pSzenenGraph kind;
pSzenenGraph prev;
pSzenenGraph next;
};
and im trying this:
Code:
void
zeichneSzenenGraph(pSzenenGraph wurzelzeiger){
...
tVector3D normale = vec3Cross(vec3Sub(wurzelzeiger->objekt.p_koerper->p_punkte[wurzelzeiger->objekt.p_koerper->dreiecke[n].punkte[3]],
wurzelzeiger->objekt.p_koerper->p_punkte[wurzelzeiger->objekt.p_koerper->dreiecke[n].punkte[2]]),
vec3Sub(wurzelzeiger->objekt.p_koerper->p_punkte[wurzelzeiger->objekt.p_koerper->dreiecke[n].punkte[1]],
wurzelzeiger->objekt.p_koerper->p_punkte[wurzelzeiger->objekt.p_koerper->dreiecke[n].punkte[2]]));
...
}
trying to compile, i get :"invalid initializer"
can anyone tell me why, please?
thanks
martin
-
we really need more info..
waht is vec3cross? and vec3sub?
-
I refuse to read code where they hide pointers. Sorry. It's just too damn ugly.
Quzah.
-
Well peeling away several layers of indirection with a local variable would help
Code:
pKoerper *bar = wurzelzeiger->objekt.p_koerper;
tVector3D normale = vec3Cross(vec3Sub(bar->p_punkte[bar->dreiecke[n].punkte[3]],
bar->p_punkte[bar->dreiecke[n].punkte[2]]),
vec3Sub(bar->p_punkte[bar->dreiecke[n].punkte[1]],
bar->p_punkte[bar->dreiecke[n].punkte[2]]));
Then my next impression is that you think arrays start at 1, and not 0, because you have this declaration in a struct
unsigned int punkte[3];
and your code is trying to access an out-of-range element
-
thank you for your answer salem.
the problem is, i cannot initialize a variable *bar like you did. i get:
Code:
[Warning] initialization from incompatible pointer type
i tried not to hide my pointers, like quzah suggested, but that didnt do it either.
>>misplaced
vec3Cross and vec3Sub return tVector3D.
any other idea?
-
Well I would assume you would pick the right type for the pointer.
-
>>Well I would assume you would pick the right type for the pointer.
i did!
Code:
pKoerper *bar = wurzelzeiger->objekt.p_koerper;
-
I suggest you create a single file containing the bare minimum of declarations and code which compiles with the same error messages, then post that code.
-
thanks guys. i found out myself.
i forgot to include "vectorOperations.h"...
hmpf!
sorry to bother with such a beginner problem
;)