diff --git a/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp b/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp index d07c05390..7ddb1c089 100644 --- a/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp +++ b/Demos/CcdPhysicsDemo/CcdPhysicsDemo.cpp @@ -37,36 +37,6 @@ subject to the following restrictions: #include "GLDebugDrawer.h" -//#define COLLADA_PHYSICS_TEST 1 -#ifdef COLLADA_PHYSICS_TEST - -//Collada Physics test -//#define NO_LIBXML //need LIBXML, because FCDocument/FCDPhysicsRigidBody.h needs FUDaeWriter, through FCDPhysicsParameter.hpp -#include "FUtils/FUtils.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDSceneNode.h" -#include "FUtils/FUFileManager.h" -#include "FUtils/FULogFile.h" -#include "FCDocument/FCDPhysicsSceneNode.h" -#include "FCDocument/FCDPhysicsModelInstance.h" -#include "FCDocument/FCDPhysicsRigidBodyInstance.h" -#include "FCDocument/FCDPhysicsRigidBody.h" -#include "FCDocument/FCDGeometryInstance.h" -#include "FCDocument/FCDGeometryMesh.h" -#include "FCDocument/FCDGeometry.h" -#include "FCDocument/FCDPhysicsAnalyticalGeometry.h" - - - - -//aaa - - - - - -#endif //COLLADA_PHYSICS_TEST - @@ -143,349 +113,8 @@ CollisionShape* shapePtr[numShapes] = //////////////////////////////////// -#ifdef COLLADA_PHYSICS_TEST -bool ConvertColladaPhysicsToBulletPhysics(const FCDPhysicsSceneNode* inputNode) -{ - - assert(inputNode); - - /// FRSceneNodeList nodesToDelete; - // FRMeshPhysicsController::StartCooking(); - - FCDPhysicsModelInstanceList models = inputNode->GetInstances(); - - //Go through all of the physics models - for (FCDPhysicsModelInstanceList::iterator itM=models.begin(); itM != models.end(); itM++) - { - - FCDEntityInstanceList& instanceList = (*itM)->GetInstances(); - //create one node per physics model. This node is pretty much only a middle man, - //but better describes the structure we get from the input file - //FRSceneNode* modelNode = new FRSceneNode(); - //modelNode->SetParent(outputNode); - //outputNode->AddChild(modelNode); - //Go through all of the rigid bodies and rigid constraints in that model - - for (FCDEntityInstanceList::iterator itE=instanceList.begin(); itE!=instanceList.end(); itE++) - { - if ((*itE)->GetType() == FCDEntityInstance::PHYSICS_RIGID_CONSTRAINT) - { - //not yet, could add point to point / hinge support easily - } - else - if ((*itE)->GetType() == FCDEntityInstance::PHYSICS_RIGID_BODY) - { - - printf("PHYSICS_RIGID_BODY\n"); - - - //Create a controller per rigid-body - - //FRMeshPhysicsController* controller = new FRMeshPhysicsController(inputNode->GetGravity(), inputNode->GetTimestep()); - FCDPhysicsRigidBodyInstance* rbInstance = (FCDPhysicsRigidBodyInstance*)(*itE); - - FCDSceneNode* targetNode = rbInstance->GetTargetNode(); - - - if (!targetNode) - { - - - //DebugOut("FCTranslator: No target node defined in rigid body instance"); - - //SAFE_DELETE(controller); - - continue; - } - - - //Transfer all the transforms in n into cNode, and bake - //at the same time the scalings. It is necessary to re-translate the - //transforms as they will get deleted when we delete the old node. - //A better way to do this would be to steal the transforms from the old - //nodes, and make sure they're not deleted later, but this is impractical - //right now as we would also have to migrate all the animation curves. - - - //FRTScaleList scaleTransforms; - - uint32 numTransforms = targetNode->GetTransformCount(); - - for (uint32 i=0; iGetTransforms()[i]); - } - - //Then affect all of its geometry instances. - //Collect all the entities inside the entity vector and inside the children nodes -/* - FREntityList childEntities = n->GetEntities(); - FRSceneNodeList childrenToParse = n->GetChildren(); - - while (!childrenToParse.empty()) - { - FRSceneNode* child = *childrenToParse.begin(); - const FREntityList& e = child->GetEntities(); - //add the entities of that child - childEntities.insert(childEntities.end(), e.begin(), e.end()); - //queue the grand-children nodes - childrenToParse.insert(childrenToParse.end(), child->GetChildren().begin(), child->GetChildren().end()); - childrenToParse.erase(childrenToParse.begin()); - - } -*/ - //now check which ones are geometry mesh (right now an entity is only derived by mesh - //but do this to avoid problems in the future) -/* - for (FREntityList::iterator itT = childEntities.begin(); itT != childEntities.end(); itT++) - { - - if ((*itT)->GetType() == FREntity::MESH || (*itT)->GetType() == FREntity::MESH_CONTROLLER) - - { - - FRMesh* cMesh = (FRMesh*)*itT; - - //while we're here, bake the scaling transforms into the meshes - - BakeScalingIntoMesh(cMesh, scaleTransforms); - - controller->AddBindMesh((FRMesh*)*itT); - - } - - } -*/ - - - ///////////////////////////////////////////////////////////////////// - //We're done with the targets. Now take care of the physics shapes. - FCDPhysicsRigidBody* rigidBody = rbInstance->FlattenRigidBody(); - FCDPhysicsMaterial* mat = rigidBody->GetPhysicsMaterial(); - FCDPhysicsShapeList shapes = rigidBody->GetPhysicsShapeList(); - for (uint32 i=0; iGetType();// - //controller->SetDensity(OldShape->GetDensity()); - - - if (OldShape->GetGeometryInstance()) - - { - - FCDGeometry* geoTemp = (FCDGeometry*)(OldShape->GetGeometryInstance()->GetEntity()); - - const FCDGeometryMesh* colladaMesh = geoTemp->GetMesh(); - - - - //FRMesh* cMesh = ToFREntityGeometry(geoTemp); - //BakeScalingIntoMesh(cMesh, scaleTransforms); - - for (uint32 j=0; jGetPolygonsCount(); j++) - { - /* - FRMeshPhysicsShape* NewShape = new FRMeshPhysicsShape(controller); - - if (!NewShape->CreateTriangleMesh(cMesh, j, true)) - - { - - SAFE_DELETE(NewShape); - - continue; - - } - if (mat) - { - NewShape->SetMaterial(mat->GetStaticFriction(), mat->GetDynamicFriction(), mat->GetRestitution()); - //FIXME - //NewShape->material->setFrictionCombineMode(); - //NewShape->material->setSpring(); - } - - controller->AddShape(NewShape); - - */ - } - - - - } - - else - - { - - //FRMeshPhysicsShape* NewShape = new FRMeshPhysicsShape(controller); - - FCDPhysicsAnalyticalGeometry* analGeom = OldShape->GetAnalyticalGeometry(); - - //increse the following value for nicer shapes with more vertices - - uint16 superEllipsoidSubdivisionLevel = 2; - - if (!analGeom) - - continue; - - switch (analGeom->GetGeomType()) - - { - - case FCDPhysicsAnalyticalGeometry::BOX: - - { - - FCDPASBox* box = (FCDPASBox*)analGeom; - - break; - - } - - case FCDPhysicsAnalyticalGeometry::PLANE: - - { - - FCDPASPlane* plane = (FCDPASPlane*)analGeom; - - break; - - } - - case FCDPhysicsAnalyticalGeometry::SPHERE: - - { - - FCDPASSphere* sphere = (FCDPASSphere*)analGeom; - - break; - - } - - case FCDPhysicsAnalyticalGeometry::CYLINDER: - - { - - //FIXME: only using the first radius of the cylinder - - FCDPASCylinder* cylinder = (FCDPASCylinder*)analGeom; - - - break; - - } - - case FCDPhysicsAnalyticalGeometry::CAPSULE: - - { - - //FIXME: only using the first radius of the capsule - - FCDPASCapsule* capsule = (FCDPASCapsule*)analGeom; - - - break; - - } - - case FCDPhysicsAnalyticalGeometry::TAPERED_CAPSULE: - - { - - //FIXME: only using the first radius of the capsule - - FCDPASTaperedCapsule* tcapsule = (FCDPASTaperedCapsule*)analGeom; - - break; - - } - - case FCDPhysicsAnalyticalGeometry::TAPERED_CYLINDER: - - { - - //FIXME: only using the first radius of the cylinder - - FCDPASTaperedCylinder* tcylinder = (FCDPASTaperedCylinder*)analGeom; - - break; - - } - - default: - - { - - break; - - } - - } - - //controller->AddShape(NewShape); - } - - } - - FCDPhysicsParameter* dyn = (FCDPhysicsParameter*)rigidBody->FindParameterByReference(DAE_DYNAMIC_ELEMENT); - - if (dyn) - { - //dyn->GetValue(); - } - - FCDPhysicsParameter* mass = (FCDPhysicsParameter*)rigidBody->FindParameterByReference(DAE_MASS_ELEMENT); - - if (mass) - { - mass->GetValue(); - } - - FCDPhysicsParameter* inertia = (FCDPhysicsParameter*)rigidBody->FindParameterByReference(DAE_INERTIA_ELEMENT); - - if (inertia) - { - inertia->GetValue(); - } - - FCDPhysicsParameter* velocity = (FCDPhysicsParameter*)rigidBody->FindParameterByReference(DAE_VELOCITY_ELEMENT); - - if (velocity) - { - velocity->GetValue(); - } - - FCDPhysicsParameter* angularVelocity = (FCDPhysicsParameter*)rigidBody->FindParameterByReference(DAE_ANGULAR_VELOCITY_ELEMENT); - - if (angularVelocity) - { - angularVelocity->GetValue(); - } - - //controller->SetGlobalPose(n->CalculateWorldTransformation());//?? - - //SAFE_DELETE(rigidBody); - - } - - } - - } - - return true; -} - - - -#endif //COLLADA_PHYSICS_TEST - - -//////////////////////////////////// @@ -494,27 +123,6 @@ GLDebugDrawer debugDrawer; int main(int argc,char** argv) { -#ifdef COLLADA_PHYSICS_TEST - char* filename = "ColladaPhysics.dae"; - FCDocument* document = new FCDocument(); - FUStatus status = document->LoadFromFile(filename); - bool success = status.IsSuccessful(); - printf ("Collada import %i\n",success); - - if (success) - { - const FCDPhysicsSceneNode* physicsSceneRoot = document->GetPhysicsSceneRoot(); - if (ConvertColladaPhysicsToBulletPhysics( physicsSceneRoot )) - { - printf("ConvertColladaPhysicsToBulletPhysics successfull\n"); - } else - { - printf("ConvertColladaPhysicsToBulletPhysics failed\n"); - } - - - } -#endif //COLLADA_PHYSICS_TEST CollisionDispatcher* dispatcher = new CollisionDispatcher(); diff --git a/Demos/ColladaDemo/ColladaDemo.cpp b/Demos/ColladaDemo/ColladaDemo.cpp index 8d0060fa4..79df38257 100644 --- a/Demos/ColladaDemo/ColladaDemo.cpp +++ b/Demos/ColladaDemo/ColladaDemo.cpp @@ -37,7 +37,7 @@ subject to the following restrictions: #include "GLDebugDrawer.h" -//#define COLLADA_PHYSICS_TEST 1 +#define COLLADA_PHYSICS_TEST 1 #ifdef COLLADA_PHYSICS_TEST //Collada Physics test @@ -57,8 +57,6 @@ subject to the following restrictions: #include "FCDocument/FCDPhysicsAnalyticalGeometry.h" - - //aaa @@ -274,7 +272,6 @@ bool ConvertColladaPhysicsToBulletPhysics(const FCDPhysicsSceneNode* inputNode) if (OldShape->GetGeometryInstance()) - { FCDGeometry* geoTemp = (FCDGeometry*)(OldShape->GetGeometryInstance()->GetEntity()); @@ -288,6 +285,7 @@ bool ConvertColladaPhysicsToBulletPhysics(const FCDPhysicsSceneNode* inputNode) for (uint32 j=0; jGetPolygonsCount(); j++) { + /* FRMeshPhysicsShape* NewShape = new FRMeshPhysicsShape(controller); @@ -436,14 +434,16 @@ bool ConvertColladaPhysicsToBulletPhysics(const FCDPhysicsSceneNode* inputNode) if (dyn) { - //dyn->GetValue(); + bool* mydyn = dyn->GetValue(); + printf("mydyn %i\n",*mydyn); } FCDPhysicsParameter* mass = (FCDPhysicsParameter*)rigidBody->FindParameterByReference(DAE_MASS_ELEMENT); if (mass) { - mass->GetValue(); + float* mymass = mass->GetValue(); + printf("RB mass:%f\n",*mymass); } FCDPhysicsParameter* inertia = (FCDPhysicsParameter*)rigidBody->FindParameterByReference(DAE_INERTIA_ELEMENT); @@ -495,7 +495,7 @@ int main(int argc,char** argv) { #ifdef COLLADA_PHYSICS_TEST - char* filename = "ColladaPhysics.dae"; + char* filename = "analyticalGeomPhysicsTest.dae";//ColladaPhysics.dae"; FCDocument* document = new FCDocument(); FUStatus status = document->LoadFromFile(filename); bool success = status.IsSuccessful(); diff --git a/Extras/ConvexDecomposition/ConvexBuilder.cpp b/Extras/ConvexDecomposition/ConvexBuilder.cpp index d1bb0908c..e0539898d 100644 --- a/Extras/ConvexDecomposition/ConvexBuilder.cpp +++ b/Extras/ConvexDecomposition/ConvexBuilder.cpp @@ -290,7 +290,7 @@ unsigned int ConvexBuilder::process(const DecompDesc &desc) hdesc.mVertexStride = sizeof(float)*3; hdesc.mMaxVertices = desc.mMaxVertices; // maximum number of vertices allowed in the output - if ( desc.mSkinWidth > 0 ) + if ( desc.mSkinWidth ) { hdesc.mSkinWidth = desc.mSkinWidth; hdesc.SetHullFlag(QF_SKIN_WIDTH); // do skin width computation. diff --git a/Extras/FCollada/FCDocument/FCDPhysicsShape.cpp b/Extras/FCollada/FCDocument/FCDPhysicsShape.cpp index 3b36a1624..9b55c592c 100644 --- a/Extras/FCollada/FCDocument/FCDPhysicsShape.cpp +++ b/Extras/FCollada/FCDocument/FCDPhysicsShape.cpp @@ -167,15 +167,18 @@ FUStatus FCDPhysicsShape::LoadFromXML(xmlNode* physicsShapeNode) else { FCDTransform* transform = FCDTFactory::CreateTransform(GetDocument(), NULL, child); - if (transform != NULL && (transform->GetType() != FCDTransform::TRANSLATION - || transform->GetType() != FCDTransform::ROTATION || transform->GetType() != FCDTransform::SCALE)) + if (transform) { - SAFE_DELETE(transform); - } - else - { - transforms.push_back(transform); - status.AppendStatus(transform->LoadFromXML(child)); + if (transform != NULL && (transform->GetType() != FCDTransform::TRANSLATION + || transform->GetType() != FCDTransform::ROTATION || transform->GetType() != FCDTransform::SCALE)) + { + SAFE_DELETE(transform); + } + else + { + transforms.push_back(transform); + status.AppendStatus(transform->LoadFromXML(child)); + } } } } diff --git a/Extras/FCollada/FMath/FMArray.h b/Extras/FCollada/FMath/FMArray.h index dd77ca902..6a18d873a 100644 --- a/Extras/FCollada/FMath/FMArray.h +++ b/Extras/FCollada/FMath/FMArray.h @@ -36,7 +36,7 @@ public: /** Copy constructor. @param copy The dynamically-sized array to copy the values from. */ - vector(const std::vector& copy) : std::vector(copy) {} + vector(const std::vector& copy) : std::vector(copy) {} /** Constructor: Builds a dynamically-sized array from a constant-sized array. @param values A constant-sized array of floating-point values. diff --git a/Extras/FCollada/FUtils/FUFileManager.cpp b/Extras/FCollada/FUtils/FUFileManager.cpp index 71fe1e2a4..82a7f62ab 100644 --- a/Extras/FCollada/FUtils/FUFileManager.cpp +++ b/Extras/FCollada/FUtils/FUFileManager.cpp @@ -237,7 +237,7 @@ fstring FUFileManager::MakeFilePathAbsolute(const fstring& _filePath) if (filePath.size() < 2 || (filePath[1] != ':' && filePath[1] != '|')) { - filePath.insert(0, '/'); + filePath.insert(0, "/");//'/'); } } diff --git a/Extras/FCollada/FUtils/FUUniqueStringMap.h b/Extras/FCollada/FUtils/FUUniqueStringMap.h index 03364c2b7..aafb31668 100644 --- a/Extras/FCollada/FUtils/FUUniqueStringMap.h +++ b/Extras/FCollada/FUtils/FUUniqueStringMap.h @@ -50,7 +50,7 @@ void FUUniqueStringMapT::AddUniqueString(typename Builder::String& want { // Attempt to generate a new string by appending an increasing counter. uint32 counter = 2; - static const maxCounter = 256; + static const int maxCounter = 256; Builder buffer; buffer.reserve(wantedStr.length() + 5); do