Revision: 7500
http://playerstage.svn.sourceforge.net/playerstage/?rev=7500&view=rev
Author: hsujohnhsu
Date: 2009-03-17 01:00:38 +0000 (Tue, 17 Mar 2009)
Log Message:
-----------
for running headless mode.
Modified Paths:
--------------
code/gazebo/branches/ogre-1.4.9/server/physics/TrimeshGeom.cc
Modified: code/gazebo/branches/ogre-1.4.9/server/physics/TrimeshGeom.cc
===================================================================
--- code/gazebo/branches/ogre-1.4.9/server/physics/TrimeshGeom.cc
2009-03-17 00:58:27 UTC (rev 7499)
+++ code/gazebo/branches/ogre-1.4.9/server/physics/TrimeshGeom.cc
2009-03-17 01:00:38 UTC (rev 7500)
@@ -59,37 +59,40 @@
/// Update function.
void TrimeshGeom::UpdateChild()
{
+ /// FIXME: use below to update trimesh geometry for collision without using
above Ogre codes
+ if (Simulator::Instance()->GetRenderEngineEnabled())
+ {
+ // tell the tri-tri collider the current transform of the trimesh --
+ // this is fairly important for good results.
- // tell the tri-tri collider the current transform of the trimesh --
- // this is fairly important for good results.
+ // Fill in the (4x4) matrix.
+ dReal* p_matrix = this->matrix_dblbuff + ( this->last_matrix_index * 16 );
+ const dReal *Pos = dGeomGetPosition(this->geomId);
+ const dReal *Rot = dGeomGetRotation(this->geomId);
- // Fill in the (4x4) matrix.
- dReal* p_matrix = this->matrix_dblbuff + ( this->last_matrix_index * 16 );
- const dReal *Pos = dGeomGetPosition(this->geomId);
- const dReal *Rot = dGeomGetRotation(this->geomId);
+ p_matrix[ 0 ] = Rot[ 0 ];
+ p_matrix[ 1 ] = Rot[ 1 ];
+ p_matrix[ 2 ] = Rot[ 2 ];
+ p_matrix[ 3 ] = 0;
+ p_matrix[ 4 ] = Rot[ 4 ];
+ p_matrix[ 5 ] = Rot[ 5 ];
+ p_matrix[ 6 ] = Rot[ 6 ];
+ p_matrix[ 7 ] = 0;
+ p_matrix[ 8 ] = Rot[ 8 ];
+ p_matrix[ 9 ] = Rot[ 9 ];
+ p_matrix[10 ] = Rot[10 ];
+ p_matrix[11 ] = 0;
+ p_matrix[12 ] = Pos[ 0 ];
+ p_matrix[13 ] = Pos[ 1 ];
+ p_matrix[14 ] = Pos[ 2 ];
+ p_matrix[15 ] = 1;
- p_matrix[ 0 ] = Rot[ 0 ];
- p_matrix[ 1 ] = Rot[ 1 ];
- p_matrix[ 2 ] = Rot[ 2 ];
- p_matrix[ 3 ] = 0;
- p_matrix[ 4 ] = Rot[ 4 ];
- p_matrix[ 5 ] = Rot[ 5 ];
- p_matrix[ 6 ] = Rot[ 6 ];
- p_matrix[ 7 ] = 0;
- p_matrix[ 8 ] = Rot[ 8 ];
- p_matrix[ 9 ] = Rot[ 9 ];
- p_matrix[10 ] = Rot[10 ];
- p_matrix[11 ] = 0;
- p_matrix[12 ] = Pos[ 0 ];
- p_matrix[13 ] = Pos[ 1 ];
- p_matrix[14 ] = Pos[ 2 ];
- p_matrix[15 ] = 1;
+ // Flip to other matrix.
+ this->last_matrix_index = !this->last_matrix_index;
- // Flip to other matrix.
- this->last_matrix_index = !this->last_matrix_index;
-
- dGeomTriMeshSetLastTransform( this->geomId,
- *(dMatrix4*)( this->matrix_dblbuff +
this->last_matrix_index * 16) );
+ dGeomTriMeshSetLastTransform( this->geomId,
+ *(dMatrix4*)( this->matrix_dblbuff +
this->last_matrix_index * 16) );
+ }
}
//////////////////////////////////////////////////////////////////////////////
@@ -118,103 +121,109 @@
this->meshNameP->Load(node);
this->scaleP->Load(node);
- mesh =
Ogre::MeshManager::getSingleton().load(this->meshNameP->GetValue(),Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
+ if (Simulator::Instance()->GetRenderEngineEnabled())
+ {
+ mesh =
Ogre::MeshManager::getSingleton().load(this->meshNameP->GetValue(),Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
- if (mesh.isNull())
- gzthrow("Failed to load trimesh "+ this->meshNameP->GetValue());
+ if (mesh.isNull())
+ gzthrow("Failed to load trimesh "+ this->meshNameP->GetValue());
- // Count the number of vertices and indices
- // for (i=0; i<mesh->getNumSubMeshes(); i++)
- for (i=0; i<1; i++)
- {
- subMesh = mesh->getSubMesh(i);
- if (subMesh->useSharedVertices)
- numVertices += mesh->sharedVertexData->vertexCount;
- else
- numVertices += subMesh->vertexData->vertexCount;
- numIndices += subMesh->indexData->indexCount;
- }
+ // Count the number of vertices and indices
+ // for (i=0; i<mesh->getNumSubMeshes(); i++)
+ for (i=0; i<1; i++)
+ {
+ subMesh = mesh->getSubMesh(i);
+ if (subMesh->useSharedVertices)
+ numVertices += mesh->sharedVertexData->vertexCount;
+ else
+ numVertices += subMesh->vertexData->vertexCount;
+ numIndices += subMesh->indexData->indexCount;
+ }
- // Create the vertex and index arrays
- vertices = new float[numVertices*3];
- indices = new int[numIndices];
+ // Create the vertex and index arrays
+ vertices = new float[numVertices*3];
+ indices = new int[numIndices];
- // Copy the vertex and index data from OGRE
- //for (i = 0; i < mesh->getNumSubMeshes(); i++)
- for (i = 0; i < 1; i++)
- {
- subMesh = mesh->getSubMesh(i);
+ // Copy the vertex and index data from OGRE
+ //for (i = 0; i < mesh->getNumSubMeshes(); i++)
+ for (i = 0; i < 1; i++)
+ {
+ subMesh = mesh->getSubMesh(i);
- if (subMesh->useSharedVertices)
- vertexData=mesh->sharedVertexData;
- else
- vertexData=subMesh->vertexData;
+ if (subMesh->useSharedVertices)
+ vertexData=mesh->sharedVertexData;
+ else
+ vertexData=subMesh->vertexData;
- elem =
vertexData->vertexDeclaration->findElementBySemantic(Ogre::VES_POSITION);
- vbuf = vertexData->vertexBufferBinding->getBuffer(elem->getSource());
+ elem =
vertexData->vertexDeclaration->findElementBySemantic(Ogre::VES_POSITION);
+ vbuf = vertexData->vertexBufferBinding->getBuffer(elem->getSource());
- // Pointer to vertex array.
- vertPtr = &(vertices[vindex]);
- vindex += vertexData->vertexCount*3;
+ // Pointer to vertex array.
+ vertPtr = &(vertices[vindex]);
+ vindex += vertexData->vertexCount*3;
- pData = static_cast<unsigned
char*>(vbuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
+ pData = static_cast<unsigned
char*>(vbuf->lock(Ogre::HardwareBuffer::HBL_READ_ONLY));
- // Add vertices to the vertex array
- for (j = 0; j < vertexData->vertexCount; j++)
- {
- elem->baseVertexPointerToElement(pData, &pFloat);
+ // Add vertices to the vertex array
+ for (j = 0; j < vertexData->vertexCount; j++)
+ {
+ elem->baseVertexPointerToElement(pData, &pFloat);
- *(vertPtr+0) = (*pFloat++) * this->scaleP->GetValue().x;
- *(vertPtr+1) = (*pFloat++) * this->scaleP->GetValue().y;
- *(vertPtr+2) = (*pFloat++) * this->scaleP->GetValue().z;
+ *(vertPtr+0) = (*pFloat++) * this->scaleP->GetValue().x;
+ *(vertPtr+1) = (*pFloat++) * this->scaleP->GetValue().y;
+ *(vertPtr+2) = (*pFloat++) * this->scaleP->GetValue().z;
- vertPtr += 3;
+ vertPtr += 3;
- pData += vbuf->getVertexSize();
- }
+ pData += vbuf->getVertexSize();
+ }
- vbuf->unlock();
+ vbuf->unlock();
- // Get the indices
- ibuf = subMesh->indexData->indexBuffer;
- indTmp = new unsigned short[subMesh->indexData->indexCount];
+ // Get the indices
+ ibuf = subMesh->indexData->indexBuffer;
+ indTmp = new unsigned short[subMesh->indexData->indexCount];
- ibuf->readData(0, ibuf->getSizeInBytes(), indTmp);
+ ibuf->readData(0, ibuf->getSizeInBytes(), indTmp);
- /// Copy the indices
- for (j = 0; j < subMesh->indexData->indexCount; j++)
- {
- indices[j+iindex] = indTmp[j];
- }
+ /// Copy the indices
+ for (j = 0; j < subMesh->indexData->indexCount; j++)
+ {
+ indices[j+iindex] = indTmp[j];
+ }
- iindex += subMesh->indexData->indexCount;
+ iindex += subMesh->indexData->indexCount;
- if (indTmp)
- {
- delete [] indTmp;
- indTmp = NULL;
+ if (indTmp)
+ {
+ delete [] indTmp;
+ indTmp = NULL;
+ }
}
- }
- /// This will hold the vertex data of the triangle mesh
- this->odeData = dGeomTriMeshDataCreate();
- // Build the ODE triangle mesh
- dGeomTriMeshDataBuildSingle( this->odeData,
- (float*)vertices, 3*sizeof(float), numVertices,
- (int*)indices, numIndices, 3*sizeof(int));
+ /// FIXME: use below to setup trimesh geometry for collision without using
above Ogre codes
- this->geomId = dCreateTriMesh( this->spaceId, this->odeData,0,0,0 );
+ /// This will hold the vertex data of the triangle mesh
+ this->odeData = dGeomTriMeshDataCreate();
- dMassSetTrimesh(&this->mass, this->massP->GetValue(), this->geomId);
+ // Build the ODE triangle mesh
+ dGeomTriMeshDataBuildSingle( this->odeData,
+ (float*)vertices, 3*sizeof(float),
numVertices,
+ (int*)indices, numIndices, 3*sizeof(int));
- // Create the trimesh geometry
- this->SetGeom(this->geomId, true);
+ this->geomId = dCreateTriMesh( this->spaceId, this->odeData,0,0,0 );
- memset(this->matrix_dblbuff,0,32*sizeof(dReal));
- this->last_matrix_index = 0;
+ dMassSetTrimesh(&this->mass, this->massP->GetValue(), this->geomId);
+
+ // Create the trimesh geometry
+ this->SetGeom(this->geomId, true);
+
+ memset(this->matrix_dblbuff,0,32*sizeof(dReal));
+ this->last_matrix_index = 0;
+ }
}
//////////////////////////////////////////////////////////////////////////////
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit