[ODE] Fwd: Trimesh troubles.
Kris
kris at kolos.math.uni.lodz.pl
Thu Mar 17 12:33:38 MST 2005
Hi
On Wed, 16 Mar 2005, Derek Arndt wrote:
> > if(shape == LV_TRIMESH)
> > {
> > vertices.clear();
> > normals.clear();
> > indices.clear();
> > const std::vector<kMesh> meshes = *obj.GetModel()->GetMeshes();
> > dVector3Wrapper tempV;
> >
> > uint meshCount = meshes.size();
> > for(uint k = 0; k < meshCount; k++)
> > {
> > uint vertexCount = meshes[k].data.vertices.size();
> > uint normalCount = meshes[k].data.normals.size();
> > for(uint p = 0; p < vertexCount; p++)
> > {
> > tempV.vector[0] = (dReal)meshes[k].data.vertices[p].x;
> > tempV.vector[1] = (dReal)meshes[k].data.vertices[p].y;
> > tempV.vector[2] = (dReal)meshes[k].data.vertices[p].z;
> >
> > vertices.push_back(tempV);
> >
> > if(normalCount >= p+1)
> > {
> > tempV.vector[0] = (dReal)meshes[k].data.normals[p].x;
> > tempV.vector[1] = (dReal)meshes[k].data.normals[p].y;
> > tempV.vector[2] = (dReal)meshes[k].data.normals[p].z;
> >
> > normals.push_back(tempV);
> > }
> > }
> >
> > uint indexCount = meshes[k].data.triangles.size();
Number of indices is 3 times larger than triangles :], so you have too few
indices in your vector.
Remember that when you create trimeshdata pointers to vertices and indices
are being copied, veritces and indices vector are NOT being copied, so
when youcreate next trimesh you will overwrite vertices and indices of
previous trimesh :P
> > for(uint p = 0; p < indexCount; p++)
> > indices.push_back((int)meshes[k].data.triangles[p]);
> > }
> >
> > dTriMeshDataID triMesh = dGeomTriMeshDataCreate();
> > dGeomTriMeshDataBuildSimple(triMesh, (dReal*)&(vertices[0]),
> > vertices.size(), (const int*)&(indices[0]), indices.size());
> > // dGeomTriMeshDataBuildSingle1(triMesh, &vertices[0],
> > sizeof(dVector3Wrapper), vertices.size(),
> > // &indices[0], indices.size(), sizeof(int)*3,
> > // NULL);
> > geom = dCreateTriMesh(Controllers()->Collision()->GetSpace(),
> > triMesh, 0,0,0);
> >
> > dMassSetBoxTotal(&mass, 1, bbox.Width(), bbox.Height(),
> > bbox.Depth());
> > dGeomSetData(geom, triMesh);
> > }
> >
> > dGeomSetBody(this->geom, 0);
> > dGeomSetPosition(this->geom, modelPos.x, modelPos.y, modelPos.z);
> >
> > Thanks,
> > Derek
> >
> > /*
> > http://www.dereksucks.com _game development is just my forte_
> > >81
> > */
>
Pozdr __DEVELOPER_TRINITY_CREEZ_H__
--
===========================================
GG: 1271378
-------------[ PROJECT TRINITY ]-----------
[ http://trinity.glt.pl ] [ Trinity ]
[ The post-nuclear cRPG ]
===========================================
More information about the ODE
mailing list