B
berthelot samuel
Hi,
I have a problem with structures that lose their content when I pass
them to a function.
Here are the structures
typedef struct VERTEX
{
int id; /* id of this vertex */
float x, y, z; /* vertex coordinates */
float u, v; /* texture coordinates */
float r, g, b; /* rgb colour of the vertex */
float normal[3]; /* x y z values of the normal */
}vertex;
typedef struct FACE
{
int vertices[3];/* list of vertices corresponding to this face */
CVector normal; /* x y z values of the normal */
}face;
typedef struct OBJECT3D
{
vertex *vertices; /* hold the vertices of the object3D */
face *faces; /* hold the faces of the object3D */
int vcnt; /* number of vertices of the object3D */
int fcnt; /* number of faces of the object3D */
CVector center; /* center of the object - used for bounding box
*/
float width; /* max width of the object -used for bounding box */
void ComputeBB(); /* compute the bounding box of the object */
}object3D;
typedef struct WORLD3D
{
int numObjects; /* number of objects in the world */
vector<object3D> m_objList; /* list of objects in the world */
}world3D;
And there I create my objects and I add them to a vector
object3D myObject;
memset(&myObject, 0, sizeof(object3D));
g_world.numObjects ++;
myObject.vcnt = 8;
myObject.vertices = new vertex[myObject.vcnt];
myObject.vertices = vertices;
myObject.fcnt = 10;
myObject.faces = new face[myObject.fcnt];
myObject.faces = faces;
g_world.m_objList.push_back(myObject);
I've checked with the debugger and g_world contains everything ok. The
problem is there:
m_octree->BuildRootNode(&g_world, m_city->GetNumPoly(),
m_octree->GetCenter(), m_octree->GetSize());
In BuildRootNode(...) g_world doesn't contain the value of vertices
and faces any more. I believe it's related to the way I pass it to the
function, but I'm not too sure about that.
Thanx for any help.
Sam
I have a problem with structures that lose their content when I pass
them to a function.
Here are the structures
typedef struct VERTEX
{
int id; /* id of this vertex */
float x, y, z; /* vertex coordinates */
float u, v; /* texture coordinates */
float r, g, b; /* rgb colour of the vertex */
float normal[3]; /* x y z values of the normal */
}vertex;
typedef struct FACE
{
int vertices[3];/* list of vertices corresponding to this face */
CVector normal; /* x y z values of the normal */
}face;
typedef struct OBJECT3D
{
vertex *vertices; /* hold the vertices of the object3D */
face *faces; /* hold the faces of the object3D */
int vcnt; /* number of vertices of the object3D */
int fcnt; /* number of faces of the object3D */
CVector center; /* center of the object - used for bounding box
*/
float width; /* max width of the object -used for bounding box */
void ComputeBB(); /* compute the bounding box of the object */
}object3D;
typedef struct WORLD3D
{
int numObjects; /* number of objects in the world */
vector<object3D> m_objList; /* list of objects in the world */
}world3D;
And there I create my objects and I add them to a vector
object3D myObject;
memset(&myObject, 0, sizeof(object3D));
g_world.numObjects ++;
myObject.vcnt = 8;
myObject.vertices = new vertex[myObject.vcnt];
myObject.vertices = vertices;
myObject.fcnt = 10;
myObject.faces = new face[myObject.fcnt];
myObject.faces = faces;
g_world.m_objList.push_back(myObject);
I've checked with the debugger and g_world contains everything ok. The
problem is there:
m_octree->BuildRootNode(&g_world, m_city->GetNumPoly(),
m_octree->GetCenter(), m_octree->GetSize());
In BuildRootNode(...) g_world doesn't contain the value of vertices
and faces any more. I believe it's related to the way I pass it to the
function, but I'm not too sure about that.
Thanx for any help.
Sam