Did a bit more Collada physics importing work.
Also did a quick workaround to allow different camera UP. This demo stuff really needs to be cleaned up now!
This commit is contained in:
@@ -27,7 +27,8 @@ subject to the following restrictions:
|
|||||||
#include "CollisionShapes/TriangleMeshShape.h"
|
#include "CollisionShapes/TriangleMeshShape.h"
|
||||||
|
|
||||||
|
|
||||||
|
extern SimdVector3 gCameraUp;
|
||||||
|
extern int gForwardAxis;
|
||||||
|
|
||||||
#include "CollisionShapes/Simplex1to4Shape.h"
|
#include "CollisionShapes/Simplex1to4Shape.h"
|
||||||
#include "CollisionShapes/EmptyShape.h"
|
#include "CollisionShapes/EmptyShape.h"
|
||||||
@@ -44,6 +45,9 @@ subject to the following restrictions:
|
|||||||
|
|
||||||
#include "GLDebugDrawer.h"
|
#include "GLDebugDrawer.h"
|
||||||
|
|
||||||
|
//either FCollada or Collada-dom
|
||||||
|
#define USE_FCOLLADA 1
|
||||||
|
#ifdef USE_FCOLLADA
|
||||||
|
|
||||||
//Collada Physics test
|
//Collada Physics test
|
||||||
//#define NO_LIBXML //need LIBXML, because FCDocument/FCDPhysicsRigidBody.h needs FUDaeWriter, through FCDPhysicsParameter.hpp
|
//#define NO_LIBXML //need LIBXML, because FCDocument/FCDPhysicsRigidBody.h needs FUDaeWriter, through FCDPhysicsParameter.hpp
|
||||||
@@ -67,11 +71,14 @@ subject to the following restrictions:
|
|||||||
#include "FCDocument/FCDPhysicsAnalyticalGeometry.h"
|
#include "FCDocument/FCDPhysicsAnalyticalGeometry.h"
|
||||||
|
|
||||||
|
|
||||||
//aaa
|
#else
|
||||||
|
//Use Collada-dom
|
||||||
|
|
||||||
|
#include "dae.h"
|
||||||
|
#include "dom/domCOLLADA.h"
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -216,6 +223,8 @@ void CreatePhysicsObject(bool isDynamic, float mass, const SimdTransform& startT
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef USE_FCOLLADA
|
||||||
|
|
||||||
|
|
||||||
bool ConvertColladaPhysicsToBulletPhysics(const FCDPhysicsSceneNode* inputNode)
|
bool ConvertColladaPhysicsToBulletPhysics(const FCDPhysicsSceneNode* inputNode)
|
||||||
{
|
{
|
||||||
@@ -281,7 +290,11 @@ bool ConvertColladaPhysicsToBulletPhysics(const FCDPhysicsSceneNode* inputNode)
|
|||||||
//right now as we would also have to migrate all the animation curves.
|
//right now as we would also have to migrate all the animation curves.
|
||||||
|
|
||||||
|
|
||||||
//FRTScaleList scaleTransforms;
|
SimdVector3 localScaling(1.f,1.f,1.f);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SimdTransform accumulatedWorldTransform;
|
SimdTransform accumulatedWorldTransform;
|
||||||
accumulatedWorldTransform.setIdentity();
|
accumulatedWorldTransform.setIdentity();
|
||||||
@@ -290,19 +303,33 @@ bool ConvertColladaPhysicsToBulletPhysics(const FCDPhysicsSceneNode* inputNode)
|
|||||||
|
|
||||||
for (uint32 i=0; i<numTransforms; i++)
|
for (uint32 i=0; i<numTransforms; i++)
|
||||||
{
|
{
|
||||||
FMMatrix44 mat = (targetNode->GetTransforms()[i])->ToMatrix();
|
|
||||||
SimdVector3 pos(mat.GetTranslation().x,mat.GetTranslation().y,mat.GetTranslation().z);
|
|
||||||
|
|
||||||
SimdMatrix3x3 rotMat(
|
if (targetNode->GetTransforms()[i]->GetType() == FCDTransform::SCALE)
|
||||||
mat.m[0][0],mat.m[0][1],mat.m[0][2],
|
{
|
||||||
mat.m[1][0],mat.m[1][1],mat.m[1][2],
|
|
||||||
mat.m[2][0],mat.m[2][1],mat.m[2][2]);
|
|
||||||
|
|
||||||
rotMat = rotMat.transpose();
|
FCDTScale* scaleTrans = (FCDTScale*)targetNode->GetTransforms()[i];
|
||||||
SimdTransform trans(rotMat,pos);
|
const FMVector3& scaling = scaleTrans->GetScale();
|
||||||
|
localScaling[0] = scaling.x;
|
||||||
|
localScaling[1] = scaling.y;
|
||||||
|
localScaling[2] = scaling.z;
|
||||||
|
|
||||||
//TODO: check pre or post multiply
|
} else
|
||||||
accumulatedWorldTransform = accumulatedWorldTransform * trans;
|
{
|
||||||
|
|
||||||
|
FMMatrix44 mat = (targetNode->GetTransforms()[i])->ToMatrix();
|
||||||
|
SimdVector3 pos(mat.GetTranslation().x,mat.GetTranslation().y,mat.GetTranslation().z);
|
||||||
|
|
||||||
|
SimdMatrix3x3 rotMat(
|
||||||
|
mat.m[0][0],mat.m[0][1],mat.m[0][2],
|
||||||
|
mat.m[1][0],mat.m[1][1],mat.m[1][2],
|
||||||
|
mat.m[2][0],mat.m[2][1],mat.m[2][2]);
|
||||||
|
|
||||||
|
rotMat = rotMat.transpose();
|
||||||
|
SimdTransform trans(rotMat,pos);
|
||||||
|
|
||||||
|
//TODO: check pre or post multiply
|
||||||
|
accumulatedWorldTransform = accumulatedWorldTransform * trans;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -552,6 +579,7 @@ bool ConvertColladaPhysicsToBulletPhysics(const FCDPhysicsSceneNode* inputNode)
|
|||||||
|
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
|
printf("static not yet?\n");
|
||||||
|
|
||||||
//should be static triangle mesh!
|
//should be static triangle mesh!
|
||||||
|
|
||||||
@@ -751,6 +779,9 @@ bool ConvertColladaPhysicsToBulletPhysics(const FCDPhysicsSceneNode* inputNode)
|
|||||||
printf("create Physics Object\n");
|
printf("create Physics Object\n");
|
||||||
//void CreatePhysicsObject(bool isDynamic, float mass, const SimdTransform& startTransform,CollisionShape* shape)
|
//void CreatePhysicsObject(bool isDynamic, float mass, const SimdTransform& startTransform,CollisionShape* shape)
|
||||||
|
|
||||||
|
collisionShape->setLocalScaling(localScaling);
|
||||||
|
ms[numObjects].m_localScaling = localScaling;
|
||||||
|
|
||||||
CreatePhysicsObject(isDynamic, mymass, accumulatedWorldTransform,collisionShape);
|
CreatePhysicsObject(isDynamic, mymass, accumulatedWorldTransform,collisionShape);
|
||||||
|
|
||||||
|
|
||||||
@@ -768,7 +799,10 @@ bool ConvertColladaPhysicsToBulletPhysics(const FCDPhysicsSceneNode* inputNode)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
//Collada-dom
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -780,6 +814,8 @@ GLDebugDrawer debugDrawer;
|
|||||||
|
|
||||||
int main(int argc,char** argv)
|
int main(int argc,char** argv)
|
||||||
{
|
{
|
||||||
|
gCameraUp = SimdVector3(0,0,1);
|
||||||
|
gForwardAxis = 1;
|
||||||
|
|
||||||
///Setup a Physics Simulation Environment
|
///Setup a Physics Simulation Environment
|
||||||
CollisionDispatcher* dispatcher = new CollisionDispatcher();
|
CollisionDispatcher* dispatcher = new CollisionDispatcher();
|
||||||
@@ -792,6 +828,7 @@ int main(int argc,char** argv)
|
|||||||
physicsEnvironmentPtr->setGravity(0,-10,0);
|
physicsEnvironmentPtr->setGravity(0,-10,0);
|
||||||
physicsEnvironmentPtr->setDebugDrawer(&debugDrawer);
|
physicsEnvironmentPtr->setDebugDrawer(&debugDrawer);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// Import Collada 1.4 Physics objects
|
/// Import Collada 1.4 Physics objects
|
||||||
|
|
||||||
@@ -800,7 +837,7 @@ int main(int argc,char** argv)
|
|||||||
|
|
||||||
//char* filename = "friction.dae";
|
//char* filename = "friction.dae";
|
||||||
|
|
||||||
|
#ifdef USE_FCOLLADA
|
||||||
|
|
||||||
FCDocument* document = new FCDocument();
|
FCDocument* document = new FCDocument();
|
||||||
FUStatus status = document->LoadFromFile(filename);
|
FUStatus status = document->LoadFromFile(filename);
|
||||||
@@ -818,7 +855,150 @@ int main(int argc,char** argv)
|
|||||||
printf("ConvertColladaPhysicsToBulletPhysics failed\n");
|
printf("ConvertColladaPhysicsToBulletPhysics failed\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#else
|
||||||
|
//Collada-dom
|
||||||
|
DAE *collada = new DAE;
|
||||||
|
|
||||||
|
|
||||||
|
int res = collada->load(filename);//,docBuffer);
|
||||||
|
if (res != DAE_OK)
|
||||||
|
{
|
||||||
|
printf("DAE/Collada-dom: Couldn't load %s\n",filename);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
|
||||||
|
domCOLLADA *dom = collada->getDom(filename);
|
||||||
|
if ( !dom )
|
||||||
|
{
|
||||||
|
printf("COLLADA File loaded to the dom, but query for the dom assets failed \n" );
|
||||||
|
printf("COLLADA Load Aborted! \n" );
|
||||||
|
delete collada;
|
||||||
|
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
|
||||||
|
//succesfully loaded file, now convert data
|
||||||
|
|
||||||
|
if ( dom->getAsset()->getUp_axis() )
|
||||||
|
{
|
||||||
|
domAsset::domUp_axis * up = dom->getAsset()->getUp_axis();
|
||||||
|
switch( up->getValue() )
|
||||||
|
{
|
||||||
|
case UPAXISTYPE_X_UP:
|
||||||
|
printf(" X is Up Data and Hiearchies must be converted!\n" );
|
||||||
|
printf(" Conversion to X axis Up isn't currently supported!\n" );
|
||||||
|
printf(" COLLADA_RT defaulting to Y Up \n" );
|
||||||
|
break;
|
||||||
|
case UPAXISTYPE_Y_UP:
|
||||||
|
printf(" Y Axis is Up for this file \n" );
|
||||||
|
printf(" COLLADA_RT set to Y Up \n" );
|
||||||
|
|
||||||
|
break;
|
||||||
|
case UPAXISTYPE_Z_UP:
|
||||||
|
printf(" Z Axis is Up for this file \n" );
|
||||||
|
printf(" All Geometry and Hiearchies must be converted!\n" );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Load all the geometry libraries
|
||||||
|
for ( int i = 0; i < dom->getLibrary_geometries_array().getCount(); i++)
|
||||||
|
{
|
||||||
|
domLibrary_geometriesRef libgeom = dom->getLibrary_geometries_array()[i];
|
||||||
|
|
||||||
|
printf(" CrtScene::Reading Geometry Library \n" );
|
||||||
|
for ( int i = 0; i < libgeom->getGeometry_array().getCount(); i++)
|
||||||
|
{
|
||||||
|
//ReadGeometry( );
|
||||||
|
domGeometryRef lib = libgeom->getGeometry_array()[i];
|
||||||
|
|
||||||
|
domMesh *meshElement = lib->getMesh();
|
||||||
|
if (meshElement)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
// Find out how many groups we need to allocate space for
|
||||||
|
int numTriangleGroups = (int)meshElement->getTriangles_array().getCount();
|
||||||
|
int numPolygonGroups = (int)meshElement->getPolygons_array().getCount();
|
||||||
|
int totalGroups = numTriangleGroups + numPolygonGroups;
|
||||||
|
if (totalGroups == 0)
|
||||||
|
{
|
||||||
|
printf("No Triangles or Polygons found int Geometry %s \n", lib->getId() );
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
printf("Found mesh geometry: numTriangleGroups:%i numPolygonGroups:%i\n",numTriangleGroups,numPolygonGroups);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
domConvex_mesh *convexMeshElement = lib->getConvex_mesh();
|
||||||
|
if (convexMeshElement)
|
||||||
|
{
|
||||||
|
printf("found convexmesh element\n");
|
||||||
|
// Find out how many groups we need to allocate space for
|
||||||
|
int numTriangleGroups = (int)convexMeshElement->getTriangles_array().getCount();
|
||||||
|
int numPolygonGroups = (int)convexMeshElement->getPolygons_array().getCount();
|
||||||
|
int totalGroups = numTriangleGroups + numPolygonGroups;
|
||||||
|
if (totalGroups == 0)
|
||||||
|
{
|
||||||
|
printf("No Triangles or Polygons found in ConvexMesh Geometry %s \n", lib->getId() );
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
printf("Found convexmesh geometry: numTriangleGroups:%i numPolygonGroups:%i\n",numTriangleGroups,numPolygonGroups);
|
||||||
|
}
|
||||||
|
}//fi
|
||||||
|
}//for each geometry
|
||||||
|
|
||||||
|
}//for all geometry libraries
|
||||||
|
|
||||||
|
for ( int i = 0; i < dom->getLibrary_physics_scenes_array().getCount(); i++)
|
||||||
|
{
|
||||||
|
domLibrary_physics_scenesRef physicsScenesRef = dom->getLibrary_physics_scenes_array()[i];
|
||||||
|
for (int s=0;s<physicsScenesRef->getPhysics_scene_array().getCount();s++)
|
||||||
|
{
|
||||||
|
domPhysics_sceneRef physicsSceneRef = physicsScenesRef->getPhysics_scene_array()[s];
|
||||||
|
|
||||||
|
for (int m=0;m<physicsSceneRef->getInstance_physics_model_array().getCount();m++)
|
||||||
|
{
|
||||||
|
domInstance_physics_modelRef modelRef = physicsSceneRef->getInstance_physics_model_array()[m];
|
||||||
|
|
||||||
|
for (int r=0;r<modelRef->getInstance_rigid_body_array().getCount();r++)
|
||||||
|
{
|
||||||
|
domInstance_rigid_bodyRef rigidbodyRef = modelRef->getInstance_rigid_body_array()[r];
|
||||||
|
domInstance_rigid_body::domTechnique_commonRef techniqueRef = rigidbodyRef->getTechnique_common();
|
||||||
|
|
||||||
|
if (techniqueRef)
|
||||||
|
{
|
||||||
|
float mass = techniqueRef->getMass()->getValue();
|
||||||
|
bool isDynamics = techniqueRef->getDynamic()->getValue();
|
||||||
|
printf("mass = %f, isDynamics %i\n",mass,isDynamics);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//we don't handle constraints just yet
|
||||||
|
for (int c=0;c<modelRef->getInstance_rigid_constraint_array().getCount();i++)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
clientResetScene();
|
clientResetScene();
|
||||||
|
|
||||||
setCameraDistance(26.f);
|
setCameraDistance(26.f);
|
||||||
@@ -911,7 +1091,8 @@ void renderme()
|
|||||||
}
|
}
|
||||||
|
|
||||||
char extraDebug[125];
|
char extraDebug[125];
|
||||||
sprintf(extraDebug,"islId, Body=%i , %i",physObjects[i]->GetRigidBody()->m_islandTag1,physObjects[i]->GetRigidBody()->m_debugBodyId);
|
|
||||||
|
sprintf(extraDebug,"islandId=%i, Body=%i, ShapeType=%s",physObjects[i]->GetRigidBody()->m_islandTag1,physObjects[i]->GetRigidBody()->m_debugBodyId,physObjects[i]->GetRigidBody()->GetCollisionShape()->GetName());
|
||||||
physObjects[i]->GetRigidBody()->GetCollisionShape()->SetExtraDebugInfo(extraDebug);
|
physObjects[i]->GetRigidBody()->GetCollisionShape()->SetExtraDebugInfo(extraDebug);
|
||||||
GL_ShapeDrawer::DrawOpenGL(m,physObjects[i]->GetRigidBody()->GetCollisionShape(),wireColor,getDebugMode());
|
GL_ShapeDrawer::DrawOpenGL(m,physObjects[i]->GetRigidBody()->GetCollisionShape(),wireColor,getDebugMode());
|
||||||
|
|
||||||
@@ -1136,6 +1317,7 @@ float gOldPickingDist = 0.f;
|
|||||||
RigidBody* pickedBody = 0;//for deactivation state
|
RigidBody* pickedBody = 0;//for deactivation state
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
SimdVector3 GetRayTo(int x,int y)
|
SimdVector3 GetRayTo(int x,int y)
|
||||||
{
|
{
|
||||||
float top = 1.f;
|
float top = 1.f;
|
||||||
@@ -1151,7 +1333,8 @@ SimdVector3 GetRayTo(int x,int y)
|
|||||||
rayForward*= farPlane;
|
rayForward*= farPlane;
|
||||||
|
|
||||||
SimdVector3 rightOffset;
|
SimdVector3 rightOffset;
|
||||||
SimdVector3 vertical(0.f,1.f,0.f);
|
SimdVector3 vertical = gCameraUp;
|
||||||
|
|
||||||
SimdVector3 hor;
|
SimdVector3 hor;
|
||||||
hor = rayForward.cross(vertical);
|
hor = rayForward.cross(vertical);
|
||||||
hor.normalize();
|
hor.normalize();
|
||||||
|
|||||||
@@ -170,6 +170,8 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const CollisionShape* shape, const Sim
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (useWireframeFallback)
|
if (useWireframeFallback)
|
||||||
{
|
{
|
||||||
/// for polyhedral shapes
|
/// for polyhedral shapes
|
||||||
@@ -195,16 +197,10 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const CollisionShape* shape, const Sim
|
|||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (debugMode==IDebugDraw::DBG_DrawText)
|
|
||||||
{
|
|
||||||
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),polyshape->GetName());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (debugMode==IDebugDraw::DBG_DrawFeaturesText)
|
if (debugMode==IDebugDraw::DBG_DrawFeaturesText)
|
||||||
{
|
{
|
||||||
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),polyshape->GetExtraDebugInfo());
|
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),polyshape->GetExtraDebugInfo());
|
||||||
|
|
||||||
glColor3f(1.f, 1.f, 1.f);
|
glColor3f(1.f, 1.f, 1.f);
|
||||||
for (i=0;i<polyshape->GetNumVertices();i++)
|
for (i=0;i<polyshape->GetNumVertices();i++)
|
||||||
{
|
{
|
||||||
@@ -230,6 +226,8 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const CollisionShape* shape, const Sim
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -262,6 +260,17 @@ void GL_ShapeDrawer::DrawOpenGL(float* m, const CollisionShape* shape, const Sim
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glDisable(GL_DEPTH_BUFFER_BIT);
|
||||||
|
if (debugMode==IDebugDraw::DBG_DrawText)
|
||||||
|
{
|
||||||
|
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),shape->GetName());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (debugMode==IDebugDraw::DBG_DrawFeaturesText)
|
||||||
|
{
|
||||||
|
BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),shape->GetExtraDebugInfo());
|
||||||
|
}
|
||||||
|
glEnable(GL_DEPTH_BUFFER_BIT);
|
||||||
|
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|||||||
@@ -105,22 +105,40 @@ void toggleIdle() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "SimdMatrix3x3.h"
|
||||||
|
|
||||||
|
SimdVector3 gCameraUp(0,1,0);
|
||||||
|
int gForwardAxis = 2;
|
||||||
|
|
||||||
void setCamera() {
|
void setCamera() {
|
||||||
|
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
float rele = ele * 0.01745329251994329547;// rads per deg
|
float rele = ele * 0.01745329251994329547;// rads per deg
|
||||||
float razi = azi * 0.01745329251994329547;// rads per deg
|
float razi = azi * 0.01745329251994329547;// rads per deg
|
||||||
eye[0] = DISTANCE * sin(razi) * cos(rele);
|
|
||||||
eye[1] = DISTANCE * sin(rele);
|
|
||||||
eye[2] = DISTANCE * cos(razi) * cos(rele);
|
|
||||||
|
|
||||||
|
|
||||||
|
SimdQuaternion rot(gCameraUp,razi);
|
||||||
|
|
||||||
|
|
||||||
|
SimdVector3 eyePos(0,0,0);
|
||||||
|
eyePos[gForwardAxis] = -DISTANCE;
|
||||||
|
|
||||||
|
SimdVector3 forward(eyePos[0],eyePos[1],eyePos[2]);
|
||||||
|
SimdVector3 right = gCameraUp.cross(forward);
|
||||||
|
SimdQuaternion roll(right,-rele);
|
||||||
|
|
||||||
|
eyePos = SimdMatrix3x3(rot) * SimdMatrix3x3(roll) * eyePos;
|
||||||
|
|
||||||
|
eye[0] = eyePos.getX();
|
||||||
|
eye[1] = eyePos.getY();
|
||||||
|
eye[2] = eyePos.getZ();
|
||||||
|
|
||||||
glFrustum(-1.0, 1.0, -1.0, 1.0, 1.0, 100.0);
|
glFrustum(-1.0, 1.0, -1.0, 1.0, 1.0, 100.0);
|
||||||
gluLookAt(eye[0], eye[1], eye[2],
|
gluLookAt(eye[0], eye[1], eye[2],
|
||||||
center[0], center[1], center[2],
|
center[0], center[1], center[2],
|
||||||
0, 1, 0);
|
gCameraUp.getX(),gCameraUp.getY(),gCameraUp.getZ());
|
||||||
glMatrixMode(GL_MODELVIEW);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ using namespace FUDaeWriter;
|
|||||||
FCDPhysicsSceneNode::FCDPhysicsSceneNode(FCDocument* document) : FCDEntity(document, "PhysicsSceneNode")
|
FCDPhysicsSceneNode::FCDPhysicsSceneNode(FCDocument* document) : FCDEntity(document, "PhysicsSceneNode")
|
||||||
{
|
{
|
||||||
//FIXME: no default values are specified in the 1.4 spec!
|
//FIXME: no default values are specified in the 1.4 spec!
|
||||||
gravity.x = 0.f; gravity.y = -9.8f; gravity.z = 0.f;
|
gravity.x = 0.f; gravity.y = 0.f; gravity.z = -9.8f;
|
||||||
timestep = 1.f;
|
timestep = 1.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,13 +52,13 @@ FUStatus FCDTTranslation::LoadFromXML(xmlNode* node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write the <translate> node to the COLLADA xml document
|
// Write the <translate> node to the COLLADA xml document
|
||||||
xmlNode* FCDTTranslation::WriteToXML(xmlNode* parentNode) const
|
xmlNode* FCDTTranslation::WriteToXML(xmlNode* parentNode) const
|
||||||
{
|
{
|
||||||
string content = FUStringConversion::ToString(translation);
|
string content = FUStringConversion::ToString(translation);
|
||||||
xmlNode* transformNode = FUDaeWriter::AddChild(parentNode, DAE_TRANSLATE_ELEMENT, content);
|
xmlNode* transformNode = FUDaeWriter::AddChild(parentNode, DAE_TRANSLATE_ELEMENT, content);
|
||||||
GetDocument()->WriteAnimatedValueToXML(&translation.x, transformNode, "translation");
|
GetDocument()->WriteAnimatedValueToXML(&translation.x, transformNode, "translation");
|
||||||
return transformNode;
|
return transformNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
FMMatrix44 FCDTTranslation::ToMatrix() const
|
FMMatrix44 FCDTTranslation::ToMatrix() const
|
||||||
{
|
{
|
||||||
@@ -111,14 +111,14 @@ FUStatus FCDTRotation::LoadFromXML(xmlNode* node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write the <rotate> node to the COLLADA xml document
|
// Write the <rotate> node to the COLLADA xml document
|
||||||
xmlNode* FCDTRotation::WriteToXML(xmlNode* parent) const
|
xmlNode* FCDTRotation::WriteToXML(xmlNode* parent) const
|
||||||
{
|
{
|
||||||
globalSBuilder.clear();
|
globalSBuilder.clear();
|
||||||
FUStringConversion::ToString(globalSBuilder, axis); globalSBuilder += ' '; globalSBuilder += angle;
|
FUStringConversion::ToString(globalSBuilder, axis); globalSBuilder += ' '; globalSBuilder += angle;
|
||||||
xmlNode* transformNode = FUDaeWriter::AddChild(parent, DAE_ROTATE_ELEMENT, globalSBuilder);
|
xmlNode* transformNode = FUDaeWriter::AddChild(parent, DAE_ROTATE_ELEMENT, globalSBuilder);
|
||||||
GetDocument()->WriteAnimatedValueToXML(&axis.x, transformNode, "rotation");
|
GetDocument()->WriteAnimatedValueToXML(&axis.x, transformNode, "rotation");
|
||||||
return transformNode;
|
return transformNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
FMMatrix44 FCDTRotation::ToMatrix() const
|
FMMatrix44 FCDTRotation::ToMatrix() const
|
||||||
{
|
{
|
||||||
@@ -174,12 +174,12 @@ FUStatus FCDTScale::LoadFromXML(xmlNode* node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write the <scale> node to the COLLADA xml document
|
// Write the <scale> node to the COLLADA xml document
|
||||||
xmlNode* FCDTScale::WriteToXML(xmlNode* parentNode) const
|
xmlNode* FCDTScale::WriteToXML(xmlNode* parentNode) const
|
||||||
{
|
{
|
||||||
string content = FUStringConversion::ToString(scale);
|
string content = FUStringConversion::ToString(scale);
|
||||||
xmlNode* transformNode = FUDaeWriter::AddChild(parentNode, DAE_SCALE_ELEMENT, content);
|
xmlNode* transformNode = FUDaeWriter::AddChild(parentNode, DAE_SCALE_ELEMENT, content);
|
||||||
GetDocument()->WriteAnimatedValueToXML(&scale.x, transformNode, "scale");
|
GetDocument()->WriteAnimatedValueToXML(&scale.x, transformNode, "scale");
|
||||||
return transformNode;
|
return transformNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
FMMatrix44 FCDTScale::ToMatrix() const
|
FMMatrix44 FCDTScale::ToMatrix() const
|
||||||
@@ -225,12 +225,12 @@ FUStatus FCDTMatrix::LoadFromXML(xmlNode* node)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write the <matrix> node to the COLLADA xml document
|
// Write the <matrix> node to the COLLADA xml document
|
||||||
xmlNode* FCDTMatrix::WriteToXML(xmlNode* parentNode) const
|
xmlNode* FCDTMatrix::WriteToXML(xmlNode* parentNode) const
|
||||||
{
|
{
|
||||||
string content = FUStringConversion::ToString(transform);
|
string content = FUStringConversion::ToString(transform);
|
||||||
xmlNode* transformNode = FUDaeWriter::AddChild(parentNode, DAE_MATRIX_ELEMENT, content);
|
xmlNode* transformNode = FUDaeWriter::AddChild(parentNode, DAE_MATRIX_ELEMENT, content);
|
||||||
GetDocument()->WriteAnimatedValueToXML(&transform[0][0], transformNode, "transform");
|
GetDocument()->WriteAnimatedValueToXML(&transform[0][0], transformNode, "transform");
|
||||||
return transformNode;
|
return transformNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
FCDAnimated* FCDTMatrix::GetAnimated()
|
FCDAnimated* FCDTMatrix::GetAnimated()
|
||||||
@@ -274,14 +274,14 @@ FUStatus FCDTLookAt::LoadFromXML(xmlNode* lookAtNode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write the <lookat> node to the COLLADA xml document
|
// Write the <lookat> node to the COLLADA xml document
|
||||||
xmlNode* FCDTLookAt::WriteToXML(xmlNode* parentNode) const
|
xmlNode* FCDTLookAt::WriteToXML(xmlNode* parentNode) const
|
||||||
{
|
{
|
||||||
globalSBuilder.clear();
|
globalSBuilder.clear();
|
||||||
FUStringConversion::ToString(globalSBuilder, position); globalSBuilder += ' ';
|
FUStringConversion::ToString(globalSBuilder, position); globalSBuilder += ' ';
|
||||||
FUStringConversion::ToString(globalSBuilder, target); globalSBuilder += ' ';
|
FUStringConversion::ToString(globalSBuilder, target); globalSBuilder += ' ';
|
||||||
FUStringConversion::ToString(globalSBuilder, up);
|
FUStringConversion::ToString(globalSBuilder, up);
|
||||||
xmlNode* transformNode = FUDaeWriter::AddChild(parentNode, DAE_LOOKAT_ELEMENT, globalSBuilder);
|
xmlNode* transformNode = FUDaeWriter::AddChild(parentNode, DAE_LOOKAT_ELEMENT, globalSBuilder);
|
||||||
return transformNode;
|
return transformNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
FMMatrix44 FCDTLookAt::ToMatrix() const
|
FMMatrix44 FCDTLookAt::ToMatrix() const
|
||||||
@@ -346,15 +346,15 @@ FUStatus FCDTSkew::LoadFromXML(xmlNode* skewNode)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Write the <lookat> node to the COLLADA xml document
|
// Write the <lookat> node to the COLLADA xml document
|
||||||
xmlNode* FCDTSkew::WriteToXML(xmlNode* parentNode) const
|
xmlNode* FCDTSkew::WriteToXML(xmlNode* parentNode) const
|
||||||
{
|
{
|
||||||
globalSBuilder.clear();
|
globalSBuilder.clear();
|
||||||
globalSBuilder.set(angle); globalSBuilder += ' ';
|
globalSBuilder.set(angle); globalSBuilder += ' ';
|
||||||
FUStringConversion::ToString(globalSBuilder, rotateAxis); globalSBuilder += ' ';
|
FUStringConversion::ToString(globalSBuilder, rotateAxis); globalSBuilder += ' ';
|
||||||
FUStringConversion::ToString(globalSBuilder, aroundAxis);
|
FUStringConversion::ToString(globalSBuilder, aroundAxis);
|
||||||
xmlNode* transformNode = FUDaeWriter::AddChild(parentNode, DAE_SKEW_ELEMENT, globalSBuilder);
|
xmlNode* transformNode = FUDaeWriter::AddChild(parentNode, DAE_SKEW_ELEMENT, globalSBuilder);
|
||||||
GetDocument()->WriteAnimatedValueToXML(&angle, transformNode, "skew");
|
GetDocument()->WriteAnimatedValueToXML(&angle, transformNode, "skew");
|
||||||
return transformNode;
|
return transformNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
FMMatrix44 FCDTSkew::ToMatrix() const
|
FMMatrix44 FCDTSkew::ToMatrix() const
|
||||||
@@ -389,30 +389,30 @@ bool FCDTSkew::IsAnimated() const
|
|||||||
return GetDocument()->IsValueAnimated(&angle);
|
return GetDocument()->IsValueAnimated(&angle);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creates a new COLLADA transform, given a transform type.
|
// Creates a new COLLADA transform, given a transform type.
|
||||||
FCDTransform* FCDTFactory::CreateTransform(FCDocument* document, FCDSceneNode* parent, FCDTransform::Type type)
|
FCDTransform* FCDTFactory::CreateTransform(FCDocument* document, FCDSceneNode* parent, FCDTransform::Type type)
|
||||||
{
|
{
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case FCDTransform::TRANSLATION: return new FCDTTranslation(document, parent);
|
case FCDTransform::TRANSLATION: return new FCDTTranslation(document, parent);
|
||||||
case FCDTransform::ROTATION: return new FCDTRotation(document, parent);
|
case FCDTransform::ROTATION: return new FCDTRotation(document, parent);
|
||||||
case FCDTransform::SCALE: return new FCDTScale(document, parent);
|
case FCDTransform::SCALE: return new FCDTScale(document, parent);
|
||||||
case FCDTransform::SKEW: return new FCDTSkew(document, parent);
|
case FCDTransform::SKEW: return new FCDTSkew(document, parent);
|
||||||
case FCDTransform::MATRIX: return new FCDTMatrix(document, parent);
|
case FCDTransform::MATRIX: return new FCDTMatrix(document, parent);
|
||||||
case FCDTransform::LOOKAT: return new FCDTLookAt(document, parent);
|
case FCDTransform::LOOKAT: return new FCDTLookAt(document, parent);
|
||||||
default: return NULL;
|
default: return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Imports a COLLADA transform, given an XML tree node.
|
// Imports a COLLADA transform, given an XML tree node.
|
||||||
FCDTransform* FCDTFactory::CreateTransform(FCDocument* document, FCDSceneNode* parent, xmlNode* node)
|
FCDTransform* FCDTFactory::CreateTransform(FCDocument* document, FCDSceneNode* parent, xmlNode* node)
|
||||||
{
|
{
|
||||||
FCDTransform* transform = NULL;
|
FCDTransform* transform = NULL;
|
||||||
if (IsEquivalent(node->name, DAE_ROTATE_ELEMENT)) transform = new FCDTRotation(document, parent);
|
if (IsEquivalent(node->name, DAE_ROTATE_ELEMENT)) transform = new FCDTRotation(document, parent);
|
||||||
else if (IsEquivalent(node->name, DAE_TRANSLATE_ELEMENT)) transform = new FCDTTranslation(document, parent);
|
else if (IsEquivalent(node->name, DAE_TRANSLATE_ELEMENT)) transform = new FCDTTranslation(document, parent);
|
||||||
else if (IsEquivalent(node->name, DAE_SCALE_ELEMENT)) transform = new FCDTScale(document, parent);
|
else if (IsEquivalent(node->name, DAE_SCALE_ELEMENT)) transform = new FCDTScale(document, parent);
|
||||||
else if (IsEquivalent(node->name, DAE_SKEW_ELEMENT)) transform = new FCDTSkew(document, parent);
|
else if (IsEquivalent(node->name, DAE_SKEW_ELEMENT)) transform = new FCDTSkew(document, parent);
|
||||||
else if (IsEquivalent(node->name, DAE_MATRIX_ELEMENT)) transform = new FCDTMatrix(document, parent);
|
else if (IsEquivalent(node->name, DAE_MATRIX_ELEMENT)) transform = new FCDTMatrix(document, parent);
|
||||||
else if (IsEquivalent(node->name, DAE_LOOKAT_ELEMENT)) transform = new FCDTLookAt(document, parent);
|
else if (IsEquivalent(node->name, DAE_LOOKAT_ELEMENT)) transform = new FCDTLookAt(document, parent);
|
||||||
return transform;
|
return transform;
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -8,171 +8,174 @@
|
|||||||
Copyright (C) 2005-2006 Autodesk Media Entertainment
|
Copyright (C) 2005-2006 Autodesk Media Entertainment
|
||||||
MIT License: http://www.opensource.org/licenses/mit-license.php
|
MIT License: http://www.opensource.org/licenses/mit-license.php
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "StdAfx.h"
|
#include "StdAfx.h"
|
||||||
#include "FUtils/FUXmlParser.h"
|
#include "FUtils/FUXmlParser.h"
|
||||||
|
|
||||||
#define xmlT(a) (const xmlChar*) (a)
|
#define xmlT(a) (const xmlChar*) (a)
|
||||||
|
|
||||||
namespace FUXmlParser
|
namespace FUXmlParser
|
||||||
{
|
{
|
||||||
// Returns the first child node of a given type
|
// Returns the first child node of a given type
|
||||||
xmlNode* FindChildByType(xmlNode* parent, const char* type)
|
xmlNode* FindChildByType(xmlNode* parent, const char* type)
|
||||||
{
|
{
|
||||||
if (parent != NULL)
|
if (parent != NULL)
|
||||||
{
|
{
|
||||||
for (xmlNode* child = parent->children; child != NULL; child = child->next)
|
for (xmlNode* child = parent->children; child != NULL; child = child->next)
|
||||||
{
|
{
|
||||||
if (child->type == XML_ELEMENT_NODE)
|
if (child->type == XML_ELEMENT_NODE)
|
||||||
{
|
{
|
||||||
if (IsEquivalent(child->name, type)) return child;
|
if (IsEquivalent(child->name, type)) return child;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return the first child node of a given name
|
// return the first child node of a given name
|
||||||
xmlNode* FindChildByName(xmlNode* parent, const char* name)
|
xmlNode* FindChildByName(xmlNode* parent, const char* name)
|
||||||
{
|
{
|
||||||
if (parent != NULL)
|
if (parent != NULL)
|
||||||
{
|
{
|
||||||
for (xmlNode* child = parent->children; child != NULL; child = child->next)
|
for (xmlNode* child = parent->children; child != NULL; child = child->next)
|
||||||
{
|
{
|
||||||
if (child->type == XML_ELEMENT_NODE)
|
if (child->type == XML_ELEMENT_NODE)
|
||||||
{
|
{
|
||||||
string str_name = ReadNodeProperty(child, "name");
|
string str_name = ReadNodeProperty(child, "name");
|
||||||
if (str_name == name) return child;
|
if (str_name == name) return child;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// return the first child node of a given property value
|
// return the first child node of a given property value
|
||||||
xmlNode* FindChildByProperty(xmlNode* parent, const char* prop, const char* val )
|
xmlNode* FindChildByProperty(xmlNode* parent, const char* prop, const char* val )
|
||||||
{
|
{
|
||||||
if (parent != NULL)
|
if (parent != NULL)
|
||||||
{
|
{
|
||||||
for (xmlNode* child = parent->children; child != NULL; child = child->next)
|
for (xmlNode* child = parent->children; child != NULL; child = child->next)
|
||||||
{
|
{
|
||||||
string str_pop = ReadNodeProperty(child, prop);
|
string str_pop = ReadNodeProperty(child, prop);
|
||||||
if (str_pop == val) return child;
|
if (str_pop == val) return child;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return the first node in list of a given property
|
// return the first node in list of a given property
|
||||||
xmlNode* FindNodeInListByProperty(xmlNodeList list, const char* property, const char* prop)
|
xmlNode* FindNodeInListByProperty(xmlNodeList list, const char* property, const char* prop)
|
||||||
{
|
{
|
||||||
for (xmlNodeList::iterator it = list.begin(); it != list.end(); ++it)
|
for (xmlNodeList::iterator it = list.begin(); it != list.end(); ++it)
|
||||||
{
|
{
|
||||||
xmlNode* element = *it;
|
xmlNode* element = *it;
|
||||||
string str_prop = ReadNodeProperty(element, property);
|
string str_prop = ReadNodeProperty(element, property);
|
||||||
if (str_prop == prop) return element;
|
if (str_prop == prop) return element;
|
||||||
|
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieves all the child nodes of a given type
|
// Retrieves all the child nodes of a given type
|
||||||
void FindChildrenByType(xmlNode* parent, const char* type, xmlNodeList& nodes)
|
void FindChildrenByType(xmlNode* parent, const char* type, xmlNodeList& nodes)
|
||||||
{
|
{
|
||||||
if (parent != NULL)
|
if (parent != NULL)
|
||||||
{
|
{
|
||||||
for (xmlNode* child = parent->children; child != NULL; child = child->next)
|
for (xmlNode* child = parent->children; child != NULL; child = child->next)
|
||||||
{
|
{
|
||||||
if (child->type == XML_ELEMENT_NODE)
|
if (child->type == XML_ELEMENT_NODE)
|
||||||
{
|
{
|
||||||
if (IsEquivalent(child->name, type)) nodes.push_back(child);
|
if (IsEquivalent(child->name, type)) nodes.push_back(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns whether the given node has the given property
|
// Returns whether the given node has the given property
|
||||||
bool HasNodeProperty(xmlNode* node, const char* property)
|
bool HasNodeProperty(xmlNode* node, const char* property)
|
||||||
{
|
{
|
||||||
xmlAttr* attribute = xmlHasProp(node, xmlT(property));
|
xmlAttr* attribute = xmlHasProp(node, xmlT(property));
|
||||||
return attribute != NULL;
|
return attribute != NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the string value of a node's property
|
// Returns the string value of a node's property
|
||||||
string ReadNodeProperty(xmlNode* node, const char* property)
|
string ReadNodeProperty(xmlNode* node, const char* property)
|
||||||
{
|
{
|
||||||
string ret;
|
string ret="";
|
||||||
if (node != NULL && property != NULL)
|
if (node != NULL && property != NULL)
|
||||||
{
|
{
|
||||||
xmlChar* data = xmlGetProp(node, xmlT(property));
|
xmlChar* data = xmlGetProp(node, xmlT(property));
|
||||||
if (data != NULL) ret = (const char*) data;
|
if (data != NULL)
|
||||||
xmlFree(data);
|
{
|
||||||
}
|
ret = (const char*) data;
|
||||||
|
}
|
||||||
// Process the string for special characters
|
xmlFree(data);
|
||||||
XmlToString(ret);
|
}
|
||||||
return ret;
|
|
||||||
}
|
// Process the string for special characters
|
||||||
|
XmlToString(ret);
|
||||||
// Returns the CRC value of a node's property
|
return ret;
|
||||||
FUCrc32::crc32 ReadNodePropertyCRC(xmlNode* node, const char* property)
|
}
|
||||||
{
|
|
||||||
FUCrc32::crc32 ret = 0;
|
// Returns the CRC value of a node's property
|
||||||
if (node != NULL && property != NULL)
|
FUCrc32::crc32 ReadNodePropertyCRC(xmlNode* node, const char* property)
|
||||||
{
|
{
|
||||||
xmlChar* data = xmlGetProp(node, xmlT(property));
|
FUCrc32::crc32 ret = 0;
|
||||||
if (data != NULL) ret = FUCrc32::CRC32((const char*) data);
|
if (node != NULL && property != NULL)
|
||||||
xmlFree(data);
|
{
|
||||||
}
|
xmlChar* data = xmlGetProp(node, xmlT(property));
|
||||||
return ret;
|
if (data != NULL) ret = FUCrc32::CRC32((const char*) data);
|
||||||
}
|
xmlFree(data);
|
||||||
|
}
|
||||||
// Returns the text content directly attached to a node
|
return ret;
|
||||||
const char* ReadNodeContentDirect(xmlNode* node)
|
}
|
||||||
{
|
|
||||||
if (node == NULL || node->children == NULL
|
// Returns the text content directly attached to a node
|
||||||
|| node->children->type != XML_TEXT_NODE || node->children->content == NULL) return "";
|
const char* ReadNodeContentDirect(xmlNode* node)
|
||||||
return (const char*) node->children->content;
|
{
|
||||||
}
|
if (node == NULL || node->children == NULL
|
||||||
|
|| node->children->type != XML_TEXT_NODE || node->children->content == NULL) return "";
|
||||||
// Returns the inner text content of a node
|
return (const char*) node->children->content;
|
||||||
string ReadNodeContentFull(xmlNode* node)
|
}
|
||||||
{
|
|
||||||
string ret;
|
// Returns the inner text content of a node
|
||||||
if (node != NULL)
|
string ReadNodeContentFull(xmlNode* node)
|
||||||
{
|
{
|
||||||
xmlChar* content = xmlNodeGetContent(node);
|
string ret;
|
||||||
ret = (const char*) content;
|
if (node != NULL)
|
||||||
xmlFree(content);
|
{
|
||||||
}
|
xmlChar* content = xmlNodeGetContent(node);
|
||||||
return ret;
|
ret = (const char*) content;
|
||||||
}
|
xmlFree(content);
|
||||||
|
}
|
||||||
// Convert a XML string to a text string: handles the '%' character
|
return ret;
|
||||||
void XmlToString(string& s)
|
}
|
||||||
{
|
|
||||||
if (s.find('%') == string::npos) return;
|
// Convert a XML string to a text string: handles the '%' character
|
||||||
|
void XmlToString(string& s)
|
||||||
// Replace all the '%XX' characters by the equivalent hex value
|
{
|
||||||
const char* original = s.c_str();
|
if (s.find('%') == string::npos) return;
|
||||||
uint32 length = (uint32) s.length();
|
|
||||||
char* copy = new char[length],* p = copy;
|
// Replace all the '%XX' characters by the equivalent hex value
|
||||||
for (uint32 i = 0; i < length; ++i, ++p)
|
const char* original = s.c_str();
|
||||||
{
|
uint32 length = (uint32) s.length();
|
||||||
char c = original[i];
|
char* copy = new char[length],* p = copy;
|
||||||
if (c != '%' || i >= length - 2) *p = c;
|
for (uint32 i = 0; i < length; ++i, ++p)
|
||||||
else
|
{
|
||||||
{
|
char c = original[i];
|
||||||
char* dummy;
|
if (c != '%' || i >= length - 2) *p = c;
|
||||||
p[0] = original[i + 1]; p[1] = original[i + 2]; p[2] = 0;
|
else
|
||||||
uint32 v = strtoul(p, &dummy, 16);
|
{
|
||||||
*p = (char) v;
|
char* dummy;
|
||||||
i += 2;
|
p[0] = original[i + 1]; p[1] = original[i + 2]; p[2] = 0;
|
||||||
}
|
uint32 v = strtoul(p, &dummy, 16);
|
||||||
}
|
*p = (char) v;
|
||||||
*p = 0;
|
i += 2;
|
||||||
s = copy;
|
}
|
||||||
}
|
}
|
||||||
};
|
*p = 0;
|
||||||
|
s = copy;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|||||||
@@ -535,6 +535,7 @@ PHY_IPhysicsController* CcdPhysicsController::GetReplica()
|
|||||||
DefaultMotionState::DefaultMotionState()
|
DefaultMotionState::DefaultMotionState()
|
||||||
{
|
{
|
||||||
m_worldTransform.setIdentity();
|
m_worldTransform.setIdentity();
|
||||||
|
m_localScaling.setValue(1.f,1.f,1.f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -552,9 +553,9 @@ void DefaultMotionState::getWorldPosition(float& posX,float& posY,float& posZ)
|
|||||||
|
|
||||||
void DefaultMotionState::getWorldScaling(float& scaleX,float& scaleY,float& scaleZ)
|
void DefaultMotionState::getWorldScaling(float& scaleX,float& scaleY,float& scaleZ)
|
||||||
{
|
{
|
||||||
scaleX = 1.;
|
scaleX = m_localScaling.getX();
|
||||||
scaleY = 1.;
|
scaleY = m_localScaling.getY();
|
||||||
scaleZ = 1.;
|
scaleZ = m_localScaling.getZ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DefaultMotionState::getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)
|
void DefaultMotionState::getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal)
|
||||||
|
|||||||
@@ -208,6 +208,7 @@ class DefaultMotionState : public PHY_IMotionState
|
|||||||
virtual void calculateWorldTransformations();
|
virtual void calculateWorldTransformations();
|
||||||
|
|
||||||
SimdTransform m_worldTransform;
|
SimdTransform m_worldTransform;
|
||||||
|
SimdVector3 m_localScaling;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
AdditionalOptions=" "
|
AdditionalOptions=" "
|
||||||
Optimization="2"
|
Optimization="2"
|
||||||
AdditionalIncludeDirectories=".;..\..;..\..\Bullet;..\..\BulletDynamics;..\..\LinearMath;..\..\Extras\PhysicsInterface\Common;..\..\Extras\ConvexDecomposition;..\..\Glut;..\..\Demos\OpenGL;..\..\Extras\PhysicsInterface\CcdPhysics;..\..\Extras\FCollada;..\..\Extras\FCollada\LibXML\include"
|
AdditionalIncludeDirectories=".;..\..;..\..\Bullet;..\..\BulletDynamics;..\..\LinearMath;..\..\Extras\PhysicsInterface\Common;..\..\Extras\ConvexDecomposition;..\..\Glut;..\..\Demos\OpenGL;..\..\Extras\PhysicsInterface\CcdPhysics;..\..\Extras\FCollada;..\..\Extras\FCollada\LibXML\include;..\..\Extras\COLLADA_DOM\include;..\..\Extras\COLLADA_DOM\include\1.4"
|
||||||
PreprocessorDefinitions="NDEBUG;_CONSOLE;WIN32"
|
PreprocessorDefinitions="NDEBUG;_CONSOLE;WIN32"
|
||||||
StringPooling="true"
|
StringPooling="true"
|
||||||
ExceptionHandling="0"
|
ExceptionHandling="0"
|
||||||
@@ -152,7 +152,7 @@
|
|||||||
Name="VCCLCompilerTool"
|
Name="VCCLCompilerTool"
|
||||||
AdditionalOptions=" "
|
AdditionalOptions=" "
|
||||||
Optimization="0"
|
Optimization="0"
|
||||||
AdditionalIncludeDirectories=".;..\..;..\..\Bullet;..\..\BulletDynamics;..\..\LinearMath;..\..\Extras\PhysicsInterface\Common;..\..\Extras\ConvexDecomposition;..\..\Glut;..\..\Demos\OpenGL;..\..\Extras\PhysicsInterface\CcdPhysics;..\..\Extras\FCollada;..\..\Extras\FCollada\LibXML\include"
|
AdditionalIncludeDirectories=".;..\..;..\..\Bullet;..\..\BulletDynamics;..\..\LinearMath;..\..\Extras\PhysicsInterface\Common;..\..\Extras\ConvexDecomposition;..\..\Glut;..\..\Demos\OpenGL;..\..\Extras\PhysicsInterface\CcdPhysics;..\..\Extras\FCollada;..\..\Extras\FCollada\LibXML\include;..\..\Extras\COLLADA_DOM\include;..\..\Extras\COLLADA_DOM\include\1.4"
|
||||||
PreprocessorDefinitions="_DEBUG;_CONSOLE;WIN32"
|
PreprocessorDefinitions="_DEBUG;_CONSOLE;WIN32"
|
||||||
MinimalRebuild="true"
|
MinimalRebuild="true"
|
||||||
ExceptionHandling="0"
|
ExceptionHandling="0"
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user