diff --git a/BulletDocs.chi b/BulletDocs.chi deleted file mode 100644 index e489c5472..000000000 Binary files a/BulletDocs.chi and /dev/null differ diff --git a/BulletDocs.chm b/BulletDocs.chm deleted file mode 100644 index 87c0514ce..000000000 Binary files a/BulletDocs.chm and /dev/null differ diff --git a/Demos/BasicSample/BasicSample.cpp b/Demos/BasicSample/BasicSample.cpp deleted file mode 100644 index 9cb82d52e..000000000 --- a/Demos/BasicSample/BasicSample.cpp +++ /dev/null @@ -1,793 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#include "CcdPhysicsEnvironment.h" -#include "CcdPhysicsController.h" -#include "MyMotionState.h" -#include "CollisionShapes/BoxShape.h" -#include "CollisionShapes/SphereShape.h" -#include "CollisionShapes/ConeShape.h" -#include "CollisionShapes/Simplex1to4Shape.h" -#include "CollisionShapes/EmptyShape.h" - -#include "Dynamics/RigidBody.h" -#include "CollisionDispatch/CollisionDispatcher.h" -#include "BroadphaseCollision/SimpleBroadphase.h" -#include "BroadphaseCollision/AxisSweep3.h" -#include "ConstraintSolver/Point2PointConstraint.h" -#include "ConstraintSolver/HingeConstraint.h" - -#include "quickprof.h" -#include "PrintfDebugDrawer.h" - - -#include "PHY_Pro.h" -#include //printf debugging - - -int getDebugMode() -{ - return IDebugDraw::DBG_ProfileTimings; -} - -//make up for lack of glut and camera -float eye[3]={10.f,0.f,0.f}; -int glutScreenWidth=640; -int glutScreenHeight=480; - - -#ifdef _DEBUG -const int numObjects = 22; -#else -const int numObjects = 120; -#endif - -const int maxNumObjects = 450; - -MyMotionState ms[maxNumObjects]; -CcdPhysicsController* physObjects[maxNumObjects] = {0,0,0,0}; -int shapeIndex[maxNumObjects]; -CcdPhysicsEnvironment* physicsEnvironmentPtr = 0; - - -#define CUBE_HALF_EXTENTS 1 - -#define EXTRA_HEIGHT -20.f -static const int numShapes = 4; - -CollisionShape* shapePtr[numShapes] = -{ - new BoxShape (SimdVector3(50,10,50)), - new BoxShape (SimdVector3(CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS)), - new SphereShape (CUBE_HALF_EXTENTS- 0.05f), - - //new ConeShape(CUBE_HALF_EXTENTS,2.f*CUBE_HALF_EXTENTS), - //new BU_Simplex1to4(SimdPoint3(-1,-1,-1),SimdPoint3(1,-1,-1),SimdPoint3(-1,1,-1),SimdPoint3(0,0,1)), - - //new EmptyShape(), - - new BoxShape (SimdVector3(0.4f,1.f,0.8f)) - -}; - -void clientResetScene(); -void simulateMe(); -void clientDisplay() -{ -} -void clientMoveAndDisplay() -{ -} -PrintfDebugDrawer debugDrawer; - -int main(int argc,char** argv) -{ - - - - CollisionDispatcher* dispatcher = new CollisionDispatcher(); - - - SimdVector3 worldAabbMin(-10000,-10000,-10000); - SimdVector3 worldAabbMax(10000,10000,10000); - - BroadphaseInterface* broadphase = new AxisSweep3(worldAabbMin,worldAabbMax); - //BroadphaseInterface* broadphase = new SimpleBroadphase(); - - physicsEnvironmentPtr = new CcdPhysicsEnvironment(dispatcher,broadphase); - physicsEnvironmentPtr->setDeactivationTime(2.f); - - - physicsEnvironmentPtr->setGravity(0,-10,0); - PHY_ShapeProps shapeProps; - - shapeProps.m_do_anisotropic = false; - shapeProps.m_do_fh = false; - shapeProps.m_do_rot_fh = false; - shapeProps.m_friction_scaling[0] = 1.; - shapeProps.m_friction_scaling[1] = 1.; - shapeProps.m_friction_scaling[2] = 1.; - - shapeProps.m_inertia = 1.f; - shapeProps.m_lin_drag = 0.2f; - shapeProps.m_ang_drag = 0.1f; - shapeProps.m_mass = 10.0f; - - PHY_MaterialProps materialProps; - materialProps.m_friction = 10.5f; - materialProps.m_restitution = 0.0f; - - CcdConstructionInfo ccdObjectCi; - ccdObjectCi.m_friction = 0.5f; - - ccdObjectCi.m_linearDamping = shapeProps.m_lin_drag; - ccdObjectCi.m_angularDamping = shapeProps.m_ang_drag; - - SimdTransform tr; - tr.setIdentity(); - - int i; - for (i=0;i0) - { - shapeIndex[i] = 1;//sphere - } - else - shapeIndex[i] = 0; - } - - - - - for (i=0;iSetMargin(0.05f); - - - - bool isDyna = i>0; - //if (i==1) - // isDyna=false; - - if (0)//i==1) - { - SimdQuaternion orn(0,0,0.1*SIMD_HALF_PI); - ms[i].setWorldOrientation(orn.x(),orn.y(),orn.z(),orn[3]); - } - - - if (i>0) - { - - switch (i) - { - case 1: - { - ms[i].setWorldPosition(0,10,0); - //for testing, rotate the ground cube so the stack has to recover a bit - - break; - } - case 2: - { - ms[i].setWorldPosition(0,8,2); - break; - } - default: - ms[i].setWorldPosition(0,i*CUBE_HALF_EXTENTS*2 - CUBE_HALF_EXTENTS,0); - } - - - SimdQuaternion quat; - SimdVector3 axis(0.f,0.f,1.f); - SimdScalar angle=0.5f; - - quat.setRotation(axis,angle); - - ms[i].setWorldOrientation(quat.getX(),quat.getY(),quat.getZ(),quat[3]); - - - - } else - { - ms[i].setWorldPosition(0,-100+EXTRA_HEIGHT,0); - - } - - ccdObjectCi.m_MotionState = &ms[i]; - ccdObjectCi.m_gravity = SimdVector3(0,0,0); - ccdObjectCi.m_localInertiaTensor =SimdVector3(0,0,0); - if (!isDyna) - { - shapeProps.m_mass = 0.f; - ccdObjectCi.m_mass = shapeProps.m_mass; - } - else - { - shapeProps.m_mass = 1.f; - ccdObjectCi.m_mass = shapeProps.m_mass; - } - - - SimdVector3 localInertia; - if (shapePtr[shapeIndex[i]]->GetShapeType() == EMPTY_SHAPE_PROXYTYPE) - { - //take inertia from first shape - shapePtr[1]->CalculateLocalInertia(shapeProps.m_mass,localInertia); - } else - { - shapePtr[shapeIndex[i]]->CalculateLocalInertia(shapeProps.m_mass,localInertia); - } - ccdObjectCi.m_localInertiaTensor = localInertia; - - ccdObjectCi.m_collisionShape = shapePtr[shapeIndex[i]]; - - - physObjects[i]= new CcdPhysicsController( ccdObjectCi); - physicsEnvironmentPtr->addCcdPhysicsController( physObjects[i]); - - if (i==1) - { - //physObjects[i]->SetAngularVelocity(0,0,-2,true); - } - - physicsEnvironmentPtr->setDebugDrawer(&debugDrawer); - - } - - - //create a constraint - { - //physObjects[i]->SetAngularVelocity(0,0,-2,true); - int constraintId; - - //0.0f, -1.0f, 1.0f - - float pivotX=CUBE_HALF_EXTENTS, - pivotY=-CUBE_HALF_EXTENTS, - pivotZ=CUBE_HALF_EXTENTS; - - float axisX=1,axisY=0,axisZ=0; - - /*constraintId =physicsEnvironmentPtr->createConstraint( - physObjects[1], - //0, - physObjects[2], - //PHY_POINT2POINT_CONSTRAINT, - PHY_LINEHINGE_CONSTRAINT, - pivotX,pivotY,pivotZ, - axisX,axisY,axisZ - ); - - */ - - HingeConstraint* hinge = 0; - - SimdVector3 pivotInA(CUBE_HALF_EXTENTS,-CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS); - SimdVector3 pivotInB(-CUBE_HALF_EXTENTS,-CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS); - SimdVector3 axisInA(0,1,0); - SimdVector3 axisInB(0,-1,0); - - RigidBody* rb0 = physObjects[1]->GetRigidBody(); - RigidBody* rb1 = physObjects[2]->GetRigidBody(); - - hinge = new HingeConstraint( - *rb0, - *rb1,pivotInA,pivotInB,axisInA,axisInB); - - physicsEnvironmentPtr->m_constraints.push_back(hinge); - - hinge->SetUserConstraintId(100); - hinge->SetUserConstraintType(PHY_LINEHINGE_CONSTRAINT); - - } - - - - - clientResetScene(); - - while (1) - { - - simulateMe(); - } - - -} - -//to be implemented by the demo - - -void simulateMe() -{ - float deltaTime = 1.f/60.f; - physicsEnvironmentPtr->proceedDeltaTime(0.f,deltaTime); - - - debugDrawer.SetDebugMode(getDebugMode()); - - //render the hinge axis - { - SimdVector3 color(1,0,0); - SimdVector3 dirLocal(0,1,0); - SimdVector3 pivotInA(CUBE_HALF_EXTENTS,-CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS); - SimdVector3 pivotInB(-CUBE_HALF_EXTENTS,-CUBE_HALF_EXTENTS,CUBE_HALF_EXTENTS); - SimdVector3 from = physObjects[1]->GetRigidBody()->getCenterOfMassTransform()(pivotInA); - SimdVector3 fromB = physObjects[2]->GetRigidBody()->getCenterOfMassTransform()(pivotInB); - SimdVector3 dirWorldA = physObjects[1]->GetRigidBody()->getCenterOfMassTransform().getBasis() * dirLocal ; - SimdVector3 dirWorldB = physObjects[2]->GetRigidBody()->getCenterOfMassTransform().getBasis() * dirLocal ; - debugDrawer.DrawLine(from,from+dirWorldA,color); - debugDrawer.DrawLine(fromB,fromB+dirWorldB,color); - } - - float m[16]; - int i; - - - if (getDebugMode() & IDebugDraw::DBG_DisableBulletLCP) - { - //don't use Bullet, use quickstep - physicsEnvironmentPtr->setSolverType(0); - } else - { - //Bullet LCP solver - physicsEnvironmentPtr->setSolverType(1); - } - - - bool isSatEnabled = (getDebugMode() & IDebugDraw::DBG_EnableSatComparison); - - physicsEnvironmentPtr->EnableSatCollisionDetection(isSatEnabled); - - - - - for (i=0;iGetRigidBody()->GetActivationState() == 1) //active - { - if (i & 1) - { - wireColor += SimdVector3 (1.f,0.f,0.f); - } else - { - wireColor += SimdVector3 (.5f,0.f,0.f); - } - } - if (physObjects[i]->GetRigidBody()->GetActivationState() == 2) //ISLAND_SLEEPING - { - if (i & 1) - { - wireColor += SimdVector3 (0.f,1.f, 0.f); - } else - { - wireColor += SimdVector3 (0.f,0.5f,0.f); - } - } - - char extraDebug[125]; - sprintf(extraDebug,"islId, Body=%i , %i",physObjects[i]->GetRigidBody()->m_islandTag1,physObjects[i]->GetRigidBody()->m_debugBodyId); - physObjects[i]->GetRigidBody()->GetCollisionShape()->SetExtraDebugInfo(extraDebug); - - //GL_ShapeDrawer::DrawOpenGL(m,physObjects[i]->GetRigidBody()->GetCollisionShape(),wireColor,getDebugMode()); - - } - - - if (!(getDebugMode() & IDebugDraw::DBG_NoHelpText)) - { - - - - - float xOffset = 10.f; - float yStart = 20.f; - - float yIncr = -2.f; - - char buf[124]; - - //glColor3f(0, 0, 0); - -#ifdef USE_QUICKPROF - if ( getDebugMode() & IDebugDraw::DBG_ProfileTimings) - { - static int counter = 0; - counter++; - std::map::iterator iter; - for (iter = Profiler::mProfileBlocks.begin(); iter != Profiler::mProfileBlocks.end(); ++iter) - { - char blockTime[128]; - sprintf(blockTime, "%s: %lf",&((*iter).first[0]),Profiler::getBlockTime((*iter).first, Profiler::BLOCK_CYCLE_SECONDS));//BLOCK_TOTAL_PERCENT)); - printf(blockTime); - - - } - } - - -#endif //USE_QUICKPROF - - - - -/* - glRasterPos3f(xOffset,yStart,0); - sprintf(buf,"mouse to interact"); - BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); - yStart += yIncr; - - glRasterPos3f(xOffset,yStart,0); - sprintf(buf,"space to reset"); - BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); - yStart += yIncr; - - glRasterPos3f(xOffset,yStart,0); - sprintf(buf,"c to show contact points"); - BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); - yStart += yIncr; - - glRasterPos3f(xOffset,yStart,0); - sprintf(buf,"cursor keys and z,x to navigate"); - BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); - yStart += yIncr; - - glRasterPos3f(xOffset,yStart,0); - sprintf(buf,"i to toggle simulation, s single step"); - BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); - yStart += yIncr; - - glRasterPos3f(xOffset,yStart,0); - sprintf(buf,"q to quit"); - BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); - yStart += yIncr; - - glRasterPos3f(xOffset,yStart,0); - sprintf(buf,"d to toggle deactivation"); - BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); - yStart += yIncr; - - glRasterPos3f(xOffset,yStart,0); - sprintf(buf,". to shoot primitive"); - BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); - yStart += yIncr; - - glRasterPos3f(xOffset,yStart,0); - sprintf(buf,"h to toggle help text"); - BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); - yStart += yIncr; - - bool useBulletLCP = !(getDebugMode() & IDebugDraw::DBG_DisableBulletLCP); - - glRasterPos3f(xOffset,yStart,0); - sprintf(buf,"m Bullet GJK = %i",!isSatEnabled); - BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); - yStart += yIncr; - - glRasterPos3f(xOffset,yStart,0); - sprintf(buf,"n Bullet LCP = %i",useBulletLCP); - BMF_DrawString(BMF_GetFont(BMF_kHelvetica10),buf); - yStart += yIncr; - - */ - - - - } - -} - - - -///make this positive to show stack falling from a distance -///this shows the penalty tresholds in action, springy/spungy look - - - -void clientResetScene() -{ - - int i; - for (i=0;i0) - { - - if ((getDebugMode() & IDebugDraw::DBG_NoHelpText)) - { - if (physObjects[i]->GetRigidBody()->GetCollisionShape()->GetShapeType() == BOX_SHAPE_PROXYTYPE) - { - physObjects[i]->GetRigidBody()->SetCollisionShape(shapePtr[2]); - } else - { - physObjects[i]->GetRigidBody()->SetCollisionShape(shapePtr[1]); - } - - BroadphaseProxy* bpproxy = physObjects[i]->GetRigidBody()->m_broadphaseHandle; - physicsEnvironmentPtr->GetBroadphase()->CleanProxyFromPairs(bpproxy); - } - - //stack them - int colsize = 10; - int row = (i*CUBE_HALF_EXTENTS*2)/(colsize*2*CUBE_HALF_EXTENTS); - int row2 = row; - int col = (i)%(colsize)-colsize/2; - - - if (col>3) - { - col=11; - row2 |=1; - } - physObjects[i]->setPosition(col*2*CUBE_HALF_EXTENTS + (row2%2)*CUBE_HALF_EXTENTS, - row*2*CUBE_HALF_EXTENTS+CUBE_HALF_EXTENTS+EXTRA_HEIGHT,0); - physObjects[i]->setOrientation(0,0,0,1); - physObjects[i]->SetLinearVelocity(0,0,0,false); - physObjects[i]->SetAngularVelocity(0,0,0,false); - } else - { - ms[i].setWorldPosition(0,-10-EXTRA_HEIGHT,0); - } - } -} - -void shootBox(const SimdVector3& destination) -{ - int i = numObjects-1; - - float speed = 40.f; - SimdVector3 linVel(destination[0]-eye[0],destination[1]-eye[1],destination[2]-eye[2]); - linVel.normalize(); - linVel*=speed; - - physObjects[i]->setPosition(eye[0],eye[1],eye[2]); - physObjects[i]->setOrientation(0,0,0,1); - physObjects[i]->SetLinearVelocity(linVel[0],linVel[1],linVel[2],false); - physObjects[i]->SetAngularVelocity(0,0,0,false); -} - -void clientKeyboard(unsigned char key, int x, int y) -{ - - if (key == '.') - { - shootBox(SimdVector3(0,0,0)); - } - //defaultKeyboard(key, x, y); -} - -int gPickingConstraintId = 0; -SimdVector3 gOldPickingPos; -float gOldPickingDist = 0.f; -RigidBody* pickedBody = 0;//for deactivation state - - -SimdVector3 GetRayTo(int x,int y) -{ - float top = 1.f; - float bottom = -1.f; - float nearPlane = 1.f; - float tanFov = (top-bottom)*0.5f / nearPlane; - float fov = 2.0 * atanf (tanFov); - - SimdVector3 rayFrom(eye[0],eye[1],eye[2]); - SimdVector3 rayForward = -rayFrom; - rayForward.normalize(); - float farPlane = 600.f; - rayForward*= farPlane; - - SimdVector3 rightOffset; - SimdVector3 vertical(0.f,1.f,0.f); - SimdVector3 hor; - hor = rayForward.cross(vertical); - hor.normalize(); - vertical = hor.cross(rayForward); - vertical.normalize(); - - float tanfov = tanf(0.5f*fov); - hor *= 2.f * farPlane * tanfov; - vertical *= 2.f * farPlane * tanfov; - SimdVector3 rayToCenter = rayFrom + rayForward; - SimdVector3 dHor = hor * 1.f/float(glutScreenWidth); - SimdVector3 dVert = vertical * 1.f/float(glutScreenHeight); - SimdVector3 rayTo = rayToCenter - 0.5f * hor + 0.5f * vertical; - rayTo += x * dHor; - rayTo -= y * dVert; - return rayTo; -} -void clientMouseFunc(int button, int state, int x, int y) -{ - //printf("button %i, state %i, x=%i,y=%i\n",button,state,x,y); - //button 0, state 0 means left mouse down - - SimdVector3 rayTo = GetRayTo(x,y); - - switch (button) - { - case 2: - { - if (state==0) - { - shootBox(rayTo); - } - break; - }; - case 1: - { - if (state==0) - { - //apply an impulse - if (physicsEnvironmentPtr) - { - float hit[3]; - float normal[3]; - PHY_IPhysicsController* hitObj = physicsEnvironmentPtr->rayTest(0,eye[0],eye[1],eye[2],rayTo.getX(),rayTo.getY(),rayTo.getZ(),hit[0],hit[1],hit[2],normal[0],normal[1],normal[2]); - if (hitObj) - { - CcdPhysicsController* physCtrl = static_cast(hitObj); - RigidBody* body = physCtrl->GetRigidBody(); - if (body) - { - body->SetActivationState(ACTIVE_TAG); - SimdVector3 impulse = rayTo; - impulse.normalize(); - float impulseStrength = 10.f; - impulse *= impulseStrength; - SimdVector3 relPos( - hit[0] - body->getCenterOfMassPosition().getX(), - hit[1] - body->getCenterOfMassPosition().getY(), - hit[2] - body->getCenterOfMassPosition().getZ()); - - body->applyImpulse(impulse,relPos); - } - - } - - } - - } else - { - - } - break; - } - case 0: - { - if (state==0) - { - //add a point to point constraint for picking - if (physicsEnvironmentPtr) - { - float hit[3]; - float normal[3]; - PHY_IPhysicsController* hitObj = physicsEnvironmentPtr->rayTest(0,eye[0],eye[1],eye[2],rayTo.getX(),rayTo.getY(),rayTo.getZ(),hit[0],hit[1],hit[2],normal[0],normal[1],normal[2]); - if (hitObj) - { - - CcdPhysicsController* physCtrl = static_cast(hitObj); - RigidBody* body = physCtrl->GetRigidBody(); - - if (body) - { - pickedBody = body; - pickedBody->SetActivationState(DISABLE_DEACTIVATION); - - SimdVector3 pickPos(hit[0],hit[1],hit[2]); - - SimdVector3 localPivot = body->getCenterOfMassTransform().inverse() * pickPos; - - gPickingConstraintId = physicsEnvironmentPtr->createConstraint(physCtrl,0,PHY_POINT2POINT_CONSTRAINT, - localPivot.getX(), - localPivot.getY(), - localPivot.getZ(), - 0,0,0); - //printf("created constraint %i",gPickingConstraintId); - - //save mouse position for dragging - gOldPickingPos = rayTo; - - - SimdVector3 eyePos(eye[0],eye[1],eye[2]); - - gOldPickingDist = (pickPos-eyePos).length(); - - Point2PointConstraint* p2p = static_cast(physicsEnvironmentPtr->getConstraintById(gPickingConstraintId)); - if (p2p) - { - //very weak constraint for picking - p2p->m_setting.m_tau = 0.1f; - } - } - } - } - } else - { - if (gPickingConstraintId && physicsEnvironmentPtr) - { - physicsEnvironmentPtr->removeConstraint(gPickingConstraintId); - //printf("removed constraint %i",gPickingConstraintId); - gPickingConstraintId = 0; - pickedBody->ForceActivationState(ACTIVE_TAG); - pickedBody->m_deactivationTime = 0.f; - pickedBody = 0; - - - } - } - - break; - - } - default: - { - } - } - -} - -void clientMotionFunc(int x,int y) -{ - - if (gPickingConstraintId && physicsEnvironmentPtr) - { - - //move the constraint pivot - - Point2PointConstraint* p2p = static_cast(physicsEnvironmentPtr->getConstraintById(gPickingConstraintId)); - if (p2p) - { - //keep it at the same picking distance - - SimdVector3 newRayTo = GetRayTo(x,y); - SimdVector3 eyePos(eye[0],eye[1],eye[2]); - SimdVector3 dir = newRayTo-eyePos; - dir.normalize(); - dir *= gOldPickingDist; - - SimdVector3 newPos = eyePos + dir; - p2p->SetPivotB(newPos); - } - - } -} diff --git a/Demos/BasicSample/Jamfile b/Demos/BasicSample/Jamfile deleted file mode 100644 index 65fec5333..000000000 --- a/Demos/BasicSample/Jamfile +++ /dev/null @@ -1,3 +0,0 @@ -SubDir TOP Demos BasicSample ; - -BulletBasicDemo BasicSample : [ Wildcard *.h *.cpp ] ; diff --git a/Demos/BasicSample/MyMotionState.cpp b/Demos/BasicSample/MyMotionState.cpp deleted file mode 100644 index 956aac1ec..000000000 --- a/Demos/BasicSample/MyMotionState.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#include "MyMotionState.h" -#include "SimdPoint3.h" - -MyMotionState::MyMotionState() -{ - m_worldTransform.setIdentity(); -} - - -MyMotionState::~MyMotionState() -{ - -} - -void MyMotionState::getWorldPosition(float& posX,float& posY,float& posZ) -{ - posX = m_worldTransform.getOrigin().x(); - posY = m_worldTransform.getOrigin().y(); - posZ = m_worldTransform.getOrigin().z(); -} - -void MyMotionState::getWorldScaling(float& scaleX,float& scaleY,float& scaleZ) -{ - scaleX = 1.; - scaleY = 1.; - scaleZ = 1.; -} - -void MyMotionState::getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal) -{ - quatIma0 = m_worldTransform.getRotation().x(); - quatIma1 = m_worldTransform.getRotation().y(); - quatIma2 = m_worldTransform.getRotation().z(); - quatReal = m_worldTransform.getRotation()[3]; -} - -void MyMotionState::setWorldPosition(float posX,float posY,float posZ) -{ - SimdPoint3 pos(posX,posY,posZ); - m_worldTransform.setOrigin( pos ); -} - -void MyMotionState::setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal) -{ - SimdQuaternion orn(quatIma0,quatIma1,quatIma2,quatReal); - m_worldTransform.setRotation( orn ); -} - -void MyMotionState::calculateWorldTransformations() -{ - -} diff --git a/Demos/BasicSample/MyMotionState.h b/Demos/BasicSample/MyMotionState.h deleted file mode 100644 index e1adb2bfa..000000000 --- a/Demos/BasicSample/MyMotionState.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - -#ifndef MY_MOTIONSTATE_H -#define MY_MOTIONSTATE_H - -#include "PHY_IMotionState.h" -#include - - -class MyMotionState : public PHY_IMotionState - -{ - public: - MyMotionState(); - - virtual ~MyMotionState(); - - virtual void getWorldPosition(float& posX,float& posY,float& posZ); - virtual void getWorldScaling(float& scaleX,float& scaleY,float& scaleZ); - virtual void getWorldOrientation(float& quatIma0,float& quatIma1,float& quatIma2,float& quatReal); - - virtual void setWorldPosition(float posX,float posY,float posZ); - virtual void setWorldOrientation(float quatIma0,float quatIma1,float quatIma2,float quatReal); - - virtual void calculateWorldTransformations(); - - SimdTransform m_worldTransform; - -}; - -#endif //MY_MOTIONSTATE_H diff --git a/Demos/BasicSample/PrintfDebugDrawer.cpp b/Demos/BasicSample/PrintfDebugDrawer.cpp deleted file mode 100644 index 7e43fa468..000000000 --- a/Demos/BasicSample/PrintfDebugDrawer.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "PrintfDebugDrawer.h" - -#include //printf debugging - -PrintfDebugDrawer::PrintfDebugDrawer() -{ -} - - -void PrintfDebugDrawer::DrawLine(const SimdVector3& from,const SimdVector3& to,const SimdVector3& color) -{ - if (m_debugMode > 0) - { - printf("DrawLine: from(%f , %f . %f) , to(%f , %f . %f)\n",from.getX(),from.getY(),from.getZ(),to.getX(),to.getY(),to.getZ()); - } -} - -void PrintfDebugDrawer::DrawContactPoint(const SimdVector3& pointOnB,const SimdVector3& normalOnB,float distance,int lifeTime,const SimdVector3& color) -{ - if (m_debugMode & IDebugDraw::DBG_DrawContactPoints) - { - SimdVector3 to=pointOnB+normalOnB*distance; - const SimdVector3&from = pointOnB; - printf("DrawContactPoint (%d) from(%f , %f . %f) , to(%f , %f . %f)\n",lifeTime, from.getX(),from.getY(),from.getZ(),to.getX(),to.getY(),to.getZ()); - } -} - -void PrintfDebugDrawer::SetDebugMode(int debugMode) -{ - m_debugMode = debugMode; -} diff --git a/Demos/BasicSample/PrintfDebugDrawer.h b/Demos/BasicSample/PrintfDebugDrawer.h deleted file mode 100644 index 499dff2b6..000000000 --- a/Demos/BasicSample/PrintfDebugDrawer.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef PRINTF_DEBUG_DRAWER_H -#define PRINTF_DEBUG_DRAWER_H - -#include "IDebugDraw.h" - - - - -class PrintfDebugDrawer : public IDebugDraw -{ - int m_debugMode; - -public: - - PrintfDebugDrawer(); - - virtual void DrawLine(const SimdVector3& from,const SimdVector3& to,const SimdVector3& color); - - virtual void DrawContactPoint(const SimdVector3& PointOnB,const SimdVector3& normalOnB,float distance,int lifeTime,const SimdVector3& color); - - virtual void SetDebugMode(int debugMode); - - virtual int GetDebugMode() const { return m_debugMode;} - -}; - -#endif//PRINTF_DEBUG_DRAWER_H diff --git a/Demos/Jamfile b/Demos/Jamfile index df540e90f..9ce4492f7 100644 --- a/Demos/Jamfile +++ b/Demos/Jamfile @@ -75,7 +75,6 @@ else SubInclude TOP Demos CcdPhysicsDemo ; SubInclude TOP Demos ConvexDecompositionDemo ; SubInclude TOP Demos ColladaDemo ; -SubInclude TOP Demos BasicSample ; SubInclude TOP Demos CollisionDemo ; SubInclude TOP Demos CollisionInterfaceDemo ; SubInclude TOP Demos ConcaveDemo ; diff --git a/Demos/OpenGL/GlutStuff.cpp b/Demos/OpenGL/GlutStuff.cpp index c09cc3027..171e8e6ab 100644 --- a/Demos/OpenGL/GlutStuff.cpp +++ b/Demos/OpenGL/GlutStuff.cpp @@ -90,7 +90,7 @@ bool stepping= true; bool singleStep = false; -static bool idle = true; +static bool idle = false; void toggleIdle() { @@ -365,7 +365,7 @@ int glutmain(int argc, char **argv,int width,int height,const char* title) { glutSpecialFunc(mySpecial); glutReshapeFunc(myReshape); //createMenu(); - glutIdleFunc(0);//clientMoveAndDisplay); + glutIdleFunc(clientMoveAndDisplay); glutMouseFunc(clientMouseFunc); glutMotionFunc(clientMotionFunc); glutDisplayFunc( clientDisplay ); diff --git a/Extras/BulletOdeCollide/BVHTrimeshShape.cpp b/Extras/BulletOdeCollide/BVHTrimeshShape.cpp deleted file mode 100644 index d59ec37ec..000000000 --- a/Extras/BulletOdeCollide/BVHTrimeshShape.cpp +++ /dev/null @@ -1,147 +0,0 @@ - -#include "BVHTrimeshShape.h" - -#define TRIMESH_INTERNAL //requires OPCODE for the AABB tree -#include <../ode/src/collision_trimesh_internal.h> - -//Thanks AndrewONeil for the TrimeshBridge fix - -BVHTrimeshShape::BVHTrimeshShape(dxTriMesh* trimesh) -: TriangleMeshShape(new TrimeshBridge(trimesh)) -, m_triangleBridge( static_cast(m_meshInterface)) -{ -} - -BVHTrimeshShape::~BVHTrimeshShape () -{ - delete m_triangleBridge; -} - - - - - -TrimeshBridge::TrimeshBridge(dxTriMesh* trimesh) -:m_trimesh(trimesh) -{ -} - -void TrimeshBridge::getLockedReadOnlyVertexIndexBase(const unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& stride,const unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart) const -{ - numverts = m_trimesh->Data->Mesh.GetNbVertices(); - (*vertexbase) = (unsigned char *)m_trimesh->Data->Mesh.GetVerts(); - type = PHY_FLOAT; - stride = m_trimesh->Data->Mesh.GetVertexStride(); - - numfaces = m_trimesh->Data->Mesh.GetNbTriangles(); - (*indexbase) = (unsigned char *)m_trimesh->Data->Mesh.GetTris(); - indexstride = m_trimesh->Data->Mesh.GetTriStride(); - indicestype = PHY_INTEGER; -} - -void TrimeshBridge::getLockedVertexIndexBase(unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& stride,unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart) -{ - - numverts = m_trimesh->Data->Mesh.GetNbVertices(); - (*vertexbase) = (unsigned char *)m_trimesh->Data->Mesh.GetVerts(); - type = PHY_FLOAT; - stride = m_trimesh->Data->Mesh.GetVertexStride(); - - numfaces = m_trimesh->Data->Mesh.GetNbTriangles(); - (*indexbase) = (unsigned char *)m_trimesh->Data->Mesh.GetTris(); - indexstride = m_trimesh->Data->Mesh.GetTriStride(); - indicestype = PHY_INTEGER; - -} - - -#ifdef USE_AABB_TREE - - //ProcessAllTriangles first gets the overlapping triangles using BVH culling - //and passes them on to the TriangleCallback -void BVHTrimeshShape::ProcessAllTriangles(TriangleCallback* callback,const SimdVector3& aabbMin,const SimdVector3& aabbMax) const -{ - dxTriMesh* TriMesh = m_triangleBridge->m_trimesh; - - // Init - const dVector3& TLPosition = *(const dVector3*)dGeomGetPosition(TriMesh); - const dMatrix3& TLRotation = *(const dMatrix3*)dGeomGetRotation(TriMesh); - - SphereCollider& Collider = TriMesh->_SphereCollider; - - - SimdVector3 he = (aabbMax-aabbMin)*0.5f; - SimdVector3 cen = (aabbMax+aabbMin)*0.5f; - - - dVector3 aabbHalfExtents; - aabbHalfExtents[0] = he.x(); - aabbHalfExtents[1] = he.y(); - aabbHalfExtents[2] = he.z(); - - dVector3 Position; - Position[0]=cen.x(); - Position[1]=cen.y(); - Position[2]=cen.z(); - - dReal Radius = he.length(); - - // Bounding Sphere (from aabb) - Sphere Sphere; - Sphere.mCenter.x = Position[0]; - Sphere.mCenter.y = Position[1]; - Sphere.mCenter.z = Position[2]; - Sphere.mRadius = Radius; - - Matrix4x4 trimeshTransform; - MakeMatrix(TLPosition, TLRotation, trimeshTransform); - -// bvhTraversal.getOverlappingPrimitiveIndices( -// indicesCache, -// Sphere, -// TriMesh->Data->BVTree, -// &trimeshTransform); - - Collider.SetTemporalCoherence(false); - Collider.SetPrimitiveTests(false); - Collider.Collide(dxTriMesh::defaultSphereCache, Sphere, TriMesh->Data->BVTree, null, - &trimeshTransform); - - // get results - int TriCount = Collider.GetNbTouchedPrimitives(); - const int* Triangles = (const int*)Collider.GetTouchedPrimitives(); - - if (TriCount != 0){ - - int OutTriCount = 0; - for (int i = 0; i < TriCount; i++){ - //what was this - //if (OutTriCount == (Flags & 0xffff)){ - // break; - //} - - const int& TriIndex = Triangles[i]; - - dVector3 dv[3]; - FetchTriangle(TriMesh, TriIndex, TLPosition, TLRotation, dv); - - SimdVector3 vts[3] = - { SimdVector3(dv[0][0],dv[0][1],dv[0][2]), - SimdVector3 (dv[1][0],dv[1][1],dv[1][2]), - SimdVector3 (dv[2][0],dv[2][1],dv[2][2]) - }; - - callback->ProcessTriangle(&vts[0]); - - OutTriCount++; - } - if (OutTriCount) - { - - } - } - - -} -#endif //USE_AABB_TREE - diff --git a/Extras/BulletOdeCollide/BVHTrimeshShape.h b/Extras/BulletOdeCollide/BVHTrimeshShape.h deleted file mode 100644 index 1c4fc1899..000000000 --- a/Extras/BulletOdeCollide/BVHTrimeshShape.h +++ /dev/null @@ -1,68 +0,0 @@ - -#ifndef BVH_TRIMESH_SHAPE_H -#define BVH_TRIMESH_SHAPE_H - -#include -#include -#include -#include -#include <../ode/src/collision_util.h> -#include <../ode/src/collision_kernel.h> -#include <../ode/src/collision_kernel.h> -#include "CollisionShapes/TriangleMeshShape.h" -struct dxTriMesh; - -///if this USE_AABB_TREE is not defined, it will brute force go through all triangles -#define USE_AABB_TREE - - -class TrimeshBridge : public StridingMeshInterface -{ - - public: - - dxTriMesh* m_trimesh; - - TrimeshBridge(dxTriMesh* trimesh); - - virtual void getLockedVertexIndexBase(unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& stride,unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart=0); - - virtual void getLockedReadOnlyVertexIndexBase(const unsigned char **vertexbase, int& numverts,PHY_ScalarType& type, int& stride,const unsigned char **indexbase,int & indexstride,int& numfaces,PHY_ScalarType& indicestype,int subpart=0) const; - - /// unLockVertexBase finishes the access to a subpart of the triangle mesh - /// make a call to unLockVertexBase when the read and write access (using getLockedVertexIndexBase) is finished - virtual void unLockVertexBase(int subpart) {} - - virtual void unLockReadOnlyVertexBase(int subpart) const {} - - /// getNumSubParts returns the number of seperate subparts - /// each subpart has a continuous array of vertices and indices - virtual int getNumSubParts() const { return 1;} - - virtual void preallocateVertices(int numverts){} - virtual void preallocateIndices(int numindices){} - -}; - - -/// BVHTrimeshShape bridges the Opcode to provide backwards compatibility with dxTriMesh. -/// You can also avoid using Opcode and use Bullet trimesh support See: BvhTriangleMeshShape -class BVHTrimeshShape : public TriangleMeshShape -{ - TrimeshBridge * m_triangleBridge; - -public: - BVHTrimeshShape(dxTriMesh* trimesh); - virtual ~BVHTrimeshShape (); - - -#ifdef USE_AABB_TREE - //ProcessAllTriangles first gets the overlapping triangles using BVH culling - //and passes them on to the TriangleCallback - void ProcessAllTriangles(TriangleCallback* callback,const SimdVector3& aabbMin,const SimdVector3& aabbMax) const; -#endif - -}; - - -#endif //BVH_TRIMESH_SHAPE_H \ No newline at end of file diff --git a/Extras/BulletOdeCollide/BulletOdeCollide.cpp b/Extras/BulletOdeCollide/BulletOdeCollide.cpp deleted file mode 100644 index 63182be2f..000000000 --- a/Extras/BulletOdeCollide/BulletOdeCollide.cpp +++ /dev/null @@ -1,139 +0,0 @@ - -#include "BulletOdeCollide.h" - -//quick hack, we need internals, not just the public ode api -#include <../ode/src/collision_kernel.h> - -#include "NarrowPhaseCollision/PersistentManifold.h" -#include "NarrowPhaseCollision/ManifoldPoint.h" - -#include "BroadphaseCollision/CollisionAlgorithm.h" -#include "BulletOdeCollisionPair.h" -#include "../ode/src/collision_convex_internal.h" - -#define CONTACT(p,skip) ((dContactGeom*) (((char*)p) + (skip))) - - -//Persistent collision pairs. Best is to store this in the broadphase/collision-pairs if the collision detection framework provides this -#define MAX_COLLISION_PAIRS 10000 -static BulletOdeCollisionPair* sCollisionPair[MAX_COLLISION_PAIRS]; -static int numActiveCollisionPairs = 0; - -void InitBulletOdeCollide() -{ - numActiveCollisionPairs = 0; -} - -void ExitBulletOdeCollide() -{ - //todo: cleanup memory - numActiveCollisionPairs = 0; -} - - - -CollisionShape* GetCollisionShapeFromConvex(dGeomID geom) -{ - dUASSERT (geom && geom->type == dConvexClass,"argument not a convex"); - dxConvex* cnvx = (dxConvex*) geom; - return cnvx->m_bulletCollisionShape; -} - - -BulletOdeCollisionPair* FindCollisionPair(dGeomID o1,dGeomID o2) -{ - int i; - for (i=0;im_o1 == o1) && - (sCollisionPair[i]->m_o2 == o2)) - { - return sCollisionPair[i]; - } - } - return 0; -} - - -void RemoveOdeGeomFromCollisionCache(dGeomID geom) -{ - int i; - for (i=numActiveCollisionPairs-1;i>=0;i--) - { - if ( (sCollisionPair[i]->m_o1 == geom) || - (sCollisionPair[i]->m_o2 == geom)) - { - delete sCollisionPair[i]; - sCollisionPair[i] = sCollisionPair[numActiveCollisionPairs-1]; - numActiveCollisionPairs--; - } - } -} - -int BulletOdeCollide(dGeomID o1,dGeomID o2,dContactGeom *contact,int maxContact,int skip) -{ - - //In order to have more then 1 point we use persistent manifold per overlapping pair - BulletOdeCollisionPair* collisionPair = FindCollisionPair(o1,o2); - if (!collisionPair) - { - if (numActiveCollisionPairs < MAX_COLLISION_PAIRS) - { - collisionPair = new BulletOdeCollisionPair(o1,o2); - sCollisionPair[numActiveCollisionPairs++] = collisionPair ; - } else - { - printf("overflow in collisionpair cache\n"); - return 0; - } - } - - //perform collision detection and recalculate the contact manifold - collisionPair->CalculateContacts(); - - //transfer contacts from PersistentManifold to gContactGeom - int validContacts = 0; - float maxDepth = -1e30f; - - for (int i=0; im_manifold->GetNumContacts(); i++) - { - const ManifoldPoint& pt = collisionPair->m_manifold->GetContactPoint(i); - - if (pt.GetDistance() < 0.f) - { - float depth = -pt.GetDistance(); - - //add contacts, and make sure to add the deepest contact in any case - if ((validContacts < maxContact) || (depth > maxDepth)) - { - maxDepth = depth; - int contactIndex = validContacts; - - if (contactIndex >= maxContact) - contactIndex = 0; - - if (contactIndex < maxContact) - { - SimdVector3 pos = (pt.m_positionWorldOnB + pt.m_positionWorldOnA)*0.5f; - - CONTACT(contact,contactIndex*skip)->depth = depth; - CONTACT(contact,contactIndex*skip)->pos[0] = pos.getX(); - CONTACT(contact,contactIndex*skip)->pos[1] = pos.getY(); - CONTACT(contact,contactIndex*skip)->pos[2] = pos.getZ(); - CONTACT(contact,contactIndex*skip)->normal[0] = pt.m_normalWorldOnB.getX(); - CONTACT(contact,contactIndex*skip)->normal[1] = pt.m_normalWorldOnB.getY(); - CONTACT(contact,contactIndex*skip)->normal[2] = pt.m_normalWorldOnB.getZ(); - CONTACT(contact,contactIndex*skip)->g1 = o1; - CONTACT(contact,contactIndex*skip)->g2 = o2; - } - if (validContacts < maxContact) - validContacts++; - } - - } - } - - //printf("numcontacts: %d",validContacts); - - return validContacts; -} \ No newline at end of file diff --git a/Extras/BulletOdeCollide/BulletOdeCollide.h b/Extras/BulletOdeCollide/BulletOdeCollide.h deleted file mode 100644 index 54f1f04c6..000000000 --- a/Extras/BulletOdeCollide/BulletOdeCollide.h +++ /dev/null @@ -1,13 +0,0 @@ -#ifndef _BULLET_ODE_COLLIDE_H -#define _BULLET_ODE_COLLIDE_H - -#include -#include - -int BulletOdeCollide(dGeomID o1,dGeomID o2,dContactGeom *contact,int maxContacts,int skip); -void RemoveOdeGeomFromCollisionCache(dGeomID geom); -class CollisionShape* GetCollisionShapeFromConvex(dGeomID convex); -dGeomID dCreateConvex (dSpaceID space, class CollisionShape* shape); -void dGeomConvexGetLengths(dGeomID convex, dVector3 result); - -#endif //_BULLET_ODE_COLLIDE_H \ No newline at end of file diff --git a/Extras/BulletOdeCollide/BulletOdeCollide_vc7.vcproj b/Extras/BulletOdeCollide/BulletOdeCollide_vc7.vcproj deleted file mode 100644 index 59ba942fe..000000000 --- a/Extras/BulletOdeCollide/BulletOdeCollide_vc7.vcproj +++ /dev/null @@ -1,161 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/BulletOdeCollide/BulletOdeCollisionPair.cpp b/Extras/BulletOdeCollide/BulletOdeCollisionPair.cpp deleted file mode 100644 index 4ee4d3f6f..000000000 --- a/Extras/BulletOdeCollide/BulletOdeCollisionPair.cpp +++ /dev/null @@ -1,184 +0,0 @@ -#include "BulletOdeCollisionPair.h" - -#include "NarrowPhaseCollision/PersistentManifold.h" -//quick hack, we need internals, not just the public ode api -#include <../ode/src/collision_kernel.h> -#include "CollisionShapes/BoxShape.h" -#include "BulletOdeCollide.h" - -#include "CollisionShapes/SphereShape.h" -#include "CollisionShapes/CylinderShape.h" -#include "CollisionShapes/MultiSphereShape.h"//capped cylinder is convex hull of two spheres -#include "CollisionShapes/ConvexTriangleCallback.h" - -#include "BVHTrimeshShape.h" - -#include "NarrowPhaseCollision/GjkPairDetector.h" -#include "NarrowPhaseCollision/VoronoiSimplexSolver.h" -#include "NarrowPhaseCollision/MinkowskiPenetrationDepthSolver.h" -///for comparison/unit testing -#ifdef UNIT_TEST_COMPARE_PENETRATION_DEPTH -#include "../ExtraSolid35/Solid3EpaPenetrationDepth.h" -#endif //UNIT_TEST_COMPARE_PENETRATION_DEPTH - -#include "BulletOdeManifoldResult.h" -#include "BulletOdeTransformConvert.h" - -BulletOdeCollisionPair::BulletOdeCollisionPair(dGeomID o1,dGeomID o2) -{ - m_manifold = new PersistentManifold(); - - m_o1 = o1; - m_o2 = o2; - - m_shape1 = CreateShapeFromGeom(o1); - - m_shape2 = CreateShapeFromGeom(o2); - -} - - -BulletOdeCollisionPair::~BulletOdeCollisionPair() -{ -} - -void BulletOdeCollisionPair::CalculateContacts() -{ - //perform gjk, passing the points to the persistent manifold and convert to ode contacts - - if ((!m_shape1) || (!m_shape2)) - return; - - if (m_shape1->IsConcave() && m_shape2->IsConvex()) - { - TriangleMeshShape* triangleMesh = (TriangleMeshShape*)m_shape1; - ConvexShape* convexShape2 = (ConvexShape*)m_shape2; - - float collisionMarginTriangle = 0.02f;//triangleMesh->GetMargin(); - SimdTransform triangleMeshTrans = GetTransformFromGeom(m_o1); - SimdTransform convexTrans = GetTransformFromGeom(m_o2); - - ConvexTriangleCallback convexTriangleCallback(m_manifold,convexShape2,convexTrans,triangleMeshTrans); - convexTriangleCallback.Update(collisionMarginTriangle); - - triangleMesh->ProcessAllTriangles( &convexTriangleCallback,convexTriangleCallback.GetAabbMin(),convexTriangleCallback.GetAabbMax()); - - m_manifold->RefreshContactPoints(triangleMeshTrans,convexTrans); - - } - - if (m_shape1->IsConvex() && m_shape2->IsConvex()) - { - ConvexShape* convexShape1 = (ConvexShape*)m_shape1; - ConvexShape* convexShape2 = (ConvexShape*)m_shape2; - - - - BulletOdeManifoldResult output(m_o1,m_o2,m_manifold); - - GjkPairDetector::ClosestPointInput input; - - VoronoiSimplexSolver simplexSolver; - -#ifdef UNIT_TEST_COMPARE_PENETRATION_DEPTH - Solid3EpaPenetrationDepth penetrationDepthSolver; -#else - MinkowskiPenetrationDepthSolver penetrationDepthSolver; -#endif// UNIT_TEST_COMPARE_PENETRATION_DEPTH - - GjkPairDetector gjkDetector(convexShape1,convexShape2,&simplexSolver,&penetrationDepthSolver); - - - gjkDetector.SetMinkowskiA(convexShape1); - gjkDetector.SetMinkowskiB(convexShape2); - input.m_maximumDistanceSquared = m_shape1->GetMargin()+ m_shape2->GetMargin() + m_manifold->GetManifoldMargin(); - input.m_maximumDistanceSquared*= input.m_maximumDistanceSquared; - - input.m_maximumDistanceSquared = 1e30;//? - - input.m_transformA = GetTransformFromGeom(m_o1); - input.m_transformB = GetTransformFromGeom(m_o2); - - gjkDetector.GetClosestPoints(input,output,0); - - m_manifold->RefreshContactPoints(input.m_transformA,input.m_transformB); - - } -} - -void BulletOdeCollisionPair::ProcessCollision (BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const struct DispatcherInfo& dispatchInfo) -{ - -} - -float BulletOdeCollisionPair::CalculateTimeOfImpact(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const struct DispatcherInfo& dispatchInfo) -{ - return 1.f; -} - - -CollisionShape* BulletOdeCollisionPair::CreateShapeFromGeom(dGeomID geom) -{ - CollisionShape* shape = 0; - - if (geom->type == dConvexClass) - { - shape = GetCollisionShapeFromConvex(geom); - } else - { - //bullet shape versus ode geom, create a compatible shape from the ode types - switch (geom->type) - { - case dPlaneClass: - break; - case dBoxClass: - { - dVector3 size; - dGeomBoxGetLengths (geom,size); - SimdVector3 halfExtents(0.5f*size[0],0.5f*size[1],0.5f*size[2]); - shape = new BoxShape(halfExtents); - break; - } - case dSphereClass: - { - dVector3 size; - shape = new SphereShape(dGeomSphereGetRadius(geom)); - break; - } - case dCylinderClass: - { - dVector3 size; - dGeomBoxGetLengths (geom,size); - SimdVector3 boxHalfExtents(size[0],size[0],size[1]); - shape = new CylinderShapeZ(boxHalfExtents); - break; - } - case dCCylinderClass: - { - dReal radius,length; - dGeomCCylinderGetParams (geom, &radius, &length); - SimdVector3 boxHalfExtents(radius,radius,0.5f*length); - int numspheres = 2; - SimdVector3 centers[2]={ SimdVector3(0,0,0.5f*length),SimdVector3(0,0,-0.5f*length)}; - SimdScalar radi[2]={radius,radius}; - shape = new MultiSphereShape(boxHalfExtents,centers,radi,numspheres); - break; - } - case dTriMeshClass: - { - dxTriMesh* trimesh = (dxTriMesh*) geom; - shape = 0;//new BVHTrimeshShape(trimesh); - break; - } - - - default: - { - } - }; - - } - - return shape; - -} diff --git a/Extras/BulletOdeCollide/BulletOdeCollisionPair.h b/Extras/BulletOdeCollide/BulletOdeCollisionPair.h deleted file mode 100644 index c74b71a75..000000000 --- a/Extras/BulletOdeCollide/BulletOdeCollisionPair.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef BULLET_ODE_COLLISION_PAIR_H -#define BULLET_ODE_COLLISION_PAIR_H - -#include -#include -class PersistentManifold; - -/// BulletOdeCollisionPair provides Bullet convex collision detection for Open Dynamics Engine -class BulletOdeCollisionPair : public CollisionAlgorithm -{ -public: - BulletOdeCollisionPair(dGeomID o1,dGeomID o2); - virtual ~BulletOdeCollisionPair(); - - PersistentManifold* m_manifold; - dGeomID m_o1; - dGeomID m_o2; - - class CollisionShape* m_shape1; - - class CollisionShape* m_shape2; - - - void CalculateContacts(); - - CollisionShape* CreateShapeFromGeom(dGeomID); - - ///future support for Bullet broadphase + framework? - virtual void ProcessCollision (BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const struct DispatcherInfo& dispatchInfo); - - ///future support for Bullet broadphase + framework? - virtual float CalculateTimeOfImpact(BroadphaseProxy* proxy0,BroadphaseProxy* proxy1,const struct DispatcherInfo& dispatchInfo); -}; - -#endif //BULLET_ODE_COLLISION_PAIR_H \ No newline at end of file diff --git a/Extras/BulletOdeCollide/BulletOdeManifoldResult.cpp b/Extras/BulletOdeCollide/BulletOdeManifoldResult.cpp deleted file mode 100644 index 598a5b173..000000000 --- a/Extras/BulletOdeCollide/BulletOdeManifoldResult.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include "BulletOdeManifoldResult.h" -#include "NarrowPhaseCollision/PersistentManifold.h" -#include "BulletOdeTransformConvert.h" - -BulletOdeManifoldResult::BulletOdeManifoldResult(dGeomID geom1,dGeomID geom2,PersistentManifold* manifoldPtr) - :m_manifoldPtr(manifoldPtr), - m_geom1(geom1), - m_geom2(geom2) -{ -} - -void BulletOdeManifoldResult::AddContactPoint(const SimdVector3& normalOnBInWorld,const SimdVector3& pointInWorld,float depth) -{ - if (depth > m_manifoldPtr->GetManifoldMargin()) - return; - - SimdTransform transAInv = GetTransformFromGeom(m_geom1).inverse(); - SimdTransform transBInv = GetTransformFromGeom(m_geom2).inverse(); - - SimdVector3 pointA = pointInWorld + normalOnBInWorld * depth; - SimdVector3 localA = transAInv(pointA ); - SimdVector3 localB = transBInv(pointInWorld); - ManifoldPoint newPt(localA,localB,normalOnBInWorld,depth); - - int insertIndex = m_manifoldPtr->GetCacheEntry(newPt); - if (insertIndex >= 0) - { - m_manifoldPtr->ReplaceContactPoint(newPt,insertIndex); - } else - { - m_manifoldPtr->AddManifoldPoint(newPt); - } -} \ No newline at end of file diff --git a/Extras/BulletOdeCollide/BulletOdeManifoldResult.h b/Extras/BulletOdeCollide/BulletOdeManifoldResult.h deleted file mode 100644 index 4c187f33e..000000000 --- a/Extras/BulletOdeCollide/BulletOdeManifoldResult.h +++ /dev/null @@ -1,38 +0,0 @@ -/* -Bullet Continuous Collision Detection and Physics Library -Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ - -This software is provided 'as-is', without any express or implied warranty. -In no event will the authors be held liable for any damages arising from the use of this software. -Permission is granted to anyone to use this software for any purpose, -including commercial applications, and to alter it and redistribute it freely, -subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. -2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. -3. This notice may not be removed or altered from any source distribution. -*/ - - -#ifndef BULLET_ODE_MANIFOLD_RESULT_H -#define BULLET_ODE_MANIFOLD_RESULT_H - -#include "NarrowPhaseCollision/DiscreteCollisionDetectorInterface.h" -class PersistentManifold; -#include - -class BulletOdeManifoldResult : public DiscreteCollisionDetectorInterface::Result -{ - PersistentManifold* m_manifoldPtr; - dGeomID m_geom1; - dGeomID m_geom2; - -public: - - BulletOdeManifoldResult(dGeomID geom1,dGeomID geom2,PersistentManifold* manifoldPtr); - - virtual void AddContactPoint(const SimdVector3& normalOnBInWorld,const SimdVector3& pointInWorld,float depth); - -}; - -#endif //BULLET_ODE_MANIFOLD_RESULT_H diff --git a/Extras/BulletOdeCollide/BulletOdeTransformConvert.cpp b/Extras/BulletOdeCollide/BulletOdeTransformConvert.cpp deleted file mode 100644 index d292f2ca8..000000000 --- a/Extras/BulletOdeCollide/BulletOdeTransformConvert.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include "BulletOdeTransformConvert.h" -#include "../ode/src/collision_kernel.h" - -SimdTransform GetTransformFromGeom(dGeomID geom) -{ - SimdTransform trans; - trans.setIdentity(); - - - const dReal* pos = dGeomGetPosition (geom);// pointer to object's position vector - const dReal* rot = dGeomGetRotation (geom);; // pointer to object's rotation matrix, 4*3 format! - - SimdMatrix3x3 orn(rot[0],rot[1],rot[2], - rot[4],rot[5],rot[6], - rot[8],rot[9],rot[10]); - - trans.setOrigin(SimdVector3(pos[0],pos[1],pos[2])); - trans.setBasis(orn); - - return trans; -} - -SimdTransform GetTransformFromBody(dBodyID body) -{ - SimdTransform trans; - - const dReal* pos = body->pos; - const dReal* rot = body->R; - - SimdMatrix3x3 orn(rot[0],rot[1],rot[2], - rot[4],rot[5],rot[6], - rot[8],rot[9],rot[10]); - - trans.setOrigin(SimdVector3(pos[0],pos[1],pos[2])); - trans.setBasis(orn); - - return trans; - -} diff --git a/Extras/BulletOdeCollide/BulletOdeTransformConvert.h b/Extras/BulletOdeCollide/BulletOdeTransformConvert.h deleted file mode 100644 index ec30bdc6c..000000000 --- a/Extras/BulletOdeCollide/BulletOdeTransformConvert.h +++ /dev/null @@ -1,10 +0,0 @@ -#ifndef BULLET_ODE_TRANSFORM_CONVERT_H -#define BULLET_ODE_TRANSFORM_CONVERT_H - -#include "SimdTransform.h" -#include - -SimdTransform GetTransformFromGeom(dGeomID geom); -SimdTransform GetTransformFromBody(dBodyID body); - -#endif //BULLET_ODE_TRANSFORM_CONVERT_H \ No newline at end of file diff --git a/Extras/BulletOdeCollide/GeomToShape.cpp b/Extras/BulletOdeCollide/GeomToShape.cpp deleted file mode 100644 index 01c616425..000000000 --- a/Extras/BulletOdeCollide/GeomToShape.cpp +++ /dev/null @@ -1,70 +0,0 @@ - -#include "CollisionShapes/SphereShape.h" -#include "CollisionShapes/CylinderShape.h" -#include "CollisionShapes/MultiSphereShape.h"//capped cylinder is convex hull of two spheres -#include "CollisionShapes/ConvexTriangleCallback.h" -#include "CollisionShapes/BoxShape.h" - -//need access to internals to convert... -#include <../ode/src/collision_kernel.h> - - -CollisionShape* CreateShapeFromGeom(dGeomID geom) -{ - CollisionShape* shape = 0; - - switch (geom->type) - { - case dPlaneClass: - break; - case dBoxClass: - { - dVector3 size; - dGeomBoxGetLengths (geom,size); - SimdVector3 halfExtents(0.5f*size[0],0.5f*size[1],0.5f*size[2]); - shape = new BoxShape(halfExtents); - break; - } - case dSphereClass: - { - dVector3 size; - shape = new SphereShape(dGeomSphereGetRadius(geom)); - break; - } - case dCylinderClass: - { - dVector3 size; - dGeomBoxGetLengths (geom,size); - SimdVector3 boxHalfExtents(size[0],size[0],size[1]); - shape = new CylinderShapeZ(boxHalfExtents); - break; - } - case dCCylinderClass: - { - dReal radius,length; - dGeomCCylinderGetParams (geom, &radius, &length); - SimdVector3 boxHalfExtents(radius,radius,0.5f*length); - int numspheres = 2; - SimdVector3 centers[2]={ SimdVector3(0,0,0.5f*length),SimdVector3(0,0,-0.5f*length)}; - SimdScalar radi[2]={radius,radius}; - shape = new MultiSphereShape(boxHalfExtents,centers,radi,numspheres); - break; - } - /*case dTriMeshClass: - { - dxTriMesh* trimesh = (dxTriMesh*) geom; - shape = 0;//new BVHTrimeshShape(trimesh); - break; - } -*/ - - - default: - { - } - }; - - - return shape; - -} \ No newline at end of file diff --git a/Extras/BulletOdeCollide/GeomToShape.h b/Extras/BulletOdeCollide/GeomToShape.h deleted file mode 100644 index 5747c40ca..000000000 --- a/Extras/BulletOdeCollide/GeomToShape.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef GEOM_TO_SHAPE_H -#define GEOM_TO_SHAPE_H - -class CollisionShape; - -//need internals to handle dGeomID -#include <../ode/src/collision_kernel.h> - -CollisionShape* CreateShapeFromGeom(dGeomID geom); - -#endif // \ No newline at end of file diff --git a/Extras/BulletOdeCollide/ode_bullet2005nov5.patch b/Extras/BulletOdeCollide/ode_bullet2005nov5.patch deleted file mode 100644 index b1319b040..000000000 --- a/Extras/BulletOdeCollide/ode_bullet2005nov5.patch +++ /dev/null @@ -1,119 +0,0 @@ -? OPCODE/Debug -? OPCODE/Opcode.vcproj -? OPCODE/Release -? VC6/Debug -? VC6/Release -? VC6/msvcdefs.def -? VC6/ode.ncb -? VC6/ode.vcproj -? VC6/Samples/BuildLog.htm -? VC6/Samples/DrawStuff.vcproj -? VC6/Samples/DrawStuff_Debug -? VC6/Samples/DrawStuff_Release -? VC6/Samples/MakeAllTests.ncb -? VC6/Samples/MakeAllTests.sln -? VC6/Samples/MakeAllTests.suo -? VC6/Samples/MakeAllTests.vcproj -? VC6/Samples/Test_BoxStack.vcproj -? VC6/Samples/Test_BoxStack_Debug -? VC6/Samples/Test_BoxStack_Release -? VC6/Samples/Test_Buggy.vcproj -? VC6/Samples/Test_Chain1.vcproj -? VC6/Samples/Test_Chain2.vcproj -? VC6/Samples/Test_Collision.vcproj -? VC6/Samples/Test_Friction.vcproj -? VC6/Samples/Test_Hinge.vcproj -? VC6/Samples/Test_I.vcproj -? VC6/Samples/Test_Joints.vcproj -? VC6/Samples/Test_MovingTrimesh.vcproj -? VC6/Samples/Test_Ode.vcproj -? VC6/Samples/Test_Slider.vcproj -? VC6/Samples/Test_Space.vcproj -? VC6/Samples/Test_Step.vcproj -? VC6/Samples/Test_Trimesh.vcproj -? VC6/Samples/Test_Trimesh_Debug -? VC6/Samples/Test_Trimesh_Release -? VC6/Samples/state.dif -? include/ode/config.h -? ode/test/test_trimesh_convex.cpp -? ode/test/text_convex.cpp -Index: include/ode/collision.h -=================================================================== -RCS file: /cvsroot/opende/ode/include/ode/collision.h,v -retrieving revision 1.9 -diff -u -r1.9 collision.h ---- include/ode/collision.h 19 Jun 2004 15:44:22 -0000 1.9 -+++ include/ode/collision.h 6 Nov 2005 23:06:52 -0000 -@@ -84,6 +84,7 @@ - dRayClass, - dGeomTransformClass, - dTriMeshClass, -+ dConvexClass, - - dFirstSpaceClass, - dSimpleSpaceClass = dFirstSpaceClass, -Index: ode/src/collision_kernel.cpp -=================================================================== -RCS file: /cvsroot/opende/ode/ode/src/collision_kernel.cpp,v -retrieving revision 1.18 -diff -u -r1.18 collision_kernel.cpp ---- ode/src/collision_kernel.cpp 19 Apr 2004 18:27:56 -0000 1.18 -+++ ode/src/collision_kernel.cpp 6 Nov 2005 23:10:02 -0000 -@@ -146,6 +146,17 @@ - setCollider (dTriMeshClass,dTriMeshClass,&dCollideTTL); - setCollider (dTriMeshClass,dCCylinderClass,&dCollideCCTL); - #endif -+ -+#ifdef BULLET_CONVEX_SUPPORT -+ ///see collision_convex.cpp -+ setCollider (dConvexClass,dConvexClass,&dCollideConvexConvex); -+ setCollider (dConvexClass,dPlaneClass,&dCollideConvexConvex); -+ setCollider (dConvexClass,dBoxClass,&dCollideConvexConvex); -+ setCollider (dConvexClass,dSphereClass,&dCollideConvexConvex); -+ setCollider (dConvexClass,dCCylinderClass,&dCollideConvexConvex); -+ setCollider( dTriMeshClass,dConvexClass, dCollideConvexConvex); -+#endif //BULLET_CONVEX_SUPPORT -+ - setAllColliders (dGeomTransformClass,&dCollideTransform); - } - -Index: ode/src/collision_std.h -=================================================================== -RCS file: /cvsroot/opende/ode/ode/src/collision_std.h,v -retrieving revision 1.2 -diff -u -r1.2 collision_std.h ---- ode/src/collision_std.h 1 Dec 2002 06:13:42 -0000 1.2 -+++ ode/src/collision_std.h 6 Nov 2005 23:03:52 -0000 -@@ -37,6 +37,7 @@ - // the same interface as dCollide(). the first and second geom arguments must - // have the specified types. - -+ - int dCollideSphereSphere (dxGeom *o1, dxGeom *o2, int flags, - dContactGeom *contact, int skip); - int dCollideSphereBox (dxGeom *o1, dxGeom *o2, int flags, -@@ -63,6 +64,9 @@ - int flags, dContactGeom *contact, int skip); - int dCollideRayPlane (dxGeom *o1, dxGeom *o2, int flags, - dContactGeom *contact, int skip); -+///dCollideConvexConvex: see collision_convex.cpp for details -+int dCollideConvexConvex(dxGeom *o1, dxGeom *o2, int flags, -+ dContactGeom *contact, int skip); - - - #endif -Index: ode/src/collision_trimesh_internal.h -=================================================================== -RCS file: /cvsroot/opende/ode/ode/src/collision_trimesh_internal.h,v -retrieving revision 1.10 -diff -u -r1.10 collision_trimesh_internal.h ---- ode/src/collision_trimesh_internal.h 21 Sep 2004 20:54:21 -0000 1.10 -+++ ode/src/collision_trimesh_internal.h 6 Nov 2005 23:04:52 -0000 -@@ -25,6 +25,7 @@ - #ifndef _ODE_COLLISION_TRIMESH_INTERNAL_H_ - #define _ODE_COLLISION_TRIMESH_INTERNAL_H_ - -+int dCollideTrimeshConvex(dxGeom* g1, dxGeom* cnvx, int Flags, dContactGeom* Contacts, int Stride); - int dCollideSTL(dxGeom *o1, dxGeom *o2, int flags, dContactGeom *contact, int skip); - int dCollideBTL(dxGeom *o1, dxGeom *o2, int flags, dContactGeom *contact, int skip); - int dCollideRTL(dxGeom *o1, dxGeom *o2, int flags, dContactGeom *contact, int skip); diff --git a/Extras/FCollada/COLLADA_Specification_140.pdf b/Extras/FCollada/COLLADA_Specification_140.pdf deleted file mode 100644 index 22d63d8fa..000000000 Binary files a/Extras/FCollada/COLLADA_Specification_140.pdf and /dev/null differ diff --git a/Extras/FCollada/Changes.txt b/Extras/FCollada/Changes.txt deleted file mode 100644 index 15228c4d6..000000000 --- a/Extras/FCollada/Changes.txt +++ /dev/null @@ -1,145 +0,0 @@ -Release 1.08 -[ zhang 04-04-06] FXC exports images within , but ColladaMaya looks for images in . Disable the error return in image loading in FCDEffectParameterSurface, and add the dump of images in the FCDEffect. -[glaforte 03-04-06] Export and Documentation: Documenting the FCDSceneNode class. Added the FCDTFactory class to easily create and import new transforms. Fixed the parenting of transforms inside scene nodes. Changed the visual scene node’s target flag into a target counter, in case there are multiple cameras/lights that target the same visual scene node. Documented the FCDTransform class and all its up-classes. -[ aazar 03-04-06] Fixed with Guillaume a curve cloning issue and removed the ownsCurve boolean from FCDAnimated. -[ aazar 02-04-06] Fixed a code typo that prevented the loading of some physics scenes. -[glaforte 02-04-06] Export and Documentation: Documented the FCDAnimation class and added necessary functions to insert/release/retrieve child elements. Documented/refactored the FCDAnimated base class and its many up-classes. Wrote an automated test procedure for the animation tree export/re-import. Added to this test the creation of an animation curve and placing that animation curve to affect one component of a light color. Added and implemented generic creating functions for the typed animated up-classes: these will be used to add animation curves. To add new animations, I need access to the animatable parameters directly, so I added to cameras, lights, materials and effect parameters accessor that return the float references not as constant. Documented the FCDAnimationChannel class and added the necessary mutators/curve insertion/release functionality. Documented the FCDAnimationCurve class and the FCDAnimationMultiCurve class. -[glaforte 02-04-06] Export and Documentation: Documented the FUDaeWriter namespace. Documented the FUCrc32 namespace, the FUDebug and the FUAssert functions, the FUObject and the FUObjectContainer classes. -[ aazar 28-04-06] Implemented Guillaume's suggestion for FCDEffectParameterSurfaceInit and created a factory along with clone methods. It might be a good idea to move these guys to a new file though, as FCDEffectParameterSurface.h/cpp are getting crowded. -[glaforte 28-04-06] Export and Documentation: Documented the FCDExtra tree class and its technique/node sub-classes, also added the necessary information modifying/pulling and pushing functionality. Wrote an automated test for the export/re-import of a custom information tree. Documented the FUUniqueStringMapT template and started documenting the FUDaeWriter.h namespace. -[ zhang 28-04-06] Added "channels" and "format_hint" COLLADA tokens. -[glaforte 28-04-06] Export and Documentation: Documented the FUStringConversion, the FCDEntity, the FCDTargetedEntity classes. -[glaforte 25-04-06] Export and Documentation: Added an automated import/re-export test for a simple skin controller with two joints and on top of a mesh. Added one automated import/re-import test for a simple morpher on top of spline. Fixed the export of the skin controller: wrong count on the accessor of the bind-pose source and the wrong source id was used for the influence weight input in the element. Added an automated test for the export/re-import of the orthographic camera. -[glaforte 25-04-06] Export and Documentation: Documented the FCDEffectParameterSurface class, its initialization method sub-classes, the FCDController class, the FCDSkinController class and the FCDMorphController class. Added the FCDMorphTarget class, as the weight must now be attached to the controller at all times: before, I had a separate STL vector with the weights and on a resize, all the animations would have been lost. Added modifiers/pullers and pushers to these classes. Fixed ColladaMaya, ColladaMax and the viewer for the interface change in the morph controller class. -[ aazar 25-04-06] Fixed bug that would cause crash in FCDMaterialInstance if a controller had another controller as a base target. Fixed a bug where the wrong nodes would be sent to the animation linking, preventing correct shading animation. Fixed driven animation by fixing some bugs in FCollada for the driver. -[glaforte 25-04-06] Documentation and Export: Documented the FCDEffectParameterSurface class and its initialization method sub-classes. Added modifiers/pullers and pushers to these classes. -[glaforte 25-04-06] Fixed the import of the orthographic camera: it always failed as the camera strangely became both orthographic and perspective at the same time. -[glaforte 24-04-06] Export and Documentation: Documented the FCDImage class and added new modifiers/pullers/pushers. Modified the automated export/re-import test for the profile COMMON material to include a few textures and added the export/re-import of a few images for these textures. Fixed the export of COLLADA images: the id was missing and the filename was not a valid URL. Documented the FCDEffectParameterFactory class, the FCDEffectParameterList class, the FCDEffectParameter class and most of its derivates: the FCDEffectParameterSurface class is not yet documented. Added modifiers/pullers and pushers to all these classes, as well. Improved the document parsing error reporting by adding the line number on all the warnings/errors reported. -[glaforte 22-04-06] Export and Documentation: Documented the FCDTexture class. The FCDEffectStandard class now always owns all its textures, as I added the texture push/pull for this class. It will be easier that way for COLLADA 1.3 backward compatibility: the texture entities are cloned. Documented the FCDEffectPassShader and fixes a few typos and grammar mistakes in the documentation. -[glaforte 21-04-06] Export and Documentation: Documented the FCDEffectTechnique class and the FCDEffectPass class. Documented the FCDEffectCode class. Fixed the STL-related doxygen warnings. -[ aazar 20-04-06] Added a check for zero-length in FMVector3::NormalizeIt(). -[glaforte 20-04-06] Export and Documentation: The output file for the export/re-import automated test is starting to contain important information: ran it through a XML validator and fixed the validation issues: quite a few missing ‘sid’ and ‘url’ attributes, as well as quite a few required nodes: ‘ in an empty visual scene’, ‘ in an empty effect technique’... -[glaforte 20-04-06] Export and Documentation: Documented the FCDEffectStandard class and the FCDEffectProfileFX class. Wrote two automated tests for the export and re-import of the CG and COMMON profile materials. Simplified the documentation, removing all the "defines a" and "defines the", to be simply "A" and "The". -[glaforte 20-04-06] Export and Documentation: Documented the FCDEffect class. I realized that the FCDEffect class can still hold only one effect profile. Renamed the FCDEffectProfile class into the FCDEffectProfileFX class. Created a new FCDEffectProfile class which is the base class for the FCDEffectProfileFX and the FCDEffectStandard classes. Refactored the FCDEffect class to contain a list of FCDEffectProfile objects. Documented/implemented the FCDEffectProfile class. Updated ColladaMaya, ColladaMax and the Feeling Viewer to use the new effect/profile architecture. -[ aazar 19-04-06] Fixed material instancing issue with geometry controllers. -[glaforte 17-04-06] Export and Documentation: Started writing the export-import test for the materials/effects classes. Documented the FCDMaterialLibrary and FCDMaterial classes. Removed the ClearDaeIdWithoutTouchingTheUniqueMap function from the FCDObjectWithId class and refactored the import of materials to handle empty materials correctly. This will need to be re-tested with COLLADA 1.3 materials. -[glaforte 17-04-06] Export and Documentation: Added Doxygen group for all the math classes. Re-organized the automated export/import test into multiple files and a namespace. Wrote an automated test for the export/import of lights. Fixed the case of the exported light type. Added un-implemented RemoveEntity function to the library. This function will require a lot of extra structure. -[glaforte 17-04-06] Documentation: Finished (finally), the documentation of the FCDCamera class. Corrected some doxygen warnings in the polygon set class and the document class. - -Release 1.07 -[glaforte 13-04-06] FCollada: Corrected a small application-compatibility issue found in ColladaMax. -[glaforte 13-04-06] FCollada: Added basic exception handling in non-debug builds and fixed XSI import of animation curve tangents [theirs are 2D points, we use the strange bezier derivate]. -[ aazar 13-04-06] Fixed overwrite/clone bug in the FCDEffectParameterSurface. Everything works back correctly with shaders. Fixed reading of multiple elements. Fixed reading of gravity and timestep in the Collada file. Added angular velocity to physics -[ zhang 13-04-06] Traverse the group node and looking for to import light link. -[ aazar 12-04-06] Fixed bug in file path reading for FCDEffectCode. This fixed the rendering for a few Cg datasets. Rewrote the FCDEffectParameterSurface class to support the 40,000 new initialization possibilities of a surface. -[ zhang 12-04-06] Modified FindNamedAnimated() with string operations. -[glaforte 11-04-06] Integration: Integrated the errors found within FCollada by Autodesk's recent changes to ColladaMax. -[glaforte 10-04-06] Export and Documentation: Continued writing a simple test scenario for a mesh export/import: added a list of static indices for the vertex positions and colors to export and verify on re-import. Added functions to the mesh polygon set interface to add and remove faces. Since holes and faces are listed together within the face-vertex degree list for a polygon set, added function to access the hole/face information using an iterative index for faces. -[glaforte 07-04-06] Export and Documentation: Wrote the export/re-import test for the geometry sources. Fixed a memory hog within the DAE import code. Added a new constructor and an equivalency function for the FloatList class, which is now a class rather than a typedef. Added push/pull function for polygon set inputs as well as some renaming. -[glaforte 07-04-06] Export and Documentation: Documented the FCDGeometryPolygons and FCDGeometryPolygonsInput classes. Removed the ‘sourceId?member from the polygon set input class, as it now contains a pointer to the data source. Improved the interface of the geometry polygon set class. Added FMFloat and FMInteger, in order to better classify the information previously contained within FUtils.h. FMath.h now includes all the mathematical classes below it, rather than have FUtils includes them. -[glaforte 06-04-06] Export and documentation: Started an export/re-import test for a geometry mesh. Documented the FCDGeometryMesh class at the same time as I added the information pushing functions and improved on the interface of the class. Documented the FCDGeometrySource class. Created a new sub-class: FCDObjectWithId, so that non-entity objects which require a unique id have access to that functionality. Documented the FCDObject and FCDObjectWithId classes. Fixed the export of the geometry source. -[glaforte 06-04-06] Export and Documentation: Enabled and fixed the MSVC 64-bit warnings: many integer types went from uint32 to size_t, which is unsigned, or intptr_t, which is signed. LibXML required a lot of work, as there are many 8-bit string substractions to calculate sizes. Removed from LibXML the "trio" classes, which were unused. -[ aazar 06-04-06] Fixed bug in FCDEffectParameter concerning 1D, 3D and Cube samplers. - -Release 1.06 -[glaforte 05-04-06] Zapped a few Doxygen warnings. -[glaforte 05-04-06] Documented FUDateTime.h. Documented FUXmlWriter.h. -[glaforte 05-04-06] Removed the FPoint and FMatrix typedefs. Everyone should use FMVector3 and FMMatrix44 instead. Documented the FUStatus class and some of the FUtils.h macros. Added FUString.h which includes string-related macros/functions previously found in FUtils.h. -[glaforte 05-04-06] Work from two weeks ago: continued the documentation of the FCDCamera class. -[glaforte 04-04-06] Bug #38: Debug crash when importing. Reported by Alfred, this issue occurs only when importing a COLLADA document that has some visibility animation. This bug was due to leaking animation curves, when the animation curves for visibility were cloned in FCollada. -[ zhang 31-03-06] FCDEffectParameterBool returns boolean value -[ aazar 28-03-06] Implemented hack to allow Collada 1.3 materials and effects to load properly with the unique IDs. Simplified the FCDMaterialLibrary::LoadFromXML. -[glaforte 27-03-06] Updated the documentation for FCDLibrary and up-ed the version of the FCollada library. - -Internal Release 1.05 -[glaforte 27-03-06] Export and Documentation: Wrote the documentation for the FCDGeometry class. Added the CreateMesh and CreateSpline functions to the FCDGeometry class, in order to create a new mesh/spline for a new geometry object. Fixed the export of the camera, which was missing the element. Fixed the re-import of the entity notes: Refactored the extra structure containment. The FCDEntity base class now contains the extra structure. Documented and wrote an import/export test for the FCDGeometrySpline class. Implemented the export of splines. Improved the interface of the FCDGeometrySpline class so that retrieving information for splines is slightly less convoluted. -[ aazar 27-03-06] Fixed loading of physics scene since unique names have been implemented. We now load the rigid constraints and bodies correctly from sid instead of id, but looking them up in their physics model. -[glaforte 24-03-06] Added a test sequence for the export/import/push of camera information. Started documenting the FCDCamera class. -[glaforte 24-03-06] Completed the first draft Doxygeon documentation for the FCDocument class. -[ aazar 24-03-06] Completed some WriteToXML functions in physics classes. Fixed some bugs in the analytical geometries. -[glaforte 24-03-06] Started the documentation of the FCDocument class and header. -[glaforte 23-03-06] More information pushing: of transforms. Some re-organization of the scene node class header with some accessor additions. Initialization of the matrix can now take in a constant list of floats. Added testing of the pushing/export/import of transforms. -[ aazar 23-03-06] Adapted FCDImage to read in height, width and depth. -[glaforte 23-03-06] Started a full, simple, import-export scene test for visual scenes within FColladaTest. Wrote the push for libraries entities and the scene node transforms/children. Added the unique name map for the entities. Write out default names for all the entities, targeted or otherwise. Fixed a few export issues: empty names and the push of visual scene when there are no roots. -[glaforte 23-03-06] Implemented the export of the animation clips. Added accessors for the parent of an animation channel. -[ aazar 22-03-06] Fixed rigid constraint angular limit bug. -[ aazar 17-03-06] In FCDPhysicsRigidConstraint, added reading in of translation/rotation nodes inside rigid constraint attachment, and fixed a bug in reading interpenetrate node. -[glaforte 17-03-06] Added a flushing function to FULogFile. -[claforte 16-03-06] Fixed crash when exporting the default sphere in ColladaMaya: due to the string builder not being initialized properly. -[ aazar 16-03-06] Initialization and bug fix in FCDPhysicsRigidConstraint. -[glaforte 16-03-06] Animation clips don't have Ids when exported from ColladaMaya, right now so work-around them when importing in FCollada. -[claforte 15-03-06] Fixed import problems with files loaded from FX Composer 2, that have surfaces with no image. -[ aazar 15-03-06] Fixed Analytical shape reading from Collada file, and set only one radius per cylinder/capsule. Fixed bug in reading rigid constraints in FCDPhysicsModelInstance. Fixed bugs in reading rigid contraints parameters in FCDPhysicsRigidConstraint. Fixed bug reading in gravity in FCDPhysicsSceneNode. -[ aleung 15-03-06] Fixed Maya parameters nodes that were missing in FCDEffectStandard. -[glaforte 14-03-06] PS3: Fixed up the strlen within the string builder. Modified the absolute path creation with the FUFileManager. -[ aazar 13-03-06] Updated the LoadFromXML functions of the analytical geometries to take into account they have no Id. Added some Get functions to the FCDPhysicsRigidConstraint. -[claforte 13-03-06] Port to PS3: Fixed many warnings, e.g. missing newline at the end of include, enums were not using latest C++ spec, etc. Added #ifdefs related to PPU (PowerPC Unit), for stuff OpenGL ES-specific limitations, missing time() function, etc. Fixed bug in FindHierarchyChildBySid. Introduced some abstractions, e.g. fglActiveTexture and fglClientActiveTexture, to simplify support for OpenGL ES. Replaced Configure-generated makefile in PS3 DevIL by a hand-written one. Note that the ported version compiles and runs on the PS3, but nothing shows up due to #ifdef-ed code that needs to be written. -[glaforte 13-03-06] Added to FDCSkinController::ReduceInfluences a minimum weight threshold. -[ aazar 10-03-06] Mostly all physics-related: Completed the FCollada part for importing. -[ aazar 10-03-06] Added cloning support for FCDAnimated, FCDAnimationClip and FCDAnimationCurve objects. -[ aazar 10-03-06] Added SetClassName in FUObject so that classes can better identify themselves. -[ aazar 10-03-06] Corrected a suspected bug in material and effect flattening. -[ aazar 10-03-06] Fixed bug in creation of FCDPhysicsRigidConstraintInstance where it would try to compare the parent's type to the wrong one. -[glaforte 08-03-06] Added a unique name map that somewhat generates unique names. Added whether the FMath classes are used within FCollada to the doxygen documentation. Some improvements on the FCollada test project. - -Release 1.04 -[ aleung 06-03-06] Fixed up the Doxygen script for an improved main page template, files, global functions and completed the documentation of the FMath classes. -[ aleung 03-03-06] Wrote an initial doxygen script. Started documenting the FMath classes for Doxygen. -[glaforte 02-03-06] Planned the refactoring of the animation classes in order to support import/export/push/pull correctly. Added to the FCDAnimationCurve all the information necessary for it to do its own import/export. Similarly for FCDAnimationMultiCurve. When registering the animated values for export, just write out the targets to the curves. Implemented the recursive export of the animation trees. -[glaforte 02-03-06] Fixed memory overwrite within the FUStringBuilder template class. -[ zhang 28-02-06] Correct the float parameter min/max parsing. -[glaforte 27-02-06] Removed the Maya-Max type references from FCollada. Fixed the compilation errors in FUtils. -[glaforte 25-02-06] Added FUAssert and included Blinn shading on a few levels. -[glaforte 23-02-06] Fixed-up the STL #includes, in an attempt to fix the FCollada DLL. -[glaforte 23-02-06] 06-003-07: Fixed the loading of this skin test case, coming from COLLADA 1.3: the geometry cloning was not working when overriding the position-source. -[glaforte 23-02-06] ColladaMaya Fixes: Fixed the morph target input types. Fixed the array export types to be IDREF_arrays as well as their accessor parameter types to be IDREF. Fixed the import of the animation drivers: the input driver target processing was not correctly. -[ aleung 22-02-06] Performance: performance boost by reserving all the memory at once for the tessellations. -[ aazar 21-02-06] Physics: Completed FCDPhysicsShape and FCDAnalyticalGeometry, added FCDPhysicsScene class separate from FCDScene. Fixed many parsing bugs (mostly related to the order of parsing and instantiation) and some crashes related to incomplete destructors. It is now possible to load physics scenes and the FCD classes will read in correctly all the physics information. -[ aazar 21-02-06] Physics: Created the FCDPhysicsRigidConstraintInstance class. Completed the LoadXML for the FCDPhysicsRigidConstraint class. -[glaforte 21-02-06] Importer: Fixed the scene node animation import sampling. -[ aazar 20-02-06] Physics: Added lots of stuff for 1.4 Physics support. Some nodes are not complete yet, so don't try importing physics datasets as it will probably crash. The main nodes that need more work are the FCDPhysicsShape and the FCDPhysicsAnalyticalGeometry (need to derive classes for sphere, box, capsule, etc). -[ aazar 20-02-06] Physics: The other change worth mentioning is a slight modification in the ToFloat functions of the FUStringConversion, to check for infinity. That's a sensitive function and if something goes wrong, the whole rendering gets screwed up. -[glaforte 19-02-06] Light/Camera Export: Added and implemented the WriteToXML for the FCDlight and FCDCamera classes, writing out all the different supported light/camera types and the extra parameters for both Max and Maya, with their animations. - -Release 1.03 -[glaforte 15-02-06] Fixed the matrix flattening of scene nodes. -[glaforte 15-02-06] Fixed the import of scene node's notes/user-properties. -[glaforte 14-02-06] Standard Material Export: Wrote the export of the standard material texture and its animated placement/projection parameters. -[glaforte 13-02-06] Standard Material Export: Implemented the export of the standard material’s parameters and texture lists. Split the export function into four functions that export either the textures belong to the correct texture channel(s) as a standard material parameter, or the / element with its animation, if there is one. -[glaforte 11-02-06] Controller Export: Added and implemented the WriteToXML to the FCDController, FCDMorphController and FCDSkinController classes. Added morph method string conversion. Implemented the export of IDRef arrays and sources. Corrected the missing id/name for the element export. Corrected the extra ??in the morph target source. Corrected the ‘float?parameter type used too often in accessors. -[glaforte 10-02-06] Fixed the ordering of the cloning, so that the FCDEffectCode objects are always cloned before the passes. -[glaforte 09-02-06] Material Export: Split the FCDEffectPass class into itself and the FCDEffectPassShader class, which will hold all custom shader information, instead of assuming there are exactly one vertex and one fragment shader. Implemented the XML export of the FCDEffectPass and the FCDEffectPassShader classes. Created the FCDEffectCode class to hold both and ColladaFX element values. Corrected the element to read in the contents as the name and to use the ‘source?attribute for name-matching with the / elements. -[glaforte 08-02-06] Instantiation Export: Added the basic WriteToXML functionality to the effects/materials and the instances. -[glaforte 08-02-06] Fixed memory-related crash within the effect parameter release. -[ aleung 08-02-06] Fixed compilation error in FCDMorphController. -[glaforte 08-02-06] Instantiation Refactoring: Added the parsing of the ‘platform?attribute for ColladaFX profiles. Refactored the material instance class to hold the simple bind information as well. Added material ‘flattening?to the material instance class, so that viewers can assume only ColladaFX techniques hold parameters. The parameter values are trickled down by matching references. All the parameters are trickled down, while the parameters overwrite the parameters below. Implemented the WriteToXML functions for the effect, the effect profile and the effect technique classes. Added the parsing of the elements at the material level. -[glaforte 08-02-06] Instantiation Refactoring: Added FCDEffectParameterList class, based on the std:vector of parameters, adding a parameter lookup-by-name function. Refactored the FCDEffectParameter to not be tied to a ‘pass?object, as a parent. The parameters now use their own reference string for error-reporting. Added a parameter list at the material, effect, profile and technique levels. Refactored the ‘pass?to hold simple bind information, rather than all the parameters. -[glaforte 08-02-06] Instantiation Refactoring: In order to support correctly the export of geometry/controller instances, some refactoring is necessary, with respect to material parameters and their binding. The plan is to move from flattening materials on import to flattening materials on-demand, keeping the parameter override information around so that it can be modified and exported correctly. -[glaforte 07-02-06] Animation Export: Remove empty animation libraries. -[ aazar 07-02-06] Fixed a crash when releasing FCDocument, due to non-virtual destructors and missing memory deallocations. -[glaforte 07-02-06] Animation Export: Implemented XML export functions for the basic animation curve: splitting the export of the sources, samplers and channels, in order to keep the element enforced ordering. Wrote the XML export functions for the merged animation curve, with a custom stride and multiple accessor parameters. Implemented the export of animated translations and rotations. Tested with a simple, animated DAE file. Found/Investigated memory corruption crash: was due to wrong include being added to the tools?project. Corrected id-generation for the animation sources, the export of float arrays. -[glaforte 07-02-06] Animation Export: New feature: when generating a ‘sid? look for uniqueness, within the scope. Use an incremental counter appended to the wanted ‘sid?value, in order to generate unique sids. Fixed duplicated VERTEX geometry input, found within my current test case. Added the animation export to the other transformation elements. -[glaforte 06-02-06] Animation Export: Plan out the export of animation curves, animated values and animation clips, for FCollada. Implemented the cleaning-up of name and id string values, in order to strip them of the invalid characters, on export. Save the node for the animation library in the FCDocument object. Added a function to export the animated value, if it has curves attached to it. Added and Implemented WriteToXML function for the animated value: check for curve merging, and then export either the merged curve or the individual curves. -[glaforte 05-02-06] DLL Project: Some refactoring related to the usage of int8. Added functions to FUFileManager for relative/absolute/url filenames. -[glaforte 05-02-06] Material Export: The material library now exports effects for ColladaFX profiles and the standard profile, as well as materials with instantiated effects. The image library now exports file images correctly. -[claforte 03-02-06] Modified definitions used in ColladaMaya physics export: instead of , . -[glaforte 03-02-06] Geometry Export/Refactoring: Added WriteToXML functions at the relevant levels. Split the FCDGeometry class into the spline and mesh components. This modifies the API for the FCollada: merge in the changes within the viewer. -[glaforte 03-02-06] Import/Export of Asset tag: Added FCDAsset and FCDAssetContributor elements. Added FUDateTime class and its string parsing mechanism: mostly for the UTC times in the asset tags. - -Release 1.02 -[glaforte 02-02-06] Some corrections of warnings/errors for MacOSX and GCC. -[glaforte 01-02-06] Refactored the FUStringConversion header to have more inlined functions and reverted the changes on the ToFloat, ToUInt and ToInt functions to use our own parsing functions, as they were much faster than fstrtoX. -[glaforte 31-01-06] FCollada Extra Tree: Added and Implemented FCDExtra, FCDETechnique and FCDENode classes. Added an FCDExtra object to the scene node. -[glaforte 31-01-06] FCollada Extra Tree and Animations: Added FCDAnimatedCustom class that contains animation curves of any sizes and their float* targets directly. Refactored the animation system to link animations right away, resulting in a much smaller FCDAnimated object count. FCDENode contains an FCDAnimatedCustom object. Modified the scene node object to parse and extra the Max and Maya-specific parameters and their animations directly from the extra tree. -[ aazar 31-01-06] Created FCDEffectTechnique class to support multiple techniques in ColladaFX. FCDEffectProfile now has a list of FCDEffectTechnique, which has a list of FCDEffectPass, which has a list of FCDEffectParameters. -[glaforte 30-01-06] Added to FCDocument the export functions: WriteToFile and WriteDocumentToXML(). I'll be propagating these over the other FCDx classes. -[glaforte 30-01-06] Added writing utility namespaces: FUXmlWriter and FUDaeWriter. Ported ColladaMaya's XML writing functions over to the FUXmlWriter, but FUDaeWriter is still empty. -[glaforte 30-01-06] Added to FCDLibrary, FCDEntity and FCDSceneNode some basic writing functionality. -[glaforte 30-01-06] Made all the write to XML functions const. -[glaforte 30-01-06] Added ToString functions for FPoint and FMatrix, with length conversion. -[glaforte 30-01-06] Added to FCDTransform and its derivates, XML writing functions. - -Release 1.01 -[glaforte 30-01-06] First official version: includes all the modifications to the FS import classes made for the different projects, -[glaforte 30-01-06] up to now. Added DLL support and unicode support to the project(s). - diff --git a/Extras/FCollada/Copyright.txt b/Extras/FCollada/Copyright.txt deleted file mode 100644 index 85b6086e8..000000000 --- a/Extras/FCollada/Copyright.txt +++ /dev/null @@ -1,84 +0,0 @@ -You can get more information and the latest versions of the FCollada library -on our website. - -Feel free to drop us an email if you want more information on using the library. - -Guillaume Laforte -glaforte@feelingsoftware.com - -Feeling Software Inc. -http://www.feelingsoftware.com - - -Copyright and License information: ------------------------------------- - - -FCollada: ----------- -Copyright 2006 Feeling Software. -Under MIT License: http://www.opensource.org/licenses/mit-license.php - - -FS import classes: ------------------------ -Copyright 2005-2006 Feeling Software and -Copyright 2005-2006 Autodesk Media Entertainment. -Under MIT License: http://www.opensource.org/licenses/mit-license.php - - -LibXML2: ---------- -Except where otherwise noted in the source code (e.g. the files -hash.c, -list.c and the trio files, which are covered by a similar -licence but -with different Copyright notices) all the files are: - - - -Copyright (C) 1998-2003 Daniel Veillard. All Rights Reserved. - - -Permission is hereby granted, free of charge, -to any person obtaining a copy -of this software and associated documentation -files (the "Software"), to deal -in the Software without restriction, including -without limitation the rights -to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell -copies of the Software, and to -permit persons to whom the Software is fur- -nished to do so, subject -to the following conditions: - -The above copyright notice and this -permission notice shall be included in -all copies or substantial -portions of the Software. - - - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FIT- -NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL THE -DANIEL VEILLARD BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, -TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON- -NECTION WITH THE -SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - - - -Except as contained in this notice, the name of Daniel -Veillard shall not -be used in advertising or otherwise to -promote the sale, use or other deal- -ings in this Software -without prior written authorization from him. - diff --git a/Extras/FCollada/DLLEntry.cpp b/Extras/FCollada/DLLEntry.cpp deleted file mode 100644 index b0a55e2e5..000000000 --- a/Extras/FCollada/DLLEntry.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" - -HINSTANCE hInstance = NULL; - -BOOL WINAPI DllMain(HINSTANCE _hInstance, ULONG UNUSED(fdwReason), LPVOID UNUSED(lpvReserved)) -{ - hInstance = _hInstance; - return TRUE; -} - -namespace FCollada -{ - FCOLLADA_EXPORT unsigned long GetVersion() { return FCOLLADA_VERSION; } -}; - -#include "FMath/FMColor.h" -#include "FUtils/FUDebug.h" -#include "FUtils/FULogFile.h" - -// Trick the linker so that it adds the functionalities of the classes that are not used internally. -FCOLLADA_EXPORT void TrickLinker() -{ - // FMColor - FMColor* color = NULL; - float* f = NULL; - color->ToFloats(f, 4); - - // FULogFile - FULogFile* logFile = NULL; - logFile->WriteLine("Test"); - - // FUDebug - DebugOut("Tricking Linker..."); -} \ No newline at end of file diff --git a/Extras/FCollada/Doxyfile b/Extras/FCollada/Doxyfile deleted file mode 100644 index 027b65f9b..000000000 --- a/Extras/FCollada/Doxyfile +++ /dev/null @@ -1,1237 +0,0 @@ -# Doxyfile 1.4.6-NO - -# This file describes the settings to be used by the documentation system -# doxygen (www.doxygen.org) for a project -# -# All text after a hash (#) is considered a comment and will be ignored -# The format is: -# TAG = value [value, ...] -# For lists items can also be appended using: -# TAG += value [value, ...] -# Values that contain spaces should be placed between quotes (" ") - -#--------------------------------------------------------------------------- -# Project related configuration options -#--------------------------------------------------------------------------- - -# The PROJECT_NAME tag is a single word (or a sequence of words surrounded -# by quotes) that should identify the project. - -PROJECT_NAME = FCollada - -# The PROJECT_NUMBER tag can be used to enter a project or revision number. -# This could be handy for archiving the generated documentation or -# if some version control system is used. - -PROJECT_NUMBER = - -# The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) -# base path where the generated documentation will be put. -# If a relative path is entered, it will be relative to the location -# where doxygen was started. If left blank the current directory will be used. - -OUTPUT_DIRECTORY = Output/Doxygen - -# If the CREATE_SUBDIRS tag is set to YES, then doxygen will create -# 4096 sub-directories (in 2 levels) under the output directory of each output -# format and will distribute the generated files over these directories. -# Enabling this option can be useful when feeding doxygen a huge amount of -# source files, where putting all generated files in the same directory would -# otherwise cause performance problems for the file system. - -CREATE_SUBDIRS = NO - -# The OUTPUT_LANGUAGE tag is used to specify the language in which all -# documentation generated by doxygen is written. Doxygen will use this -# information to generate all constant output in the proper language. -# The default language is English, other supported languages are: -# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, -# Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, -# Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian, -# Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, -# Swedish, and Ukrainian. - -OUTPUT_LANGUAGE = English - -# This tag can be used to specify the encoding used in the generated output. -# The encoding is not always determined by the language that is chosen, -# but also whether or not the output is meant for Windows or non-Windows users. -# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES -# forces the Windows encoding (this is the default for the Windows binary), -# whereas setting the tag to NO uses a Unix-style encoding (the default for -# all platforms other than Windows). - -USE_WINDOWS_ENCODING = YES - -# If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will -# include brief member descriptions after the members that are listed in -# the file and class documentation (similar to JavaDoc). -# Set to NO to disable this. - -BRIEF_MEMBER_DESC = YES - -# If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend -# the brief description of a member or function before the detailed description. -# Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the -# brief descriptions will be completely suppressed. - -REPEAT_BRIEF = YES - -# This tag implements a quasi-intelligent brief description abbreviator -# that is used to form the text in various listings. Each string -# in this list, if found as the leading text of the brief description, will be -# stripped from the text and the result after processing the whole list, is -# used as the annotated text. Otherwise, the brief description is used as-is. -# If left blank, the following values are used ("$name" is automatically -# replaced with the name of the entity): "The $name class" "The $name widget" -# "The $name file" "is" "provides" "specifies" "contains" -# "represents" "a" "an" "the" - -ABBREVIATE_BRIEF = - -# If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then -# Doxygen will generate a detailed section even if there is only a brief -# description. - -ALWAYS_DETAILED_SEC = NO - -# If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all -# inherited members of a class in the documentation of that class as if those -# members were ordinary class members. Constructors, destructors and assignment -# operators of the base classes will not be shown. - -INLINE_INHERITED_MEMB = NO - -# If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full -# path before files name in the file list and in the header files. If set -# to NO the shortest path that makes the file name unique will be used. - -FULL_PATH_NAMES = YES - -# If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag -# can be used to strip a user-defined part of the path. Stripping is -# only done if one of the specified strings matches the left-hand part of -# the path. The tag can be used to show relative paths in the file list. -# If left blank the directory from which doxygen is run is used as the -# path to strip. - -STRIP_FROM_PATH = - -# The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of -# the path mentioned in the documentation of a class, which tells -# the reader which header file to include in order to use a class. -# If left blank only the name of the header file containing the class -# definition is used. Otherwise one should specify the include paths that -# are normally passed to the compiler using the -I flag. - -STRIP_FROM_INC_PATH = - -# If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter -# (but less readable) file names. This can be useful is your file systems -# doesn't support long names like on DOS, Mac, or CD-ROM. - -SHORT_NAMES = NO - -# If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen -# will interpret the first line (until the first dot) of a JavaDoc-style -# comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explicit @brief command for a brief description. - -JAVADOC_AUTOBRIEF = YES - -# The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen -# treat a multi-line C++ special comment block (i.e. a block of //! or /// -# comments) as a brief description. This used to be the default behaviour. -# The new default is to treat a multi-line C++ comment block as a detailed -# description. Set this tag to YES if you prefer the old behaviour instead. - -MULTILINE_CPP_IS_BRIEF = NO - -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = NO - -# If the INHERIT_DOCS tag is set to YES (the default) then an undocumented -# member inherits the documentation from any documented member that it -# re-implements. - -INHERIT_DOCS = YES - -# If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce -# a new page for each member. If set to NO, the documentation of a member will -# be part of the file/class/namespace that contains it. - -SEPARATE_MEMBER_PAGES = NO - -# The TAB_SIZE tag can be used to set the number of spaces in a tab. -# Doxygen uses this value to replace tabs by spaces in code fragments. - -TAB_SIZE = 4 - -# This tag can be used to specify a number of aliases that acts -# as commands in the documentation. An alias has the form "name=value". -# For example adding "sideeffect=\par Side Effects:\n" will allow you to -# put the command \sideeffect (or @sideeffect) in the documentation, which -# will result in a user-defined paragraph with heading "Side Effects:". -# You can put \n's in the value part of an alias to insert newlines. - -ALIASES = - -# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C -# sources only. Doxygen will then generate output that is more tailored for C. -# For instance, some of the names that are used will be different. The list -# of all members will be omitted, etc. - -OPTIMIZE_OUTPUT_FOR_C = NO - -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java -# sources only. Doxygen will then generate output that is more tailored for Java. -# For instance, namespaces will be presented as packages, qualified scopes -# will look different, etc. - -OPTIMIZE_OUTPUT_JAVA = NO - -# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want to -# include (a tag file for) the STL sources as input, then you should -# set this tag to YES in order to let doxygen match functions declarations and -# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. -# func(std::string) {}). This also make the inheritance and collaboration -# diagrams that involve STL classes more complete and accurate. - -BUILTIN_STL_SUPPORT = YES - -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - -# Set the SUBGROUPING tag to YES (the default) to allow class member groups of -# the same type (for instance a group of public functions) to be put as a -# subgroup of that type (e.g. under the Public Functions section). Set it to -# NO to prevent subgrouping. Alternatively, this can be done per class using -# the \nosubgrouping command. - -SUBGROUPING = YES - -#--------------------------------------------------------------------------- -# Build related configuration options -#--------------------------------------------------------------------------- - -# If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in -# documentation are documented, even if no documentation was available. -# Private class members and static file members will be hidden unless -# the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES - -EXTRACT_ALL = NO - -# If the EXTRACT_PRIVATE tag is set to YES all private members of a class -# will be included in the documentation. - -EXTRACT_PRIVATE = NO - -# If the EXTRACT_STATIC tag is set to YES all static members of a file -# will be included in the documentation. - -EXTRACT_STATIC = NO - -# If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) -# defined locally in source files will be included in the documentation. -# If set to NO only classes defined in header files are included. - -EXTRACT_LOCAL_CLASSES = YES - -# This flag is only useful for Objective-C code. When set to YES local -# methods, which are defined in the implementation section but not in -# the interface are included in the documentation. -# If set to NO (the default) only methods in the interface are included. - -EXTRACT_LOCAL_METHODS = NO - -# If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all -# undocumented members of documented classes, files or namespaces. -# If set to NO (the default) these members will be included in the -# various overviews, but no documentation section is generated. -# This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_MEMBERS = NO - -# If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all -# undocumented classes that are normally visible in the class hierarchy. -# If set to NO (the default) these classes will be included in the various -# overviews. This option has no effect if EXTRACT_ALL is enabled. - -HIDE_UNDOC_CLASSES = NO - -# If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all -# friend (class|struct|union) declarations. -# If set to NO (the default) these declarations will be included in the -# documentation. - -HIDE_FRIEND_COMPOUNDS = NO - -# If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any -# documentation blocks found inside the body of a function. -# If set to NO (the default) these blocks will be appended to the -# function's detailed documentation block. - -HIDE_IN_BODY_DOCS = NO - -# The INTERNAL_DOCS tag determines if documentation -# that is typed after a \internal command is included. If the tag is set -# to NO (the default) then the documentation will be excluded. -# Set it to YES to include the internal documentation. - -INTERNAL_DOCS = NO - -# If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate -# file names in lower-case letters. If set to YES upper-case letters are also -# allowed. This is useful if you have classes or files whose names only differ -# in case and if your file system supports case sensitive file names. Windows -# and Mac users are advised to set this option to NO. - -CASE_SENSE_NAMES = NO - -# If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen -# will show members with their full class and namespace scopes in the -# documentation. If set to YES the scope will be hidden. - -HIDE_SCOPE_NAMES = NO - -# If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen -# will put a list of the files that are included by a file in the documentation -# of that file. - -SHOW_INCLUDE_FILES = YES - -# If the INLINE_INFO tag is set to YES (the default) then a tag [inline] -# is inserted in the documentation for inline members. - -INLINE_INFO = YES - -# If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen -# will sort the (detailed) documentation of file and class members -# alphabetically by member name. If set to NO the members will appear in -# declaration order. - -SORT_MEMBER_DOCS = YES - -# If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the -# brief documentation of file, namespace and class members alphabetically -# by member name. If set to NO (the default) the members will appear in -# declaration order. - -SORT_BRIEF_DOCS = NO - -# If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be -# sorted by fully-qualified names, including namespaces. If set to -# NO (the default), the class list will be sorted only by class name, -# not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. -# Note: This option applies only to the class list, not to the -# alphabetical list. - -SORT_BY_SCOPE_NAME = NO - -# The GENERATE_TODOLIST tag can be used to enable (YES) or -# disable (NO) the todo list. This list is created by putting \todo -# commands in the documentation. - -GENERATE_TODOLIST = YES - -# The GENERATE_TESTLIST tag can be used to enable (YES) or -# disable (NO) the test list. This list is created by putting \test -# commands in the documentation. - -GENERATE_TESTLIST = YES - -# The GENERATE_BUGLIST tag can be used to enable (YES) or -# disable (NO) the bug list. This list is created by putting \bug -# commands in the documentation. - -GENERATE_BUGLIST = YES - -# The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or -# disable (NO) the deprecated list. This list is created by putting -# \deprecated commands in the documentation. - -GENERATE_DEPRECATEDLIST= YES - -# The ENABLED_SECTIONS tag can be used to enable conditional -# documentation sections, marked by \if sectionname ... \endif. - -ENABLED_SECTIONS = - -# The MAX_INITIALIZER_LINES tag determines the maximum number of lines -# the initial value of a variable or define consists of for it to appear in -# the documentation. If the initializer consists of more lines than specified -# here it will be hidden. Use a value of 0 to hide initializers completely. -# The appearance of the initializer of individual variables and defines in the -# documentation can be controlled using \showinitializer or \hideinitializer -# command in the documentation regardless of this setting. - -MAX_INITIALIZER_LINES = 30 - -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - -# If the sources in your project are distributed over multiple directories -# then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is NO. - -SHOW_DIRECTORIES = NO - -# The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from the -# version control system). Doxygen will invoke the program by executing (via -# popen()) the command , where is the value of -# the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the program writes to standard output -# is used as the file version. See the manual for examples. - -FILE_VERSION_FILTER = - -#--------------------------------------------------------------------------- -# configuration options related to warning and progress messages -#--------------------------------------------------------------------------- - -# The QUIET tag can be used to turn on/off the messages that are generated -# by doxygen. Possible values are YES and NO. If left blank NO is used. - -QUIET = NO - -# The WARNINGS tag can be used to turn on/off the warning messages that are -# generated by doxygen. Possible values are YES and NO. If left blank -# NO is used. - -WARNINGS = YES - -# If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings -# for undocumented members. If EXTRACT_ALL is set to YES then this flag will -# automatically be disabled. - -WARN_IF_UNDOCUMENTED = YES - -# If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for -# potential errors in the documentation, such as not documenting some -# parameters in a documented function, or documenting parameters that -# don't exist or using markup commands wrongly. - -WARN_IF_DOC_ERROR = YES - -# This WARN_NO_PARAMDOC option can be abled to get warnings for -# functions that are documented, but have no documentation for their parameters -# or return value. If set to NO (the default) doxygen will only warn about -# wrong or incomplete parameter documentation, but not about the absence of -# documentation. - -WARN_NO_PARAMDOC = YES - -# The WARN_FORMAT tag determines the format of the warning messages that -# doxygen can produce. The string should contain the $file, $line, and $text -# tags, which will be replaced by the file and line number from which the -# warning originated and the warning text. Optionally the format may contain -# $version, which will be replaced by the version of the file (if it could -# be obtained via FILE_VERSION_FILTER) - -WARN_FORMAT = "$file:$line: $text" - -# The WARN_LOGFILE tag can be used to specify a file to which warning -# and error messages should be written. If left blank the output is written -# to stderr. - -WARN_LOGFILE = Output/Doxygen/log.txt - -#--------------------------------------------------------------------------- -# configuration options related to the input files -#--------------------------------------------------------------------------- - -# The INPUT tag can be used to specify the files and/or directories that contain -# documented source files. You may enter file names like "myfile.cpp" or -# directories like "/usr/src/myproject". Separate the files or directories -# with spaces. - -INPUT = . - -# If the value of the INPUT tag contains directories, you can use the -# FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank the following patterns are tested: -# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py - -FILE_PATTERNS = *.h *.hpp - -# The RECURSIVE tag can be used to turn specify whether or not subdirectories -# should be searched for input files as well. Possible values are YES and NO. -# If left blank NO is used. - -RECURSIVE = YES - -# The EXCLUDE tag can be used to specify files and/or directories that should -# excluded from the INPUT source files. This way you can easily exclude a -# subdirectory from a directory tree whose root is specified with the INPUT tag. - -EXCLUDE = Output LibXML FColladaTest - -# The EXCLUDE_SYMLINKS tag can be used select whether or not files or -# directories that are symbolic links (a Unix filesystem feature) are excluded -# from the input. - -EXCLUDE_SYMLINKS = NO - -# If the value of the INPUT tag contains directories, you can use the -# EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude -# certain files from those directories. Note that the wildcards are matched -# against the file with absolute path, so to exclude all test directories -# for example use the pattern */test/* - -EXCLUDE_PATTERNS = - -# The EXAMPLE_PATH tag can be used to specify one or more files or -# directories that contain example code fragments that are included (see -# the \include command). - -EXAMPLE_PATH = - -# If the value of the EXAMPLE_PATH tag contains directories, you can use the -# EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp -# and *.h) to filter out the source-files in the directories. If left -# blank all files are included. - -EXAMPLE_PATTERNS = - -# If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be -# searched for input files to be used with the \include or \dontinclude -# commands irrespective of the value of the RECURSIVE tag. -# Possible values are YES and NO. If left blank NO is used. - -EXAMPLE_RECURSIVE = NO - -# The IMAGE_PATH tag can be used to specify one or more files or -# directories that contain image that are included in the documentation (see -# the \image command). - -IMAGE_PATH = - -# The INPUT_FILTER tag can be used to specify a program that doxygen should -# invoke to filter for each input file. Doxygen will invoke the filter program -# by executing (via popen()) the command , where -# is the value of the INPUT_FILTER tag, and is the name of an -# input file. Doxygen will then use the output that the filter program writes -# to standard output. If FILTER_PATTERNS is specified, this tag will be -# ignored. - -INPUT_FILTER = - -# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern -# basis. Doxygen will compare the file name with each pattern and apply the -# filter if there is a match. The filters are a list of the form: -# pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further -# info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER -# is applied to all files. - -FILTER_PATTERNS = - -# If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using -# INPUT_FILTER) will be used to filter the input files when producing source -# files to browse (i.e. when SOURCE_BROWSER is set to YES). - -FILTER_SOURCE_FILES = NO - -#--------------------------------------------------------------------------- -# configuration options related to source browsing -#--------------------------------------------------------------------------- - -# If the SOURCE_BROWSER tag is set to YES then a list of source files will -# be generated. Documented entities will be cross-referenced with these sources. -# Note: To get rid of all source code in the generated output, make sure also -# VERBATIM_HEADERS is set to NO. - -SOURCE_BROWSER = NO - -# Setting the INLINE_SOURCES tag to YES will include the body -# of functions and classes directly in the documentation. - -INLINE_SOURCES = NO - -# Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct -# doxygen to hide any special comment blocks from generated source code -# fragments. Normal C and C++ comments will always remain visible. - -STRIP_CODE_COMMENTS = YES - -# If the REFERENCED_BY_RELATION tag is set to YES (the default) -# then for each documented function all documented -# functions referencing it will be listed. - -REFERENCED_BY_RELATION = YES - -# If the REFERENCES_RELATION tag is set to YES (the default) -# then for each documented function all documented entities -# called/used by that function will be listed. - -REFERENCES_RELATION = YES - -# If the USE_HTAGS tag is set to YES then the references to source code -# will point to the HTML generated by the htags(1) tool instead of doxygen -# built-in source browser. The htags tool is part of GNU's global source -# tagging system (see http://www.gnu.org/software/global/global.html). You -# will need version 4.8.6 or higher. - -USE_HTAGS = NO - -# If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen -# will generate a verbatim copy of the header file for each class for -# which an include is specified. Set to NO to disable this. - -VERBATIM_HEADERS = YES - -#--------------------------------------------------------------------------- -# configuration options related to the alphabetical class index -#--------------------------------------------------------------------------- - -# If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index -# of all compounds will be generated. Enable this if the project -# contains a lot of classes, structs, unions or interfaces. - -ALPHABETICAL_INDEX = YES - -# If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then -# the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns -# in which this list will be split (can be a number in the range [1..20]) - -COLS_IN_ALPHA_INDEX = 5 - -# In case all classes in a project start with a common prefix, all -# classes will be put under the same header in the alphabetical index. -# The IGNORE_PREFIX tag can be used to specify one or more prefixes that -# should be ignored while generating the index headers. - -IGNORE_PREFIX = - -#--------------------------------------------------------------------------- -# configuration options related to the HTML output -#--------------------------------------------------------------------------- - -# If the GENERATE_HTML tag is set to YES (the default) Doxygen will -# generate HTML output. - -GENERATE_HTML = YES - -# The HTML_OUTPUT tag is used to specify where the HTML docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `html' will be used as the default path. - -HTML_OUTPUT = html - -# The HTML_FILE_EXTENSION tag can be used to specify the file extension for -# each generated HTML page (for example: .htm,.php,.asp). If it is left blank -# doxygen will generate files with .html extension. - -HTML_FILE_EXTENSION = .html - -# The HTML_HEADER tag can be used to specify a personal HTML header for -# each generated HTML page. If it is left blank doxygen will generate a -# standard header. - -HTML_HEADER = - -# The HTML_FOOTER tag can be used to specify a personal HTML footer for -# each generated HTML page. If it is left blank doxygen will generate a -# standard footer. - -HTML_FOOTER = - -# The HTML_STYLESHEET tag can be used to specify a user-defined cascading -# style sheet that is used by each HTML page. It can be used to -# fine-tune the look of the HTML output. If the tag is left blank doxygen -# will generate a default style sheet. Note that doxygen will try to copy -# the style sheet file to the HTML output directory, so don't put your own -# stylesheet in the HTML output directory as well, or it will be erased! - -HTML_STYLESHEET = - -# If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, -# files or namespaces will be aligned in HTML using tables. If set to -# NO a bullet list will be used. - -HTML_ALIGN_MEMBERS = YES - -# If the GENERATE_HTMLHELP tag is set to YES, additional index files -# will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) -# of the generated HTML documentation. - -GENERATE_HTMLHELP = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can -# be used to specify the file name of the resulting .chm file. You -# can add a path in front of the file if the result should not be -# written to the html output directory. - -CHM_FILE = - -# If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can -# be used to specify the location (absolute path including file name) of -# the HTML help compiler (hhc.exe). If non-empty doxygen will try to run -# the HTML help compiler on the generated index.hhp. - -HHC_LOCATION = - -# If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag -# controls if a separate .chi index file is generated (YES) or that -# it should be included in the master .chm file (NO). - -GENERATE_CHI = NO - -# If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag -# controls whether a binary table of contents is generated (YES) or a -# normal table of contents (NO) in the .chm file. - -BINARY_TOC = NO - -# The TOC_EXPAND flag can be set to YES to add extra items for group members -# to the contents of the HTML help documentation and to the tree view. - -TOC_EXPAND = NO - -# The DISABLE_INDEX tag can be used to turn on/off the condensed index at -# top of each HTML page. The value NO (the default) enables the index and -# the value YES disables it. - -DISABLE_INDEX = NO - -# This tag can be used to set the number of enum values (range [1..20]) -# that doxygen will group on one line in the generated HTML documentation. - -ENUM_VALUES_PER_LINE = 4 - -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that -# is generated for HTML Help). For this to work a browser that supports -# JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, -# Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. - -GENERATE_TREEVIEW = NO - -# If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be -# used to set the initial width (in pixels) of the frame in which the tree -# is shown. - -TREEVIEW_WIDTH = 250 - -#--------------------------------------------------------------------------- -# configuration options related to the LaTeX output -#--------------------------------------------------------------------------- - -# If the GENERATE_LATEX tag is set to YES (the default) Doxygen will -# generate Latex output. - -GENERATE_LATEX = NO - -# The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `latex' will be used as the default path. - -LATEX_OUTPUT = latex - -# The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be -# invoked. If left blank `latex' will be used as the default command name. - -LATEX_CMD_NAME = latex - -# The MAKEINDEX_CMD_NAME tag can be used to specify the command name to -# generate index for LaTeX. If left blank `makeindex' will be used as the -# default command name. - -MAKEINDEX_CMD_NAME = makeindex - -# If the COMPACT_LATEX tag is set to YES Doxygen generates more compact -# LaTeX documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_LATEX = NO - -# The PAPER_TYPE tag can be used to set the paper type that is used -# by the printer. Possible values are: a4, a4wide, letter, legal and -# executive. If left blank a4wide will be used. - -PAPER_TYPE = a4wide - -# The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX -# packages that should be included in the LaTeX output. - -EXTRA_PACKAGES = - -# The LATEX_HEADER tag can be used to specify a personal LaTeX header for -# the generated latex document. The header should contain everything until -# the first chapter. If it is left blank doxygen will generate a -# standard header. Notice: only use this tag if you know what you are doing! - -LATEX_HEADER = - -# If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated -# is prepared for conversion to pdf (using ps2pdf). The pdf file will -# contain links (just like the HTML output) instead of page references -# This makes the output suitable for online browsing using a pdf viewer. - -PDF_HYPERLINKS = NO - -# If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of -# plain latex in the generated Makefile. Set this option to YES to get a -# higher quality PDF documentation. - -USE_PDFLATEX = NO - -# If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. -# command to the generated LaTeX files. This will instruct LaTeX to keep -# running if errors occur, instead of asking the user for help. -# This option is also used when generating formulas in HTML. - -LATEX_BATCHMODE = NO - -# If LATEX_HIDE_INDICES is set to YES then doxygen will not -# include the index chapters (such as File Index, Compound Index, etc.) -# in the output. - -LATEX_HIDE_INDICES = NO - -#--------------------------------------------------------------------------- -# configuration options related to the RTF output -#--------------------------------------------------------------------------- - -# If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output -# The RTF output is optimized for Word 97 and may not look very pretty with -# other RTF readers or editors. - -GENERATE_RTF = NO - -# The RTF_OUTPUT tag is used to specify where the RTF docs will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `rtf' will be used as the default path. - -RTF_OUTPUT = rtf - -# If the COMPACT_RTF tag is set to YES Doxygen generates more compact -# RTF documents. This may be useful for small projects and may help to -# save some trees in general. - -COMPACT_RTF = NO - -# If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated -# will contain hyperlink fields. The RTF file will -# contain links (just like the HTML output) instead of page references. -# This makes the output suitable for online browsing using WORD or other -# programs which support those fields. -# Note: wordpad (write) and others do not support links. - -RTF_HYPERLINKS = NO - -# Load stylesheet definitions from file. Syntax is similar to doxygen's -# config file, i.e. a series of assignments. You only have to provide -# replacements, missing definitions are set to their default value. - -RTF_STYLESHEET_FILE = - -# Set optional variables used in the generation of an rtf document. -# Syntax is similar to doxygen's config file. - -RTF_EXTENSIONS_FILE = - -#--------------------------------------------------------------------------- -# configuration options related to the man page output -#--------------------------------------------------------------------------- - -# If the GENERATE_MAN tag is set to YES (the default) Doxygen will -# generate man pages - -GENERATE_MAN = NO - -# The MAN_OUTPUT tag is used to specify where the man pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `man' will be used as the default path. - -MAN_OUTPUT = man - -# The MAN_EXTENSION tag determines the extension that is added to -# the generated man pages (default is the subroutine's section .3) - -MAN_EXTENSION = .3 - -# If the MAN_LINKS tag is set to YES and Doxygen generates man output, -# then it will generate one additional man file for each entity -# documented in the real man page(s). These additional files -# only source the real man page, but without them the man command -# would be unable to find the correct page. The default is NO. - -MAN_LINKS = NO - -#--------------------------------------------------------------------------- -# configuration options related to the XML output -#--------------------------------------------------------------------------- - -# If the GENERATE_XML tag is set to YES Doxygen will -# generate an XML file that captures the structure of -# the code including all documentation. - -GENERATE_XML = NO - -# The XML_OUTPUT tag is used to specify where the XML pages will be put. -# If a relative path is entered the value of OUTPUT_DIRECTORY will be -# put in front of it. If left blank `xml' will be used as the default path. - -XML_OUTPUT = xml - -# The XML_SCHEMA tag can be used to specify an XML schema, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_SCHEMA = - -# The XML_DTD tag can be used to specify an XML DTD, -# which can be used by a validating XML parser to check the -# syntax of the XML files. - -XML_DTD = - -# If the XML_PROGRAMLISTING tag is set to YES Doxygen will -# dump the program listings (including syntax highlighting -# and cross-referencing information) to the XML output. Note that -# enabling this will significantly increase the size of the XML output. - -XML_PROGRAMLISTING = YES - -#--------------------------------------------------------------------------- -# configuration options for the AutoGen Definitions output -#--------------------------------------------------------------------------- - -# If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will -# generate an AutoGen Definitions (see autogen.sf.net) file -# that captures the structure of the code including all -# documentation. Note that this feature is still experimental -# and incomplete at the moment. - -GENERATE_AUTOGEN_DEF = NO - -#--------------------------------------------------------------------------- -# configuration options related to the Perl module output -#--------------------------------------------------------------------------- - -# If the GENERATE_PERLMOD tag is set to YES Doxygen will -# generate a Perl module file that captures the structure of -# the code including all documentation. Note that this -# feature is still experimental and incomplete at the -# moment. - -GENERATE_PERLMOD = NO - -# If the PERLMOD_LATEX tag is set to YES Doxygen will generate -# the necessary Makefile rules, Perl scripts and LaTeX code to be able -# to generate PDF and DVI output from the Perl module output. - -PERLMOD_LATEX = NO - -# If the PERLMOD_PRETTY tag is set to YES the Perl module output will be -# nicely formatted so it can be parsed by a human reader. This is useful -# if you want to understand what is going on. On the other hand, if this -# tag is set to NO the size of the Perl module output will be much smaller -# and Perl will parse it just the same. - -PERLMOD_PRETTY = YES - -# The names of the make variables in the generated doxyrules.make file -# are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. -# This is useful so different doxyrules.make files included by the same -# Makefile don't overwrite each other's variables. - -PERLMOD_MAKEVAR_PREFIX = - -#--------------------------------------------------------------------------- -# Configuration options related to the preprocessor -#--------------------------------------------------------------------------- - -# If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will -# evaluate all C-preprocessor directives found in the sources and include -# files. - -ENABLE_PREPROCESSING = YES - -# If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro -# names in the source code. If set to NO (the default) only conditional -# compilation will be performed. Macro expansion can be done in a controlled -# way by setting EXPAND_ONLY_PREDEF to YES. - -MACRO_EXPANSION = NO - -# If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES -# then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_DEFINED tags. - -EXPAND_ONLY_PREDEF = NO - -# If the SEARCH_INCLUDES tag is set to YES (the default) the includes files -# in the INCLUDE_PATH (see below) will be search if a #include is found. - -SEARCH_INCLUDES = YES - -# The INCLUDE_PATH tag can be used to specify one or more directories that -# contain include files that are not input files but should be processed by -# the preprocessor. - -INCLUDE_PATH = - -# You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard -# patterns (like *.h and *.hpp) to filter out the header-files in the -# directories. If left blank, the patterns specified with FILE_PATTERNS will -# be used. - -INCLUDE_FILE_PATTERNS = - -# The PREDEFINED tag can be used to specify one or more macro names that -# are defined before the preprocessor is started (similar to the -D option of -# gcc). The argument of the tag is a list of macros of the form: name -# or name=definition (no spaces). If the definition and the = are -# omitted =1 is assumed. To prevent a macro definition from being -# undefined via #undef or recursively expanded use the := operator -# instead of the = operator. - -PREDEFINED = HAS_LIBXML HAS_VECTORTYPES UNICODE _UNICODE - -# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then -# this tag can be used to specify a list of macro names that should be expanded. -# The macro definition that is found in the sources will be used. -# Use the PREDEFINED tag if you want to use a different macro definition. - -EXPAND_AS_DEFINED = - -# If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then -# doxygen's preprocessor will remove all function-like macros that are alone -# on a line, have an all uppercase name, and do not end with a semicolon. Such -# function macros are typically used for boiler-plate code, and will confuse -# the parser if not removed. - -SKIP_FUNCTION_MACROS = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to external references -#--------------------------------------------------------------------------- - -# The TAGFILES option can be used to specify one or more tagfiles. -# Optionally an initial location of the external documentation -# can be added for each tagfile. The format of a tag file without -# this location is as follows: -# TAGFILES = file1 file2 ... -# Adding location for the tag files is done as follows: -# TAGFILES = file1=loc1 "file2 = loc2" ... -# where "loc1" and "loc2" can be relative or absolute paths or -# URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) -# If a tag file is not located in the directory in which doxygen -# is run, you must also specify the path to the tagfile here. - -TAGFILES = - -# When a file name is specified after GENERATE_TAGFILE, doxygen will create -# a tag file that is based on the input files it reads. - -GENERATE_TAGFILE = - -# If the ALLEXTERNALS tag is set to YES all external classes will be listed -# in the class index. If set to NO only the inherited external classes -# will be listed. - -ALLEXTERNALS = NO - -# If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed -# in the modules index. If set to NO, only the current project's groups will -# be listed. - -EXTERNAL_GROUPS = YES - -# The PERL_PATH should be the absolute path and name of the perl script -# interpreter (i.e. the result of `which perl'). - -PERL_PATH = /usr/bin/perl - -#--------------------------------------------------------------------------- -# Configuration options related to the dot tool -#--------------------------------------------------------------------------- - -# If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will -# generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base -# or super classes. Setting the tag to NO turns the diagrams off. Note that -# this option is superseded by the HAVE_DOT option below. This is only a -# fallback. It is recommended to install and use dot, since it yields more -# powerful graphs. - -CLASS_DIAGRAMS = YES - -# If set to YES, the inheritance and collaboration graphs will hide -# inheritance and usage relations if the target is undocumented -# or is not a class. - -HIDE_UNDOC_RELATIONS = YES - -# If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is -# available from the path. This tool is part of Graphviz, a graph visualization -# toolkit from AT&T and Lucent Bell Labs. The other options in this section -# have no effect if this option is set to NO (the default) - -HAVE_DOT = NO - -# If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect inheritance relations. Setting this tag to YES will force the -# the CLASS_DIAGRAMS tag to NO. - -CLASS_GRAPH = YES - -# If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for each documented class showing the direct and -# indirect implementation dependencies (inheritance, containment, and -# class references variables) of the class with other documented classes. - -COLLABORATION_GRAPH = YES - -# If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen -# will generate a graph for groups, showing the direct groups dependencies - -GROUP_GRAPHS = YES - -# If the UML_LOOK tag is set to YES doxygen will generate inheritance and -# collaboration diagrams in a style similar to the OMG's Unified Modeling -# Language. - -UML_LOOK = NO - -# If set to YES, the inheritance and collaboration graphs will show the -# relations between templates and their instances. - -TEMPLATE_RELATIONS = NO - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT -# tags are set to YES then doxygen will generate a graph for each documented -# file showing the direct and indirect include dependencies of the file with -# other documented files. - -INCLUDE_GRAPH = YES - -# If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and -# HAVE_DOT tags are set to YES then doxygen will generate a graph for each -# documented header file showing the documented files that directly or -# indirectly include this file. - -INCLUDED_BY_GRAPH = YES - -# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a call dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. - -CALL_GRAPH = NO - -# If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen -# will graphical hierarchy of all classes instead of a textual one. - -GRAPHICAL_HIERARCHY = YES - -# If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES -# then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include -# relations between the files in the directories. - -DIRECTORY_GRAPH = YES - -# The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif -# If left blank png will be used. - -DOT_IMAGE_FORMAT = png - -# The tag DOT_PATH can be used to specify the path where the dot tool can be -# found. If left blank, it is assumed the dot tool can be found in the path. - -DOT_PATH = - -# The DOTFILE_DIRS tag can be used to specify one or more directories that -# contain dot files that are included in the documentation (see the -# \dotfile command). - -DOTFILE_DIRS = - -# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - -MAX_DOT_GRAPH_WIDTH = 1024 - -# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - -MAX_DOT_GRAPH_HEIGHT = 1024 - -# The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the -# graphs generated by dot. A depth value of 3 means that only nodes reachable -# from the root by following a path via at most 3 edges will be shown. Nodes -# that lay further from the root node will be omitted. Note that setting this -# option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that a graph may be further truncated if the graph's -# image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH -# and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default), -# the graph is not depth-constrained. - -MAX_DOT_GRAPH_DEPTH = 0 - -# Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, which results in a white background. -# Warning: Depending on the platform used, enabling this option may lead to -# badly anti-aliased labels on the edges of a graph (i.e. they become hard to -# read). - -DOT_TRANSPARENT = NO - -# Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output -# files in one run (i.e. multiple -o and -T options on the command line). This -# makes dot run faster, but since only newer versions of dot (>1.8.10) -# support this, this feature is disabled by default. - -DOT_MULTI_TARGETS = NO - -# If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will -# generate a legend page explaining the meaning of the various boxes and -# arrows in the dot generated graphs. - -GENERATE_LEGEND = YES - -# If the DOT_CLEANUP tag is set to YES (the default) Doxygen will -# remove the intermediate dot files that are used to generate -# the various graphs. - -DOT_CLEANUP = YES - -#--------------------------------------------------------------------------- -# Configuration::additions related to the search engine -#--------------------------------------------------------------------------- - -# The SEARCHENGINE tag specifies whether or not a search engine should be -# used. If set to NO the values of all tags below this one will be ignored. - -SEARCHENGINE = NO diff --git a/Extras/FCollada/FCDocument/FCDAnimated.cpp b/Extras/FCollada/FCDocument/FCDAnimated.cpp deleted file mode 100644 index cc41cb687..000000000 --- a/Extras/FCollada/FCDocument/FCDAnimated.cpp +++ /dev/null @@ -1,544 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDAnimationChannel.h" -#include "FCDocument/FCDAnimationCurve.h" -#include "FCDocument/FCDAnimationMultiCurve.h" -#include "FCDocument/FCDAnimated.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDAnimated::FCDAnimated(FCDocument* document, size_t valueCount) : FCDObject(document, "FCDAnimated") -{ - arrayElement = -1; - - // Allocate the values/qualifiers/curves arrays - values.resize(valueCount, NULL); - qualifiers.resize(valueCount, ""); - curves.resize(valueCount, NULL); -} - -FCDAnimated::~FCDAnimated() -{ - values.clear(); - qualifiers.clear(); - curves.clear(); -} - -// Assigns a curve to a value of the animated element. -bool FCDAnimated::SetCurve(size_t index, FCDAnimationCurve* curve) -{ - FUAssert(index < GetValueCount(), return false); - curves.at(index) = curve; - return true; -} - -// Removes the curve affecting a value of the animated element. -bool FCDAnimated::RemoveCurve(size_t index) -{ - FUAssert(index < GetValueCount(), return false); - bool hasCurve = curves[index] != NULL; - curves[index] = NULL; - return hasCurve; -} - -bool FCDAnimated::Link(xmlNode* node) -{ - bool linked = false; - - if (node != NULL) - { - // Write down the expected target string for the given node - FUDaeParser::CalculateNodeTargetPointer(node, pointer); - - // Check if this animated value is used as a driver - linked |= GetDocument()->LinkDriver(this); - - // Retrieve the list of the channels pointing to this node - FCDAnimationChannelList channels; - GetDocument()->FindAnimationChannels(pointer, channels); - linked |= ProcessChannels(channels); - } - else linked = true; - - if (linked) - { - // Register this animated value with the document - GetDocument()->RegisterAnimatedValue(this); - } - - return linked; -} - -bool FCDAnimated::ProcessChannels(FCDAnimationChannelList& channels) -{ - bool linked = false; - for (FCDAnimationChannelList::iterator it = channels.begin(); it != channels.end(); ++it) - { - FCDAnimationChannel* channel = *it; - const FCDAnimationCurveList& channelCurves = channel->GetCurves(); - if (channelCurves.empty()) continue; - - // Retrieve the channel's qualifier and check for a requested matrix element - string qualifier = channel->GetTargetQualifier(); - if (arrayElement != -1) - { - int32 element = ReadTargetMatrixElement(qualifier); - if (arrayElement != element) continue; - } - - if (qualifier.empty()) - { - // An empty qualifier implies that the channel should provide ALL the curves - for (size_t i = 0; i < channelCurves.size() && i < curves.size(); ++i) - { - curves[i] = channelCurves[i]; - linked = true; - } - } - else - { - // Attempt to match the qualifier with this animated qualifiers - size_t index; - for (index = 0; index < qualifiers.size(); ++index) - { - if (qualifiers[index] == qualifier) break; - } - - // Check for a matrix element instead - if (index == qualifiers.size()) index = ReadTargetMatrixElement(qualifier); - if (index < qualifiers.size()) - { - curves[index] = channelCurves.front(); - linked = true; - } - /* else return status.Fail(FS("Invalid qualifier for animation channel target: ") + TO_FSTRING(pointer)); */ - } - } - - if (linked) - { - // Now that the curves are imported: set their target information - for (size_t i = 0; i < curves.size(); ++i) - { - if (curves[i] != NULL) - { - curves[i]->SetTargetElement(arrayElement); - curves[i]->SetTargetQualifier(qualifiers[i]); - } - } - } - - return linked; -} - -const string& FCDAnimated::GetQualifier(size_t index) const -{ - FUAssert(index < GetValueCount(), return emptyString); - return qualifiers.at(index); -} - -// Retrieves an animated value, given a valid qualifier -float* FCDAnimated::FindValue(const string& qualifier) -{ - for (size_t i = 0; i < qualifiers.size(); ++i) - { - if (qualifiers[i] == qualifier) return values[i]; - } - return NULL; -} -const float* FCDAnimated::FindValue(const string& qualifier) const -{ - for (size_t i = 0; i < qualifiers.size(); ++i) - { - if (qualifiers[i] == qualifier) return values[i]; - } - return NULL; -} - -// Retrieve the index of a given qualifier -size_t FCDAnimated::FindQualifier(const char* qualifier) const -{ - for (size_t i = 0; i < qualifiers.size(); ++i) - { - if (qualifiers[i] == qualifier) return i; - } - - // Otherwise, check for a matrix element - string q = qualifier; - int32 matrixElement = FUDaeParser::ReadTargetMatrixElement(q); - if (matrixElement >= 0 && matrixElement < (int32) qualifiers.size()) return matrixElement; - return size_t(-1); -} - -// Retrieve the index of a given value pointer -size_t FCDAnimated::FindValue(const float* value) const -{ - for (size_t i = 0; i < values.size(); ++i) - { - if (values[i] == value) return i; - } - return size_t(-1); -} - -// Returns whether any of the contained curves are non-NULL -bool FCDAnimated::HasCurve() const -{ - FCDAnimationCurveList::const_iterator cit; - for (cit = curves.begin(); cit != curves.end() && (*cit) == NULL; ++cit) {} - return cit != curves.end(); -} - -// Create one multi-curve out of this animated value's single curves -FCDAnimationMultiCurve* FCDAnimated::CreateMultiCurve() const -{ - FloatList defaultValues; - size_t count = values.size(); - defaultValues.resize(count); - for (size_t i = 0; i < count; ++i) defaultValues[i] = (*values[i]); - - vector toMerge; - toMerge.resize(count); - for (size_t i = 0; i < count; ++i) toMerge[i] = curves[i]; - return FCDAnimationMultiCurve::MergeCurves(toMerge, defaultValues); -} - -// Create one multi-curve out of the single curves from many FCDAnimated objects -FCDAnimationMultiCurve* FCDAnimated::CreateMultiCurve(const FCDAnimatedList& toMerge) -{ - // Calculate the total dimension of the curve to create - size_t count = 0; - for (FCDAnimatedList::const_iterator cit = toMerge.begin(); cit != toMerge.end(); ++cit) - { - count += (*cit)->GetValueCount(); - } - - // Generate the list of default values and the list of curves - FloatList defaultValues(count, 0.0f); - vector curves(count, NULL); - size_t offset = 0; - for (FCDAnimatedList::const_iterator cit = toMerge.begin(); cit != toMerge.end(); ++cit) - { - size_t localCount = (*cit)->GetValueCount(); - for (size_t i = 0; i < localCount; ++i) - { - defaultValues[offset + i] = *(*cit)->GetValue(i); - curves[offset + i] = (*cit)->GetCurve(i); - } - offset += localCount; - } - - return FCDAnimationMultiCurve::MergeCurves(curves, defaultValues); -} - -// Sample the animated values for a given time -void FCDAnimated::Evaluate(float time) -{ - size_t valueCount = values.size(); - size_t curveCount = curves.size(); - size_t count = min(curveCount, valueCount); - for (size_t i = 0; i < count; ++i) - { - // Retrieve the curve and the corresponding value - FCDAnimationCurve* curve = curves[i]; - if (curve == NULL) continue; - float* value = values[i]; - if (value == NULL) continue; - - // Evaluate the curve at this time - (*value) = curve->Evaluate(time); - } -} - -FCDAnimated* FCDAnimated::Clone(FCDocument* document) -{ - FCDAnimated* clone = new FCDAnimated(document, GetValueCount()); - clone->arrayElement = arrayElement; - for(size_t i = 0; i < curves.size(); ++i) - { - clone->curves[i] = curves[i]->Clone(); - } - clone->pointer = pointer; - clone->qualifiers = qualifiers; - clone->values = values; - document->RegisterAnimatedValue(clone); - return clone; -} - - -// Clones the whole animated associated with a given value. -FCDAnimated* FCDAnimated::Clone(FCDocument* document, const float* animatedValue, FloatPtrList& newAnimatedValues) -{ - const FCDAnimated* toClone = document->FindAnimatedValue(animatedValue); - if (toClone == NULL) return NULL; - - FCDAnimated* clone = new FCDAnimated(document, toClone->GetValueCount()); - clone->arrayElement = toClone->arrayElement; - for(size_t i = 0; i < toClone->curves.size(); ++i) - { - clone->curves[i] = toClone->curves[i]; - } - - clone->pointer = toClone->pointer; - clone->qualifiers = toClone->qualifiers; - clone->values = newAnimatedValues; - document->RegisterAnimatedValue(clone); - return clone; -} - -FCDAnimatedFloat::FCDAnimatedFloat(FCDocument* document, float* value, int32 _arrayElement) : FCDAnimated(document, 1) -{ - values[0] = value; - qualifiers[0] = ""; - arrayElement = _arrayElement; -} - -FCDAnimatedFloat* FCDAnimatedFloat::Create(FCDocument* document, float* value, int32 arrayElement) -{ - FCDAnimatedFloat* animated = new FCDAnimatedFloat(document, value, arrayElement); - if (!animated->Link(NULL)) SAFE_DELETE(animated); - return animated; -} -FCDAnimatedFloat* FCDAnimatedFloat::Create(FCDocument* document, xmlNode* node, float* value, int32 arrayElement) -{ - FCDAnimatedFloat* animated = new FCDAnimatedFloat(document, value, arrayElement); - if (!animated->Link(node)) SAFE_DELETE(animated); - return animated; -} - -FCDAnimated* FCDAnimatedFloat::Clone(FCDocument* document, const float* oldValue, float* newValue) -{ - FloatPtrList newValues; - newValues.push_back(newValue); - return FCDAnimated::Clone(document, oldValue, newValues); -} - -FCDAnimatedPoint3::FCDAnimatedPoint3(FCDocument* document, FMVector3* value, int32 _arrayElement) : FCDAnimated(document, 3) -{ - values[0] = &value->x; values[1] = &value->y; values[2] = &value->z; - qualifiers[0] = ".X"; qualifiers[1] = ".Y"; qualifiers[2] = ".Z"; - arrayElement = _arrayElement; -} - -FCDAnimatedPoint3* FCDAnimatedPoint3::Create(FCDocument* document, FMVector3* value, int32 arrayElement) -{ - FCDAnimatedPoint3* animated = new FCDAnimatedPoint3(document, value, arrayElement); - if (!animated->Link(NULL)) SAFE_DELETE(animated); - return animated; -} -FCDAnimatedPoint3* FCDAnimatedPoint3::Create(FCDocument* document, xmlNode* node, FMVector3* value, int32 arrayElement) -{ - FCDAnimatedPoint3* animated = new FCDAnimatedPoint3(document, value, arrayElement); - if (!animated->Link(node)) SAFE_DELETE(animated); - return animated; -} - -FCDAnimated* FCDAnimatedPoint3::Clone(FCDocument* document, const FMVector3* oldValue, FMVector3* newValue) -{ - FloatPtrList newValues; - newValues.push_back(&newValue->x); newValues.push_back(&newValue->y); newValues.push_back(&newValue->z); - return FCDAnimated::Clone(document, &oldValue->x, newValues); -} - -FCDAnimatedColor::FCDAnimatedColor(FCDocument* document, FMVector3* value, int32 _arrayElement) : FCDAnimated(document, 3) -{ - values[0] = &value->x; values[1] = &value->y; values[2] = &value->z; - qualifiers[0] = ".R"; qualifiers[1] = ".G"; qualifiers[2] = ".B"; - arrayElement = _arrayElement; -} - -FCDAnimatedColor* FCDAnimatedColor::Create(FCDocument* document, FMVector3* value, int32 arrayElement) -{ - FCDAnimatedColor* animated = new FCDAnimatedColor(document, value, arrayElement); - if (!animated->Link(NULL)) SAFE_DELETE(animated); - return animated; -} -FCDAnimatedColor* FCDAnimatedColor::Create(FCDocument* document, xmlNode* node, FMVector3* value, int32 arrayElement) -{ - FCDAnimatedColor* animated = new FCDAnimatedColor(document, value, arrayElement); - if (!animated->Link(node)) SAFE_DELETE(animated); - return animated; -} - -FCDAnimated* FCDAnimatedColor::Clone(FCDocument* document, const FMVector3* oldValue, FMVector3* newValue) -{ - FloatPtrList newValues; newValues.push_back(&newValue->x); newValues.push_back(&newValue->y); newValues.push_back(&newValue->z); - return FCDAnimated::Clone(document, &oldValue->x, newValues); -} - -FCDAnimatedAngle::FCDAnimatedAngle(FCDocument* document, float* value, int32 _arrayElement) : FCDAnimated(document, 1) -{ - values[0] = value; - qualifiers[0] = ".ANGLE"; - arrayElement = _arrayElement; -} - -FCDAnimatedAngle* FCDAnimatedAngle::Create(FCDocument* document, float* value, int32 arrayElement) -{ - FCDAnimatedAngle* animated = new FCDAnimatedAngle(document, value, arrayElement); - if (!animated->Link(NULL)) SAFE_DELETE(animated); - return animated; -} -FCDAnimatedAngle* FCDAnimatedAngle::Create(FCDocument* document, xmlNode* node, float* value, int32 arrayElement) -{ - FCDAnimatedAngle* animated = new FCDAnimatedAngle(document, value, arrayElement); - if (!animated->Link(node)) SAFE_DELETE(animated); - return animated; -} - -FCDAnimated* FCDAnimatedAngle::Clone(FCDocument* document, const float* oldValue, float* newValue) -{ - FloatPtrList newValues; - newValues.push_back(newValue); - return FCDAnimated::Clone(document, oldValue, newValues); -} - -FCDAnimatedAngleAxis::FCDAnimatedAngleAxis(FCDocument* document, FMVector3* axis, float* angle, int32 _arrayElement) : FCDAnimated(document, 4) -{ - values[0] = &axis->x; values[1] = &axis->y; values[2] = &axis->z; values[3] = angle; - qualifiers[0] = ".X"; qualifiers[1] = ".Y"; qualifiers[2] = ".Z"; qualifiers[3] = ".ANGLE"; - arrayElement = _arrayElement; -} - -FCDAnimatedAngleAxis* FCDAnimatedAngleAxis::Create(FCDocument* document, FMVector3* axis, float* angle, int32 arrayElement) -{ - FCDAnimatedAngleAxis* animated = new FCDAnimatedAngleAxis(document, axis, angle, arrayElement); - if (!animated->Link(NULL)) SAFE_DELETE(animated); - return animated; -} -FCDAnimatedAngleAxis* FCDAnimatedAngleAxis::Create(FCDocument* document, xmlNode* node, FMVector3* axis, float* angle, int32 arrayElement) -{ - FCDAnimatedAngleAxis* animated = new FCDAnimatedAngleAxis(document, axis, angle, arrayElement); - if (!animated->Link(node)) SAFE_DELETE(animated); - return animated; -} - -FCDAnimated* FCDAnimatedAngleAxis::Clone(FCDocument* document, const float* oldAngle, FMVector3* newAxis, float* newAngle) -{ - FloatPtrList newValues; - newValues.push_back(&newAxis->x); newValues.push_back(&newAxis->y); newValues.push_back(&newAxis->z); - newValues.push_back(newAngle); - return FCDAnimated::Clone(document, oldAngle, newValues); -} - -FCDAnimatedMatrix::FCDAnimatedMatrix(FCDocument* document, FMMatrix44* value, int32 _arrayElement) : FCDAnimated(document, 16) -{ - arrayElement = _arrayElement; - -#define MX_V(a,b) values[b*4+a] = (&(*value)[a][b]) - MX_V(0,0); MX_V(1,0); MX_V(2,0); MX_V(3,0); - MX_V(0,1); MX_V(1,1); MX_V(2,1); MX_V(3,1); - MX_V(0,2); MX_V(1,2); MX_V(2,2); MX_V(3,2); - MX_V(0,3); MX_V(1,3); MX_V(2,3); MX_V(3,3); -#undef MX_V - -#define MX_V(a,b) qualifiers[b*4+a] = ("(" #a ")(" #b ")"); - MX_V(0,0); MX_V(0,1); MX_V(0,2); MX_V(0,3); - MX_V(1,0); MX_V(1,1); MX_V(1,2); MX_V(1,3); - MX_V(2,0); MX_V(2,1); MX_V(2,2); MX_V(2,3); - MX_V(3,0); MX_V(3,1); MX_V(3,2); MX_V(3,3); -#undef MX_V -} - -FCDAnimatedMatrix* FCDAnimatedMatrix::Create(FCDocument* document, FMMatrix44* value, int32 arrayElement) -{ - FCDAnimatedMatrix* animated = new FCDAnimatedMatrix(document, value, arrayElement); - if (!animated->Link(NULL)) SAFE_DELETE(animated); - return animated; -} -FCDAnimatedMatrix* FCDAnimatedMatrix::Create(FCDocument* document, xmlNode* node, FMMatrix44* value, int32 arrayElement) -{ - FCDAnimatedMatrix* animated = new FCDAnimatedMatrix(document, value, arrayElement); - if (!animated->Link(node)) SAFE_DELETE(animated); - return animated; -} - -FCDAnimated* FCDAnimatedMatrix::Clone(FCDocument* document, const FMMatrix44* oldMx, FMMatrix44* newMx) -{ - FloatPtrList newValues; - -#define MX_V(a,b) newValues.push_back(&(*newMx)[a][b]); - MX_V(0,0); MX_V(0,1); MX_V(0,2); MX_V(0,3); - MX_V(1,0); MX_V(1,1); MX_V(1,2); MX_V(1,3); - MX_V(2,0); MX_V(2,1); MX_V(2,2); MX_V(2,3); - MX_V(3,0); MX_V(3,1); MX_V(3,2); MX_V(3,3); -#undef MX_V - - return FCDAnimated::Clone(document, &(*oldMx)[0][0], newValues); -} - -FCDAnimatedCustom::FCDAnimatedCustom(FCDocument* document) : FCDAnimated(document, 1) -{ - dummy = 0.0f; -} - -bool FCDAnimatedCustom::Link(xmlNode* node) -{ - bool linked = false; - - // Retrieve the list of the channels pointing to this node - FUDaeParser::CalculateNodeTargetPointer(node, pointer); - FCDAnimationChannelList channels; - GetDocument()->FindAnimationChannels(pointer, channels); - - // Extract all the qualifiers needed to hold these channels - for (FCDAnimationChannelList::iterator itC = channels.begin(); itC != channels.end(); ++itC) - { - FCDAnimationChannel* channel = *itC; - const FCDAnimationCurveList& channelCurves = channel->GetCurves(); - if (channelCurves.empty()) continue; - - // Retrieve the channel's qualifier - string qualifier = channel->GetTargetQualifier(); - if (qualifier.empty()) - { - // Implies one channel holding multiple curves - qualifiers.clear(); - qualifiers.resize(channels.size()); - break; - } - else - { - qualifiers.push_back(qualifier); - } - } - - // Link the curves and check if this animated value is used as a driver - values.resize(qualifiers.size()); - curves.resize(values.size()); - for (size_t i = 0; i < qualifiers.size(); ++i) { values[i] = &dummy; curves[i] = NULL; } - linked |= ProcessChannels(channels); - linked |= GetDocument()->LinkDriver(this); - - if (linked) - { - // Register this animated value with the document - GetDocument()->RegisterAnimatedValue(this); - } - return linked; -} - -FCDAnimatedCustom* FCDAnimatedCustom::Create(FCDocument* document) -{ - FCDAnimatedCustom* animated = new FCDAnimatedCustom(document); - if (!animated->Link(NULL)) SAFE_DELETE(animated); - return animated; -} -FCDAnimatedCustom* FCDAnimatedCustom::Create(FCDocument* document, xmlNode* node) -{ - FCDAnimatedCustom* animated = new FCDAnimatedCustom(document); - if (!animated->Link(node)) SAFE_DELETE(animated); - return animated; -} diff --git a/Extras/FCollada/FCDocument/FCDAnimated.h b/Extras/FCollada/FCDocument/FCDAnimated.h deleted file mode 100644 index 77dedbf26..000000000 --- a/Extras/FCollada/FCDocument/FCDAnimated.h +++ /dev/null @@ -1,488 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDAnimated.h - This file contains the FCDAnimated class. -*/ - -#ifndef _FCD_ANIMATED_H_ -#define _FCD_ANIMATED_H_ - -#include "FCDocument/FCDObject.h" - -class FCDocument; -class FCDAnimated; -class FCDAnimationCurve; -class FCDAnimationChannel; -class FCDAnimationMultiCurve; - -typedef vector FloatPtrList; /**< A dynamically-sized array of floating-point value pointers. */ -typedef vector FCDAnimationCurveList; /**< A dynamically-sized array of animation curves. */ -typedef vector FCDAnimationChannelList; /**< A dynamically-sized array of animation channels. */ -typedef vector FCDAnimatedList; /**< A dynamically-sized array of animated values. */ - -/** - An animated element. - An animated element encapsulates a set of floating-point values that are - marked as animated. - - For this purpose, an animated element holds a list of floating-point values, - their animation curves and their COLLADA qualifiers for the generation of - COLLADA targets. For animated list elements, an animated element holds an array index. - - There are many classes built on top of this class. They represent - the different element types that may be animated, such as 3D points, - colors and matrices. - - @ingroup FCDocument -*/ -class FCOLLADA_EXPORT FCDAnimated : public FCDObject -{ -protected: - /** The list of value pointers. */ - FloatPtrList values; - - /** The list of target qualifiers. - There is always one qualifier for one value pointer. */ - StringList qualifiers; - - /** The list of animation curves. - There is always one curve for one value pointer, although - that curve may be the NULL pointer to indicate a non-animated value. */ - FCDAnimationCurveList curves; - - /** The array index for animated element that belong - to a list of animated elements. This value may be -1 - to indicate that the element does not belong to a list. - Otherwise, the index should always be unsigned. */ - int32 arrayElement; - - /** [INTERNAL] The target pointer prefix. */ - string pointer; - -public: - /** Constructor. - In most cases, it is preferable to create objects of the up-classes. - @param document The COLLADA document that owns this animated element. - @param valueCount The number of values inside the animated element. */ - FCDAnimated(FCDocument* document, size_t valueCount); - - /** Destructor. */ - virtual ~FCDAnimated(); - - /** Retrieves the number of values contained within this animated element. - @return The number of values. */ - inline size_t GetValueCount() const { return values.size(); } - - /** Retrieves the animation curve affecting the value of an animated element. - @param index The value index. - @return The curve affecting the value at the given index. This pointer will - be NULL if the index is out-of-bounds or if the value is not animated. */ - inline FCDAnimationCurve* GetCurve(size_t index) { FUAssert(index < GetValueCount(), return NULL); return curves.at(index); } - inline const FCDAnimationCurve* GetCurve(size_t index) const { FUAssert(index < GetValueCount(), return NULL); return curves.at(index); } /**< See above. */ - - /** Retrieves the list of the curves affecting the values of an animated element. - This list may contain the NULL pointer, where a value is not animated. - @return The list of animation curves. */ - inline FCDAnimationCurveList& GetCurves() { return curves; } - inline const FCDAnimationCurveList& GetCurves() const { return curves; } /**< See above. */ - - /** Assigns a curve to a value of the animated element. - The previously assigned curve will be deleted. - @param index The value index. - @param curve The new curve that will affect the value at the given index. - @return Whether the curve was successfully assigned. Will return false if - the index is out-of-bounds. */ - bool SetCurve(size_t index, FCDAnimationCurve* curve); - - /** Removes the curve affecting a value of the animated element. - @param index The value index. - @return Whether a curve was successfully removed. Will return false - if there was no curve to release or the index is out-of-bounds. */ - bool RemoveCurve(size_t index); - - /** Retrieves the value of an animated element. - @param index The value index. - @return The value at the given index. This pointer will - be NULL if the index is out-of-boudns. */ - inline float* GetValue(size_t index) { FUAssert(index < GetValueCount(), return NULL); return values.at(index); } - inline const float* GetValue(size_t index) const { FUAssert(index < GetValueCount(), return NULL); return values.at(index); } /**< See above. */ - - /** Retrieves the qualifier of the value of an animated element. - @param index The value index. - @return The qualifier for the value. The value returned will be an - empty string when the index is out-of-bounds. */ - inline const string& GetQualifier(size_t index) const; - - /** Retrieves an animated value given a valid qualifier. - @param qualifier A valid qualifier. - @return The animated value for this qualifier. This pointer will be - NULL if the given qualifier is not used within this animated element. */ - float* FindValue(const string& qualifier); - const float* FindValue(const string& qualifier) const; /**< See above. */ - - /** Retrieves an animation curve given a valid qualifier. - @param qualifier A valid qualifier. - @return The animation curve for this qualifier. This pointer will be - NULL if the given qualifier is not used within this animated element - or if the value for the given qualifier is not animated. */ - inline FCDAnimationCurve* FindCurve(const char* qualifier) { return GetCurve(FindQualifier(qualifier)); } - inline FCDAnimationCurve* FindCurve(const string& qualifier) { return FindCurve(qualifier.c_str()); } /**< See above. */ - inline const FCDAnimationCurve* FindCurve(const char* qualifier) const { return GetCurve(FindQualifier(qualifier)); } /**< See above. */ - inline const FCDAnimationCurve* FindCurve(const string& qualifier) const { return FindCurve(qualifier.c_str()); } /**< See above. */ - - /** Retrieves an animation curve given a value pointer. - @param value A value pointer contained within the animated element. - @return The animation curve for this qualifier. This pointer will be - NULL if the value pointer is not contained by this animated element - or if the value is not animated. */ - inline FCDAnimationCurve* FindCurve(const float* value) { return GetCurve(FindValue(value)); } - inline const FCDAnimationCurve* FindCurve(const float* value) const { return GetCurve(FindValue(value)); } /**< See above. */ - - /** Retrieves the value index for a given qualifier. - @param qualifier A valid qualifier. - @return The value index. This value will be -1 to indicate that the - qualifier does not belong to this animated element. */ - size_t FindQualifier(const char* qualifier) const; - inline size_t FindQualifier(const string& qualifier) const { return FindQualifier(qualifier.c_str()); } /**< See above. */ - - /** Retrieves the value index for a given value pointer. - @param value A value pointer contained within the animated element. - @return The value index. This value will be -1 to indicate that the - value pointer is not contained by this animated element. */ - size_t FindValue(const float* value) const; - - /** Retrieves the array index for an animated element. - This value is used only for animated elements that belong - to a list of animated elements within the COLLADA document. - @return The array index. This value will be -1 to indicate that - the animated element does not belong to a list. */ - inline int32 GetArrayElement() const { return arrayElement; } - - /** Sets the array index for an animated element. - This value is used only for animated elements that belong - to a list of animated elements within the COLLADA document. - @param index The array index. This value should be -1 to indicate that - the animated element does not belong to a list. */ - inline void SetArrayElement(int32 index) { arrayElement = index; } - - /** Retrieves whether this animated element has any animation curves - affecting its values. - @return Whether any curves affect this animated element. */ - bool HasCurve() const; - - /** Creates one multi-dimensional animation curve from this animated element. - This function is useful is your application does not handle animations - per-values, but instead needs one animation per-element. - @return The multi-dimensional animation curve. */ - FCDAnimationMultiCurve* CreateMultiCurve() const; - - /** Creates one multi-dimensional animation curve from a list of animated element. - This function is useful is your application does not handle animations - per-values. For example, we use this function is ColladaMax for animated scale values, - where one scale value is two rotations for the scale rotation pivot and one - 3D point for the scale factors. - @param toMerge The list of animated elements to merge - @return The multi-dimensional animation curve. */ - static FCDAnimationMultiCurve* CreateMultiCurve(const FCDAnimatedList& toMerge); - - /** Evaluates the animated element at a given time. - This function directly and permanently modifies the values - of the animated element according to the curves affecting them. - @param time The evaluation time. */ - void Evaluate(float time); - - /** [INTERNAL] Clones an animated element. - @param document The COLLADA document that owns the cloned animated element. - @param animatedValue One animated value contained within the original animated element. - @param newAnimatedValues The list of value pointers to be contained by the cloned animated element. - @return The cloned animated element. */ - static FCDAnimated* Clone(FCDocument* document, const float* animatedValue, FloatPtrList& newAnimatedValues); - - /** [INTERNAL] Clones an animated element. - @param document The COLLADA document that owns the cloned animated element. - @return The cloned animated element. */ - FCDAnimated* Clone(FCDocument* document); - - /** [INTERNAL] Retrieves the target pointer that prefixes the - fully-qualified target for the element. - @return The target pointer prefix. */ - const string& GetTargetPointer() const { return pointer; } - - /** [INTERNAL] Links this animated element with a given XML tree node. - This function is solely used within the import of a COLLADA document. - The floating-point values held within the XML tree node will be linked - with the list of floating-point value pointers held by the animated entity. - @param node The XML tree node. - @return Whether there was any linkage done. */ - bool Link(xmlNode* node); - - /** [INTERNAL] Links the animated element with the imported animation curves. - This compares the animation channel targets with the animated element target - and qualifiers to assign curves unto the value pointers. - @param channels A list of animation channels with the correct target pointer. - @return Whether any animation curves were assigned to the animation element. */ - bool ProcessChannels(FCDAnimationChannelList& channels); -}; - -/** A COLLADA animated single floating-point value element. - Use this animated element class for all generic-purpose single floating-point values. - For angles, use the FCDAnimatedAngle class. - @ingroup FCDocument */ -class FCOLLADA_EXPORT FCDAnimatedFloat : public FCDAnimated -{ -private: - // Don't build directly, use the Create function instead - FCDAnimatedFloat(FCDocument* document, float* value, int32 arrayElement); - -public: - /** Creates a new animated element. - @param document The COLLADA document that owns the animated element. - @param value The value pointer for the single floating-point value. - @param arrayElement The optional array index for animated element - that belong to an animated element list. - @return The new animated element. */ - static FCDAnimatedFloat* Create(FCDocument* document, float* value, int32 arrayElement=-1); - - /** [INTERNAL] Creates a new animated element. - This function is used during the import of a COLLADA document. - @param document The COLLADA document that owns the animated element. - @param node The XML tree node that contains the animated values. - @param value The value pointer for the single floating-point value. - @param arrayElement The optional array index for animated element - that belong to an animated element list. - @return The new animated element. */ - static FCDAnimatedFloat* Create(FCDocument* document, xmlNode* node, float* value, int32 arrayElement=-1); - - /** [INTERNAL] Clones an animated element. - @param document The COLLADA document that owns the cloned animated element. - @param oldValue The single floating-point value pointer contained within the original animated element. - @param newValue The single floating-point value pointer for the cloned animated element. - @return The cloned animated value. */ - static FCDAnimated* Clone(FCDocument* document, const float* oldValue, float* newValue); -}; - -/** A COLLADA animated 3D vector element. - @ingroup FCDocument */ -class FCOLLADA_EXPORT FCDAnimatedPoint3 : public FCDAnimated -{ -private: - // Don't build directly, use the Create function instead - FCDAnimatedPoint3(FCDocument* document, FMVector3* value, int32 arrayElement); - -public: - /** Creates a new animated element. - @param document The COLLADA document that owns the animated element. - @param value The value pointer for the 3D vector. - @param arrayElement The optional array index for animated element - that belong to an animated element list. - @return The new animated element. */ - static FCDAnimatedPoint3* Create(FCDocument* document, FMVector3* value, int32 arrayElement=-1); - - /** [INTERNAL] Creates a new animated element. - This function is used during the import of a COLLADA document. - @param document The COLLADA document that owns the animated element. - @param node The XML tree node that contains the animated values. - @param value The value pointer for the 3D vector. - @param arrayElement The optional array index for animated element - that belong to an animated element list. - @return The new animated element. */ - static FCDAnimatedPoint3* Create(FCDocument* document, xmlNode* node, FMVector3* value, int32 arrayElement=-1); - - /** [INTERNAL] Clones an animated element. - @param document The COLLADA document that owns the cloned animated element. - @param oldValue The 3D vector contained within the original animated element. - @param newValue The 3D vector for the cloned animated element. - @return The cloned animated value. */ - static FCDAnimated* Clone(FCDocument* document, const FMVector3* oldValue, FMVector3* newValue); -}; - -/** A COLLADA animated RGB color element. - @ingroup FCDocument */ -class FCOLLADA_EXPORT FCDAnimatedColor : public FCDAnimated -{ -private: - // Don't build directly, use the Create function instead - FCDAnimatedColor(FCDocument* document, FMVector3* value, int32 arrayElement); - -public: - /** Creates a new animated element. - @param document The COLLADA document that owns the animated element. - @param value The value pointer for the RGB color. - @param arrayElement The optional array index for animated element - that belong to an animated element list. - @return The new animated element. */ - static FCDAnimatedColor* Create(FCDocument* document, FMVector3* value, int32 arrayElement=-1); - - /** [INTERNAL] Creates a new animated element. - This function is used during the import of a COLLADA document. - @param document The COLLADA document that owns the animated element. - @param node The XML tree node that contains the animated values. - @param value The value pointer for the RGB color. - @param arrayElement The optional array index for animated element - that belong to an animated element list. - @return The new animated element. */ - static FCDAnimatedColor* Create(FCDocument* document, xmlNode* node, FMVector3* value, int32 arrayElement=-1); - - /** [INTERNAL] Clones an animated element. - @param document The COLLADA document that owns the cloned animated element. - @param oldValue The RGB color contained within the original animated element. - @param newValue The RGB color for the cloned animated element. - @return The cloned animated value. */ - static FCDAnimated* Clone(FCDocument* document, const FMVector3* oldValue, FMVector3* newValue); -}; - -/** A COLLADA floating-point value that represents an angle. - @ingroup FCDocument */ -class FCOLLADA_EXPORT FCDAnimatedAngle : public FCDAnimated -{ -private: - // Don't build directly, use the Create function instead - FCDAnimatedAngle(FCDocument* document, float* value, int32 arrayElement); - -public: - /** Creates a new animated element. - @param document The COLLADA document that owns the animated element. - @param value The value pointer for the angle. - @param arrayElement The optional array index for animated element - that belong to an animated element list. - @return The new animated element. */ - static FCDAnimatedAngle* Create(FCDocument* document, float* value, int32 arrayElement=-1); - - /** [INTERNAL] Creates a new animated element. - This function is used during the import of a COLLADA document. - @param document The COLLADA document that owns the animated element. - @param node The XML tree node that contains the animated values. - @param value The value pointer for the angle. - @param arrayElement The optional array index for animated element - that belong to an animated element list. - @return The new animated element. */ - static FCDAnimatedAngle* Create(FCDocument* document, xmlNode* node, float* value, int32 arrayElement=-1); - - /** [INTERNAL] Clones an animated element. - @param document The COLLADA document that owns the cloned animated element. - @param oldValue The angle value pointer contained within the original animated element. - @param newValue The angle value pointer for the cloned animated element. - @return The cloned animated value. */ - static FCDAnimated* Clone(FCDocument* document, const float* oldValue, float* newValue); -}; - -/** A COLLADA animated angle-axis. - Used for rotations, takes in a 3D vector for the axis and - a single floating-point value for the angle. - @ingroup FCDocument */ -class FCOLLADA_EXPORT FCDAnimatedAngleAxis : public FCDAnimated -{ -private: - // Don't build directly, use the Create function instead - FCDAnimatedAngleAxis(FCDocument* document, FMVector3* axis, float* angle, int32 arrayElement); - -public: - /** Creates a new animated element. - @param document The COLLADA document that owns the animated element. - @param value The value pointer for the axis. - @param angle The value pointer for the angle. - @param arrayElement The optional array index for animated element - that belong to an animated element list. - @return The new animated element. */ - static FCDAnimatedAngleAxis* Create(FCDocument* document, FMVector3* value, float* angle, int32 arrayElement=-1); - - /** [INTERNAL] Creates a new animated element. - This function is used during the import of a COLLADA document. - @param document The COLLADA document that owns the animated element. - @param node The XML tree node that contains the animated values. - @param axis The value pointer for the axis. - @param angle The value pointer for the angle. - @param arrayElement The optional array index for animated element - that belong to an animated element list. - @return The new animated element. */ - static FCDAnimatedAngleAxis* Create(FCDocument* document, xmlNode* node, FMVector3* axis, float* angle, int32 arrayElement=-1); - - /** [INTERNAL] Clones an animated element. - @param document The COLLADA document that owns the cloned animated element. - @param oldAngle The angle value pointer contained within the original animated element. - @param newAxis The axis value pointer for the cloned animated element. - @param newAngle The angle value pointer for the cloned animated element. - @return The cloned animated value. */ - static FCDAnimated* Clone(FCDocument* document, const float* oldAngle, FMVector3* newAxis, float* newAngle); -}; - -/** A COLLADA animated matrix. - Used for animated transforms, takes in a 16 floating-point values. - @ingroup FCDocument */ -class FCOLLADA_EXPORT FCDAnimatedMatrix : public FCDAnimated -{ -private: - // Don't build directly, use the Create function instead - FCDAnimatedMatrix(FCDocument* document, FMMatrix44* value, int32 arrayElement); - -public: - /** Creates a new animated element. - @param document The COLLADA document that owns the animated element. - @param value The value pointer for the matrix. - @param arrayElement The optional array index for animated element - that belong to an animated element list. - @return The new animated element. */ - static FCDAnimatedMatrix* Create(FCDocument* document, FMMatrix44* value, int32 arrayElement=-1); - - /** [INTERNAL] Creates a new animated element. - This function is used during the import of a COLLADA document. - @param document The COLLADA document that owns the animated element. - @param node The XML tree node that contains the animated values. - @param value The value pointer for the matrix. - @param arrayElement The optional array index for animated element - that belong to an animated element list. - @return The new animated element. */ - static FCDAnimatedMatrix* Create(FCDocument* document, xmlNode* node, FMMatrix44* value, int32 arrayElement=-1); - - /** [INTERNAL] Clones an animated element. - @param document The COLLADA document that owns the cloned animated element. - @param oldMx The matrix value pointer contained within the original animated element. - @param newMx The matrix value pointer for the cloned animated element. - @return The cloned animated value. */ - static FCDAnimated* Clone(FCDocument* document, const FMMatrix44* oldMx, FMMatrix44* newMx); -}; - -/** A COLLADA custom animated value. - Used for animated extra elements. A single value is used multiple times to hold - as many value pointers are necessary to hold the animation curves. - @ingroup FCDocument */ -class FCOLLADA_EXPORT FCDAnimatedCustom : public FCDAnimated -{ -private: - float dummy; - - // Don't build directly, use the Create function instead - FCDAnimatedCustom(FCDocument* document); - - bool Link(xmlNode* node); - -public: - /** Creates a new animated element. - @param document The COLLADA document that owns the animated element. - @return The new animated element. */ - static FCDAnimatedCustom* Create(FCDocument* document); - - /** [INTERNAL] Creates a new animated element. - This function is used during the import of a COLLADA document. - @param document The COLLADA document that owns the animated element. - @param node The XML tree node that contains the animated values. - @return The new animated element. */ - static FCDAnimatedCustom* Create(FCDocument* document, xmlNode* node); - - /** Retrieves the floating-point value used for all the value pointers. - @return The dummy floating-point value. */ - const float& GetDummy() const { return dummy; } -}; - -#endif // _FCD_ANIMATED_H_ - diff --git a/Extras/FCollada/FCDocument/FCDAnimation.cpp b/Extras/FCollada/FCDocument/FCDAnimation.cpp deleted file mode 100644 index 24657a2a3..000000000 --- a/Extras/FCollada/FCDocument/FCDAnimation.cpp +++ /dev/null @@ -1,224 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDAnimation.h" -#include "FCDocument/FCDAnimationChannel.h" -#include "FUtils/FUDaeParser.h" -using namespace FUDaeParser; - -FCDAnimation::FCDAnimation(FCDocument* document) : FCDEntity(document, "Animation") -{ -} - -FCDAnimation::~FCDAnimation() -{ - CLEAR_POINTER_VECTOR(channels); - CLEAR_POINTER_VECTOR(children); - childNodes.clear(); -} - -// Creates a new animation entity sub-tree contained within this animation entity tree. -FCDAnimation* FCDAnimation::AddChild() -{ - FCDAnimation* animation = new FCDAnimation(GetDocument()); - children.push_back(animation); - return animation; -} - -// Releases an animation entity sub-tree contained by this animation entity tree. -void FCDAnimation::ReleaseChild(FCDAnimation* animation) -{ - FCDAnimationList::iterator itA = std::find(children.begin(), children.end(), animation); - if (itA != children.end()) - { - delete *itA; - children.erase(itA); - } -} - -// Adds a new animation channel to this animation entity. -FCDAnimationChannel* FCDAnimation::AddChannel() -{ - FCDAnimationChannel* channel = new FCDAnimationChannel(GetDocument(), this); - channels.push_back(channel); - return channel; -} - -// Releases an animation channel contained within this animation entity. -void FCDAnimation::ReleaseChannel(FCDAnimationChannel* channel) -{ - FCDAnimationChannelList::iterator itC = std::find(channels.begin(), channels.end(), channel); - if (itC != channels.end()) - { - delete *itC; - channels.erase(itC); - } -} - -// Optimization: Look for the xml child node with the given id -xmlNode* FCDAnimation::FindChildById(const string& _id) -{ - FUCrc32::crc32 id = FUCrc32::CRC32(_id.c_str() + ((_id[0] == '#') ? 1 : 0)); - for (FUXmlNodeIdPairList::iterator it = childNodes.begin(); it != childNodes.end(); ++it) - { - if ((*it).id == id) return (*it).node; - } - return NULL; -} - -// Look for an animation children with the given COLLADA Id. -FCDEntity* FCDAnimation::FindDaeId(const string& daeId) -{ - if (GetDaeId() == daeId) return this; - - for (FCDAnimationList::iterator it = children.begin(); it != children.end(); ++it) - { - FCDEntity* found = (*it)->FindDaeId(daeId); - if (found != NULL) return found; - } - return NULL; -} - -// Retrieve all the curves created under this animation element, in the animation tree -void FCDAnimation::GetCurves(FCDAnimationCurveList& curves) -{ - // Retrieve the curves for this animation tree element - for (FCDAnimationChannelList::iterator it = channels.begin(); it != channels.end(); ++it) - { - const FCDAnimationCurveList& channelCurves = (*it)->GetCurves(); - for (FCDAnimationCurveList::const_iterator itC = channelCurves.begin(); itC != channelCurves.end(); ++itC) - { - curves.push_back(*itC); - } - } - - // Retrieve the curves for the animation nodes under this one in the animation tree - for (FCDAnimationList::iterator it = children.begin(); it != children.end(); ++it) - { - (*it)->GetCurves(curves); - } -} - -FUStatus FCDAnimation::Link() -{ - FUStatus status; - - // Link the child nodes and check the curves for their drivers - for (FCDAnimationChannelList::iterator it = channels.begin(); it != channels.end(); ++it) - { - status.AppendStatus((*it)->CheckDriver()); - } - for (FCDAnimationList::iterator it = children.begin(); it != children.end(); ++it) - { - status.AppendStatus((*it)->Link()); - } - - return status; -} - -// Check for animation curves that need this animated as a driver -bool FCDAnimation::LinkDriver(FCDAnimated* animated) -{ - bool driver = false; - - // Link the child curves and child nodes - for (FCDAnimationChannelList::iterator it = channels.begin(); it != channels.end(); ++it) - { - driver |= (*it)->LinkDriver(animated); - } - for (FCDAnimationList::iterator it = children.begin(); it != children.end(); ++it) - { - driver |= (*it)->LinkDriver(animated); - } - - return driver; -} - -// Load a Collada animation node from the XML document -FUStatus FCDAnimation::LoadFromXML(xmlNode* node) -{ - FUStatus status = FCDEntity::LoadFromXML(node); - if (!status) return status; - if (!IsEquivalent(node->name, DAE_ANIMATION_ELEMENT)) - { - return status.Warning(FS("Animation library contains unknown element."), node->line); - } - - // Optimization: Grab all the IDs of the child nodes, in CRC format. - ReadChildrenIds(node, childNodes); - - // Parse all the inner elements - xmlNodeList channelNodes; - FindChildrenByType(node, DAE_CHANNEL_ELEMENT, channelNodes); - channels.reserve(channelNodes.size()); - for (xmlNodeList::iterator itC = channelNodes.begin(); itC != channelNodes.end(); ++itC) - { - // Parse each element individually - // They each handle reading the and elements - FCDAnimationChannel* channel = AddChannel(); - status.AppendStatus(channel->LoadFromXML(*itC)); - if (!status) - { - ReleaseChannel(channel); - } - } - - // Parse all the hierarchical elements - xmlNodeList animationNodes; - FindChildrenByType(node, DAE_ANIMATION_ELEMENT, animationNodes); - for (xmlNodeList::iterator itA = animationNodes.begin(); itA != animationNodes.end(); ++itA) - { - FCDAnimation* animation = AddChild(); - animation->LoadFromXML(*itA); - } - return status; -} - -// Search for an animation channel for the given XML pointer in this animation node -void FCDAnimation::FindAnimationChannels(const string& pointer, vector& targetChannels) -{ - // Look for channels locally - for (FCDAnimationChannelList::iterator itChannel = channels.begin(); itChannel != channels.end(); ++itChannel) - { - if ((*itChannel)->GetTargetPointer() == pointer) - { - targetChannels.push_back(*itChannel); - } - } - - // Look for channel(s) within the child animations - for (FCDAnimationList::iterator it = children.begin(); it != children.end(); ++it) - { - (*it)->FindAnimationChannels(pointer, targetChannels); - } -} - -// Write out the COLLADA animations to the document -xmlNode* FCDAnimation::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* animationNode = WriteToEntityXML(parentNode, DAE_ANIMATION_ELEMENT); - - // Write out the local channels - for (FCDAnimationChannelList::const_iterator itChannel = channels.begin(); itChannel != channels.end(); ++itChannel) - { - (*itChannel)->WriteToXML(animationNode); - } - - // Write out the child animations - for (FCDAnimationList::const_iterator it = children.begin(); it != children.end(); ++it) - { - (*it)->WriteToXML(animationNode); - } - - FCDEntity::WriteToExtraXML(animationNode); - return animationNode; -} diff --git a/Extras/FCollada/FCDocument/FCDAnimation.h b/Extras/FCollada/FCDocument/FCDAnimation.h deleted file mode 100644 index 02b782dd2..000000000 --- a/Extras/FCollada/FCDocument/FCDAnimation.h +++ /dev/null @@ -1,163 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDAnimation.h - This file contains the FCDAnimation class. -*/ - -#ifndef _FCD_ANIMATION_H_ -#define _FCD_ANIMATION_H_ - -#include "FUtils/FUXmlNodeIdPair.h" -#include "FCDocument/FCDEntity.h" - -class FCDocument; -class FCDAnimated; -class FCDAnimation; -class FCDAnimationChannel; -class FCDAnimationCurve; - -typedef vector FCDAnimationList; /**< A dynamically-sized array of animation entities. */ -typedef vector FCDAnimationChannelList; /**< A dynamically-sized array of animation channels. */ -typedef vector FCDAnimationCurveList; /**< A dynamically-sized array of animation curves. */ - -/** - A COLLADA animation entity. - An animation entity contains a list of child animation entities, - in order to form a tree of animation entities. - It also hold a list of animation channels, which hold the information - to generate animation curves. - - In other words, the animation entity is a structural class - used to group animation channels hierarchically. - - @ingroup FCDocument -*/ -class FCOLLADA_EXPORT FCDAnimation : public FCDEntity -{ -private: - FCDAnimationChannelList channels; - FUXmlNodeIdPairList childNodes; - FCDAnimationList children; - -public: - /** Constructor: do not use directly. - Instead, use the FCDLibrary::AddEntity function - or the AddChild function, depending on the - hierarchical level of the animation entity. - @param document The COLLADA document that owns the animation entity. */ - FCDAnimation(FCDocument* document); - - /** Destructor: do not use directly. - Instead, use the FCDLibrary::ReleaseEntity function - or the ReleaseChild function, depending on the - hierarchical level of the animation entity.*/ - virtual ~FCDAnimation(); - - /** Retrieves the entity class type. - This function is a part of the FCDEntity interface. - @return The entity class type: ANIMATION. */ - virtual Type GetType() const { return ANIMATION; } - - /** Retrieves the entity with the given COLLADA id. - This function will look through the local sub-tree of animations - for the given COLLADA id. - @param daeId A COLLADA id. - @return The animation entity that matches the COLLADA id. This pointer - will be NULL if there are no animation entities that matches the COLLADA id. */ - virtual FCDEntity* FindDaeId(const string& daeId); - - /** Retrieves the number of animation entity sub-trees contained - by this animation entity tree. - @return The number of animation entity sub-trees. */ - inline size_t GetChildCount() const { return children.size(); } - - /** Retrieves an animation entity sub-tree contained by this - animation entity tree. - @param index The index of the sub-tree. - @return The animation entity sub-tree at the given index. This pointer will - be NULL if the index is out-of-bounds. */ - inline FCDAnimation* GetChild(size_t index) { FUAssert(index < GetChildCount(), return NULL); return children.at(index); } - inline const FCDAnimation* GetChild(size_t index) const { FUAssert(index < GetChildCount(), return NULL); return children.at(index); } /**< See above. */ - - /** Creates a new animation entity sub-tree contained within this animation entity tree. - @return The new animation sub-tree. */ - inline FCDAnimation* AddChild(); - - /** Releases an animation entity sub-tree contained by this animation entity tree. - @param animation The animation entity the release. */ - inline void ReleaseChild(FCDAnimation* animation); - - /** Retrieves the animation channels that target the given COLLADA target pointer. - @param pointer A COLLADA target pointer. - @param targetChannels A list of animation channels to fill in. - This list is not cleared. */ - void FindAnimationChannels(const string& pointer, FCDAnimationChannelList& targetChannels); - - /** Retrieves the number of animation channels at this level within the animation tree. - @return The number of animation channels. */ - size_t GetChannelCount() const { return channels.size(); } - - /** Retrieves an animation channel contained by this animation entity. - @param index The index of the channel. - @return The channel at the given index. This pointer will be NULL - if the index is out-of-bounds. */ - FCDAnimationChannel* GetChannel(size_t index) { FUAssert(index < GetChannelCount(), return NULL); return channels.at(index); } - const FCDAnimationChannel* GetChannel(size_t index) const { FUAssert(index < GetChannelCount(), return NULL); return channels.at(index); } /**< See above. */ - - /** Adds a new animation channel to this animation entity. - @return The new animation channel. */ - FCDAnimationChannel* AddChannel(); - - /** Releases an animation channel contained within this animation entity. - @param channel The animation channel to release. */ - void ReleaseChannel(FCDAnimationChannel* channel); - - /** Retrieves all the curves created in the subtree of this animation element. - @param curves A list of animation curves to fill in. - This list is not cleared. */ - void GetCurves(FCDAnimationCurveList& curves); - - /** [INTERNAL] Links the animation sub-tree with the other entities within the document. - This function is used at the end of the import of a document to verify that all the - necessary drivers were found. - @return The status of the linkage. */ - FUStatus Link(); - - /** [INTERNAL] Reads in the animation entity from a given COLLADA XML tree node. - @param animationNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the animation. */ - virtual FUStatus LoadFromXML(xmlNode* animationNode); - - /** [INTERNAL] Writes out the \ element to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the animation tree. - @return The created element XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; - - /** [INTERNAL] Retrieves the child source or sampler. - This function should only be used by the FCDAnimationChannel class - during the import of a COLLADA document. - @param id The COLLADA id of a sampler or a source. - @return The XML node tree for the sampler or the source. This pointer - will be NULL if there are no child nodes for the given id. */ - xmlNode* FindChildById(const string& id); - - /** [INTERNAL] Links a possible driver with the animation curves contained - within the subtree of this animation element. - This function is used during the import of a COLLADA document. - @param animated The driver animated value. - @return Whether any linkage was done. */ - bool LinkDriver(FCDAnimated* animated); -}; - -#endif // _FCD_ANIMATION_H_ diff --git a/Extras/FCollada/FCDocument/FCDAnimationChannel.cpp b/Extras/FCollada/FCDocument/FCDAnimationChannel.cpp deleted file mode 100644 index e65f730bc..000000000 --- a/Extras/FCollada/FCDocument/FCDAnimationChannel.cpp +++ /dev/null @@ -1,292 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDAnimated.h" -#include "FCDocument/FCDAnimation.h" -#include "FCDocument/FCDAnimationChannel.h" -#include "FCDocument/FCDAnimationCurve.h" -#include "FCDocument/FCDAnimationMultiCurve.h" -#include "FUtils/FUDaeEnum.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -#include "FUtils/FUStringConversion.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDAnimationChannel::FCDAnimationChannel(FCDocument* document, FCDAnimation* _parent) : FCDObject(document, "FCDAnimationChannel") -{ - parent = _parent; -} - -FCDAnimationChannel::~FCDAnimationChannel() -{ - CLEAR_POINTER_VECTOR(curves); - parent = NULL; -} - -FCDAnimationCurve* FCDAnimationChannel::AddCurve() -{ - FCDAnimationCurve* curve = new FCDAnimationCurve(GetDocument(), this); - curves.push_back(curve); - return curve; -} - -void FCDAnimationChannel::ReleaseCurve(FCDAnimationCurve* curve) -{ - FCDAnimationCurveList::iterator itC = std::find(curves.begin(), curves.end(), curve); - if (itC != curves.end()) - { - // TODO: IMPLEMENT THIS. NEED RTTI and memory management. In other words, I need time!!! :(. - // delete *itC; - curves.erase(itC); - } -} - -// Consider this animated as the curve's driver -bool FCDAnimationChannel::LinkDriver(FCDAnimated* animated) -{ - bool driver = !driverPointer.empty(); - driver = driver && animated->GetTargetPointer() == driverPointer; - if (driver && driverQualifier >= 0 && (uint32) driverQualifier < animated->GetValueCount()) - { - // Retrieve the value pointer for the driver - for (FCDAnimationCurveList::iterator itC = curves.begin(); itC != curves.end(); ++itC) - { - (*itC)->SetDriver(animated->GetValue((uint32) driverQualifier)); - } - } - return driver; -} -FUStatus FCDAnimationChannel::CheckDriver() -{ - FUStatus status; - if (!driverPointer.empty() && !curves.empty() && curves.front()->GetDriver() == NULL) - { - status.Fail(FS("Unable to find animation curve driver: ") + TO_FSTRING(driverPointer) + FS(" for animation: ") + TO_FSTRING(parent->GetDaeId())); - } - return status; -} - -// Load a Collada animation channel from the XML document -FUStatus FCDAnimationChannel::LoadFromXML(xmlNode* channelNode) -{ - FUStatus status; - - // Read the channel-specific ID - string daeId = ReadNodeId(channelNode); - string samplerId = ReadNodeSource(channelNode); - ReadNodeTargetProperty(channelNode, targetPointer, targetQualifier); - - xmlNode* samplerNode = parent->FindChildById(samplerId); - if (samplerNode == NULL || !IsEquivalent(samplerNode->name, DAE_SAMPLER_ELEMENT)) - { - return status.Fail(FS("Unable to find sampler node for channel node: ") + TO_FSTRING(daeId), channelNode->line); - } - - // Find and process the sources - xmlNode* inputSource = NULL,* outputSource = NULL,* inTangentSource = NULL,* outTangentSource = NULL; - xmlNode* outTangentWeightSource = NULL,* inTangentWeightSource = NULL,* interpolationSource = NULL; - xmlNodeList samplerInputNodes; - FindChildrenByType(samplerNode, DAE_INPUT_ELEMENT, samplerInputNodes); - for (size_t i = 0; i < samplerInputNodes.size(); ++i) // Don't use iterator here because we are possibly appending source nodes in the loop - { - xmlNode* inputNode = samplerInputNodes[i]; - string sourceId = ReadNodeSource(inputNode); - xmlNode* sourceNode = parent->FindChildById(sourceId); - string sourceSemantic = ReadNodeSemantic(inputNode); - - if (sourceSemantic == DAE_INPUT_ANIMATION_INPUT) inputSource = sourceNode; - else if (sourceSemantic == DAE_OUTPUT_ANIMATION_INPUT) outputSource = sourceNode; - else if (sourceSemantic == DAE_INTANGENT_ANIMATION_INPUT) inTangentSource = sourceNode; - else if (sourceSemantic == DAE_OUTTANGENT_ANIMATION_INPUT) outTangentSource = sourceNode; - else if (sourceSemantic == DAEMAYA_INTANGENTWEIGHT_ANIMATION_INPUT) inTangentWeightSource = sourceNode; - else if (sourceSemantic == DAEMAYA_OUTTANGENTWEIGHT_ANIMATION_INPUT) outTangentWeightSource = sourceNode; - else if (sourceSemantic == DAE_INTERPOLATION_ANIMATION_INPUT) interpolationSource = sourceNode; - } - if (inputSource == NULL || outputSource == NULL) - { - return status.Fail(FS("Missing INPUT or OUTPUT sources in animation channel: ") + TO_FSTRING(parent->GetDaeId()), samplerNode->line); - } - - // Calculate the number of curves that in contained by this channel - xmlNode* outputAccessor = FindTechniqueAccessor(outputSource); - string accessorStrideString = ReadNodeProperty(outputAccessor, DAE_STRIDE_ATTRIBUTE); - uint32 curveCount = FUStringConversion::ToUInt32(accessorStrideString); - if (curveCount == 0) curveCount = 1; - - // Create the animation curves - curves.reserve(curveCount); - for (uint32 i = 0; i < curveCount; ++i) AddCurve(); - - // Read in the animation curves - // The input keys are shared by all the curves - ReadSource(inputSource, curves.front()->GetKeys()); - for (uint32 i = 1; i < curveCount; ++i) curves[i]->GetKeys() = curves.front()->GetKeys(); - - // Read in the interleaved outputs and tangents as floats - #define READ_SOURCE_INTERLEAVED(sourceNode, curveArrayPtr) \ - if (sourceNode != NULL) { \ - vector arrays(curveCount); \ - for (uint32 i = 0; i < curveCount; ++i) { \ - arrays[i] = &(curves[i]->curveArrayPtr()); } \ - ReadSourceInterleaved(sourceNode, arrays); \ - } - - READ_SOURCE_INTERLEAVED(outputSource, GetKeyValues) - READ_SOURCE_INTERLEAVED(inTangentSource, GetInTangents) - READ_SOURCE_INTERLEAVED(outTangentSource, GetOutTangents) - READ_SOURCE_INTERLEAVED(inTangentWeightSource, GetInTangentWeights) - READ_SOURCE_INTERLEAVED(outTangentWeightSource, GetOutTangentWeights) - #undef READ_SOURCE_INTERLEAVED - - // Read in the interleaved interpolation values, parsing the tokens directly - if (interpolationSource != NULL) - { - vector arrays(curveCount); - for (uint32 i = 0; i < curveCount; ++i) arrays[i] = &(curves[i]->GetInterpolations()); - ReadSourceInterpolationInterleaved(interpolationSource, arrays); - } - - // Read in the pre/post-infinity type - xmlNodeList mayaParameterNodes; StringList mayaParameterNames; - xmlNode* mayaTechnique = FindTechnique(inputSource, DAEMAYA_MAYA_PROFILE); - FindParameters(mayaTechnique, mayaParameterNames, mayaParameterNodes); - size_t parameterCount = mayaParameterNodes.size(); - for (size_t i = 0; i < parameterCount; ++i) - { - xmlNode* parameterNode = mayaParameterNodes[i]; - const string& paramName = mayaParameterNames[i]; - const char* content = ReadNodeContentDirect(parameterNode); - - if (paramName == DAEMAYA_PREINFINITY_PARAMETER || paramName == DAEMAYA_PREINFINITY_PARAMETER1_3) - { - for (FCDAnimationCurveList::iterator itC = curves.begin(); itC != curves.end(); ++itC) - { - (*itC)->SetPreInfinity(FUDaeInfinity::FromString(content)); - } - } - else if (paramName == DAEMAYA_POSTINFINITY_PARAMETER || paramName == DAEMAYA_POSTINFINITY_PARAMETER1_3) - { - for (FCDAnimationCurveList::iterator itC = curves.begin(); itC != curves.end(); ++itC) - { - (*itC)->SetPostInfinity(FUDaeInfinity::FromString(content)); - } - } - else - { - // Look for driven-key input target - if (paramName == DAE_INPUT_ELEMENT) - { - string semantic = ReadNodeSemantic(parameterNode); - if (semantic == DAEMAYA_DRIVER_INPUT) - { - string fullDriverTarget = ReadNodeSource(parameterNode); - const char* driverTarget = FUDaeParser::SkipPound(fullDriverTarget); - if (driverTarget != NULL) - { - string driverQualifierValue; - FUDaeParser::SplitTarget(driverTarget, driverPointer, driverQualifierValue); - driverQualifier = FUDaeParser::ReadTargetMatrixElement(driverQualifierValue); - } - } - } - } - } - - // Ready the curves for usage/evaluation. - for (uint32 i = 0; i < curveCount; ++i) curves[i]->Ready(); - - return status; -} - -// Write out the animation curves for an animation channel to a COLLADA document -void FCDAnimationChannel::WriteToXML(xmlNode* parentNode) const -{ - string baseId = CleanId(targetPointer); - - // Check for curve merging - uint32 realCurveCount = 0; - FCDAnimationCurve* masterCurve = NULL; - bool mergeCurves = true; - for (FCDAnimationCurveList::const_iterator itC = curves.begin(); itC != curves.end(); ++itC) - { - FCDAnimationCurve* curve = (*itC); - if ((*itC) != NULL) - { - ++realCurveCount; - if (masterCurve == NULL) - { - masterCurve = curve; - if (masterCurve->GetDriver() != NULL) break; - } - else - { - // Check preliminary information, before verifying the individual keys: key count, infinity types and such.. - const FloatList& masterKeys = masterCurve->GetKeys(); - const FloatList& curveKeys = curve->GetKeys(); - size_t keyCount = masterKeys.size(); - mergeCurves &= curveKeys.size() == keyCount && curve->GetPostInfinity() == masterCurve->GetPostInfinity() && curve->GetPreInfinity() == masterCurve->GetPreInfinity(); - for (size_t k = 0; k < keyCount && mergeCurves; ++k) - { - mergeCurves = curveKeys[k] == masterKeys[k]; - } - } - } - } - - if (mergeCurves && realCurveCount > 1) - { - // HACK: Will need to merge the channel and animated classes. - FloatList defaultValues(curves.size(), 0.0f); - - // Merge and export the curves - FCDAnimationMultiCurve* multiCurve = FCDAnimationMultiCurve::MergeCurves(curves, defaultValues); - multiCurve->WriteSourceToXML(parentNode, baseId); - multiCurve->WriteSamplerToXML(parentNode, baseId); - multiCurve->WriteChannelToXML(parentNode, baseId, targetPointer); - SAFE_DELETE(multiCurve); - } - else - { - // Interlace the curve's sources, samplers and channels - // Generate new ids for each of the curve's data sources, to avoid collision in special cases - size_t curveCount = curves.size(); - StringList ids; ids.resize(curves.size()); - FUSStringBuilder curveId; - for (size_t c = 0; c < curveCount; ++c) - { - if (curves[c] != NULL) - { - // Generate a valid id for this curve - curveId.set(baseId); - if (curves[c]->GetTargetElement() >= 0) - { - curveId.append('_'); curveId.append(curves[c]->GetTargetElement()); curveId.append('_'); - } - curveId.append(curves[c]->GetTargetQualifier()); - ids[c] = CleanId(curveId.ToCharPtr()); - - // Write out the curve's sources - curves[c]->WriteSourceToXML(parentNode, ids[c]); - } - } - for (size_t c = 0; c < curveCount; ++c) - { - if (curves[c] != NULL) curves[c]->WriteSamplerToXML(parentNode, ids[c]); - } - for (size_t c = 0; c < curveCount; ++c) - { - if (curves[c] != NULL) curves[c]->WriteChannelToXML(parentNode, ids[c], targetPointer.c_str()); - } - } -} diff --git a/Extras/FCollada/FCDocument/FCDAnimationChannel.h b/Extras/FCollada/FCDocument/FCDAnimationChannel.h deleted file mode 100644 index 31d55f3c5..000000000 --- a/Extras/FCollada/FCDocument/FCDAnimationChannel.h +++ /dev/null @@ -1,134 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDAnimationChannel.h - This file contains the FCDAnimationChannel class. -*/ - -#ifndef _FCD_ANIMATION_CHANNEL_H_ -#define _FCD_ANIMATION_CHANNEL_H_ - -#include "FCDocument/FCDObject.h" - -class FCDocument; -class FCDAnimated; -class FCDAnimation; -class FCDAnimationCurve; - -/** A dynamically-sized array of animation curves. */ -typedef vector FCDAnimationCurveList; - -/** - A COLLADA animation channel. - Each animation channel holds the animation curves for one animatable element, - such as a single floating-point value, a 3D vector or a matrix. - - @see FCDAnimated - @ingroup FCDocument -*/ -class FCOLLADA_EXPORT FCDAnimationChannel : public FCDObject -{ -private: - FCDAnimation* parent; - - // Channel target - string targetPointer; - string targetQualifier; - - // Maya-specific: the driver for this/these curves - string driverPointer; - int32 driverQualifier; - - FCDAnimationCurveList curves; - -public: - /** Constructor: do not use directly. - Instead, call the FCDAnimation::AddChannel function. - @param document The COLLADA document that owns the animation channel. - @param parent The animation sub-tree that contains the animation channel. */ - FCDAnimationChannel(FCDocument* document, FCDAnimation* parent); - - /** Destructor: do not use directly. - Instead, call the FCDAnimation::ReleaseChannel function. */ - virtual ~FCDAnimationChannel(); - - /** Retrieves the animation sub-tree that contains the animation channel. - @return The parent animation sub-tree. */ - FCDAnimation* GetParent() { return parent; } - const FCDAnimation* GetParent() const { return parent; } /**< See above. */ - - /** Retrieves the list of animation curves contained within the channel. - @return The list of animation curves. */ - const FCDAnimationCurveList& GetCurves() const { return curves; } - - /** Retrieves the number of animation curves contained within the channel. - @return The number of animation curves. */ - size_t GetCurveCount() const { return curves.size(); } - - /** Retrieves an animation curve contained within the channel. - @param index The index of the animation curve. - @return The animation curve at the given index. This pointer will be NULL - if the index is out-of-bounds. */ - FCDAnimationCurve* GetCurve(size_t index) { FUAssert(index < GetCurveCount(), return NULL); return curves.at(index); } - const FCDAnimationCurve* GetCurve(size_t index) const { FUAssert(index < GetCurveCount(), return NULL); return curves.at(index); } /**< See above. */ - - /** Adds a new animation curve to this animation channel. - @return The new animation curve. */ - FCDAnimationCurve* AddCurve(); - - /** Releases an animation curve contained within this channel. - @todo This function is not yet implemented, as it requires - a lot more memory management than FCollada currently does. - @param curve The animation curve to release. */ - void ReleaseCurve(FCDAnimationCurve* curve); - - /** [INTERNAL] Retrieves the target pointer prefix for this animation channel. - This function is used during the import of a COLLADA document to match the - target pointer prefixes with the animated elements. - @return The target pointer prefix. */ - const string& GetTargetPointer() const { return targetPointer; } - - /** [INTERNAL] Retrieves the target qualifier for this animation channel. - This function is used during the import of a COLLADA document. - Where there is a target qualifier, there should be only one curve contained by the channel. - @return The target qualifier. This value may be the empty string if the channel - targets all the values targeted by the target pointer prefix. */ - const string& GetTargetQualifier() const { return targetQualifier; } - - /** [INTERNAL] Enforces the tarrget pointer prefix for the animation channel. - This function is used during the export of a COLLADA document. - @param p The new target pointer prefix. */ - void SetTargetPointer(const string& p) { targetPointer = p; } - - /** [INTERNAL] Considers the given animated element as the driver for this animation channel. - @param animated An animated element. - @return Whether the animated element is in fact the driver for the animation channel. */ - bool LinkDriver(FCDAnimated* animated); - - /** [INTERNAL] Verifies that if a driver is used by this channel, then it was found during - the import of the animated elements. - @return The status of the verification. */ - FUStatus CheckDriver(); - - /** [INTERNAL] Reads in the animation channel from a given COLLADA XML tree node. - @param channelNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the animation channel. */ - FUStatus LoadFromXML(xmlNode* channelNode); - - /** [INTERNAL] Writes out the animation channel to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the animation channel. - @return The created element XML tree node. */ - void WriteToXML(xmlNode* parentNode) const; -}; - -#endif // _FCD_ANIMATION_CHANNEL_H_ diff --git a/Extras/FCollada/FCDocument/FCDAnimationClip.cpp b/Extras/FCollada/FCDocument/FCDAnimationClip.cpp deleted file mode 100644 index 172b6ec54..000000000 --- a/Extras/FCollada/FCDocument/FCDAnimationClip.cpp +++ /dev/null @@ -1,139 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDAnimation.h" -#include "FCDocument/FCDAnimationChannel.h" -#include "FCDocument/FCDAnimationClip.h" -#include "FCDocument/FCDAnimationCurve.h" -#include "FCDocument/FCDAnimated.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDAnimationClip::FCDAnimationClip(FCDocument* document) : FCDEntity(document, "AnimationClip") -{ - start = end = 0.0f; -} - -FCDAnimationClip::~FCDAnimationClip() -{ - curves.clear(); -} - -FCDAnimationClip* FCDAnimationClip::Clone() -{ - FCDAnimationClip* clone = new FCDAnimationClip(GetDocument()); - FCDEntity::Clone(clone); - - for(FCDAnimationCurveList::iterator it = curves.begin(); it != curves.end(); ++it) - { - curves.push_back((*it)->Clone()); - } - - clone->start = start; - clone->end = end; - return clone; -} - - -FUStatus FCDAnimationClip::LoadFromXML(xmlNode* clipNode) -{ - FUStatus status = FCDEntity::LoadFromXML(clipNode); - if (!status) return status; - if (!IsEquivalent(clipNode->name, DAE_ANIMCLIP_ELEMENT)) - { - return status.Warning(FS("Unknown element in animation clip library."), clipNode->line); - } - - // Read in and verify the clip's time/input bounds - start = FUStringConversion::ToFloat(ReadNodeProperty(clipNode, DAE_START_ATTRIBUTE)); - end = FUStringConversion::ToFloat(ReadNodeProperty(clipNode, DAE_END_ATTRIBUTE)); - if (end - start < FLT_TOLERANCE) - { - status.Warning(FS("Invalid start/end pair for animation clip: ") + TO_FSTRING(GetDaeId()), clipNode->line); - } - - // Read in the elements and segment the corresponding animation curves - xmlNodeList inputNodes; - FindChildrenByType(clipNode, DAE_INSTANCE_ANIMATION_ELEMENT, inputNodes); - for (xmlNodeList::iterator itI = inputNodes.begin(); itI != inputNodes.end(); ++itI) - { - xmlNode* inputNode = (*itI); - - // Retrieve the animation for this input - FUUri animationId = ReadNodeUrl(inputNode); - if (animationId.suffix.empty() || !animationId.prefix.empty()) - { - return status.Fail(FS("Invalid animation instantiation for animation clip: ") + TO_FSTRING(GetDaeId()), inputNode->line); - } - FCDAnimation* animation = GetDocument()->FindAnimation(animationId.suffix); - if (animation == NULL) continue; - - // Retrieve all the curves created under this animation node - FCDAnimationCurveList animationCurves; - animation->GetCurves(animationCurves); - if (animationCurves.empty()) - { - status.Warning(FS("No curves instantiated by animation '") + TO_FSTRING(animationId.suffix) + FS("' for animation clip: ") + TO_FSTRING(GetDaeId()), inputNode->line); - } - - for (FCDAnimationCurveList::iterator itC = animationCurves.begin(); itC != animationCurves.end(); ++itC) - { - // Keep only newly listed curves - FCDAnimationCurve* curve = *itC; - FCDAnimationCurveList::iterator itF = std::find(curves.begin(), curves.end(), curve); - if (itF == curves.end()) continue; - - curve->RegisterAnimationClip(this); - curves.push_back(curve); - } - } - - // Check for an empty clip - if (curves.empty()) - { - status.Warning(FS("Empty animation clip :") + TO_FSTRING(GetDaeId()), clipNode->line); - } - - return status; -} - -// Write out the COLLADA animations to the document -xmlNode* FCDAnimationClip::WriteToXML(xmlNode* parentNode) const -{ - // Create the element and write out its start/end information. - xmlNode* clipNode = FCDEntity::WriteToEntityXML(parentNode, DAE_ANIMCLIP_ELEMENT); - AddAttribute(clipNode, DAE_START_ATTRIBUTE, start); - AddAttribute(clipNode, DAE_END_ATTRIBUTE, end); - - // Build a list of the animations to instantiate - // from the list of curves for this clip - typedef vector FCDAnimationConstList; - FCDAnimationConstList animations; - for (FCDAnimationCurveList::const_iterator itC = curves.begin(); itC != curves.end(); ++itC) - { - const FCDAnimationChannel* channel = (*itC)->GetParent(); - if (channel == NULL) continue; - const FCDAnimation* animation = channel->GetParent(); - if (std::find(animations.begin(), animations.end(), animation) == animations.end()) - { - animations.push_back(animation); - } - } - - // Instantiate all the animations - for (FCDAnimationConstList::iterator itA = animations.begin(); itA != animations.end(); ++itA) - { - xmlNode* instanceNode = AddChild(clipNode, DAE_INSTANCE_ANIMATION_ELEMENT); - AddAttribute(instanceNode, DAE_URL_ATTRIBUTE, string("#") + (*itA)->GetDaeId()); - } - - FCDEntity::WriteToExtraXML(clipNode); - return clipNode; -} - diff --git a/Extras/FCollada/FCDocument/FCDAnimationClip.h b/Extras/FCollada/FCDocument/FCDAnimationClip.h deleted file mode 100644 index ed1cbdf87..000000000 --- a/Extras/FCollada/FCDocument/FCDAnimationClip.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _FCD_ANIMATION_CLIP_H_ -#define _FCD_ANIMATION_CLIP_H_ - -class FCDocument; -class FCDAnimationCurve; - -typedef vector FCDAnimationCurveList; - -#include "FCDocument/FCDEntity.h" -#include "FCDocument/FCDObject.h" - -class FCOLLADA_EXPORT FCDAnimationClip : public FCDEntity -{ -private: - FCDAnimationCurveList curves; - float start, end; - -public: - FCDAnimationClip(FCDocument* document); - virtual ~FCDAnimationClip(); - - FCDAnimationClip* Clone(); - - // FCDEntity overrides - virtual Type GetType() const { return ANIMATION_CLIP; } - - // Accessors - FCDAnimationCurveList& GetClipCurves() { return curves; } - const FCDAnimationCurveList& GetClipCurves() const { return curves; } - float GetStart() const { return start; } - float GetEnd() const { return end; } - - // Load a Collada animation node from the XML document - virtual FUStatus LoadFromXML(xmlNode* clipNode); - - // Write out the COLLADA animations to the document - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -#endif // _FCD_ANIMATION_CLIP_H_ - diff --git a/Extras/FCollada/FCDocument/FCDAnimationCurve.cpp b/Extras/FCollada/FCDocument/FCDAnimationCurve.cpp deleted file mode 100644 index 465ec420f..000000000 --- a/Extras/FCollada/FCDocument/FCDAnimationCurve.cpp +++ /dev/null @@ -1,295 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDAnimationCurve.h" -#include "FCDocument/FCDAnimationClip.h" -#include "FUtils/FUDaeEnum.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeWriter; - -FCDAnimationCurve::FCDAnimationCurve(FCDocument* document, FCDAnimationChannel* _parent) - : FCDObject(document, "FCDAnimationCurve"), - parent(_parent), - targetElement(-1), - preInfinity(FUDaeInfinity::CONSTANT), - postInfinity(FUDaeInfinity::CONSTANT), - inputDriver(NULL) -{ -} - -FCDAnimationCurve::~FCDAnimationCurve() -{ - inputDriver = NULL; - parent = NULL; - clips.clear(); -} - -FCDAnimationCurve* FCDAnimationCurve::Clone() -{ - FCDAnimationCurve* clone = new FCDAnimationCurve(GetDocument(), parent); - - clone->SetTargetElement(targetElement); - string q; - q.assign(targetQualifier); - clone->SetTargetQualifier(q); - - clone->keys = keys; - clone->keyValues = keyValues; - clone->inTangents = inTangents; - clone->outTangents = outTangents; - clone->inTangentWeights = inTangentWeights; - clone->outTangentWeights = outTangentWeights; - clone->isWeightedCurve = isWeightedCurve; - clone->preInfinity = preInfinity; - clone->postInfinity = postInfinity; - - clone->inputDriver = inputDriver; - - clone->SetDriverPointer(driverPointer); - - clone->interpolations = interpolations; - - // Animation clips that depend on this curve - for(FCDAnimationClipList::iterator it = clips.begin(); it != clips.end(); ++it) - { - clone->clips.push_back((*it)->Clone()); - } - return clone; -} - -// Prepare a curve for evaluation -void FCDAnimationCurve::Ready() -{ - if (keys.empty()) return; - - if (inTangents.empty() || outTangents.empty()) - { - // Calculate the bezier tangents - inTangents.resize(keys.size(), 0.0f); - outTangents.resize(keys.size(), 0.0f); - - if (keys.size() > 1) - { - for (size_t i = 0; i < keys.size(); ++i) - { - float previousKeySpan = (i > 0) ? keys[i] - keys[i - 1] : keys[i + 1] - keys[i]; - float nextKeySpan = (i < keys.size() - 1) ? keys[i + 1] - keys[i] : previousKeySpan; - float currentKeyValue = keyValues[i]; - float previousKeyValue = (i > 0) ? keyValues[i - 1] : currentKeyValue; - float nextKeyValue = (i < keys.size() - 1) ? keyValues[i + 1] : currentKeyValue; - float slope = (nextKeyValue - previousKeyValue) / (nextKeySpan + previousKeySpan); - inTangents[i] = previousKeySpan / 3.0f * slope; - outTangents[i] = nextKeySpan / 3.0f * slope; - } - } - } - - if (interpolations.empty()) - { - // Fill in the array with the default interpolation type - interpolations.resize(keys.size(), FUDaeInterpolation::DEFAULT); - } - - isWeightedCurve = !inTangentWeights.empty() && !outTangentWeights.empty(); -} - -// Main workhorse for the animation system: -// Evaluates the curve for a given input -float FCDAnimationCurve::Evaluate(float input) const -{ - if (keys.size() == 1) return keyValues.front(); - - float outputStart = keyValues.front(); - float outputEnd = keyValues.back(); - float inputStart = keys.front(); - float inputEnd = keys.back(); - float inputSpan = inputEnd - inputStart; - - // Account for pre-infinity mode - float outputOffset = 0.0f; - if (input <= inputStart) - { - switch (preInfinity) - { - case FUDaeInfinity::CONSTANT: return outputStart; - case FUDaeInfinity::LINEAR: return outputStart + (input - inputStart) * (keyValues[1] - outputStart) / (keys[1] - inputStart); - case FUDaeInfinity::CYCLE: { float cycleCount = ceilf((inputStart - input) / inputSpan); input += cycleCount * inputSpan; break; } - case FUDaeInfinity::CYCLE_RELATIVE: { float cycleCount = ceilf((inputStart - input) / inputSpan); input += cycleCount * inputSpan; outputOffset -= cycleCount * (outputEnd - outputStart); break; } - case FUDaeInfinity::OSCILLATE: { float cycleCount = ceilf((inputStart - input) / (2.0f * inputSpan)); input += cycleCount * 2.0f * inputSpan; input = inputEnd - fabsf(input - inputEnd); break; } - case FUDaeInfinity::UNKNOWN: default: return outputStart; - } - } - - // Account for post-infinity mode - else if (input >= inputEnd) - { - switch (postInfinity) - { - case FUDaeInfinity::CONSTANT: return outputEnd; - case FUDaeInfinity::LINEAR: return outputEnd + (input - inputEnd) * (keyValues[keys.size() - 2] - outputEnd) / (keys[keys.size() - 2] - inputEnd); - case FUDaeInfinity::CYCLE: { float cycleCount = ceilf((input - inputEnd) / inputSpan); input -= cycleCount * inputSpan; break; } - case FUDaeInfinity::CYCLE_RELATIVE: { float cycleCount = ceilf((input - inputEnd) / inputSpan); input -= cycleCount * inputSpan; outputOffset += cycleCount * (outputEnd - outputStart); break; } - case FUDaeInfinity::OSCILLATE: { float cycleCount = ceilf((input - inputEnd) / (2.0f * inputSpan)); input -= cycleCount * 2.0f * inputSpan; input = inputStart + fabsf(input - inputStart); break; } - case FUDaeInfinity::UNKNOWN: default: return outputEnd; - } - } - - // Find the current interval - uint32 index = 0; - FloatList::const_iterator it; - for (it = keys.begin(); it != keys.end(); ++it, ++index) - { - if ((*it) > input) break; - } - - // Get the keys and values for this interval - float endKey = *it; - float startKey = *(it - 1); - float endValue = keyValues[index]; - float startValue = keyValues[index - 1]; - float output; - - // Interpolate the output. - // Similar code is found in FCDAnimationMultiCurve.cpp. If you update this, update the other one too. - uint32 interpolation = interpolations.empty() ? ((uint32) FUDaeInterpolation::DEFAULT) : interpolations[index]; - switch (FUDaeInterpolation::Interpolation(interpolation)) - { - case FUDaeInterpolation::LINEAR: - output = (input - startKey) / (endKey - startKey) * (endValue - startValue) + startValue; - break; - - case FUDaeInterpolation::BEZIER: { - float t = (input - startKey) / (endKey - startKey); - float bValue = startValue + outTangents[index - 1]; - float cValue = endValue - inTangents[index]; - float ti = 1.0f - t; - output = startValue * ti * ti * ti + 3.0f * bValue * ti * ti * t + 3.0f * cValue * ti * t * t + endValue * t * t * t; - break; } - - case FUDaeInterpolation::STEP: - case FUDaeInterpolation::UNKNOWN: - default: - output = startValue; - break; - } - - return outputOffset + output; -} - -// Apply a conversion function on the key values and tangents -void FCDAnimationCurve::ConvertValues(FCDConversionFunction valueConversion, FCDConversionFunction tangentConversion) -{ - size_t keyCount = keys.size(); - if (valueConversion != NULL) - { - for (size_t k = 0; k < keyCount; k++) - { - keyValues[k] = (*valueConversion)(keyValues[k]); - } - } - if (tangentConversion != NULL) - { - for (size_t k = 0; k < keyCount; k++) - { - inTangents[k] = (*tangentConversion)(inTangents[k]); - outTangents[k] = (*tangentConversion)(outTangents[k]); - } - } -} - -// Apply a conversion function on the key times and tangent weights -void FCDAnimationCurve::ConvertInputs(FCDConversionFunction timeConversion, FCDConversionFunction tangentWeightConversion) -{ - size_t keyCount = keys.size(); - if (timeConversion != NULL) - { - for (size_t k = 0; k < keyCount; k++) - { - keys[k] = (*timeConversion)(keys[k]); - } - } - if (tangentWeightConversion != NULL) - { - for (size_t k = 0; k < keyCount; k++) - { - inTangentWeights[k] = (*tangentWeightConversion)(inTangentWeights[k]); - outTangentWeights[k] = (*tangentWeightConversion)(outTangentWeights[k]); - } - } -} - -// Write out the specific animation elements to the COLLADA xml tree node -void FCDAnimationCurve::WriteSourceToXML(xmlNode* parentNode, const string& baseId) const -{ - const char* parameter = targetQualifier.c_str(); - if (*parameter == '.') ++parameter; - - xmlNode* sourceNode = AddSourceFloat(parentNode, baseId + "-input", keys, "TIME"); - AddSourceFloat(parentNode, baseId + "-output", keyValues, parameter); - AddSourceFloat(parentNode, baseId + "-intangents", inTangents, parameter); - AddSourceFloat(parentNode, baseId + "-outtangents", outTangents, parameter); - if (isWeightedCurve && !inTangentWeights.empty()) - { - AddSourceFloat(parentNode, baseId + "-intangents_weights", inTangents, parameter); - AddSourceFloat(parentNode, baseId + "-outtangents_weights", outTangents, parameter); - } - AddSourceInterpolation(parentNode, baseId + "-interpolations", *(FUDaeInterpolationList*)&interpolations); - - // Export the infinity parameters - xmlNode* mayaTechnique = AddTechniqueChild(sourceNode, DAEMAYA_MAYA_PROFILE); - string infinityType = FUDaeInfinity::ToString(preInfinity); - AddChild(mayaTechnique, DAEMAYA_PREINFINITY_PARAMETER, infinityType); - infinityType = FUDaeInfinity::ToString(postInfinity); - AddChild(mayaTechnique, DAEMAYA_POSTINFINITY_PARAMETER, infinityType); -} - -xmlNode* FCDAnimationCurve::WriteSamplerToXML(xmlNode* parentNode, const string& baseId) const -{ - xmlNode* samplerNode = AddChild(parentNode, DAE_SAMPLER_ELEMENT); - AddAttribute(samplerNode, DAE_ID_ATTRIBUTE, baseId + "-sampler"); - - // Add the sampler inputs - AddInput(samplerNode, baseId + "-input", DAE_INPUT_ANIMATION_INPUT); - AddInput(samplerNode, baseId + "-output", DAE_OUTPUT_ANIMATION_INPUT); - AddInput(samplerNode, baseId + "-intangents", DAE_INTANGENT_ANIMATION_INPUT); - AddInput(samplerNode, baseId + "-outtangents", DAE_OUTTANGENT_ANIMATION_INPUT); - if (isWeightedCurve && !inTangentWeights.empty()) - { - AddInput(samplerNode, baseId + "-intangents_weights", DAEMAYA_INTANGENTWEIGHT_ANIMATION_INPUT); - AddInput(samplerNode, baseId + "-outtangents_weights", DAEMAYA_OUTTANGENTWEIGHT_ANIMATION_INPUT); - } - AddInput(samplerNode, baseId + "-interpolations", DAE_INTERPOLATION_ANIMATION_INPUT); - - // Add the driver input - if (inputDriver != NULL) - { - AddInput(samplerNode, driverPointer, DAEMAYA_DRIVER_INPUT); - } - - return samplerNode; -} - -xmlNode* FCDAnimationCurve::WriteChannelToXML(xmlNode* parentNode, const string& baseId, const char* targetPointer) const -{ - xmlNode* channelNode = AddChild(parentNode, DAE_CHANNEL_ELEMENT); - AddAttribute(channelNode, DAE_SOURCE_ATTRIBUTE, baseId + "-sampler"); - - // Generate and export the channel target - globalSBuilder.set(targetPointer); - if (targetElement >= 0) - { - globalSBuilder.append('('); globalSBuilder.append(targetElement); globalSBuilder.append(')'); - } - globalSBuilder.append(targetQualifier); - AddAttribute(channelNode, DAE_TARGET_ATTRIBUTE, globalSBuilder); - return channelNode; -} diff --git a/Extras/FCollada/FCDocument/FCDAnimationCurve.h b/Extras/FCollada/FCDocument/FCDAnimationCurve.h deleted file mode 100644 index c6699a325..000000000 --- a/Extras/FCollada/FCDocument/FCDAnimationCurve.h +++ /dev/null @@ -1,262 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDAnimationCurve.h - This file contains the FCDAnimationCurve class. -*/ - -#ifndef _FCD_ANIMATION_CURVE_H_ -#define _FCD_ANIMATION_CURVE_H_ - -#include "FUtils/FUDaeEnum.h" -#include "FCDocument/FCDObject.h" - -class FCDAnimationClip; -class FCDAnimationChannel; - -typedef vector FCDAnimationClipList; /**< A dynamically-sized array of animation clips. */ -typedef float (*FCDConversionFunction)(float v); /**< A simple conversion function. */ - -/** - A COLLADA single-dimensional animation curve. - An animation curve holds the keyframes necessary - to animate an animatable floating-point value. - - There are multiple interpolation mechanisms supported by COLLADA. - FCollada supports the CONSTANT, LINEAR and BEZIER interpolations. - - @see FUDaeInterpolation FUDaeInfinity - @ingroup FCDocument -*/ -class FCOLLADA_EXPORT FCDAnimationCurve : public FCDObject -{ -private: - FCDAnimationChannel* parent; - - // Targeting information - int32 targetElement; - string targetQualifier; - - // Input information - FloatList keys, keyValues; - FloatList inTangents, outTangents; - FloatList inTangentWeights, outTangentWeights; - bool isWeightedCurve; - FUDaeInfinity::Infinity preInfinity; - FUDaeInfinity::Infinity postInfinity; - - // Driver information - const float* inputDriver; - string driverPointer; - - // The interpolation values follow the FUDaeInterpolation enum (FUDaeEnum.h) - UInt32List interpolations; - - // Animation clips that depend on this curve - FCDAnimationClipList clips; - -public: - /** Constructor: do not use directly. - Instead, use the FCDAnimationChannel::AddCurve function. - You should also attach the new curve to an animated - element using the FCDAnimated::SetCurve function. - @param document The COLLADA document that owns the animation curve. - @param parent The animation channel that contains the curve. */ - FCDAnimationCurve(FCDocument* document, FCDAnimationChannel* parent); - - /** Destructor: do not release directly. - Instead, use the FCDAnimationChannel::ReleaseCurve function. */ - virtual ~FCDAnimationCurve(); - - /** Retrieves the animation channel that contains this animation curve. - @return The parent animation channel. */ - inline FCDAnimationChannel* GetParent() { return parent; } - inline const FCDAnimationChannel* GetParent() const { return parent; } /**< See above. */ - - /** Retrieves the list of key inputs for the animation curve. - @return The list of key inputs. */ - inline FloatList& GetKeys() { return keys; } - inline const FloatList& GetKeys() const { return keys; } /**< See above. */ - - /** Retrieves the list of key outputs for the animation curve. - @return The list of key outputs. */ - inline FloatList& GetKeyValues() { return keyValues; } - inline const FloatList& GetKeyValues() const { return keyValues; } /**< See above. */ - - /** Retrieves the list of interpolation type for the segments of the animation curve. - There is always one interpolation type for each key in the curve. The interpolation type - of a segment of the curve is set at the key at which begins the segment. - @see FUDaeInterpolation - @return The list of interpolation types. */ - inline UInt32List& GetInterpolations() { return interpolations; } - inline const UInt32List& GetInterpolations() const { return interpolations; } /**< See above. */ - - /** Retrieves the list of key in-tangent values for the animation curve. - This list has data only for curves that include segments with the bezier interpolation. - @return The list of in-tangent values. */ - inline FloatList& GetInTangents() { return inTangents; } - inline const FloatList& GetInTangents() const { return inTangents; } /**< See above. */ - - /** Retrieves the list of key out-tangent values for the animation curve. - This list has data only for curves that include segments with the bezier interpolation. - @return The list of out-tangent values. */ - inline FloatList& GetOutTangents() { return outTangents; } - inline const FloatList& GetOutTangents() const { return outTangents; } /**< See above. */ - - /** Retrieves the list of key in-tangent weights for the animation curve. - This list has data only for curves that are weighted - and include segments with the bezier interpolation. - @see IsWeightedCurve - @return The list of in-tangent weights. */ - inline FloatList& GetInTangentWeights() { return inTangentWeights; } - inline const FloatList& GetInTangentWeights() const { return inTangentWeights; } /**< See above. */ - - /** Retrieves the list of key out-tangent weights for the animation curve. - This list has data only for curves that are weighted - and include segments with the bezier interpolation. - @see IsWeightedCurve - @return The list of out-tangent weights. */ - inline FloatList& GetOutTangentWeights() { return outTangentWeights; } - inline const FloatList& GetOutTangentWeights() const { return outTangentWeights; } /**< See above. */ - - /** Retrieves whether this curve has weighted tangents. Tangent weights - give you access to 2D tangents by providing the length of the tangent. - @return Whether this curve has weighted tangents. */ - inline bool IsWeightedCurve() const { return isWeightedCurve; } - - /** Sets whether this curve has weighted tangents. Tangent weights - give you access to 2D tangents by providing the length of the tangent. - @param _isWeightedCurve Whether this curve has weighted tangents. */ - inline void SetWeightedCurveFlag(bool _isWeightedCurve) { isWeightedCurve = _isWeightedCurve; } - - /** Retrieves the type of behavior for the curve if the input value is - outside the input interval defined by the curve keys and less than any key input value. - @see FUDaeInfinity - @return The pre-infinity behavior of the curve. */ - inline FUDaeInfinity::Infinity GetPreInfinity() const { return preInfinity; } - - /** Sets the behavior of the curve if the input value is - outside the input interval defined by the curve keys and less than any key input value. - @see FUDaeInfinity - @param infinity The pre-infinity behavior of the curve. */ - inline void SetPreInfinity(FUDaeInfinity::Infinity infinity) { preInfinity = infinity; } - - /** Retrieves the type of behavior for the curve if the input value is - outside the input interval defined by the curve keys and greater than any key input value. - @see FUDaeInfinity - @return The post-infinity behavior of the curve. */ - inline FUDaeInfinity::Infinity GetPostInfinity() const { return postInfinity; } - - /** Sets the behavior of the curve if the input value is - outside the input interval defined by the curve keys and greater than any key input value. - @see FUDaeInfinity - @param infinity The post-infinity behavior of the curve. */ - inline void SetPostInfinity(FUDaeInfinity::Infinity infinity) { postInfinity = infinity; } - - /** Retrieves the value pointer that drives this animation curve. - @return The driver value pointer. This pointer will be NULL to indicate - that time drives the animation curve. */ - inline const float* GetDriver() const { return inputDriver; } - - /** Sets the value pointer that drives the animation curve. - @param driver The driver value pointer. Set this pointer to NULL - to indicate that time drives the animation curve. */ - inline void SetDriver(const float* driver) { inputDriver = driver; } - - /** Retrieves the list of animation clips that use this animation curve. - @return The list of animation clips. */ - inline FCDAnimationClipList& GetClips() { return clips; } - inline const FCDAnimationClipList& GetClips() const { return clips; } /**< See above. */ - - /** Readies this curve for evaluation. - This will create the tangents and the tangent weights, if necessary. */ - void Ready(); - - /** Clones the animation curve. - @return The cloned animation curve. */ - FCDAnimationCurve* Clone(); - - /** Applies a conversion function to the keys output values of the animation curve. - @param valueConversion The conversion function to use on the key outputs. - @param tangentConversion The conversion function to use on the key tangents. */ - void ConvertValues(FCDConversionFunction valueConversion, FCDConversionFunction tangentConversion); - - /** Applies a conversion function to the keys input values of the animation curve. - @param timeConversion The conversion function to use on the key inputs. - @param tangentWeightConversion The conversion function to use on the key tangent weights. */ - void ConvertInputs(FCDConversionFunction timeConversion, FCDConversionFunction tangentWeightConversion); - - /** Evaluates the animation curve. - @param input An input value. - @return The sampled value of the curve at the given input value. */ - float Evaluate(float input) const; - - /** [INTERNAL] Adds an animation clip to the list of animation clips that use this curve. - @param clip An animation clip. */ - inline void RegisterAnimationClip(FCDAnimationClip* clip) { clips.push_back(clip); } - - /** [INTERNAL] Writes out the data sources necessary to import the animation curve - to a given XML tree node. - @param parentNode The XML tree node in which to create the data sources. - @param baseId A COLLADA Id prefix to use when generating the source ids. */ - void WriteSourceToXML(xmlNode* parentNode, const string& baseId) const; - - /** [INTERNAL] Writes out the sampler that puts together the data sources - and generates a sampling function. - @param parentNode The XML tree node in which to create the sampler. - @param baseId The COLLADA id prefix used when generating the source ids. - This prefix is also used to generate the sampler COLLADA id. - @return The created XML tree node. */ - xmlNode* WriteSamplerToXML(xmlNode* parentNode, const string& baseId) const; - - /** [INTERNAL] Writes out the animation channel that attaches the sampling function - to the animatable value. - @param parentNode The XML tree node in which to create the sampler. - @param baseId The COLLADA Id prefix used when generating the source ids - and the sampler id. - @param targetPointer The target pointer prefix for the targeted animated element. - @return The created XML tree node. */ - xmlNode* WriteChannelToXML(xmlNode* parentNode, const string& baseId, const char* targetPointer) const; - - /** [INTERNAL] Retrieves the target element suffix for the curve. - This will be -1 if the animated element does not belong to an - animated element list. - @return The target element suffix. */ - inline int32 GetTargetElement() const { return targetElement; } - - /** [INTERNAL] Retrieves the target qualifier for the curve. - This will be the empty string if that the curve affects - a one-dimensional animated element. - @return The target qualifier. */ - inline const string& GetTargetQualifier() const { return targetQualifier; } - - /** [INTERNAL] Sets the target element suffix for the curve. - @param e The target element suffix. Set to value to -1 - if the animated element does not belong to an animated element list. */ - inline void SetTargetElement(int32 e) { targetElement = e; } - - /** [INTERNAL] Sets the target qualifier for the curve. - @param q The target qualifier. You may sets this string to the empty string - only if that the curve affects a one-dimensional animated element. */ - inline void SetTargetQualifier(const string& q) { targetQualifier = q; } - - /** [INTERNAL] Retrieves the target pointer prefix of the driver. - @return The driver's target pointer prefix. */ - inline const string& GetDriverPointer() const { return driverPointer; } - - /** [INTERNAL] Sets the target pointer prefix of the driver. - @param p The driver's target pointer prefix. Set this string to the - empty string if the input of the animation curve is the time. */ - inline void SetDriverPointer(const string& p) { driverPointer = p; } -}; - -#endif // _FCD_ANIMATION_CURVE_H_ diff --git a/Extras/FCollada/FCDocument/FCDAnimationMultiCurve.cpp b/Extras/FCollada/FCDocument/FCDAnimationMultiCurve.cpp deleted file mode 100644 index 35278ae94..000000000 --- a/Extras/FCollada/FCDocument/FCDAnimationMultiCurve.cpp +++ /dev/null @@ -1,378 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDAnimationCurve.h" -#include "FCDocument/FCDAnimationMultiCurve.h" -#include "FUtils/FUDaeEnum.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeWriter; - -#define SMALL_DELTA 0.001f - -FCDAnimationMultiCurve::FCDAnimationMultiCurve(FCDocument* document, uint32 _dimension) : FCDObject(document, "FCDAnimationMultiCurve") -{ - dimension = _dimension; - if (dimension == 0) dimension = 1; - - // Prepare the target information - targetElement = -1; - targetQualifiers = new string[dimension]; - - // Allocate the key values and tangents to the wanted dimension - keyValues = new FloatList[dimension]; - inTangents = new FloatList[dimension]; - outTangents = new FloatList[dimension]; -} - -FCDAnimationMultiCurve::~FCDAnimationMultiCurve() -{ - SAFE_DELETE_ARRAY(targetQualifiers); - SAFE_DELETE_ARRAY(keyValues); - SAFE_DELETE_ARRAY(inTangents); - SAFE_DELETE_ARRAY(outTangents); -} - -// Samples all the curves for a given input -void FCDAnimationMultiCurve::Evaluate(float input, float* output) const -{ - // Single key curves imply a constant value - if (keys.size() == 1) - { - for (uint32 i = 0; i < dimension; ++i) output[i] = keyValues[i].front(); - return; - } - - // Find the current interval - uint32 index = 0; - FloatList::const_iterator it; - for (it = keys.begin(); it != keys.end(); ++it, ++index) - { - if ((*it) > input) break; - } - - if (it == keys.end()) - { - // We're sampling after the curve, return the last values - for (uint32 i = 0; i < dimension; ++i) output[i] = keyValues[i].back(); - return; - } - else if (it == keys.begin()) - { - // We're sampling before the curve, return the first values - for (uint32 i = 0; i < dimension; ++i) output[i] = keyValues[i].front(); - return; - } - - // Get the keys and values for this interval - float endKey = *it; - float startKey = *(it - 1); - - // Interpolate the outputs. - // Similar code is found in FCDAnimationCurve.cpp. If you update this, update the other one too. - uint32 interpolation = interpolations.empty() ? ((uint32) FUDaeInterpolation::DEFAULT) : interpolations[index]; - switch (FUDaeInterpolation::Interpolation(interpolation)) - { - case FUDaeInterpolation::LINEAR: { - for (uint32 i = 0; i < dimension; ++i) - { - float startValue = keyValues[i][index - 1]; - float endValue = keyValues[i][index]; - output[i] = (input - startKey) / (endKey - startKey) * (endValue - startValue) + startValue; - } - break; } - - case FUDaeInterpolation::BEZIER: { - for (uint32 i = 0; i < dimension; ++i) - { - float startValue = keyValues[i][index - 1]; - float endValue = keyValues[i][index]; - - float t = (input - startKey) / (endKey - startKey); - float bValue = startValue + outTangents[i][index - 1]; - float cValue = endValue - inTangents[i][index]; - float ti = 1.0f - t; - - output[i] = startValue * ti * ti * ti + 3.0f * bValue * ti * ti * t + 3.0f * cValue * ti * t * t + endValue * t * t * t; - } - break; } - - case FUDaeInterpolation::UNKNOWN: - case FUDaeInterpolation::STEP: - default: { - for (uint32 i = 0; i < dimension; ++i) - { - output[i] = keyValues[i][index - 1]; - } - break; } - } -} - -FCDAnimationMultiCurve* FCDAnimationMultiCurve::MergeCurves(const vector& _toMerge, const FloatList& defaultValues) -{ - vector toMerge(_toMerge.size()); - for (vector::const_iterator itC = _toMerge.begin(); itC != _toMerge.end(); ++itC) - { - toMerge.push_back(*itC); - } - return MergeCurves(toMerge, defaultValues); -} - -// Non-standard constructor used to merge together animation curves -FCDAnimationMultiCurve* FCDAnimationMultiCurve::MergeCurves(const vector& toMerge, const FloatList& defaultValues) -{ - size_t dimension = toMerge.size(); - if (dimension == 0) return NULL; - - // Look for the document pointer - FCDocument* document = NULL; - int32 targetElement = -1; - for (size_t i = 0; i < dimension; ++i) - { - if (toMerge[i] != NULL) - { - document = toMerge[i]->GetDocument(); - targetElement = toMerge[i]->GetTargetElement(); - } - } - if (document == NULL) return NULL; - - // Allocate the output multiCurve. - FCDAnimationMultiCurve* multiCurve = new FCDAnimationMultiCurve(document, (uint32) dimension); - multiCurve->targetElement = targetElement; - - // Grab all the animation curve data element right away, to spare me some typing. - FloatList& keys = multiCurve->GetKeys(); - FloatList* values = multiCurve->GetKeyValues(); - FloatList* inTangents = multiCurve->GetInTangents(); - FloatList* outTangents = multiCurve->GetOutTangents(); - UInt32List& interpolations = multiCurve->GetInterpolations(); - - // Calculate the merged input keys - for (size_t i = 0; i < dimension; ++i) - { - const FCDAnimationCurve* curve = toMerge[i]; - if (curve == NULL) continue; - - const FloatList& curveKeys = curve->GetKeys(); - - // Merge each curve's keys, which should already be sorted, into the multi-curve's - size_t multiCurveKeyCount = keys.size(), m = 0; - size_t curveKeyCount = curveKeys.size(), c = 0; - while (m < multiCurveKeyCount && c < curveKeyCount) - { - if (IsEquivalent(keys[m], curveKeys[c])) { ++c; ++m; } - else if (keys[m] < curveKeys[c]) { ++m; } - else { keys.insert(keys.begin() + m, curveKeys[c++]); } - } - if (c < curveKeyCount) keys.insert(keys.end(), curveKeys.begin() + c, curveKeys.end()); - } - size_t keyCount = keys.size(); - - // Start with the unknown interpolation everywhere - interpolations.resize(keyCount); - for (UInt32List::iterator it = interpolations.begin(); it != interpolations.end(); ++it) - { - (*it) = (uint32) FUDaeInterpolation::UNKNOWN; - } - - // Merge the curves one by one into the multi-curve - for (size_t i = 0; i < dimension; ++i) - { - // Pre-allocate the value and tangent data arrays - values[i].resize(keyCount); - inTangents[i].resize(keyCount); - outTangents[i].resize(keyCount); - - const FCDAnimationCurve* curve = toMerge[i]; - if (curve == NULL) - { - // No curve, set the default value on all the keys - float defaultValue = (i < defaultValues.size()) ? defaultValues[i] : 0.0f; - for (size_t k = 0; k < keyCount; ++k) - { - values[i][k] = defaultValue; - inTangents[i][k] = 0.0f; - outTangents[i][k] = 0.0f; - } - continue; - } - - multiCurve->targetQualifiers[i] = curve->GetTargetQualifier(); - - // Does the curve have per-key interpolations? - bool hasDefaultInterpolation = curve->GetInterpolations().empty(); - - // Merge in this curve's values, sampling when the multi-curve's key is not present in the curve. - const FloatList& curveKeys = curve->GetKeys(); - size_t curveKeyCount = curveKeys.size(); - bool sampleNextInTangent = false; - for (size_t k = 0, c = 0; k < keyCount; ++k) - { - uint32 interpolation; - if (c >= curveKeyCount || !IsEquivalent(keys[k], curveKeys[c])) - { - // Sample the curve - float value = values[i][k] = curve->Evaluate(keys[k]); - - // Calculate the in-tangent and the previous key's out-tangent - float span = ((k > 0) ? (keys[k] - keys[k - 1]) : (keys[k + 1] - keys[k])) / 3.0f; - inTangents[i][k] = value - curve->Evaluate(keys[k] - SMALL_DELTA) / SMALL_DELTA * span; - if (k > 0) outTangents[i][k-1] = curve->Evaluate(keys[k - 1] + SMALL_DELTA) / SMALL_DELTA * span - values[i][k-1]; - - // Calculate the out-tangent and force the sampling of the next key's in-tangent - span = (c < curveKeyCount - 1) ? (keys[k + 1] - keys[k]) / 3.0f : span; - outTangents[i][k] = curve->Evaluate(keys[k] + SMALL_DELTA) / SMALL_DELTA * span - value; - interpolation = FUDaeInterpolation::BEZIER; - sampleNextInTangent = true; - } - else - { - // Keys match, grab the values directly - values[i][k] = curve->GetKeyValues()[c]; - outTangents[i][k] = curve->GetOutTangents()[c]; - interpolation = hasDefaultInterpolation ? ((uint32) FUDaeInterpolation::DEFAULT) : curve->GetInterpolations()[c]; - - // Sampling the previous key would require that we sample the inTangent - if (!sampleNextInTangent) inTangents[i][k] = curve->GetInTangents()[c]; - else - { - float span = (keys[k] - keys[k - 1]) / 3.0f; - inTangents[i][k] = values[i][k] - curve->Evaluate(keys[k] - SMALL_DELTA) / SMALL_DELTA * span; - } - ++c; - } - - // Merge the interpolation values, where bezier wins whenever interpolation values differ - uint32& oldInterpolation = interpolations[k]; - if (oldInterpolation == FUDaeInterpolation::UNKNOWN) oldInterpolation = interpolation; - else if (oldInterpolation != interpolation) oldInterpolation = FUDaeInterpolation::BEZIER; - } - } - - // Reset any unknown interpolation left - for (UInt32List::iterator it = interpolations.begin(); it != interpolations.end(); ++it) - { - if ((*it) == (uint32) FUDaeInterpolation::UNKNOWN) (*it) = FUDaeInterpolation::DEFAULT; - } - - return multiCurve; -} - -// Collapse this multi-dimensional curve into a one-dimensional curve, given a collapsing function -FCDAnimationCurve* FCDAnimationMultiCurve::Collapse(FCDCollapsingFunction collapse) const -{ - size_t keyCount = keys.size(); - if (keyCount == 0 || dimension == 0) return NULL; - if (collapse == NULL) collapse = Average; - - // Create the output one-dimensional curve and retrieve its data list - FCDAnimationCurve* out = new FCDAnimationCurve(GetDocument(), NULL); - out->SetTargetElement(targetElement); - FloatList& outKeys = out->GetKeys(); - FloatList& outKeyValues = out->GetKeyValues(); - FloatList& outInTangents = out->GetInTangents(); - FloatList& outOutTangents = out->GetOutTangents(); - UInt32List& outInterpolations = out->GetInterpolations(); - - // Pre-allocate the output arrays - outKeys.resize(keyCount); - outKeyValues.resize(keyCount); - outInTangents.resize(keyCount); - outOutTangents.resize(keyCount); - outInterpolations.resize(keyCount); - - // Copy the key data over, collapsing the values - float* buffer = new float[dimension]; - for (size_t i = 0; i < keyCount; ++i) - { - outKeys[i] = keys[i]; - outInterpolations[i] = interpolations[i]; - - // Collapse the values and the tangents -# define COLLAPSE(outArray, inArray) \ - for (uint32 j = 0; j < dimension; ++j) buffer[j] = inArray[j][i]; \ - outArray[i] = (*collapse)(buffer, dimension) - - COLLAPSE(outKeyValues, keyValues); - COLLAPSE(outInTangents, inTangents); - COLLAPSE(outOutTangents, outTangents); -# undef COLLAPSE - } - SAFE_DELETE_ARRAY(buffer); - - return out; -} - -// Write out the specific animation elements to the COLLADA xml tree node -void FCDAnimationMultiCurve::WriteSourceToXML(xmlNode* parentNode, const string& baseId) -{ - if (keys.empty() || dimension == 0 || keyValues[0].empty()) return; - - // Generate the list of the parameters - typedef const char* pchar; - pchar* parameters = new pchar[dimension]; - for (size_t i = 0; i < dimension; ++i) - { - parameters[i] = targetQualifiers[i].c_str(); - if (*(parameters[i]) == '.') ++(parameters[i]); - } - - // Export the key times - AddSourceFloat(parentNode, baseId + "-input", keys, "TIME"); - - // Interlace the key values and tangents for the export - size_t valueCount = keyValues[0].size(); - FloatList sourceData; sourceData.reserve(dimension * valueCount); - for (size_t v = 0; v < valueCount; ++v) for (uint32 n = 0; n < dimension; ++n) sourceData.push_back(keyValues[n].at(v)); - AddSourceFloat(parentNode, baseId + "-output", sourceData, dimension, parameters); - - sourceData.clear(); - for (size_t v = 0; v < valueCount; ++v) for (uint32 n = 0; n < dimension; ++n) sourceData.push_back(inTangents[n].at(v)); - AddSourceFloat(parentNode, baseId + "-intangents", sourceData, dimension, parameters); - - sourceData.clear(); - for (size_t v = 0; v < valueCount; ++v) for (uint32 n = 0; n < dimension; ++n) sourceData.push_back(outTangents[n].at(v)); - AddSourceFloat(parentNode, baseId + "-outtangents", sourceData, dimension, parameters); - - // Weights not yet supported on multi-curve - - AddSourceInterpolation(parentNode, baseId + "-interpolations", *(FUDaeInterpolationList*)&interpolations); -} - -xmlNode* FCDAnimationMultiCurve::WriteSamplerToXML(xmlNode* parentNode, const string& baseId) -{ - xmlNode* samplerNode = AddChild(parentNode, DAE_SAMPLER_ELEMENT); - AddAttribute(samplerNode, DAE_ID_ATTRIBUTE, baseId + "-sampler"); - - // Add the sampler inputs - AddInput(samplerNode, baseId + "-input", DAE_INPUT_ANIMATION_INPUT); - AddInput(samplerNode, baseId + "-output", DAE_OUTPUT_ANIMATION_INPUT); - AddInput(samplerNode, baseId + "-intangents", DAE_INTANGENT_ANIMATION_INPUT); - AddInput(samplerNode, baseId + "-outtangents", DAE_OUTTANGENT_ANIMATION_INPUT); - AddInput(samplerNode, baseId + "-interpolations", DAE_INTERPOLATION_ANIMATION_INPUT); - return samplerNode; -} - -xmlNode* FCDAnimationMultiCurve::WriteChannelToXML(xmlNode* parentNode, const string& baseId, const string& pointer) -{ - xmlNode* channelNode = AddChild(parentNode, DAE_CHANNEL_ELEMENT); - AddAttribute(channelNode, DAE_SOURCE_ATTRIBUTE, baseId + "-sampler"); - - // Generate and export the full target [no qualifiers] - globalSBuilder.set(pointer); - if (targetElement >= 0) - { - globalSBuilder.append('('); globalSBuilder.append(targetElement); globalSBuilder.append(')'); - } - AddAttribute(channelNode, DAE_TARGET_ATTRIBUTE, globalSBuilder); - return channelNode; -} diff --git a/Extras/FCollada/FCDocument/FCDAnimationMultiCurve.h b/Extras/FCollada/FCDocument/FCDAnimationMultiCurve.h deleted file mode 100644 index 55950b73c..000000000 --- a/Extras/FCollada/FCDocument/FCDAnimationMultiCurve.h +++ /dev/null @@ -1,179 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDAnimationMultiCurve.h - This file contains the FCDAnimationMultiCurve class. -*/ - -#ifndef _FCD_ANIMATION_MULTI_CURVE_H_ -#define _FCD_ANIMATION_MULTI_CURVE_H_ - -class FCDocument; - -#include "FCDocument/FCDObject.h" - -typedef float (*FCDConversionFunction)(float v); /**< A simple conversion function. */ -typedef float (*FCDCollapsingFunction)(float* values, uint32 count); /**< A collapsing function. It converts multiple floating-point values into one floating-point value. */ - -/** - A COLLADA multi-dimensional animation curve. - - This is a utility class that is used to convert multiple - animation curves into one animation curve that has multiple - dimensions, but only one list of key inputs. - - FCollada will never create a multi-dimensional animation curve - during the import of a COLLADA document. - - @ingroup FCDocument -*/ -class FCOLLADA_EXPORT FCDAnimationMultiCurve : public FCDObject -{ -private: - // The number of merged curves - uint32 dimension; - - // Target information - int32 targetElement; - string* targetQualifiers; - - // Input information - FloatList keys,* keyValues; - FloatList* inTangents,* outTangents; - - // The interpolation values follow the FUDaeInterpolation enum (FUDaeEnum.h) - UInt32List interpolations; - -public: - /** Constructor. - The number of dimensions will not change in the lifetime of a - multi-dimensional curve. - @param document The COLLADA document that owns the animation curve. - @param dimension The number of dimensions for the animation curve. */ - FCDAnimationMultiCurve(FCDocument* document, uint32 dimension); - - /** Destructor. */ - virtual ~FCDAnimationMultiCurve(); - - /** Merges multiple single-dimensional animation curves into one - multi-dimensional animation curve. - For each NULL element found within the 'toMerge' list, the corresponding - default value is used. If there are not enough default values provided, zero is assumed. - The number of dimensions for the output animation curve is taken as the size of the 'toMerge' list. - @param toMerge The list of single-dimensional animation curves to merge. This list may - contain NULL elements, as explained above. - @param defaultValues The list of default values to use when a NULL element is encountered. - Default values should be provided even for the elements that are not NULL. */ - static FCDAnimationMultiCurve* MergeCurves(const vector& toMerge, const FloatList& defaultValues); - static FCDAnimationMultiCurve* MergeCurves(const vector& toMerge, const FloatList& defaultValues); /**< See above. */ - - /** Retrieves the number of dimensions for the curve. - @return The number of dimensions for the curve. */ - inline uint32 GetDimension() const { return dimension; } - - /** Retrieves the list of key inputs for the animation curve. - @return The list of key inputs. */ - inline FloatList& GetKeys() { return keys; } - inline const FloatList& GetKeys() const { return keys; } /**< See above. */ - - /** Retrieves the lists of key outputs for the animation curve. - There is one separate list of key outputs for each dimension of the curve. - @return The lists of key outputs. */ - inline FloatList* GetKeyValues() { return keyValues; } - inline const FloatList* GetKeyValues() const { return keyValues; } /**< See above. */ - - /** Retrieves the lists of key in-tangent values for the animation curve. - These lists have data only if the curve includes segments with the bezier interpolation. - There is one separate list of key in-tangent values for each dimension of the curve. - @return The lists of in-tangent values. */ - inline FloatList* GetInTangents() { return inTangents; } - inline const FloatList* GetInTangents() const { return inTangents; } /**< See above. */ - - /** Retrieves the lists of key out-tangent values for the animation curve. - These lists have data only if the curve includes segments with the bezier interpolation. - There is one separate list of key out-tangent values for each dimension of the curve. - @return The lists of out-tangent values. */ - inline FloatList* GetOutTangents() { return outTangents; } - inline const FloatList* GetOutTangents() const { return outTangents; } /**< See above. */ - - /** Retrieves the list of interpolation type for the segments of the animation curve. - There is always one interpolation type for each key in the curve. The interpolation type - of a segment of the curve is set at the key at which begins the segment. - @see FUDaeInterpolation - @return The list of interpolation types. */ - inline UInt32List& GetInterpolations() { return interpolations; } - inline const UInt32List& GetInterpolations() const { return interpolations; } /**< See above. */ - - /** Evaluates the animation curve. - @param input An input value. - @param output An array of floating-point values to fill in with the sampled values. */ - void Evaluate(float input, float* output) const; - - /** Collapses this multi-dimensional curve into a one-dimensional curve. - @param collapse The function to use to collapse multiple floating-point - values into one. Set this to NULL to use the default collapsing - function, which averages all the values. - @see Average TakeFirst */ - FCDAnimationCurve* Collapse(FCDCollapsingFunction collapse=NULL) const; - - /** [INTERNAL] Writes out the data sources necessary to import the animation curve - to a given XML tree node. - @param parentNode The XML tree node in which to create the data sources. - @param baseId A COLLADA Id prefix to use when generating the source ids. */ - void WriteSourceToXML(xmlNode* parentNode, const string& baseId); - - /** [INTERNAL] Writes out the sampler that puts together the data sources - and generates a sampling function. - @param parentNode The XML tree node in which to create the sampler. - @param baseId The COLLADA id prefix used when generating the source ids. - This prefix is also used to generate the sampler COLLADA id. - @return The created XML tree node. */ - xmlNode* WriteSamplerToXML(xmlNode* parentNode, const string& baseId); - - /** [INTERNAL] Writes out the animation channel that attaches the sampling function - to the animatable value. - @param parentNode The XML tree node in which to create the sampler. - @param baseId The COLLADA Id prefix used when generating the source ids - and the sampler id. - @param pointer The target pointer prefix for the targeted animated element. - @return The created XML tree node. */ - xmlNode* WriteChannelToXML(xmlNode* parentNode, const string& baseId, const string& pointer); - - /** [INTERNAL] Retrieves the target element suffix for the curve. - This will be -1 if the animated element does not belong to an - animated element list. - @return The target element suffix. */ - inline int32 GetTargetElement() const { return targetElement; } - - /** [INTERNAL] Sets the target element suffix for the curve. - @param e The target element suffix. Set to value to -1 - if the animated element does not belong to an animated element list. */ - inline void SetTargetElement(int32 e) { targetElement = e; } -}; - -/** - Retrieves the first floating-point value of a list of floating-point values. - This is a typical conversion function. - @param values The list of floating-point values. - @param count The number of values within the given list. -*/ -inline float TakeFirst(float* values, uint32 count) { return (count > 0) ? *values : 0.0f; } - -/** - Retrieves the average value of a list of floating-point values. - This is a typical conversion function. - @param values The list of floating-point values. - @param count The number of values within the given list. -*/ -inline float Average(float* values, uint32 count) { float v = 0.0f; for (uint32 i = 0; i < count; ++i) v += values[i]; v /= float(count); return v; } - -#endif // _FCD_ANIMATION_MULTI_CURVE_H_ diff --git a/Extras/FCollada/FCDocument/FCDAsset.cpp b/Extras/FCollada/FCDocument/FCDAsset.cpp deleted file mode 100644 index 6ee55768c..000000000 --- a/Extras/FCollada/FCDocument/FCDAsset.cpp +++ /dev/null @@ -1,207 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FUtils/FUDateTime.h" -#include "FCDocument/FCDAsset.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDAsset::FCDAsset(FCDocument* document) : FCDObject(document, "FCDAsset") -{ - unitConversionFactor = 1.0f; - unitName = FC("meter"); - upAxis = FMVector3::YAxis; - creationDateTime = modifiedDateTime = FUDateTime::GetNow(); -} - -FCDAsset::~FCDAsset() -{ - while(!contributors.empty()) - { - SAFE_DELETE(contributors.back()); - contributors.pop_back(); - } -} - -// Insert a new contributor within the list -FCDAssetContributor* FCDAsset::AddContributor() -{ - FCDAssetContributor* contributor = new FCDAssetContributor(GetDocument()); - contributors.push_back(contributor); - return contributor; -} - -// Read in the element from a COLLADA xml document -FUStatus FCDAsset::LoadFromXML(xmlNode* assetNode) -{ - FUStatus status; - bool isPreCollada1_4 = false; - for (xmlNode* child = assetNode->children; child != NULL; child = child->next) - { - if (child->type != XML_ELEMENT_NODE) continue; - - const char* content = ReadNodeContentDirect(child); - if (IsEquivalent(child->name, DAE_CONTRIBUTOR_ASSET_ELEMENT)) - { - FCDAssetContributor* contributor = new FCDAssetContributor(GetDocument()); - contributors.push_back(contributor); - status.AppendStatus(contributor->LoadFromXML(child, false)); - } - else if (IsEquivalent(child->name, DAE_CREATED_ASSET_PARAMETER)) - { - FUStringConversion::ToDateTime(content, creationDateTime); - } - else if (IsEquivalent(child->name, DAE_KEYWORDS_ASSET_PARAMETER)) - { - keywords = TO_FSTRING(content); - } - else if (IsEquivalent(child->name, DAE_MODIFIED_ASSET_PARAMETER)) - { - FUStringConversion::ToDateTime(content, modifiedDateTime ); - } - else if (IsEquivalent(child->name, DAE_REVISION_ASSET_PARAMETER)) - { - revision = TO_FSTRING(content); - } - else if (IsEquivalent(child->name, DAE_SUBJECT_ASSET_PARAMETER)) - { - subject = TO_FSTRING(content); - } - else if (IsEquivalent(child->name, DAE_TITLE_ASSET_PARAMETER)) - { - title = TO_FSTRING(content); - } - else if (IsEquivalent(child->name, DAE_UNITS_ASSET_PARAMETER)) - { - unitName = TO_FSTRING(ReadNodeName(child)); - unitConversionFactor = FUStringConversion::ToFloat(ReadNodeProperty(child, DAE_METERS_ATTRIBUTE)); - if (unitName.empty()) unitName = FC("UNKNOWN"); - if (IsEquivalent(unitConversionFactor, 0.0f) || unitConversionFactor < 0.0f) unitConversionFactor = 1.0f; - } - else if (IsEquivalent(child->name, DAE_UPAXIS_ASSET_PARAMETER)) - { - if (IsEquivalent(content, DAE_X_UP)) upAxis = FMVector3::XAxis; - else if (IsEquivalent(content, DAE_Y_UP)) upAxis = FMVector3::YAxis; - else if (IsEquivalent(content, DAE_Z_UP)) upAxis = FMVector3::ZAxis; - } - else if (IsEquivalent(child->name, DAE_AUTHOR_ASSET_PARAMETER) || IsEquivalent(child->name, DAE_AUTHORINGTOOL_ASSET_PARAMETER) - || IsEquivalent(child->name, DAE_COMMENTS_ASSET_PARAMETER) || IsEquivalent(child->name, DAE_SOURCEDATA_ASSET_PARAMETER) - || IsEquivalent(child->name, DAE_COPYRIGHT_ASSET_PARAMETER)) - { - isPreCollada1_4 = true; - } - else - { - status.Warning(FS("Unknown child element: ") + TO_FSTRING((const char*) child->name), child->line); - } - } - - // COLLADA 1.3 Backward Compatibility: Look for the contributor information within the element - if (isPreCollada1_4) - { - FCDAssetContributor* contributor = new FCDAssetContributor(GetDocument()); - contributor->LoadFromXML(assetNode, true); - if (!contributor->IsEmpty()) contributors.push_back(contributor); - else SAFE_DELETE(contributor); - } - - return status; -} - -// Write out the element to a COLLADA xml node tree -xmlNode* FCDAsset::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* assetNode = AddChild(parentNode, DAE_ASSET_ELEMENT); - - // Update the 'last modified time' - FCDAsset* hackedAsset = const_cast(this); - hackedAsset->modifiedDateTime = FUDateTime::GetNow(); - - // Write out the contributors first. - for (FCDAssetContributorList::const_iterator itC = contributors.begin(); itC != contributors.end(); ++itC) - { - (*itC)->WriteToXML(assetNode); - } - - // Write out the parameters, one by one and in the correct order. - AddChild(assetNode, DAE_CREATED_ASSET_PARAMETER, FUStringConversion::ToString(creationDateTime)); - if (!keywords.empty()) AddChild(assetNode, DAE_KEYWORDS_ASSET_PARAMETER, keywords); - AddChild(assetNode, DAE_MODIFIED_ASSET_PARAMETER, FUStringConversion::ToString(modifiedDateTime)); - if (!revision.empty()) AddChild(assetNode, DAE_REVISION_ASSET_PARAMETER, revision); - if (!subject.empty()) AddChild(assetNode, DAE_SUBJECT_ASSET_PARAMETER, subject); - if (!title.empty()) AddChild(assetNode, DAE_TITLE_ASSET_PARAMETER, title); - - // Finally: and - xmlNode* unitNode = AddChild(assetNode, DAE_UNITS_ASSET_PARAMETER); - AddAttribute(unitNode, DAE_METERS_ATTRIBUTE, unitConversionFactor); - AddAttribute(unitNode, DAE_NAME_ATTRIBUTE, unitName); - AddChild(assetNode, DAE_UPAXIS_ASSET_PARAMETER, FUStringConversion::ToString(subject)); - return assetNode; -} - -FCDAssetContributor::FCDAssetContributor(FCDocument* document) : FCDObject(document, "FCDAssetContributor") {} -FCDAssetContributor::~FCDAssetContributor() {} - -// Returns whether this contributor element contain any valid data -bool FCDAssetContributor::IsEmpty() const -{ - return author.empty() && authoringTool.empty() && comments.empty() && copyright.empty() && sourceData.empty(); -} - -// Read in the element from a COLLADA xml document -FUStatus FCDAssetContributor::LoadFromXML(xmlNode* contributorNode, bool isPreCollada1_4) -{ - FUStatus status; - for (xmlNode* child = contributorNode->children; child != NULL; child = child->next) - { - if (child->type != XML_ELEMENT_NODE) continue; - - const char* content = ReadNodeContentDirect(child); - if (IsEquivalent(child->name, DAE_AUTHOR_ASSET_PARAMETER)) - { - author = TO_FSTRING(content); - } - else if (IsEquivalent(child->name, DAE_AUTHORINGTOOL_ASSET_PARAMETER)) - { - authoringTool = TO_FSTRING(content); - } - else if (IsEquivalent(child->name, DAE_COMMENTS_ASSET_PARAMETER)) - { - comments = TO_FSTRING(content); - } - else if (IsEquivalent(child->name, DAE_COPYRIGHT_ASSET_PARAMETER)) - { - copyright = TO_FSTRING(content); - } - else if (IsEquivalent(child->name, DAE_SOURCEDATA_ASSET_PARAMETER)) - { - sourceData = TO_FSTRING(content); - } - else if (!isPreCollada1_4) - { - status.Warning(FS("Unknown child element: ") + TO_FSTRING((const char*) child->name), child->line); - } - } - return status; -} - -// Write out the element to a COLLADA xml node tree -xmlNode* FCDAssetContributor::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* contributorNode = NULL; - if (!IsEmpty()) - { - contributorNode = AddChild(parentNode, DAE_CONTRIBUTOR_ASSET_ELEMENT); - if (!author.empty()) AddChild(contributorNode, DAE_AUTHOR_ASSET_PARAMETER, author); - if (!authoringTool.empty()) AddChild(contributorNode, DAE_AUTHORINGTOOL_ASSET_PARAMETER, authoringTool); - if (!comments.empty()) AddChild(contributorNode, DAE_COMMENTS_ASSET_PARAMETER, comments); - if (!copyright.empty()) AddChild(contributorNode, DAE_COPYRIGHT_ASSET_PARAMETER, copyright); - if (!sourceData.empty()) AddChild(contributorNode, DAE_SOURCEDATA_ASSET_PARAMETER, sourceData); - } - return contributorNode; -} diff --git a/Extras/FCollada/FCDocument/FCDAsset.h b/Extras/FCollada/FCDocument/FCDAsset.h deleted file mode 100644 index 4d325a367..000000000 --- a/Extras/FCollada/FCDocument/FCDAsset.h +++ /dev/null @@ -1,109 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _FCD_ASSET_H_ -#define _FCD_ASSET_H_ - -#include "FCDocument/FCDObject.h" -#include "FUtils/FUDateTime.h" - -class FCDAssetContributor; - -typedef vector FCDAssetContributorList; - -class FCOLLADA_EXPORT FCDAsset : public FCDObject -{ - FCDAssetContributorList contributors; - FUDateTime creationDateTime; - FUDateTime modifiedDateTime; - fstring keywords; - fstring revision; - fstring subject; - fstring title; - FMVector3 upAxis; - - // - fstring unitName; - float unitConversionFactor; - -public: - FCDAsset(FCDocument* document); - virtual ~FCDAsset(); - - // Direct contributor list access - inline FCDAssetContributorList& GetContributors() { return contributors; } - inline const FCDAssetContributorList& GetContributors() const { return contributors; } - inline size_t GetContributorCount() const { return contributors.size(); } - inline FCDAssetContributor* GetContributor(size_t index) { return index < contributors.size() ? contributors[index] : NULL; } - inline const FCDAssetContributor* GetContributor(size_t index) const { return index < contributors.size() ? contributors[index] : NULL; } - FCDAssetContributor* AddContributor(); - - // Direct accessors - inline const FUDateTime& GetCreationDateTime() const { return creationDateTime; } - inline const FUDateTime& GetModifiedDateTime() const { return modifiedDateTime; } - inline const fstring& GetKeywords() const { return keywords; } - inline const fstring& GetRevision() const { return revision; } - inline const fstring& GetSubject() const { return subject; } - inline const fstring& GetTitle() const { return title; } - inline const FMVector3& GetUpAxis() const { return upAxis; } - inline const fstring& GetUnitName() const { return unitName; } - inline float GetUnitConversionFactor() const { return unitConversionFactor; } - - // Direct mutators - inline void SetKeywords(const fstring& _keywords) { keywords = _keywords; } - inline void SetRevision(const fstring& _revision) { revision = _revision; } - inline void SetSubject(const fstring& _subject) { subject = _subject; } - inline void SetTitle(const fstring& _title) { title = _title; } - inline void SetUpAxis(const FMVector3& _upAxis) { upAxis = _upAxis; } - inline void SetUnitName(const fstring& _unitName) { unitName = _unitName; } - inline void SetUnitConversionFactor(float factor) { unitConversionFactor = factor; } - - // Read in the element from a COLLADA xml document - FUStatus LoadFromXML(xmlNode* assetNode); - - // Write out the element to a COLLADA xml node tree - // Calling this function will update the 'last modified' timestamp. - xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -// Encapsulates the element -class FCOLLADA_EXPORT FCDAssetContributor : public FCDObject -{ -private: - fstring author; - fstring authoringTool; - fstring comments; - fstring copyright; - fstring sourceData; - -public: - FCDAssetContributor(FCDocument* document); - virtual ~FCDAssetContributor(); - - // Direct accessors - inline const fstring& GetAuthor() const { return author; } - inline const fstring& GetAuthoringTool() const { return authoringTool; } - inline const fstring& GetComments() const { return comments; } - inline const fstring& GetCopyright() const { return copyright; } - inline const fstring& GetSourceData() const { return sourceData; } - - // Direct mutators - inline void SetAuthor(const fstring& _author) { author = _author; } - inline void SetAuthoringTool(const fstring& _authoringTool) { authoringTool = _authoringTool; } - inline void SetComments(const fstring& _comments) { comments = _comments; } - inline void SetCopyright(const fstring& _copyright) { copyright = _copyright; } - inline void SetSourceData(const fstring& _sourceData) { sourceData = _sourceData; } - - // Returns whether this contributor element contain any valid data - bool IsEmpty() const; - - // Read in the element from a COLLADA xml document - FUStatus LoadFromXML(xmlNode* contributorNode, bool isPreCollada1_4=false); - - // Write out the element to a COLLADA xml node tree - xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -#endif // _FCD_ASSET_H_ diff --git a/Extras/FCollada/FCDocument/FCDCamera.cpp b/Extras/FCollada/FCDocument/FCDCamera.cpp deleted file mode 100644 index 80b658b62..000000000 --- a/Extras/FCollada/FCDocument/FCDCamera.cpp +++ /dev/null @@ -1,268 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDCamera.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDAnimated.h" -#include "FCDocument/FCDSceneNode.h" -#include "FUtils/FUStringConversion.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDCamera::FCDCamera(FCDocument* document) : FCDTargetedEntity(document, "Camera") -{ - isPerspective = true; - isOrthographic = false; - viewY = viewX = 60.0f; - hasAperture = hasHorizontalView = hasVerticalView = false; - nearZ = 1.0f; - farZ = 1000.0f; - aspectRatio = 1.0f; - horizontalAperture = verticalAperture = lensSqueeze = 1.0f; -} - -FCDCamera::~FCDCamera() -{ -} - -void FCDCamera::SetFovX(float _viewX) -{ - viewX = _viewX; - if (hasVerticalView && !IsEquivalent(viewX, 0.0f)) aspectRatio = viewY / viewX; - hasHorizontalView = true; -} - -void FCDCamera::SetFovY(float _viewY) -{ - viewY = _viewY; - if (hasHorizontalView && !IsEquivalent(viewX, 0.0f)) aspectRatio = viewY / viewX; - hasVerticalView = true; -} - -void FCDCamera::SetAspectRatio(float _aspectRatio) -{ - aspectRatio = _aspectRatio; -} - -// Load this camera from the given COLLADA document's node -FUStatus FCDCamera::LoadFromXML(xmlNode* cameraNode) -{ - FUStatus status = FCDEntity::LoadFromXML(cameraNode); - if (!status) return status; - if (!IsEquivalent(cameraNode->name, DAE_CAMERA_ELEMENT)) - { - return status.Warning(FS("Camera library contains unknown element."), cameraNode->line); - } - - // COLLADA 1.3: Grab the techniques and their children - xmlNode* commonTechniqueNode1_3 = FindTechnique(cameraNode, DAE_COMMON_PROFILE); - xmlNode* commonOpticsNode1_3 = FindChildByType(commonTechniqueNode1_3, DAE_OPTICS_ELEMENT); - xmlNode* commonProgramNode1_3 = FindChildByType(commonOpticsNode1_3, DAE_PROGRAM_ELEMENT); - xmlNode* maxTechniqueNode1_3 = FindTechnique(cameraNode, DAEMAX_MAX_PROFILE); - xmlNode* maxOpticsNode1_3 = FindChildByType(maxTechniqueNode1_3, DAE_OPTICS_ELEMENT); - xmlNode* maxProgramNode1_3 = FindChildByType(maxOpticsNode1_3, DAE_PROGRAM_ELEMENT); - xmlNode* mayaTechniqueNode = FindTechnique(cameraNode, DAEMAYA_MAYA_PROFILE); - xmlNode* mayaOpticsNode = FindChildByType(mayaTechniqueNode, DAE_OPTICS_ELEMENT); - xmlNode* mayaProgramNode = FindChildByType(mayaOpticsNode, DAE_PROGRAM_ELEMENT); - bool isCollada1_3 = commonTechniqueNode1_3 != NULL; - - // COLLADA 1.4: Grab the element's techniques - xmlNode* opticsNode = FindChildByType(cameraNode, DAE_OPTICS_ELEMENT); - xmlNode* commonTechniqueNode = FindChildByType(opticsNode, DAE_TECHNIQUE_COMMON_ELEMENT); - xmlNode* maxTechniqueNode = FindTechnique(opticsNode, DAEMAX_MAX_PROFILE); - xmlNode* cameraContainerNode = (isCollada1_3) ? ((maxProgramNode1_3 != NULL) ? maxProgramNode1_3 : commonProgramNode1_3) : NULL; - if (mayaProgramNode == NULL) mayaProgramNode = FindTechnique(opticsNode, DAEMAYA_MAYA_PROFILE); - - // Figure out the camera type - if (isCollada1_3) - { - FUUri programType = ReadNodeUrl(maxProgramNode1_3); - if (programType.prefix.empty()) programType = ReadNodeUrl(commonProgramNode1_3); - if (programType.prefix.empty()) - { - return status.Fail(FS("No standard program type for camera: ") + TO_FSTRING(GetDaeId()), cameraNode->line); - } - string cameraType = TO_STRING(programType.prefix); - isOrthographic = cameraType == DAE_ORTHOGRAPHIC_CAMERA_TYPE; - isPerspective = cameraType == DAE_PERSPECTIVE_CAMERA_TYPE; - } - else - { - // Retrieve the or element - cameraContainerNode = FindChildByType(commonTechniqueNode, DAE_CAMERA_ORTHO_ELEMENT); - isOrthographic = cameraContainerNode != NULL; - if (!isOrthographic) - { - cameraContainerNode = FindChildByType(commonTechniqueNode, DAE_CAMERA_PERSP_ELEMENT); - isPerspective = cameraContainerNode != NULL; - } - else - { - isPerspective = false; - } - } - - // Check the necessary camera structures - if (cameraContainerNode == NULL) - { - return status.Fail(FS("Cannot find parameter root node for camera: ") + TO_FSTRING(GetDaeId()), cameraNode->line); - } - if (!(isPerspective ^ isOrthographic)) - { - return status.Fail(FS("Unknown program type for camera: ") + TO_FSTRING(GetDaeId()), cameraContainerNode->line); - } - - // Setup the camera according to the type and its parameters - // Retrieve all the camera parameters - StringList parameterNames; - xmlNodeList parameterNodes; - FindParameters(cameraContainerNode, parameterNames, parameterNodes); - FindParameters(maxTechniqueNode, parameterNames, parameterNodes); - FindParameters(mayaProgramNode, parameterNames, parameterNodes); - - #define CAM_PARAMETER(colladaParam, memberFunction, animatedMember) \ - if (parameterName == colladaParam) { \ - memberFunction(FUStringConversion::ToFloat(parameterValue)); \ - FCDAnimatedFloat::Create(GetDocument(), parameterNode, &animatedMember); } else - - size_t parameterCount = parameterNodes.size(); - for (size_t i = 0; i < parameterCount; ++i) - { - xmlNode* parameterNode = parameterNodes[i]; - const string& parameterName = parameterNames[i]; - const char* parameterValue = ReadNodeContentDirect(parameterNode); - - // Process the camera parameters - CAM_PARAMETER(DAE_ZNEAR_CAMERA_PARAMETER, SetNearZ, nearZ) - CAM_PARAMETER(DAE_ZFAR_CAMERA_PARAMETER, SetFarZ, farZ) - CAM_PARAMETER(DAE_XFOV_CAMERA_PARAMETER, SetFovX, viewX) - CAM_PARAMETER(DAE_YFOV_CAMERA_PARAMETER, SetFovY, viewY) - CAM_PARAMETER(DAE_XMAG_CAMERA_PARAMETER, SetMagX, viewX) - CAM_PARAMETER(DAE_YMAG_CAMERA_PARAMETER, SetMagY, viewY) - CAM_PARAMETER(DAE_ASPECT_CAMERA_PARAMETER, SetAspectRatio, aspectRatio) - CAM_PARAMETER(DAEMAYA_VAPERTURE_PARAMETER, SetVerticalAperture, verticalAperture) - CAM_PARAMETER(DAEMAYA_HAPERTURE_PARAMETER, SetHorizontalAperture, horizontalAperture) - CAM_PARAMETER(DAEMAYA_LENSSQUEEZE_PARAMETER, SetLensSqueeze, lensSqueeze) - if (parameterName == DAEMAX_TARGET_CAMERA_PARAMETER) - SetTargetId(parameterValue); - else - - // COLLADA 1.3 backward compatibility - CAM_PARAMETER(DAE_ZNEAR_CAMERA_PARAMETER1_3, SetNearZ, nearZ) - CAM_PARAMETER(DAE_ZFAR_CAMERA_PARAMETER1_3, SetFarZ, farZ) - CAM_PARAMETER(DAE_XFOV_CAMERA_PARAMETER1_3, SetFovX, viewX) - CAM_PARAMETER(DAE_YFOV_CAMERA_PARAMETER1_3, SetFovY, viewY) - CAM_PARAMETER(DAE_RIGHT_CAMERA_PARAMETER1_3, SetMagX, viewX) - CAM_PARAMETER(DAE_TOP_CAMERA_PARAMETER1_3, SetMagY, viewY) - CAM_PARAMETER(DAEMAYA_VAPERTURE_PARAMETER1_3, SetVerticalAperture, verticalAperture) - CAM_PARAMETER(DAEMAYA_HAPERTURE_PARAMETER1_3, SetHorizontalAperture, horizontalAperture) - CAM_PARAMETER(DAEMAYA_LENSSQUEEZE_PARAMETER1_3, SetLensSqueeze, lensSqueeze) - if (parameterName == DAE_LEFT_CAMERA_PARAMETER1_3) {} // Don't process - else if (parameterName == DAE_BOTTOM_CAMERA_PARAMETER1_3) {} // Don't process - - // Max-specific parameter: target - else if (parameterName == DAEMAX_TARGET_CAMERA_PARAMETER - || parameterName == DAEMAX_TARGET_CAMERA_PARAMETER1_3) - { - SetTargetId(parameterValue); - } - else - { - status.Warning(FS("Unknown parameter for camera: ") + TO_FSTRING(GetDaeId()), parameterNode->line); - } - } - - return status; -} - -// Write out this camera to the COLLADA XML document -xmlNode* FCDCamera::WriteToXML(xmlNode* parentNode) const -{ - // Create the base camera node - xmlNode* cameraNode = WriteToEntityXML(parentNode, DAE_CAMERA_ELEMENT); - xmlNode* opticsNode = AddChild(cameraNode, DAE_OPTICS_ELEMENT); - xmlNode* baseNode = AddChild(opticsNode, DAE_TECHNIQUE_COMMON_ELEMENT); - const char* baseNodeName; - if (isPerspective) baseNodeName = DAE_CAMERA_PERSP_ELEMENT; - else if (isOrthographic) baseNodeName = DAE_CAMERA_ORTHO_ELEMENT; - else baseNodeName = DAEERR_UNKNOWN_ELEMENT; - baseNode = AddChild(baseNode, baseNodeName); - - // Write out the basic camera parameters - if (isPerspective) - { - if (hasHorizontalView) - { - xmlNode* viewNode = AddChild(baseNode, DAE_XFOV_CAMERA_PARAMETER, viewX); - GetDocument()->WriteAnimatedValueToXML(&viewX, viewNode, "horizontal_fov"); - } - if (!hasHorizontalView || hasVerticalView) - { - xmlNode* viewNode = AddChild(baseNode, DAE_YFOV_CAMERA_PARAMETER, viewY); - GetDocument()->WriteAnimatedValueToXML(&viewY, viewNode, "vertical_fov"); - } - if (!hasHorizontalView || !hasVerticalView) - { - xmlNode* aspectNode = AddChild(baseNode, DAE_ASPECT_CAMERA_PARAMETER, aspectRatio); - GetDocument()->WriteAnimatedValueToXML(&aspectRatio, aspectNode, "aspect_ratio"); - } - } - if (isOrthographic) - { - if (hasHorizontalView) - { - xmlNode* viewNode = AddChild(baseNode, DAE_XMAG_CAMERA_PARAMETER, viewX); - GetDocument()->WriteAnimatedValueToXML(&viewX, viewNode, "horizontal_zoom"); - } - if (!hasHorizontalView || hasVerticalView) - { - xmlNode* viewNode = AddChild(baseNode, DAE_YMAG_CAMERA_PARAMETER, viewY); - GetDocument()->WriteAnimatedValueToXML(&viewY, viewNode, "vertical_zoom"); - } - if (!hasHorizontalView || !hasVerticalView) - { - xmlNode* aspectNode = AddChild(baseNode, DAE_ASPECT_CAMERA_PARAMETER, aspectRatio); - GetDocument()->WriteAnimatedValueToXML(&aspectRatio, aspectNode, "aspect_ratio"); - } - } - - // Near/Far clip plane distance - xmlNode* clipNode = AddChild(baseNode, DAE_ZNEAR_CAMERA_PARAMETER, nearZ); - GetDocument()->WriteAnimatedValueToXML(&nearZ, clipNode, "near_clip"); - clipNode = AddChild(baseNode, DAE_ZFAR_CAMERA_PARAMETER, farZ); - GetDocument()->WriteAnimatedValueToXML(&farZ, clipNode, "near_clip"); - - // Add the application-specific technique/parameters - // Maya has extra aperture information - if (hasAperture) - { - xmlNode* techniqueMayaNode = AddTechniqueChild(opticsNode, DAEMAYA_MAYA_PROFILE); - xmlNode* apertureNode = AddChild(techniqueMayaNode, DAEMAYA_VAPERTURE_PARAMETER, verticalAperture); - GetDocument()->WriteAnimatedValueToXML(&verticalAperture, apertureNode, "vertical_aperture"); - apertureNode = AddChild(techniqueMayaNode, DAEMAYA_HAPERTURE_PARAMETER, horizontalAperture); - GetDocument()->WriteAnimatedValueToXML(&horizontalAperture, apertureNode, "horizontal_aperture"); - apertureNode = AddChild(techniqueMayaNode, DAEMAYA_LENSSQUEEZE_PARAMETER, lensSqueeze); - GetDocument()->WriteAnimatedValueToXML(&lensSqueeze, apertureNode, "lens_squeeze"); - } - - // Max has target information - if (GetTargetNode() != NULL) - { - xmlNode* techniqueMaxNode = AddTechniqueChild(opticsNode, DAEMAX_MAX_PROFILE); - AddChild(techniqueMaxNode, DAEMAX_TARGET_CAMERA_PARAMETER, GetTargetNode()->GetDaeId()); - } - - FCDEntity::WriteToExtraXML(cameraNode); - return cameraNode; -} diff --git a/Extras/FCollada/FCDocument/FCDCamera.h b/Extras/FCollada/FCDocument/FCDCamera.h deleted file mode 100644 index f0191648e..000000000 --- a/Extras/FCollada/FCDocument/FCDCamera.h +++ /dev/null @@ -1,255 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDCamera.h - This file contains the FCDCamera class. -*/ - -#ifndef _FCD_CAMERA_H_ -#define _FCD_CAMERA_H_ - -#include "FCDocument/FCDTargetedEntity.h" - -class FCDocument; -class FCDSceneNode; - -/** - A COLLADA camera. - Based on the FCDTargetedEntity class to support aimed cameras. - COLLADA defines two types of cameras: perspective and orthographic. - Both types are fully handled by this class. - - A COLLADA perspective camera defines two of the three following parameters: horizontal field of view, - vertical field of view and aspect ratio. The missing parameter can be calculated using the following formulae: - aspect ratio = vertical field of view / horizontal field of view. The vertical and horizontal field - of view are in degrees. - - A COLLADA orthographic camera defines two of the three following parameters: horizontal magnification, - vertical magnification and aspect ratio. The missing parameter can be calculated using the following formulae: - aspect ratio = vertical magnification / horizontal magnification. You can calculate the viewport width - and height using the following formulas: viewport width = horizontal magnification * 2, viewport height - = vertical magnification * 2. - - @ingroup FCDocument -*/ -class FCOLLADA_EXPORT FCDCamera : public FCDTargetedEntity -{ -private: - // Camera flags - bool isPerspective; - bool isOrthographic; - bool hasHorizontalView; - bool hasVerticalView; - - // Camera parameters - float viewY; - float viewX; - float nearZ; - float farZ; - float aspectRatio; - - // Maya parameters - bool hasAperture; - float verticalAperture; - float horizontalAperture; - float lensSqueeze; - -public: - /** Constructor: do not use directly. Create new cameras using the FCDLibrary::AddEntity function. - @param document The COLLADA document that contains this camera entity.*/ - FCDCamera(FCDocument* document); - - /** Destructor: do not release directly. Release cameras using the FCDLibrary::ReleaseEntity function. - All cameras are released with the document that they belong to. */ - virtual ~FCDCamera(); - - /** Retrieves the entity type for this class. This function is part of the FCDEntity interface. - @return The entity type: CAMERA. */ - virtual Type GetType() const { return CAMERA; } - - /** Retrieves whether this camera is a perspective camera. - This is the default type of camera. - @return Whether this camera is a perspective camera.*/ - inline bool IsPerspective() const { return isPerspective; } - - /** Sets the type of this camera to perspective. */ - inline void SetPerspective() { isPerspective = true; isOrthographic = false; } - - /** Retrieves whether the perspective camera defines an horizontal field of view. - If the camera does not define the horizontal field of view, you can calculate - it using the following formula: horizontal field of view = vertical field of view / aspect ratio. - @return Whether the perspective camera defines an horizontal field of view. */ - inline bool HasHorizontalFov() const { return hasHorizontalView; } - - /** Retrieves whether the perspective camera defines a vertical field of view. - If the camera does not define the vertical field of view, you can calculate - it using the following formula: vertical field of view = aspect ratio * horizontal field of view. - @return Whether the perspective camera defines a vertical field of view. */ - inline bool HasVerticalFov() const { return hasVerticalView; } - - /** Retrieves the horizontal field of view. Before retrieving this value, - check whether the camera defines the horizontal field of view using the - HasHorizontalFov function. - @return The horizontal field of view, in degrees. */ - inline float& GetFovX() { return viewX; } - inline const float& GetFovX() const { return viewX; } /**< See above. */ - - /** Retrieves the vertical field of view. Before retrieving this value, - check whether the camera defines the vertical field of view using the - HasVerticalFov function. - @return The horizontal field of view, in degrees. */ - inline float& GetFovY() { return viewY; } - inline const float& GetFovY() const { return viewY; } /**< See above. */ - - /** Sets the horizontal field of view value for this camera. - @param fovX The new horizontal field of view, in degrees. */ - void SetFovX(float fovX); - - /** Sets the vertical field of view value for this camera. - @param fovY The new vertical field of view, in degrees. */ - void SetFovY(float fovY); - - /** Retrieves whether this camera is an orthographic camera. - @return Whether this camera is an orthographic camera. */ - inline bool IsOrthographic() const { return isOrthographic; } - - /** Sets the type of this camera to orthographic. */ - inline void SetOrthographic() { isPerspective = false; isOrthographic = true; } - - /** Retrieves whether the orthographic camera defines an horizontal magnification. - If the camera does not define the horizontal magnification, you can calculate - it using the following formula: horizontal magnification = vertical magnification / aspect ratio. - @return Whether the orthographic camera defines an horizontal magnification. */ - inline bool HasHorizontalMag() const { return hasHorizontalView; } - - /** Retrieves whether the perspective camera defines a vertical magnification. - If the camera does not define the vertical magnification, you can calculate - it using the following formula: vertical magnification = aspect ratio * horizontal magnification. - @return Whether the perspective camera defines a vertical magnification. */ - inline bool HasVerticalMag() const { return hasVerticalView; } - - /** Retrieves the horizontal magnification. Before retrieving this value, - check whether the camera defines the horizontal magnification using the - HasHorizontalMag function. - @return The horizontal magnification. */ - inline float& GetMagX() { return viewX; } - inline const float& GetMagX() const { return viewX; } /**< See above. */ - - /** Retrieves the vertical magnification. Before retrieving this value, - check whether the camera defines the vertical magnification using the - HasVerticalMag function. - @return The vertical magnification. */ - inline float& GetMagY() { return viewY; } - inline const float& GetMagY() const { return viewY; } /**< See above. */ - - /** Sets the horizontal magnification for this camera. - @param magX The new horizontal magnification, in degrees. */ - inline void SetMagX(float magX) { return SetFovX(magX); } - - /** Sets the vertical magnification value for this camera. - @param magY The new vertical magnification, in degrees. */ - inline void SetMagY(float magY) { return SetFovY(magY); } - - /** Retrieves the near-z value for this camera. - The near-z value represent how close the near-clip - plane of the view frustrum is. For orthographic cameras, - this value is solely used for depth-buffering. - @return The near-z value for this camera. */ - inline float& GetNearZ() { return nearZ; } - inline const float& GetNearZ() const { return nearZ; } /**< See above. */ - - /** Retrieves the far-z value for this camera. The far-z value represent - how close the far-clip plane of the view frustrum is. - For orthographic cameras, this value is solely used for depth-buffering. - @return The far-z value for this camera. */ - inline float& GetFarZ() { return farZ; } - inline const float& GetFarZ() const { return farZ; } /**< See above. */ - - /** Retrieves the aspect ratio for the view of this camera. Before using this value, - check if there are only one of the horizontal and vertical view ratios. - If there are both of the view ratios provided for the camera, you will - need to calculate the aspect ratio using the following formula: - aspect ratio = vertical field of view / horizontal field of view. - @return The view aspect ratio. */ - inline float& GetAspectRatio() { return aspectRatio; } - inline const float& GetAspectRatio() const { return aspectRatio; } /**< See above. */ - - /** Sets the near-z value for this camera. - The near-z value represent how close the near-clip - plane of the view frustrum is. For orthographic cameras, - this value is solely used for depth-buffering. - @param _nearZ A valid near-z value. No check is made to verify that the - near-z value is greather than the far-z value.*/ - inline void SetNearZ(float _nearZ) { nearZ = _nearZ; } - - /** Sets the far-z value for this camera. The far-z value represent - how close the far-clip plane of the view frustrum is. - For orthographic cameras, this value is solely used for depth-buffering. - @param _farZ A valid far-z value. No check is made to verify that the - far-z value is greather than the near-z value.*/ - inline void SetFarZ(float _farZ) { farZ = _farZ; } - - /** Sets the aspect ratio for the view of this camera. - @param aspectRatio The new view aspect ratio. */ - void SetAspectRatio(float aspectRatio); - - /** Retrieves whether the camera provides aperture information. This information is specific - to COLLADA documents exported from ColladaMaya. - @return Whether the camera provides aperture information. */ - inline bool HasAperture() const { return hasAperture; } - - /** Retrieves the vertical aperture of the camera. This information is specific to - COLLADA documents exported from ColladaMaya. - @return The vertical aperture of the camera. */ - inline float& GetVerticalAperture() { return verticalAperture; } - inline const float& GetVerticalAperture() const { return verticalAperture; } /**< See above. */ - - /** Retrieves the horizontal aperture of the camera. This information is specific to - COLLADA documents exported from ColladaMaya. - @return The horizontal aperture of the camera. */ - inline float& GetHorizontalAperture() { return horizontalAperture; } - inline const float& GetHorizontalAperture() const { return horizontalAperture; } /**< See above. */ - - /** Retrieves the lens squeeze of the camera. This information is specific to - COLLADA documents exported from ColladaMaya. The lens squeeze of the camera - is a multiplier that acts directly on the horizontal aperture, following this - formula: real horizontal aperture = given horizontal aperture * lens squeeze. - @return The lens squeeze of the camera. */ - inline float& GetLensSqueeze() { return lensSqueeze; } - inline const float& GetLensSqueeze() const { return lensSqueeze; } /**< See above. */ - - /** Sets the vertical aperture of the camera. - @param aperture The vertical aperture of the camera. */ - inline void SetVerticalAperture(float aperture) { verticalAperture = aperture; hasAperture = true; } - - /** Sets the horizontal aperture of the camera. - @param aperture The horizontal aperture of the camera. */ - inline void SetHorizontalAperture(float aperture) { horizontalAperture = aperture; hasAperture = true; } - - /** Sets the lens squeeze of the camera. - @param factor The lense squeeze of the camera. */ - inline void SetLensSqueeze(float factor) { lensSqueeze = factor; } - - /** [INTERNAL] Reads in the \ element from a given COLLADA XML tree node. - @param cameraNode A COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the camera.*/ - FUStatus LoadFromXML(xmlNode* cameraNode); - - /** [INTERNAL] Writes out the \ element to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the geometry information. - @return The created XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -#endif // _FCD_CAMERA_H_ - diff --git a/Extras/FCollada/FCDocument/FCDController.cpp b/Extras/FCollada/FCDocument/FCDController.cpp deleted file mode 100644 index 0ddc47b45..000000000 --- a/Extras/FCollada/FCDocument/FCDController.cpp +++ /dev/null @@ -1,123 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDController.h" -#include "FCDocument/FCDSkinController.h" -#include "FCDocument/FCDMorphController.h" -#include "FUtils/FUDaeParser.h" -using namespace FUDaeParser; - -FCDController::FCDController(FCDocument* document) : FCDEntity(document, "Controller") -{ - skinController = NULL; - morphController = NULL; -} - -FCDController::~FCDController() -{ - SAFE_DELETE(skinController); - SAFE_DELETE(morphController); -} - - -// Sets the type of this controller to a skin controller. -FCDSkinController* FCDController::CreateSkinController() -{ - SAFE_DELETE(skinController); - SAFE_DELETE(morphController); - skinController = new FCDSkinController(GetDocument(), this); - return skinController; -} - -// Sets the type of this controller to a morph controller. -FCDMorphController* FCDController::CreateMorphController() -{ - SAFE_DELETE(skinController); - SAFE_DELETE(morphController); - morphController = new FCDMorphController(GetDocument(), this); - return morphController; -} - -FCDEntity* FCDController::GetBaseTarget() -{ - if (skinController != NULL) return skinController->GetTarget(); - else if (morphController != NULL) return morphController->GetBaseTarget(); - else return NULL; -} - -const FCDEntity* FCDController::GetBaseTarget() const -{ - if (skinController != NULL) return skinController->GetTarget(); - else if (morphController != NULL) return morphController->GetBaseTarget(); - else return NULL; -} - -// Load this controller from a Collada node -FUStatus FCDController::LoadFromXML(xmlNode* controllerNode) -{ - FUStatus status = FCDEntity::LoadFromXML(controllerNode); - if (!status) return status; - if (!IsEquivalent(controllerNode->name, DAE_CONTROLLER_ELEMENT)) - { - return status.Warning(FS("Unexpected node in controller library: <") + TO_FSTRING((const char*) controllerNode->name) + FC(">."), controllerNode->line); - } - - // COLLADA 1.3 backward compatiblity: read in the 'target' attribute - targetId = ReadNodeProperty(controllerNode, DAE_TARGET_ATTRIBUTE); - - // Find the or element and process it - xmlNode* skinNode = FindChildByType(controllerNode, DAE_CONTROLLER_SKIN_ELEMENT); - xmlNode* morphNode = FindChildByType(controllerNode, DAE_CONTROLLER_MORPH_ELEMENT); - if (skinNode != NULL && morphNode != NULL) - { - status.Warning(FS("A controller cannot be both a skin and a morpher: ") + TO_FSTRING(GetDaeId()), controllerNode->line); - } - if (skinNode != NULL) - { - // Create and parse in the skin controller - FCDSkinController* controller = CreateSkinController(); - status.AppendStatus(controller->LoadFromXML(skinNode)); - } - else if (morphNode != NULL) - { - // Create and parse in the morph controller - FCDMorphController* controller = CreateMorphController(); - status.AppendStatus(controller->LoadFromXML(morphNode)); - } - else - { - status.Warning(FS("No base type element, or , found for controller: ") + TO_FSTRING(GetDaeId()), controllerNode->line); - } - return status; -} - -// Write out this controller to a COLLADA xml node tree -xmlNode* FCDController::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* controllerNode = FCDEntity::WriteToEntityXML(parentNode, DAE_CONTROLLER_ELEMENT); - if (skinController != NULL) skinController->WriteToXML(controllerNode); - if (morphController != NULL) morphController->WriteToXML(controllerNode); - FCDEntity::WriteToExtraXML(controllerNode); - return controllerNode; -} - -// Link this controller to the rest of the document: joints/base geometry... -FUStatus FCDController::Link() -{ - FUStatus status; - - // Link the controller - if (skinController != NULL) status.AppendStatus(skinController->Link()); - if (morphController != NULL) status.AppendStatus(morphController->Link()); - return status; -} diff --git a/Extras/FCollada/FCDocument/FCDController.h b/Extras/FCollada/FCDocument/FCDController.h deleted file mode 100644 index 4925b6607..000000000 --- a/Extras/FCollada/FCDocument/FCDController.h +++ /dev/null @@ -1,124 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDController.h - This file contains the FCDController class. -*/ - -#ifndef _FCD_CONTROLLER_H_ -#define _FCD_CONTROLLER_H_ - -#include "FCDocument/FCDEntity.h" - -class FCDocument; -class FCDSkinController; -class FCDMorphController; - -/** - A generic COLLADA controller. - A COLLADA controller is used to influence a mesh. - COLLADA defines two types of controller: - skins (FCDSkinController) and morphers (FCDMorphController). - - @ingroup FCDGeometry -*/ -class FCOLLADA_EXPORT FCDController : public FCDEntity -{ -private: - string targetId; // COLLADA 1.3 backward compatibility - - FCDSkinController* skinController; - FCDMorphController* morphController; - -public: - /** Constructor: do not use directly. - Instead, use the FCDLibrary::AddEntity function. - @param document The COLLADA document that owns the controller. */ - FCDController(FCDocument* document); - - /** Destructor: do not use directly. - Instead, use the FCDLibrary::ReleaseEntity function. */ - virtual ~FCDController(); - - /** Retrieves the entity class type. - This function is a part of the FCDEntity interface. - @return The entity class type: CONTROLLER. */ - virtual Type GetType() const { return CONTROLLER; }; - - /** Retrieves whether this controller is a skin controller. - @return Whether this controller is a skin controller. */ - bool HasSkinController() const { return skinController != NULL; } - - /** Retrieves whether this controller is a morph controller. - @return Whether this controller is a morph controller. */ - bool HasMorphController() const { return morphController != NULL; } - - /** Sets the type of this controller to a skin controller. - This function will release any previously created morpher or skin. - @return The new skin controller. */ - FCDSkinController* CreateSkinController(); - - /** Sets the type of this controller to a morph controller. - This function will release any previously created morpher or skin. - @return The new morph controller. */ - FCDMorphController* CreateMorphController(); - - /** Retrieves the skin controller. - This pointer is only valid for skins. To verify that this is a skin, - check the HasSkinController function. - @return The skin controller. This pointer will be NULL, if the controller - is not a skin. */ - FCDSkinController* GetSkinController() { return skinController; } - const FCDSkinController* GetSkinController() const { return skinController; } /**< See above. */ - - /** Retrieves the morph controller. - This pointer is only valid for skins. To verify that this is a morpher, - check the HasMorphController function. - @return The morph controller. This pointer will be NULL, if the controller - is not a morpher. */ - FCDMorphController* GetMorphController() { return morphController; } - const FCDMorphController* GetMorphController() const { return morphController; } /**< See above. */ - - /** Retrieves the base target entity for this controller. - The base target entity may be another controller or a geometry entity. - To change the base target, use the FCDMorphController::SetBaseTarget - or the FCDSkinController::SetTarget functions. - @return The base target entity. This pointer will be NULL, if no base target is defined. */ - FCDEntity* GetBaseTarget(); - const FCDEntity* GetBaseTarget() const; /**< See above. */ - - /** [INTERNAL] Retrieves the COLLADA id of the target entity. - This value is only useful for COLLADA 1.3 backward compatibility. - For more recent COLLADA documents, this value is unused. - @return The COLLADA id of the target entity. */ - const string& GetTargetId() const { return targetId; } - - /** [INTERNAL] Reads in the \ element from a given COLLADA XML tree node. - @param controllerNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the controller.*/ - virtual FUStatus LoadFromXML(xmlNode* controllerNode); - - /** [INTERNAL] Writes out the \ element to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the controller information. - @return The created element XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; - - /** [INTERNAL] Links the controller entities with their many targets/influences. - This function is executed for all the controllers, after the scene graph has been imported. - It is mainly used to link the skin and its bones. - @return The status of the linkage.*/ - FUStatus Link(); -}; - -#endif // _FCD_CONTROLLER_H_ - diff --git a/Extras/FCollada/FCDocument/FCDEffect.cpp b/Extras/FCollada/FCDocument/FCDEffect.cpp deleted file mode 100644 index f4f51ccb9..000000000 --- a/Extras/FCollada/FCDocument/FCDEffect.cpp +++ /dev/null @@ -1,268 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDAnimated.h" -#include "FCDocument/FCDEffect.h" -#include "FCDocument/FCDEffectStandard.h" -#include "FCDocument/FCDEffectProfileFX.h" -#include "FCDocument/FCDEffectParameter.h" -#include "FCDocument/FCDEffectParameterFactory.h" -#include "FCDocument/FCDEffectParameterList.h" -#include "FCDocument/FCDLibrary.h" -#include "FCDocument/FCDImage.h" -#include "FUtils/FUStringConversion.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDEffect::FCDEffect(FCDocument* document) : FCDEntity(document, "Effect") -{ - parameters = new FCDEffectParameterList(GetDocument(), true); -} - -FCDEffect::~FCDEffect() -{ - SAFE_DELETE(parameters); - CLEAR_POINTER_VECTOR(profiles); -} - -void FCDEffect::AddParameter(FCDEffectParameter* parameter) -{ - parameters->push_back(parameter); -} - -// Flatten this effect: trickling down all the parameters to the technique level -void FCDEffect::Flatten() -{ - for (FCDEffectParameterList::iterator itP = parameters->begin(); itP != parameters->end(); ++itP) - { - FCDEffectParameterList generators; - if ((*itP)->IsModifier()) - { - // Overwrite the generators - FindParametersByReference((*itP)->GetReference(), generators); - for (FCDEffectParameterList::iterator itQ = generators.begin(); itQ != generators.end(); ++itQ) - { - if ((*itP) != (*itQ)) - { - (*itP)->Overwrite(*itQ); - } - } - } - else - { - // Add this parameter to hierarchies below - for (FCDEffectProfileList::iterator itR = profiles.begin(); itR != profiles.end(); ++itR) - { - if ((*itR)->GetType() != FUDaeProfileType::COMMON) - { - ((FCDEffectProfileFX*) (*itR))->AddParameter((*itP)->Clone()); - } - } - } - } - CLEAR_POINTER_VECTOR(*parameters); - - for (FCDEffectProfileList::iterator itR = profiles.begin(); itR != profiles.end(); ++itR) - { - (*itR)->Flatten(); - } -} - -// Search for a profile of the given type -FCDEffectProfile* FCDEffect::FindProfile(FUDaeProfileType::Type type) -{ - for (FCDEffectProfileList::iterator itR = profiles.begin(); itR != profiles.end(); ++itR) - { - if ((*itR)->GetType() == type) return (*itR); - } - return NULL; -} - -const FCDEffectProfile* FCDEffect::FindProfile(FUDaeProfileType::Type type) const -{ - for (FCDEffectProfileList::const_iterator itR = profiles.begin(); itR != profiles.end(); ++itR) - { - if ((*itR)->GetType() == type) return (*itR); - } - return NULL; -} - -// Create a new effect profile. -FCDEffectProfile* FCDEffect::AddProfile(FUDaeProfileType::Type type) -{ - // Delete any old profile of the same type - FCDEffectProfile* profile = FindProfile(type); - if (profile != NULL) - { - ReleaseProfile(profile); - profile = NULL; - } - - // Create the correct profile for this type. - if (type == FUDaeProfileType::COMMON) profile = new FCDEffectStandard(GetDocument(), this); - else profile = new FCDEffectProfileFX(GetDocument(), this, type); - - profiles.push_back(profile); - return profile; -} - -// Releases the effect profile. -void FCDEffect::ReleaseProfile(FCDEffectProfile* profile) -{ - FCDEffectProfileList::iterator itR = std::find(profiles.begin(), profiles.end(), profile); - if (itR != profiles.end()) - { - delete *itR; - profiles.erase(itR); - } -} - -// Look for the effect parameter with the correct semantic, in order to bind/set its value -FCDEffectParameter* FCDEffect::FindParameterBySemantic(const string& semantic) -{ - FCDEffectParameter* p = parameters->FindSemantic(semantic); - for (FCDEffectProfileList::iterator itR = profiles.begin(); itR != profiles.end() && p == NULL; ++itR) - { - p = (*itR)->FindParameterBySemantic(semantic); - } - return p; -} - -void FCDEffect::FindParametersBySemantic(const string& semantic, FCDEffectParameterList& _parameters) -{ - parameters->FindSemantic(semantic, _parameters); - for (FCDEffectProfileList::iterator itR = profiles.begin(); itR != profiles.end(); ++itR) - { - (*itR)->FindParametersBySemantic(semantic, _parameters); - } -} - -void FCDEffect::FindParametersByReference(const string& reference, FCDEffectParameterList& _parameters) -{ - parameters->FindReference(reference, _parameters); - for (FCDEffectProfileList::iterator itR = profiles.begin(); itR != profiles.end(); ++itR) - { - (*itR)->FindParametersBySemantic(reference, _parameters); - } -} - -// Parse COLLADA document's element -// Also parses the element for COLLADA 1.3 backward compatibility -FUStatus FCDEffect::LoadFromXML(xmlNode* effectNode) -{ - FUStatus status = FCDEntity::LoadFromXML(effectNode); - if (!status) return status; - - CLEAR_POINTER_VECTOR(*parameters); - - // COLLADA 1.3 backward compatibility: look for a node and parse this into a standard effect. - if (IsEquivalent(effectNode->name, DAE_MATERIAL_ELEMENT)) - { - xmlNode* shaderNode = FindChildByType(effectNode, DAE_SHADER_ELEMENT); - if (shaderNode != NULL) - { - FCDEffectProfile* profile = AddProfile(FUDaeProfileType::COMMON); - status.AppendStatus(profile->LoadFromXML(shaderNode)); - } - } - else - { - // Accept solely elements at this point. - if (!IsEquivalent(effectNode->name, DAE_EFFECT_ELEMENT)) - { - return status.Warning(FS("Unknown element in effect library."), effectNode->line); - } - - for (xmlNode* child = effectNode->children; child != NULL; child = child->next) - { - if (child->type != XML_ELEMENT_NODE) continue; - - if (IsEquivalent(child->name, DAE_IMAGE_ELEMENT)) - { - FCDImage* image = GetDocument()->GetImageLibrary()->AddEntity(); - status.AppendStatus(image->LoadFromXML(child)); - images.push_back(image); - } - else if (IsEquivalent(child->name, DAE_FXCMN_SETPARAM_ELEMENT) || IsEquivalent(child->name, DAE_FXCMN_NEWPARAM_ELEMENT)) - { - AddParameter(FCDEffectParameterFactory::LoadFromXML(GetDocument(), child, &status)); - } - else if (IsEquivalent(child->name, DAE_EXTRA_ELEMENT)) - { - // Valid element.. but not processed. - } - else - { - // Check for a valid profile element. - FUDaeProfileType::Type type = FUDaeProfileType::FromString((const char*) child->name); - if (type != FUDaeProfileType::UNKNOWN) - { - FCDEffectProfile* profile = AddProfile(type); - status.AppendStatus(profile->LoadFromXML(child)); - } - else - { - status.Warning(FS("Unsupported profile or unknown element in effect: ") + TO_FSTRING(GetDaeId()), child->line); - } - } - } - } - - return status; -} - -// Returns a copy of the effect, with all the animations/textures attached -FCDEffect* FCDEffect::Clone() -{ - FCDEffect* clone = new FCDEffect(GetDocument()); - FCDEntity::Clone(clone); - - for (FCDEffectProfileList::iterator itR = profiles.begin(); itR != profiles.end(); ++itR) - { - FCDEffectProfile* p = (*itR)->Clone(clone); - clone->profiles.push_back(p); - } - - for (FCDEffectImageList::iterator itI = images.begin(); itI != images.end(); ++itI) - { - FCDImage* p = *itI; - clone->images.push_back(p); - } - - SAFE_DELETE(clone->parameters); - clone->parameters = parameters->Clone(); - return clone; -} - -// Write out the element to the COLLADA xml tree -xmlNode* FCDEffect::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* effectNode = WriteToEntityXML(parentNode, DAE_EFFECT_ELEMENT); - - // Write out the parameters - for (FCDEffectParameterList::iterator itP = parameters->begin(); itP != parameters->end(); ++itP) - { - (*itP)->WriteToXML(effectNode); - } - - // Write out the profiles - for (FCDEffectProfileList::const_iterator itR = profiles.begin(); itR != profiles.end(); ++itR) - { - (*itR)->WriteToXML(effectNode); - } - - FCDEffect::WriteToExtraXML(effectNode); - return effectNode; -} diff --git a/Extras/FCollada/FCDocument/FCDEffect.h b/Extras/FCollada/FCDocument/FCDEffect.h deleted file mode 100644 index d681696b5..000000000 --- a/Extras/FCollada/FCDocument/FCDEffect.h +++ /dev/null @@ -1,179 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDEffect.h - This file contains the FCDEffect class. -*/ - -#ifndef _FCD_EFFECT_H_ -#define _FCD_EFFECT_H_ - -#include "FUtils/FUDaeEnum.h" -#include "FCDocument/FCDEntity.h" - -class FCDocument; -class FCDEffectStandard; -class FCDEffectParameter; -class FCDEffectProfile; -class FCDEffectParameterList; - -/** - @defgroup FCDEffect COLLADA Effect Classes [ColladaFX] -*/ - -class FCDEffectProfile; -class FCDEffectParameterList; -class FCDImage; - -/** A dynamically-sized array of effect profiles. */ -typedef vector FCDEffectProfileList; -typedef vector FCDEffectImageList; - -/** - A COLLADA effect. - - A COLLADA effect is one of many abstraction level that defines how - to render mesh polygon sets. It contains one or more rendering profile - that the application can choose to support. In theory, all the rendering - profiles should reach the same render output, using different - rendering technologies. - - An effect may also declare new general purpose parameters that are common - to all the profiles. - - @ingroup FCDEffect -*/ -class FCOLLADA_EXPORT FCDEffect : public FCDEntity -{ -private: - FCDEffectProfileList profiles; - FCDEffectParameterList* parameters; - FCDEffectImageList images; - -public: - /** Constructor: do not use directly. - Instead use the FCDMaterialLibrary::AddEffect function. - @param document The COLLADA document that owns this effect. */ - FCDEffect(FCDocument* document); - - /** Destructor: do not use directly. - Instead use the FCDMaterialLibrary::ReleaseEffect function. */ - virtual ~FCDEffect(); - - /** Retrieves the type for this entity class. - This function is a part of the FCDEntity interface. - @return The entity type: EFFECT. */ - virtual Type GetType() const { return FCDEntity::EFFECT; } - - /** Retrieves the number of profiles contained within the effect. - @return The number of profiles within the effect. */ - size_t GetProfileCount() const { return profiles.size(); } - - /** Retrieves a profile contained within the effect. - @param index The index of the profile. - @return The profile. This pointer will be NULL, if the given index is out-of-bounds. */ - FCDEffectProfile* GetProfile(size_t index) { FUAssert(index < GetProfileCount(), return NULL); return profiles.at(index); } - const FCDEffectProfile* GetProfile(size_t index) const { FUAssert(index < GetProfileCount(), return NULL); return profiles.at(index); } /**< See above. */ - - /** Retrieves the list of the profiles contained within the effect. - @return The list of effect profiles. */ - FCDEffectProfileList& GetProfiles() { return profiles; } - const FCDEffectProfileList& GetProfiles() const { return profiles; } /**< See above. */ - - /** Retrieves the profile for a specific profile type. - There should only be one profile of each type within an effect. This - function allows you to retrieve the profile for a given type. - @param type The profile type. - @return The profile of this type. This pointer will be NULL if the effect - does not have any profile of this type. */ - FCDEffectProfile* FindProfile(FUDaeProfileType::Type type); - const FCDEffectProfile* FindProfile(FUDaeProfileType::Type type) const; /**< See above. */ - - /** Retrieves whether the effect contains a profile of the given type. - @param type The profile type. - @return Whether the effect has a profile of this type. */ - inline bool HasProfile(FUDaeProfileType::Type type) const { return FindProfile(type) != NULL; } - - /** Creates a profile of the given type. - If a profile of this type already exists, it will be released, as - a COLLADA effect should only contain one profile of each type. - @param type The profile type. - @return The new effect profile. */ - FCDEffectProfile* AddProfile(FUDaeProfileType::Type type); - - /** Releases the given effect profile. - @param profile The effect profile. */ - void ReleaseProfile(FCDEffectProfile* profile); - - /** Retrieves the list of common effect parameters declared at the effect level. - According to the COLLADA 1.4 schema, you should expect only parameter generators - at this abstraction level. - @return The list of effect parameters. */ - FCDEffectParameterList* GetParameters() { return parameters; } - const FCDEffectParameterList* GetParameters() const { return parameters; } /**< See above. */ - - /** [INTERNAL] Inserts an existing parameter into the list of common effect parameters - at this abstraction level. This function is used during the flattening of a material. - @param parameter The effect parameter to insert. */ - void AddParameter(FCDEffectParameter* parameter); - - /** Retrieves a common effect parameter. Looks for the common effect parameter with the correct - semantic, in order to bind or override its value. - This function searches through the effect and the level of abstractions below. - @param semantic The effect parameter semantic to match. - @return The first effect parameter that matches the semantic. - This pointer will be NULL if no effect parameter matches the given semantic. */ - FCDEffectParameter* FindParameterBySemantic(const string& semantic); - - /** Retrieves a subset of the common effect parameter list. - Look for the effect parameter generators with the correct semantic. - This function searches through the effect and the level of abstractions below. - @param semantic The effect parameter semantic to match. - @param parameters The list of parameters to fill in. This list is not cleared. */ - void FindParametersBySemantic(const string& semantic, FCDEffectParameterList& parameters); - - /** Retrieves a subset of the common effect parameter list. - Look for the effect parameter generators with the correct reference. - This function searches through the effect and the level of abstractions below. - @param reference The effect parameter reference to match. In the case of effect - parameter generators, the reference is replaced by the sub-id. - @param parameters The list of parameters to fill in. This list is not cleared. */ - void FindParametersByReference(const string& reference, FCDEffectParameterList& parameters); - - /** Clones the effect object. Everything is cloned, including the effect parameter - and their animations. You will need release the cloned effect directly, by deleting the pointer. - @return The cloned effect object. You will must delete this pointer. */ - FCDEffect* Clone(); - - /** [INTERNAL] Flattens the effect, pushing all the common effect parameters - into to the effect technique level of abstraction. To correctly flatten a - material, use the FCDMaterialInstance::FlattenMaterial function. */ - void Flatten(); - - /** [INTERNAL] Reads in the \ element from a given COLLADA XML tree node. - @param effectNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the effect.*/ - virtual FUStatus LoadFromXML(xmlNode* effectNode); - - /** [INTERNAL] Writes out the \ element to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the effect. - @return The created element XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; - - /** Retrieves the list of the images contained within the effect. - @return The list of effect images. */ - FCDEffectImageList& GetImages() { return images; } - const FCDEffectImageList& GetImages() const { return images; } /**< See above. */ -}; - -#endif // _FCD_MATERIAL_H_ diff --git a/Extras/FCollada/FCDocument/FCDEffectCode.cpp b/Extras/FCollada/FCDocument/FCDEffectCode.cpp deleted file mode 100644 index 96f969fb2..000000000 --- a/Extras/FCollada/FCDocument/FCDEffectCode.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDEffectCode.h" -#include "FUtils/FUFileManager.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDEffectCode::FCDEffectCode(FCDocument* document) : FCDObject(document, "FCDEffectCode") -{ - type = INCLUDE; -} - -FCDEffectCode::~FCDEffectCode() -{ -} - -// Clone -FCDEffectCode* FCDEffectCode::Clone() const -{ - FCDEffectCode* clone = new FCDEffectCode(GetDocument()); - clone->type = type; - clone->sid = sid; - clone->filename = filename; - clone->code = code; - return clone; -} - -// Read in the code/include from the xml node tree -FUStatus FCDEffectCode::LoadFromXML(xmlNode* codeNode) -{ - FUStatus status; - if (IsEquivalent(codeNode->name, DAE_FXCMN_INCLUDE_ELEMENT)) type = INCLUDE; - else if (IsEquivalent(codeNode->name, DAE_FXCMN_CODE_ELEMENT)) type = CODE; - else - { - return status.Fail(FS("Unknown effect code type."), codeNode->line); - } - - // Read in the code identifier and the actual code or filename - sid = ReadNodeProperty(codeNode, DAE_SID_ATTRIBUTE); - if (type == INCLUDE && sid.empty()) - { - status.Warning(FS("/ nodes must have an 'sid' attribute to identify them."), codeNode->line); - } - if (type == INCLUDE) - { - filename = ReadNodeUrl(codeNode).prefix; - filename = GetDocument()->GetFileManager()->GetFilePath(filename); - } - else - { - code = TO_FSTRING(ReadNodeContentDirect(codeNode)); - } - - return status; -} - -// Write out the code/include to the COLLADA xml node tree -xmlNode* FCDEffectCode::WriteToXML(xmlNode* parentNode) const -{ - // In COLLADA 1.4, the 'sid' and 'url' attributes are required. - // In the case of the sub-id, save it for later use. - xmlNode* codeNode; - switch (type) - { - case CODE: - codeNode = AddChild(parentNode, DAE_FXCMN_CODE_ELEMENT, code); - const_cast(this)->sid = AddNodeSid(codeNode, !sid.empty() ? sid.c_str() : "code"); - break; - - case INCLUDE: - codeNode = AddChild(parentNode, DAE_FXCMN_INCLUDE_ELEMENT); - const_cast(this)->sid = AddNodeSid(codeNode, !sid.empty() ? sid.c_str() : "include"); - AddAttribute(codeNode, DAE_URL_ATTRIBUTE, filename); - break; - - default: - codeNode = NULL; - } - return codeNode; -} diff --git a/Extras/FCollada/FCDocument/FCDEffectCode.h b/Extras/FCollada/FCDocument/FCDEffectCode.h deleted file mode 100644 index 6b2cf4279..000000000 --- a/Extras/FCollada/FCDocument/FCDEffectCode.h +++ /dev/null @@ -1,118 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDEffectCode.h - This file contains the FCDEffectCode class. -*/ - -#ifndef _FCD_EFFECT_CODE_H_ -#define _FCD_EFFECT_CODE_H_ - -#include "FCDocument/FCDObject.h" - -class FCDocument; - -/** - A COLLADA code inclusion. - - Code inclusions come in two forms: file includes and inline code. - For file includes, you will want to grab the filename of the file - using the GetFilename function and for inline code, you can get - the code directly through the GetCode function. - - Code inclusions are referenced through sub-ids by the effect pass - shaders. Regardless of the extension of the filename of file - includes, the code inclusions' language is solely determined by - the effect profile they belong to. -*/ -class FCDEffectCode : public FCDObject -{ -public: - /** The list of support code inclusion types. */ - enum Type - { - INCLUDE, /** A file include. @see GetFilename */ - CODE /** Inlined code. @see GetCode */ - }; - -private: - Type type; - string sid; - fstring code; - fstring filename; - -public: - /** Constructor: do not use directly. - Instead, use the FCDEffectProfile::AddCode - or the FCDEffectTechnique::AddCode functions. - @param document The COLLADA document that owns this code inclusion. */ - FCDEffectCode(FCDocument* document); - - /** Destructor: do not use directly. - Instead, use the FCDEffectProfile::ReleaseCode - or the FCDEffectTechnique::ReleaseCode functions. */ - ~FCDEffectCode(); - - /** Retrieves the form of the code inclusion. - @return The form. */ - inline Type GetType() const { return type; } - - /** Sets the form of the code inclusion. - Changing the form of the code inclusion will not - remove the inline code or the filename. - @param _type The form. */ - inline void SetType(Type _type) { type = _type; } - - /** Retrieves the sub-id of the code inclusion. - Used to match the code inclusion within the effect pass shaders. - @return The sub-id. */ - const string& GetSid() const { return sid; } - - /** Sets the sub-id of the code inclusion. - This value may change on export, as the sub-id must be unique within its scope. - @param _sid The sub-id. */ - void SetSid(const string& _sid) { sid = _sid; } - - /** Retrieves the inlined code. - First verify that this code inclusion contains inlined code - using the GetType function. - @return The inlined code. */ - const fstring& GetCode() const { return code; } - - /** Sets the inlined code. - As a side-effect, calling this function forces the type of the code inclusion. - @param _code The inlined code. */ - void SetCode(const fstring& _code) { code = _code; type = CODE; } - - /** Retrieves the filename of the code file to open. - First verify that this code inclusion contains a filename - using the GetType function. - @return The code filename. */ - const fstring& GetFilename() const { return filename; } - - /** Sets the filename of the code file. - As a side-effect, calling this function forces the type of the code inclusion. - @param _filename The code filename. */ - void SetFilename(const fstring& _filename) { filename = _filename; type = INCLUDE; } - - /** [INTERNAL] Clones the code inclusion. - @return The cloned effect object. You will must delete this pointer. */ - FCDEffectCode* Clone() const; - - /** [INTERNAL] Reads in the code inclusion from a given COLLADA XML tree node. - Code inclusions cover the \ element and the \ element. - @param codeNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the code inclusion.*/ - FUStatus LoadFromXML(xmlNode* codeNode); - - /** [INTERNAL] Writes out the code inclusion to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the code inclusion. - @return The created element XML tree node. */ - xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -#endif // _FCD_EFFECT_CODE_H_ diff --git a/Extras/FCollada/FCDocument/FCDEffectParameter.cpp b/Extras/FCollada/FCDocument/FCDEffectParameter.cpp deleted file mode 100644 index ecedd5613..000000000 --- a/Extras/FCollada/FCDocument/FCDEffectParameter.cpp +++ /dev/null @@ -1,646 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDAnimated.h" -#include "FCDocument/FCDEffectPass.h" -#include "FCDocument/FCDEffectProfile.h" -#include "FCDocument/FCDEffectTechnique.h" -#include "FCDocument/FCDEffectParameter.h" -#include "FCDocument/FCDImage.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDEffectParameter::FCDEffectParameter(FCDocument* document) : FCDObject(document, "FCDEffectParameter") -{ - isGenerator = true; - isFragment = false; - reference = ""; - semantic = ""; - bindSymbol = ""; -} - -FCDEffectParameter::~FCDEffectParameter() -{ -} - -FUStatus FCDEffectParameter::LoadFromXML(xmlNode* parameterNode) -{ - FUStatus status; - - // This parameter is a generator if this is a element. Otherwise, it modifies - // an existing parameter (, or . - isGenerator = IsEquivalent(parameterNode->name, DAE_FXCMN_NEWPARAM_ELEMENT); - if (isGenerator) - { - reference = ReadNodeProperty(parameterNode, DAE_SID_ATTRIBUTE); - if (reference.empty()) - { - return status.Warning(FS("No reference attribute on generator parameter."), parameterNode->line); - } - } - else - { - reference = ReadNodeProperty(parameterNode, DAE_REF_ATTRIBUTE); - if (reference.empty()) - { - return status.Warning(FS("No reference attribute on modifier parameter."), parameterNode->line); - } - } - - xmlNode* valueNode = FindChildByType(parameterNode, DAE_FXCMN_SEMANTIC_ELEMENT); - if (valueNode != NULL) - { - semantic = ReadNodeContentDirect(valueNode); - } - - return status; -} - -// Write out this ColladaFX parameter to the xml node tree -xmlNode* FCDEffectParameter::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* parameterNode; - if (isGenerator) - { - parameterNode = AddChild(parentNode, DAE_FXCMN_NEWPARAM_ELEMENT); - if (!reference.empty()) AddAttribute(parameterNode, DAE_SID_ATTRIBUTE, reference); - if (!semantic.empty()) AddChild(parameterNode, DAE_FXCMN_SEMANTIC_ELEMENT, semantic); - } - else - { - parameterNode = AddChild(parentNode, DAE_FXCMN_SETPARAM_ELEMENT); - if (!reference.empty()) AddAttribute(parameterNode, DAE_REF_ATTRIBUTE, reference); - } - return parameterNode; -} - -void FCDEffectParameter::Clone(FCDEffectParameter* clone) -{ - clone->bindSymbol = bindSymbol; - clone->reference = reference; - clone->semantic = semantic; - clone->isFragment = isFragment; - clone->isGenerator = isGenerator; -} - -// Flattening: overwrite the target parameter with this parameter -void FCDEffectParameter::Overwrite(FCDEffectParameter* UNUSED(target)) -{ - // Do nothing on the base class, only values and animations should be overwritten -} - -FCDEffectParameterSampler::FCDEffectParameterSampler(FCDocument* document) : FCDEffectParameter(document) -{ - samplerType = SAMPLER2D; -} - -FCDEffectParameterSampler::~FCDEffectParameterSampler() -{ -} - -// Clone -FCDEffectParameter* FCDEffectParameterSampler::Clone() -{ - FCDEffectParameterSampler* clone = new FCDEffectParameterSampler(GetDocument()); - FCDEffectParameter::Clone(clone); - clone->surfaceSid = surfaceSid; - clone->samplerType = samplerType; - return clone; -} - -// Flattening: overwrite the target parameter with this parameter -void FCDEffectParameterSampler::Overwrite(FCDEffectParameter* target) -{ - if (target->GetType() == SAMPLER) - { - FCDEffectParameterSampler* s = (FCDEffectParameterSampler*) target; - if (samplerType == s->samplerType) - { - s->surfaceSid = surfaceSid; - } - } -} - -FUStatus FCDEffectParameterSampler::LoadFromXML(xmlNode* parameterNode) -{ - FUStatus status = FCDEffectParameter::LoadFromXML(parameterNode); - - // Find the sampler node - xmlNode* samplerNode = NULL; - for (xmlNode* child = parameterNode->children; child != NULL; child = child->next) - { - if (child->type != XML_ELEMENT_NODE) continue; - - if (IsEquivalent(child->name, DAE_FXCMN_SAMPLER1D_ELEMENT)) { samplerType = SAMPLER1D; samplerNode = child; break; } - else if (IsEquivalent(child->name, DAE_FXCMN_SAMPLER2D_ELEMENT)) { samplerType = SAMPLER2D; samplerNode = child; break; } - else if (IsEquivalent(child->name, DAE_FXCMN_SAMPLER3D_ELEMENT)) { samplerType = SAMPLER3D; samplerNode = child; break; } - else if (IsEquivalent(child->name, DAE_FXCMN_SAMPLERCUBE_ELEMENT)) { samplerType = SAMPLERCUBE; samplerNode = child; break; } - } - - if (samplerNode == NULL) - { - return status.Warning(FS("Unable to find sampler node for sampler parameter: ") + TO_FSTRING(GetReference()), parameterNode->line); - } - - // Parse the source node - xmlNode* sourceNode = FindChildByType(samplerNode, DAE_SOURCE_ELEMENT); - surfaceSid = ReadNodeContentDirect(sourceNode); - if (surfaceSid.empty()) - { - return status.Fail(FS("Empty surface source value for sampler parameter: ") + TO_FSTRING(GetReference()), parameterNode->line); - } - - return status; -} - -xmlNode* FCDEffectParameterSampler::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* parameterNode = FCDEffectParameter::WriteToXML(parentNode); - const char* samplerName; - switch(samplerType) - { - case SAMPLER1D: samplerName = DAE_FXCMN_SAMPLER1D_ELEMENT; break; - case SAMPLER2D: samplerName = DAE_FXCMN_SAMPLER2D_ELEMENT; break; - case SAMPLER3D: samplerName = DAE_FXCMN_SAMPLER3D_ELEMENT; break; - case SAMPLERCUBE: samplerName = DAE_FXCMN_SAMPLERCUBE_ELEMENT; break; - default: samplerName = DAEERR_UNKNOWN_ELEMENT; break; - } - xmlNode* samplerNode = AddChild(parameterNode, samplerName); - if (!surfaceSid.empty()) AddChild(samplerNode, DAE_SOURCE_ELEMENT, surfaceSid); - return parameterNode; -} - -FCDEffectParameterInt::FCDEffectParameterInt(FCDocument* document) : FCDEffectParameter(document) { value = 0; } -FCDEffectParameterInt::~FCDEffectParameterInt() -{ - value = 0; -} - -// Clone -FCDEffectParameter* FCDEffectParameterInt::Clone() -{ - FCDEffectParameterInt* clone = new FCDEffectParameterInt(GetDocument()); - FCDEffectParameter::Clone(clone); - clone->value = value; - return clone; -} - -// Flattening: overwrite the target parameter with this parameter -void FCDEffectParameterInt::Overwrite(FCDEffectParameter* target) -{ - if (target->GetType() == INTEGER) - { - FCDEffectParameterInt* s = (FCDEffectParameterInt*) target; - s->value = value; - } -} - -// Parse in this ColladaFX integer from the document's XML node -FUStatus FCDEffectParameterInt::LoadFromXML(xmlNode* parameterNode) -{ - FUStatus status = FCDEffectParameter::LoadFromXML(parameterNode); - xmlNode* valueNode = FindChildByType(parameterNode, DAE_FXCMN_INT_ELEMENT); - const char* valueString = ReadNodeContentDirect(valueNode); - if (valueString == NULL || *valueString == 0) - { - return status.Fail(FS("Bad value for float parameter in integer parameter: ") + TO_FSTRING(GetReference()), parameterNode->line); - } - value = FUStringConversion::ToInt32(valueString); - return status; -} - -xmlNode* FCDEffectParameterInt::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* parameterNode = FCDEffectParameter::WriteToXML(parentNode); - AddChild(parameterNode, DAE_FXCMN_INT_ELEMENT, value); - return parameterNode; -} - -// boolean type parameter -FCDEffectParameterBool::FCDEffectParameterBool(FCDocument* document) : FCDEffectParameter(document) -{ - value = 0; -} - -FCDEffectParameterBool::~FCDEffectParameterBool() {} - -// Clone -FCDEffectParameter* FCDEffectParameterBool::Clone() -{ - FCDEffectParameterBool* clone = new FCDEffectParameterBool(GetDocument()); - FCDEffectParameter::Clone(clone); - clone->value = value; - return clone; -} - -// Flattening: overwrite the target parameter with this parameter -void FCDEffectParameterBool::Overwrite(FCDEffectParameter* target) -{ - if (target->GetType() == BOOLEAN) - { - FCDEffectParameterBool* s = (FCDEffectParameterBool*) target; - s->value = value; - } -} - -FUStatus FCDEffectParameterBool::LoadFromXML(xmlNode* parameterNode) -{ - FUStatus status = FCDEffectParameter::LoadFromXML(parameterNode); - xmlNode* valueNode = FindChildByType(parameterNode, DAE_FXCMN_BOOL_ELEMENT); - const char* valueString = ReadNodeContentDirect(valueNode); - if (valueString == NULL || *valueString == 0) - { - return status.Fail(FS("Bad value for boolean parameter in effect: ") + TO_FSTRING(GetReference()), parameterNode->line); - } - value = FUStringConversion::ToBoolean(valueString); - return status; -} - -xmlNode* FCDEffectParameterBool::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* parameterNode = FCDEffectParameter::WriteToXML(parentNode); - AddChild(parameterNode, DAE_FXCMN_BOOL_ELEMENT, value); - return parameterNode; -} - -// string type parameter -FCDEffectParameterString::FCDEffectParameterString(FCDocument* document) : FCDEffectParameter(document) -{ - value = ""; -} - -FCDEffectParameterString::~FCDEffectParameterString() -{ -} - -// Clone -FCDEffectParameter* FCDEffectParameterString::Clone() -{ - FCDEffectParameterString* clone = new FCDEffectParameterString(GetDocument()); - FCDEffectParameter::Clone(clone); - clone->value = value; - return clone; -} - -// Flattening: overwrite the target parameter with this parameter -void FCDEffectParameterString::Overwrite(FCDEffectParameter* target) -{ - if (target->GetType() == STRING) - { - FCDEffectParameterString* s = (FCDEffectParameterString*) target; - s->value = value; - } -} - -FUStatus FCDEffectParameterString::LoadFromXML(xmlNode* parameterNode) -{ - FUStatus status = FCDEffectParameter::LoadFromXML(parameterNode); - xmlNode* valueNode = FindChildByType(parameterNode, DAE_FXCMN_STRING_ELEMENT); - const char* valueString = ReadNodeContentDirect(valueNode); - value = valueString; - return status; -} - -xmlNode* FCDEffectParameterString::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* parameterNode = FCDEffectParameter::WriteToXML(parentNode); - AddChild(parameterNode, DAE_FXCMN_STRING_ELEMENT, value); - return parameterNode; -} - -// float type parameter -FCDEffectParameterFloat::FCDEffectParameterFloat(FCDocument* document) : FCDEffectParameter(document) -{ - floatType = FLOAT; - value = 0.0f; - min = 0.0f; - max = 1.0f; -} - -FCDEffectParameterFloat::~FCDEffectParameterFloat() -{ -} - -// Clone -FCDEffectParameter* FCDEffectParameterFloat::Clone() -{ - FCDEffectParameterFloat* clone = new FCDEffectParameterFloat(GetDocument()); - FCDEffectParameter::Clone(clone); - clone->floatType = floatType; - clone->value = value; - clone->min = min; - clone->max = max; - return clone; -} - -// Flattening: overwrite the target parameter with this parameter -void FCDEffectParameterFloat::Overwrite(FCDEffectParameter* target) -{ - if (target->GetType() == FCDEffectParameter::FLOAT) - { - FCDEffectParameterFloat* s = (FCDEffectParameterFloat*) target; - if (s->floatType == floatType) s->value = value; - } -} - -FUStatus FCDEffectParameterFloat::LoadFromXML(xmlNode* parameterNode) -{ - FUStatus status = FCDEffectParameter::LoadFromXML(parameterNode); - xmlNode* valueNode = FindChildByType(parameterNode, DAE_FXCMN_FLOAT_ELEMENT); - if (valueNode == NULL) - { - valueNode = FindChildByType(parameterNode, DAE_FXCMN_HALF_ELEMENT); - floatType = HALF; - } - else floatType = FLOAT; - - const char* valueString = ReadNodeContentDirect(valueNode); - if (valueString == NULL || *valueString == 0) - { - return status.Fail(FS("Bad float value for float parameter: ") + TO_FSTRING(GetReference()), parameterNode->line); - } - value = FUStringConversion::ToFloat(valueString); - - FCDAnimatedFloat::Create(GetDocument(), parameterNode, &value); - - xmlNode* minannNode = FindChildByName(parameterNode, "UIMin"); - if(minannNode) { - xmlNode* minNode = FindChildByType(minannNode, DAE_FXCMN_FLOAT_ELEMENT); - valueString = ReadNodeContentDirect(minNode); - if (valueString != NULL) min = FUStringConversion::ToFloat(valueString); - } - - xmlNode* maxannNode = FindChildByName(parameterNode, "UIMax"); - if(maxannNode) { - xmlNode* maxNode = FindChildByType(maxannNode, DAE_FXCMN_FLOAT_ELEMENT); - valueString = ReadNodeContentDirect(maxNode); - if (valueString != NULL) max = FUStringConversion::ToFloat(valueString); - } - - return status; -} - -xmlNode* FCDEffectParameterFloat::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* parameterNode = FCDEffectParameter::WriteToXML(parentNode); - AddChild(parameterNode, (floatType == FLOAT) ? DAE_FXCMN_FLOAT_ELEMENT : DAE_FXCMN_HALF_ELEMENT, value); - return parameterNode; -} - -// float2 type parameter -FCDEffectParameterFloat2::FCDEffectParameterFloat2(FCDocument* document) : FCDEffectParameter(document) -{ - floatType = FLOAT; - value_x = 0.0f; - value_y = 0.0f; -} - -FCDEffectParameterFloat2::~FCDEffectParameterFloat2() -{ -} - -// Clone -FCDEffectParameter* FCDEffectParameterFloat2::Clone() -{ - FCDEffectParameterFloat2* clone = new FCDEffectParameterFloat2(GetDocument()); - FCDEffectParameter::Clone(clone); - clone->floatType = floatType; - clone->value_x = value_x; - clone->value_y = value_y; - return clone; -} - -// Flattening: overwrite the target parameter with this parameter -void FCDEffectParameterFloat2::Overwrite(FCDEffectParameter* target) -{ - if (target->GetType() == FLOAT2) - { - FCDEffectParameterFloat2* s = (FCDEffectParameterFloat2*) target; - if (s->floatType == floatType) - { - s->value_x = value_x; - s->value_y = value_y; - } - } -} - -FUStatus FCDEffectParameterFloat2::LoadFromXML(xmlNode* parameterNode) -{ - FUStatus status = FCDEffectParameter::LoadFromXML(parameterNode); - xmlNode* valueNode = FindChildByType(parameterNode, DAE_FXCMN_FLOAT2_ELEMENT); - if (valueNode == NULL) - { - valueNode = FindChildByType(parameterNode, DAE_FXCMN_HALF2_ELEMENT); - floatType = HALF; - } - else floatType = FLOAT; - - const char* valueString = ReadNodeContentDirect(valueNode); - if (valueString == NULL || *valueString == 0) - { - return status.Fail(FS("Bad value for float2 parameter: ") + TO_FSTRING(GetReference()), parameterNode->line); - } - value_x = FUStringConversion::ToFloat(&valueString); - value_y = FUStringConversion::ToFloat(&valueString); - return status; -} - -xmlNode* FCDEffectParameterFloat2::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* parameterNode = FCDEffectParameter::WriteToXML(parentNode); - globalSBuilder.set(value_x); globalSBuilder.append(' '); globalSBuilder.append(value_y); - AddChild(parameterNode, (floatType == FLOAT) ? DAE_FXCMN_FLOAT2_ELEMENT : DAE_FXCMN_HALF2_ELEMENT, globalSBuilder); - return parameterNode; -} - -// float3 type parameter -FCDEffectParameterFloat3::FCDEffectParameterFloat3(FCDocument* document) : FCDEffectParameter(document) -{ - floatType = FLOAT; - value = FMVector3(0.0f, 0.0f, 0.0f); -} - -FCDEffectParameterFloat3::~FCDEffectParameterFloat3() -{ -} - -// Clone -FCDEffectParameter* FCDEffectParameterFloat3::Clone() -{ - FCDEffectParameterFloat3* clone = new FCDEffectParameterFloat3(GetDocument()); - FCDEffectParameter::Clone(clone); - clone->floatType = floatType; - clone->value = value; - return clone; -} - -// Flattening: overwrite the target parameter with this parameter -void FCDEffectParameterFloat3::Overwrite(FCDEffectParameter* target) -{ - if (target->GetType() == FLOAT3) - { - FCDEffectParameterFloat3* s = (FCDEffectParameterFloat3*) target; - if (s->floatType == floatType) - { - s->value = value; - } - } -} - -FUStatus FCDEffectParameterFloat3::LoadFromXML(xmlNode* parameterNode) -{ - FUStatus status = FCDEffectParameter::LoadFromXML(parameterNode); - xmlNode* valueNode = FindChildByType(parameterNode, DAE_FXCMN_FLOAT3_ELEMENT); - if (valueNode == NULL) - { - valueNode = FindChildByType(parameterNode, DAE_FXCMN_HALF3_ELEMENT); - floatType = HALF; - } - else floatType = FLOAT; - - const char* valueString = ReadNodeContentDirect(valueNode); - if (valueString == NULL || *valueString == 0) - { - return status.Fail(FS("Bad value for float3 parameter: ") + TO_FSTRING(GetReference()), parameterNode->line); - } - value = FUStringConversion::ToPoint(valueString); - FCDAnimatedColor::Create(GetDocument(), parameterNode, &value); - - return status; -} - -xmlNode* FCDEffectParameterFloat3::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* parameterNode = FCDEffectParameter::WriteToXML(parentNode); - string s = FUStringConversion::ToString(value); - AddChild(parameterNode, (floatType == FLOAT) ? DAE_FXCMN_FLOAT3_ELEMENT : DAE_FXCMN_HALF3_ELEMENT, s); - return parameterNode; -} - -FCDEffectParameterVector::FCDEffectParameterVector(FCDocument* document) : FCDEffectParameter(document) -{ - floatType = FLOAT; - vector[0] = vector[1] = vector[2] = vector[3] = 0.0f; -} - -FCDEffectParameterVector::~FCDEffectParameterVector() {} - -// Clone -FCDEffectParameter* FCDEffectParameterVector::Clone() -{ - FCDEffectParameterVector* clone = new FCDEffectParameterVector(GetDocument()); - FCDEffectParameter::Clone(clone); - clone->floatType = floatType; - memcpy(clone->vector, vector, sizeof(float) * 4); - return clone; -} - -// Flattening: overwrite the target parameter with this parameter -void FCDEffectParameterVector::Overwrite(FCDEffectParameter* target) -{ - if (target->GetType() == VECTOR) - { - FCDEffectParameterVector* s = (FCDEffectParameterVector*) target; - if (s->floatType == floatType) - { - memcpy(s->vector, vector, sizeof(float) * 4); - } - } -} - -FUStatus FCDEffectParameterVector::LoadFromXML(xmlNode* parameterNode) -{ - FUStatus status = FCDEffectParameter::LoadFromXML(parameterNode); - xmlNode* valueNode = FindChildByType(parameterNode, DAE_FXCMN_FLOAT4_ELEMENT); - if (valueNode == NULL) - { - valueNode = FindChildByType(parameterNode, DAE_FXCMN_HALF4_ELEMENT); - floatType = HALF; - } - else floatType = FLOAT; - - const char* valueString = ReadNodeContentDirect(valueNode); - if (valueString == NULL || *valueString == 0) - { - return status.Fail(FS("Bad value for float4 parameter: ") + TO_FSTRING(GetReference()), parameterNode->line); - } - vector[0] = FUStringConversion::ToFloat(&valueString); - vector[1] = FUStringConversion::ToFloat(&valueString); - vector[2] = FUStringConversion::ToFloat(&valueString); - vector[3] = FUStringConversion::ToFloat(&valueString); - - return status; -} - -xmlNode* FCDEffectParameterVector::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* parameterNode = FCDEffectParameter::WriteToXML(parentNode); - globalSBuilder.set(vector[0]); globalSBuilder.append(' '); globalSBuilder.append(vector[1]); globalSBuilder.append(' '); - globalSBuilder.append(vector[2]); globalSBuilder.append(' '); globalSBuilder.append(vector[3]); - AddChild(parameterNode, (floatType == FLOAT) ? DAE_FXCMN_FLOAT4_ELEMENT : DAE_FXCMN_HALF4_ELEMENT, globalSBuilder); - return parameterNode; -} - -FCDEffectParameterMatrix::FCDEffectParameterMatrix(FCDocument* document) : FCDEffectParameter(document) -{ - floatType = FLOAT; - matrix = FMMatrix44::Identity; -} - -FCDEffectParameterMatrix::~FCDEffectParameterMatrix() -{ -} - -// Clone -FCDEffectParameter* FCDEffectParameterMatrix::Clone() -{ - FCDEffectParameterMatrix* clone = new FCDEffectParameterMatrix(GetDocument()); - FCDEffectParameter::Clone(clone); - clone->floatType = floatType; - clone->matrix = matrix; - return clone; -} - -// Flattening: overwrite the target parameter with this parameter -void FCDEffectParameterMatrix::Overwrite(FCDEffectParameter* target) -{ - if (target->GetType() == MATRIX) - { - FCDEffectParameterMatrix* s = (FCDEffectParameterMatrix*) target; - s->matrix = matrix; - } -} - -FUStatus FCDEffectParameterMatrix::LoadFromXML(xmlNode* parameterNode) -{ - FUStatus status = FCDEffectParameter::LoadFromXML(parameterNode); - xmlNode* valueNode = FindChildByType(parameterNode, DAE_FXCMN_FLOAT4X4_ELEMENT); - if (valueNode == NULL) - { - valueNode = FindChildByType(parameterNode, DAE_FXCMN_HALF4X4_ELEMENT); - floatType = HALF; - } - else floatType = FLOAT; - - const char* valueString = ReadNodeContentDirect(valueNode); - if (valueString == NULL || *valueString == 0) - { - return status.Fail(FS("Bad value for matrix parameter: ") + TO_FSTRING(GetReference()), parameterNode->line); - } - FUStringConversion::ToMatrix(valueString, matrix, GetDocument()->GetLengthUnitConversion()); - return status; -} - -xmlNode* FCDEffectParameterMatrix::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* parameterNode = FCDEffectParameter::WriteToXML(parentNode); - string s = FUStringConversion::ToString(matrix); - AddChild(parameterNode, (floatType == FLOAT) ? DAE_FXCMN_FLOAT4X4_ELEMENT : DAE_FXCMN_HALF4X4_ELEMENT, s); - return parameterNode; -} diff --git a/Extras/FCollada/FCDocument/FCDEffectParameter.h b/Extras/FCollada/FCDocument/FCDEffectParameter.h deleted file mode 100644 index 2c65a8da5..000000000 --- a/Extras/FCollada/FCDocument/FCDEffectParameter.h +++ /dev/null @@ -1,844 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDEffectParameter.h - This file contains the FCDEffectParameter interface and most of its derivate classes: - FCDEffectParameterSampler, FCDEffectParameterFloat, FCDEffectParameterVector... -*/ - -#ifndef _FCD_EFFECT_PARAMETER_H_ -#define _FCD_EFFECT_PARAMETER_H_ - -#include "FCDocument/FCDObject.h" - -class FCDEffectPass; -class FCDocument; -class FCDEffectParameterSurface; - -/** - A COLLADA effect parameter. - - This interface class is used to define all the valid - ColladaFX parameter types. There are many types of - parameters: integers, booleans, floating-point - values, 2D, 3D and 4D vectors of floating-point values, - matrices, strings, surfaces and their samplers. - - A COLLADA effect parameter may generate a new - effect parameter, in which case it will declare a semantic - and a reference: to represent it within the COLLADA document. - - @ingroup FCDEffect -*/ -class FCOLLADA_EXPORT FCDEffectParameter : public FCDObject -{ -public: - /** The type of the effect parameter class. */ - enum Type - { - SAMPLER, /**< A sampler effect parameter. Points towards a surface parameter and adds extra texturing parameters. */ - INTEGER, /**< A single integer effect parameter. */ - BOOLEAN, /**< A single boolean effect parameter. */ - FLOAT, /**< A single floating-pointer value effect parameter. */ - FLOAT2, /**< A 2D vector of floating-pointer values. */ - FLOAT3, /**< A 3D vector of floating-pointer values. */ - VECTOR, /**< A 4D vector of floating-pointer values. */ - MATRIX, /**< A 4x4 matrix. */ - STRING, /**< A string effect parameter. */ - SURFACE /**< A surface effect parameter. Contains a COLLADA image pointer. */ - }; - -private: - bool isGenerator; // whether this effect parameter structure generates a new value or modifies an existing value (is ?) - string reference; - string semantic; // this is a Collada Semantic, not a Cg semantic - - // [glaforte] These two members should be somewhere else - string bindSymbol; // this can be used in Cg to bind to the correct variable - bool isFragment; // parameter bound to the fragment program or the vertex one - -public: - /** Constructor: do not use directly. - Instead, use the FCDEffectParameterList::AddParameter function. - @param document The COLLADA document that owns the effect parameter. */ - FCDEffectParameter(FCDocument* document); - - /** Destructor: do not use directly. - Instead, use the FCDEffectParameterList::ReleaseParameter function. - When released, the effect parameter list will also release all - its parameters, if it owns them. */ - virtual ~FCDEffectParameter(); - - /** Retrieves the type of effect parameter class. - @return The type of the effect parameter class.*/ - virtual Type GetType() const = 0; - - /** Retrieves the reference for this effect parameter. - In the case of generators, the reference string contains the sub-id. - @return The reference. */ - const string& GetReference() const { return reference; } - - /** Retrieves the semantic for this effect parameter. - @return The semantic. */ - const string& GetSemantic() const { return semantic; } - - /** Sets the semantic for this effect parameter. - @param _semantic The semantic. */ - void SetSemantic(const string& _semantic) { semantic = _semantic; } - - /** Retrieves whether this effect parameter is a parameter generator. - A ColladaFX parameter must be generated to be modified or bound at - higher abstraction levels. - @return Whether this is a generator. */ - bool IsGenerator() const { return isGenerator; } - - /** Retrieves whether this effect parameter is a parameter modifier. - A ColladaFX parameter must be generated to be modified or bound at - higher abstraction levels. - @return Whether this is a modifier. */ - bool IsModifier() const { return !isGenerator; } - - /** @deprecated Retrieves the program bind symbol for - this parameter. This information should be available - per-shader, in the FCDEffectPassShader class. - @return The program bind symbol. */ - const string& GetBindSymbol() const { return bindSymbol; } - - /** @deprecated Sets the program bind symbol for this parameter. - This information is available per-shader, in the FCDEffectPassShader class. - @param _bindSymbol The program bind symbol. */ - void SetBindSymbol(const string& _bindSymbol) { bindSymbol = _bindSymbol; } - - /** @deprecated Retrieves whether the program bind symbol attached - to this parameter belongs to a fragment/pixel shader. - This information is available per-shader, in the FCDEffectPassShader class. - @return Whether it belongs to a fragment/pixel shader. */ - bool IsFragment() const { return isFragment; } - - /** @deprecated Sets whether the program bind symbol attached to this - parameter belongs to a fragment/pixel shader. - This information is available per-shader, in the FCDEffectPassShader class. - @param _isFragment Whether it belongs to a fragment/pixel shader. */ - void SetFragment(bool _isFragment) { isFragment = _isFragment;} - - /** Creates a full copy of the effect parameter. - @return The cloned effect parameter. You will need to delete this pointer. */ - virtual FCDEffectParameter* Clone() = 0; - - /** [INTERNAL] Overwrites the target parameter with this parameter. - This function is used during the flattening of materials. - @param target The target parameter to overwrite. */ - virtual void Overwrite(FCDEffectParameter* target); - - /** [INTERNAL] Reads in the effect parameter from a given COLLADA XML tree node. - @param parameterNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the parameter.*/ - virtual FUStatus LoadFromXML(xmlNode* parameterNode); - - /** [INTERNAL] Writes out the effect parameter to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the parameter. - @return The created element XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; - -protected: - /** [INTERNAL] Copies into the given effect parameters, the variables - held by the FCDEffectParameter interface. This function is used by the classes - based on this interface during the cloning process. - @param clone The parameter to clone. */ - void Clone(FCDEffectParameter* clone); -}; - -/** - A COLLADA sampler effect parameter. - A sampler parameter provides the extra texturing information necessary - to correctly sample a surface parameter. - There are four types of samplers supported: 1D, 2D, 3D and cube. - - @ingroup FCDEffect -*/ -class FCOLLADA_EXPORT FCDEffectParameterSampler : public FCDEffectParameter -{ -public: - /** The type of sampling to execute. */ - enum SamplerType - { - SAMPLER1D, /** 1D sampling. */ - SAMPLER2D, /** 2D sampling. */ - SAMPLER3D, /** 3D sampling. */ - SAMPLERCUBE /** Cube-map sampling. */ - }; - -private: - SamplerType samplerType; - string surfaceSid; - -public: - /** Constructor: do not use directly. - Instead, use the FCDEffectParameterList::AddParameter function. - @param document The COLLADA document that owns the effect parameter. */ - FCDEffectParameterSampler(FCDocument* document); - - /** Destructor: do not use directly. - Instead, use the FCDEffectParameterList::ReleaseParameter function. - When released, the effect parameter list will also release all - its parameters, if it owns them. */ - virtual ~FCDEffectParameterSampler(); - - /** Retrieves the type of effect parameter class. - @return The parameter class type: SAMPLER. */ - virtual Type GetType() const { return SAMPLER; } - - /** Retrieves the sub-id of the surface parameter. - You will want to search for that sub-id within the parameters to find the - FCDEffectParameterSurface object. - @return The sub-id. */ - const char* GetSurfaceSid() const { return surfaceSid.c_str(); } - - /** Sets the sub-id of the surface parameter to sample. - @param sid The surface parameter sub-id. */ - void SetSurfaceSid(const char* sid) { surfaceSid = sid; } - - /** Retrieves the type of sampling to do. - @return The sampling type. */ - SamplerType GetSamplerType() const { return samplerType; } - - /** Sets the type of sampling to do. - @param type The sampling type. */ - void SetSamplerType(SamplerType type) { samplerType = type; } - - /** Creates a full copy of the effect parameter. - @return The cloned effect parameter. You will need to delete this pointer. */ - virtual FCDEffectParameter* Clone(); - - /** [INTERNAL] Overwrites the target parameter with this parameter. - This function is used during the flattening of materials. - @param target The target parameter to overwrite. */ - virtual void Overwrite(FCDEffectParameter* target); - - /** [INTERNAL] Reads in the effect parameter from a given COLLADA XML tree node. - @param parameterNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the parameter.*/ - virtual FUStatus LoadFromXML(xmlNode* parameterNode); - - /** [INTERNAL] Writes out the effect parameter to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the parameter. - @return The created element XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -/** - A COLLADA integer effect parameter. - Contains a single, unanimated integer. -*/ -class FCOLLADA_EXPORT FCDEffectParameterInt : public FCDEffectParameter -{ -private: - int value; - -public: - /** Constructor: do not use directly. - Instead, use the FCDEffectParameterList::AddParameter function. - @param document The COLLADA document that owns the effect parameter. */ - FCDEffectParameterInt(FCDocument* document); - - /** Destructor: do not use directly. - Instead, use the FCDEffectParameterList::ReleaseParameter function. - When released, the effect parameter list will also release all - its parameters, if it owns them. */ - virtual ~FCDEffectParameterInt(); - - /** Retrieves the type of effect parameter class. - @return The parameter class type: INTEGER. */ - virtual Type GetType() const { return INTEGER; } - - /** Retrieves the value of the effect parameter. - @return The integer value. */ - int GetValue() const { return value; } - - /** Sets the integer value of the effect parameter. - @param _value The integer value. */ - void SetValue(int _value) { value = _value; } - - /** Creates a full copy of the effect parameter. - @return The cloned effect parameter. You will need to delete this pointer. */ - virtual FCDEffectParameter* Clone(); - - /** [INTERNAL] Overwrites the target parameter with this parameter. - This function is used during the flattening of materials. - @param target The target parameter to overwrite. */ - virtual void Overwrite(FCDEffectParameter* target); - - /** [INTERNAL] Reads in the effect parameter from a given COLLADA XML tree node. - @param parameterNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the parameter.*/ - virtual FUStatus LoadFromXML(xmlNode* parameterNode); - - /** [INTERNAL] Writes out the effect parameter to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the parameter. - @return The created element XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -/** - A COLLADA boolean effect parameter. - Contains a single, unanimated boolean. -*/ -class FCOLLADA_EXPORT FCDEffectParameterBool : public FCDEffectParameter -{ -private: - bool value; - -public: - /** Constructor: do not use directly. - Instead, use the FCDEffectParameterList::AddParameter function. - @param document The COLLADA document that owns the effect parameter. */ - FCDEffectParameterBool(FCDocument* document); - - /** Destructor: do not use directly. - Instead, use the FCDEffectParameterList::ReleaseParameter function. - When released, the effect parameter list will also release all - its parameters, if it owns them. */ - virtual ~FCDEffectParameterBool(); - - /** Retrieves the type of effect parameter class. - @return The parameter class type: BOOLEAN. */ - virtual Type GetType() const { return BOOLEAN; } - - /** Retrieves the boolean value of the effect parameter. - @return The boolean value. */ - bool GetValue() const { return value; } - - /** Sets the boolean value of the effect parameter. - @param _value The boolean value. */ - void SetValue(bool _value) { value = _value; } - - /** Creates a full copy of the effect parameter. - @return The cloned effect parameter. You will need to delete this pointer. */ - virtual FCDEffectParameter* Clone(); - - /** [INTERNAL] Overwrites the target parameter with this parameter. - This function is used during the flattening of materials. - @param target The target parameter to overwrite. */ - virtual void Overwrite(FCDEffectParameter* target); - - /** [INTERNAL] Reads in the effect parameter from a given COLLADA XML tree node. - @param parameterNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the parameter.*/ - virtual FUStatus LoadFromXML(xmlNode* parameterNode); - - /** [INTERNAL] Writes out the effect parameter to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the parameter. - @return The created element XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -/** - A COLLADA string effect parameter. - Contains a single, unanimated string. -*/ -class FCOLLADA_EXPORT FCDEffectParameterString : public FCDEffectParameter -{ -private: - string value; - -public: - /** Constructor: do not use directly. - Instead, use the FCDEffectParameterList::AddParameter function. - @param document The COLLADA document that owns the effect parameter. */ - FCDEffectParameterString(FCDocument* document); - - /** Destructor: do not use directly. - Instead, use the FCDEffectParameterList::ReleaseParameter function. - When released, the effect parameter list will also release all - its parameters, if it owns them. */ - virtual ~FCDEffectParameterString(); - - /** Retrieves the type of effect parameter class. - @return The parameter class type: STRING. */ - virtual Type GetType() const { return STRING; } - - /** Retrieves the string contained in the effect parameter. - @return The string. */ - const string& GetValue() const { return value; } - - /** Sets the string contained in the effect parameter. - @param _value The string. */ - void SetValue(const string& _value) { value = _value; } - - /** Creates a full copy of the effect parameter. - @return The cloned effect parameter. You will need to delete this pointer. */ - virtual FCDEffectParameter* Clone(); - - /** [INTERNAL] Overwrites the target parameter with this parameter. - This function is used during the flattening of materials. - @param target The target parameter to overwrite. */ - virtual void Overwrite(FCDEffectParameter* target); - - /** [INTERNAL] Reads in the effect parameter from a given COLLADA XML tree node. - @param parameterNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the parameter.*/ - virtual FUStatus LoadFromXML(xmlNode* parameterNode); - - /** [INTERNAL] Writes out the effect parameter to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the parameter. - @return The created element XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -/** - A COLLADA float effect parameter. - Contains a single, possibly animated, floating-point value. - The type of the floating-point value may be HALF or FLOAT. -*/ -class FCOLLADA_EXPORT FCDEffectParameterFloat : public FCDEffectParameter -{ -public: - /** The supported types of float-point values. */ - enum FloatType - { - FLOAT, /** A full-fledged floating-point value. This is the default. */ - HALF /** Probably implies a 16-bit floating-point value. */ - }; - -private: - FloatType floatType; - float value; - float min; - float max; - -public: - /** Constructor: do not use directly. - Instead, use the FCDEffectParameterList::AddParameter function. - @param document The COLLADA document that owns the effect parameter. */ - FCDEffectParameterFloat(FCDocument* document); - - /** Destructor: do not use directly. - Instead, use the FCDEffectParameterList::ReleaseParameter function. - When released, the effect parameter list will also release all - its parameters, if it owns them. */ - virtual ~FCDEffectParameterFloat(); - - /** Retrieves the type of effect parameter class. - @return The parameter class type: FLOAT. */ - virtual FCDEffectParameter::Type GetType() const { return FCDEffectParameter::FLOAT; } - - /** Retrieves the type of floating-point value held by this effect parameter. - @return The type of floating-point value. */ - FloatType GetFloatType() const { return floatType; } - - /** Sets the type of floating-point value held by this effect parameter. - @param type The type of floating-point value. */ - void SetFloatType(FloatType type) { floatType = type; } - - /** Retrieves the floating-point value of the effect parameter. - @return The floating-point value. */ - float& GetValue() { return value; } - const float& GetValue() const { return value; } /**< See above. */ - - /** Sets the floating-point value of the effect parameter. - @param _value The floating-point value. */ - void SetValue(float _value) { value = _value; } - - /** Retrieves the minimum value for the UI widget created for this effect parameter. - This value is for UI purposes only and has no real impact on the value. - @return The minimum value. */ - float GetMin() const { return min; } - - /** Sets the minimum value for the UI widget created for this effect parameter. - This value is for UI purposes only and has no real impact on the value. - @param _min The minimum value. */ - void SetMin(float _min) { min = _min; } - - /** Retrieves the maximum value for the UI widget created for this effect parameter. - This value is for UI purposes only and has no real impact on the value. - @return The maximum value. */ - float GetMax() const { return max; } - - /** Sets the maximum value for the UI widget created for this effect parameter. - This value is for UI purposes only and has no real impact on the value. - @param _max The maximum value. */ - void SetMax(float _max) { max = _max; } - - /** Creates a full copy of the effect parameter. - @return The cloned effect parameter. You will need to delete this pointer. */ - virtual FCDEffectParameter* Clone(); - - /** [INTERNAL] Overwrites the target parameter with this parameter. - This function is used during the flattening of materials. - @param target The target parameter to overwrite. */ - virtual void Overwrite(FCDEffectParameter* target); - - /** [INTERNAL] Reads in the effect parameter from a given COLLADA XML tree node. - @param parameterNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the parameter.*/ - virtual FUStatus LoadFromXML(xmlNode* parameterNode); - - /** [INTERNAL] Writes out the effect parameter to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the parameter. - @return The created element XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -/** - A COLLADA 2D vector of floats. - Contains two, possibly animated, floating-point values. - The type of the floating-point values may be HALF or FLOAT. -*/ -class FCOLLADA_EXPORT FCDEffectParameterFloat2 : public FCDEffectParameter -{ -public: - /** The supported types of float-point values. */ - enum FloatType - { - FLOAT, /** A full-fledged floating-point value. This is the default. */ - HALF /** Probably implies a 16-bit floating-point value. */ - }; - -private: - FloatType floatType; - float value_x; - float value_y; - -public: - /** Constructor: do not use directly. - Instead, use the FCDEffectParameterList::AddParameter function. - @param document The COLLADA document that owns the effect parameter. */ - FCDEffectParameterFloat2(FCDocument* document); - - /** Destructor: do not use directly. - Instead, use the FCDEffectParameterList::ReleaseParameter function. - When released, the effect parameter list will also release all - its parameters, if it owns them. */ - virtual ~FCDEffectParameterFloat2(); - - /** Retrieves the type of effect parameter class. - @return The parameter class type: FLOAT2. */ - virtual Type GetType() const { return FLOAT2; } - - /** Retrieves the type of floating-point value held by this effect parameter. - @return The type of floating-point value. */ - FloatType GetFloatType() const { return floatType; } - - /** Sets the type of floating-point value held by this effect parameter. - @param type The type of floating-point value. */ - void SetFloatType(FloatType type) { floatType = type; } - - /** Retrieves the first floating-point value of the effect parameter. - @return The first floating-point value. */ - float& GetValueX() { return value_x; } - const float& GetValueX() const { return value_x; } /**< See above. */ - - /** Sets the first floating-point value of the effect parameter. - @param value The first floating-point value. */ - void SetValueX(float value) { value_x = value; } - - /** Retrieves the second floating-point value of the effect parameter. - @return The second floating-point value. */ - float& GetValueY() { return value_y; } - const float& GetValueY() const { return value_y; } /**< See above. */ - - /** Sets the second floating-point value of the effect parameter. - @param value The second floating-point value. */ - void SetValueY(float value) { value_y = value; } - - /** Creates a full copy of the effect parameter. - @return The cloned effect parameter. You will need to delete this pointer. */ - virtual FCDEffectParameter* Clone(); - - /** [INTERNAL] Overwrites the target parameter with this parameter. - This function is used during the flattening of materials. - @param target The target parameter to overwrite. */ - virtual void Overwrite(FCDEffectParameter* target); - - /** [INTERNAL] Reads in the effect parameter from a given COLLADA XML tree node. - @param parameterNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the parameter.*/ - virtual FUStatus LoadFromXML(xmlNode* parameterNode); - - /** [INTERNAL] Writes out the effect parameter to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the parameter. - @return The created element XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -/** - A COLLADA 3D vector of floats. - Contains three, possibly animated, floating-point values. - The type of the floating-point values may be HALF or FLOAT. -*/ -class FCOLLADA_EXPORT FCDEffectParameterFloat3 : public FCDEffectParameter -{ -public: - /** The supported types of float-point values. */ - enum FloatType - { - FLOAT, /** A full-fledged floating-point value. This is the default. */ - HALF /** Probably implies a 16-bit floating-point value. */ - }; - -private: - FloatType floatType; - FMVector3 value; - -public: - /** Constructor: do not use directly. - Instead, use the FCDEffectParameterList::AddParameter function. - @param document The COLLADA document that owns the effect parameter. */ - FCDEffectParameterFloat3(FCDocument* document); - - /** Destructor: do not use directly. - Instead, use the FCDEffectParameterList::ReleaseParameter function. - When released, the effect parameter list will also release all - its parameters, if it owns them. */ - virtual ~FCDEffectParameterFloat3(); - - /** Retrieves the type of effect parameter class. - @return The parameter class type: FLOAT3. */ - virtual Type GetType() const { return FLOAT3; } - - /** Retrieves the type of floating-point value held by this effect parameter. - @return The type of floating-point value. */ - FloatType GetFloatType() const { return floatType; } - - /** Sets the type of floating-point value held by this effect parameter. - @param type The type of floating-point value. */ - void SetFloatType(FloatType type) { floatType = type; } - - /** Retrieves the first floating-point value of the effect parameter. - @return The first floating-point value. */ - float& GetValueX() { return value.x; } - const float& GetValueX() const { return value.x; } /**< See above. */ - - /** Sets the first floating-point value of the effect parameter. - @param _value The first floating-point value. */ - void SetValueX(float _value) { value.x = _value; } - - /** Retrieves the second floating-point value of the effect parameter. - @return The second floating-point value. */ - float& GetValueY() { return value.y; } - const float& GetValueY() const { return value.y; } /**< See above. */ - - /** Sets the second floating-point value of the effect parameter. - @param _value The second floating-point value. */ - void SetValueY(float _value) { value.y = _value; } - - /** Retrieves the third floating-point value of the effect parameter. - @return The third floating-point value. */ - float& GetValueZ() { return value.z; } - const float& GetValueZ() const { return value.z; } /**< See above. */ - - /** Sets the third floating-point value of the effect parameter. - @param _value The third floating-point value. */ - void SetValueZ(float _value) { value.z = _value; } - - /** Creates a full copy of the effect parameter. - @return The cloned effect parameter. You will need to delete this pointer. */ - virtual FCDEffectParameter* Clone(); - - /** [INTERNAL] Overwrites the target parameter with this parameter. - This function is used during the flattening of materials. - @param target The target parameter to overwrite. */ - virtual void Overwrite(FCDEffectParameter* target); - - /** [INTERNAL] Reads in the effect parameter from a given COLLADA XML tree node. - @param parameterNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the parameter.*/ - virtual FUStatus LoadFromXML(xmlNode* parameterNode); - - /** [INTERNAL] Writes out the effect parameter to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the parameter. - @return The created element XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -/** - A COLLADA 4D vector of floats. - Contains four, possibly animated, floating-point values. - The type of the floating-point values may be HALF or FLOAT. -*/ -class FCOLLADA_EXPORT FCDEffectParameterVector : public FCDEffectParameter -{ -public: - /** The supported types of float-point values. */ - enum FloatType - { - FLOAT, /** A full-fledged floating-point value. This is the default. */ - HALF /** Probably implies a 16-bit floating-point value. */ - }; - -private: - FloatType floatType; - float vector[4]; - -public: - /** Constructor: do not use directly. - Instead, use the FCDEffectParameterList::AddParameter function. - @param document The COLLADA document that owns the effect parameter. */ - FCDEffectParameterVector(FCDocument* document); - - /** Destructor: do not use directly. - Instead, use the FCDEffectParameterList::ReleaseParameter function. - When released, the effect parameter list will also release all - its parameters, if it owns them. */ - virtual ~FCDEffectParameterVector(); - - /** Retrieves the type of effect parameter class. - @return The parameter class type: VECTOR. */ - virtual Type GetType() const { return VECTOR; } - - /** Retrieves the type of floating-point value held by this effect parameter. - @return The type of floating-point value. */ - FloatType GetFloatType() const { return floatType; } - - /** Sets the type of floating-point value held by this effect parameter. - @param type The type of floating-point value. */ - void SetFloatType(FloatType type) { floatType = type; } - - /** Sets the vector value of the effect parameter. - @return The vector value. */ - float* GetVector() { return vector; } - const float* GetVector() const { return vector; } /**< See above. */ - - /** Retrieves the first floating-point value of the effect parameter. - @return The first floating-point value. */ - float& GetValueX() { return vector[0]; } - const float& GetValueX() const { return vector[0]; } /**< See above. */ - - /** Sets the first floating-point value of the effect parameter. - @param _value The first floating-point value. */ - void SetValueX(float _value) { vector[0] = _value; } - - /** Retrieves the second floating-point value of the effect parameter. - @return The second floating-point value. */ - float& GetValueY() { return vector[1]; } - const float& GetValueY() const { return vector[1]; } /**< See above. */ - - /** Sets the second floating-point value of the effect parameter. - @param _value The second floating-point value. */ - void SetValueY(float _value) { vector[1] = _value; } - - /** Retrieves the third floating-point value of the effect parameter. - @return The third floating-point value. */ - float& GetValueZ() { return vector[2]; } - const float& GetValueZ() const { return vector[2]; } /**< See above. */ - - /** Sets the third floating-point value of the effect parameter. - @param _value The third floating-point value. */ - void SetValueZ(float _value) { vector[2] = _value; } - - /** Retrieves the fourth floating-point value of the effect parameter. - @return The fourth floating-point value. */ - float& GetValueW() { return vector[3]; } - const float& GetValueW() const { return vector[3]; } /**< See above. */ - - /** Sets the fourth floating-point value of the effect parameter. - @param _value The fourth floating-point value. */ - void SetValueW(float _value) { vector[3] = _value; } - - /** Creates a full copy of the effect parameter. - @return The cloned effect parameter. You will need to delete this pointer. */ - virtual FCDEffectParameter* Clone(); - - /** [INTERNAL] Overwrites the target parameter with this parameter. - This function is used during the flattening of materials. - @param target The target parameter to overwrite. */ - virtual void Overwrite(FCDEffectParameter* target); - - /** [INTERNAL] Reads in the effect parameter from a given COLLADA XML tree node. - @param parameterNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the parameter.*/ - virtual FUStatus LoadFromXML(xmlNode* parameterNode); - - /** [INTERNAL] Writes out the effect parameter to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the parameter. - @return The created element XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -/** - A COLLADA 4x4 matrix. - Contains 16 floating-point values that represent a COLLADA column-major 4x4 matrix. - The type of the floating-point values may be HALF or FLOAT. -*/ -class FCOLLADA_EXPORT FCDEffectParameterMatrix : public FCDEffectParameter -{ -public: - /** The supported types of float-point values. */ - enum FloatType - { - FLOAT, /** A full-fledged floating-point value. This is the default. */ - HALF /** Probably implies a 16-bit floating-point value. */ - }; - -private: - FloatType floatType; - FMMatrix44 matrix; - -public: - /** Constructor: do not use directly. - Instead, use the FCDEffectParameterList::AddParameter function. - @param document The COLLADA document that owns the effect parameter. */ - FCDEffectParameterMatrix(FCDocument* document); - - /** Destructor: do not use directly. - Instead, use the FCDEffectParameterList::ReleaseParameter function. - When released, the effect parameter list will also release all - its parameters, if it owns them. */ - virtual ~FCDEffectParameterMatrix(); - - /** Retrieves the type of effect parameter class. - @return The parameter class type: MATRIX. */ - virtual Type GetType() const { return MATRIX; } - - /** Retrieves the type of floating-point value held by this effect parameter. - @return The type of floating-point value. */ - FloatType GetFloatType() const { return floatType; } - - /** Sets the type of floating-point value held by this effect parameter. - @param type The type of floating-point value. */ - void SetFloatType(FloatType type) { floatType = type; } - - /** Retrieves the matrix contained within this effect parameter. - @return The matrix. */ - FMMatrix44& GetMatrix() { return matrix; } - const FMMatrix44& GetMatrix() const { return matrix; } /**< See above. */ - - /** Sets the matrix contained within this effect parameter. - @param mx The matrix. */ - void SetMatrix(const FMMatrix44& mx) { matrix = mx; } - - /** Creates a full copy of the effect parameter. - @return The cloned effect parameter. You will need to delete this pointer. */ - virtual FCDEffectParameter* Clone(); - - /** [INTERNAL] Overwrites the target parameter with this parameter. - This function is used during the flattening of materials. - @param target The target parameter to overwrite. */ - virtual void Overwrite(FCDEffectParameter* target); - - /** [INTERNAL] Reads in the effect parameter from a given COLLADA XML tree node. - @param parameterNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the parameter.*/ - virtual FUStatus LoadFromXML(xmlNode* parameterNode); - - /** [INTERNAL] Writes out the effect parameter to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the parameter. - @return The created element XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -#endif // _FCD_EFFECT_PARAMETER_H_ - diff --git a/Extras/FCollada/FCDocument/FCDEffectParameterFactory.cpp b/Extras/FCollada/FCDocument/FCDEffectParameterFactory.cpp deleted file mode 100644 index 6ea750a88..000000000 --- a/Extras/FCollada/FCDocument/FCDEffectParameterFactory.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDEffectParameter.h" -#include "FCDocument/FCDEffectParameterFactory.h" -#include "FCDocument/FCDEffectParameterSurface.h" -#include "FUtils/FUDaeParser.h" - -// Creates a new effect parameter, given a type. -FCDEffectParameter* FCDEffectParameterFactory::Create(FCDocument* document, uint32 type) -{ - FCDEffectParameter* parameter = NULL; - - switch (type) - { - case FCDEffectParameter::SAMPLER: parameter = new FCDEffectParameterSampler(document); break; - case FCDEffectParameter::INTEGER: parameter = new FCDEffectParameterInt(document); break; - case FCDEffectParameter::BOOLEAN: parameter = new FCDEffectParameterBool(document); break; - case FCDEffectParameter::FLOAT: parameter = new FCDEffectParameterFloat(document); break; - case FCDEffectParameter::FLOAT2: parameter = new FCDEffectParameterFloat2(document); break; - case FCDEffectParameter::FLOAT3: parameter = new FCDEffectParameterFloat3(document); break; - case FCDEffectParameter::VECTOR: parameter = new FCDEffectParameterVector(document); break; - case FCDEffectParameter::MATRIX: parameter = new FCDEffectParameterMatrix(document); break; - case FCDEffectParameter::STRING: parameter = new FCDEffectParameterString(document); break; - case FCDEffectParameter::SURFACE: parameter = new FCDEffectParameterSurface(document); break; - default: break; - } - - return parameter; -} - -// Generates the effect parameter object for the given XML node tree -FCDEffectParameter* FCDEffectParameterFactory::LoadFromXML(FCDocument* document, xmlNode* parameterNode, FUStatus* status) -{ - // Look for the type of the parameter. - FCDEffectParameter* parameter = NULL; - for (xmlNode* child = parameterNode->children; child != NULL && parameter == NULL; child = child->next) - { - if (child->type != XML_ELEMENT_NODE) continue; - - if (IsEquivalent(child->name, DAE_FXCMN_BOOL_ELEMENT)) parameter = new FCDEffectParameterBool(document); - else if (IsEquivalent(child->name, DAE_FXCMN_FLOAT_ELEMENT)) parameter = new FCDEffectParameterFloat(document); - else if (IsEquivalent(child->name, DAE_FXCMN_FLOAT2_ELEMENT)) parameter = new FCDEffectParameterFloat2(document); - else if (IsEquivalent(child->name, DAE_FXCMN_FLOAT3_ELEMENT)) parameter = new FCDEffectParameterFloat3(document); - else if (IsEquivalent(child->name, DAE_FXCMN_FLOAT4_ELEMENT)) parameter = new FCDEffectParameterVector(document); - else if (IsEquivalent(child->name, DAE_FXCMN_FLOAT4X4_ELEMENT)) parameter = new FCDEffectParameterMatrix(document); - else if (IsEquivalent(child->name, DAE_FXCMN_HALF_ELEMENT)) parameter = new FCDEffectParameterFloat(document); - else if (IsEquivalent(child->name, DAE_FXCMN_HALF2_ELEMENT)) parameter = new FCDEffectParameterFloat2(document); - else if (IsEquivalent(child->name, DAE_FXCMN_HALF3_ELEMENT)) parameter = new FCDEffectParameterFloat3(document); - else if (IsEquivalent(child->name, DAE_FXCMN_HALF4_ELEMENT)) parameter = new FCDEffectParameterVector(document); - else if (IsEquivalent(child->name, DAE_FXCMN_HALF4X4_ELEMENT)) parameter = new FCDEffectParameterMatrix(document); - else if (IsEquivalent(child->name, DAE_FXCMN_INT_ELEMENT)) parameter = new FCDEffectParameterInt(document); - else if (IsEquivalent(child->name, DAE_FXCMN_SAMPLER1D_ELEMENT)) parameter = new FCDEffectParameterSampler(document); - else if (IsEquivalent(child->name, DAE_FXCMN_SAMPLER2D_ELEMENT)) parameter = new FCDEffectParameterSampler(document); - else if (IsEquivalent(child->name, DAE_FXCMN_SAMPLER3D_ELEMENT)) parameter = new FCDEffectParameterSampler(document); - else if (IsEquivalent(child->name, DAE_FXCMN_SAMPLERCUBE_ELEMENT)) parameter = new FCDEffectParameterSampler(document); - else if (IsEquivalent(child->name, DAE_FXCMN_SURFACE_ELEMENT)) parameter = new FCDEffectParameterSurface(document); - else if (IsEquivalent(child->name, DAE_FXCMN_STRING_ELEMENT)) parameter = new FCDEffectParameterString(document); - } - - if (parameter != NULL) - { - FUStatus s = parameter->LoadFromXML(parameterNode); - if (status != NULL) status->AppendStatus(s); - } - return parameter; -} diff --git a/Extras/FCollada/FCDocument/FCDEffectParameterFactory.h b/Extras/FCollada/FCDocument/FCDEffectParameterFactory.h deleted file mode 100644 index c8cfb1d03..000000000 --- a/Extras/FCollada/FCDocument/FCDEffectParameterFactory.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDEffectParameterFactory.h - This file contains the FCDEffectParameterFactory class. -*/ - -#ifndef _FCD_EFFECT_PARAMETER_FACTORY_H_ -#define _FCD_EFFECT_PARAMETER_FACTORY_H_ - -class FCDocument; - -/** - [INTERNAL] The factory for COLLADA effect parameters. - - Takes in a COLLADA XML tree and returns a new - parameter that represent it, if one is possible. - - @ingroup FCDEffect -*/ -class FCOLLADA_EXPORT FCDEffectParameterFactory -{ -private: - // Never instantiate: this is a static class - FCDEffectParameterFactory() {} - -public: - /** [INTERNAL] Creates a new effect parameter, given a type. - To create new effect parameters, use the FCDEffectParameterList::AddParameter function. - @param document The COLLADA document that will own the effect parameter. - @param type The type of effect to create. - This value should reflect the FCDEffectParameter::Type enum. */ - static FCDEffectParameter* Create(FCDocument* document, uint32 type); - - /** [INTERNAL] Generates the effect parameter object for the given XML node tree. - @param document The COLLADA document that will own the effect parameter. - @param parameterNode The COLLADA XML tree node. - @param status An optional return status. - @return The new effect parameter. This pointer will be NULL if no parameter can be generated - from the given COLLADA XML tree node. */ - static FCDEffectParameter* LoadFromXML(FCDocument* document, xmlNode* parameterNode, FUStatus* status); -}; - -#endif // _FCD_EFFECT_PARAMETER_FACTORY_H_ diff --git a/Extras/FCollada/FCDocument/FCDEffectParameterList.cpp b/Extras/FCollada/FCDocument/FCDEffectParameterList.cpp deleted file mode 100644 index bf7fa7366..000000000 --- a/Extras/FCollada/FCDocument/FCDEffectParameterList.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDEffectParameter.h" -#include "FCDocument/FCDEffectParameterFactory.h" -#include "FCDocument/FCDEffectParameterList.h" - -FCDEffectParameterList::FCDEffectParameterList(FCDocument* document, bool _ownParameters) - : FCDObject(document, "FCDEffectParameterList") -{ - ownParameters = _ownParameters; -} - -FCDEffectParameterList::~FCDEffectParameterList() -{ - if (ownParameters) - { - size_t l = size(); - for (size_t i = 0; i < l; ++i) - { - FCDEffectParameter* p = at(i); - SAFE_DELETE(p); - } - } - clear(); - ownParameters = false; -} - -FCDEffectParameter* FCDEffectParameterList::AddParameter(uint32 type) -{ - FCDEffectParameter* parameter = NULL; - if (ownParameters) - { - parameter = FCDEffectParameterFactory::Create(GetDocument(), type); - push_back(parameter); - } - return parameter; -} - -void FCDEffectParameterList::ReleaseParameter(FCDEffectParameter* parameter) -{ - iterator it = std::find(begin(), end(), parameter); - if (it != end()) - { - if (ownParameters) delete *it; - erase(it); - } -} - -FCDEffectParameter* FCDEffectParameterList::FindReference(const char* reference) -{ - for (iterator it = begin(); it != end(); ++it) - { - if ((*it)->GetReference() == reference) return (*it); - } - return NULL; -} -const FCDEffectParameter* FCDEffectParameterList::FindReference(const char* reference) const -{ - for (const_iterator it = begin(); it != end(); ++it) - { - if ((*it)->GetReference() == reference) return (*it); - } - return NULL; -} - -FCDEffectParameter* FCDEffectParameterList::FindSemantic(const char* semantic) -{ - for (iterator it = begin(); it != end(); ++it) - { - if ((*it)->GetSemantic() == semantic) return (*it); - } - return NULL; -} -const FCDEffectParameter* FCDEffectParameterList::FindSemantic(const char* semantic) const -{ - for (const_iterator it = begin(); it != end(); ++it) - { - if ((*it)->GetSemantic() == semantic) return (*it); - } - return NULL; -} - -void FCDEffectParameterList::FindReference(const char* reference, FCDEffectParameterList& list) -{ - for (iterator it = begin(); it != end(); ++it) - { - if ((*it)->GetReference() == reference) list.push_back(*it); - } -} - -void FCDEffectParameterList::FindSemantic(const char* semantic, FCDEffectParameterList& list) -{ - for (iterator it = begin(); it != end(); ++it) - { - if ((*it)->GetSemantic() == semantic) list.push_back(*it); - } -} - -// Copy this list -FCDEffectParameterList* FCDEffectParameterList::Clone() const -{ - FCDEffectParameterList* clone = new FCDEffectParameterList(GetDocument(), ownParameters); - if (!empty()) - { - clone->reserve(size()); - - if (ownParameters) - { - for (const_iterator it = begin(); it != end(); ++it) - { - clone->push_back((*it)->Clone()); - } - } - else - { - (*clone) = (*this); - } - } - return clone; -} diff --git a/Extras/FCollada/FCDocument/FCDEffectParameterList.h b/Extras/FCollada/FCDocument/FCDEffectParameterList.h deleted file mode 100644 index 8427c34d0..000000000 --- a/Extras/FCollada/FCDocument/FCDEffectParameterList.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDEffectParameterList.h - This file contains the FCDEffectParameterList class. -*/ - -#ifndef _FCD_EFFECT_PARAMETER_LIST_H_ -#define _FCD_EFFECT_PARAMETER_LIST_H_ - -class FCDEffectParameter; - -/** - A searchable list of COLLADA effect parameters. - - This class is based on the STL vector class and adds some - useful search methods: by reference and by semantic. - - @ingroup FCDEffect -*/ -class FCOLLADA_EXPORT FCDEffectParameterList : public vector, public FCDObject -{ -private: - bool ownParameters; - -public: - /** Constructor. - All the objects that need a parameter list will create it when necessary. - You may also create new lists for the retrieval of parameters during a search. - @param document The COLLADA document that owns this parameter list. This pointer - can remain NULL unless you expect to create new parameters within this list. - @param ownParameters Whether this list should release the contained parameters - during its destruction. */ - FCDEffectParameterList(FCDocument* document = NULL, bool ownParameters = false); - - /** Destructor. */ - virtual ~FCDEffectParameterList(); - - /** Creates a new parameters within this list. - @param type The effect parameter type. - @return The new effect parameter. This pointer will be NULL if this list does not own its parameters. */ - FCDEffectParameter* AddParameter(uint32 type); - - /** Releases a parameter contained within this list. - The memory used by this parameter will be released only if this list owns the parameters. - @param parameter The effect parameter to release. */ - void ReleaseParameter(FCDEffectParameter* parameter); - - /** Retrieves the first effect parameter with the given reference. - For effect parameter generators, the sub-id is used instead of the reference. - @param reference A reference to match. - @return The effect parameter that matches the reference. This pointer will be NULL, - if no parameter matches the reference. */ - FCDEffectParameter* FindReference(const char* reference); - const FCDEffectParameter* FindReference(const char* reference) const; /**< See above. */ - inline FCDEffectParameter* FindReference(const string& reference) { return FindReference(reference.c_str()); } /**< See above. */ - inline const FCDEffectParameter* FindReference(const string& reference) const { return FindReference(reference.c_str()); } /**< See above. */ - - /** Retrieves the first effect parameter with the given semantic. - @param semantic A semantic to match. - @return The effect parameter that matches the semantic. This pointer will be NULL - if no parameter matches the semantic. */ - FCDEffectParameter* FindSemantic(const char* semantic); - const FCDEffectParameter* FindSemantic(const char* semantic) const; /**< See above. */ - inline FCDEffectParameter* FindSemantic(const string& semantic) { return FindReference(semantic.c_str()); } /**< See above. */ - inline const FCDEffectParameter* FindSemantic(const string& semantic) const { return FindReference(semantic.c_str()); } /**< See above. */ - - /** Retrieves a subset of this parameter list. - All the effects that match the given reference will be added to the given list. - For effect parameter generators, the sub-id is used instead of the reference. - @param reference A reference to match. - @param list The effect parameter list to fill in with the matched parameters. - This list is not clear. */ - void FindReference(const char* reference, FCDEffectParameterList& list); - inline void FindReference(const string& reference, FCDEffectParameterList& list) { return FindReference(reference.c_str(), list); } /**< See above. */ - - /** Retrieves a subset of this parameter list. - All the effects that match the given semantic will be added to the given list. - @param semantic A semantic to match. - @param list The effect parameter list to fill in with the matched parameters. - This list is not clear. */ - void FindSemantic(const char* semantic, FCDEffectParameterList& list); - inline void FindSemantic(const string& semantic, FCDEffectParameterList& list) { return FindReference(semantic.c_str(), list); } /**< See above. */ - - /** Creates a full copy of the list of parameters and its content. - @return The cloned list. You will need to delete this pointer.*/ - FCDEffectParameterList* Clone() const; -}; - -#endif // _FCD_EFFECT_PARAMETER_LIST_H_ diff --git a/Extras/FCollada/FCDocument/FCDEffectParameterSurface.cpp b/Extras/FCollada/FCDocument/FCDEffectParameterSurface.cpp deleted file mode 100644 index d360bbf65..000000000 --- a/Extras/FCollada/FCDocument/FCDEffectParameterSurface.cpp +++ /dev/null @@ -1,589 +0,0 @@ -/* - Copyright (C) 2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDAnimated.h" -#include "FCDocument/FCDEffectPass.h" -#include "FCDocument/FCDEffectProfile.h" -#include "FCDocument/FCDEffectTechnique.h" -#include "FCDocument/FCDEffectParameter.h" -#include "FCDocument/FCDEffectParameterSurface.h" -#include "FCDocument/FCDImage.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -// surface type parameter -FCDEffectParameterSurface::FCDEffectParameterSurface(FCDocument* document) : FCDEffectParameter(document) -{ - initMethod = NULL; -} - -FCDEffectParameterSurface::~FCDEffectParameterSurface() -{ - SAFE_DELETE(initMethod); - names.clear(); - images.clear(); -} - -void FCDEffectParameterSurface::SetInitMethod(FCDEffectParameterSurfaceInit* method) -{ - SAFE_DELETE(initMethod); - initMethod = method; -} - -// Retrieves the index that matches the given image. -size_t FCDEffectParameterSurface::FindImage(const FCDImage* image) const -{ - FCDImageList::const_iterator it = std::find(images.begin(), images.end(), image); - if (it != images.end()) - { - return it - images.begin(); - } - else return (size_t) -1; -} - -// Adds an image to the list. -size_t FCDEffectParameterSurface::AddImage(FCDImage* image) -{ - size_t index = FindImage(image); - if (index == (size_t) -1) - { - index = images.size(); - images.push_back(image); - } - return index; -} - -// Removes an image from the list. -void FCDEffectParameterSurface::RemoveImage(FCDImage* image) -{ - size_t index = FindImage(image); - if (index != (size_t) -1) - { - images.erase(images.begin() + index); - - if (initMethod != NULL && initMethod->GetInitType() == FCDEffectParameterSurfaceInitFactory::CUBE) - { - // Shift down all the indexes found within the cube map initialization. - FCDEffectParameterSurfaceInitCube* cube = (FCDEffectParameterSurfaceInitCube*) initMethod; - for (UInt16List::iterator itI = cube->order.begin(); itI != cube->order.end(); ++itI) - { - if ((*itI) == index) (*itI) = 0; - else if ((*itI) > index) --(*itI); - } - } - } -} - -// Clone -FCDEffectParameter* FCDEffectParameterSurface::Clone() -{ - FCDEffectParameterSurface* clone = new FCDEffectParameterSurface(GetDocument()); - FCDEffectParameter::Clone(clone); - clone->images.clear(); - for(uint32 i=0; iimages.push_back(images[i]); - clone->names.clear(); - for(uint32 i=0; inames.push_back(names[i]); - - if(initMethod) - clone->initMethod = initMethod->Clone(); - - clone->size = size; - clone->viewportRatio = viewportRatio; - clone->mipLevelCount = mipLevelCount; - clone->generateMipmaps = generateMipmaps; - - return clone; -} - -// Flattening: overwrite the target parameter with this parameter -void FCDEffectParameterSurface::Overwrite(FCDEffectParameter* target) -{ - if (target->GetType() == SURFACE) - { - FCDEffectParameterSurface* s = (FCDEffectParameterSurface*) target; - s->images.clear(); - for(uint32 i=0; iimages.push_back(images[i]); - s->names.clear(); - for(uint32 i=0; inames.push_back(names[i]); - -// s->initMethod->initType = initMethod->GetInitType(); - s->size = size; - s->viewportRatio = viewportRatio; - s->mipLevelCount = mipLevelCount; - s->generateMipmaps = generateMipmaps; - } -} - -FUStatus FCDEffectParameterSurface::LoadFromXML(xmlNode* parameterNode) -{ - FUStatus status = FCDEffectParameter::LoadFromXML(parameterNode); - xmlNode* surfaceNode = FindChildByType(parameterNode, DAE_FXCMN_SURFACE_ELEMENT); - - bool initialized = false; - xmlNode* valueNode = NULL; - //The surface can now contain many init_from elements (1.4.1) - xmlNodeList valueNodes; - FindChildrenByType(surfaceNode, DAE_INITFROM_ELEMENT, valueNodes); - for (xmlNodeList::iterator it = valueNodes.begin(); it != valueNodes.end(); ++it) - { - initialized = true; - if(!initMethod) - initMethod = new FCDEffectParameterSurfaceInitFrom(); - - FCDEffectParameterSurfaceInitFrom* ptrInit = (FCDEffectParameterSurfaceInitFrom*)initMethod; - StringList tempNames; - FUStringConversion::ToStringList(ReadNodeContentDirect(*it), tempNames); - - if (tempNames.size() == 0 || tempNames[0].empty()) - { - return status.Fail(FS(" element is empty in surface parameter: ") + TO_FSTRING(GetReference()), parameterNode->line); - } - - if(tempNames.size() == 1) //might be 1.4.1, so allow the attributes mip, slice, face - { - if(HasNodeProperty(*it, DAE_MIP_ATTRIBUTE)) - { - string mip = ReadNodeProperty(*it, DAE_MIP_ATTRIBUTE); - ptrInit->mip.push_back(mip); - } - if(HasNodeProperty(*it, DAE_SLICE_ATTRIBUTE)) - { - string slice = ReadNodeProperty(*it, DAE_SLICE_ATTRIBUTE); - ptrInit->slice.push_back(slice); - } - if(HasNodeProperty(*it, DAE_FACE_ATTRIBUTE)) - { - string face = ReadNodeProperty(*it, DAE_FACE_ATTRIBUTE); - ptrInit->face.push_back(face); - } - } - - //go through the new names, get their images, and add update the image and name lists - for(uint32 i=0; iFindImage(tempNames[i]); - if (image != NULL) - { - images.push_back(image); - - } - //else return status.Fail(FS("Unable to find image source for surface parameter: ") + TO_FSTRING(GetReference()), parameterNode->line); - } - } - - - //Check if it's initialized AS NULL - if(!initialized) - { - valueNode = FindChildByType(surfaceNode, DAE_INITASNULL_ELEMENT); - if(valueNode) - { - initialized = true; - initMethod = FCDEffectParameterSurfaceInitFactory::Create(FCDEffectParameterSurfaceInitFactory::AS_NULL); - } - } - //Check if it's initialized AS TARGET - if(!initialized) - { - valueNode = FindChildByType(surfaceNode, DAE_INITASTARGET_ELEMENT); - if(valueNode) - { - initialized = true; - initMethod = FCDEffectParameterSurfaceInitFactory::Create(FCDEffectParameterSurfaceInitFactory::AS_TARGET); - } - } - //Check if it's initialized AS CUBE - if(!initialized) - { - valueNode = FindChildByType(surfaceNode, DAE_INITCUBE_ELEMENT); - if(valueNode) - { - initialized = true; - initMethod = FCDEffectParameterSurfaceInitFactory::Create(FCDEffectParameterSurfaceInitFactory::CUBE); - FCDEffectParameterSurfaceInitCube* ptrInit = (FCDEffectParameterSurfaceInitCube*) initMethod; - - //Check if it's an ALL reference - xmlNode* refNode = FindChildByType(valueNode, DAE_ALL_ELEMENT); - if(refNode) - { - ptrInit->cubeType = FCDEffectParameterSurfaceInitCube::ALL; - string name = ReadNodeProperty(refNode, DAE_REF_ATTRIBUTE); - if (name.empty()) - { - return status.Fail(FS("'s all reference is empty in surface parameter: ") + TO_FSTRING(GetReference()), surfaceNode->line); - } - names.push_back(name); - - FCDImage* image = GetDocument()->FindImage(name); - if (image == NULL) - { - return status.Fail(FS("Unable to find image source for surface parameter: ") + TO_FSTRING(GetReference()), surfaceNode->line); - } - images.push_back(image); - } - - //Check if it's a PRIMARY reference - if(!refNode) - { - refNode = FindChildByType(valueNode, DAE_PRIMARY_ELEMENT); - if(refNode) - { - ptrInit->cubeType = FCDEffectParameterSurfaceInitCube::PRIMARY; - string name = ReadNodeProperty(refNode, DAE_REF_ATTRIBUTE); - if (name.empty()) - { - return status.Fail(FS("'s primary reference is empty in surface parameter: ") + TO_FSTRING(GetReference()), valueNode->line); - } - names.push_back(name); - - FCDImage* image = GetDocument()->FindImage(name); - if (image == NULL) - { - return status.Fail(FS("Unable to find image source for surface parameter: ") + TO_FSTRING(GetReference()), valueNode->line); - } - images.push_back(image); - - xmlNode* orderNode = FindChildByType(refNode, DAE_ORDER_ELEMENT); - if(orderNode) - { - //FIXME: complete when the spec has more info - } - } - } - - //Check if it's a FACE reference - if(!refNode) - { - xmlNodeList faceNodes; - FindChildrenByType(valueNode, DAE_FACE_ELEMENT, faceNodes); - if(faceNodes.size()==6) - { - ptrInit->cubeType = FCDEffectParameterSurfaceInitCube::FACE; - for(uint8 ii=0; ii's face reference is empty in surface parameter: ") + TO_FSTRING(GetReference()), refNode->line); - } - names.push_back(valueName); - FCDImage* image = GetDocument()->FindImage(valueName); - - if (image == NULL) - { - return status.Fail(FS("Unable to find image source for surface parameter: ") + TO_FSTRING(GetReference()), refNode->line); - } - images.push_back(image); - } - } - } - } - } - - //Check if it's initialized AS VOLUME - if(!initialized) - { - valueNode = FindChildByType(surfaceNode, DAE_INITVOLUME_ELEMENT); - if(valueNode) - { - initialized = true; - initMethod = FCDEffectParameterSurfaceInitFactory::Create(FCDEffectParameterSurfaceInitFactory::VOLUME); - FCDEffectParameterSurfaceInitVolume* ptrInit = (FCDEffectParameterSurfaceInitVolume*) initMethod; - - //Check if it's an ALL reference - xmlNode* refNode = FindChildByType(valueNode, DAE_ALL_ELEMENT); - if(refNode) - { - ptrInit->volumeType = FCDEffectParameterSurfaceInitVolume::ALL; - string name = ReadNodeProperty(refNode, DAE_REF_ATTRIBUTE); - if (name.empty()) - { - return status.Fail(FS("'s all reference is empty in surface parameter: ") + TO_FSTRING(GetReference()), refNode->line); - } - names.push_back(name); - - FCDImage* image = GetDocument()->FindImage(name); - if (image == NULL) - { - return status.Fail(FS("Unable to find image source for surface parameter: ") + TO_FSTRING(GetReference()), refNode->line); - } - images.push_back(image); - } - - //Check if it's a PRIMARY reference - if(!refNode) - { - refNode = FindChildByType(valueNode, DAE_PRIMARY_ELEMENT); - if(refNode) - { - ptrInit->volumeType = FCDEffectParameterSurfaceInitVolume::PRIMARY; - string name = ReadNodeProperty(refNode, DAE_REF_ATTRIBUTE); - if (name.empty()) - { - return status.Fail(FS("'s primary reference is empty in surface parameter: ") + TO_FSTRING(GetReference()), valueNode->line); - } - names.push_back(name); - - FCDImage* image = GetDocument()->FindImage(name); - if (image == NULL) - { - return status.Fail(FS("Unable to find image source for surface parameter: ") + TO_FSTRING(GetReference()), valueNode->line); - } - images.push_back(image); - } - } - } - } - - //Check if it's initialized as PLANAR - if(!initialized) - { - valueNode = FindChildByType(surfaceNode, DAE_INITPLANAR_ELEMENT); - if(valueNode) - { - initialized = true; - initMethod = FCDEffectParameterSurfaceInitFactory::Create(FCDEffectParameterSurfaceInitFactory::PLANAR); - - //Check if it's an ALL reference - xmlNode* refNode = FindChildByType(valueNode, DAE_ALL_ELEMENT); - if(refNode) - { - string name = ReadNodeProperty(refNode, DAE_REF_ATTRIBUTE); - if (name.empty()) - { - return status.Fail(FS("'s all reference is empty in surface parameter: ") + TO_FSTRING(GetReference()), refNode->line); - } - names.push_back(name); - - FCDImage* image = GetDocument()->FindImage(name); - if (image == NULL) - { - return status.Fail(FS("Unable to find image source for surface parameter: ") + TO_FSTRING(GetReference()), refNode->line); - } - images.push_back(image); - } - } - } - - // It is acceptable for a surface not to have an initialization option - //but we should flag a warning - if(!initialized) - { - DebugOut("Warning: surface %s not initialized", GetReference().c_str()); - } - - xmlNode* sizeNode = FindChildByType(parameterNode, DAE_SIZE_ELEMENT); - size = FUStringConversion::ToPoint(ReadNodeContentDirect(sizeNode)); - xmlNode* viewportRatioNode = FindChildByType(parameterNode, DAE_VIEWPORT_RATIO); - viewportRatio = FUStringConversion::ToFloat(ReadNodeContentDirect(viewportRatioNode)); - xmlNode* mipLevelsNode = FindChildByType(parameterNode, DAE_MIP_LEVELS); - mipLevelCount = (uint16) FUStringConversion::ToInt32(ReadNodeContentDirect(mipLevelsNode)); - xmlNode* mipmapGenerateNode = FindChildByType(parameterNode, DAE_MIPMAP_GENERATE); - generateMipmaps = FUStringConversion::ToBoolean(ReadNodeContentDirect(mipmapGenerateNode)); - - return status; -} - -xmlNode* FCDEffectParameterSurface::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* parameterNode = FCDEffectParameter::WriteToXML(parentNode); - xmlNode* surfaceNode = AddChild(parameterNode, DAE_FXCMN_SURFACE_ELEMENT); - if (!images.empty() && initMethod != NULL) - { - switch (initMethod->GetInitType()) - { - case FCDEffectParameterSurfaceInitFactory::FROM: - { - //Since 1.4.1, there are two possibilities here. - //Possibility 1 - // image1 image2...imageN - - //Possibility 2 - // image1 - // image2 - - FCDEffectParameterSurfaceInitFrom* in = (FCDEffectParameterSurfaceInitFrom*)initMethod; - size_t size = images.size(); //images.size() should always be equal to names.size() - - if( size == in->face.size() || size == in->mip.size() || size == in->slice.size()) - { - //This is possibility 2 - for(uint32 i=0; iGetDaeId()); - AddAttribute(childNode, DAE_MIP_ATTRIBUTE, in->mip[i]); - AddAttribute(childNode, DAE_SLICE_ATTRIBUTE, in->slice[i]); - AddAttribute(childNode, DAE_FACE_ATTRIBUTE, in->face[i]); - } - } - else - { - //This is possibility 1 - globalSBuilder.reserve(size * 18); // Pulled out of a hat - StringList::const_iterator itV = names.begin(); - globalSBuilder.set(*itV); - for (++itV; itV != names.end(); ++itV) - { - globalSBuilder.append(' '); - globalSBuilder.append(*itV); - } - - xmlNode* childNode = AddChild(surfaceNode, DAE_INITFROM_ELEMENT); - AddContent(childNode, globalSBuilder.ToString()); - } - break; - } - case FCDEffectParameterSurfaceInitFactory::AS_NULL: - { - AddChild(surfaceNode, DAE_INITASNULL_ELEMENT); - break; - } - case FCDEffectParameterSurfaceInitFactory::AS_TARGET: - { - AddChild(surfaceNode, DAE_INITASTARGET_ELEMENT); - break; - } - case FCDEffectParameterSurfaceInitFactory::VOLUME: - { - FCDEffectParameterSurfaceInitVolume* in = (FCDEffectParameterSurfaceInitVolume*)initMethod; - xmlNode* childNode = AddChild(surfaceNode, DAE_INITVOLUME_ELEMENT); - if(in->volumeType == FCDEffectParameterSurfaceInitVolume::ALL) - { - xmlNode* typeNode = AddChild(childNode, DAE_ALL_ELEMENT); - AddAttribute(typeNode, DAE_REF_ATTRIBUTE, names[0]); - } - else if(in->volumeType == FCDEffectParameterSurfaceInitVolume::PRIMARY) - { - xmlNode* typeNode = AddChild(childNode, DAE_PRIMARY_ELEMENT); - AddAttribute(typeNode, DAE_REF_ATTRIBUTE, names[0]); - } - break; - } - case FCDEffectParameterSurfaceInitFactory::CUBE: - { - FCDEffectParameterSurfaceInitCube* in = (FCDEffectParameterSurfaceInitCube*)initMethod; - xmlNode* childNode = AddChild(surfaceNode, DAE_INITCUBE_ELEMENT); - if(in->cubeType == FCDEffectParameterSurfaceInitCube::ALL) - { - xmlNode* typeNode = AddChild(childNode, DAE_ALL_ELEMENT); - AddAttribute(typeNode, DAE_REF_ATTRIBUTE, names[0]); - } - else if(in->cubeType == FCDEffectParameterSurfaceInitCube::PRIMARY) - { - xmlNode* typeNode = AddChild(childNode, DAE_PRIMARY_ELEMENT); - AddChild(typeNode, DAE_ORDER_ELEMENT); //FIXME: complete when the spec gets more info. - AddAttribute(typeNode, DAE_REF_ATTRIBUTE, names[0]); - } - if(in->cubeType == FCDEffectParameterSurfaceInitCube::FACE) - { - xmlNode* childNode = AddChild(surfaceNode, DAE_FACE_ELEMENT); - AddAttribute(childNode, DAE_REF_ATTRIBUTE, names[0]); - } - break; - } - case FCDEffectParameterSurfaceInitFactory::PLANAR: - { - xmlNode* childNode = AddChild(surfaceNode, DAE_INITPLANAR_ELEMENT); - xmlNode* typeNode = AddChild(childNode, DAE_ALL_ELEMENT); - AddAttribute(typeNode, DAE_REF_ATTRIBUTE, names[0]); - break; - } - default: - break; - } - - } - return parameterNode; -} - - -void FCDEffectParameterSurfaceInit::Clone(FCDEffectParameterSurfaceInit* UNUSED(clone)) -{ - //no member variables to copy in this class, but leave this for future use. -} - -FCDEffectParameterSurfaceInitCube::FCDEffectParameterSurfaceInitCube() -{ - cubeType = ALL; -} - -FCDEffectParameterSurfaceInit* FCDEffectParameterSurfaceInitCube::Clone() -{ - FCDEffectParameterSurfaceInitCube* clone = new FCDEffectParameterSurfaceInitCube(); - FCDEffectParameterSurfaceInit::Clone(clone); - clone->cubeType = cubeType; - return clone; -} - -FCDEffectParameterSurfaceInit* FCDEffectParameterSurfaceInitFrom::Clone() -{ - FCDEffectParameterSurfaceInitFrom* clone = new FCDEffectParameterSurfaceInitFrom(); - FCDEffectParameterSurfaceInit::Clone(clone); - clone->face = face; - clone->mip = mip; - clone->slice = slice; - return clone; -} - -FCDEffectParameterSurfaceInitVolume::FCDEffectParameterSurfaceInitVolume() -{ - volumeType = ALL; -} - -FCDEffectParameterSurfaceInit* FCDEffectParameterSurfaceInitVolume::Clone() -{ - FCDEffectParameterSurfaceInitVolume* clone = new FCDEffectParameterSurfaceInitVolume(); - FCDEffectParameterSurfaceInit::Clone(clone); - clone->volumeType = volumeType; - return clone; -} - -FCDEffectParameterSurfaceInit* FCDEffectParameterSurfaceInitAsNull::Clone() -{ - FCDEffectParameterSurfaceInitAsNull* clone = new FCDEffectParameterSurfaceInitAsNull(); - FCDEffectParameterSurfaceInit::Clone(clone); - return clone; -} - -FCDEffectParameterSurfaceInit* FCDEffectParameterSurfaceInitAsTarget::Clone() -{ - FCDEffectParameterSurfaceInitAsTarget* clone = new FCDEffectParameterSurfaceInitAsTarget(); - FCDEffectParameterSurfaceInit::Clone(clone); - return clone; -} - -FCDEffectParameterSurfaceInit* FCDEffectParameterSurfaceInitPlanar::Clone() -{ - FCDEffectParameterSurfaceInitPlanar* clone = new FCDEffectParameterSurfaceInitPlanar(); - FCDEffectParameterSurfaceInit::Clone(clone); - return clone; -} - -FCDEffectParameterSurfaceInit* FCDEffectParameterSurfaceInitFactory::Create(InitType type) -{ - FCDEffectParameterSurfaceInit* parameter = NULL; - - switch (type) - { - case FCDEffectParameterSurfaceInitFactory::AS_NULL: parameter = new FCDEffectParameterSurfaceInitAsNull(); break; - case FCDEffectParameterSurfaceInitFactory::AS_TARGET: parameter = new FCDEffectParameterSurfaceInitAsTarget(); break; - case FCDEffectParameterSurfaceInitFactory::CUBE: parameter = new FCDEffectParameterSurfaceInitCube(); break; - case FCDEffectParameterSurfaceInitFactory::FROM: parameter = new FCDEffectParameterSurfaceInitFrom(); break; - case FCDEffectParameterSurfaceInitFactory::PLANAR: parameter = new FCDEffectParameterSurfaceInitPlanar(); break; - case FCDEffectParameterSurfaceInitFactory::VOLUME: parameter = new FCDEffectParameterSurfaceInitVolume(); break; - default: break; - } - - return parameter; -} \ No newline at end of file diff --git a/Extras/FCollada/FCDocument/FCDEffectParameterSurface.h b/Extras/FCollada/FCDocument/FCDEffectParameterSurface.h deleted file mode 100644 index 67327e429..000000000 --- a/Extras/FCollada/FCDocument/FCDEffectParameterSurface.h +++ /dev/null @@ -1,435 +0,0 @@ -/* - Copyright (C) 2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDEffectParameterSurface.h - This file contains the FCDEffectParameterSurface class, - the FCDEffectParameterSurfaceInit interface and its derivate classes. -*/ - -#ifndef _FCD_EFFECT_PARAMETER_SURFACE_H_ -#define _FCD_EFFECT_PARAMETER_SURFACE_H_ - -#include "FCDocument/FCDEffectParameter.h" - -class FCDEffectParameterSurfaceInit; - -/** A dynamically-sized array of COLLADA images */ -typedef std::vector FCDImageList; - -/** - A COLLADA surface parameter. - This parameters hold the texture loading information. The texture - placement information should be held by the sampler parameter. - - @see FCDEffectParameterSampler - - @ingroup FCDEffect -*/ -class FCOLLADA_EXPORT FCDEffectParameterSurface : public FCDEffectParameter -{ -private: - StringList names; - FCDImageList images; - FCDEffectParameterSurfaceInit* initMethod; - FMVector3 size; - float viewportRatio; - uint16 mipLevelCount; - bool generateMipmaps; - -public: - /** Constructor: do not use directly. - Instead, use the FCDEffectParameterList::AddParameter function. - @param document The COLLADA document that owns the effect parameter. */ - FCDEffectParameterSurface(FCDocument* document); - - /** Destructor: do not use directly. - Instead, use the FCDEffectParameterList::ReleaseParameter function. - When released, the effect parameter list will also release all - its parameters, if it owns them. */ - virtual ~FCDEffectParameterSurface(); - - /** Retrieves the type of effect parameter class. - @return The parameter class type: SURFACE. */ - virtual Type GetType() const { return SURFACE; } - - /** Retrieves the initialization method for the surface parameter. - The initialization method is a powerful method of describing how - to build complex textures, such as cube maps, from one or - multiple image files. - @return The surface initialization method. This pointer will be NULL, - if no initialization method is provided. */ - FCDEffectParameterSurfaceInit* GetInitMethod() { return initMethod; } - const FCDEffectParameterSurfaceInit* GetInitMethod() const { return initMethod; } /**< See above. */ - - /** Sets the initialization method for the surface parameter. - The initialization method is a powerful method of describing how - to build complex textures, such as cube maps, from one or - multiple image files. - @param method The new initialization method. - The old initialization method will be released. - You should create a new initialization method - for each surface parameter. */ - void SetInitMethod(FCDEffectParameterSurfaceInit* method); - - /** Retrieves the number of COLLADA images that make up this surface. - There should never be more than six images to build a surface. - In the large majority of cases, expect one image. - @return The number of images. */ - size_t GetImageCount() const { return images.size(); } - - /** Retrieves the list of images that make up this surface. - There should never be more than six images to build a surface. - In the large majority of cases, expect one image. - @return The list of images. */ - FCDImageList& GetImages() { return images; } - const FCDImageList& GetImages() const { return images; } /**< See above. */ - - /** Retrieves a specific image. - @param index The index of the image. - @return The image. This pointer will be NULL if the index is out-of-bounds. */ - FCDImage* GetImage(size_t index = 0) { return index < images.size() ? images.at(index) : NULL; } - const FCDImage* GetImage(size_t index = 0) const { return index < images.size() ? images.at(index) : NULL; } /**< See above. */ - - /** Retrieves the index that matches the given image. - @param image The image to match. - @return The index within the list for this image. - This index may be -1 if no match was found. */ - size_t FindImage(const FCDImage* image) const; - - /** Adds an image to the list. - The initialization method indexes the images from this list. - This function will verify that this image does not already exist within the list, - so use the returned index. - @param image The new image. - @return The index of the image within the list. */ - size_t AddImage(FCDImage* image); - - /** Removes an image from the list. - The initialization method indexes the images from this list. - This function will shift all the indexes in the initialization method - so that they continue matching the correct image. - @param image The image to remove. Its memory is not released. */ - void RemoveImage(FCDImage* image); - - /** Retrieves the wanted dimensions of the surface. - This parameter is optional and may contain all zeroes to indicate - that you should read the surface dimensions from the image file(s). - @return The wanted dimensions. */ - const FMVector3& GetSize() const { return size; } - - /** Sets the wanted dimensions of the surface. - This parameter is optional and can contain all zeroes to indicate - that you should read the surface dimensions from the image file(s). - @param dimensions The wanted dimensions. */ - void SetSize(const FMVector3& dimensions) { size = dimensions; } - - /** Retrieves the viewport ratio to use when the surface is a render target. - @return The viewport ratio. */ - float GetViewportRatio() const { return viewportRatio; } - - /** Sets the viewport ratio to use when the surface is a render target. - @param ratio The viewport ratio. */ - void SetViewportRatio(float ratio) { viewportRatio = ratio; } - - /** Retrieves the wanted number of mip-levels. - This parameter is optional and may be zero to indicate that you should - retrieve the mip-levels from the image file(s) or generate a full - mip-chain, depending on the mip-map generate flag. - @see GetMipMapGenerate - @return The wanted number of mip-levels. */ - uint16 GetMipLevelCount() const { return mipLevelCount; } - - /** Sets the wanted number of mip-levels. - This parameter is optional and can be zero to indicate that you should - retrieve the mip-levels from the image file(s) or generate a full - mip-chain, depending on the mip-map generate flag. - @param levelCount The wanted number of mip-levels. */ - void SetMipLevelCount(uint16 levelCount) { mipLevelCount = levelCount; } - - /** Retrieves whether to generate the mip-map levels on load. - The alternative is to load the mip-map levels from the image files. - @return Whether to generate the mip-map levels on load. */ - bool IsGenerateMipMaps() const { return generateMipmaps; } - - /** Sets whether to generate the mip-map levels of load. - The alternative is to load the mip-map levels from the image files. - @param _generateMipmaps Whether to generate the mip-map levels on load. */ - void SetGenerateMipMaps(bool _generateMipmaps) { generateMipmaps = _generateMipmaps; } - - /** Retrieves a specific sub-id. - @todo I'm not too sure of the implications of the names, - at this level of abstraction: once I'm clear why they exists, add the - necessary interface to access/pull/push items from/to the list. - @param index The sub-id index. - @return The sub-id. This pointer will be NULL if the index is out-of-bounds. */ - const char* GetName(size_t index = 0) const { return (index < names.size()) ? names[index].c_str() : NULL; } - - /** Creates a full copy of the effect parameter. - @todo The cloning does not clone the initialization method correctly. - @return The cloned effect parameter. You will need to delete this pointer. */ - virtual FCDEffectParameter* Clone(); - - /** [INTERNAL] Overwrites the target parameter with this parameter. - This function is used during the flattening of materials. - @param target The target parameter to overwrite. */ - virtual void Overwrite(FCDEffectParameter* target); - - /** [INTERNAL] Reads in the effect parameter from a given COLLADA XML tree node. - @param parameterNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the parameter.*/ - virtual FUStatus LoadFromXML(xmlNode* parameterNode); - - /** [INTERNAL] Writes out the effect parameter to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the parameter. - @return The created element XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - - -/** - [INTERNAL] The factory for COLLADA effect parameter surface initialization. - - @ingroup FCDEffect -*/ -class FCOLLADA_EXPORT FCDEffectParameterSurfaceInitFactory -{ -private: - // Never instantiate: this is a static class - FCDEffectParameterSurfaceInitFactory() {} - -public: - - /** The supported initialization types. */ - enum InitType - { - FROM, /**< Loads a surface from one simple image file. @see FCDEffectParameterSurfaceInitFrom */ - AS_NULL, /**< No initialization. This surface may be initialized by some future effect parameter override. */ - AS_TARGET, /**< Initializes an engine-specific render target for offscreen rendering. In this case, the dimensions should be provided by the surface effect parameter. */ - CUBE, /**< Loads a cube-map from one complex image file or six simple image files. @see FCDEffectParameterSurfaceInitCube */ - VOLUME, /**< Loads a 3D images for one image file. @see FCDEffectParameterSurfaceInitVolume */ - PLANAR /**< Loads a surface from one simple image file. */ - }; - - /** [INTERNAL] Creates a new effect surface initialization parameter, given a type. - @param type The type of initialization parameter to create.*/ - static FCDEffectParameterSurfaceInit* Create(InitType type); -}; - - -/** - A surface initialization method. - In COLLADA 1.4.1, this information was added to support complex surface types. - There are six types of initialization methods, described in the InitType enumerated type. - Expect the FROM initialization type in the large majority of cases. - - @ingroup FCDEffect -*/ -class FCOLLADA_EXPORT FCDEffectParameterSurfaceInit -{ -public: - - /** Constructor: builds a new surface initialization method. */ - FCDEffectParameterSurfaceInit() {} - - /** Destructor. */ - virtual ~FCDEffectParameterSurfaceInit() {} - - /** Retrieves the initialization type. You cannot modify this value. - To change the initialization type of a surface parameter, create a new - surface initialization structure of the correct type. - @return The initialization type. */ - virtual FCDEffectParameterSurfaceInitFactory::InitType GetInitType() const = 0; - - /** Copies all member variables into clone. - @param clone a valid pointer to a FCDEffectParameterSurfaceInit object*/ - void Clone(FCDEffectParameterSurfaceInit* clone); - - /** Creates a full copy of the surface initialization parameter. - @return The surface initialization parameter. You will need to delete this pointer. */ - virtual FCDEffectParameterSurfaceInit* Clone() = 0; -}; - -/** - A cube-map surface initialization method. -*/ -class FCOLLADA_EXPORT FCDEffectParameterSurfaceInitCube : public FCDEffectParameterSurfaceInit -{ -public: - /** The types of cube-map initializations. */ - enum CubeType - { - ALL, /** Load all the mip-levels of all the cube-map faces from one image file. */ - PRIMARY, /** Load the first mip-level of all the cube-map faces from one image file. */ - FACE /** Load all the cube-map faces from separate image files. */ - }; - -public: - /** Constructor: builds a new cube-map initialization method. */ - FCDEffectParameterSurfaceInitCube(); - - /** Destructor. */ - virtual ~FCDEffectParameterSurfaceInitCube() {} - - /** Retrieves the initialization type. You cannot modify this value. - To change the initialization type of a surface parameter, create a new - surface initialization structure of the correct type. - @return The initialization type. */ - virtual FCDEffectParameterSurfaceInitFactory::InitType GetInitType() const {return FCDEffectParameterSurfaceInitFactory::CUBE;} - - /** Creates a full copy of the surface initialization parameter. - @return The surface initialization parameter. You will need to delete this pointer. */ - virtual FCDEffectParameterSurfaceInit* Clone(); - - /** The type of cube-map initialization. */ - CubeType cubeType; - - /** The list of image indices. - The images are contained within the surface effect parameter. - This is used only for the FACE cube-map initialization type and indicates - how to match the faces of faces of the cube-map with the images in the surface effect parameter. */ - UInt16List order; -}; - -/** - A volumetric surface initialization method. -*/ -class FCOLLADA_EXPORT FCDEffectParameterSurfaceInitVolume : public FCDEffectParameterSurfaceInit -{ -public: - /** The types of volumetric surfaces initialization. */ - enum VolumeType - { - ALL, /** Load all the mip-levels from the image file. */ - PRIMARY /** Load the first mip-level from the image file. */ - }; - -public: - /** Constructor: builds a new volumetric surface initialization method. */ - FCDEffectParameterSurfaceInitVolume(); - - /** Destructor. */ - virtual ~FCDEffectParameterSurfaceInitVolume() {} - - /** Retrieves the initialization type. You cannot modify this value. - To change the initialization type of a surface parameter, create a new - surface initialization structure of the correct type. - @return The initialization type. */ - virtual FCDEffectParameterSurfaceInitFactory::InitType GetInitType() const {return FCDEffectParameterSurfaceInitFactory::VOLUME;} - - /** Creates a full copy of the surface initialization parameter. - @return The surface initialization parameter. You will need to delete this pointer. */ - virtual FCDEffectParameterSurfaceInit* Clone(); - - /** The type of volumetric initialization. */ - VolumeType volumeType; -}; - -/** - A simple file surface initialization method. - This is the method used for backward-compatibility. -*/ -class FCOLLADA_EXPORT FCDEffectParameterSurfaceInitFrom : public FCDEffectParameterSurfaceInit -{ -public: - /** Constructor: builds a new file surface initialization method. */ - FCDEffectParameterSurfaceInitFrom() {} - - /** Destructor. */ - virtual ~FCDEffectParameterSurfaceInitFrom() {} - - /** Retrieves the initialization type. You cannot modify this value. - To change the initialization type of a surface parameter, create a new - surface initialization structure of the correct type. - @return The initialization type. */ - virtual FCDEffectParameterSurfaceInitFactory::InitType GetInitType() const {return FCDEffectParameterSurfaceInitFactory::FROM;} - - /** Creates a full copy of the surface initialization parameter. - @return The surface initialization parameter. You will need to delete this pointer. */ - virtual FCDEffectParameterSurfaceInit* Clone(); - - /** The list of mip levels. */ - StringList mip; - - /** The list of matching slices. */ - StringList slice; - - /** The list of matching faces. */ - StringList face; -}; - -/** - This method allows to initialize the surface at a later point. -*/ -class FCOLLADA_EXPORT FCDEffectParameterSurfaceInitAsNull : public FCDEffectParameterSurfaceInit -{ -public: - /** Constructor: builds a new file surface initialization method. */ - FCDEffectParameterSurfaceInitAsNull() {} - - /** Destructor. */ - virtual ~FCDEffectParameterSurfaceInitAsNull() {} - - /** Retrieves the initialization type. You cannot modify this value. - To change the initialization type of a surface parameter, create a new - surface initialization structure of the correct type. - @return The initialization type. */ - virtual FCDEffectParameterSurfaceInitFactory::InitType GetInitType() const {return FCDEffectParameterSurfaceInitFactory::AS_NULL;} - - /** Creates a full copy of the surface initialization parameter. - @return The surface initialization parameter. You will need to delete this pointer. */ - virtual FCDEffectParameterSurfaceInit* Clone(); -}; - -/** - This method allows to initialize the surface as a rendering target. -*/ -class FCOLLADA_EXPORT FCDEffectParameterSurfaceInitAsTarget : public FCDEffectParameterSurfaceInit -{ -public: - /** Constructor: builds a new file surface initialization method. */ - FCDEffectParameterSurfaceInitAsTarget() {}; - - /** Destructor. */ - virtual ~FCDEffectParameterSurfaceInitAsTarget() {} - - /** Retrieves the initialization type. You cannot modify this value. - To change the initialization type of a surface parameter, create a new - surface initialization structure of the correct type. - @return The initialization type. */ - virtual FCDEffectParameterSurfaceInitFactory::InitType GetInitType() const {return FCDEffectParameterSurfaceInitFactory::AS_TARGET;} - - /** Creates a full copy of the surface initialization parameter. - @return The surface initialization parameter. You will need to delete this pointer. */ - virtual FCDEffectParameterSurfaceInit* Clone(); -}; - -/** - This method allows to initialize the surface as planar. -*/ -class FCOLLADA_EXPORT FCDEffectParameterSurfaceInitPlanar : public FCDEffectParameterSurfaceInit -{ -public: - /** Constructor: builds a new file surface initialization method. */ - FCDEffectParameterSurfaceInitPlanar() {}; - - /** Destructor. */ - virtual ~FCDEffectParameterSurfaceInitPlanar() {} - - /** Retrieves the initialization type. You cannot modify this value. - To change the initialization type of a surface parameter, create a new - surface initialization structure of the correct type. - @return The initialization type. */ - virtual FCDEffectParameterSurfaceInitFactory::InitType GetInitType() const {return FCDEffectParameterSurfaceInitFactory::PLANAR;} - - /** Creates a full copy of the surface initialization parameter. - @return The surface initialization parameter. You will need to delete this pointer. */ - virtual FCDEffectParameterSurfaceInit* Clone(); -}; - - - -#endif // _FCD_EFFECT_PARAMETER_SURFACE_H_ diff --git a/Extras/FCollada/FCDocument/FCDEffectPass.cpp b/Extras/FCollada/FCDocument/FCDEffectPass.cpp deleted file mode 100644 index 32af45d13..000000000 --- a/Extras/FCollada/FCDocument/FCDEffectPass.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDEffectTechnique.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDEffectPass.h" -#include "FCDocument/FCDEffectPassShader.h" -#include "FCDocument/FCDEffectParameter.h" -#include "FCDocument/FCDEffectParameterList.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDEffectPass::FCDEffectPass(FCDocument* document, FCDEffectTechnique *_parent) : FCDObject(document, "FCDEffectPass") -{ - parent = _parent; -} - -FCDEffectPass::~FCDEffectPass() -{ - CLEAR_POINTER_VECTOR(shaders); - meshdata.clear(); - parent = NULL; -} - -// Adds a new shader to the pass. -FCDEffectPassShader* FCDEffectPass::AddShader() -{ - FCDEffectPassShader* shader = new FCDEffectPassShader(GetDocument(), this); - shaders.push_back(shader); - return shader; -} - -// Releases a shader contained within the pass. -void FCDEffectPass::ReleaseShader(FCDEffectPassShader* shader) -{ - FCDEffectPassShaderList::iterator it = std::find(shaders.begin(), shaders.end(), shader); - if (it != shaders.end()) - { - delete *it; - shaders.push_back(shader); - } -} - -// Adds a new vertex shader to the pass. -// If a vertex shader already exists within the pass, it will be released. -FCDEffectPassShader* FCDEffectPass::AddVertexShader() -{ - FCDEffectPassShader* vertexShader; - for (vertexShader = GetVertexShader(); vertexShader != NULL; vertexShader = GetVertexShader()) - { - ReleaseShader(vertexShader); - } - - vertexShader = AddShader(); - vertexShader->AffectsVertices(); - return vertexShader; -} - -// Adds a new fragment shader to the pass. -// If a fragment shader already exists within the pass, it will be released. -FCDEffectPassShader* FCDEffectPass::AddFragmentShader() -{ - FCDEffectPassShader* fragmentShader; - for (fragmentShader = GetFragmentShader(); fragmentShader != NULL; fragmentShader = GetFragmentShader()) - { - ReleaseShader(fragmentShader); - } - - fragmentShader = AddShader(); - fragmentShader->AffectsFragments(); - return fragmentShader; -} - -FCDEffectPass* FCDEffectPass::Clone(FCDEffectTechnique* newParent) const -{ - FCDEffectPass* clone = new FCDEffectPass(GetDocument(), newParent); - clone->name = name; - clone->meshdata = meshdata; - - // Clone the shaderss - clone->shaders.reserve(shaders.size()); - for (FCDEffectPassShaderList::const_iterator itS = shaders.begin(); itS != shaders.end(); ++itS) - { - clone->shaders.push_back((*itS)->Clone(clone)); - } - - return clone; -} - -const string& FCDEffectPass::GetDaeId() const -{ - return parent->GetDaeId(); -} - -// Retrieve the type-specific shaders -FCDEffectPassShader* FCDEffectPass::GetVertexShader() -{ - for (FCDEffectPassShaderList::iterator itS = shaders.begin(); itS != shaders.end(); ++itS) - { - if ((*itS)->IsVertexShader()) return (*itS); - } - return NULL; -} -const FCDEffectPassShader* FCDEffectPass::GetVertexShader() const -{ - for (FCDEffectPassShaderList::const_iterator itS = shaders.begin(); itS != shaders.end(); ++itS) - { - if ((*itS)->IsVertexShader()) return (*itS); - } - return NULL; -} - -FCDEffectPassShader* FCDEffectPass::GetFragmentShader() -{ - for (FCDEffectPassShaderList::iterator itS = shaders.begin(); itS != shaders.end(); ++itS) - { - if ((*itS)->IsFragmentShader()) return (*itS); - } - return NULL; -} -const FCDEffectPassShader* FCDEffectPass::GetFragmentShader() const -{ - for (FCDEffectPassShaderList::const_iterator itS = shaders.begin(); itS != shaders.end(); ++itS) - { - if ((*itS)->IsFragmentShader()) return (*itS); - } - return NULL; -} - -FUStatus FCDEffectPass::LoadFromXML(xmlNode* passNode, xmlNode* techniqueNode, xmlNode* profileNode) -{ - FUStatus status; - if (!IsEquivalent(passNode->name, DAE_PASS_ELEMENT)) - { - return status.Warning(FS("Pass contains unknown element."), passNode->line); - } - name = TO_FSTRING(ReadNodeProperty(passNode, DAE_SID_ATTRIBUTE)); - - // parse mesh data - const char* smdnames[10] = { "COLOR0", "COLOR1", "TEXCOORD0", "TEXCOORD1", "TEXCOORD2", "TEXCOORD3", "TEXCOORD4", "TEXCOORD5", "TEXCOORD6", "TEXCOORD7" }; - for(uint32 i = 0; i < 10; ++i) - { - string smdname = smdnames[i]; - - string smdata = ""; - xmlNode *mdataNode = FindChildByProperty(profileNode, "sid", smdname.c_str() ); - if(mdataNode == NULL) - mdataNode = FindChildByProperty(techniqueNode, "sid", smdname.c_str() ); - - if( mdataNode != NULL ) - { - xmlNode *stringNode = FindChildByType(mdataNode, "string" ); - smdata = ReadNodeContentDirect(stringNode); - } - - meshdata.push_back(smdata); - } - - // Look for the elements - xmlNodeList shaderNodes; - FindChildrenByType(passNode, DAE_SHADER_ELEMENT, shaderNodes); - for (xmlNodeList::iterator itS = shaderNodes.begin(); itS != shaderNodes.end(); ++itS) - { - FCDEffectPassShader* shader = new FCDEffectPassShader(GetDocument(), this); - shaders.push_back(shader); - status.AppendStatus(shader->LoadFromXML(*itS)); - } - - return status; -} - -// Write out the pass to the COLLADA xml node tree -xmlNode* FCDEffectPass::WriteToXML(xmlNode* parentNode) const -{ - // Write out the element, with the shader's name - xmlNode* passNode = AddChild(parentNode, DAE_PASS_ELEMENT); - if (!name.empty()) - { - const_cast(this)->name = TO_FSTRING(AddNodeSid(passNode, TO_STRING(name).c_str())); - } - - // Write out the shaders - for (FCDEffectPassShaderList::const_iterator itS = shaders.begin(); itS != shaders.end(); ++itS) - { - (*itS)->WriteToXML(passNode); - } - - return passNode; -} diff --git a/Extras/FCollada/FCDocument/FCDEffectPass.h b/Extras/FCollada/FCDocument/FCDEffectPass.h deleted file mode 100644 index a03725c17..000000000 --- a/Extras/FCollada/FCDocument/FCDEffectPass.h +++ /dev/null @@ -1,140 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDEffectPass.h - This file contains the FCDEffectPass class. -*/ - -#ifndef _FCD_EFFECT_PASS_H_ -#define _FCD_EFFECT_PASS_H_ - -#include "FCDocument/FCDObject.h" - -class FCDEffectTechnique; -class FCDEffectParameter; -class FCDEffectParameterList; -class FCDEffectPassShader; - -typedef vector FCDEffectPassShaderList; /**< A dynamically-sized array of shaders. */ -typedef vector MeshDataList; /**< @deprecated A dynamically-sized array of mesh bindings. These should be bound using the \ element, at the instantiation level! */ - -/** - A COLLADA effect pass. - - The effect pass contains a list of effect shaders. While they - may be missing, it does not make sense for the effect pass to - contain more than two shaders: a vertex shader and a fragment/pixel shader. - - For this reason, we provide the GetVertexShader and the GetFragmentShader - which we expect will be used for most applications, rather than looking - through the list of shader objects. - - @ingroup FCDEffect -*/ -class FCOLLADA_EXPORT FCDEffectPass : public FCDObject -{ -private: - fstring name; - FCDEffectTechnique* parent; - FCDEffectPassShaderList shaders; - MeshDataList meshdata; - -public: - /** Constructor: do not use directly. - Instead, use the FCDEffectTechnique::AddPass function. - @param document The COLLADA document that owns this effect pass. - @param _parent The effect technique that contains this effect pass. */ - FCDEffectPass(FCDocument* document, FCDEffectTechnique *_parent); - - /** Destructor: do not use directly. - Instead, use the FCDEffectTechnique::ReleasePass function. */ - virtual ~FCDEffectPass(); - - /** Retrieves the effect techniques which contains this effect pass. - @return The parent technique. */ - FCDEffectTechnique* GetParent() { return parent; } - const FCDEffectTechnique* GetParent() const { return parent; } /**< See above. */ - - /** Retrieves the COLLADA id of the parent effect. - This function is mostly useful as a shortcut for debugging and reporting. - @return The COLLADA id of the parent effect. */ - const string& GetDaeId() const; - - /** Retrieves the sub-id of the effect pass. - This sub-id is optional. - @return The sub-id. */ - const fstring& GetPassName() const { return name; } - - /** Sets the optional sub-id for the effect pass. - This sub-id is optional. - @param _name The sub-id. */ - void SetPassName(const fstring& _name) { name = _name; } - - /** @deprecated Retrieves the list of mesh data bindings. - This patches bad export data in ColladaMaya and will be removed soon. - @return The list of mesh data bindings. */ - const MeshDataList& GetMeshData() const { return meshdata; } - - /** Retrieves the number of shaders contained within the effect pass. - @return The number of shaders. */ - size_t GetShaderCount() const { return shaders.size(); } - - /** Retrieves a specific shader. - @param index The index of the shader. - @return The shader. This pointer will be NULL if the index is out-of-bounds. */ - FCDEffectPassShader* GetShader(size_t index) { FUAssert(index < GetShaderCount(), return NULL); return shaders.at(index); } - const FCDEffectPassShader* GetShader(size_t index) const { FUAssert(index < GetShaderCount(), return NULL); return shaders.at(index); } /**< See above. */ - - /** Adds a new shader to the pass. - @return The new shader. */ - FCDEffectPassShader* AddShader(); - - /** Releases a shader contained within the pass. - @param shader The shader to release. */ - void ReleaseShader(FCDEffectPassShader* shader); - - /** Retrieves the vertex shader for this effect pass. - @return The vertex shader. This pointer will be NULL if no - shader within the pass affects vertices. */ - FCDEffectPassShader* GetVertexShader(); - const FCDEffectPassShader* GetVertexShader() const; /**< See above. */ - - /** Retrieves the fragment shader for this effect pass. - @return The fragment shader. This pointer will be NULL if no - shader within the pass affects pixels/fragments. */ - FCDEffectPassShader* GetFragmentShader(); - const FCDEffectPassShader* GetFragmentShader() const; /**< See above. */ - - /** Adds a new vertex shader to the pass. - If a vertex shader already exists within the pass, it will be released. - @return The new vertex shader. */ - FCDEffectPassShader* AddVertexShader(); - - /** Adds a new fragment shader to the pass. - If a fragment shader already exists within the pass, it will be released. - @return The new fragment shader. */ - FCDEffectPassShader* AddFragmentShader(); - - /** [INTERNAL] Clones the full effect pass. - @param newParent The effect technique that will contain the cloned profile. - @return The cloned pass. This pointer will never be NULL. */ - FCDEffectPass* Clone(FCDEffectTechnique* newParent) const; - - /** [INTERNAL] Reads in the effect pass from a given COLLADA XML tree node. - @param passNode The COLLADA XML tree node. - @param techniqueNode X @deprecated bad interface : this dependency must be taken out[3] - @param profileNode X @deprecated bad interface : this dependency must be taken out[2] - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the effect pass.*/ - FUStatus LoadFromXML(xmlNode* passNode, xmlNode* techniqueNode, xmlNode* profileNode); - - /** [INTERNAL] Writes out the effect pass to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the effect pass. - @return The created element XML tree node. */ - xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -#endif diff --git a/Extras/FCollada/FCDocument/FCDEffectPassShader.cpp b/Extras/FCollada/FCDocument/FCDEffectPassShader.cpp deleted file mode 100644 index 6dac83f23..000000000 --- a/Extras/FCollada/FCDocument/FCDEffectPassShader.cpp +++ /dev/null @@ -1,148 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDEffectCode.h" -#include "FCDocument/FCDEffectPass.h" -#include "FCDocument/FCDEffectPassShader.h" -#include "FCDocument/FCDEffectProfileFX.h" -#include "FCDocument/FCDEffectTechnique.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDEffectPassShader::FCDEffectPassShader(FCDocument* document, FCDEffectPass* _parent) : FCDObject(document, "FCDEffectPassShader") -{ - parent = _parent; - isFragment = false; - code = NULL; -} - -FCDEffectPassShader::~FCDEffectPassShader() -{ - parent = NULL; - code = NULL; -} - - -// Adds a new binding to this shader. -FCDEffectPassBind* FCDEffectPassShader::AddBinding() -{ - bindings.push_back(FCDEffectPassBind()); - return &bindings.back(); -} - -// Releases a binding contained within this shader. -void FCDEffectPassShader::ReleaseBinding(FCDEffectPassBind* binding) -{ - for (FCDEffectPassBindList::iterator it = bindings.begin(); it != bindings.end(); ++it) - { - if (&(*it) == binding) - { - bindings.erase(it); - break; - } - } -} - -// Cloning -FCDEffectPassShader* FCDEffectPassShader::Clone(FCDEffectPass* newParent) const -{ - FCDEffectPassShader* clone = new FCDEffectPassShader(GetDocument(), newParent); - clone->isFragment = isFragment; - clone->bindings = bindings; - clone->compilerTarget = compilerTarget; - clone->compilerOptions = compilerOptions; - clone->name = name; - - // Look for the new code within the parent. - if (code != NULL) - { - clone->code = newParent->GetParent()->FindCode(code->GetSid()); - if (clone->code == NULL) clone->code = newParent->GetParent()->GetParent()->FindCode(code->GetSid()); - } - return clone; -} - -// Read in the ColladaFX pass shader from the xml node tree -FUStatus FCDEffectPassShader::LoadFromXML(xmlNode* shaderNode) -{ - FUStatus status; - if (!IsEquivalent(shaderNode->name, DAE_SHADER_ELEMENT)) - { - return status.Warning(FS("Pass shader contains unknown element."), shaderNode->line); - } - - // Read in the shader's name and stage - xmlNode* nameNode = FindChildByType(shaderNode, DAE_FXCMN_NAME_ELEMENT); - name = ReadNodeContentDirect(nameNode); - string codeSource = ReadNodeProperty(nameNode, DAE_SOURCE_ATTRIBUTE); - if (name.empty()) - { - return status.Warning(FS("Unnamed effect pass shader found."), shaderNode->line); - } - string stage = ReadNodeStage(shaderNode); - isFragment = stage == DAE_FXCMN_FRAGMENT_SHADER; - if (!isFragment && stage != DAE_FXCMN_VERTEX_SHADER) - { - return status.Warning(FS("Unknown stage for effect pass shader: ") + TO_FSTRING(name), shaderNode->line); - } - - // Look-up the code filename for this shader, if available - code = parent->GetParent()->FindCode(codeSource); - if (code == NULL) code = parent->GetParent()->GetParent()->FindCode(codeSource); - - // Read in the compiler-related elements - xmlNode* compilerTargetNode = FindChildByType(shaderNode, DAE_FXCMN_COMPILERTARGET_ELEMENT); - compilerTarget = TO_FSTRING(ReadNodeContentDirect(compilerTargetNode)); - xmlNode* compilerOptionsNode = FindChildByType(shaderNode, DAE_FXCMN_COMPILEROPTIONS_ELEMENT); - compilerOptions = TO_FSTRING(ReadNodeContentDirect(compilerOptionsNode)); - - // Read in the bind parameters - xmlNodeList bindNodes; - FindChildrenByType(shaderNode, DAE_FXCMN_BIND_ELEMENT, bindNodes); - for (xmlNodeList::iterator itB = bindNodes.begin(); itB != bindNodes.end(); ++itB) - { - xmlNode* paramNode = FindChildByType(*itB, DAE_PARAMETER_ELEMENT); - - FCDEffectPassBind& bind = *(bindings.insert(bindings.end(), FCDEffectPassBind())); - bind.symbol = ReadNodeProperty((*itB), DAE_SYMBOL_ATTRIBUTE); - bind.reference = ReadNodeProperty(paramNode, DAE_REF_ATTRIBUTE); - } - - return status; -} - -// Write out the pass shader to the COLLADA xml node tree -xmlNode* FCDEffectPassShader::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* shaderNode = AddChild(parentNode, DAE_SHADER_ELEMENT); - - // Write out the compiler information and the shader's name/stage - if (!compilerTarget.empty()) AddChild(shaderNode, DAE_FXCMN_COMPILERTARGET_ELEMENT, compilerTarget); - if (!compilerOptions.empty()) AddChild(shaderNode, DAE_FXCMN_COMPILEROPTIONS_ELEMENT, compilerOptions); - AddAttribute(shaderNode, DAE_STAGE_ATTRIBUTE, isFragment ? DAE_FXCMN_FRAGMENT_SHADER : DAE_FXCMN_VERTEX_SHADER); - if (!name.empty()) - { - xmlNode* nameNode = AddChild(shaderNode, DAE_FXCMN_NAME_ELEMENT, name); - if (code != NULL) AddAttribute(nameNode, DAE_SOURCE_ATTRIBUTE, code->GetSid()); - } - - // Write out the bindings - for (FCDEffectPassBindList::const_iterator itB = bindings.begin(); itB != bindings.end(); ++itB) - { - const FCDEffectPassBind& b = (*itB); - if (!b.reference.empty() && !b.symbol.empty()) - { - xmlNode* bindNode = AddChild(shaderNode, DAE_BIND_ELEMENT); - AddAttribute(bindNode, DAE_SYMBOL_ATTRIBUTE, b.symbol); - xmlNode* paramNode = AddChild(bindNode, DAE_PARAMETER_ELEMENT); - AddAttribute(paramNode, DAE_REF_ATTRIBUTE, b.reference); - } - } - return shaderNode; -} diff --git a/Extras/FCollada/FCDocument/FCDEffectPassShader.h b/Extras/FCollada/FCDocument/FCDEffectPassShader.h deleted file mode 100644 index 4b41b3b95..000000000 --- a/Extras/FCollada/FCDocument/FCDEffectPassShader.h +++ /dev/null @@ -1,169 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDEffectPassShader.h - This file contains the FCDEffectPassShader and the FCDEffectPassBind classes. -*/ - -#ifndef _FCD_EFFECT_PASS_SHADER_H_ -#define _FCD_EFFECT_PASS_SHADER_H_ - -#include "FCDocument/FCDObject.h" - -class FCDocument; -class FCDEffectCode; - -/** - A COLLADA shader binding. - - Binds an external symbol to a COLLADA effect parameter, by reference. - - @ingroup FCDEffect -*/ -class FCOLLADA_EXPORT FCDEffectPassBind -{ -public: - string reference; /**< A COLLADA effect parameter reference. */ - string symbol; /**< An external symbol, used within the shader code. */ -}; - -typedef vector FCDEffectPassBindList; /**< A dynamically-sized array of shader bindings. */ - -/** - A COLLADA shader. - - The shader abstraction level in ColladaFX is contained within the effect passes. - There are two types of shaders: vertex shaders and fragment/pixel shaders. - A COLLADA shader contains a list of bindings to attach the effect parameters to the - shader input parameters. - - The shader object also contains the compiler information necessary to build - the shader: its code, the compiler target and the compiler options. -*/ -class FCOLLADA_EXPORT FCDEffectPassShader : public FCDObject -{ -private: - FCDEffectPass* parent; - - FCDEffectPassBindList bindings; - fstring compilerTarget; - fstring compilerOptions; - string name; - bool isFragment; - FCDEffectCode* code; - -public: - /** Constructor: do not use directly. Instead, use the FCDEffectPass::AddShader, - FCDEffectPass::AddVertexShader or FCDEffectPass::AddFragmentShader functions. - @param document The COLLADA document that owns this shader. - @param parent The effect pass that contains this shader. */ - FCDEffectPassShader(FCDocument* document, FCDEffectPass* parent); - - /** Destructor: do not use directly. - Instead, use the FCDEffectPass::ReleaseShader function. */ - virtual ~FCDEffectPassShader(); - - /** Retrieves the effect pass that contains this shader. - @return The effect pass. */ - inline FCDEffectPass* GetParent() { return parent; } - inline const FCDEffectPass* GetParent() const { return parent; } /**< See above. */ - - /** Sets this shader as affecting vertices. - This sets the stage of the shader to the vertex pipeline. */ - inline void AffectsVertices() { isFragment = false; } - - /** Sets this shader as affecting fragments/pixels. - This sets the stage of the shader to the fragment/pixel pipeline. */ - inline void AffectsFragments() { isFragment = true; } - - /** Retrieves whether this shader affects fragments/pixels. - @return Whether this shader affects fragments/pixels. */ - inline bool IsFragmentShader() const { return isFragment; } - - /** Retrieves whether this shader affects vertices. - @return Whether this shader affects vertices. */ - inline bool IsVertexShader() const { return !isFragment; } - - /** Retrieves the list of bindings for this shader. - @return The list of bindings. */ - inline FCDEffectPassBindList& GetBindings() { return bindings; } - inline const FCDEffectPassBindList& GetBindings() const { return bindings; } /**< See above. */ - - /** Retrieves the number of bindings for this shader. - @return The number of bindings. */ - inline size_t GetBindingCount() const { return bindings.size(); } - - /** Retrieves a binding contained in this shader. - @param index The index of the binding. - @return The binding. This pointer will be NULL if the index is out-of-bounds. */ - inline FCDEffectPassBind* GetBinding(size_t index) { FUAssert(index < GetBindingCount(), return NULL); return &bindings.at(index); } - inline const FCDEffectPassBind* GetBinding(size_t index) const { FUAssert(index < GetBindingCount(), return NULL); return &bindings.at(index); } /**< See above. */ - - /** Adds a new binding to this shader. - @return The new binding. */ - FCDEffectPassBind* AddBinding(); - - /** Releases a binding contained within this shader. - @param binding The binding to release. */ - void ReleaseBinding(FCDEffectPassBind* binding); - - /** Retrieves the compiler target information. - The validity of this string depends on the type of the profile that contains this shader. - @return The compiler target information string. */ - inline const fstring& GetCompilerTarget() const { return compilerTarget; } - - /** Sets the compiler target information string. - The validity of this string depends on the type of the profile that contains this shader. - @param _compilerTarget The compiler target information. */ - inline void SetCompilerTarget(const fstring& _compilerTarget) { compilerTarget = _compilerTarget; } - - /** Retrieves the compiler option string. - The validity of this string depends on the type of the profile that contains this shader. - @return The compiler option string. */ - inline const fstring& GetCompilerOptions() const { return compilerOptions; } - - /** Sets the compiler option string. - The validity of this string depends on the type of the profile that contains this shader. - @param _compilerOptions The compiler option string. */ - inline void SetCompilerOptions(const fstring& _compilerOptions) { compilerOptions = _compilerOptions; } - - /** Retrieves the sub-id of the shader. - @return The sub-id. */ - inline const string& GetName() const { return name; } - - /** Sets the sub-id of the shader. - @param _name The sub-id. */ - inline void SetName(const string& _name) { name = _name; } - - /** Retrieves the code inclusion that contains the code for this shader. - @return The code inclusion. This pointer will be NULL if this shader - is not yet attached to any code. */ - inline FCDEffectCode* GetCode() { return code; } - inline const FCDEffectCode* GetCode() const { return code; } /**< See above. */ - - /** Sets the code inclusion that contains the code for this shader. - @param _code The code inclusion. This pointer will be NULL to detach - a shader from its code. */ - inline void SetCode(FCDEffectCode* _code) { code = _code; } - - /** [INTERNAL] Clones this shader. You must manually delete the clone. - @param newParent The effect pass that will contain the clone. - @return The cloned shader. */ - FCDEffectPassShader* Clone(FCDEffectPass* newParent) const; - - /** [INTERNAL] Reads in the pass shader from a given COLLADA XML tree node. - @param shaderNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the shader.*/ - FUStatus LoadFromXML(xmlNode* shaderNode); - - /** [INTERNAL] Writes out the pass shader to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the effect profile. - @return The created element XML tree node. */ - xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -#endif // _FCD_EFFECT_PASS_SHADER_H_ diff --git a/Extras/FCollada/FCDocument/FCDEffectProfile.cpp b/Extras/FCollada/FCDocument/FCDEffectProfile.cpp deleted file mode 100644 index eed6d563c..000000000 --- a/Extras/FCollada/FCDocument/FCDEffectProfile.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDEffect.h" -#include "FCDocument/FCDEffectProfile.h" - -FCDEffectProfile::FCDEffectProfile(FCDocument* document, FCDEffect* _parent) : FCDObject(document, "FCDEffectProfile") -{ - parent = _parent; -} - -FCDEffectProfile::~FCDEffectProfile() -{ - parent = NULL; -} - -const string& FCDEffectProfile::GetDaeId() const -{ - return parent->GetDaeId(); -} diff --git a/Extras/FCollada/FCDocument/FCDEffectProfile.h b/Extras/FCollada/FCDocument/FCDEffectProfile.h deleted file mode 100644 index 3dfe5871c..000000000 --- a/Extras/FCollada/FCDocument/FCDEffectProfile.h +++ /dev/null @@ -1,111 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDEffectProfile.h - This file contains the FCDEffectProfile abstract class. -*/ - -#ifndef _FCD_EFFECT_PROFILE_H_ -#define _FCD_EFFECT_PROFILE_H_ - -#include "FUtils/FUDaeEnum.h" -#include "FCDocument/FCDObject.h" - -class FCDocument; -class FCDEffect; - -/** - The base for a COLLADA effect profile. - - COLLADA has multiple effect profiles: CG, HLSL, GLSL, GLES and the COMMON profile. - For each profile, there is a class which implements this abstract class. - This abstract class solely holds the parent effect and allows access to the - profile type. - - @see FCDEffectProfileFX FCDEffectStandard - - @ingroup FCDEffect -*/ -class FCOLLADA_EXPORT FCDEffectProfile : public FCDObject -{ -private: - FCDEffect* parent; - -public: - /** Constructor: do not use directly. - Instead, use the FCDEffect::AddProfile function. - @param document The COLLADA document that owns this effect profile. - @param parent The effect which contains this profile. */ - FCDEffectProfile(FCDocument* document, FCDEffect* parent); - - /** Destructor: do not use directly. - Instead, use the FCDEffect::ReleaseProfile function. */ - virtual ~FCDEffectProfile(); - - /** Retrieves the profile type for this effect. - This function allows you to up-cast the pointer safely to a more specific - effect profile class. - @return The profile type. */ - virtual FUDaeProfileType::Type GetType() const = 0; - - /** Retrieves the parent effect. - This is the effect which contains this profile. - @return The parent effect. This pointer will never be NULL. */ - FCDEffect* GetParent() { return parent; } - const FCDEffect* GetParent() const { return parent; } /**< See above. */ - - /** [INTERNAL] Retrieves the COLLADA id of the parent effect. - This function is useful when reporting errors and warnings. - @return The COLLADA id of the parent effect. */ - const string& GetDaeId() const; - - /** Retrieves an effect parameter. Looks for the effect parameter with the correct - semantic, in order to bind or override its value. - This function searches through the effect profile and the level of abstractions below. - @param semantic The effect parameter semantic to match. - @return The effect parameter that matches the semantic. This pointer will be NULL - if no effect parameter matches the given semantic. */ - virtual FCDEffectParameter* FindParameterBySemantic(const string& semantic) = 0; - - /** Retrieves a subset of the effect parameter list. - Look for effect parameters with the correct semantic. - This function searches through the effect profile and the level of abstractions below. - @param semantic The effect parameter semantic to match. - @param parameters The list of parameters to fill in. This list is not cleared. */ - virtual void FindParametersBySemantic(const string& semantic, FCDEffectParameterList& parameters) = 0; - - /** Retrieves a subset of the effect parameter list. - Look for effect parameters with the correct reference. - This function searches through the effect profile and the level of abstractions below. - @param reference The effect parameter reference to match. In the case of effect - parameter generators, the reference is replaced by the sub-id. - @param parameters The list of parameters to fill in. This list is not cleared. */ - virtual void FindParametersByReference(const string& reference, FCDEffectParameterList& parameters) = 0; - - /** [INTERNAL] Clones the profile effect and its parameters. - @param newParent The effect that will contain the cloned profile. - @return The cloned profile. This pointer will never be NULL. */ - virtual FCDEffectProfile* Clone(FCDEffect* newParent) = 0; - - /** [INTERNAL] Flattens this effect profile, pushing all the effect parameter overrides - into the effect parameter generators and moving all the parameters to the - effect technique level of abstraction. To flatten the material, use the - FCDMaterialInstance::FlattenMaterial function. */ - virtual void Flatten() = 0; - - /** [INTERNAL] Reads in the effect profile from a given COLLADA XML tree node. - @param profileNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the effect profile.*/ - virtual FUStatus LoadFromXML(xmlNode* profileNode) = 0; - - /** [INTERNAL] Writes out the effect profile to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the effect profile. - @return The created element XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const = 0; -}; - -#endif // _FCD_EFFECT_PROFILE_H_ diff --git a/Extras/FCollada/FCDocument/FCDEffectProfileFX.cpp b/Extras/FCollada/FCDocument/FCDEffectProfileFX.cpp deleted file mode 100644 index 42483d8a0..000000000 --- a/Extras/FCollada/FCDocument/FCDEffectProfileFX.cpp +++ /dev/null @@ -1,282 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDEffect.h" -#include "FCDocument/FCDEffectCode.h" -#include "FCDocument/FCDEffectProfileFX.h" -#include "FCDocument/FCDEffectParameter.h" -#include "FCDocument/FCDEffectParameterList.h" -#include "FCDocument/FCDEffectParameterFactory.h" -#include "FCDocument/FCDEffectTechnique.h" -#include "FCDocument/FCDLibrary.h" -#include "FCDocument/FCDImage.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDEffectProfileFX::FCDEffectProfileFX(FCDocument* document, FCDEffect* _parent, FUDaeProfileType::Type _type) : FCDEffectProfile(document, _parent) -{ - type = _type; - parameters = new FCDEffectParameterList(GetDocument(), true); -} - -FCDEffectProfileFX::~FCDEffectProfileFX() -{ - CLEAR_POINTER_VECTOR(techniques); - CLEAR_POINTER_VECTOR(codes); - SAFE_DELETE(parameters); -} - -FCDEffectTechnique* FCDEffectProfileFX::AddTechnique() -{ - FCDEffectTechnique* technique = new FCDEffectTechnique(GetDocument(), this); - techniques.push_back(technique); - return technique; -} - -void FCDEffectProfileFX::ReleaseTechnique(FCDEffectTechnique* technique) -{ - FCDEffectTechniqueList::iterator it = std::find(techniques.begin(), techniques.end(), technique); - if (it != techniques.end()) - { - delete *it; - techniques.erase(it); - } -} - -void FCDEffectProfileFX::AddParameter(FCDEffectParameter* parameter) -{ - parameters->push_back(parameter); -} - -// Look for the parameter with the given reference. -const FCDEffectParameter* FCDEffectProfileFX::FindParameter(const char* ref) const -{ - const FCDEffectParameter* parameter = parameters->FindReference(ref); - for (FCDEffectTechniqueList::const_iterator it = techniques.begin(); it != techniques.end() && parameter == NULL; ++it) - { - parameter = (*it)->FindParameter(ref); - } - return parameter; -} - -// Look for the effect parameter with the correct semantic, in order to bind/set its value -FCDEffectParameter* FCDEffectProfileFX::FindParameterBySemantic(const string& semantic) -{ - FCDEffectParameter* parameter = parameters->FindSemantic(semantic); - for (FCDEffectTechniqueList::iterator it = techniques.begin(); it != techniques.end() && parameter == NULL; ++it) - { - parameter = (*it)->FindParameterBySemantic(semantic); - } - return parameter; -} - -void FCDEffectProfileFX::FindParametersBySemantic(const string& semantic, FCDEffectParameterList& _parameters) -{ - // Look in the local parameters - parameters->FindSemantic(semantic, _parameters); - - // Look in the techniques - for( FCDEffectTechniqueList::iterator it = techniques.begin(); it != techniques.end(); ++it) - { - (*it)->FindParametersBySemantic(semantic, _parameters); - } -} - -void FCDEffectProfileFX::FindParametersByReference(const string& reference, FCDEffectParameterList& _parameters) -{ - // Look in the local parameters - parameters->FindReference(reference, _parameters); - - // Look in the techniques - for( FCDEffectTechniqueList::iterator it = techniques.begin(); it != techniques.end(); ++it) - { - (*it)->FindParametersBySemantic(reference, _parameters); - } -} - -FCDEffectCode* FCDEffectProfileFX::FindCode(const string& sid) -{ - for (FCDEffectCodeList::iterator itC = codes.begin(); itC != codes.end(); ++itC) - { - if ((*itC)->GetSid() == sid) return (*itC); - } - return NULL; -} -const FCDEffectCode* FCDEffectProfileFX::FindCode(const string& sid) const -{ - for (FCDEffectCodeList::const_iterator itC = codes.begin(); itC != codes.end(); ++itC) - { - if ((*itC)->GetSid() == sid) return (*itC); - } - return NULL; -} - -// Adds a new code inclusion to this effect profile. -FCDEffectCode* FCDEffectProfileFX::AddCode() -{ - FCDEffectCode* code = new FCDEffectCode(GetDocument()); - codes.push_back(code); - return code; -} - -// Releases a code inclusion contained within this effect profile. -void FCDEffectProfileFX::ReleaseCode(FCDEffectCode* code) -{ - FCDEffectCodeList::iterator itC = std::find(codes.begin(), codes.end(), code); - if (itC != codes.end()) - { - delete *itC; - codes.erase(itC); - } -} - -// Clone the profile effect and its parameters -FCDEffectProfile* FCDEffectProfileFX::Clone(FCDEffect* newParent) -{ - // Hack, because I'm time-bound right now. - FCDEffectProfileFX* clone = new FCDEffectProfileFX(GetDocument(), newParent, type); - SAFE_DELETE(clone->parameters); - clone->parameters = parameters->Clone(); - clone->includeFilename = includeFilename; - - // Clone the codes: needs to happen before the techniques are cloned. - clone->codes.reserve(codes.size()); - for (FCDEffectCodeList::const_iterator itC = codes.begin(); itC != codes.end(); ++itC) - { - clone->codes.push_back((*itC)->Clone()); - } - - // Clone the techniques - clone->techniques.reserve(techniques.size()); - for (FCDEffectTechniqueList::iterator itPs = techniques.begin(); itPs != techniques.end(); ++itPs) - { - clone->techniques.push_back((*itPs)->Clone(clone)); - } - return clone; -} - -// Flatten this effect profile: trickling down all the parameters to the techniques -void FCDEffectProfileFX::Flatten() -{ - for (FCDEffectParameterList::iterator itP = parameters->begin(); itP != parameters->end(); ++itP) - { - FCDEffectParameterList generators; - if ((*itP)->IsModifier()) - { - // Overwrite the generators - FindParametersByReference((*itP)->GetReference(), generators); - for (FCDEffectParameterList::iterator itQ = generators.begin(); itQ != generators.end(); ++itQ) - { - if ((*itP) != (*itQ)) - { - (*itP)->Overwrite(*itQ); - } - } - } - else - { - // Add this parameter to the techniques - for (FCDEffectTechniqueList::iterator itT = techniques.begin(); itT != techniques.end(); ++itT) - { - (*itT)->AddParameter((*itP)->Clone()); - } - } - } - CLEAR_POINTER_VECTOR(*parameters); - - // Flatten the techniques - for (FCDEffectTechniqueList::iterator itT = techniques.begin(); itT != techniques.end(); ++itT) - { - (*itT)->Flatten(); - } -} - -// Read a node for a given COLLADA effect -// Note that this function should do most of the work, except for profile-specific states -FUStatus FCDEffectProfileFX::LoadFromXML(xmlNode* profileNode) -{ - FUStatus status; - - // Verify that we are given a valid XML input node. - const char* profileName = FUDaeProfileType::ToString(type); - if (!IsEquivalent(profileNode->name, profileName)) - { - return status.Warning(FS("Invalid profile input node for effect") + TO_FSTRING(GetDaeId()), profileNode->line); - } - - // Read in the target platform for this effect profile - platform = TO_FSTRING(ReadNodeProperty(profileNode, DAE_PLATFORM_ATTRIBUTE)); - - // Parse in the child elements: parameters and techniques - SAFE_DELETE(parameters); - parameters = new FCDEffectParameterList(GetDocument(), true); - - for (xmlNode* child = profileNode->children; child != NULL; child = child->next) - { - if (child->type != XML_ELEMENT_NODE) continue; - - if (IsEquivalent(child->name, DAE_TECHNIQUE_ELEMENT)) - { - FCDEffectTechnique* technique = AddTechnique(); - status.AppendStatus(technique->LoadFromXML(child, profileNode)); - } - else if (IsEquivalent(child->name, DAE_FXCMN_NEWPARAM_ELEMENT)) - { - AddParameter(FCDEffectParameterFactory::LoadFromXML(GetDocument(), child, &status)); - } - else if (IsEquivalent(child->name, DAE_FXCMN_CODE_ELEMENT) || IsEquivalent(child->name, DAE_FXCMN_INCLUDE_ELEMENT)) - { - FCDEffectCode* code = AddCode(); - status.AppendStatus(code->LoadFromXML(child)); - } - else if (IsEquivalent(child->name, DAE_IMAGE_ELEMENT)) - { - // You can create images within the ColladaFX profile: tell the image library about it. - FCDImage* image = GetDocument()->GetImageLibrary()->AddEntity(); - status.AppendStatus(image->LoadFromXML(child)); - } - } - - return status; -} - -xmlNode* FCDEffectProfileFX::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* profileNode = AddChild(parentNode, FUDaeProfileType::ToString(type)); - - // Write out the profile properties/base elements - if (!platform.empty()) AddAttribute(profileNode, DAE_PLATFORM_ATTRIBUTE, platform); - if (!includeFilename.empty()) AddChild(profileNode, DAE_FXCMN_INCLUDE_ELEMENT, includeFilename); - - // Write out the code/includes - for (FCDEffectCodeList::const_iterator itC = codes.begin(); itC != codes.end(); ++itC) - { - (*itC)->WriteToXML(profileNode); - } - - // Write out the parameters - for (FCDEffectParameterList::const_iterator itP = parameters->begin(); itP != parameters->end(); ++itP) - { - (*itP)->WriteToXML(profileNode); - } - - // Write out the techniques - for (FCDEffectTechniqueList::const_iterator itT = techniques.begin(); itT != techniques.end(); ++itT) - { - (*itT)->WriteToXML(profileNode); - } - - return profileNode; -} diff --git a/Extras/FCollada/FCDocument/FCDEffectProfileFX.h b/Extras/FCollada/FCDocument/FCDEffectProfileFX.h deleted file mode 100644 index f673aa8a5..000000000 --- a/Extras/FCollada/FCDocument/FCDEffectProfileFX.h +++ /dev/null @@ -1,219 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDEffectProfileFX.h - This file declares the FCDEffectProfileFX class. -*/ - -#ifndef _FCD_EFFECT_PROFILE_FX_H_ -#define _FCD_EFFECT_PROFILE_FX_H_ - -#include "FUtils/FUDaeEnum.h" -#include "FCDocument/FCDEffectProfile.h" - -class FCDocument; -class FCDEffect; -class FCDEffectCode; -class FCDEffectParameter; -class FCDEffectParameterSurface; -class FCDEffectTechnique; -class FCDEffectParameterList; - -typedef vector FCDEffectTechniqueList; /**< A dynamically-sized array of effect techniques. */ -typedef vector FCDEffectCodeList; /**< A dynamically-sized array of effect code inclusion. */ - -/** - A general effect profile description. - - The general effect profile contains all the information necessary - to implement the advanced effect profiles, such as CG, HLSL, GLSL and GLES. - Since these effect profiles contains extremely similar information, they - use the same description structure. For the COMMON profile, - see the FCDEffectStandard class. - - You should use the GetType function to figure out which profile this structure - addresses. You can then retrieve one or many of the FCDEffectTechnique objects - that describe how to render for this profile. You may want to check the - FCDEffectMaterialTechniqueHint objects at the FCDMaterial level, in order to - determine which technique(s) to use for your platform. At the profile - level of abstraction, parameters may be generated within the FCDEffectParamterList. - - @ingroup FCDEffect -*/ -class FCOLLADA_EXPORT FCDEffectProfileFX : public FCDEffectProfile -{ -private: - FUDaeProfileType::Type type; - string includeFilename; - fstring platform; - - FCDEffectCodeList codes; - FCDEffectTechniqueList techniques; - FCDEffectParameterList* parameters; - -public: - /** Constructor: do not use directly. Instead, use the FCDEffect::AddProfile function. - @param document The COLLADA document which owns the effect profile. - @param parent The effect which contains this profile. - @param type The type of profile. */ - FCDEffectProfileFX(FCDocument* document, FCDEffect* parent, FUDaeProfileType::Type type); - - /** Destructor: do not use directly. Instead, use the FCDEffect:RemoveProfile function. */ - virtual ~FCDEffectProfileFX(); - - /** Retrieves the profile type for this effect. - This function is a part of the FCDEffectProfile interface and allows you - to up-cast an effect profile pointer safely to this class. - @return The profile type. This should never be the value: 'COMMON', - but all other profiles currently derive from this class. */ - virtual FUDaeProfileType::Type GetType() const { return type; } - - /** @deprecated Retrieves the filename of the file that contains the code for this effect profile. - Instead, look through the FCDEffectCode object, using the GetCodeList function and retrieve - the correct object and its filename string. - @return The filename of the file to import. */ - const string& GetIncludeFilename() const { return includeFilename; } - - /** Retrieves the name of the platform in which to use the effect profile. - This parameter is very optional. - @return The platform name. */ - const fstring& GetPlatform() const { return platform; } - - /** Sets the name of the platform in which to use the effect profile. - This parameter is very optional. - @param _platform The platform name. */ - void SetPlatform(fstring& _platform) { platform = _platform; } - - /** Retrieves the list of techniques contained within this effect profile. - You may want to check the FCDEffectMaterialTechniqueHint objects at the FCDMaterial level, - in order to determine which technique(s) to use for your platform. - @return The list of inner techniques. */ - FCDEffectTechniqueList& GetTechniqueList() { return techniques; } - const FCDEffectTechniqueList& GetTechniqueList() const { return techniques; } /**< See above. */ - - /** Retrieves the number of techniques contained within this effect profile. - @return The number of inner techniques. */ - size_t GetTechniqueCount() const { return techniques.size(); } - - /** Retrieves a technique contained within this effect profile. - You may want to check the FCDEffectMaterialTechniqueHint objects at the FCDMaterial level, - in order to determine which technique(s) to use for your platform. - @param index The index of the technique. - @return The inner technique. This pointer will be NULL if the index is out-of-bounds. */ - FCDEffectTechnique* GetTechnique(size_t index) { FUAssert(index < GetTechniqueCount(), return NULL); return techniques.at(index); } - const FCDEffectTechnique* GetTechnique(size_t index) const { FUAssert(index < GetTechniqueCount(), return NULL); return techniques.at(index); } /**< See above. */ - - /** Adds a new technique to this effect profile. - @return The new technique object. */ - FCDEffectTechnique* AddTechnique(); - - /** Releases a technique contained within this effect profile. - @param technique The technique to release. */ - void ReleaseTechnique(FCDEffectTechnique* technique); - - /** Retrieves the list of code inclusions. - @return The list of code inclusions. */ - FCDEffectCodeList& GetCodeList() { return codes; } - const FCDEffectCodeList& GetCodeList() const { return codes; } /**< See above. */ - - /** Retrieves the number of code inclusions contained within the effect profile. - @return The number of code inclusions. */ - size_t GetCodeCount() const { return codes.size(); } - - /** Retrieves a code inclusion contained within the effect profile. - @param index The index of the code inclusion. - @return The code inclusion. This pointer will be NULL if the index is out-of-bounds. */ - FCDEffectCode* GetCode(size_t index) { FUAssert(index < GetCodeCount(), return NULL); return codes.at(index); } - const FCDEffectCode* GetCode(size_t index) const { FUAssert(index < GetCodeCount(), return NULL); return codes.at(index); } /**< See above. */ - - /** Retrieves the code inclusion with the given sub-id. - @param sid A COLLADA sub-id. - @return The code inclusion with the given sub-id. This pointer will be NULL, - if there are no code inclusions that match the given sub-id. */ - FCDEffectCode* FindCode(const string& sid); - const FCDEffectCode* FindCode(const string& sid) const; /**< See above. */ - - /** Adds a new code inclusion to this effect profile. - @return The new code inclusion. */ - FCDEffectCode* AddCode(); - - /** Releases a code inclusion contained within this effect profile. - @param code The code inclusion to release. */ - void ReleaseCode(FCDEffectCode* code); - - /** Retrieves the list of effect parameters contained within the effect profile. - At this level of abstraction, there should be only effect parameter generators. - @return The list of effect parameters. */ - FCDEffectParameterList* GetParameters() { return parameters; } - const FCDEffectParameterList* GetParameters() const { return parameters; } /**< See above. */ - - /** [INTERNAL] Inserts an existing parameter into the list of effect parameters - at this abstraction level. This function is used during the flattening of a material. - @param parameter The effect parameter to insert. */ - void AddParameter(FCDEffectParameter* parameter); - - /** Retrieves an effect parameter. - Looks for the effect parameter with the correct reference, in order to bind or override its value. - This function searches through the effect profile and the level of abstractions below. - @param reference The reference to match. In the case of effect parameter generators, - the sub-id is used to match. - @return The first effect parameter that matches the reference. - This pointer will be NULL if no effect parameter matches the given semantic. */ - const FCDEffectParameter* FindParameter(const char* reference) const; - - /** Retrieves an effect parameter. - Looks for the effect parameter with the correct semantic, in order to bind or override its value. - This function searches through the effect profile and the level of abstractions below. - @param semantic The effect parameter semantic to match. - @return The first effect parameter that matches the semantic. - This pointer will be NULL if no effect parameter matches the given semantic. */ - virtual FCDEffectParameter* FindParameterBySemantic(const string& semantic); - - /** Retrieves a subset of the effect parameter list. - Look for the effect parameter generators with the correct semantic. - This function searches through the effect profile and the level of abstractions below. - @param semantic The effect parameter semantic to match. - @param parameters The list of parameters to fill in. This list is not cleared. */ - virtual void FindParametersBySemantic(const string& semantic, FCDEffectParameterList& parameters); - - /** Retrieves a subset of the effect parameter list. - Look for the effect parameter generators with the correct reference. - This function searches through the effect profile and the level of abstractions below. - @param reference The effect parameter reference to match. In the case of effect - parameter generators, the reference is replaced by the sub-id. - @param parameters The list of parameters to fill in. This list is not cleared. */ - virtual void FindParametersByReference(const string& reference, FCDEffectParameterList& parameters); - - /** [INTERNAL] Clones the full effect profile. - @param newParent The effect that will contain the cloned profile. - @return The cloned profile. This pointer will never be NULL. */ - virtual FCDEffectProfile* Clone(FCDEffect* newParent); - - /** [INTERNAL] Flattens this effect profile. Pushes all the effect parameter overrides - into the effect parameter generators and moves all the parameters to the - effect technique level of abstraction. To flatten the material, use the - FCDMaterialInstance::FlattenMaterial function. */ - virtual void Flatten(); - - /** [INTERNAL] Reads in the effect profile from a given COLLADA XML tree node. - @param profileNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the effect profile.*/ - virtual FUStatus LoadFromXML(xmlNode* profileNode); - - /** [INTERNAL] Writes out the effect profile to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the material declaration. - @return The created element XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -#endif // _FCD_EFFECT_PROFILE_H_ diff --git a/Extras/FCollada/FCDocument/FCDEffectStandard.cpp b/Extras/FCollada/FCDocument/FCDEffectStandard.cpp deleted file mode 100644 index 0ba73edc7..000000000 --- a/Extras/FCollada/FCDocument/FCDEffectStandard.cpp +++ /dev/null @@ -1,572 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDAnimated.h" -#include "FCDocument/FCDEffect.h" -#include "FCDocument/FCDEffectStandard.h" -#include "FCDocument/FCDMaterial.h" -#include "FCDocument/FCDTexture.h" -#include "FUtils/FUDaeEnum.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -#include "FUtils/FUStringConversion.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDEffectStandard::FCDEffectStandard(FCDocument* document, FCDEffect* _parent) : FCDEffectProfile(document, _parent) -{ - emissionColor = translucencyColor = diffuseColor = ambientColor = specularColor = FMVector3::Origin; - reflectivityFactor = translucencyFactor = specularFactor = emissionFactor = 1.0f; - reflectivityColor = translucencyColor = FMVector3(1.0f, 1.0f, 1.0f); - shininess = 20.0f; - type = CONSTANT; - isWireframe = isFaceMap = isDoubleSided = isFaceted = isEmissionFactor = false; - textureBuckets = new FCDTextureList[FUDaeTextureChannel::COUNT]; -} - -FCDEffectStandard::~FCDEffectStandard() -{ - for (uint32 i = 0; i < FUDaeTextureChannel::COUNT; ++i) - { - FCDTextureList& t = textureBuckets[i]; - CLEAR_POINTER_VECTOR(t); - } - SAFE_DELETE_ARRAY(textureBuckets); -} - -// Retrieve one of the buckets -const FCDTextureList& FCDEffectStandard::GetTextureBucket(uint32 bucket) const -{ - if (bucket < FUDaeTextureChannel::COUNT) return textureBuckets[bucket]; - else return textureBuckets[FUDaeTextureChannel::FILTER]; // Because I think this one will almost always be empty. ;) -} - -// Adds a texture to a specific channel. -FCDTexture* FCDEffectStandard::AddTexture(uint32 bucket) -{ - FUAssert(bucket < FUDaeTextureChannel::COUNT, return NULL); - FCDTexture* texture = new FCDTexture(GetDocument()); - textureBuckets[bucket].push_back(texture); - return texture; -} - -// Releases a texture contained within this effect profile. -void FCDEffectStandard::ReleaseTexture(FCDTexture* texture) -{ - for (uint32 i = 0; i < FUDaeTextureChannel::COUNT; ++i) - { - FCDTextureList::iterator it = std::find(textureBuckets[i].begin(), textureBuckets[i].end(), texture); - if (it != textureBuckets[i].end()) - { - delete *it; - textureBuckets[i].erase(it); - break; - } - } -} - -// Calculate the opacity for this material -float FCDEffectStandard::GetOpacity() const -{ - return 1.0f - (translucencyColor.x + translucencyColor.y + translucencyColor.z) / 3.0f * translucencyFactor; -} - -// Calculate the overall reflectivity for this material -float FCDEffectStandard::GetReflectivity() const -{ - return (reflectivityColor.x + reflectivityColor.y + reflectivityColor.z) / 3.0f * reflectivityFactor; -} - -// Look for the effect parameter with the correct semantic, in order to bind/set its value -FCDEffectParameter* FCDEffectStandard::FindParameterBySemantic(const string& semantic) -{ - // Check only the texture buckets, for now. - for (uint32 i = 0; i < FUDaeTextureChannel::COUNT; ++i) - { - for (FCDTextureList::iterator itT = textureBuckets[i].begin(); itT != textureBuckets[i].end(); ++itT) - { - FCDEffectParameter* p = (*itT)->FindParameterBySemantic(semantic); - if (p != NULL) return p; - } - } - - return NULL; -} - -void FCDEffectStandard::FindParametersBySemantic(const string& semantic, FCDEffectParameterList& parameters) -{ - // Check only the texture buckets, for now. - for (uint32 i = 0; i < FUDaeTextureChannel::COUNT; ++i) - { - for (FCDTextureList::iterator itT = textureBuckets[i].begin(); itT != textureBuckets[i].end(); ++itT) - { - (*itT)->FindParametersBySemantic(semantic, parameters); - } - } -} - -void FCDEffectStandard::FindParametersByReference(const string& reference, FCDEffectParameterList& parameters) -{ - // Check only the texture buckets, for now. - for (uint32 i = 0; i < FUDaeTextureChannel::COUNT; ++i) - { - for (FCDTextureList::iterator itT = textureBuckets[i].begin(); itT != textureBuckets[i].end(); ++itT) - { - (*itT)->FindParametersByReference(reference, parameters); - } - } -} - -// Clone the standard effect -FCDEffectProfile* FCDEffectStandard::Clone(FCDEffect* newParent) -{ - FCDEffectStandard* clone = new FCDEffectStandard(GetDocument(), newParent); - clone->type = type; - for (uint32 i = 0; i < FUDaeTextureChannel::COUNT; ++i) - { - for (FCDTextureList::iterator itT = textureBuckets[i].begin(); itT != textureBuckets[i].end(); ++itT) - { - clone->textureBuckets[i].push_back((*itT)->Clone()); - } - } - -# define CLONE_ANIMATED_F(flt) clone->flt = flt; FCDAnimatedFloat::Clone(GetDocument(), &flt, &clone->flt); -# define CLONE_ANIMATED_C(flt) clone->flt = flt; FCDAnimatedColor::Clone(GetDocument(), &flt, &clone->flt); - - CLONE_ANIMATED_C(emissionColor); CLONE_ANIMATED_F(emissionFactor); clone->isEmissionFactor = isEmissionFactor; - CLONE_ANIMATED_C(translucencyColor); CLONE_ANIMATED_F(translucencyFactor); - CLONE_ANIMATED_C(diffuseColor); CLONE_ANIMATED_C(ambientColor); - CLONE_ANIMATED_C(specularColor); CLONE_ANIMATED_F(specularFactor); CLONE_ANIMATED_F(shininess); - CLONE_ANIMATED_C(reflectivityColor); CLONE_ANIMATED_F(reflectivityFactor); - clone->isFaceted = isFaceted; - clone->isDoubleSided = isDoubleSided; - clone->isWireframe = isWireframe; - clone->isFaceMap = isFaceMap; - -# undef CLONE_ANIMATED_F -# undef CLONE_ANIMATED_C - - return clone; -} - -// Read in a node from the COLLADA document -FUStatus FCDEffectStandard::LoadFromXML(xmlNode* baseNode) -{ - FUStatus status; - - // support is for COLLADA 1.3 backward compatibility - bool isCollada1_3 = IsEquivalent(baseNode->name, DAE_SHADER_ELEMENT); - if (!isCollada1_3 && !IsEquivalent(baseNode->name, DAE_FX_PROFILE_COMMON_ELEMENT)) - { - return status.Warning(FS("Unknown element as standard material base."), baseNode->line); - } - - // For COLLADA 1.3 backward compatibility: find the correct base node for the profile. - // While we're digging, find the node with the Max-specific parameters - xmlNode* maxParameterNode = NULL; - xmlNode* mayaParameterNode = NULL; - if (isCollada1_3) - { - // COLLADA 1.3 backward compatibility: the base node is - // and the Max-specific parameters are in . - xmlNode* commonTechniqueNode = FindTechnique(baseNode, DAE_COMMON_PROFILE); - xmlNode* maxTechniqueNode = FindTechnique(baseNode, DAEMAX_MAX_PROFILE); - baseNode = FindChildByType(commonTechniqueNode, DAE_PASS_ELEMENT); - xmlNode* maxPassNode = FindChildByType(maxTechniqueNode, DAE_PASS_ELEMENT); - maxParameterNode = FindChildByType(maxPassNode, DAE_PROGRAM_ELEMENT); - } - else - { - // Bump the base node up the first element - xmlNode* techniqueNode = FindChildByType(baseNode, DAE_TECHNIQUE_ELEMENT); - if (techniqueNode == NULL) - { - return status.Warning(FS("Expecting within the element for effect: ") + TO_FSTRING(GetDaeId()), baseNode->line); - } - baseNode = techniqueNode; - - // Look for an node for Max-specific parameter - xmlNode* extraNode = FindChildByType(baseNode, DAE_EXTRA_ELEMENT); - maxParameterNode = FindTechnique(extraNode, DAEMAX_MAX_PROFILE); - mayaParameterNode = FindTechnique(extraNode, DAEMAYA_MAYA_PROFILE); - } - - if (isCollada1_3) - { - // COLLADA 1.3 backward compatibility: look for elements pointing to textures - xmlNodeList textureInputNodes; - FindChildrenByType(baseNode, DAE_INPUT_ELEMENT, textureInputNodes); - for (xmlNodeList::iterator it = textureInputNodes.begin(); it != textureInputNodes.end(); ++it) - { - string semantic = ReadNodeSemantic(*it); - if (semantic != DAE_TEXTURE_INPUT) - { - status.Warning(FS("Unknown input semantic in material: ") + TO_FSTRING(GetDaeId()), (*it)->line); - continue; - } - - // Retrieve the texture and bucket it - string textureId = ReadNodeSource(*it); - FCDTexture* texture = GetDocument()->FindTexture(textureId); - if (texture != NULL) - { - uint32 channel = (uint32) texture->GetTextureChannel(); - textureBuckets[(uint32) channel].push_back(texture->Clone()); - } - else - { - status.Warning(FS("Unknown input texture '") + TO_FSTRING(textureId) + FS("' in material: ") + TO_FSTRING(GetDaeId()), (*it)->line); - } - } - } - - // Parse the material's program node and figure out the correct shader type - xmlNode* commonParameterNode = NULL; - if (isCollada1_3) - { - // COLLADA 1.3 backward compatibility: read in the type attribute of the node - commonParameterNode = FindChildByType(baseNode, DAE_PROGRAM_ELEMENT); - FUUri programUrl = ReadNodeUrl(commonParameterNode); - string materialType = FUStringConversion::ToString(programUrl.prefix); - if (materialType == DAE_CONSTANT_MATERIAL_PROGRAM) type = CONSTANT; - else if (materialType == DAE_LAMBERT_MATERIAL_PROGRAM) type = LAMBERT; - else if (materialType == DAE_PHONG_MATERIAL_PROGRAM) type = PHONG; - else - { - return status.Warning(FS("Unsupported shader program type: '") + programUrl.prefix + FS("' in material: ") + TO_FSTRING(GetDaeId()), commonParameterNode->line); - } - } - else - { - // Either , or are expected - for (commonParameterNode = baseNode->children; commonParameterNode != NULL; commonParameterNode = commonParameterNode->next) - { - if (commonParameterNode->type != XML_ELEMENT_NODE) continue; - if (IsEquivalent(commonParameterNode->name, DAE_FXSTD_CONSTANT_ELEMENT)) { type = CONSTANT; break; } - else if (IsEquivalent(commonParameterNode->name, DAE_FXSTD_LAMBERT_ELEMENT)) { type = LAMBERT; break; } - else if (IsEquivalent(commonParameterNode->name, DAE_FXSTD_PHONG_ELEMENT)) { type = PHONG; break; } - else if (IsEquivalent(commonParameterNode->name, DAE_FXSTD_BLINN_ELEMENT)) { type = BLINN; break; } - } - } - if (commonParameterNode == NULL) - { - return status.Fail(FS("Unable to find the program node for standard effect: ") + TO_FSTRING(GetDaeId()), baseNode->line); - } - - bool hasTranslucency = false, hasReflectivity = false; - FCDTextureList emptyBucket; - - // Read in the parameters for the common program types and apply them to the shader - StringList parameterNames; - xmlNodeList parameterNodes; - FindParameters(commonParameterNode, parameterNames, parameterNodes); - FindParameters(maxParameterNode, parameterNames, parameterNodes); - FindParameters(mayaParameterNode, parameterNames, parameterNodes); - size_t parameterCount = parameterNodes.size(); - for (size_t i = 0; i < parameterCount; ++i) - { - xmlNode* parameterNode = parameterNodes[i]; - const string& parameterName = parameterNames[i]; - const char* parameterContent = ReadNodeContentDirect(parameterNode); - if (parameterName == DAE_EMISSION_MATERIAL_PARAMETER || parameterName == DAE_EMISSION_MATERIAL_PARAMETER1_3) - { - status.AppendStatus(ParseColorTextureParameter(parameterNode, emissionColor, textureBuckets[FUDaeTextureChannel::EMISSION])); - } - else if (parameterName == DAE_DIFFUSE_MATERIAL_PARAMETER || parameterName == DAE_DIFFUSE_MATERIAL_PARAMETER1_3) - { - status.AppendStatus(ParseColorTextureParameter(parameterNode, diffuseColor, textureBuckets[FUDaeTextureChannel::DIFFUSE])); - } - else if (parameterName == DAE_AMBIENT_MATERIAL_PARAMETER || parameterName == DAE_AMBIENT_MATERIAL_PARAMETER1_3) - { - status.AppendStatus(ParseColorTextureParameter(parameterNode, ambientColor, textureBuckets[FUDaeTextureChannel::AMBIENT])); - } - else if (parameterName == DAE_TRANSPARENT_MATERIAL_PARAMETER || parameterName == DAE_TRANSPARENT_MATERIAL_PARAMETER1_3) - { - status.AppendStatus(ParseColorTextureParameter(parameterNode, translucencyColor, textureBuckets[FUDaeTextureChannel::TRANSPARENT])); - hasTranslucency = true; - } - else if (parameterName == DAE_TRANSPARENCY_MATERIAL_PARAMETER || parameterName == DAE_TRANSPARENCY_MATERIAL_PARAMETER1_3) - { - status.AppendStatus(ParseFloatTextureParameter(parameterNode, translucencyFactor, textureBuckets[FUDaeTextureChannel::OPACITY])); - hasTranslucency = true; - } - else if (parameterName == DAE_SPECULAR_MATERIAL_PARAMETER || parameterName == DAE_SPECULAR_MATERIAL_PARAMETER1_3) - { - status.AppendStatus(ParseColorTextureParameter(parameterNode, specularColor, textureBuckets[FUDaeTextureChannel::SPECULAR])); - } - else if (parameterName == DAE_SPECULAR_MATERIAL_PARAMETER || parameterName == DAE_SPECULAR_MATERIAL_PARAMETER1_3) - { - status.AppendStatus(ParseColorTextureParameter(parameterNode, specularColor, textureBuckets[FUDaeTextureChannel::SPECULAR])); - } - else if (parameterName == DAE_SHININESS_MATERIAL_PARAMETER || parameterName == DAE_SHININESS_MATERIAL_PARAMETER1_3) - { - status.AppendStatus(ParseFloatTextureParameter(parameterNode, shininess, textureBuckets[FUDaeTextureChannel::SHININESS])); - } - else if (parameterName == DAE_REFLECTIVE_MATERIAL_PARAMETER || parameterName == DAE_REFLECTIVE_MATERIAL_PARAMETER1_3) - { - status.AppendStatus(ParseColorTextureParameter(parameterNode, reflectivityColor, textureBuckets[FUDaeTextureChannel::REFLECTION])); - hasReflectivity = true; - } - else if (parameterName == DAE_REFLECTIVITY_MATERIAL_PARAMETER || parameterName == DAE_REFLECTIVITY_MATERIAL_PARAMETER1_3) - { - status.AppendStatus(ParseFloatTextureParameter(parameterNode, reflectivityFactor, emptyBucket)); - hasReflectivity = true; - } - else if (parameterName == DAE_BUMP_MATERIAL_PARAMETER) - { - status.AppendStatus(ParseSimpleTextureParameter(parameterNode, textureBuckets[FUDaeTextureChannel::BUMP])); - } - else if (parameterName == DAEMAX_SPECLEVEL_MATERIAL_PARAMETER || parameterName == DAEMAX_SPECLEVEL_MATERIAL_PARAMETER1_3) - { - status.AppendStatus(ParseFloatTextureParameter(parameterNode, specularFactor, textureBuckets[FUDaeTextureChannel::SPECULAR_LEVEL])); - } - else if (parameterName == DAEMAX_EMISSIONLEVEL_MATERIAL_PARAMETER || parameterName == DAEMAX_EMISSIONLEVEL_MATERIAL_PARAMETER1_3) - { - status.AppendStatus(ParseFloatTextureParameter(parameterNode, emissionFactor, textureBuckets[FUDaeTextureChannel::EMISSION])); - isEmissionFactor = true; - } - else if (parameterName == DAEMAX_FACETED_MATERIAL_PARAMETER || parameterName == DAEMAX_FACETED_MATERIAL_PARAMETER1_3) - { - isFaceted = FUStringConversion::ToBoolean(parameterContent); - } - else if (parameterName == DAESHD_DOUBLESIDED_PARAMETER) - { - isDoubleSided = FUStringConversion::ToBoolean(parameterContent); - } - else if (parameterName == DAEMAX_WIREFRAME_MATERIAL_PARAMETER) - { - isWireframe = FUStringConversion::ToBoolean(parameterContent); - } - else if (parameterName == DAEMAX_FACEMAP_MATERIAL_PARAMETER) - { - isFaceMap = FUStringConversion::ToBoolean(parameterContent); - } - else if (parameterName == DAEMAX_INDEXOFREFRACTION_MATERIAL_PARAMETER) - { - status.AppendStatus(ParseSimpleTextureParameter(parameterNode, textureBuckets[FUDaeTextureChannel::REFRACTION])); - } - else if (parameterName == DAEMAX_DISPLACEMENT_MATERIAL_PARAMETER) - { - status.AppendStatus(ParseSimpleTextureParameter(parameterNode, textureBuckets[FUDaeTextureChannel::DISPLACEMENT])); - } - else if (parameterName == DAEMAX_FILTERCOLOR_MATERIAL_PARAMETER) - { - status.AppendStatus(ParseSimpleTextureParameter(parameterNode, textureBuckets[FUDaeTextureChannel::FILTER])); - } - else - { - status.Warning(FS("Unknown parameter name for material ") + TO_FSTRING(GetDaeId()), parameterNode->line); - } - } - - bool isEmptyBucketEmpty = emptyBucket.empty(); - CLEAR_POINTER_VECTOR(emptyBucket); - if (!isEmptyBucketEmpty) - { - return status.Fail(FS("Unexpected texture sampler on some parameters for material ") + TO_FSTRING(GetDaeId()), baseNode->line); - } - - // Although the default COLLADA materials gives, wrongly, a transparent material, - // when neither the TRANSPARENT or TRANSPARENCY parameters are set, assume an opaque material. - // Similarly for reflectivity - if (!hasTranslucency) - { - translucencyColor = FMVector3::Origin; - translucencyFactor = 0.0f; - } - if (!hasReflectivity) - { - reflectivityColor = FMVector3::Origin; - reflectivityFactor = 0.0f; - } - - // Convert some of the values that may appear in different formats - if (!isEmissionFactor) - { - emissionFactor = (emissionColor.x + emissionColor.y + emissionColor.z) / 3.0f; - } - - return status; -} - -xmlNode* FCDEffectStandard::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* profileCommonNode = AddChild(parentNode, DAE_FX_PROFILE_COMMON_ELEMENT); - xmlNode* techniqueCommonNode = AddChild(profileCommonNode, DAE_TECHNIQUE_ELEMENT); - AddNodeSid(techniqueCommonNode, "common"); - - const char* materialName; - switch (type) - { - case CONSTANT: materialName = DAE_FXSTD_CONSTANT_ELEMENT; break; - case LAMBERT: materialName = DAE_FXSTD_LAMBERT_ELEMENT; break; - case PHONG: materialName = DAE_FXSTD_PHONG_ELEMENT; break; - case BLINN: materialName = DAE_FXSTD_BLINN_ELEMENT; break; - case UNKNOWN: - default: materialName = DAEERR_UNKNOWN_ELEMENT; break; - } - xmlNode* materialNode = AddChild(techniqueCommonNode, materialName); - xmlNode* techniqueNode = AddExtraTechniqueChild(techniqueCommonNode, DAEMAYA_MAYA_PROFILE); - - // Export the color/float parameters - FCDTextureList emptyBucket; float emptyValue = 0.0f; FMVector3 emptyColor; - WriteColorTextureParameterToXML(materialNode, DAE_EMISSION_MATERIAL_PARAMETER, emissionColor, textureBuckets[FUDaeTextureChannel::EMISSION]); - if (type != CONSTANT) - { - WriteColorTextureParameterToXML(materialNode, DAE_AMBIENT_MATERIAL_PARAMETER, emissionColor, textureBuckets[FUDaeTextureChannel::AMBIENT]); - WriteColorTextureParameterToXML(materialNode, DAE_DIFFUSE_MATERIAL_PARAMETER, diffuseColor, textureBuckets[FUDaeTextureChannel::DIFFUSE]); - if (type != LAMBERT) - { - WriteColorTextureParameterToXML(materialNode, DAE_SPECULAR_MATERIAL_PARAMETER, specularColor, textureBuckets[FUDaeTextureChannel::SPECULAR]); - WriteFloatTextureParameterToXML(materialNode, DAE_SHININESS_MATERIAL_PARAMETER, shininess, emptyBucket); - if (!textureBuckets[FUDaeTextureChannel::SHININESS].empty()) - { - WriteFloatTextureParameterToXML(techniqueNode, DAE_SHININESS_MATERIAL_PARAMETER, shininess, textureBuckets[FUDaeTextureChannel::SHININESS]); - WriteFloatTextureParameterToXML(techniqueNode, DAEMAX_SPECLEVEL_MATERIAL_PARAMETER, specularFactor, textureBuckets[FUDaeTextureChannel::SPECULAR_LEVEL]); - } - } - } - WriteColorTextureParameterToXML(materialNode, DAE_REFLECTIVE_MATERIAL_PARAMETER, reflectivityColor, textureBuckets[FUDaeTextureChannel::REFLECTION]); - WriteFloatTextureParameterToXML(materialNode, DAE_REFLECTIVITY_MATERIAL_PARAMETER, reflectivityFactor, emptyBucket); - - // Translucency includes both transparent and opacity textures - FCDTextureList translucencyBucket = textureBuckets[FUDaeTextureChannel::TRANSPARENT]; - translucencyBucket.insert(translucencyBucket.end(), textureBuckets[FUDaeTextureChannel::OPACITY].begin(), textureBuckets[FUDaeTextureChannel::OPACITY].end()); - WriteColorTextureParameterToXML(materialNode, DAE_TRANSPARENT_MATERIAL_PARAMETER, translucencyColor, translucencyBucket); - WriteFloatTextureParameterToXML(materialNode, DAE_TRANSPARENCY_MATERIAL_PARAMETER, translucencyFactor, emptyBucket); - WriteFloatTextureParameterToXML(materialNode, DAEMAX_INDEXOFREFRACTION_MATERIAL_PARAMETER, emptyValue, textureBuckets[FUDaeTextureChannel::REFRACTION]); - - // Non-COLLADA parameters - if (!textureBuckets[FUDaeTextureChannel::BUMP].empty()) - { - WriteFloatTextureParameterToXML(techniqueNode, DAE_BUMP_MATERIAL_PARAMETER, emptyValue, textureBuckets[FUDaeTextureChannel::BUMP]); - } - if (!textureBuckets[FUDaeTextureChannel::DISPLACEMENT].empty()) - { - WriteFloatTextureParameterToXML(techniqueNode, DAEMAX_DISPLACEMENT_MATERIAL_PARAMETER, emptyValue, textureBuckets[FUDaeTextureChannel::DISPLACEMENT]); - } - if (!textureBuckets[FUDaeTextureChannel::FILTER].empty()) - { - WriteColorTextureParameterToXML(techniqueNode, DAEMAX_FILTERCOLOR_MATERIAL_PARAMETER, emptyColor, textureBuckets[FUDaeTextureChannel::FILTER]); - } - - return profileCommonNode; -} - -xmlNode* FCDEffectStandard::WriteColorTextureParameterToXML(xmlNode* parentNode, const char* parameterNodeName, const FMVector3& value, const FCDTextureList& textureBucket) const -{ - xmlNode* parameterNode = AddChild(parentNode, parameterNodeName); - if (WriteTextureParameterToXML(parameterNode, textureBucket) == NULL) - { - // The color value expected by the profile_COMMON element has four floating-point values. - string colorValue = FUStringConversion::ToString(value) + " 1.0"; - xmlNode* valueNode = AddChild(parameterNode, DAE_FXSTD_COLOR_ELEMENT, colorValue); - GetDocument()->WriteAnimatedValueToXML(&value.x, valueNode, parameterNodeName); - } - return parameterNode; -} - -xmlNode* FCDEffectStandard::WriteFloatTextureParameterToXML(xmlNode* parentNode, const char* parameterNodeName, const float& value, const FCDTextureList& textureBucket) const -{ - xmlNode* parameterNode = AddChild(parentNode, parameterNodeName); - if (WriteTextureParameterToXML(parameterNode, textureBucket) == NULL) - { - xmlNode* valueNode = AddChild(parameterNode, DAE_FXSTD_FLOAT_ELEMENT, value); - GetDocument()->WriteAnimatedValueToXML(&value, valueNode, parameterNodeName); - } - return parameterNode; -} - -xmlNode* FCDEffectStandard::WriteTextureParameterToXML(xmlNode* parentNode, const FCDTextureList& textureBucket) const -{ - xmlNode* textureNode = NULL; - for (FCDTextureList::const_iterator itT = textureBucket.begin(); itT != textureBucket.end(); ++itT) - { - xmlNode* newTextureNode = (*itT)->WriteToXML(parentNode); - if (newTextureNode != NULL && textureNode == NULL) textureNode = newTextureNode; - } - return textureNode; -} - -// Parse in the different standard effect parameters, bucketing the textures -FUStatus FCDEffectStandard::ParseColorTextureParameter(xmlNode* parameterNode, FMVector3& value, FCDTextureList& textureBucket) -{ - FUStatus status; - - // Look for elements, they pre-empt everything else - size_t originalSize = textureBucket.size(); - ParseSimpleTextureParameter(parameterNode, textureBucket); - if (originalSize < textureBucket.size()) { value = FMVector3(1.0f, 1.0f, 1.0f); return status; } - - // Next, look for a element - // COLLADA 1.3 backward compatibility: also look for the color value directly inside the parameter node. - xmlNode* colorNode = FindChildByType(parameterNode, DAE_FXSTD_COLOR_ELEMENT); - const char* content = ReadNodeContentDirect(colorNode); - if (content == NULL || *content == 0) content = ReadNodeContentDirect(parameterNode); - - // Parse the color value and allow for an animation of it - value = FUStringConversion::ToPoint(content); - if (HasNodeProperty(colorNode, DAE_ID_ATTRIBUTE) || HasNodeProperty(colorNode, DAE_SID_ATTRIBUTE)) - FCDAnimatedColor::Create(GetDocument(), colorNode, &value); - else - FCDAnimatedColor::Create(GetDocument(), parameterNode, &value); - - return status; -} - -FUStatus FCDEffectStandard::ParseFloatTextureParameter(xmlNode* parameterNode, float& value, FCDTextureList& textureBucket) -{ - FUStatus status; - - // Look for elements, they pre-empt everything else - size_t originalSize = textureBucket.size(); - ParseSimpleTextureParameter(parameterNode, textureBucket); - if (originalSize < textureBucket.size()) { value = 1.0f; return status; } - - // Next, look for a element - // COLLADA 1.3 backward compatibility: also look for the value directly inside the parameter node. - xmlNode* floatNode = FindChildByType(parameterNode, DAE_FXSTD_FLOAT_ELEMENT); - const char* content = ReadNodeContentDirect(floatNode); - if (content == NULL || *content == 0) content = ReadNodeContentDirect(parameterNode); - - // Parse the value and register it for an animation. - value = FUStringConversion::ToFloat(content); - if (HasNodeProperty(floatNode, DAE_ID_ATTRIBUTE) || HasNodeProperty(floatNode, DAE_SID_ATTRIBUTE)) - FCDAnimatedFloat::Create(GetDocument(), floatNode, &value); - else - FCDAnimatedFloat::Create(GetDocument(), parameterNode, &value); - - - return status; -} - -FUStatus FCDEffectStandard::ParseSimpleTextureParameter(xmlNode* parameterNode, FCDTextureList& textureBucket) -{ - FUStatus status; - - // Parse in all the elements as standard effect samplers - xmlNodeList samplerNodes; - FindChildrenByType(parameterNode, DAE_FXSTD_SAMPLER_ELEMENT, samplerNodes); - if (!samplerNodes.empty()) - { - for (xmlNodeList::iterator itS = samplerNodes.begin(); itS != samplerNodes.end(); ++itS) - { - // Parse in the texture element and bucket them - FCDTexture* texture = new FCDTexture(GetDocument()); - status.AppendStatus(texture->LoadFromTextureXML(*itS)); - if (status) textureBucket.push_back(texture); - else { SAFE_DELETE(texture); } - } - } - return status; -} diff --git a/Extras/FCollada/FCDocument/FCDEffectStandard.h b/Extras/FCollada/FCDocument/FCDEffectStandard.h deleted file mode 100644 index eca2f16f3..000000000 --- a/Extras/FCollada/FCDocument/FCDEffectStandard.h +++ /dev/null @@ -1,415 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDEffectStandard.h - This file contains the FCDEffectStandard class. -*/ - -#ifndef _FCD_MATERIAL_STANDARD_H_ -#define _FCD_MATERIAL_STANDARD_H_ - -#include "FUtils/FUDaeEnum.h" -#include "FCDocument/FCDEffectProfile.h" - -class FCDocument; -class FCDEffect; -class FCDEffectParameter; -class FCDTexture; -class FCDEffectParameterList; - -/** A dynamically-sized array of texture objects. */ -typedef vector FCDTextureList; - -/** - A COMMON profile effect description. - - The COMMON effect profile holds the information necessary - to render your polygon sets using the well-defined lighting models. - - COLLADA supports four lighting models: constant, Lambert, Phong and Blinn. - - @ingroup FCDEffect -*/ -class FCOLLADA_EXPORT FCDEffectStandard : public FCDEffectProfile -{ -public: - /** The list of the lighting models supported by the COMMON profile of COLLADA. */ - enum LightingType - { - /** The constant lighting model. - This lighting model uses the emissive color everywhere, without - any complex lighting calculations. It also uses the translucency - factor and the translucency color, by multiplying them together - and applying them to your standard alpha channel according to the - final lighting color.*/ - CONSTANT, - - /** The Lambert lighting model. - This lighting model improves on the constant lighting model by - using the dot-product between the normalized light vectors and the - polygon normals to determine how much light should affect each polygon. - This value is multiplied to the diffuse color and (1 + the ambient color). */ - LAMBERT, - - /** The Phong lighting model. - This lighting model improves on the Lambert lighting model by - calculating how much light is reflected by the polygons into the viewer's eye. - For this calculation, the shininess, the specular color and the reflectivity is used. */ - PHONG, - - /** The Blinn lighting model. - This lighting model improves on the Lambert lighting model by - calculating how much light is reflected by the polygons into the viewer's eye. - For this calculation, the shininess, the specular color and the reflectivity is used. */ - BLINN, - - /** Not a valid lighting model. */ - UNKNOWN - }; - -private: - LightingType type; - FCDTextureList* textureBuckets; - - // Common material parameter: Emission - FMVector3 emissionColor; - float emissionFactor; // Max-specific - - // Common material parameter: Translucency - FMVector3 translucencyColor; - float translucencyFactor; - - // Lambert material parameters - FMVector3 diffuseColor; - FMVector3 ambientColor; - - // Phong material parameters: Specular - FMVector3 specularColor; - float specularFactor; // Max-specific - float shininess; - - // Phong material parameter: Reflectivity - FMVector3 reflectivityColor; // Maya-specific - float reflectivityFactor; // Maya-specific - - // Geometry modifier - bool isFaceted; // Max-specific - bool isDoubleSided; // Max-specific for now - bool isWireframe; // Max-specific - bool isFaceMap; // Max-specific - bool isEmissionFactor; // Max-specific - -public: - /** Constructor: do not use directly. Instead, use the FCDEffect::AddProfile function - with the FUDaeProfileType::COMMON parameter. - @param document The COLLADA document that owns this effect profile. - @param parent The effect that contains this profile. */ - FCDEffectStandard(FCDocument* document, FCDEffect* parent); - - /** Destructor: do not use directly. - Instead, use the FCDEffect::ReleaseProfile function. */ - virtual ~FCDEffectStandard(); - - /** Retrieves the lighting model to be used for this profile. - @return The lighting model. */ - inline LightingType GetLightingType() const { return type; } - - /** Sets the lighting model to be used for this profile. - Note that which parameters are exported depends on the lighting model. - @param _type The lighting model. */ - inline void SetLightingType(LightingType _type) { type = _type; } - - /** Retrieves the profile type for this effect. - This function is a part of the FCDEffectProfile interface and allows you - to up-cast an effect profile pointer safely to this class. - @return The profile type: COMMON. */ - virtual FUDaeProfileType::Type GetType() const { return FUDaeProfileType::COMMON; } - - /** Retrieves the list of textures belonging to a specific channel. - @param bucket A texture channel index. This index should match one - of the values in the FUDaeTextureChannel enum. - @return The list of textures for this channel. */ - const FCDTextureList& GetTextureBucket(uint32 bucket) const; - - /** Retrieves the number of textures belonging to a specific channel. - @param bucket A texture channel index. This index should match one - of the values in the FUDaeTextureChannel enum. - @return The number of textures in that channel. */ - size_t GetTextureCount(uint32 bucket) const { FUAssert(bucket < FUDaeTextureChannel::COUNT, return 0); return textureBuckets[bucket].size(); } - - /** Retrieves a texture - @param bucket A texture channel index. This index should match one - of the values in the FUDaeTextureChannel enum. - @param index The index of a texture within this channel. - @return The texture. This pointer will be NULL if either the bucket or the index is out-of-bounds. */ - inline FCDTexture* GetTexture(uint32 bucket, size_t index) { FUAssert(index < GetTextureCount(bucket), return NULL); return textureBuckets[bucket].at(index); } - inline const FCDTexture* GetTexture(uint32 bucket, size_t index) const { FUAssert(index < GetTextureCount(bucket), return NULL); return textureBuckets[bucket].at(index); } /**< See above. */ - - /** Adds a texture to a specific channel. - @param bucket A texture channel index. This index should match one - of the values in the FUDaeTextureChannel enum. - @return The new texture. This pointer will be NULL if the bucket is out-of-bounds. */ - FCDTexture* AddTexture(uint32 bucket); - - /** Releases a texture contained within this effect profile. - @param texture The texture to release. */ - void ReleaseTexture(FCDTexture* texture); - - /** Retrieves the base translucency color. - This value must be multiplied with the translucency factor - to get the real translucency color. - This value is used in all lighting models. - @return The base translucency color. */ - inline const FMVector3& GetTranslucencyColor() const { return translucencyColor; } - - /** Sets the base translucency color. - @param color The base translucency color. */ - inline void SetTranslucencyColor(const FMVector3& color) { translucencyColor = color; } - - /** Retrieves the translucency factor. - This value must be multiplied with the translucency color - to get the real translucency color. - This value is used in all lighting models. - @return The translucency factor. */ - inline const float& GetTranslucencyFactor() const { return translucencyFactor; } - - /** Sets the translucency factor. - @param factor The translucency factor. */ - inline void SetTranslucencyFactor(float factor) { translucencyFactor = factor; } - - /** Retrieves the flat opacity. - This is a calculated value and will not take into consideration any animations - that affect either the base translucency color or the translucency factor. - This value can be used in all lighting models. - @return The flat opacity. */ - float GetOpacity() const; - - /** Retrieves the base emission/self-illumination color. - This value must be multiplied with the emission factor to get the real emission color. - This value is used in all lighting models. - @return The base emission color. */ - inline const FMVector3& GetEmissionColor() const { return emissionColor; } - - /** Sets the base emission/self-illumination color. - @param color The base emission color. */ - inline void SetEmissionColor(const FMVector3& color) { emissionColor = color; } - - /** Retrieves the emission/self-illumination factor. - This value must be multiplied with the base emission color to get the real emission color. - @return The emission factor. */ - inline const float& GetEmissionFactor() const { return emissionFactor; } - - /** Sets the emission/self-illumination factor. - @param factor The emission factor. */ - inline void SetEmissionFactor(float factor) { emissionFactor = factor; } - - /** Retrieves whether the emission factor was used, rather than the emission color. - This value is used in conjunction with 3dsMax, in which the self-illumination color - and the self-illumination factor are mutually exclusive. - @return Whether the emission factor is to be used. */ - inline bool IsEmissionFactor() const { return isEmissionFactor; } - - /** Sets whether the emission factor is to be used, rather than the emission color. - This value is used in conjunction with 3dsMax, in which the self-illumination color - and the self-illumination factor are mutually exclusive. - @param useFactor Whether the emission factor should be used. */ - inline void SetIsEmissionFactor(bool useFactor) { isEmissionFactor = useFactor; } - - /** Retrieves the diffuse color. - This value is used in the Lambert lighting model. - @return The diffuse color. */ - inline const FMVector3& GetDiffuseColor() const { return diffuseColor; } - - /** Sets the diffuse color. - @param color The diffuse color. */ - inline void SetDiffuseColor(const FMVector3& color) { diffuseColor = color; } - - /** Retrieves the ambient color. - This value is used in the Lambert lighting model. - @return The ambient color. */ - inline const FMVector3& GetAmbientColor() const { return ambientColor; } - - /** Sets the ambient color. - @param color The ambient color. */ - inline void SetAmbientColor(const FMVector3& color) { ambientColor = color; } - - /** Retrieves the base specular color. - This value must be multiplied with the specular factor - to get the real specular color. - This value is used in the Phong and Blinn lighting models. - @return The specular color. */ - inline const FMVector3& GetSpecularColor() const { return specularColor; } - - /** Sets the specular color. - @param color The specular color. */ - inline void SetSpecularColor(const FMVector3& color) { specularColor = color; } - - /** Retrieves the specular factor. - This value must be multiplied with the base specular color - to get the real specular color. - This value is used in the Phong and Blinn lighting models. - @return The specular factor. */ - inline const float& GetSpecularFactor() const { return specularFactor; } - - /** Sets the specular factor. - @param factor The specular factor. */ - inline void SetSpecularFactor(float factor) { specularFactor = factor; } - - /** Retrieves the specular shininess. - This value represents the exponent to which you must raise - the dot-product between the view vector and reflected light vectors: - as such, it is usually a number greater than 1. - This value is used in the Phong and Blinn lighting models. - @return The specular shininess. */ - inline const float& GetShininess() const { return shininess; } - - /** Sets the specular shininess. - This value represents the exponent to which you must raise - the dot-product between the view vector and reflected light vectors: - as such, it is usually a number greater than 1. - @param _shininess The specular shininess. */ - inline void SetShininess(float _shininess) { shininess = _shininess; } - - /** Retrieves the base reflectivity color. - This value must be multiplied to the reflectivity factor to - get the real reflectivity color. - This value is used in the Phong and Blinn lighting models. - @return The base reflectivity color. */ - inline const FMVector3& GetReflectivityColor() const { return reflectivityColor; } - - /** Sets the base reflectivity color. - @param color The base reflectivity color. */ - inline void SetReflectivityColor(const FMVector3& color) { reflectivityColor = color; } - - /** Retrieves the reflectivity factor. - This value must be multiplied to the base reflectivity color - to get the real reflectivity color. - This value is used in the Phong and Blinn lighting models. - @return The reflectivity factor. */ - inline const float& GetReflectivityFactor() const { return reflectivityFactor; } - - /** Sets the reflectivity factor. - @param factor The reflectivity factor. */ - inline void SetReflectivityFactor(float factor) { reflectivityFactor = factor; } - - /** Retrieves the flat reflectivity. - This is a calculated value and will not take into consideration any animations - that affect either the base reflectivity color or the reflectivity factor. - This value can be used in the Phong and Blinn lighting models. - @return The flat reflectivity. */ - float GetReflectivity() const; - - /** Retrieves the 'faceted' flag. - This flag is used in conjunction with 3dsMax. It represents whether all the edges - of the polygon sets using this effect profile should be hard. The final result - of using this flag is a mesh where all the faces stand out. - @return The status of the 'faceted' flag. */ - inline bool GetFacetedFlag() const { return isFaceted; } - - /** Sets the 'faceted' flag. - This flag is used in conjunction with 3dsMax. It represents whether all the edges - of the polygon sets using this effect profile should be hard. The final result - of using this flag is a mesh where all the faces stand out. - @param flag The status of the 'faceted' flag. */ - inline void SetFacetedFlag(bool flag) { isFaceted = flag; } - - /** Retrieves the 'double-sided' flag. - This flag is used in conjunction with 3dsMax. It represents whether all the faces - of the polygon sets should be treated as two-sided and have normals in both directions. - @return The status of the 'double-sided' flag. */ - inline bool GetDoubleSidedFlag() const { return isDoubleSided; } - - /** Sets the 'double-sided' flag. - This flag is used in conjunction with 3dsMax. It represents whether all the faces - of the polygon sets should be treated as two-sided and have normals in both directions. - @param flag The status of the 'double-sided' flag. */ - inline bool SetDoubleSidedFlag(bool flag) { isDoubleSided = flag; } - - /** Retrieves the 'wireframe' flag. - This flag is used in conjunction with 3dsMax. It represents whether all the edges - of the polygon sets should be rendered, rather than the faces. - @return The status of the 'wireframe' flag. */ - inline bool GetWireframeFlag() const { return isWireframe; } - - /** Sets the 'wireframe' flag. - This flag is used in conjunction with 3dsMax. It represents whether all the edges - of the polygon sets should be rendered, rather than the faces. - @param flag The status of the 'wireframe' flag. */ - inline bool SetWireframeFlag(bool flag) { isWireframe = flag; } - - /** Retrieves the 'face-map' flag. - This is a pure 3dsMax flag and I have no idea what it does. - @return The status of the 'face-map' flag. */ - inline bool GetFaceMapFlag() const { return isFaceMap; } - - /** Sets the 'face-map' flag. - This is a pure 3dsMax flag and I have no idea what it does. - @param flag The status of the 'face-map' flag. */ - inline void SetFaceMapFlag(bool flag) { isFaceMap = flag; } - - /** Retrieves an effect parameter. - Looks for the effect parameter with the correct semantic, in order to bind or override its value. - This function searches through the effect profile and the level of abstractions below. - @param semantic The effect parameter semantic to match. - @return The effect parameter that matches the semantic. This pointer may be - NULL if no effect parameter matches the given semantic. */ - virtual FCDEffectParameter* FindParameterBySemantic(const string& semantic); - - /** Retrieves a subset of the effect parameter list. - Look for effect parameters with the correct semantic. - This function searches through the effect profile and the level of abstractions below. - @param semantic The effect parameter semantic to match. - @param parameters The list of parameters to fill in. This list is not cleared. */ - virtual void FindParametersBySemantic(const string& semantic, FCDEffectParameterList& parameters); - - /** Retrieves a subset of the effect parameter list. - Look for effect parameters with the correct reference. - This function searches through the effect profile and the level of abstractions below. - @param reference The effect parameter reference to match. In the case of effect - parameter, the reference is replaced by the sub-id. - @param parameters The list of parameters to fill in. This list is not cleared. */ - virtual void FindParametersByReference(const string& reference, FCDEffectParameterList& parameters); - - /** [INTERNAL] Clones the COMMON profile effect. - You will need release the cloned effect directly, by deleting the pointer. - @param newParent The effect that contains the cloned effect profile. - @return The cloned effect profile. You will must delete this pointer. */ - virtual FCDEffectProfile* Clone(FCDEffect* newParent); - - /** [INTERNAL] Flattens the profile. - Does nothing on the common profile. */ - virtual void Flatten() {} - - /** [INTERNAL] Reads in the \ element from a given COLLADA XML tree node. - For COLLADA 1.3 backward-compatibility, this function can also read in \ elements. - @param baseNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the effect profile.*/ - virtual FUStatus LoadFromXML(xmlNode* baseNode); - - /** [INTERNAL] Writes out the \ element to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the effect profile. - @return The created element XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; - -private: - xmlNode* WriteColorTextureParameterToXML(xmlNode* parentNode, const char* parameterNodeName, const FMVector3& value, const FCDTextureList& textureBucket) const; - xmlNode* WriteFloatTextureParameterToXML(xmlNode* parentNode, const char* parameterNodeName, const float& value, const FCDTextureList& textureBucket) const; - xmlNode* WriteTextureParameterToXML(xmlNode* parentNode, const FCDTextureList& textureBucket) const; - - FUStatus ParseColorTextureParameter(xmlNode* parameterNode, FMVector3& value, FCDTextureList& textureBucket); - FUStatus ParseFloatTextureParameter(xmlNode* parameterNode, float& value, FCDTextureList& textureBucket); - FUStatus ParseSimpleTextureParameter(xmlNode* parameterNode, FCDTextureList& textureBucket); -}; - -#endif //_FCD_MATERIAL_STANDARD_H_ - diff --git a/Extras/FCollada/FCDocument/FCDEffectTechnique.cpp b/Extras/FCollada/FCDocument/FCDEffectTechnique.cpp deleted file mode 100644 index 4cfa510e5..000000000 --- a/Extras/FCollada/FCDocument/FCDEffectTechnique.cpp +++ /dev/null @@ -1,254 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDEffectCode.h" -#include "FCDocument/FCDEffectPass.h" -#include "FCDocument/FCDEffectProfileFX.h" -#include "FCDocument/FCDEffectParameter.h" -#include "FCDocument/FCDEffectParameterFactory.h" -#include "FCDocument/FCDEffectParameterList.h" -#include "FCDocument/FCDEffectTechnique.h" -#include "FCDocument/FCDLibrary.h" -#include "FCDocument/FCDImage.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDEffectTechnique::FCDEffectTechnique(FCDocument* document, FCDEffectProfileFX *_parent) : FCDObject(document, "FCDEffectTechnique") -{ - parent = _parent; - parameters = new FCDEffectParameterList(GetDocument(), true);; -} - -FCDEffectTechnique::~FCDEffectTechnique() -{ - CLEAR_POINTER_VECTOR(codes); - CLEAR_POINTER_VECTOR(passes); - SAFE_DELETE(parameters); - parent = NULL; -} - -// Adds a new pass to this effect technique. -FCDEffectPass* FCDEffectTechnique::AddPass() -{ - FCDEffectPass* pass = new FCDEffectPass(GetDocument(), this); - passes.push_back(pass); - return pass; -} - -// Releases a pass contaied within this effect technique. -void FCDEffectTechnique::ReleasePass(FCDEffectPass* pass) -{ - FCDEffectPassList::iterator it = std::find(passes.begin(), passes.end(), pass); - if (it != passes.end()) - { - delete *it; - passes.erase(it); - } -} - -// Adds a new code inclusion to this effect profile. -FCDEffectCode* FCDEffectTechnique::AddCode() -{ - FCDEffectCode* code = new FCDEffectCode(GetDocument()); - codes.push_back(code); - return code; -} - -// Releases a code inclusion contained within this effect profile. -void FCDEffectTechnique::ReleaseCode(FCDEffectCode* code) -{ - FCDEffectCodeList::iterator itC = std::find(codes.begin(), codes.end(), code); - if (itC != codes.end()) - { - delete *itC; - codes.erase(itC); - } -} - -FCDEffectTechnique* FCDEffectTechnique::Clone(FCDEffectProfileFX* newParent) -{ - FCDEffectTechnique* clone = new FCDEffectTechnique(GetDocument(), newParent); - clone->name = name; - SAFE_DELETE(clone->parameters); - clone->parameters = parameters->Clone(); - - // Clone the codes: need to happen before the passes are cloned - clone->codes.reserve(codes.size()); - for (FCDEffectCodeList::const_iterator itC = codes.begin(); itC != codes.end(); ++itC) - { - clone->codes.push_back((*itC)->Clone()); - } - - // Clone the passes - for (FCDEffectPassList::iterator itP = passes.begin(); itP != passes.end(); ++itP) - { - clone->passes.push_back((*itP)->Clone(clone)); - } - return clone; -} - -const string& FCDEffectTechnique::GetDaeId() const -{ - return parent->GetDaeId(); -} - -void FCDEffectTechnique::AddParameter(FCDEffectParameter* parameter) -{ - parameters->push_back(parameter); -} - -// Flatten this effect technique: merge the parameter modifiers and generators -void FCDEffectTechnique::Flatten() -{ - for (FCDEffectParameterList::iterator itP = parameters->begin(); itP != parameters->end();) - { - FCDEffectParameterList generators(GetDocument()); - if ((*itP)->IsModifier()) - { - // Overwrite the generators - FindParametersByReference((*itP)->GetReference(), generators); - for (FCDEffectParameterList::iterator itQ = generators.begin(); itQ != generators.end(); ++itQ) - { - if ((*itQ)->IsGenerator()) - { - (*itP)->Overwrite(*itQ); - } - } - SAFE_DELETE(*itP); - parameters->erase(itP); - } - else - { - ++itP; - } - } -} - -FUStatus FCDEffectTechnique::LoadFromXML(xmlNode* techniqueNode, xmlNode* profileNode) -{ - FUStatus status; - if (!IsEquivalent(techniqueNode->name, DAE_TECHNIQUE_ELEMENT)) - { - return status.Warning(FS("Technique contains unknown element."), techniqueNode->line); - } - - string techniqueName = ReadNodeProperty(techniqueNode, DAE_SID_ATTRIBUTE); - name = TO_FSTRING(techniqueName); - - // Look for the pass and parameter elements - SAFE_DELETE(parameters); - parameters = new FCDEffectParameterList(GetDocument(), true); - for (xmlNode* child = techniqueNode->children; child != NULL; child = child->next) - { - if (child->type != XML_ELEMENT_NODE) continue; - - if (IsEquivalent(child->name, DAE_PASS_ELEMENT)) - { - FCDEffectPass* pass = AddPass(); - status.AppendStatus(pass->LoadFromXML(child, techniqueNode, profileNode)); - } - else if (IsEquivalent(child->name, DAE_FXCMN_NEWPARAM_ELEMENT) || IsEquivalent(child->name, DAE_FXCMN_SETPARAM_ELEMENT)) - { - AddParameter(FCDEffectParameterFactory::LoadFromXML(GetDocument(), child, &status)); - } - else if (IsEquivalent(child->name, DAE_FXCMN_CODE_ELEMENT) || IsEquivalent(child->name, DAE_FXCMN_INCLUDE_ELEMENT)) - { - FCDEffectCode* code = new FCDEffectCode(GetDocument()); - codes.push_back(code); - status.AppendStatus(code->LoadFromXML(child)); - } - else if (IsEquivalent(child->name, DAE_IMAGE_ELEMENT)) - { - FCDImage* image = GetDocument()->GetImageLibrary()->AddEntity(); - status.AppendStatus(image->LoadFromXML(child)); - } - } - - return status; -} - -// Write out the effect techniques to the COLLADA xml node tree -xmlNode* FCDEffectTechnique::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* techniqueNode = AddChild(parentNode, DAE_TECHNIQUE_ELEMENT); - const_cast(this)->name = TO_FSTRING(AddNodeSid(techniqueNode, !name.empty() ? TO_STRING(name).c_str() : "common")); - - // Write out the code/includes - for (FCDEffectCodeList::const_iterator itC = codes.begin(); itC != codes.end(); ++itC) - { - (*itC)->WriteToXML(techniqueNode); - } - - // Write out the effect parameters at this level - for (FCDEffectParameterList::const_iterator itP = parameters->begin(); itP != parameters->end(); ++itP) - { - (*itP)->WriteToXML(techniqueNode); - } - - // Write out the passes. - // In COLLADA 1.4: there should always be at least one pass. - if (!passes.empty()) - { - for (FCDEffectPassList::const_iterator itP = passes.begin(); itP != passes.end(); ++itP) - { - (*itP)->WriteToXML(techniqueNode); - } - } - else - { - UNUSED(xmlNode* dummyPassNode =) AddChild(techniqueNode, DAE_PASS_ELEMENT); - } - - return techniqueNode; -} - -// Look for the parameter with the given reference. -const FCDEffectParameter* FCDEffectTechnique::FindParameter(const char* ref) const -{ - return parameters->FindReference(ref); -} - -// Look for the effect parameter with the correct semantic, in order to bind/set its value -FCDEffectParameter* FCDEffectTechnique::FindParameterBySemantic(const string& semantic) -{ - return parameters->FindSemantic(semantic); -} - -void FCDEffectTechnique::FindParametersBySemantic(const string& semantic, FCDEffectParameterList& _parameters) -{ - for (FCDEffectParameterList::iterator it = parameters->begin(); it != parameters->end(); ++it) - { - if ((*it)->GetSemantic() == semantic) _parameters.push_back(*it); - } -} - -void FCDEffectTechnique::FindParametersByReference(const string& reference, FCDEffectParameterList& _parameters) -{ - for (FCDEffectParameterList::iterator it = parameters->begin(); it != parameters->end(); ++it) - { - if ((*it)->GetReference() == reference) _parameters.push_back(*it); - } -} - -FCDEffectCode* FCDEffectTechnique::FindCode(const string& sid) -{ - for (FCDEffectCodeList::iterator itC = codes.begin(); itC != codes.end(); ++itC) - { - if ((*itC)->GetSid() == sid) return (*itC); - } - return NULL; -} -const FCDEffectCode* FCDEffectTechnique::FindCode(const string& sid) const -{ - for (FCDEffectCodeList::const_iterator itC = codes.begin(); itC != codes.end(); ++itC) - { - if ((*itC)->GetSid() == sid) return (*itC); - } - return NULL; -} diff --git a/Extras/FCollada/FCDocument/FCDEffectTechnique.h b/Extras/FCollada/FCDocument/FCDEffectTechnique.h deleted file mode 100644 index c3b260802..000000000 --- a/Extras/FCollada/FCDocument/FCDEffectTechnique.h +++ /dev/null @@ -1,195 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDEffectTechnique.h - This file declares the FCDEffectTechnique class. -*/ - -#ifndef _FCD_EFFECT_TECHNIQUE_H_ -#define _FCD_EFFECT_TECHNIQUE_H_ - -#include "FCDocument/FCDObject.h" - -class FCDEffectCode; -class FCDEffectPass; -class FCDEffectParameter; -class FCDEffectParameterList; -class FCDEffectProfileFX; - -typedef vector FCDEffectPassList; /**< A dynamically-sized array of effect passes. */ -typedef vector FCDEffectCodeList; /**< A dynamically-sized array of effect code inclusions. */ - -/** - A COLLADA effect technique. - - The COLLADA effect technique contains the passes to be used in the rendering of - polygon sets. - - It also contains a list of effect parameters: both generators and overrides - and it is the lowest level of abstraction in which you can access effect parameters. For - flattened materials, this means that all the effect parameters will be accessible at this level. - - It also contains a list of effect code inclusions. - - @ingroup FCDEffect -*/ -class FCOLLADA_EXPORT FCDEffectTechnique : public FCDObject -{ -private: - FCDEffectProfileFX* parent; - - fstring name; - FCDEffectCodeList codes; - FCDEffectPassList passes; - FCDEffectParameterList* parameters; - -public: - /** Constructor: do not use directly. - Instead, use the FCDEffectProfileFX::AddTechnique function. - @param document The COLLADA document which owns this technique. - @param _parent The effect profile which contains the technique. */ - FCDEffectTechnique(FCDocument* document, FCDEffectProfileFX *_parent); - - /** Destructor: do not use directly. - Instead, use the FCDEffectProfileFX::ReleaseTechnique function. */ - virtual ~FCDEffectTechnique(); - - /** Retrieves the effect profile that contains this technique. - @return The parent effect profile. */ - FCDEffectProfileFX* GetParent() { return parent; } - const FCDEffectProfileFX* GetParent() const { return parent; } /**< See above. */ - - /** Retrieves the COLLADA id of the parent effect. - This function is mostly useful as a shortcut for debugging and reporting. - @return The COLLADA id of the parent effect. */ - const string& GetDaeId() const; - - /** Retrieves the sub-id of the technique. - @return The sub-id of the technique. */ - const fstring& GetName() const { return name; } - - /** Sets the sub-id of the technique. - The effect technique must have a valid sub-id that is unique - within its scope. Otherwise, one will be provided on XML export. - @param _name A valid sub-id. */ - void SetName(const fstring& _name) { name = _name; } - - /** Retrieves the list of passes. - @return The list of passes. */ - FCDEffectPassList& GetPassList() { return passes; } - const FCDEffectPassList& GetPassList() const { return passes; } /**< See above. */ - - /** Retrieves the number of passes contained within this effect technique. - @return The number of passes. */ - size_t GetPassCount() const { return passes.size(); } - - /** Retrieves a specific pass contained within this effect technique. - @param index The index of the pass. - @return The pass. This pointer will be NULL if the index is out-of-bounds. */ - FCDEffectPass* GetPass(size_t index) { FUAssert(index < GetPassCount(), return NULL); return passes.at(index); } - const FCDEffectPass* GetPass(size_t index) const { FUAssert(index < GetPassCount(), return NULL); return passes.at(index); } /**< See above. */ - - /** Adds a new pass to this effect technique. - @return The new pass. */ - FCDEffectPass* AddPass(); - - /** Releases a pass contaied within this effect technique. - @param pass The pass to release. */ - void ReleasePass(FCDEffectPass* pass); - - /** Retrieves the list of code inclusions. - @return The list of code inclusions. */ - FCDEffectCodeList& GetCodeList() { return codes; } - const FCDEffectCodeList& GetCodeList() const { return codes; } /**< See above. */ - - /** Retrieves the number of code inclusions contained within the effect profile. - @return The number of code inclusions. */ - size_t GetCodeCount() const { return codes.size(); } - - /** Retrieves a code inclusion contained within the effect profile. - @param index The index of the code inclusion. - @return The code inclusion. This pointer will be NULL if the index is out-of-bounds. */ - FCDEffectCode* GetCode(size_t index) { FUAssert(index < GetCodeCount(), return NULL); return codes.at(index); } - const FCDEffectCode* GetCode(size_t index) const { FUAssert(index < GetCodeCount(), return NULL); return codes.at(index); } /**< See above. */ - - /** Retrieves the code inclusion with the given sub-id. - @param sid A COLLADA sub-id. - @return The code inclusion with the given sub-id. This pointer will be NULL, - if there are no code inclusions that match the given sub-id. */ - FCDEffectCode* FindCode(const string& sid); - const FCDEffectCode* FindCode(const string& sid) const; /**< See above. */ - - /** Adds a new code inclusion to this effect profile. - @return The new code inclusion. */ - FCDEffectCode* AddCode(); - - /** Releases a code inclusion contained within this effect profile. - @param code The code inclusion to release. */ - void ReleaseCode(FCDEffectCode* code); - - /** Retrieves the list of effect parameters contained within the effect profile. - This is the lowest level of abstraction and may contain either effect parameter - generators or effect parameter overrides. - @return The list of effect parameters. */ - FCDEffectParameterList* GetParameterList() { return parameters; } - const FCDEffectParameterList* GetParameterList() const { return parameters; } /**< See above. */ - - /** [INTERNAL] Inserts an existing parameter into the list of effect parameters - at this abstraction level. This function is used during the flattening of a material. - @param parameter The effect parameter to insert. */ - void AddParameter(FCDEffectParameter* parameter); - - /** Retrieves an effect parameter. - Looks for the effect parameter with the correct reference, in order to bind or override its value. - @param reference The reference to match. In the case of effect parameter generators, - the sub-id is used to match. - @return The first effect parameter that matches the reference. - This pointer will be NULL if no effect parameter matches the given semantic. */ - const FCDEffectParameter* FindParameter(const char* reference) const; - - /** Retrieves an effect parameter. - Looks for the effect parameter with the correct semantic, in order to bind or override its value. - @param semantic The effect parameter semantic to match. - @return The first effect parameter that matches the semantic. - This pointer will be NULL if no effect parameter matches the given semantic. */ - virtual FCDEffectParameter* FindParameterBySemantic(const string& semantic); - - /** Retrieves a subset of the effect parameter list. - Look for the effect parameter generators with the correct semantic. - @param semantic The effect parameter semantic to match. - @param parameters The list of parameters to fill in. This list is not cleared. */ - virtual void FindParametersBySemantic(const string& semantic, FCDEffectParameterList& parameters); - - /** Retrieves a subset of the effect parameter list. - Look for the effect parameter generators with the correct reference. - @param reference The effect parameter reference to match. In the case of effect - parameter generators, the reference is replaced by the sub-id. - @param parameters The list of parameters to fill in. This list is not cleared. */ - virtual void FindParametersByReference(const string& reference, FCDEffectParameterList& parameters); - - /** [INTERNAL] Clones the full effect technique. - @param newParent The effect profile that will contain the cloned technique. - @return The cloned technique. This pointer will never be NULL. */ - FCDEffectTechnique* Clone(FCDEffectProfileFX* newParent); - - /** [INTERNAL] Flattens this effect technique. - Merges the parameter overrides into the parameter generators. */ - void Flatten(); - - /** [INTERNAL] Reads in the effect technique from a given COLLADA XML tree node. - @param techniqueNode The COLLADA XML tree node. - @param profileNode X @deprecated bad interface : this dependency must be taken out. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the effect technique.*/ - FUStatus LoadFromXML(xmlNode* techniqueNode, xmlNode* profileNode); - - /** [INTERNAL] Writes out the effect technique to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the effect technique. - @return The created element XML tree node. */ - xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -#endif diff --git a/Extras/FCollada/FCDocument/FCDEntity.cpp b/Extras/FCollada/FCDocument/FCDEntity.cpp deleted file mode 100644 index 8e146e555..000000000 --- a/Extras/FCollada/FCDocument/FCDEntity.cpp +++ /dev/null @@ -1,127 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDEntity.h" -#include "FCDocument/FCDExtra.h" -#include "FCDocument/FCDSceneNode.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -#include "FUtils/FUUniqueStringMap.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDEntity::FCDEntity(FCDocument* document, const char* baseId) : FCDObjectWithId(document, baseId) -{ - extra = new FCDExtra(document); -} - -FCDEntity::~FCDEntity() -{ - SAFE_DELETE(extra); -} - -// Structure cloning -void FCDEntity::Clone(FCDEntity* clone) -{ - FCDObjectWithId::Clone(clone); - clone->name = name; - clone->note = note; -} - -void FCDEntity::SetName(const fstring& _name) -{ - name = CleanName(_name); -} - -// Parse this entity information from the COLLADA XML document -FUStatus FCDEntity::LoadFromXML(xmlNode* entityNode) -{ - FUStatus status; - - string fileId = FUDaeParser::ReadNodeId(entityNode); - if (!fileId.empty()) SetDaeId(fileId); - else RemoveDaeId(); - - name = TO_FSTRING(FUDaeParser::ReadNodeName(entityNode)); - if (name.empty()) name = TO_FSTRING(fileId); - - xmlNode* extraNode = FindChildByType(entityNode, DAE_EXTRA_ELEMENT); - if (extraNode != NULL) - { - extra->LoadFromXML(extraNode); - - // Look for an extra node at this level and a Max/Maya-specific technique - FCDETechnique* mayaTechnique = extra->FindTechnique(DAEMAYA_MAYA_PROFILE); - FCDETechnique* maxTechnique = extra->FindTechnique(DAEMAX_MAX_PROFILE); - - // Read in all the extra parameters - StringList parameterNames; - FCDENodeList parameterNodes; - if (mayaTechnique != NULL) mayaTechnique->FindParameters(parameterNodes, parameterNames); - if (maxTechnique != NULL) maxTechnique->FindParameters(parameterNodes, parameterNames); - - // Look for the note and user-properties, which is the only parameter currently supported at this level - size_t parameterCount = parameterNodes.size(); - for (size_t i = 0; i < parameterCount; ++i) - { - FCDENode* parameterNode = parameterNodes[i]; - const string& parameterName = parameterNames[i]; - - if (parameterName == DAEMAX_USERPROPERTIES_NODE_PARAMETER || parameterName == DAEMAYA_NOTE_PARAMETER - || parameterName == DAEMAX_USERPROPERTIES_NODE_PARAMETER1_3 || parameterName == DAEMAYA_MAYA_NOTE_PARAMETER1_3) - { - note = parameterNode->GetContent(); - parameterNode->Release(); - } - } - } - - return status; -} - -// Look for a children with the given COLLADA Id. -FCDEntity* FCDEntity::FindDaeId(const string& _daeId) -{ - if (GetDaeId() == _daeId) return this; - return NULL; -} - -xmlNode* FCDEntity::WriteToXML(xmlNode* parentNode) const -{ - return WriteToEntityXML(parentNode, DAEERR_UNKNOWN_ELEMENT); -} - -xmlNode* FCDEntity::WriteToEntityXML(xmlNode* parentNode, const char* nodeName) const -{ - // Create the entity node and write out the id and name attributes - xmlNode* entityNode = AddChild(parentNode, nodeName); - AddAttribute(entityNode, DAE_ID_ATTRIBUTE, GetDaeId()); - if (!name.empty()) - { - AddAttribute(entityNode, DAE_NAME_ATTRIBUTE, name); - } - - return entityNode; -} - -void FCDEntity::WriteToExtraXML(xmlNode* entityNode) const -{ - // Write out the note - if (HasNote()) - { - xmlNode* techniqueNode = AddExtraTechniqueChild(entityNode, DAEMAX_MAX_PROFILE); - AddChild(techniqueNode, DAEMAX_USERPROPERTIES_NODE_PARAMETER, note); - } - - // Write out the user-defined extra information. - extra->WriteToXML(entityNode); -} diff --git a/Extras/FCollada/FCDocument/FCDEntity.h b/Extras/FCollada/FCDocument/FCDEntity.h deleted file mode 100644 index 5269c9e81..000000000 --- a/Extras/FCollada/FCDocument/FCDEntity.h +++ /dev/null @@ -1,189 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDEntity.h - This file contains the FCDEntity class. -*/ - -#ifndef _FCD_ENTITY_H_ -#define _FCD_ENTITY_H_ - -#include "FCDocument/FCDObject.h" - -class FCDocument; -class FCDExtra; - -/** - A COLLADA entity. - - A COLLADA entity is an object contained within a COLLADA library. - As such, it is based on the FCDObjectWithId class so that it - can be accessed by other entities, such as the scene graph. - - The entity adds to the FCDObjectWithId class: a name, - an extra tree and an optional note, as well as a way - to identity the type of the entity, in order to up-cast it - to its correct class. - - @ingroup FCDocument -*/ - -class FCOLLADA_EXPORT FCDEntity : public FCDObjectWithId -{ -public: - /** The types of entity classes. - Each type corresponds directly to one class that contains the - FCDEntity class as a parent, so you can up-cast FCDEntity pointers. */ - enum Type - { - ENTITY, /**< A generic entity (FCDEntity). Should never be used. */ - ANIMATION, /**< An animation (FCDAnimation). */ - ANIMATION_CLIP, /**< An animation clip (FCDAnimationClip). */ - CAMERA, /**< A camera (FCDCamera). */ - LIGHT, /**< A light (FCDLight). */ - IMAGE, /**< An image (FCDImage). */ - TEXTURE, /**< A texture (FCDTexture). Used for COLLADA 1.3 backward compatibility only! */ - MATERIAL, /**< A visual material definition (FCDMaterial). */ - EFFECT, /**< An effect definition (FCDEffect). */ - GEOMETRY, /**< A geometric object (FCDGeometry). Includes splines and meshes. */ - CONTROLLER, /**< A geometric controller (FCDController). Includes skins and morphers. */ - SCENE_NODE, /**< A visual scene node (FCDSceneNode). */ - PHYSICS_RIGID_CONSTRAINT, /**< A physics rigid constraint (FCDPhysicsRigidConstraint). */ - PHYSICS_MATERIAL, /**< A physics material definiton (FCDPhysicsMaterial). */ - PHYSICS_RIGID_BODY, /**< A physics rigid body (FCDPhysicsRigidBody). */ - PHYSICS_SHAPE, /**< A physics shape (FCDPhysicsShape). */ - PHYSICS_ANALYTICAL_GEOMETRY, /**< A physics analytical geometric object (FCDPhysicsAnalyticalGeometry). */ - PHYSICS_MODEL, /**< A physics model (FCDPhysicsModel). */ - PHYSICS_SCENE_NODE /**< A physics scene node (FCDPhysicsSceneNode). */ - }; - -private: - fstring name; - - // Extra information for the entity. - FCDExtra* extra; - - // Maya and Max both support custom strings for objects. - fstring note; - - // Deprecated ColladaMaya post-processing information. - StringList postCmds; - -public: - /** Constructor: do not use directly. - Instead, create objects of the up-classes. - @param document The COLLADA document that owns the entity. - @param baseId The prefix COLLADA id to be used if no COLLADA id is provided. */ - FCDEntity(FCDocument* document, const char* baseId = "GenericEntity"); - - /** Destructor: do not use directly. - Instead, release objects through their libraries or their parent entities. */ - virtual ~FCDEntity(); - - /** Retrieves the entity class type for an entity. - You can use the entity class type of up-cast an entity pointer - to the correct up-class. - This function should be overwritten by all up-classes. - @return The entity class type. */ - virtual Type GetType() const { return ENTITY; } - - /** Retrieves the name of the entity. - This value has no direct use in COLLADA but is useful - to track the user-friendly name of an entity. - @return The name. */ - const fstring& GetName() const { return name; } - - /** Sets the name of the entity. - This value has no direct use in COLLADA but is useful - to track the user-friendly name of an entity. - @param _name The name. */ - void SetName(const fstring& _name); - - /** Retrieves the extra information tree for this entity. - The prefered way to save extra information in FCollada is at - the entity level. Use this extra information tree to store - any information you want exported and imported back. - @return The extra information tree. */ - FCDExtra* GetExtra() { return extra; } - const FCDExtra* GetExtra() const { return extra; } /**< See above. */ - - /** Retrieves whether the entity has a user-defined note. - This value is a simpler way, than the extra tree, to store - user-defined information that does not belong in COLLADA. - @return Whether the entity has an user-defined note. */ - bool HasNote() const { return !note.empty(); } - - /** Retrieves the user-defined note for this entity. - This value is a simpler way, than the extra tree, to store - user-defined information that does not belong in COLLADA. - @return The user-defined note. */ - const fstring& GetNote() const { return note; } - - /** Sets the user-defined note for this entity. - This value is a simpler way, than the extra tree, to store - user-defined information that does not belong in COLLADA. - @param _note The user-defined note. */ - void SetNote(const fstring& _note) { note = _note; } - - /** Retrieves the child entity that has the given COLLADA id. - This function is only useful for entities that are hierarchical: - visual/physics scene nodes and animations. - @param daeId A COLLADA id. - @return The child entity with the given id. This pointer will be NULL - if no child entity matches the given id. */ - virtual FCDEntity* FindDaeId(const string& daeId); - - /** [INTERNAL] Reads in the entity from a given COLLADA XML tree node. - This function should be overwritten by all up-classes. - @param entityNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the entity.*/ - virtual FUStatus LoadFromXML(xmlNode* entityNode); - - /** [INTERNAL] Writes out the entity to the given COLLADA XML tree node. - This function should be overwritten by all up-classes. - @param parentNode The COLLADA XML parent node in which to insert the entity. - @return The created element XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; - - /** @deprecated Retrieves the like of post-processing commands. - Used only in ColladaMaya and should be taken out. - @return The list of post-processing commands. */ - StringList& GetPostProcessCmds() { return postCmds; } - -protected: - /** [INTERNAL] Writes out the top entity XML node for the entity. - This function should be used by all up-classes within the - WriteToXML overwritting function to create the top XML node, - as it will write out the name and COLLADA id of the entity. - @param parentNode The COLLADA XML parent node in which to insert the entity. - @param nodeName The COLLADA XML node name for the top entity XML node. - @return The created element XML tree node. */ - xmlNode* WriteToEntityXML(xmlNode* parentNode, const char* nodeName) const; - - /** [INTERNAL] Writes out the extra information for the entity. - This function should be used by all up-classes within the - WriteToXML overwritting function, at the very end, to write - the user-defined note and the extra tree to the COLLADA document. - @param entityNode The created element XML tree node returned - by the WriteToEntityXML function. */ - void WriteToExtraXML(xmlNode* entityNode) const; - - /** [INTERNAL] Copies the entity information into a cloned entity. - This function should be used by all up-classes when cloning an entity - to copy the COLLADA id and the other entity-level information into a clone. - @param clone The cloned entity. */ - void Clone(FCDEntity* clone); -}; - -#endif // _FCD_ENTITY_H_ - diff --git a/Extras/FCollada/FCDocument/FCDEntityInstance.h b/Extras/FCollada/FCDocument/FCDEntityInstance.h deleted file mode 100644 index 33c7d7b88..000000000 --- a/Extras/FCollada/FCDocument/FCDEntityInstance.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _FCD_ENTITY_INSTANCE_H_ -#define _FCD_ENTITY_INSTANCE_H_ - -class FCDocument; -class FCDEntity; - -#include "FCDocument/FCDObject.h" - -class FCOLLADA_EXPORT FCDEntityInstance : public FCDObject -{ -public: - enum Type { SIMPLE, EXTERNAL_REFERENCE, GEOMETRY, MATERIAL, PHYSICS_MODEL, PHYSICS_RIGID_BODY, PHYSICS_RIGID_CONSTRAINT }; - -protected: - FCDEntity* entity; - -public: - FCDEntityInstance(FCDocument* document, FCDEntity* _entity = NULL) : FCDObject(document, "FCDEntityInstance") { entity = _entity; } - virtual ~FCDEntityInstance() { entity = NULL; } - - // Accessors - FCDEntity* GetEntity() { return entity; } - const FCDEntity* GetEntity() const { return entity; } - virtual Type GetType() const { return SIMPLE; } - - // Load the per-instance information from the xml node tree - virtual FUStatus LoadFromXML(xmlNode* UNUSED(instanceNode)) { return FUStatus(true); } - - // Write out the instantiation information to the xml node tree - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -#endif // _FCD_ENTITY_INSTANCE_H_ diff --git a/Extras/FCollada/FCDocument/FCDExternalReference.h b/Extras/FCollada/FCDocument/FCDExternalReference.h deleted file mode 100644 index b2af48352..000000000 --- a/Extras/FCollada/FCDocument/FCDExternalReference.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _FCD_XREF_ENTITY_H_ -#define _FCD_XREF_ENTITY_H_ - -#include "FCDocument/FCDEntityInstance.h" -#include "FUtils/FUStringConversion.h" -#include "FUtils/FUUri.h" - -class FCOLLADA_EXPORT FCDExternalReference : public FCDEntityInstance -{ -private: - FUUri uri; - -public: - FCDExternalReference(FCDocument* document, const FUUri& _uri) : FCDEntityInstance(document) { uri = _uri; } - virtual ~FCDExternalReference() {} - - // FCDEntity override for RTTI-like - virtual Type GetType() const { return EXTERNAL_REFERENCE; } - - // Accessors - const FUUri& GetUri() const { return uri; } - const fstring& GetFilename() const { return uri.prefix; } - fstring GetObjectName() const { return TO_FSTRING(uri.suffix); } -}; - -#endif // _FCD_XREF_ENTITY_H_ diff --git a/Extras/FCollada/FCDocument/FCDExtra.cpp b/Extras/FCollada/FCDocument/FCDExtra.cpp deleted file mode 100644 index dead43e54..000000000 --- a/Extras/FCollada/FCDocument/FCDExtra.cpp +++ /dev/null @@ -1,366 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDAnimated.h" -#include "FCDocument/FCDExtra.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDExtra::FCDExtra(FCDocument* document) : FCDObject(document, "FCDExtra") -{ -} - -FCDExtra::~FCDExtra() -{ - CLEAR_POINTER_VECTOR(techniques); -} - -// Adds a technique of the given profile (or return the existing technique with this profile). -FCDETechnique* FCDExtra::AddTechnique(const char* profile) -{ - FCDETechnique* technique = FindTechnique(profile); - if (technique == NULL) - { - technique = new FCDETechnique(GetDocument(), profile); - techniques.push_back(technique); - } - return technique; -} - -// Releases a technique contained within the extra tree. -void FCDExtra::ReleaseTechnique(FCDETechnique* technique) -{ - FCDETechniqueList::iterator it = std::find(techniques.begin(), techniques.end(), technique); - if (it != techniques.end()) - { - delete (*it); - techniques.erase(it); - } -} - -// Search for a profile-specific technique -FCDETechnique* FCDExtra::FindTechnique(const char* profile) -{ - for (FCDETechniqueList::iterator itT = techniques.begin(); itT != techniques.end(); ++itT) - { - if (IsEquivalent((*itT)->GetProfile(), profile)) return *itT; - } - return NULL; -} -const FCDETechnique* FCDExtra::FindTechnique(const char* profile) const -{ - for (FCDETechniqueList::const_iterator itT = techniques.begin(); itT != techniques.end(); ++itT) - { - if (IsEquivalent((*itT)->GetProfile(), profile)) return *itT; - } - return NULL; -} - -// Search for a root node with a specific element name -FCDENode* FCDExtra::FindRootNode(const char* name) -{ - FCDENode* rootNode = NULL; - for (FCDETechniqueList::iterator itT = techniques.begin(); itT != techniques.end(); ++itT) - { - rootNode = (*itT)->FindChildNode(name); - if (rootNode != NULL) break; - } - return rootNode; -} -const FCDENode* FCDExtra::FindRootNode(const char* name) const -{ - FCDENode* rootNode = NULL; - for (FCDETechniqueList::const_iterator itT = techniques.begin(); itT != techniques.end(); ++itT) - { - rootNode = (*itT)->FindChildNode(name); - if (rootNode != NULL) break; - } - return rootNode; -} - -// Read in/Write to a COLLADA xml document -FUStatus FCDExtra::LoadFromXML(xmlNode* extraNode) -{ - FUStatus status; - - // Read in the techniques - xmlNodeList techniqueNodes; - FindChildrenByType(extraNode, DAE_TECHNIQUE_ELEMENT, techniqueNodes); - for (xmlNodeList::iterator itN = techniqueNodes.begin(); itN != techniqueNodes.end(); ++itN) - { - xmlNode* techniqueNode = (*itN); - FCDETechnique* technique = AddTechnique(ReadNodeProperty(techniqueNode, DAE_PROFILE_ATTRIBUTE)); - status.AppendStatus(technique->LoadFromXML(techniqueNode)); - } - - return status; -} - -xmlNode* FCDExtra::WriteToXML(xmlNode* parentNode) const -{ - if (techniques.empty()) return NULL; - - // Add the element and its techniques - xmlNode* extraNode = AddChildOnce(parentNode, DAE_EXTRA_ELEMENT); - for (FCDETechniqueList::const_iterator itT = techniques.begin(); itT != techniques.end(); ++itT) - { - (*itT)->WriteToXML(extraNode); - } - return extraNode; -} - -FCDENode::FCDENode(FCDocument* document, FCDENode* _parent) : FCDObject(document, "FCDENode") -{ - parent = _parent; - animated = NULL; -} - -FCDENode::~FCDENode() -{ - GetDocument()->UnregisterAnimatedValue(animated); - SAFE_DELETE(animated); - parent = NULL; - - CLEAR_POINTER_VECTOR(children); - CLEAR_POINTER_VECTOR(attributes); -} - -void FCDENode::Release() -{ - if (parent != NULL) - { - parent->ReleaseChildNode(this); - } - - // Otherwise, we have a technique so don't release -} - -void FCDENode::SetContent(const fchar* _content) -{ - // As COLLADA doesn't allow for mixed content, release all the children. - while (!children.empty()) - { - children.back()->Release(); - } - - content = _content; -} - -// Search for a children with a specific name -FCDENode* FCDENode::FindChildNode(const char* name) -{ - for (FCDENodeList::iterator itN = children.begin(); itN != children.end(); ++itN) - { - if (IsEquivalent((*itN)->GetName(), name)) return (*itN); - } - return NULL; -} - -const FCDENode* FCDENode::FindChildNode(const char* name) const -{ - for (FCDENodeList::const_iterator itN = children.begin(); itN != children.end(); ++itN) - { - if (IsEquivalent((*itN)->GetName(), name)) return (*itN); - } - return NULL; -} - -// Adds a new child node -FCDENode* FCDENode::AddChildNode() -{ - FCDENode* node = new FCDENode(GetDocument(), this); - children.push_back(node); - return node; -} - -// Releases a child node -void FCDENode::ReleaseChildNode(FCDENode* childNode) -{ - FCDENodeList::iterator itN = std::find(children.begin(), children.end(), childNode); - if (itN != children.end()) - { - delete (*itN); - children.erase(itN); - } -} - - -FCDENode* FCDENode::FindParameter(const char* name) -{ - for (FCDENodeList::iterator itN = children.begin(); itN != children.end(); ++itN) - { - FCDENode* node = (*itN); - if (IsEquivalent(node->GetName(), name)) return node; - else if (IsEquivalent(node->GetName(), DAE_PARAMETER_ELEMENT)) - { - FCDEAttribute* nameAttribute = node->FindAttribute(DAE_NAME_ATTRIBUTE); - if (nameAttribute != NULL && nameAttribute->value == TO_FSTRING(name)) return node; - } - } - return NULL; -} - -void FCDENode::FindParameters(FCDENodeList& nodes, StringList& names) -{ - for (FCDENodeList::iterator itN = children.begin(); itN != children.end(); ++itN) - { - FCDENode* node = (*itN); - if (node->GetChildNodeCount() > 1) continue; - - if (IsEquivalent(node->GetName(), DAE_PARAMETER_ELEMENT)) - { - FCDEAttribute* nameAttribute = node->FindAttribute(DAE_NAME_ATTRIBUTE); - if (nameAttribute != NULL) - { - nodes.push_back(node); - names.push_back(FUStringConversion::ToString(nameAttribute->value)); - } - } - else - { - nodes.push_back(node); - names.push_back(node->GetName()); - } - } -} - -// Adds a new attribute to this extra tree node. -FCDEAttribute* FCDENode::AddAttribute(const char* _name, const fchar* _value) -{ - FCDEAttribute* attribute = FindAttribute(_name); - if (attribute == NULL) - { - attribute = new FCDEAttribute(); - attribute->name = _name; - attributes.push_back(attribute); - } - - attribute->value = _value; - return attribute; -} - -// Releases an attribute -void FCDENode::ReleaseAttribute(FCDEAttribute* attribute) -{ - FCDEAttributeList::iterator it = std::find(attributes.begin(), attributes.end(), attribute); - if (it != attributes.end()) - { - delete *it; - attributes.erase(it); - } -} - -// Search for an attribute with a specific name -FCDEAttribute* FCDENode::FindAttribute(const char* name) -{ - for (FCDEAttributeList::iterator itA = attributes.begin(); itA != attributes.end(); ++itA) - { - if ((*itA)->name == name) return (*itA); - } - return NULL; -} -const FCDEAttribute* FCDENode::FindAttribute(const char* name) const -{ - for (FCDEAttributeList::const_iterator itA = attributes.begin(); itA != attributes.end(); ++itA) - { - if ((*itA)->name == name) return (*itA); - } - return NULL; -} - -// Read in this extra node from a COLLADA xml document -FUStatus FCDENode::LoadFromXML(xmlNode* customNode) -{ - FUStatus status; - - // Read in the node's name and children - name = (const char*) customNode->name; - ReadChildrenFromXML(customNode); - - // If there are no child nodes, we have a tree leaf: parse in the content and its animation - content = (children.empty()) ? TO_FSTRING(ReadNodeContentDirect(customNode)) : FS(""); - animated = FCDAnimatedCustom::Create(GetDocument(), customNode); - - // Read in the node's attributes - for (xmlAttr* a = customNode->properties; a != NULL; a = a->next) - { - AddAttribute((const char*) a->name, (a->children != NULL) ? TO_FSTRING((const char*) (a->children->content)) : FS("")); - } - - return status; -} - -// Write out this extra to a COLLADA xml document -xmlNode* FCDENode::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* customNode = AddChild(parentNode, name.c_str(), content); - - // Write out the attributes - for (FCDEAttributeList::const_iterator itA = attributes.begin(); itA != attributes.end(); ++itA) - { - const FCDEAttribute* attribute = (*itA); - FUXmlWriter::AddAttribute(customNode, attribute->name.c_str(), attribute->value); - } - - // Write out the children - WriteChildrenToXML(customNode); - return customNode; -} - -// Read in the child nodes from the xml tree node -FUStatus FCDENode::ReadChildrenFromXML(xmlNode* customNode) -{ - FUStatus status; - - // Read in the node's children - for (xmlNode* k = customNode->children; k != NULL; k = k->next) - { - if (k->type != XML_ELEMENT_NODE) continue; - - FCDENode* node = AddChildNode(); - status.AppendStatus(node->LoadFromXML(k)); - } - - return status; -} - -// Write out the child nodes to the xml tree node -void FCDENode::WriteChildrenToXML(xmlNode* customNode) const -{ - for (FCDENodeList::const_iterator itN = children.begin(); itN != children.end(); ++itN) - { - (*itN)->WriteToXML(customNode); - } -} - -FCDETechnique::FCDETechnique(FCDocument* document, const char* _profile) : FCDENode(document, NULL) -{ - profile = _profile; -} - -FCDETechnique::~FCDETechnique() {} - -// Read in/Write to a COLLADA xml document -FUStatus FCDETechnique::LoadFromXML(xmlNode* techniqueNode) -{ - FUStatus status; - - // Read in only the child elements: none of the attributes - status.AppendStatus(ReadChildrenFromXML(techniqueNode)); - return status; -} - -xmlNode* FCDETechnique::WriteToXML(xmlNode* parentNode) const -{ - // Create the technique for this profile and write out the children - xmlNode* customNode = AddTechniqueChild(parentNode, profile.c_str()); - WriteChildrenToXML(customNode); - return customNode; -} - diff --git a/Extras/FCollada/FCDocument/FCDExtra.h b/Extras/FCollada/FCDocument/FCDExtra.h deleted file mode 100644 index d5a3293c3..000000000 --- a/Extras/FCollada/FCDocument/FCDExtra.h +++ /dev/null @@ -1,357 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDExtra.h - This file contains the FCDExtra class and its sub-classes: - FCDENode, FCDETechnique and FCDEAttribute. -*/ - -#ifndef _FCD_EXTRA_H_ -#define _FCD_EXTRA_H_ - -#include "FCDocument/FCDObject.h" - -class FCDAnimated; -class FCDAnimatedCustom; -class FCDETechnique; -class FCDENode; - -/** - An extra tree attribute. - Contains a name and a value string. -*/ -struct FCDEAttribute -{ - string name; /**< The attribute name. Must be provided. */ - fstring value; /**< The attribute value. Is optional. */ -}; - -typedef vector FCDETechniqueList; /**< A dynamically-sized array of extra tree techniques. */ -typedef vector FCDENodeList; /**< A dynamically-sized array of extra tree nodes. */ -typedef vector FCDEAttributeList; /**< A dynamically-sized array of extra tree attributes. */ - -/** - A COLLADA extra tree. - - An extra tree contains the user-defined COLLADA information - contained within \ elements. For this, the extra tree - root simply contains a list of techniques. Each technique - belongs to a different application-specific profile. -*/ -class FCOLLADA_EXPORT FCDExtra : public FCDObject -{ -private: - FCDETechniqueList techniques; - -public: - /** Constructor: do not use directly. - The structures that contain extra trees will create them. - @param document The COLLADA document that owns the extra tree. */ - FCDExtra(FCDocument* document); - - /** Destructor: do not use directly. - The structures that contain extra trees will release them. */ - virtual ~FCDExtra(); - - /** Retrieves the list of techniques contained by this extra tree. - @return The list of techniques. */ - FCDETechniqueList& GetTechniques() { return techniques; } - const FCDETechniqueList& GetTechniques() const { return techniques; } /**< See above. */ - - /** Retrieves the number of techniques contained by this extra tree. - @return The number of techniques. */ - size_t GetTechniqueCount() const { return techniques.size(); } - - /** Retrieves a specific technique contained by this extra tree. - @param index The index of the technique. - @return The technique. This pointer will be NULL if the - index is out-of-bounds. */ - FCDETechnique* GetTechnique(size_t index) { FUAssert(index < techniques.size(), return NULL); return techniques.at(index); } - const FCDETechnique* GetTechnique(size_t index) const { FUAssert(index < techniques.size(), return NULL); return techniques.at(index); } /**< See above. */ - - /** Adds a new application-specific profile technique to the extra tree. - If the given application-specific profile already exists - within the extra tree, the old technique will be returned. - @param profile The application-specific profile name. - @return A technique for this application-specific profile. */ - FCDETechnique* AddTechnique(const char* profile); - inline FCDETechnique* AddTechnique(const string& profile) { return AddTechnique(profile.c_str()); } /**< See above. */ - - /** Releases a technique contained within the extra tree. - @param technique The technique to release. */ - void ReleaseTechnique(FCDETechnique* technique); - - /** Retrieves a specific technique contained by this extra tree. - @param profile The application-specific profile name of the technique. - @return The technique that matches the profile name. This pointer may - be NULL if no technique matches the profile name. */ - FCDETechnique* FindTechnique(const char* profile); - const FCDETechnique* FindTechnique(const char* profile) const; /**< See above. */ - inline FCDETechnique* FindTechnique(const string& profile) { return FindTechnique(profile.c_str()); } /**< See above. */ - inline const FCDETechnique* FindTechnique(const string& profile) const { return FindTechnique(profile.c_str()); } /**< See above. */ - - /** Retrieves the extra tree node that has a given element name. - This function searches for the extra tree node within all the - techniques. - @param name An element name. - @return The extra tree node that matches the element name. This pointer - will be NULL if no extra tree node matches the element name. */ - FCDENode* FindRootNode(const char* name); - const FCDENode* FindRootNode(const char* name) const; /**< See above. */ - inline FCDENode* FindRootNode(const string& name) { return FindRootNode(name.c_str()); } /**< See above. */ - inline const FCDENode* FindRootNode(const string& name) const { return FindRootNode(name.c_str()); } /**< See above. */ - - /** [INTERNAL] Reads in the extra tree from a given COLLADA XML tree node. - @param extraNode The COLLADA \ element XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the entity.*/ - FUStatus LoadFromXML(xmlNode* extraNode); - - /** [INTERNAL] Writes out the extra tree to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the \ element. - @return The created element XML tree node. */ - xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -/** - A COLLADA extra tree node. - - The extra tree node is a hierarchical structure that contains child - extra tree nodes as well as attributes. If the extra tree node is a leaf - of the tree, it may contain textual content. - - The extra tree node leaf may be animated, if it has the 'sid' attribute. -*/ -class FCOLLADA_EXPORT FCDENode : public FCDObject -{ -private: - string name; - fstring content; - - FCDENode* parent; - FCDENodeList children; - FCDEAttributeList attributes; - - FCDAnimatedCustom* animated; - -public: - /** Constructor: do not use directly. - Instead, call the FCDENode::AddChild function of the parent within the hierarchy. - @param document The COLLADA document that owns the extra tree node. - @param parent The extra tree node that contains this extra tree node. */ - FCDENode(FCDocument* document, FCDENode* parent); - - /** Destructor: do not use directly. - Instead, for hierarchical nodes: call the Release function - or the parent's ReleaseChildNode function and for techniques: - call the FCDExtra::ReleaseTechnique function. */ - virtual ~FCDENode(); - - /** Releases this extra tree node. - This function is a shortcut to the parent's FCDENode::ReleaseChildNode function. */ - void Release(); - - /** Retrieves the name of the extra tree node. - The name of the extra tree node is the name of the equivalent XML tree node. - @return The name of the extra tree node. */ - inline const char* GetName() const { return name.c_str(); } - - /** Sets the name of the extra tree node. - The name of the extra tree node is the name of the equivalent XML tree node. - @param _name The name of the extra tree node. */ - inline void SetName(const char* _name) { name = _name; } - inline void SetName(const string& _name) { name = _name; } /**< See above. */ - - /** Retrieves the textual content of the extra tree node. - This value is only valid for extra tree node that have no children, - as COLLADA doesn't allow for mixed-content. - @return The textual content of the extra tree node. */ - const fchar* GetContent() const { return content.c_str(); } - - /** Sets the textual content of the extra tree node. - This function will release all the child node of this extra tree node, - as COLLADA doesn't allow for mixed-content. - @param _content The textual content. */ - void SetContent(const fchar* _content); - inline void SetContent(const fstring& _content) { return SetContent(_content.c_str()); } /**< See above. */ - - /** Retrieves the animated values associated with this extra tree node. - Extra tree node leaves may be animated. If this extra tree node leaf - is animated, this animated value will contain the animation curves. - @return The animated value. */ - FCDAnimatedCustom* GetAnimated() { return animated; } - const FCDAnimatedCustom* GetAnimated() const { return animated; } /**< See above. */ - - /** Retrieves the parent of an extra tree node. - The hierarchy cannot be changed dynamically. If you to move an extra tree node, - you will need to clone it manually and release the old extra tree node. - @return The parent extra tree node within the hierarchy. This pointer - will be NULL if the extra tree node is a extra tree technique. */ - FCDENode* GetParent() { return parent; } - const FCDENode* GetParent() const { return parent; } /**< See above. */ - - /** Retrieves the children of an extra tree node. - @return The list of child extra tree nodes. */ - FCDENodeList& GetChildNodes() { return children; } - const FCDENodeList& GetChildNodes() const { return children; } /**< See above. */ - - /** Retrieves the number of children of an extra tree node. - @return The number of children. */ - size_t GetChildNodeCount() const { return children.size(); } - - /** Retrieves a specific child extra tree node. - @param index The index of the child extra tree node. - @return The child extra tree node. This pointer will be NULL if the index - is out-of-bounds. */ - FCDENode* GetChildNode(size_t index) { FUAssert(index < children.size(), return NULL); return children.at(index); } - const FCDENode* GetChildNode(size_t index) const { FUAssert(index < children.size(), return NULL); return children.at(index); } /**< See above. */ - - /** Adds a new child extra tree to this extra tree node. - @return The new child extra tree node. */ - FCDENode* AddChildNode(); - - /** Releases a child extra tree node of this extra tree node. - @param childNode The child to release. */ - void ReleaseChildNode(FCDENode* childNode); - - /** Retrieves the child extra tree node with the given name. - @param name A name. - @return The child extra tree node that matches the given name. - This pointer will be NULL if no child extra tree node matches - the given name. */ - FCDENode* FindChildNode(const char* name); - const FCDENode* FindChildNode(const char* name) const; /**< See above. */ - inline FCDENode* FindChildNode(const string& name) { return FindChildNode(name.c_str()); } /**< See above. */ - inline const FCDENode* FindChildNode(const string& name) const { return FindChildNode(name.c_str()); } /**< See above. */ - - /** Retrieves the child extra tree node with the given name. - This function is used for COLLADA 1.3 backward compatibility, - where all parameters were described as \value\. - So, if the child extra tree node with the name 'X' as searched for: - both the above COLLADA 1.3 parameter and the COLLADA 1.4+ - \value\ parameters will be returned. - @param name The parameter name. - @return The first child extra tree node holding the wanted parameter within the hierarchy. - This pointer will be NULL to indicate that no parameter matches the given name. */ - FCDENode* FindParameter(const char* name); - - /** Retrieves a list of all the parameters contained within the hierarchy. - This function is used for COLLADA 1.3 backward compatibility, - where all parameters were described as \value\. - In COLLADA 1.4+, the same parameter should be described as: \value\. - Using this function, both parameters would be returned with the name 'X'. - @param nodes The list of parameters to fill in. This list is not emptied by the function. - @param names The list of names of the parameters. This list is not emptied by the function. */ - void FindParameters(FCDENodeList& nodes, StringList& names); - - /** Retrieves the list of attributes for this extra tree node. - @return The list of attributes. */ - FCDEAttributeList& GetAttributes() { return attributes; } - const FCDEAttributeList& GetAttributes() const { return attributes; } /**< See above. */ - - /** Retrieves the number of attributes for this extra tree node. - @return The number of attributes. */ - size_t GetAttributeCount() const { return attributes.size(); } - - /** Retrieves a specific attribute of this extra tree node. - @param index The index. - @return The attribute at this index. This pointer will be NULL - if the index is out-of-bounds. */ - FCDEAttribute* GetAttribute(size_t index) { FUAssert(index < attributes.size(), return NULL); return attributes.at(index); } - const FCDEAttribute* GetAttribute(size_t index) const { FUAssert(index < attributes.size(), return NULL); return attributes.at(index); } /**< See above. */ - - /** Adds a new attribute to this extra tree node. - If an attribute with the same name already exists, this function simply - assigns the new value to the existing attribute and returns the existing attribute. - @param _name The name of the attribute. - @param _value The value of the attribute. - @return The new attribute. */ - FCDEAttribute* AddAttribute(const char* _name, const fchar* _value); - inline FCDEAttribute* AddAttribute(const string& _name, const fchar* _value) { return AddAttribute(_name.c_str(), _value); } /**< See above. */ - inline FCDEAttribute* AddAttribute(const char* _name, const fstring& _value) { return AddAttribute(_name, _value.c_str()); } /**< See above. */ - inline FCDEAttribute* AddAttribute(const string& _name, const fstring& _value) { return AddAttribute(_name.c_str(), _value.c_str()); } /**< See above. */ - template inline FCDEAttribute* AddAttribute(const char* _name, const T& _value) { return AddAttribute(_name, TO_FSTRING(_value)); } /**< See above. */ - template inline FCDEAttribute* AddAttribute(const string& _name, const T& _value) { return AddAttribute(_name.c_str(), TO_FSTRING(_value)); } /**< See above. */ - - /** Releases an attribute of this extra tree node. - @param attribute The attribute to release. */ - void ReleaseAttribute(FCDEAttribute* attribute); - - /** Retrieve the attribute of this extra tree node with the given name. - Attribute names are unique within an extra tree node. - @param name The attribute name. - @return The attribute that matches the name. This pointer will be NULL if - there is no attribute with the given name. */ - FCDEAttribute* FindAttribute(const char* name); - const FCDEAttribute* FindAttribute(const char* name) const; /**< See above. */ - - /** [INTERNAL] Reads in the extra tree node from a given COLLADA XML tree node. - @param customNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the extra tree node.*/ - virtual FUStatus LoadFromXML(xmlNode* customNode); - - /** [INTERNAL] Writes out the extra tree node to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the extra tree node. - @return The created element XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; - -protected: - /** [INTERNAL] Reads in the children nodes of the extra tree node. - Used by the FCDETechnique class exclusively. - @param customNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the extra tree node.*/ - FUStatus ReadChildrenFromXML(xmlNode* customNode); - - /** [INTERNAL] Writes out the children nodes of extra tree node. - Used by the FCDETechnique class exclusively. - @param customNode The COLLADA XML node for the extra tree node. */ - void WriteChildrenToXML(xmlNode* customNode) const; -}; - -/** - A COLLADA extra tree technique. - - For convenience, this extra tree technique is based on top of the FCDENode class. - An extra tree technique is the root of the extra tree specific to - the profile of an application. - - @ingroup FCDocument -*/ -class FCOLLADA_EXPORT FCDETechnique : public FCDENode -{ -private: - string profile; - -public: - /** Constructor: do not use directly. - Instead, use the FCDExtra::AddTechnique function. - @param document The COLLADA document that owns the technique. - @param profile The application-specific profile name. */ - FCDETechnique(FCDocument* document, const char* profile); - - /** Destructor: do not use directly. - Instead, release a technique using the FCDExtra::ReleaseTechnique function. */ - virtual ~FCDETechnique(); - - /** Retrieves the name of the application-specific profile of the technique. - @return The name of the application-specific profile. */ - const char* GetProfile() const { return profile.c_str(); } - - /** [INTERNAL] Reads in the extra tree technique from a given COLLADA XML tree node. - @param techniqueNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the extra tree technique.*/ - virtual FUStatus LoadFromXML(xmlNode* techniqueNode); - - /** [INTERNAL] Writes out the extra tree technique to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the extra tree technique. - @return The created element XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -#endif // _FCD_EXTRA_H_ diff --git a/Extras/FCollada/FCDocument/FCDGeometry.cpp b/Extras/FCollada/FCDocument/FCDGeometry.cpp deleted file mode 100644 index ef7ef1629..000000000 --- a/Extras/FCollada/FCDocument/FCDGeometry.cpp +++ /dev/null @@ -1,151 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDAnimated.h" -#include "FCDocument/FCDGeometry.h" -#include "FCDocument/FCDGeometryMesh.h" -#include "FCDocument/FCDGeometrySpline.h" -#include "FUtils/FUStringConversion.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDGeometry::FCDGeometry(FCDocument* document) : FCDEntity(document, "Geometry") -{ - spline = NULL; - mesh = NULL; -} - -FCDGeometry::~FCDGeometry() -{ - SAFE_DELETE(spline); - SAFE_DELETE(mesh); -} - -// Sets the type of this geometry to mesh and creates an empty mesh structure. -FCDGeometryMesh* FCDGeometry::CreateMesh() -{ - SAFE_DELETE(spline); - SAFE_DELETE(mesh); - - mesh = new FCDGeometryMesh(GetDocument(), this); - return mesh; -} - -// Sets the type of this geometry to spline and creates an empty spline structure. -FCDGeometrySpline* FCDGeometry::CreateSpline() -{ - SAFE_DELETE(spline); - SAFE_DELETE(mesh); - - spline = new FCDGeometrySpline(GetDocument(), this); - return spline; -} - -// Create a copy of this geometry, with the vertices overwritten -FCDGeometry* FCDGeometry::Clone(FloatList& newPositions, uint32 newPositionsStride, FloatList& newNormals, uint32 newNormalsStride) -{ - // Clone only mesh geometries. This function is necessary for COLLADA 1.3 backward compatibility and should not be used - // in some other way (yet) - if (!IsMesh()) return NULL; - - FCDGeometry* clone = new FCDGeometry(GetDocument()); - clone->mesh = mesh->Clone(newPositions, newPositionsStride, newNormals, newNormalsStride); - return clone; -} - -// Load from a XML node the given geometry -FUStatus FCDGeometry::LoadFromXML(xmlNode* geometryNode) -{ - SAFE_DELETE(mesh); - SAFE_DELETE(spline); - - FUStatus status = FCDEntity::LoadFromXML(geometryNode); - if (!status) return status; - if (!IsEquivalent(geometryNode->name, DAE_GEOMETRY_ELEMENT)) - { - return status.Warning(FS("Geometry library contains unknown element."), geometryNode->line); - } - - // Read in the first valid child element found - for (xmlNode* child = geometryNode->children; child != NULL; child = child->next) - { - if (child->type != XML_ELEMENT_NODE) continue; - - if (IsEquivalent(child->name, DAE_MESH_ELEMENT)) - { - // Create a new mesh - FCDGeometryMesh* m = CreateMesh(); - status.AppendStatus(m->LoadFromXML(child)); - break; - } - else if (IsEquivalent(child->name, DAE_SPLINE_ELEMENT)) - { - // Create a new spline - FCDGeometrySpline* s = CreateSpline(); - status.AppendStatus(s->LoadFromXML(child)); - break; - } - else if (IsEquivalent(child->name, DAE_CONVEX_MESH_ELEMENT)) - { - //several cases can exist here... - //wait for fixed version of FCollada? - //assume and do instantiate? - - // Create a new mesh - FCDGeometryMesh* m = CreateMesh(); - m->m_convex = true; - FUUri url; - char hullname[] = "convex_hull_of"; - - url = ReadNodeUrl(child,hullname); - - if (!url.prefix.empty()) - { - - FCDGeometry* entity = GetDocument()->FindGeometry(url.prefix); - if (entity) - { - printf("found convex_mesh\n"); - //quick hack - this->mesh = entity->GetMesh(); - mesh->m_convex = true; - - } - - } - - - //status.AppendStatus(m->LoadFromXML(child)); - - break; - } - else - { - return status.Fail(FS("Unknown child in with id: ") + TO_FSTRING(GetDaeId()), child->line); - } - } - - if (mesh == NULL && spline == NULL) - { - status.Warning(FS("No mesh or spline found within geometry: ") + TO_FSTRING(GetDaeId()), geometryNode->line); - } - return status; -} - -// Write out the node -xmlNode* FCDGeometry::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* geometryNode = WriteToEntityXML(parentNode, DAE_GEOMETRY_ELEMENT); - - if (mesh != NULL) mesh->WriteToXML(geometryNode); - else if (spline != NULL) spline->WriteToXML(geometryNode); - - FCDEntity::WriteToExtraXML(geometryNode); - return geometryNode; -} diff --git a/Extras/FCollada/FCDocument/FCDGeometry.h b/Extras/FCollada/FCDocument/FCDGeometry.h deleted file mode 100644 index 0a63c12d0..000000000 --- a/Extras/FCollada/FCDocument/FCDGeometry.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDGeometry.h - This file contains the FCDGeometry class. - The FCDGeometry class holds the information for one mesh or spline - entity, within the COLLADA geometry library. -*/ -#ifndef _FCD_GEOMETRY_H_ -#define _FCD_GEOMETRY_H_ - -#include "FCDocument/FCDEntity.h" -#include "FUtils/FUDaeEnum.h" - -class FCDocument; -class FCDGeometryMesh; -class FCDGeometrySpline; - -/** - @defgroup FCDGeometry COLLADA Document Geometry Entity - @addtogroup FCDocument -*/ - -/** - A COLLADA geometry entity. - There are two types of COLLADA geometry entities: meshes and splines. - - Meshes are collections of polygons where the vertices always have a position, - usually have a normal to define smooth or hard edges and may be colored or textured. - - Splines are a sequence of control points used to generate a smooth curve. - - @ingroup FCDGeometry -*/ - -class FCOLLADA_EXPORT FCDGeometry : public FCDEntity -{ -private: - // Contains only one of the following, in order of importance. - FCDGeometryMesh* mesh; - FCDGeometrySpline* spline; - -public: - /** Contructor: do not use directly. Create new geometries using the FCDocument::AddGeometry function, - or the FCDLibrary::AddEntity function. - @param document The COLLADA document which owns the new geometry entity. */ - FCDGeometry(FCDocument* document); - - /** Destructor: only release cloned geometries directly. - Release original geometries using the FCDLibrary::ReleaseEntity function. - All original geometries are released with the document that they belong to. */ - virtual ~FCDGeometry(); - - /** Retrieves the entity class type. - This function is a part of the FCDEntity interface. - @return The entity class type: GEOMETRY. */ - virtual Type GetType() const { return GEOMETRY; } - - /** Retrieves whether the type of this geometry is a mesh. - @return Whether this geometry is a mesh. */ - bool IsMesh() const { return mesh != NULL; } - - /** Retrieves the mesh information structure for this geometry. - Verify that this geometry is a mesh using the IsMesh function prior to calling this function. - @return The mesh information structure. This pointer will be NULL when the geometry is a spline or is undefined. */ - FCDGeometryMesh* GetMesh() { return mesh; } - const FCDGeometryMesh* GetMesh() const { return mesh; } /**< See above. */ - - /** Sets the type of this geometry to mesh and creates an empty mesh structure. - This function will release any mesh or spline structure that the geometry may already contain - @return The mesh information structure. This pointer will always be valid. */ - FCDGeometryMesh* CreateMesh(); - - /** Retrieves whether the type of this geometry is a spline. - @return Whether this geometry is a spline. */ - bool IsSpline() const { return spline != NULL; } - - /** Retrieves the spline information structure for this geometry. - Verify that this geometry is a spline using the IsSpline function prior to calling this function. - @return The spline information structure. This pointer will be NULL when the geometry is a mesh or is undefined. */ - FCDGeometrySpline* GetSpline() { return spline; } - const FCDGeometrySpline* GetSpline() const { return spline; } /**< See above. */ - - /** Sets the type of this geometry to spline and creates an empty spline structure. - This function will release any mesh or spline structure that the geometry may already contain. - @return The spline information structure. This pointer will always be valid. */ - FCDGeometrySpline* CreateSpline(); - - /** @deprecated [INTERNAL] Clones the geometry entity. - Works only on mesh geometry. Creates a full copy of the geometry, with the vertices overwritten - by the given data: this is used when importing COLLADA 1.3 skin controllers. - You will need to release the cloned entity. - @param newPositions The list of vertex position that will - overwrite the current mesh vertex positions. This list may be empty. - @param newPositionsStride The stride, in bytes, of the newPositions list. - For an empty newPositions list, this value is discarded. - @param newNormals The list of vertex normals that will overwrite - the current mesh vertex normals. This list may be empty. - @param newNormalsStride The stride, in bytes, of the newNormals list. - For an empty newNormals list, this value is discarded. - @return The cloned geometry entity. This pointer will be NULL, - if the geometry is not a mesh. You will need to release this pointer. */ - FCDGeometry* Clone(FloatList& newPositions, uint32 newPositionsStride, FloatList& newNormals, uint32 newNormalsStride); - - /** [INTERNAL] Reads in the \ element from a given COLLADA XML tree node. - @param node The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the geometry.*/ - virtual FUStatus LoadFromXML(xmlNode* node); - - /** [INTERNAL] Writes out the \ element to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the geometry information. - @return The created \ element XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -#endif // _FCD_GEOMETRY_H_ diff --git a/Extras/FCollada/FCDocument/FCDGeometryInstance.cpp b/Extras/FCollada/FCDocument/FCDGeometryInstance.cpp deleted file mode 100644 index 2e8d71d0e..000000000 --- a/Extras/FCollada/FCDocument/FCDGeometryInstance.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDController.h" -#include "FCDocument/FCDEntity.h" -#include "FCDocument/FCDGeometry.h" -#include "FCDocument/FCDGeometryInstance.h" -#include "FCDocument/FCDGeometryMesh.h" -#include "FCDocument/FCDGeometryPolygons.h" -#include "FCDocument/FCDMaterialInstance.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -// Parasitic: Write out the instantiation information to the xml node tree -xmlNode* FCDEntityInstance::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* instanceNode = NULL; - if (entity != NULL) - { - const char* instanceEntityName; - switch (entity->GetType()) - { - case FCDEntity::ANIMATION: instanceEntityName = DAE_INSTANCE_ANIMATION_ELEMENT; break; - case FCDEntity::CAMERA: instanceEntityName = DAE_INSTANCE_CAMERA_ELEMENT; break; - case FCDEntity::CONTROLLER: instanceEntityName = DAE_INSTANCE_CONTROLLER_ELEMENT; break; - case FCDEntity::EFFECT: instanceEntityName = DAE_INSTANCE_EFFECT_ELEMENT; break; - case FCDEntity::GEOMETRY: instanceEntityName = DAE_INSTANCE_GEOMETRY_ELEMENT; break; - case FCDEntity::LIGHT: instanceEntityName = DAE_INSTANCE_LIGHT_ELEMENT; break; - case FCDEntity::MATERIAL: instanceEntityName = DAE_INSTANCE_MATERIAL_ELEMENT; break; - case FCDEntity::PHYSICS_MODEL: instanceEntityName = DAE_INSTANCE_PHYSICS_MODEL_ELEMENT; break; - case FCDEntity::PHYSICS_RIGID_BODY: instanceEntityName = DAE_INSTANCE_RIGID_BODY_ELEMENT; break; - case FCDEntity::PHYSICS_RIGID_CONSTRAINT: instanceEntityName = DAE_INSTANCE_RIGID_CONSTRAINT_ELEMENT; break; - case FCDEntity::SCENE_NODE: instanceEntityName = DAE_INSTANCE_NODE_ELEMENT; break; - - case FCDEntity::ANIMATION_CLIP: - case FCDEntity::ENTITY: - case FCDEntity::IMAGE: - case FCDEntity::TEXTURE: - default: instanceEntityName = DAEERR_UNKNOWN_ELEMENT; - } - - instanceNode = AddChild(parentNode, instanceEntityName); - AddAttribute(instanceNode, DAE_URL_ATTRIBUTE, string("#") + entity->GetDaeId()); - } - return instanceNode; -} - -FCDGeometryInstance::FCDGeometryInstance(FCDocument* document, FCDEntity* entity) : FCDEntityInstance(document, entity) -{ -} - -FCDGeometryInstance::~FCDGeometryInstance() -{ - CLEAR_POINTER_VECTOR(materials); -} - -// Access Bound Materials -FCDMaterialInstance* FCDGeometryInstance::FindMaterialInstance(const fstring& semantic) -{ - for (FCDMaterialInstanceList::iterator itB = materials.begin(); itB != materials.end(); ++itB) - { - if ((*itB)->GetSemantic() == semantic) return (*itB); - } - return NULL; -} - -const FCDMaterialInstance* FCDGeometryInstance::FindMaterialInstance(const fstring& semantic) const -{ - for (FCDMaterialInstanceList::const_iterator itB = materials.begin(); itB != materials.end(); ++itB) - { - if ((*itB)->GetSemantic() == semantic) return (*itB); - } - return NULL; -} - -// Load the geometry instance from the COLLADA document -FUStatus FCDGeometryInstance::LoadFromXML(xmlNode* instanceNode) -{ - FUStatus status = FCDEntityInstance::LoadFromXML(instanceNode); - if (!status) return status; - - if (entity == NULL) - { - return status.Fail(FS("Trying to instantiate non-valid geometric entity."), instanceNode->line); - } - - // Check for the expected instantiation node type - if (!IsEquivalent(instanceNode->name, DAE_INSTANCE_GEOMETRY_ELEMENT) && !IsEquivalent(instanceNode->name, DAE_INSTANCE_CONTROLLER_ELEMENT) - && !IsEquivalent(instanceNode->name, DAE_INSTANCE_ELEMENT)) - { - return status.Fail(FS("Unknown element for instantiation of entity: ") + TO_FSTRING(entity->GetDaeId()), instanceNode->line); - } - - // Look for the element. The others are discarded for now. - xmlNode* bindMaterialNode = FindChildByType(instanceNode, DAE_BINDMATERIAL_ELEMENT); - if (bindMaterialNode != NULL) - { - // Retrieve the list of the elements. - xmlNode* techniqueNode = FindChildByType(bindMaterialNode, DAE_TECHNIQUE_COMMON_ELEMENT); - xmlNodeList materialNodes; - FindChildrenByType(techniqueNode, DAE_INSTANCE_MATERIAL_ELEMENT, materialNodes); - for (xmlNodeList::iterator itM = materialNodes.begin(); itM != materialNodes.end(); ++itM) - { - FCDMaterialInstance* material = new FCDMaterialInstance(GetDocument(), this); - status.AppendStatus(material->LoadFromXML(*itM)); - materials.push_back(material); - } - } - - if (materials.empty()) - { - // COLLADA 1.3 backward compatibility: Create blank material instances for all the geometry's - // polygons that have a valid material semantic - FCDEntity* itE = entity; - while (itE != NULL && itE->GetType() == FCDEntity::CONTROLLER) itE = ((FCDController*) itE)->GetBaseTarget(); - if (itE != NULL) - { - FCDGeometry* geometry = (FCDGeometry*) itE; - if (geometry->IsMesh()) - { - FCDGeometryMesh* mesh = geometry->GetMesh(); - size_t polygonsCount = mesh->GetPolygonsCount(); - for (size_t i = 0; i < polygonsCount; ++i) - { - FCDGeometryPolygons* polygons = mesh->GetPolygons(i); - const fstring& materialSemantic = polygons->GetMaterialSemantic(); - - if (!materialSemantic.empty()) - { - FCDMaterialInstance* material = new FCDMaterialInstance(GetDocument(), this); - status.AppendStatus(material->LoadFromId(FUStringConversion::ToString(materialSemantic))); - materials.push_back(material); - } - } - } - } - } - - return status; -} - -// Write out the instantiation information to the xml node tree -xmlNode* FCDGeometryInstance::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* instanceNode = FCDEntityInstance::WriteToXML(parentNode); - if (!materials.empty()) - { - xmlNode* bindMaterialNode = AddChild(instanceNode, DAE_BINDMATERIAL_ELEMENT); - xmlNode* techniqueCommonNode = AddChild(bindMaterialNode, DAE_TECHNIQUE_COMMON_ELEMENT); - for (FCDMaterialInstanceList::const_iterator itM = materials.begin(); itM != materials.end(); ++itM) - { - (*itM)->WriteToXML(techniqueCommonNode); - } - } - return instanceNode; -} diff --git a/Extras/FCollada/FCDocument/FCDGeometryInstance.h b/Extras/FCollada/FCDocument/FCDGeometryInstance.h deleted file mode 100644 index 1165da715..000000000 --- a/Extras/FCollada/FCDocument/FCDGeometryInstance.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _FCD_GEOMETRY_ENTITY_H_ -#define _FCD_GEOMETRY_ENTITY_H_ - -#include "FCDocument/FCDEntityInstance.h" - -class FCDocument; -class FCDMaterialInstance; - -typedef vector FCDMaterialInstanceList; - -class FCOLLADA_EXPORT FCDGeometryInstance : public FCDEntityInstance -{ -private: - FCDMaterialInstanceList materials; - -public: - FCDGeometryInstance(FCDocument* document, FCDEntity* entity); - virtual ~FCDGeometryInstance(); - - // FCDEntity override for RTTI-like - virtual Type GetType() const { return GEOMETRY; } - - // Access Bound Materials - FCDMaterialInstance* FindMaterialInstance(const fstring& semantic); - const FCDMaterialInstance* FindMaterialInstance(const fstring& semantic) const; - const FCDMaterialInstanceList& GetMaterialInstanceList() const { return materials; } - - // Load the geometry instance from the COLLADA document - virtual FUStatus LoadFromXML(xmlNode* instanceNode); - - // Write out the instantiation information to the xml node tree - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -#endif // _FCD_GEOMETRY_ENTITY_H_ diff --git a/Extras/FCollada/FCDocument/FCDGeometryMesh.cpp b/Extras/FCollada/FCDocument/FCDGeometryMesh.cpp deleted file mode 100644 index 927921504..000000000 --- a/Extras/FCollada/FCDocument/FCDGeometryMesh.cpp +++ /dev/null @@ -1,358 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDGeometry.h" -#include "FCDocument/FCDGeometryMesh.h" -#include "FCDocument/FCDGeometryPolygons.h" -#include "FCDocument/FCDGeometrySource.h" -#include "FUtils/FUStringConversion.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDGeometryMesh::FCDGeometryMesh(FCDocument* document, FCDGeometry* _parent) : FCDObject(document, "FCDGeometryMesh") -{ - m_convex = false; - parent = _parent; - faceVertexCount = faceCount = holeCount = 0; - isDoubleSided = true; -} - -FCDGeometryMesh::~FCDGeometryMesh() -{ - CLEAR_POINTER_VECTOR(sources); - CLEAR_POINTER_VECTOR(polygons); - faceVertexCount = faceCount = 0; - parent = NULL; -} - -// Retrieve the parent's id -const string& FCDGeometryMesh::GetDaeId() const -{ - return parent->GetDaeId(); -} - -// Search for a data source in the geometry node -FCDGeometrySource* FCDGeometryMesh::FindSourceById(const string& id) -{ - const char* localId = id.c_str(); - if (localId[0] == '#') ++localId; - for (FCDGeometrySourceList::iterator it = sources.begin(); it != sources.end(); ++it) - { - if ((*it)->GetSourceId() == localId) return (*it); - } - return NULL; -} - -// Search for a data source in the geometry node -const FCDGeometrySource* FCDGeometryMesh::FindSourceById(const string& id) const -{ - const char* localId = id.c_str(); - if (localId[0] == '#') ++localId; - for (FCDGeometrySourceList::const_iterator it = sources.begin(); it != sources.end(); ++it) - { - if ((*it)->GetSourceId() == localId) return (*it); - } - return NULL; -} - -// Retrieve the source for the vertex position -FCDGeometrySource* FCDGeometryMesh::GetPositionSource() -{ - string vertexSourceId; - for (FCDGeometrySourceList::iterator itS = vertexSources.begin(); itS != vertexSources.end(); ++itS) - { - if ((*itS)->GetSourceType() == FUDaeGeometryInput::POSITION) return (*itS); - } - return NULL; -} - -// Retrieve the source of the vertex position -const FCDGeometrySource* FCDGeometryMesh::GetPositionSource() const -{ - string vertexSourceId; - for (FCDGeometrySourceList::const_iterator itS = vertexSources.begin(); itS != vertexSources.end(); ++itS) - { - if ((*itS)->GetSourceType() == FUDaeGeometryInput::POSITION) return (*itS); - } - return NULL; -} - -// Creates a new polygon group. -FCDGeometryPolygons* FCDGeometryMesh::AddPolygons() -{ - FCDGeometryPolygons* polys = new FCDGeometryPolygons(GetDocument(), this); - polygons.push_back(polys); - - // Add to this new polygons all the per-vertex sources. - for (FCDGeometrySourceList::iterator itS = vertexSources.begin(); itS != vertexSources.end(); ++itS) - { - polys->AddInput(*itS, 0); - } - - return polys; -} - -// Creates a new per-vertex data source -FCDGeometrySource* FCDGeometryMesh::AddVertexSource() -{ - FCDGeometrySource* vertexSource = AddSource(); - vertexSources.push_back(vertexSource); - - // Add this new per-vertex data source to all the existing polygon groups, at offset 0. - for (FCDGeometryPolygonsList::iterator itP = polygons.begin(); itP != polygons.end(); ++itP) - { - (*itP)->AddInput(vertexSource, 0); - } - return vertexSource; -} - -// Creates a new data source -FCDGeometrySource* FCDGeometryMesh::AddSource() -{ - FCDGeometrySource* source = new FCDGeometrySource(GetDocument()); - sources.push_back(source); - return source; -} - -// Forces the triangulation of the mesh polygons -void FCDGeometryMesh::Triangulate() -{ - for (FCDGeometryPolygonsList::iterator itP = polygons.begin(); itP != polygons.end(); ++itP) - { - (*itP)->Triangulate(); - } - - // Recalculate the mesh/polygons statistics - Recalculate(); -} - -// Recalculates all the hole/vertex/face-vertex counts and offsets within the mesh and its polygons -void FCDGeometryMesh::Recalculate() -{ - faceCount = holeCount = faceVertexCount = 0; - for (FCDGeometryPolygonsList::iterator itP = polygons.begin(); itP != polygons.end(); ++itP) - { - FCDGeometryPolygons* polygons = *itP; - polygons->Recalculate(); - - polygons->SetFaceOffset(faceCount); - polygons->SetHoleOffset(holeCount); - polygons->SetFaceVertexOffset(faceVertexCount); - faceCount += polygons->GetFaceCount(); - holeCount += polygons->GetHoleCount(); - faceVertexCount += polygons->GetFaceVertexCount(); - } -} - -// Create a copy of this geometry, with the vertices overwritten -FCDGeometryMesh* FCDGeometryMesh::Clone(FloatList& newPositions, uint32 newPositionsStride, FloatList& newNormals, uint32 newNormalsStride) -{ - // Create the clone and fill it with the known information - FCDGeometryMesh* clone = new FCDGeometryMesh(GetDocument(), NULL); - clone->faceCount = faceCount; - - // Clone the source data - size_t sourceCount = sources.size(); - clone->sources.reserve(sourceCount); - for (FCDGeometrySourceList::const_iterator itS = sources.begin(); itS != sources.end(); ++itS) - { - clone->sources.push_back((*itS)->Clone()); - if (std::find(vertexSources.begin(), vertexSources.end(), (*itS)) != vertexSources.end()) - { - clone->vertexSources.push_back(clone->sources.back()); - } - } - - // Clone the polygons data - // Gather up the position and normal data sources - FCDGeometrySourceList positionSources, normalSources; - size_t polygonsCount = polygons.size(); - clone->polygons.resize(polygonsCount); - for (size_t i = 0; i < polygonsCount; ++i) - { - clone->polygons[i] = polygons[i]->Clone(clone); - - // Retrieve the position data source - FCDGeometryPolygonsInput* positionInput = clone->polygons[i]->FindInput(FUDaeGeometryInput::POSITION); - if (positionInput != NULL) - { - FCDGeometrySource* dataSource = positionInput->source; - FUAssert(dataSource != NULL, continue); - if (std::find(positionSources.begin(), positionSources.end(), dataSource) == positionSources.end()) - { - positionSources.push_back(dataSource); - } - } - - // Retrieve the normal data source - FCDGeometryPolygonsInput* normalInput = clone->polygons[i]->FindInput(FUDaeGeometryInput::NORMAL); - if (normalInput != NULL) - { - FCDGeometrySource* dataSource = normalInput->source; - FUAssert(dataSource != NULL, continue); - if (std::find(normalSources.begin(), normalSources.end(), dataSource) == normalSources.end()) - { - normalSources.push_back(dataSource); - } - } - } - - // Override the position and normal data sources with the given data (from the controller's bind shape) -# define OVERWRITE_SOURCES(cloneSources, newSourceData, newSourceStride) { \ - size_t dataSourceCount = min(cloneSources.size(), newSourceData.size()), offset = 0; \ - for (size_t i = 0; i < dataSourceCount; ++i) { \ - FCDGeometrySource* dataSource = cloneSources[i]; \ - size_t dataCount = dataSource->GetSourceData().size() / dataSource->GetSourceStride(); \ - if (offset + dataCount > newSourceData.size() / newSourceStride) dataCount = newSourceData.size() / newSourceStride - offset; \ - if (dataCount == 0) break; \ - /* Insert the relevant data in this source */ \ - dataSource->SetSourceData(newSourceData, newSourceStride, offset * newSourceStride, (offset + dataCount) * newSourceStride); \ - offset += dataCount; \ - } } - - OVERWRITE_SOURCES(positionSources, newPositions, newPositionsStride); - OVERWRITE_SOURCES(normalSources, newNormals, newNormalsStride); -# undef OVERWRITE_SOURCES - - return clone; -} - -// Read in the node of the COLLADA document -FUStatus FCDGeometryMesh::LoadFromXML(xmlNode* meshNode) -{ - FUStatus status; - - // Read in the data sources - xmlNodeList sourceDataNodes; - FindChildrenByType(meshNode, DAE_SOURCE_ELEMENT, sourceDataNodes); - for (xmlNodeList::iterator it = sourceDataNodes.begin(); it != sourceDataNodes.end(); ++it) - { - FCDGeometrySource* source = AddSource(); - status.AppendStatus(source->LoadFromXML(*it)); - if (source->GetSourceStride() < 3) continue; - - // COLLADA 1.3 backward compatibility - // Maya-specific: Look for the double-sided flag in the normals source - StringList parameterNames; xmlNodeList parameterNodes; - xmlNode* mayaTechniqueNode = FindTechnique((*it), DAEMAYA_MAYA_PROFILE); - FindParameters(mayaTechniqueNode, parameterNames, parameterNodes); - size_t parameterCount = parameterNodes.size(); - for (size_t i = 0; i < parameterCount; ++i) - { - const char* content = ReadNodeContentDirect(parameterNodes[i]); - if (parameterNames[i] == DAEMAYA_DOUBLE_SIDED_PARAMETER) isDoubleSided = FUStringConversion::ToBoolean(content); - } - } - - // Retrieve the node - xmlNode* verticesNode = FindChildByType(meshNode, DAE_VERTICES_ELEMENT); - if (verticesNode == NULL) - { - return status.Warning(FS("No element in mesh: ") + TO_FSTRING(parent->GetDaeId()), meshNode->line); - } - - // Read in the per-vertex inputs - bool hasPositions = false; - - xmlNodeList vertexInputNodes; - FindChildrenByType(verticesNode, DAE_INPUT_ELEMENT, vertexInputNodes); - for (xmlNodeList::iterator it = vertexInputNodes.begin(); it < vertexInputNodes.end(); ++it) - { - xmlNode* vertexInputNode = *it; - string inputSemantic = ReadNodeSemantic(vertexInputNode); - FUDaeGeometryInput::Semantic semantic = FUDaeGeometryInput::FromString(inputSemantic); - if (semantic == FUDaeGeometryInput::POSITION || semantic == FUDaeGeometryInput::NORMAL - || semantic == FUDaeGeometryInput::COLOR || semantic == FUDaeGeometryInput::TEXCOORD) - { - string sourceId = ReadNodeSource(vertexInputNode); - FCDGeometrySource* source = FindSourceById(sourceId); - if (source == NULL) - { - return status.Fail(FS("Mesh has source with an unknown id: ") + TO_FSTRING(parent->GetDaeId()), vertexInputNode->line); - } - source->SetSourceType(semantic); - if (semantic == FUDaeGeometryInput::POSITION) hasPositions = true; - vertexSources.push_back(source); - } - } - if (!hasPositions) - { - return status.Warning(FS("No vertex position input node in mesh: ") + TO_FSTRING(parent->GetDaeId()), verticesNode->line); - } - - // Create our rendering object and read in the tessellation - xmlNodeList polygonsNodes; - FindChildrenByType(meshNode, DAE_POLYGONS_ELEMENT, polygonsNodes); - FindChildrenByType(meshNode, DAE_TRIANGLES_ELEMENT, polygonsNodes); - FindChildrenByType(meshNode, DAE_POLYLIST_ELEMENT, polygonsNodes); - if (polygonsNodes.empty()) - { - return status.Warning(FS("No tessellation found for mesh: ") + TO_FSTRING(parent->GetDaeId()), meshNode->line); - } - for (xmlNodeList::iterator it = polygonsNodes.begin(); it != polygonsNodes.end(); ++it) - { - // Create the geometry polygons object - xmlNode* polygonsNode = *it; - FCDGeometryPolygons* polygon = new FCDGeometryPolygons(GetDocument(), this); - polygons.push_back(polygon); - status = polygon->LoadFromXML(polygonsNode); - if (!status) return status; - } - - // Calculate the important statistics/offsets/counts - Recalculate(); - - // Apply the length factor on the vertex positions - float lengthFactor = GetDocument()->GetLengthUnitConversion(); - FCDGeometrySource* positionSource = GetPositionSource(); - if (positionSource == NULL) - { - return status.Fail(FS("Cannot process the vertex POSITION source for mesh: ") + TO_FSTRING(parent->GetDaeId()), meshNode->line); - } - FloatList& positionData = positionSource->GetSourceData(); - for (FloatList::iterator it = positionData.begin(); it != positionData.end(); ++it) (*it) *= lengthFactor; - - return status; -} - -// Write out the node to the COLLADA xml tree -xmlNode* FCDGeometryMesh::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* meshNode = AddChild(parentNode, DAE_MESH_ELEMENT); - - // Write out the sources - for (FCDGeometrySourceList::const_iterator itS = sources.begin(); itS != sources.end(); ++itS) - { - (*itS)->WriteToXML(meshNode); - } - - // Write out the element - xmlNode* verticesNode = AddChild(meshNode, DAE_VERTICES_ELEMENT); - for (FCDGeometrySourceList::const_iterator itS = vertexSources.begin(); itS != vertexSources.end(); ++itS) - { - const char* semantic = FUDaeGeometryInput::ToString((*itS)->GetSourceType()); - AddInput(verticesNode, (*itS)->GetSourceId(), semantic); - } - FUSStringBuilder verticesNodeId(GetDaeId()); verticesNodeId.append("-vertices"); - AddAttribute(verticesNode, DAE_ID_ATTRIBUTE, verticesNodeId); - - // Write out the polygons - for (FCDGeometryPolygonsList::const_iterator itP = polygons.begin(); itP != polygons.end(); ++itP) - { - (*itP)->WriteToXML(meshNode); - } - - return meshNode; -} diff --git a/Extras/FCollada/FCDocument/FCDGeometryMesh.h b/Extras/FCollada/FCDocument/FCDGeometryMesh.h deleted file mode 100644 index 15a0b49cc..000000000 --- a/Extras/FCollada/FCDocument/FCDGeometryMesh.h +++ /dev/null @@ -1,211 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDGeometryMesh.h - This file contains the FCDGeometryMesh class. -*/ - -#ifndef _FCD_GEOMETRY_MESH_H_ -#define _FCD_GEOMETRY_MESH_H_ - -#include "FCDocument/FCDObject.h" -#include "FUtils/FUDaeEnum.h" - -class FCDocument; -class FCDGeometry; -class FCDGeometryPolygons; -class FCDGeometrySource; - -/** A dynamically-sized array of FCDGeometrySource objects. */ -typedef vector FCDGeometrySourceList; -/** A dynamically-sized array of FCDGeometryPolygons objects. */ -typedef vector FCDGeometryPolygonsList; - -/** - A COLLADA geometric mesh. - A COLLADA geometric mesh is a list of vertices tied together in polygons. - A set of per-vertex data is used to determine the vertices of the mesh. - This data usually includes a single list: of vertex positions, but it may also - contain per-vertex colors, per-vertex normals or per-vertex texture coordinates. - The other data sources declare per-vertex-face data. - - The faces of a mesh may be split across different groups, as they may have - different materials assigned to them. The FCDGeometryPolygons objects contains one such group - of faces. - - @ingroup FCDGeometry -*/ -class FCOLLADA_EXPORT FCDGeometryMesh : public FCDObject -{ -private: - FCDGeometry* parent; - FCDGeometrySourceList sources; - FCDGeometryPolygonsList polygons; - - FCDGeometrySourceList vertexSources; - size_t faceCount, holeCount; - size_t faceVertexCount; - bool isDoubleSided; // Maya-specific, defaults to true - -public: - /** Contructor: do not use directly. Use FCDGeometry::AddMesh instead. - @param document The COLLADA document which owns this mesh. - @param parent The geometry entity which contains this mesh. */ - FCDGeometryMesh(FCDocument* document, FCDGeometry* parent); - - /** Destructor: do not use directly. All geometric meshes are released with the geometry that they belong to. */ - virtual ~FCDGeometryMesh(); - - /** Retrieves the number of faces within the geometric mesh. - @return The number of faces within the geometric mesh. */ - inline size_t GetFaceCount() const { return faceCount; } - - /** Retrieves the number of holes within the faces of the geometric mesh. - As one face may contain multiple holes, this value may be larger than the number of faces. - @return The number of holes within the faces of the geometric mesh. */ - inline size_t GetHoleCount() const { return holeCount; } - - /** Retrieves the total number of per-face vertices in the mesh. - This function makes no assumption about the uniqueness of the per-face vertices. - @return The total number of per-face vertices in the mesh. */ - inline size_t GetFaceVertexCount() const { return faceVertexCount; } - - /** Retrieves whether the mesh should be treated as double-sided. - This flag does not belong to COLLADA but is exported at the geometric-level by ColladaMaya. - @return Whether the mesh is double-sided. */ - inline bool IsDoubleSided() const { return isDoubleSided; } - - /** Retrieves the COLLADA id of the mesh. - This is a shortcut to the parent geometry's COLLADA id. - @return The COLLADA id of the mesh. */ - const string& GetDaeId() const; - - /** Retrieves the number of independent polygon groups. - Each polygon group is represented within a FCDGeometryPolygons object. - An independent polygon group is usually created to assign a different material to different parts of the mesh - or to assign partial texture coordinates and texture tangents to different parts of the mesh. - @return The number of independent polygon groups. */ - inline size_t GetPolygonsCount() const { return polygons.size(); } - - /** Retrieves a specific polygon group. - Each polygon group is represented within a FCDGeometryPolygons object. - An independent polygon group is usually created to assign a different material to different parts of the mesh - or to assign partial texture coordinates and texture tangents to different parts of the mesh. - @param index The index of the polygon group. This index should be less than the number - of independent polygon groups returned by the GetPolygonsCount function. - @return The polygon group. This pointer will be NULL if the index is out-of-bounds. */ - inline FCDGeometryPolygons* GetPolygons(size_t index) { FUAssert(index < GetPolygonsCount(), return NULL); return polygons.at(index); } - inline const FCDGeometryPolygons* GetPolygons(size_t index) const { FUAssert(index < GetPolygonsCount(), return NULL); return polygons.at(index); } /**< See above. */ - - /** Creates a new polygon group. - Each polygon group is represented within a FCDGeometryPolygons object. - The new polygon group will be assigned all the existing per-vertex data sources. - No material will be assigned to the new polygon group. - @return The new polygon group. This pointer should never be NULL. */ - FCDGeometryPolygons* AddPolygons(); - - /** [INTERNAL] Retrieves the list of per-vertex data sources. - There should usually be one per-vertex data source that contains positions. - All the sources within this list are also present within the data source list. - @return The list of per-vertex data sources. */ - inline FCDGeometrySourceList& GetVertexSources() { return vertexSources; } - inline const FCDGeometrySourceList& GetVertexSources() const { return vertexSources; } /**< See above. */ - - /** Retrieves the number of per-vertex data sources. - This number should always be lesser or equal to the number of data sources, as each per-vertex - data source is also included within the list of data sources. - @return The number of per-vertex data sources. */ - inline size_t GetVertexSourceCount() const { return vertexSources.size(); } - - /** Retrieves a specific per-vertex data source. - All the per-vertex data sources are also included in the list of data sources. - @param index The index of the per-vertex data source. This index should be less than the number of - per-vertex data sources returns by the GetVertexSourceCount function. - @return The per-vertex data source. This pointer will be NULL if the index is out-of-bounds. */ - inline FCDGeometrySource* GetVertexSource(size_t index) { FUAssert(index < GetVertexSourceCount(), return NULL); return vertexSources.at(index); } - inline const FCDGeometrySource* GetVertexSource(size_t index) const { FUAssert(index < GetVertexSourceCount(), return NULL); return vertexSources.at(index); } /**< See above. */ - - /** Creates a new per-vertex data source for this geometric mesh. - The per-vertex data source will be added to both the per-vertex data source list and the data source list. - The new per-vertex data source will automatically be added to all the existing polygon groups. - @return The new per-vertex data source. This pointer should never be NULL. */ - FCDGeometrySource* AddVertexSource(); - - /** [INTERNAL] Retrieves the data source that matches the given COLLADA id. - @param id A valid COLLADA id. - @return The data source. This pointer will be NULL if no matching data source was found. */ - FCDGeometrySource* FindSourceById(const string& id); - const FCDGeometrySource* FindSourceById(const string& id) const; /**< See above. */ - - /** Retrieves the per-vertex data that specifically contains the vertex positions. - If there are more than one per-vertex data source that contains vertex positions, the first one is returned. - @return A per-vertex data source that contains vertex positions. This pointer will be NULL - in the unlikely possibility that there are no per-vertex data source that contains vertex positions. */ - FCDGeometrySource* GetPositionSource(); - const FCDGeometrySource* GetPositionSource() const; /**< See above. */ - - /** Retrieves the number of data sources contained within this geometric mesh. - @return The number of data sources within the mesh. */ - inline size_t GetSourceCount() const { return sources.size(); } - - /** Retrieves a specific data source. - @param index The index of the data source. This index should be less than the number of - data sources returns by the GetSourceCount function. - @return The data source. This pointer will be NULL if the index is out-of-bounds. */ - inline FCDGeometrySource* GetSource(size_t index) { FUAssert(index < GetSourceCount(), return NULL); return sources.at(index); } - inline const FCDGeometrySource* GetSource(size_t index) const { FUAssert(index < GetSourceCount(), return NULL); return sources.at(index); } /**< See above. */ - - /** Creates a new data source for this geometric mesh. - The new data source will not be added to any of the existing polygon groups. - @return The new per-vertex data source. This pointer should never be NULL. */ - FCDGeometrySource* AddSource(); - - /** Triangulates the mesh. - A simple fanning techique is currently used: holes will not be triangulated correctly. */ - void Triangulate(); - - /** [INTERNAL] Forces the recalculation of the hole count, vertex count, face-vertex counts and their offsets. - Since the counts and offsets are buffered at the geometric mesh object level, this function allows the polygon - groups to force the recalculation of the buffered values, when they are modified. */ - void Recalculate(); - - /** [INTERNAL] Creates a copy of this mesh. You may use the FCDGeometry::Clone function instead of this function. - Creates a full copy of the geometry, with the vertices overwritten - by the given data: this is used when importing COLLADA 1.3 skin controllers. - You will need to release the cloned entity. - @see FCDGeometry::Clone. - @param newPositions The list of vertex position that will - overwrite the current mesh vertex positions. This list may be empty. - @param newPositionsStride The stride, in bytes, of the newPositions list. - For an empty newPositions list, this value is discarded. - @param newNormals The list of vertex normals that will overwrite - the current mesh vertex normals. This list may be empty. - @param newNormalsStride The stride, in bytes, of the newNormals list. - For an empty newNormals list, this value is discarded. - @return The cloned geometry entity. You will need to release this pointer. */ - FCDGeometryMesh* Clone(FloatList& newPositions, uint32 newPositionsStride, FloatList& newNormals, uint32 newNormalsStride); - - /** [INTERNAL] Reads in the \ element from a given COLLADA XML tree node. - @param meshNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the geometric mesh.*/ - FUStatus LoadFromXML(xmlNode* meshNode); - - /** [INTERNAL] Writes out the \ element to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the geometric mesh. - @return The created \ element XML tree node. */ - xmlNode* WriteToXML(xmlNode* parentNode) const; - - bool m_convex; -}; - -#endif // _FCD_GEOMETRY_MESH_H_ diff --git a/Extras/FCollada/FCDocument/FCDGeometryPolygons.cpp b/Extras/FCollada/FCDocument/FCDGeometryPolygons.cpp deleted file mode 100644 index 4b0aa6977..000000000 --- a/Extras/FCollada/FCDocument/FCDGeometryPolygons.cpp +++ /dev/null @@ -1,811 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDGeometryMesh.h" -#include "FCDocument/FCDGeometryPolygons.h" -#include "FCDocument/FCDGeometrySource.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -#include "FUtils/FUStringConversion.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -typedef vector UniqueVerticesTable; - -FCDGeometryPolygons::FCDGeometryPolygons(FCDocument* document, FCDGeometryMesh* _parent) : FCDObject(document, "FCDGeometryPolygons") -{ - parent = _parent; - faceVertexCount = 0; - faceOffset = faceVertexOffset = 0; -} - -FCDGeometryPolygons::~FCDGeometryPolygons() -{ - CLEAR_POINTER_VECTOR(inputs); - idxOwners.clear(); - holeFaces.clear(); - parent = NULL; -} - - -// Creates a new face. -void FCDGeometryPolygons::AddFace(uint32 degree) -{ - faceVertexCounts.push_back(degree); - - // Inserts empty indices - for (FCDGeometryPolygonsInputList::iterator it = idxOwners.begin(); it != idxOwners.end(); ++it) - { - FCDGeometryPolygonsInput* input = (*it); - input->indices.resize(input->indices.size() + degree, 0); - } - - parent->Recalculate(); -} - -// Removes a face -void FCDGeometryPolygons::RemoveFace(size_t index) -{ - FUAssert(index < GetFaceCount(), return); - - // Remove the associated indices, if they exist. - size_t offset = GetFaceVertexOffset(index); - size_t indexCount = GetFaceVertexCount(index); - for (FCDGeometryPolygonsInputList::iterator it = idxOwners.begin(); it != idxOwners.end(); ++it) - { - FCDGeometryPolygonsInput* input = (*it); - size_t inputIndexCount = input->indices.size(); - if (offset < inputIndexCount) - { - UInt32List::iterator end, begin = input->indices.begin() + offset; - if (offset + indexCount < inputIndexCount) end = begin + indexCount; - else end = input->indices.end(); - input->indices.erase(begin, end); - } - } - - // Remove the face and its holes - size_t holeBefore = GetHoleCountBefore(index); - UInt32List::iterator itFV = faceVertexCounts.begin() + index + holeBefore; - size_t holeCount = GetHoleCount(index); - faceVertexCounts.erase(itFV, itFV + holeCount + 1); // +1 in order to remove the polygon as well as the holes. - - parent->Recalculate(); -} - -// Calculates the offset of face-vertex pairs before the given face index within the polygon set. -size_t FCDGeometryPolygons::GetFaceVertexOffset(size_t index) const -{ - size_t offset = 0; - - // We'll need to skip over the holes - size_t holeCount = GetHoleCountBefore(index); - if (index + holeCount < faceVertexCounts.size()) - { - // Sum up the wanted offset - UInt32List::const_iterator end = faceVertexCounts.begin() + index + holeCount; - for (UInt32List::const_iterator it = faceVertexCounts.begin(); it != end; ++it) - { - offset += (*it); - } - } - return offset; -} - -// Calculates the number of holes within the polygon set that appear before the given face index. -size_t FCDGeometryPolygons::GetHoleCountBefore(size_t index) const -{ - size_t holeCount = 0; - for (UInt32List::const_iterator it = holeFaces.begin(); it != holeFaces.end(); ++it) - { - if ((*it) < index) ++holeCount; - } - return holeCount; -} - -// Retrieves the number of holes within a given face. -size_t FCDGeometryPolygons::GetHoleCount(size_t index) const -{ - size_t holeCount = 0; - for (size_t i = GetFaceVertexOffset(index) + 1; i < faceVertexCounts.size(); ++i) - { - bool isHoled = std::find(holeFaces.begin(), holeFaces.end(), i) != holeFaces.end(); - if (!isHoled) break; - else ++holeCount; - } - return holeCount; -} - -// The number of face-vertex pairs for a given face. -size_t FCDGeometryPolygons::GetFaceVertexCount(size_t index) const -{ - size_t count = 0; - if (index < GetFaceCount()) - { - size_t holeCount = GetHoleCount(index); - UInt32List::const_iterator it = faceVertexCounts.begin() + index + GetHoleCountBefore(index); - UInt32List::const_iterator end = it + holeCount + 1; // +1 in order to sum the face-vertex pairs of the polygon as its holes. - for (; it != end; ++it) count += (*it); - } - return count; -} - -FCDGeometryPolygonsInput* FCDGeometryPolygons::AddInput(FCDGeometrySource* source, uint32 offset) -{ - FCDGeometryPolygonsInput* input = new FCDGeometryPolygonsInput(); - input->source = source; - input->idx = offset; - input->semantic = source->GetSourceType(); - - // Check if the offset is new - input->ownsIdx = true; - for (FCDGeometryPolygonsInputList::iterator it = inputs.begin(); it != inputs.end(); ++it) - { - if ((*it)->idx == input->idx) - { - input->ownsIdx = false; - break; - } - } - - inputs.push_back(input); - if (input->ownsIdx) idxOwners.push_back(input); - return input; -} - -void FCDGeometryPolygons::ReleaseInput(FCDGeometryPolygonsInput* input) -{ - FCDGeometryPolygonsInputList::iterator itP = std::find(inputs.begin(), inputs.end(), input); - if (itP != inputs.end()) - { - // Before releasing the polygon set input, verify that shared indices are not lost - if (input->ownsIdx) - { - for (FCDGeometryPolygonsInputList::iterator it = inputs.begin(); it != inputs.end(); ++it) - { - if ((*it)->idx == input->idx && !(*it)->ownsIdx) - { - (*it)->indices = input->indices; - (*it)->ownsIdx = true; - idxOwners.push_back(*it); - break; - } - } - - FCDGeometryPolygonsInputList::iterator itO = std::find(idxOwners.begin(), idxOwners.end(), input); - if (itO != idxOwners.end()) idxOwners.erase(itO); - input->indices.clear(); - input->ownsIdx = false; - } - - // Release the polygon set input - SAFE_DELETE(input); - inputs.erase(itP); - } -} - -FCDGeometryPolygonsInput* FCDGeometryPolygons::FindInput(FUDaeGeometryInput::Semantic semantic) -{ - for (FCDGeometryPolygonsInputList::iterator it = inputs.begin(); it != inputs.end(); ++it) - { - if ((*it)->semantic == semantic) return (*it); - } - return NULL; -} - -const FCDGeometryPolygonsInput* FCDGeometryPolygons::FindInput(FUDaeGeometryInput::Semantic semantic) const -{ - for (FCDGeometryPolygonsInputList::const_iterator it = inputs.begin(); it != inputs.end(); ++it) - { - if ((*it)->semantic == semantic) return (*it); - } - return NULL; -} - -FCDGeometryPolygonsInput* FCDGeometryPolygons::FindInput(FCDGeometrySource* source) -{ - for (FCDGeometryPolygonsInputList::iterator it = inputs.begin(); it != inputs.end(); ++it) - { - if ((*it)->source == source) return (*it); - } - return NULL; -} - -const FCDGeometryPolygonsInput* FCDGeometryPolygons::FindInput(const FCDGeometrySource* source) const -{ - for (FCDGeometryPolygonsInputList::const_iterator it = inputs.begin(); it != inputs.end(); ++it) - { - if ((*it)->source == source) return (*it); - } - return NULL; -} - -FCDGeometryPolygonsInput* FCDGeometryPolygons::FindInput(const string& sourceId) -{ - const char* s = sourceId.c_str(); - if (*s == '#') ++s; - for (FCDGeometryPolygonsInputList::iterator it = inputs.begin(); it != inputs.end(); ++it) - { - if ((*it)->source->GetDaeId() == s) return (*it); - } - return NULL; -} - -void FCDGeometryPolygons::FindInputs(FUDaeGeometryInput::Semantic semantic, FCDGeometryPolygonsInputList& _inputs) -{ - for (FCDGeometryPolygonsInputList::iterator it = inputs.begin(); it != inputs.end(); ++it) - { - if ((*it)->semantic == semantic) _inputs.push_back(*it); - } -} - -UInt32List* FCDGeometryPolygons::FindIndicesForIdx(uint32 idx) -{ - for (FCDGeometryPolygonsInputList::iterator it = idxOwners.begin(); it != idxOwners.end(); ++it) - { - if ((*it)->idx == idx) return &(*it)->indices; - } - return NULL; -} - -const UInt32List* FCDGeometryPolygons::FindIndicesForIdx(uint32 idx) const -{ - for (FCDGeometryPolygonsInputList::const_iterator cit = idxOwners.begin(); cit != idxOwners.end(); ++cit) - { - if ((*cit)->idx == idx) return &(*cit)->indices; - } - return NULL; -} - -UInt32List* FCDGeometryPolygons::FindIndices(FCDGeometrySource* source) -{ - FCDGeometryPolygonsInput* input = FindInput(source); - return (input != NULL) ? FindIndices(input) : NULL; -} - -const UInt32List* FCDGeometryPolygons::FindIndices(const FCDGeometrySource* source) const -{ - const FCDGeometryPolygonsInput* input = FindInput(source); - return (input != NULL) ? FindIndices(input) : NULL; -} - -UInt32List* FCDGeometryPolygons::FindIndices(FCDGeometryPolygonsInput* input) -{ - FCDGeometryPolygonsInputList::iterator itP = std::find(inputs.begin(), inputs.end(), input); - return itP != inputs.end() ? FindIndicesForIdx(input->idx) : NULL; -} - -const UInt32List* FCDGeometryPolygons::FindIndices(const FCDGeometryPolygonsInput* input) const -{ - FCDGeometryPolygonsInputList::const_iterator itP = std::find(inputs.begin(), inputs.end(), input); - return itP != inputs.end() ? FindIndicesForIdx(input->idx) : NULL; -} - -// Forces the triangulation of the polygons -void FCDGeometryPolygons::Triangulate() -{ - // Pre-allocate and ready the end index/count buffers - UInt32List oldFaceVertexCounts = faceVertexCounts; - faceVertexCounts.clear(); - vector dataIndices; - vector oldDataIndices; - for (FCDGeometryPolygonsInputList::iterator itI = idxOwners.begin(); itI != idxOwners.end(); ++itI) - { - UInt32List* indices = &(*itI)->indices; - oldDataIndices.push_back(*indices); - dataIndices.push_back(indices); - indices->clear(); - } - size_t dataIndicesCount = oldDataIndices.size(); - - // Rebuild the index/count buffers through simple fan-triangulation. - // Drop holes and polygons with less than two vertices. - size_t oldOffset = 0, oldFaceCount = oldFaceVertexCounts.size(); - for (size_t oldFaceIndex = 0; oldFaceIndex < oldFaceCount; ++oldFaceIndex) - { - size_t oldFaceVertexCount = oldFaceVertexCounts[oldFaceIndex]; - bool isHole = std::find(holeFaces.begin(), holeFaces.end(), oldFaceIndex) != holeFaces.end(); - if (!isHole && oldFaceVertexCount >= 3) - { - // Fan-triangulation: works well on convex polygons. - size_t triangleCount = oldFaceVertexCount - 2; - for (size_t triangleIndex = 0; triangleIndex < triangleCount; ++triangleIndex) - { - for (size_t j = 0; j < dataIndicesCount; ++j) - { - UInt32List& oldData = oldDataIndices[j]; - UInt32List* newData = dataIndices[j]; - newData->push_back(oldData[oldOffset]); - newData->push_back(oldData[oldOffset + triangleIndex + 1]); - newData->push_back(oldData[oldOffset + triangleIndex + 2]); - } - faceVertexCounts.push_back(3); - } - } - oldOffset += oldFaceVertexCount; - } - - holeFaces.clear(); -} - -// Recalculates the face-vertex count within the polygons -void FCDGeometryPolygons::Recalculate() -{ - faceVertexCount = 0; - for (UInt32List::iterator itC = faceVertexCounts.begin(); itC != faceVertexCounts.end(); ++itC) faceVertexCount += (*itC); -} - -FUStatus FCDGeometryPolygons::LoadFromXML(xmlNode* baseNode) -{ - FUStatus status; - - // Retrieve the expected face count from the base node's 'count' attribute - size_t expectedFaceCount = ReadNodeCount(baseNode); - - // Check the node's name to know whether to expect a element - size_t expectedVertexCount; bool isPolygons = false, isTriangles = false, isPolylist = false; - if (IsEquivalent(baseNode->name, DAE_POLYGONS_ELEMENT)) { expectedVertexCount = 4; isPolygons = true; } - else if (IsEquivalent(baseNode->name, DAE_TRIANGLES_ELEMENT)) { expectedVertexCount = 3 * expectedFaceCount; isTriangles = true; } - else if (IsEquivalent(baseNode->name, DAE_POLYLIST_ELEMENT)) { expectedVertexCount = 0; isPolylist = true; } - else - { - return status.Fail(FS("Unknown polygons element in geometry: ") + TO_FSTRING(parent->GetDaeId()), baseNode->line); - } - - // Retrieve the material symbol used by these polygons - materialSemantic = TO_FSTRING(ReadNodeProperty(baseNode, DAE_MATERIAL_ATTRIBUTE)); - if (materialSemantic.empty()) - { - status.Warning(FS("Unknown or missing polygonal material symbol in geometry: ") + TO_FSTRING(parent->GetDaeId()), baseNode->line); - } - - // Read in the per-face, per-vertex inputs - uint32 idxCount = 1, tableIdx = 0; - xmlNode* itNode = NULL; - for (itNode = baseNode->children; itNode != NULL; itNode = itNode->next) - { - if (itNode->type != XML_ELEMENT_NODE) continue; - if (IsEquivalent(itNode->name, DAE_INPUT_ELEMENT)) - { - FCDGeometryPolygonsInput* input = new FCDGeometryPolygonsInput(); - string sourceId = ReadNodeSource(itNode); - if (sourceId[0] == '#') sourceId.erase(0, 1); - - // Parse input idx - string idx = ReadNodeProperty(itNode, DAE_OFFSET_ATTRIBUTE); - if (idx.empty()) idx = ReadNodeProperty(itNode, DAE_IDX_ATTRIBUTE); // COLLADA 1.3 Backward-compatibility - input->idx = (!idx.empty()) ? FUStringConversion::ToUInt32(idx) : idxCount; - idxCount = max(input->idx + 1, idxCount); - - // Parse input set - string setString = ReadNodeProperty(itNode, DAE_SET_ATTRIBUTE); - input->set = setString.empty() ? -1 : FUStringConversion::ToInt32(setString); - - // Parse input semantic - string semanticString = ReadNodeSemantic(itNode); - input->semantic = FUDaeGeometryInput::FromString(semanticString); - if (input->semantic == FUDaeGeometryInput::UNKNOWN) - { - // Unknown input type - SAFE_DELETE(input); - continue; - } - else if (input->semantic == FUDaeGeometryInput::VERTEX) - { - tableIdx = input->idx; - } - else - { - // Retrieve the source for this input - input->source = parent->FindSourceById(sourceId); - if (input->source == NULL) - { - status.Warning(FS("Unknown polygons set input with id: '") + TO_FSTRING(sourceId) + FS("' in geometry: ") + TO_FSTRING(parent->GetDaeId()), itNode->line); - SAFE_DELETE(input); - continue; - } - } - - // Check uniqueness of idx - input->ownsIdx = true; - for (FCDGeometryPolygonsInputList::iterator it = inputs.begin(); it != inputs.end(); ++it) - { - if ((*it)->idx == input->idx) - { - input->ownsIdx = false; - break; - } - } - - // Add to our lists - if (input->ownsIdx) idxOwners.push_back(input); - inputs.push_back(input); - } - else if (IsEquivalent(itNode->name, DAE_POLYGON_ELEMENT) - || IsEquivalent(itNode->name, DAE_VERTEXCOUNT_ELEMENT) - || IsEquivalent(itNode->name, DAE_POLYGONHOLED_ELEMENT)) - { - break; - } - - // COLLADA 1.3 backward compatibility: is a valid node, but unused - else if (IsEquivalent(itNode->name, DAE_PARAMETER_ELEMENT)) {} - else - { - status.Warning(FS("Unknown polygon child element in geometry: ") + TO_FSTRING(parent->GetDaeId()), itNode->line); - } - } - if (itNode == NULL) - { - return status.Fail(FS("No polygon

/ element found in geometry: ") + TO_FSTRING(parent->GetDaeId()), baseNode->line); - } - - // Look for the element and parse it in - xmlNode* vCountNode = FindChildByType(baseNode, DAE_VERTEXCOUNT_ELEMENT); - const char* vCountDataString = ReadNodeContentDirect(vCountNode); - if (vCountDataString != NULL) FUStringConversion::ToUInt32List(vCountDataString, faceVertexCounts); - bool hasVertexCounts = !faceVertexCounts.empty(); - if (isPolylist && !hasVertexCounts) - { - return status.Fail(FS("No or empty element found in geometry: ") + TO_FSTRING(parent->GetDaeId()), baseNode->line); - } - else if (!isPolylist && hasVertexCounts) - { - return status.Fail(FS(" is only expected with the element in geometry: ") + TO_FSTRING(parent->GetDaeId()), baseNode->line); - } - else if (isPolylist) - { - // Count the total number of face-vertices expected, to pre-buffer the index lists - expectedVertexCount = 0; - for (UInt32List::iterator itC = faceVertexCounts.begin(); itC != faceVertexCounts.end(); ++itC) - { - expectedVertexCount += *itC; - } - } - - string holeBuffer; - UInt32List allIndices; - // First pass, allocation for tessellation - xmlNode* savedNode = itNode; // two pass process for performance - uint32 indicesSize = 0; - faceVertexCount = 0; - allIndices.clear(); - allIndices.reserve(expectedVertexCount * idxCount); - for (; itNode != NULL; itNode = itNode->next) - { - uint32 localFaceVertexCount; - const char* content = NULL; - xmlNode* holeNode = NULL; - bool failed = false; - if (!InitTessellation(itNode, &localFaceVertexCount, allIndices, content, holeNode, idxCount, &failed)) continue; - - if (failed) - { - return status.Fail(FS("Unknown element found in element for geometry: ") + TO_FSTRING(parent->GetDaeId()), itNode->line); - } - - indicesSize += localFaceVertexCount; - } - for (FCDGeometryPolygonsInputList::iterator it = idxOwners.begin(); it != idxOwners.end(); ++it) - { - size_t currentIndexCount = (*it)->indices.size(); - (*it)->indices.reserve(currentIndexCount + indicesSize); - } - - // Second pass, saving the tessellation - faceVertexCount = 0; - allIndices.clear(); - allIndices.reserve(expectedVertexCount * idxCount); - itNode = savedNode; - for (; itNode != NULL; itNode = itNode->next) - { - uint32 localFaceVertexCount; - const char* content = NULL; - xmlNode* holeNode = NULL; - bool failed = false; - if (!InitTessellation(itNode, &localFaceVertexCount, allIndices, content, holeNode, idxCount, &failed)) continue; - - if (failed) - { - return status.Fail(FS("Unknown element found in element for geometry: ") + TO_FSTRING(parent->GetDaeId()), itNode->line); - } - - if (isTriangles) for (uint32 i = 0; i < localFaceVertexCount / 3; ++i) faceVertexCounts.push_back(3); - else if (isPolygons) faceVertexCounts.push_back(localFaceVertexCount); - faceVertexCount += localFaceVertexCount; - - // Append any hole indices found - for (; holeNode != NULL; holeNode = holeNode->next) - { - if (holeNode->type != XML_ELEMENT_NODE) continue; - - // Read in the hole indices and push them on top of the other indices - UInt32List holeIndices; holeIndices.reserve(expectedVertexCount * idxCount); - content = ReadNodeContentDirect(holeNode); - FUStringConversion::ToUInt32List(content, holeIndices); - allIndices.insert(allIndices.end(), holeIndices.begin(), holeIndices.end()); - - // Create the hole face and record its index - size_t holeVertexCount = holeIndices.size() / idxCount; - holeFaces.push_back((uint32) faceVertexCounts.size()); - faceVertexCounts.push_back((uint32) holeVertexCount); - faceVertexCount += holeVertexCount; - } - - // Create a new entry for the vertex buffer - for (size_t offset = 0; offset < allIndices.size(); offset += idxCount) - { - for (FCDGeometryPolygonsInputList::iterator it = idxOwners.begin(); it != idxOwners.end(); ++it) - { - (*it)->indices.push_back(allIndices[offset + (*it)->idx]); - } - } - } - - // Check the actual face count - if (expectedFaceCount != faceVertexCounts.size() - holeFaces.size()) - { - return status.Fail(FS("Face count for polygons node doesn't match actual number of faces found in

element(s) in geometry: ") + TO_FSTRING(parent->GetDaeId()), baseNode->line); - } - - // Merge the vertex input with the vertices node information - FCDGeometryPolygonsInputList::iterator itVertex; - for (itVertex = inputs.begin(); itVertex != inputs.end(); ++itVertex) - { - if ((*itVertex)->semantic == FUDaeGeometryInput::VERTEX) break; - } - if (itVertex == inputs.end()) - { - return status.Fail(FS("Cannot find VERTEX polygons' input within geometry: ") + TO_FSTRING(parent->GetDaeId()), baseNode->line); - } - - FCDGeometrySourceList& vertexSources = parent->GetVertexSources(); - size_t vertexMergeCount = vertexSources.size(); - if (vertexMergeCount == 0) - { - return status.Fail(FS("Empty element in geometry: ") + TO_FSTRING(parent->GetDaeId()), baseNode->line); - } - (*itVertex)->semantic = vertexSources.front()->GetSourceType(); - (*itVertex)->source = vertexSources.front(); - uint32 vertexIdx = (*itVertex)->idx; - uint32 vertexPosition = (uint32) (itVertex - inputs.begin()); - for (uint32 i = 1; i < vertexMergeCount; ++i) - { - FCDGeometryPolygonsInput* perVertexInput = new FCDGeometryPolygonsInput(); - perVertexInput->source = vertexSources[i]; - perVertexInput->semantic = vertexSources[i]->GetSourceType(); - perVertexInput->ownsIdx = false; - perVertexInput->idx = vertexIdx; - perVertexInput->set = 0; - inputs.insert(inputs.begin() + vertexPosition, perVertexInput); - } - - // Read in the polygons source animations - for (FCDGeometryPolygonsInputList::iterator it = inputs.begin(); it != inputs.end(); ++it) - { - (*it)->source->SetSourceType((*it)->semantic); - } - - return status; -} - -bool FCDGeometryPolygons::InitTessellation(xmlNode* itNode, - uint32* localFaceVertexCount, UInt32List& allIndices, - const char* content, xmlNode*& holeNode, uint32 idxCount, - bool* failed) -{ - if (itNode->type != XML_ELEMENT_NODE) return false; - if (!IsEquivalent(itNode->name, DAE_POLYGON_ELEMENT) - && !IsEquivalent(itNode->name, DAE_POLYGONHOLED_ELEMENT)) return false; - - // Retrieve the indices - content = NULL; - holeNode = NULL; - if (!IsEquivalent(itNode->name, DAE_POLYGONHOLED_ELEMENT)) - { - content = ReadNodeContentDirect(itNode); - } - else - { - // Holed face found - for (xmlNode* child = itNode->children; child != NULL; child = child->next) - { - if (child->type != XML_ELEMENT_NODE) continue; - if (IsEquivalent(child->name, DAE_POLYGON_ELEMENT)) - { - content = ReadNodeContentDirect(child); - } - else if (IsEquivalent(child->name, DAE_HOLE_ELEMENT)) - { - holeNode = child; break; - } - else - { - *failed = true; - return true; - } - } - } - - // Parse the indices - allIndices.clear(); - FUStringConversion::ToUInt32List(content, allIndices); - *localFaceVertexCount = (uint32) allIndices.size() / idxCount; - return true; -} - -// Write out the polygons structure to the COLLADA xml tree -xmlNode* FCDGeometryPolygons::WriteToXML(xmlNode* parentNode) const -{ - // Are there holes? Then, export a element. - // Are there only non-triangles within the list? Then, export a element. - // Otherwise, you only have triangles: export a element. - bool hasHoles = !holeFaces.empty(), hasNPolys = true; - if (!hasHoles) - { - UInt32List::const_iterator itC; - for (itC = faceVertexCounts.begin(); itC != faceVertexCounts.end() && (*itC) == 3; ++itC) {} - hasNPolys = (itC != faceVertexCounts.end()); - } - - // Create the base node for these polygons - const char* polygonNodeType; - if (hasHoles) polygonNodeType = DAE_POLYGONS_ELEMENT; - else if (hasNPolys) polygonNodeType = DAE_POLYLIST_ELEMENT; - else polygonNodeType = DAE_TRIANGLES_ELEMENT; - xmlNode* polygonsNode = AddChild(parentNode, polygonNodeType); - - // Add the inputs - // Find which input owner belongs to the element. Replace the semantic and the source id accordingly. - // Make sure to add that 'vertex' input only once. - FUSStringBuilder verticesNodeId(parent->GetDaeId()); verticesNodeId.append("-vertices"); - const FCDGeometrySourceList& vertexSources = parent->GetVertexSources(); - bool isVertexInputFound = false; - for (FCDGeometryPolygonsInputList::const_iterator itI = inputs.begin(); itI != inputs.end(); ++itI) - { - FCDGeometryPolygonsInput* input = *itI; - if (std::find(vertexSources.begin(), vertexSources.end(), input->source) == vertexSources.end()) - { - const char* semantic = FUDaeGeometryInput::ToString(input->semantic); - FUDaeWriter::AddInput(polygonsNode, input->source->GetDaeId(), semantic, input->idx, input->set); - } - else if (!isVertexInputFound) - { - FUDaeWriter::AddInput(polygonsNode, verticesNodeId.ToCharPtr(), DAE_VERTEX_INPUT, input->idx); - isVertexInputFound = true; - } - } - - FUSStringBuilder builder; - builder.reserve(1024); - - // For the poly-list case, export the list of vertex counts - if (!hasHoles && hasNPolys) - { - FUStringConversion::ToString(builder, faceVertexCounts); - AddChild(polygonsNode, DAE_VERTEXCOUNT_ELEMENT, builder.ToCharPtr()); - builder.clear(); - } - - // For the non-holes cases, open only one

element for all the data indices - xmlNode* pNode = NULL,* phNode = NULL; - if (!hasHoles) pNode = AddChild(polygonsNode, DAE_POLYGON_ELEMENT); - - // Export the data indices (tessellation information) - size_t faceCount = faceVertexCounts.size(); - uint32 faceVertexOffset = 0; - for (size_t faceIndex = 0; faceIndex < faceCount; ++faceIndex) - { - // For the holes cases, verify whether this face or the next one(s) are holes. We may need to open a new /

element - bool isHole = false, isHoleNext = false; - if (hasHoles) - { - for (UInt32List::const_iterator itH = holeFaces.begin(); itH != holeFaces.end(); ++itH) - { - isHole |= (*itH) == (uint32) faceIndex; - isHoleNext |= (*itH) + 1 == (uint32) faceIndex; - } - - if (!isHole) - { - // Just open a

element: this is the most common case - if (!isHoleNext) pNode = AddChild(polygonsNode, DAE_POLYGONHOLED_ELEMENT); - else - { - // Open up a new element and its

element - phNode = AddChild(polygonsNode, DAE_POLYGONHOLED_ELEMENT); - pNode = AddChild(phNode, DAE_POLYGON_ELEMENT); - } - } - else - { - // Open up a element - pNode = AddChild(phNode, DAE_HOLE_ELEMENT); - } - } - - // Write out the tessellation information for all the vertices of this face - uint32 faceVertexCount = faceVertexCounts[faceIndex]; - for (uint32 faceVertexIndex = faceVertexOffset; faceVertexIndex < faceVertexOffset + faceVertexCount; ++faceVertexIndex) - { - for (FCDGeometryPolygonsInputList::const_iterator itI = idxOwners.begin(); itI != idxOwners.end(); ++itI) - { - UInt32List& indices = (*itI)->indices; - builder.append(indices[faceVertexIndex]); - builder.append(' '); - } - } - - // For the holes cases: write out the indices for every polygon element - if (hasHoles) - { - if (!builder.empty()) builder.pop_back(); // take out the last space - AddContent(pNode, builder); - } - faceVertexOffset += faceVertexCount; - } - - // For the non-holes cases: write out the indices at the very end, for the single

element - if (!hasHoles) - { - if (!builder.empty()) builder.pop_back(); // take out the last space - AddContent(pNode, builder); - } - - // Write out the material semantic and the number of polygons - if (!materialSemantic.empty()) - { - AddAttribute(polygonsNode, DAE_MATERIAL_ATTRIBUTE, materialSemantic); - } - AddAttribute(polygonsNode, DAE_COUNT_ATTRIBUTE, GetFaceCount() - GetHoleCount()); - - return polygonsNode; -} - -// Clone this list of polygons -FCDGeometryPolygons* FCDGeometryPolygons::Clone(FCDGeometryMesh* cloneParent) -{ - FCDGeometryPolygons* clone = new FCDGeometryPolygons(GetDocument(), cloneParent); - clone->materialSemantic = materialSemantic; - clone->faceVertexCounts = faceVertexCounts; - clone->faceOffset = faceOffset; - clone->faceVertexCount = faceVertexCount; - clone->faceVertexOffset = faceVertexOffset; - - // Clone the geometry inputs - uint32 inputCount = (uint32) inputs.size(); - clone->inputs.resize(inputCount); - for (uint32 i = 0; i < inputCount; ++i) - { - clone->inputs[i] = new FCDGeometryPolygonsInput(); - clone->inputs[i]->source = cloneParent->FindSourceById(inputs[i]->source->GetDaeId()); - clone->inputs[i]->idx = inputs[i]->idx; - clone->inputs[i]->indices = inputs[i]->indices; - clone->inputs[i]->ownsIdx = inputs[i]->ownsIdx; - clone->inputs[i]->semantic = inputs[i]->semantic; - clone->inputs[i]->set = inputs[i]->set; - - // Regenerate the idxOwners list with the new inputs - if (clone->inputs[i]->ownsIdx) clone->idxOwners.push_back(clone->inputs[i]); - } - return clone; -} - -FCDGeometryPolygonsInput::FCDGeometryPolygonsInput() -{ - idx = 0; - ownsIdx = false; - semantic = FUDaeGeometryInput::UNKNOWN; - set = -1; - source = NULL; -} diff --git a/Extras/FCollada/FCDocument/FCDGeometryPolygons.h b/Extras/FCollada/FCDocument/FCDGeometryPolygons.h deleted file mode 100644 index 170d7a124..000000000 --- a/Extras/FCollada/FCDocument/FCDGeometryPolygons.h +++ /dev/null @@ -1,340 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDGeometryPolygons.h - This file defines the FCDGeometryPolygons and the FCDGeometryPolygonsInput classes. -*/ - -#ifndef _FCD_GEOMETRY_POLYGONS_H_ -#define _FCD_GEOMETRY_POLYGONS_H_ - -#include "FCDocument/FCDObject.h" -#include "FUtils/FUDaeEnum.h" - -class FCDocument; -class FRMeshPolygons; -class FCDMaterial; -class FCDGeometryMesh; -class FCDGeometrySource; - -/** - An input data source for one mesh polygons set. - This structure knows the type of input data in the data source - as well as the set and offset for the data. It also contains a - pointer to the mesh data source. - - Many polygon set inputs may have the same offset (or 'idx') when multiple - data sources are compressed together within the COLLADA document. - In this case, one and only one of the polygon set input will have - the 'ownsIdx' flag set. A polygon set input with this flag set will - contain valid indices. To find the indices of any polygon set input, - it is recommended that you use the FCDGeometryPolygons::FindIndicesForIdx function. - - @ingroup FCDGeometry -*/ -class FCDGeometryPolygonsInput -{ -public: - /** Constructor. */ - FCDGeometryPolygonsInput(); - - /** Determines the type of data to input. */ - FUDaeGeometryInput::Semantic semantic; - - /** Offset within the COLLADA document for this input. - All the inputs with the same offset value use the same indices within the COLLADA document. */ - uint32 idx; - - /** [INTERNAL] Offset owner flags. One and only one polygon set input will have this flag set for each offset value. - A polygon set input with this flag set will contain valid indices within the 'indices' member variable. - You should not set or access this flag directly. Instead, use the FCDGeometryPolygons::FindIndicesForIdx function. */ - bool ownsIdx; - - /** [INTERNAL] Tessellation indices. Use these indices to generate a list of unique vertices and generate your vertex buffers. - You should not set or access the indices directly. Instead, use the FCDGeometryPolygons::FindIndicesForIdx function. */ - UInt32List indices; - - /** Data source. This is the data source into which the indices are indexing. You need to take the data source - stride into consideration when unindexing the data. */ - FCDGeometrySource* source; - - /** Input set. Used to group together the texture coordinates with the texture tangents and binormals. - ColladaMax: this value should also represent the map channel index or texture coordinates - and vertex color channels. */ - int32 set; -}; - -/** A dynamically-sized array of FCDGeometryPolygonsInput objects. */ -typedef vector FCDGeometryPolygonsInputList; - -/** - A mesh polygon set. - Each polygon set contains a list of inputs and the tessellation information - to make polygons out of the data and indices of the input. FCollada - supports triangle lists as well as polygon lists and lists of polygons with holes. - This implies that each face has an undeterminate number of vertices. - The tessellation information creates polygons, but may also creates holes within the polygons. - - @ingroup FCDGeometry -*/ -class FCOLLADA_EXPORT FCDGeometryPolygons : public FCDObject -{ -private: - FCDGeometryPolygonsInputList inputs; - FCDGeometryPolygonsInputList idxOwners; - UInt32List faceVertexCounts; - FCDGeometryMesh* parent; - size_t faceVertexCount; - UInt32List holeFaces; - - // Buffered statistics - size_t faceOffset; - size_t faceVertexOffset; - size_t holeOffset; - - // Material for this set of polygons - fstring materialSemantic; - -public: - /** Constructor: do not use directly. Instead, use the FCDGeometryMesh::AddPolygons function - to create new polygon sets. - @param document The COLLADA document which owns this polygon set. - @param parent The geometric mesh which contains this polygon set.*/ - FCDGeometryPolygons(FCDocument* document, FCDGeometryMesh* parent); - - /** Destructor: do not use directly. - The mesh which contains this polygon set will handle its release. */ - virtual ~FCDGeometryPolygons(); - - /** Retrieves the list of face-vertex counts. Each face within the polygon set - has one or more entry within this list, depending on the number of holes within that face. - Each face-vertex count indicates the number of ordered indices - within the polygon set inputs that are used to generate a face or its holes. - To find out if a face-vertex count represents a face or its holes, check - the hole-faces list retrieved using the GetHoleFaces function. - Indirectly, the face-vertex count indicates the degree of the polygon. - @see GetHoleFaces @see GetHoleCount - @return The list of face-vertex counts.*/ - inline const UInt32List& GetFaceVertexCounts() const { return faceVertexCounts; } - - /** Retrieves the number of holes within the faces of the polygon set. - @return The number of holes within the faces of the polygon set. */ - inline size_t GetHoleCount() const { return holeFaces.size(); } - - /** Retrieves the number of faces within the polygon set. - @return The number of faces within the polygon set. */ - inline size_t GetFaceCount() const { return faceVertexCounts.size() - GetHoleCount(); } - - /** Retrieves the number of faces which appear before this polygon set within the geometric mesh. - This value is useful when traversing all the faces of a geometric mesh. - @return The number of faces in previous polygon sets. */ - inline size_t GetFaceOffset() const { return faceOffset; } - - /** Retrieves the total number of face-vertex pairs within the polygon set. - This value is the total of all the values within the face-vertex count list. - Do remember that the list of face-vertex pairs includes holes. - @return The total number of face-vertex pairs within the polygon set. */ - inline size_t GetFaceVertexCount() const { return faceVertexCount; } - - /** Retrieves the number of face-vertex pairs for a given face. - This value includes face-vertex pairs that create the polygon and its holes. - @param index A face index. - @return The number of face-vertex pairs for a given face. */ - size_t GetFaceVertexCount(size_t index) const; - - /** Retrieves the total number of face-vertex pairs which appear - before this polygon set within the geometric mesh. - This value is useful when traversing all the face-vertex pairs of a geometric mesh. - @return The number of face-vertex pairs in previous polygon sets. */ - inline size_t GetFaceVertexOffset() const { return faceVertexOffset; } - - /** Retrieves the number of holes which appear before this polygon set. - This value is useful when traversing all the face-vertex pairs of a geometric mesh. */ - inline size_t GetHoleOffset() const { return holeOffset; } - - /** Retrieves the number of face-vertex pairs which appear - before a given face within the polygon set. - This value is useful when doing per-vertex mesh operations within the polygon set. - @param index The index of the face. - @return The number of face-vertex pairs before the given face, within the polygon set. */ - size_t GetFaceVertexOffset(size_t index) const; - - /** [INTERNAL] Sets the number of faces in previous polygon sets. - Used by the FCDGeometryMesh::Recalculate function. - @param offset The number of faces in previous polygon sets. */ - inline void SetFaceOffset(size_t offset) { faceOffset = offset; } - - /** [INTERNAL] Sets the number of face-vertex pairs in previous polygon sets. - Used by the FCDGeometryMesh::Recalculate function. - @param offset The number of face-vertex pairs in previous polygon sets. */ - inline void SetFaceVertexOffset(size_t offset) { faceVertexOffset = offset; } - - /** [INTERNAL] Sets the number of holes in previous polygon sets. - Used by the FCDGeometryMesh::Recalculate function. - @param offset The number of holes in previous polygon sets. */ - inline void SetHoleOffset(size_t offset) { holeOffset = offset; } - - /** Creates a new face. - Enough indices to fill the face will be added to the polygon set inputs: you will - want to overwrite those, as they will all be set to zero. - @param degree The degree of the polygon. This number implies the number of indices - that will be expected, in order, within each of the input index lists. */ - void AddFace(uint32 degree); - - /** Removes a face - @param index The index of the face to remove. All the indices associated - with this face will also be removed. */ - void RemoveFace(size_t index); - - /** Retrieves the list of polygon set inputs. - @see FCDGeometryPolygonsInput - @return The list of polygon set inputs. */ - inline FCDGeometryPolygonsInputList& GetInputs() { return inputs; } - inline const FCDGeometryPolygonsInputList& GetInputs() const { return inputs; } /**< See above. */ - - /** Retrieves the number of polygon set inputs. - @return The number of polygon set inputs. */ - inline size_t GetInputCount() const { return inputs.size(); } - - /** Retrieves a specific polygon set input. - @param index The index of the polygon set input. This index should - not be greater than or equal to the number of polygon set inputs. - @return The specific polygon set input. This pointer will be NULL if the index is out-of-bounds. */ - inline FCDGeometryPolygonsInput* GetInput(size_t index) { FUAssert(index < GetInputCount(), return NULL); return inputs.at(index); } - inline const FCDGeometryPolygonsInput* GetInput(size_t index) const { FUAssert(index < GetInputCount(), return NULL); return inputs.at(index); } /**< See above. */ - - /** Creates a new polygon set input. - @param source The data source for the polygon set input. - @param offset The tessellation indices offset for the polygon set input. - If this value is new to the list of polygon inputs, you will need to fill in the indices. - Please use the FindIndices function to verify that the offset is new and that indices need - to be provided. The offset of zero is reserved for per-vertex data sources. - @return The new polygon set input. */ - FCDGeometryPolygonsInput* AddInput(FCDGeometrySource* source, uint32 offset); - - /** Deletes a polygon set input. - This function releases the memory held by the polygon set input as well as moves - the indices to another polygon set input with the same offset, if the offset is re-used. - @param input The polygon set input to delete. */ - void ReleaseInput(FCDGeometryPolygonsInput* input); - - /** Retrieves the list of entries within the face-vertex count list - that are considered holes. COLLADA does not support holes within holes, - so each entry within this list implies a hole within the previous face. - @see GetFaceVertexCounts - @return The list of hole entries within the face-vertex counts. */ - inline const UInt32List& GetHoleFaces() const { return holeFaces; } - - /** Retrieves the number of holes within faces of the polygon set that appear - before the given face index. This value is useful when trying to access - a specific face of a mesh, as holes and faces appear together within the - face-vertex degree list. - @param index A face index. - @return The number of holes within the polygon set that appear - before the given face index. */ - size_t GetHoleCountBefore(size_t index) const; - - /** Retrieves the number of holes within a given face. - @param index A face index. - @return The number of holes within the given face. */ - size_t GetHoleCount(size_t index) const; - - /** Retrieves the first polygon set input found that has the given data type. - @param semantic A type of geometry data. - @return The polygon set input. This pointer will be NULL if - no polygon set input matches the data type. */ - FCDGeometryPolygonsInput* FindInput(FUDaeGeometryInput::Semantic semantic); - const FCDGeometryPolygonsInput* FindInput(FUDaeGeometryInput::Semantic semantic) const; /**< See above. */ - - /** Retrieves the polygon set input that points towards a given data source. - @param source A geometry data source. - @return The polygon set input. This pointer will be NULL if - no polygon set input matches the data source. */ - FCDGeometryPolygonsInput* FindInput(FCDGeometrySource* source); - const FCDGeometryPolygonsInput* FindInput(const FCDGeometrySource* source) const; /**< See above. */ - - /** [INTERNAL] Retrieves the polygon set input that points towards a given data source. - @param sourceId The COLLADA id of a geometry data source. - @return The polygon set input. This pointer will be NULL if - no polygon set input matches the COLLADA id. */ - FCDGeometryPolygonsInput* FindInput(const string& sourceId); - - /** Retrieves all the polygon set inputs that have the given data type. - @param semantic A type of geometry data. - @param inputs A list of polygon set inputs to fill in. This list is not emptied by the function - and may remain untouched, if no polygon set input matches the given data type. */ - void FindInputs(FUDaeGeometryInput::Semantic semantic, FCDGeometryPolygonsInputList& inputs); - - /** Retrieves the tessellation indices for a given polygon set input offset. - @deprecated Instead, use the FindIndices function. - @param idx A polygon set input offset. - @return The tessellation indices corresponding to the offset. This pointer - will be NULL if there are no polygon set input which uses the given offset. */ - UInt32List* FindIndicesForIdx(uint32 idx); - const UInt32List* FindIndicesForIdx(uint32 idx) const; /**< See above. */ - - /** Retrieves the first tessellation index list for a given data source. - @param source A data source. - @return The first tessellation index list corresponding to the data source. This pointer - will be NULL if the data source is not used within this polygon set. */ - UInt32List* FindIndices(FCDGeometrySource* source); - const UInt32List* FindIndices(const FCDGeometrySource* source) const; /**< See above. */ - - /** Retrieves the tessellation indices for a given polygon set input. - @param input A given polygon set input. - @return The tessellation indices corresponding to the polygon set input. This pointer - will be NULL if the polygon set input is not used within this polygon set. */ - UInt32List* FindIndices(FCDGeometryPolygonsInput* input); - const UInt32List* FindIndices(const FCDGeometryPolygonsInput* input) const; /**< See above. */ - - /** Retrieves the symbolic name for the material used on this polygon set. - Match this symbolic name within a FCDGeometryInstance to get the - correct material instance. - @return A symbolic material name. */ - inline const fstring& GetMaterialSemantic() const { return materialSemantic; } - - /** Triangulates the polygon set. - A simple fanning techique is currently used: holes will not be triangulated correctly. */ - void Triangulate(); - - /** [INTERNAL] Recalculates the buffered offset and count values for this polygon set. */ - void Recalculate(); - - /** [INTERNAL] Reads in the polygon set element from a given COLLADA XML tree node. - COLLADA has multiple polygon set elements. The most common ones are \ and \. - @param polygonNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the polygon set.*/ - FUStatus LoadFromXML(xmlNode* polygonNode); - - /** [INTERNAL] Writes out the correct polygon set element to the given COLLADA XML tree node. - COLLADA has multiple polygon set elements. The most common ones are \ and \. - @param parentNode The COLLADA XML parent node in which to insert the geometric mesh. - @return The created XML tree node. */ - xmlNode* WriteToXML(xmlNode* parentNode) const; - - /** [INTERNAL] Creates a copy of this mesh. - You should use the FCDGeometry::Clone function instead of this function. - You will need to release the cloned entity. - @param cloneParent The geometric mesh which will contain the cloned polygon set. - @return An identical copy of the polygon set. */ - FCDGeometryPolygons* Clone(FCDGeometryMesh* cloneParent); - -private: - // Performs operations needed before tessellation - bool InitTessellation(xmlNode* itNode, - uint32* localFaceVertexCount, UInt32List& allIndices, - const char* content, xmlNode*& holeNode, uint32 idxCount, - bool* failed); -}; - -#endif // _FCD_GEOMETRY_POLYGONS_H_ diff --git a/Extras/FCollada/FCDocument/FCDGeometrySource.cpp b/Extras/FCollada/FCDocument/FCDGeometrySource.cpp deleted file mode 100644 index 0eb14221a..000000000 --- a/Extras/FCollada/FCDocument/FCDGeometrySource.cpp +++ /dev/null @@ -1,147 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDAnimated.h" -#include "FCDocument/FCDGeometrySource.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -#include "FUtils/FUDaeEnum.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDGeometrySource::FCDGeometrySource(FCDocument* document) : FCDObjectWithId(document, "GeometrySource") -{ - sourceNode = NULL; - sourceStride = 0; - sourceType = FUDaeGeometryInput::UNKNOWN; -} - -FCDGeometrySource::~FCDGeometrySource() -{ - animatedValues.clear(); -} - -void FCDGeometrySource::SetSourceData(const FloatList& _sourceData, uint32 _sourceStride, size_t offset, size_t count) -{ - // Remove all the data currently held by the source. - sourceData.clear(); - sourceStride = _sourceStride; - - // Check the given bounds - size_t beg = min(offset, _sourceData.size()), end; - if (count == 0) end = _sourceData.size(); - else end = min(count + offset, _sourceData.size()); - sourceData.insert(sourceData.begin(), _sourceData.begin() + beg, _sourceData.begin() + end); -} - -void FCDGeometrySource::SetSourceType(FUDaeGeometryInput::Semantic type) -{ - sourceType = type; - animatedValues.clear(); - - // Most types should remain un-animated - if (sourceType != FUDaeGeometryInput::POSITION && sourceType != FUDaeGeometryInput::COLOR) return; - - // Look for an animation on this source's objects - Int32List animatedIndices; - GetDocument()->FindAnimationChannelsArrayIndices(sourceNode, animatedIndices); - for (Int32List::iterator itA = animatedIndices.begin(); itA != animatedIndices.end(); ++itA) - { - // Check for repeated animated indices - Int32List::iterator itB = animatedIndices.begin(); - for (; itB != itA && (*itA) != (*itB); ++itB) {} - if (itB != itA) continue; - - FCDAnimated* animated = NULL; - if (sourceType == FUDaeGeometryInput::POSITION) - { - animated = FCDAnimatedPoint3::Create(GetDocument(), sourceNode, (FMVector3*)&(sourceData[(*itA) * sourceStride]), *itA); - } - else - { - animated = FCDAnimatedColor::Create(GetDocument(), sourceNode, (FMVector3*)&(sourceData[(*itA) * sourceStride]), *itA); - } - - // Keep track of these animated values - if (animated != NULL) animatedValues.push_back(animated); - } -} - -// Clone this data source -FCDGeometrySource* FCDGeometrySource::Clone() const -{ - FCDGeometrySource* clone = new FCDGeometrySource(GetDocument()); - FCDObjectWithId::Clone(clone); - clone->name = name; - clone->sourceData = sourceData; - clone->sourceNode = sourceNode; - clone->sourceStride = sourceStride; - clone->SetSourceType(sourceType); - return clone; -} - - -// Read in the node of the COLLADA document -FUStatus FCDGeometrySource::LoadFromXML(xmlNode* _sourceNode) -{ - FUStatus status; - sourceNode = _sourceNode; - - // Read in the name and id of the source - name = TO_FSTRING(ReadNodeName(sourceNode)); - string id = ReadNodeId(sourceNode); - if (id.empty()) - { - status.Warning(FS("Geometry source with no 'id' is unusable."), sourceNode->line); - } - SetDaeId(id); - if (!id.empty() && GetDaeId() != id) - { - return status.Fail(FS("Geometry source has duplicate 'id': ") + TO_FSTRING(id), sourceNode->line); - } - - // Read in the source data - sourceStride = ReadSource(sourceNode, sourceData); - if (sourceStride == 0) - { - status.Warning(FS("Geometry has source with no data."), sourceNode->line); - } - - return status; -} - -// Write out the node to the COLLADA xml tree -xmlNode* FCDGeometrySource::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* sourceNode = NULL; - - // Export the source directly, using the correct parameters and the length factor - switch (sourceType) - { - case FUDaeGeometryInput::POSITION: sourceNode = AddSourceFloat(parentNode, GetDaeId(), sourceData, sourceStride, FUDaeAccessor::XYZW, GetDocument()->GetLengthUnitConversion()); break; - case FUDaeGeometryInput::NORMAL: sourceNode = AddSourceFloat(parentNode, GetDaeId(), sourceData, sourceStride, FUDaeAccessor::XYZW); break; - case FUDaeGeometryInput::GEOTANGENT: sourceNode = AddSourceFloat(parentNode, GetDaeId(), sourceData, sourceStride, FUDaeAccessor::XYZW); break; - case FUDaeGeometryInput::GEOBINORMAL: sourceNode = AddSourceFloat(parentNode, GetDaeId(), sourceData, sourceStride, FUDaeAccessor::XYZW); break; - case FUDaeGeometryInput::TEXCOORD: sourceNode = AddSourceFloat(parentNode, GetDaeId(), sourceData, sourceStride, FUDaeAccessor::STPQ); break; - case FUDaeGeometryInput::TEXTANGENT: sourceNode = AddSourceFloat(parentNode, GetDaeId(), sourceData, sourceStride, FUDaeAccessor::XYZW); break; - case FUDaeGeometryInput::TEXBINORMAL: sourceNode = AddSourceFloat(parentNode, GetDaeId(), sourceData, sourceStride, FUDaeAccessor::XYZW); break; - case FUDaeGeometryInput::UV: sourceNode = AddSourceFloat(parentNode, GetDaeId(), sourceData, sourceStride, FUDaeAccessor::XYZW); break; - case FUDaeGeometryInput::COLOR: sourceNode = AddSourceFloat(parentNode, GetDaeId(), sourceData, sourceStride, FUDaeAccessor::RGBA); break; - case FUDaeGeometryInput::EXTRA: sourceNode = AddSourceFloat(parentNode, GetDaeId(), sourceData, sourceStride, NULL); break; - case FUDaeGeometryInput::UNKNOWN: sourceNode = AddSourceFloat(parentNode, GetDaeId(), sourceData, sourceStride, NULL); break; - - case FUDaeGeometryInput::VERTEX: // Refuse to export these sources - default: break; - } - - if (!name.empty()) - { - AddAttribute(sourceNode, DAE_NAME_ATTRIBUTE, name); - } - - return sourceNode; -} diff --git a/Extras/FCollada/FCDocument/FCDGeometrySource.h b/Extras/FCollada/FCDocument/FCDGeometrySource.h deleted file mode 100644 index 17b33b6a8..000000000 --- a/Extras/FCollada/FCDocument/FCDGeometrySource.h +++ /dev/null @@ -1,141 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDGeometrySource.h - This file contains the FCDGeometrySource class. -*/ - -#ifndef _FCD_GEOMETRY_SOURCE_H_ -#define _FCD_GEOMETRY_SOURCE_H_ - - -#include "FCDocument/FCDObject.h" -#include "FUtils/FUDaeEnum.h" - -class FCDAnimated; - -/** A dynamically-sized array of FCDAnimated objects. */ -typedef vector FCDAnimatedList; - -/** - A COLLADA data source for geometric meshes. - - A COLLADA data source for geometric meshes contains a list of floating-point values and the information - to parse these floating-point values into meaningful content: the stride of the list and the type of data - that the floating-point values represent. When the floating-point values are split according to the stride, - you get multiple elemental values of the given type. A data source may also have a user-generated name to - identify the data within. The name is optional and is used to keep around the user-friendly name for texture coordinate - sets or color sets. - - The values of the COLLADA data source may be animated individually, or together: as an element. - - @ingroup FCDGeometry -*/ -class FCOLLADA_EXPORT FCDGeometrySource : public FCDObjectWithId -{ -private: - fstring name; - FloatList sourceData; - uint32 sourceStride; - xmlNode* sourceNode; - FUDaeGeometryInput::Semantic sourceType; - - // The animated values held here are contained within the document. - FCDAnimatedList animatedValues; - -public: - /** Constructor: do not use directly. - Use FCDGeometryMesh::AddSource or FCDGeometryMesh::AddValueSource instead. - @param document The COLLADA document which owns the data source. */ - FCDGeometrySource(FCDocument* document); - - /** Destructor: do not use directly. - The geometric mesh which contains the data source will release it. */ - virtual ~FCDGeometrySource(); - - /** Retrieves the name of the data source. The name is optional and is used to - keep around a user-friendly name for texture coordinate sets or color sets. - @return The name of the data source. */ - const fstring& GetName() const { return name; } - - /** Retrieves the pure data of the data source. This is a dynamically-sized array of - floating-point values that contains all the data of the source. - @return The pure data of the data source. */ - FloatList& GetSourceData() { return sourceData; } - const FloatList& GetSourceData() const { return sourceData; } /**< See above. */ - - /** Retrieves the stride of the data within the source. - There is no guarantee that the number of data values within the source is a multiple of the stride, - yet you should always verify that the stride is at least the wanted dimension. For example, there is - no guarantee that your vertex position data source has a stride of 3. 3dsMax is known to always - export 3D texture coordinate positions. - @return The stride of the data. */ - uint32 GetSourceStride() const { return sourceStride; } - - /** @deprecated Retrieves the COLLADA id for the source. - Use the class parent's GetDaeId function instead. - @return The COLLADA id. */ - const string& GetSourceId() const { return GetDaeId(); } - - /** Retrieves the list of animated values for the data of the source. - @return The list of animated values. */ - FCDAnimatedList& GetAnimatedValues() { return animatedValues; } - const FCDAnimatedList& GetAnimatedValues() const { return animatedValues; } /**< See above. */ - - /** @deprecated [INTERNAL] Retrieves the XML tree node that represent this source. - This is used when computing the list of animated values. - @todo Take the XML tree node out of this class. - @return The XML tree node. This pointer is invalid if accessed after the document is - fully parsed. */ - xmlNode* GetSourceNode() { return sourceNode; } // Should be taken out of this class - - /** Retrieves the type of data contained within the source. - Common values for the type of data are POSITION, NORMAL, COLOR and TEXCOORD. - Please see FUDaeGeometryInput for more information. - @see FUDaeGeometryInput. - @return The type of data contained within the source. */ - FUDaeGeometryInput::Semantic GetSourceType() const { return sourceType; } - - /** Sets the user-friendly name of the data source. The name is optional and is used to - keep around a user-friendly name for texture coordinate sets or color sets. - @param _name The user-friendly name of the data source. */ - void SetName(const fstring& _name) { name = _name; } - - /** Overwrites the data contained within the data source. - @param _sourceData The new data for this source. - @param _sourceStride The stride for the new data. - @param offset The offset at which to start retrieving the new data. - This argument defaults at 0 to indicate that the data copy should start from the beginning. - @param count The number of data entries to copy into the data source. - This argument defaults at 0 to indicate that the data copy should include everything. */ - void SetSourceData(const FloatList& _sourceData, uint32 _sourceStride, size_t offset=0, size_t count=0); - - /** [INTERNAL] Sets the XML tree node associated with the data source. - @todo Take the XML tree node out of this class. - @param _sourceNode A XML tree node. */ - void SetSourceNode(xmlNode* _sourceNode) { sourceNode = _sourceNode; } - - /** Sets the type of data contained within this data source. - @param type The new type of data for this data source. */ - void SetSourceType(FUDaeGeometryInput::Semantic type); - - /** [INTERNAL] Clones this data source. You will need to release this pointer manually. - @return An identical copy of the data source. */ - FCDGeometrySource* Clone() const; - - /** [INTERNAL] Reads in the \ element from a given COLLADA XML tree node. - @param sourceNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the data source.*/ - FUStatus LoadFromXML(xmlNode* sourceNode); - - /** [INTERNAL] Writes out the \ element to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the data source. - @return The created \ element XML tree node. */ - xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -#endif // _FCD_GEOMETRY_SOURCE_H_ diff --git a/Extras/FCollada/FCDocument/FCDGeometrySpline.cpp b/Extras/FCollada/FCDocument/FCDGeometrySpline.cpp deleted file mode 100644 index c5c0eaa11..000000000 --- a/Extras/FCollada/FCDocument/FCDGeometrySpline.cpp +++ /dev/null @@ -1,163 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDGeometry.h" -#include "FCDocument/FCDGeometrySource.h" -#include "FCDocument/FCDGeometrySpline.h" -#include "FUtils/FUStringConversion.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDGeometrySpline::FCDGeometrySpline(FCDocument* document, FCDGeometry* _parent) : FCDObject(document, "FCDGeometrySpline") -{ - parent = _parent; - isClosed = false; -} - -FCDGeometrySpline::~FCDGeometrySpline() -{ - parent = NULL; - cvs.clear(); - knots.clear(); -} - -// Read in the node of the COLLADA document -FUStatus FCDGeometrySpline::LoadFromXML(xmlNode* splineNode) -{ - FUStatus status; - - // Read the curve properties - isClosed = FUStringConversion::ToBoolean(ReadNodeProperty(splineNode, DAE_CLOSED_ATTRIBUTE)); - - // Read in the element, which define the base type for this curve - xmlNode* cvsNode = FindChildByType(splineNode, DAE_CONTROL_VERTICES_ELEMENT); - if (cvsNode == NULL) - { - return status.Fail(FS("No element in spline: ") + TO_FSTRING(parent->GetDaeId()), splineNode->line); - } - - // Read in the per-vertex inputs - string positionSrc; - string sknots; - int hasPositions = 0; - int hasKnots = 0; - - xmlNodeList vertexInputNodes; - FindChildrenByType(cvsNode, DAE_INPUT_ELEMENT, vertexInputNodes); - for (xmlNodeList::iterator it = vertexInputNodes.begin(); it < vertexInputNodes.end(); ++it) - { - xmlNode* vertexInputNode = *it; - string inputSemantic = ReadNodeSemantic(vertexInputNode); - - if( strcmp(inputSemantic.c_str(), "POSITION" ) == 0 ) - { - positionSrc = ReadNodeProperty(vertexInputNode,"source"); - hasPositions = 1; - } - else if( strcmp(inputSemantic.c_str(), "KNOTSEQUENCES" ) == 0 ) - { - sknots = ReadNodeProperty(vertexInputNode,"source"); - hasKnots = 1; - } - } - - if (!hasPositions) - { - return status.Warning(FS("No vertex position input node in spline: ") + TO_FSTRING(parent->GetDaeId()), splineNode->line); - } - if (!hasKnots) - { - return status.Warning(FS("No knot sequence input node in spline: ") + TO_FSTRING(parent->GetDaeId()), splineNode->line); - } - - xmlNode* positionSrcNode = NULL; - xmlNode* knotSrcNode = NULL; - - // Read in the data sources - xmlNodeList sourceDataNodes; - FindChildrenByType(splineNode, DAE_SOURCE_ELEMENT, sourceDataNodes); - for (xmlNodeList::iterator it = sourceDataNodes.begin(); it != sourceDataNodes.end(); ++it) - { - xmlNode* sourceNode = *it; - - string srcid = ReadNodeProperty(*it,"id"); - - if( strcmp( srcid.c_str(), positionSrc.substr(1).c_str() ) == 0 ) - positionSrcNode = sourceNode; - else if( strcmp( srcid.c_str(), sknots.substr(1).c_str() ) == 0 ) - knotSrcNode = sourceNode; - } - - if (positionSrcNode == NULL) - { - return status.Warning(FS("No vertex position source element in spline: ") + TO_FSTRING(parent->GetDaeId()), splineNode->line); - } - - xmlNode* farrayNode = FindChildByType(positionSrcNode, "float_array"); - if (farrayNode == NULL) - { - return status.Warning(FS("No vertex position float array element in spline: ") + TO_FSTRING(parent->GetDaeId()), positionSrcNode->line); - } - - // Setup the curve data - const char* content = ReadNodeContentDirect(farrayNode); - int32 icount = ReadNodeCount(farrayNode); - for(int32 i = 0; i < icount / 3; ++i) - { - FMVector3 p = FUStringConversion::ToPoint(&content); - cvs.push_back(p); - } - - farrayNode = FindChildByType(knotSrcNode, "float_array"); - - if(farrayNode==NULL) - { - return status.Warning(FS("No knot sequence float array element in spline: ") + TO_FSTRING(parent->GetDaeId()), farrayNode->line); - } - - content = ReadNodeContentDirect(farrayNode); - - icount = atoi(ReadNodeProperty( farrayNode, "count").c_str()); - - // setup the curve data - for( int i=0; i< icount; i++ ) - { - float f = FUStringConversion::ToFloat(&content); - knots.push_back(double(f)); - } - - return status; -} - -// Write out the node to the COLLADA xml tree -xmlNode* FCDGeometrySpline::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* splineNode = AddChild(parentNode, DAE_SPLINE_ELEMENT); - AddAttribute(splineNode, DAE_CLOSED_ATTRIBUTE, isClosed); - - // Export the control point source - FUSStringBuilder controlPointSourceId(GetParent()->GetDaeId()); controlPointSourceId += "-cvs"; - AddSourcePosition(splineNode, controlPointSourceId.ToCharPtr(), cvs); - - // Export the knots - FUSStringBuilder knotSourceId(GetParent()->GetDaeId()); - knotSourceId += "-knots"; - FloatList floatKnots; floatKnots.reserve(knots.size()); - for (FCDKnots::const_iterator itK = knots.begin(); itK != knots.end(); ++itK) - { - floatKnots.push_back(float(*itK)); - } - AddSourceFloat(splineNode, knotSourceId.ToCharPtr(), floatKnots, "KNOT"); - - // Write out the control vertices information - xmlNode* verticesNode = AddChild(splineNode, DAE_CONTROL_VERTICES_ELEMENT); - AddInput(verticesNode, controlPointSourceId.ToCharPtr(), DAE_POSITION_SPLINE_INPUT); - AddInput(verticesNode, knotSourceId.ToCharPtr(), DAE_KNOT_SPLINE_INPUT); - return splineNode; -} diff --git a/Extras/FCollada/FCDocument/FCDGeometrySpline.h b/Extras/FCollada/FCDocument/FCDGeometrySpline.h deleted file mode 100644 index 3a327d48a..000000000 --- a/Extras/FCollada/FCDocument/FCDGeometrySpline.h +++ /dev/null @@ -1,122 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/** - @file FCDGeometrySpline.h - This file contains the FCDGeometrySpline class. - The FCDGeometrySpline class hold the information for one COLLADA geometric spline. -*/ -#ifndef _FCD_GEOMETRY_SPLINE_H_ -#define _FCD_GEOMETRY_SPLINE_H_ - -#include "FCDocument/FCDObject.h" - -class FCDocument; -class FCDGeometry; - -/** A dynamically-sized array of geometric spline control points. Each control point is simply one 3D position. @ingroup FCDGeometry */ -typedef vector FCDCVs; -/** A dynamically-sized array of weight values. Each weigth value represents a knot of a control point. @ingroup FCDGeometry */ -typedef vector FCDKnots; - -/** - A COLLADA geometric spline. - - A COLLADA spline contains a list of control points (CVs) that define an ordered list of 3D coordinates - that influence the spline. The spline also contains a matching list of knots: there should be as many control - points as there are knots. - - A COLLADA spline may be closed or open. If the spline is closed, then the first control point should be - re-used when evaluating the last control point: the result should be a continuous curve, while an open - spline will result in a discontinuity at each end. - - @todo: Insert the mathematical formula to calculate the spline position. - - @ingroup FCDGeometry -*/ -class FCOLLADA_EXPORT FCDGeometrySpline : public FCDObject -{ -private: - FCDGeometry* parent; - FCDCVs cvs; - FCDKnots knots; - bool isClosed; - -public: - /** Constructor: do not use directly. Use the FCDGeometry::CreateMesh function instead. - @param document The COLLADA document that owns the new spline. - @param parent The geometry entity that contains the new spline. */ - FCDGeometrySpline(FCDocument* document, FCDGeometry* parent); - - /** Destructor: do not use directly. All geometric splines are released with the geometry that they belong to. */ - virtual ~FCDGeometrySpline(); - - /** Retrieve the parent of this geometric spline: the geometry entity. - @return The geometry entity that this spline belongs to. */ - FCDGeometry* GetParent() { return parent; } - const FCDGeometry* GetParent() const { return parent; } /**< See above. */ - - /** Retrieves the list of control points for the spline. - @return The list of control points. */ - inline FCDCVs& GetCVs() { return cvs; } - inline const FCDCVs& GetCVs() const { return cvs; } /**< See above. */ - - /** Retrieves the number of control points for the spline. - @return The control point count. */ - inline size_t GetCVCount() const { return cvs.size(); } - - /** Retrieves a specific control point of the spline. - @param index The index of the control point. - The index should always be less than the number of control point. - @return The control point. */ - inline FMVector3* GetCV(size_t index) { FUAssert(index < GetCVCount(), return NULL); return &(cvs.at(index)); } - inline const FMVector3* GetCV(size_t index) const { FUAssert(index < GetCVCount(), return NULL); return &(cvs.at(index)); } /**< See above. */ - - /** Retrieves the list of knots for the spline. - @return The list of knots. */ - inline FCDKnots& GetKnots() { return knots; } - inline const FCDKnots& GetKnots() const { return knots; } /**< See above. */ - - /** Retrieves the number of knots for the spline. - @return The knot count. */ - inline size_t GetKnotCount() const { return knots.size(); } - - /** Retrieves a specific knot of the spline. - @param index The index of the knot. The index should always be less than the number of knots. - @return The knot value. */ - inline double GetKnot(size_t index) const { FUAssert(index < GetKnotCount(), return 0.0); return knots.at(index); } - - /** Retrieves whether this spline is closed. - @return Whether the spline is closed. */ - inline bool IsClosed() const { return isClosed; } - - /** Retrieves whether this spline is open. - @return Whether the spline is open. */ - inline bool IsOpen() const { return !isClosed; } - - /** Overwrites the list of control points for this spline with a new ordered list of control points. - @param _cvs The new control points. */ - inline void SetCVs(const FCDCVs& _cvs) { cvs = _cvs; } - - /** Overwrites the list of knots for this spline with a new ordered list of knots. - @param _knots The new knots. */ - inline void SetKnots(const FCDKnots& _knots) { knots = _knots; } - - /** Sets the spline closed state. - @param _isClosed The new closed state. */ - inline void SetClosed(bool _isClosed) { isClosed = _isClosed; } - - /** [INTERNAL] Reads in the \ element from a given COLLADA XML tree node. - @param splineNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the spline.*/ - FUStatus LoadFromXML(xmlNode* splineNode); - - /** [INTERNAL] Writes out the \ element to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the spline information. - @return The created \ element XML tree node. */ - xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -#endif // _FCD_GEOMETRY_SPLINE_H_ diff --git a/Extras/FCollada/FCDocument/FCDImage.cpp b/Extras/FCollada/FCDocument/FCDImage.cpp deleted file mode 100644 index f0a414e7b..000000000 --- a/Extras/FCollada/FCDocument/FCDImage.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDImage.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -#include "FUtils/FUFileManager.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDImage::FCDImage(FCDocument* document) : FCDEntity(document, "Image") -{ - width = 0; - height = 0; - depth = 0; -} - -FCDImage::~FCDImage() -{ -} - -// Read in the image information from the COLLADA document -FUStatus FCDImage::LoadFromXML(xmlNode* imageNode) -{ - FUStatus status = FCDEntity::LoadFromXML(imageNode); - if (!status) return status; - if (!IsEquivalent(imageNode->name, DAE_IMAGE_ELEMENT)) - { - return status.Warning(FS("Image library contains unknown element."), imageNode->line); - } - - if(HasNodeProperty(imageNode, DAE_WIDTH_ELEMENT)) - width = FUStringConversion::ToUInt32(ReadNodeProperty(imageNode, DAE_WIDTH_ELEMENT)); - if(HasNodeProperty(imageNode, DAE_HEIGHT_ELEMENT)) - height = FUStringConversion::ToUInt32(ReadNodeProperty(imageNode, DAE_HEIGHT_ELEMENT)); - if(HasNodeProperty(imageNode, DAE_DEPTH_ELEMENT)) - depth = FUStringConversion::ToUInt32(ReadNodeProperty(imageNode, DAE_DEPTH_ELEMENT)); - - // Read in the image's filename, within the element: binary images are not supported. - xmlNode* filenameSourceNode = FindChildByType(imageNode, DAE_INITFROM_ELEMENT); - filename = TO_FSTRING(ReadNodeContentDirect(filenameSourceNode)); - - // COLLADA 1.3 backward-compatibility - if (filename.empty()) filename = TO_FSTRING(ReadNodeSource(imageNode)); - - // Convert the filename to something the OS can use - filename = GetDocument()->GetFileManager()->GetFilePath(filename); - if (filename.empty()) - { - return status.Fail(FS("Invalid filename for image: ") + TO_FSTRING(GetDaeId()), imageNode->line); - } - - return status; -} - -// Write out the image information to the COLLADA xml tree node -xmlNode* FCDImage::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* imageNode = WriteToEntityXML(parentNode, DAE_IMAGE_ELEMENT); - if (!filename.empty()) - { - fstring url = GetDocument()->GetFileManager()->GetFileURL(filename, true); - AddChild(imageNode, DAE_INITFROM_ELEMENT, url); - } - - if (width > 0) AddAttribute(imageNode, DAE_WIDTH_ELEMENT, width); - if (height > 0) AddAttribute(imageNode, DAE_HEIGHT_ELEMENT, height); - if (depth > 0) AddAttribute(imageNode, DAE_DEPTH_ELEMENT, depth); - - WriteToExtraXML(imageNode); - return imageNode; -} diff --git a/Extras/FCollada/FCDocument/FCDImage.h b/Extras/FCollada/FCDocument/FCDImage.h deleted file mode 100644 index 51fdac031..000000000 --- a/Extras/FCollada/FCDocument/FCDImage.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDImage.h - This file contains the FCDImage class. -*/ - -#ifndef _FCD_IMAGE_H_ -#define _FCD_IMAGE_H_ - -#include "FCDocument/FCDEntity.h" - -class FCDocument; - -/** - A COLLADA image. - - A COLLADA image encapsulates an image file and are contained - within the image library. FCollada doesn't support inlined image bits. - - An image is solely defined by its filename. For some - image types and optionally, the width, height and depth of - the image may be required and valid. - - @ingroup FCDEffect -*/ -class FCOLLADA_EXPORT FCDImage : public FCDEntity -{ -private: - fstring filename; - uint32 width; - uint32 height; - uint32 depth; - -public: - /** Constructor: do not use directly. - Instead, use the FCDLibrary::AddEntity function. - @param document The COLLADA document that owns the image. */ - FCDImage(FCDocument* document); - - /** Destructor: do not use directly. - Instead, use the FCDLibrary::ReleaseEntity function. */ - virtual ~FCDImage(); - - /** Retrieves the entity type for this class. This function is part - of the FCDEntity class interface. - @return The entity type: IMAGE. */ - virtual Type GetType() const { return IMAGE; } - - /** Retrieves the filename of the image file. - This is the image file that you should load when attempting - to use the image bits. FCollada will deal with the filename - internally and provide an absolute filename. - @return The filename of the image file. */ - const fstring& GetFilename() const { return filename; } - - /** Sets the filename of the image file. - This is the image file that you should load when attempting - to use the image bits. FCollada will deal with the filename - internally and export a relative filename. - @param _filename The filename of the image file. */ - void SetFilename(const fstring& _filename) { filename = _filename; } - - /** Retrieves the width of the image. - This parameter is useful for off-screen render targets and is - optional for texture image files. - @return The width of the image. This value will be zero to indicate - that you should retrieve the width of the image from the image file. */ - const uint32& GetWidth() const { return width; } - - /** Sets the width of the image. - This parameter is useful for off-screen render targets and is - optional for texture image files. - @param _width The width of the image. This value can be zero to indicate - that you should retrieve the width of the image from the image file. */ - void SetWidth(uint32 _width) { width = _width; } - - /** Retrieves the height of the image. - This parameter is useful for off-screen render targets and is - optional for texture image files. - @return The height of the image. This value will be zero to indicate - that you should retrieve the height of the image from the image file. */ - const uint32& GetHeight() const { return height; } - - /** Sets the height of the image. - This parameter is useful for off-screen render targets and is - optional for texture image files. - @param _height The height of the image. This value can be zero to indicate - that you should retrieve the width of the image from the image file. */ - void SetHeight(uint32 _height) { height = _height; } - - /** Retrieves the depth of the 3D image. - This parameter is optional for texture image files. - @return The depth of the image. This value will be zero to indicate - that you should retrieve the depth of the image from the image file. */ - const uint32& GetDepth() const { return depth; } - - /** Sets the depth of the 3D image. - This parameter is optional for texture image files. - @param _depth The depth of the image. This value can be zero to indicate - that you should retrieve the depth of the image from the image file. */ - void SetDepth(uint32 _depth) { depth = _depth; } - - /** [INTERNAL] Reads in the \ element from a given COLLADA XML tree node. - @param imageNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the image.*/ - virtual FUStatus LoadFromXML(xmlNode* imageNode); - - /** [INTERNAL] Writes out the \ element to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the image. - @return The created element XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -#endif // _FCD_IMAGE_H_ diff --git a/Extras/FCollada/FCDocument/FCDLibrary.h b/Extras/FCollada/FCDocument/FCDLibrary.h deleted file mode 100644 index 9ed58f0eb..000000000 --- a/Extras/FCollada/FCDocument/FCDLibrary.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDLibrary.h - This file contains the FCDLibrary template class. - See the FCDLibrary.hpp file for the template implementation. -*/ - -#ifndef _FCD_LIBRARY_ -#define _FCD_LIBRARY_ - -class FCDocument; -class FCDEntity; - -#include "FCDocument/FCDObject.h" - -/** - A COLLADA library. - - A COLLADA library holds a list of entities. There are libraries for the following entities: - animations (FCDAnimation), animation clips (FCDAnimationClip), meshes and splines (FCDGeometry), - materials (FCDMaterial), effects (FCDEffect), images (FCDImage), skins and morphers (FCDController), - cameras (FCDCamera), lights (FCDLight), physics models (FCDPhysicsModel), physics materials - (FCDPhysicsMaterial), physics scenes (FCDPhysicsSceneNode) and visual scenes (FCDSceneNode). - - The COLLADA libraries are contained within the FCDocument object. - - @ingroup FCDocument -*/ -template -class FCDLibrary : public FCDObject -{ -protected: - /** The list type for the entities. */ - typedef vector FCDEntityList; - - /** Entities list. This list should contain all the root entities of the correct type. - Note that the following entity types are tree-based, rather than list-based: FCDAnimation, - FCDSceneNode and FCDPhysicsSceneNode. */ - FCDEntityList entities; - -public: - /** Constructor: do not use directly. - All the necessary libraries are created by the FCDocument object during its creation. - @param document The parent document. */ - FCDLibrary(FCDocument* document); - - /** Destructor: do not use directly. - The libraries are released by the FCDocument, just before it is released. */ - virtual ~FCDLibrary(); - - /** Create a new entity within this library. - @return The newly created entity. */ - T* AddEntity(); - - /** Releases an entity contained within this library. - @param entity The entity to delete. */ - void ReleaseEntity(T* entity); - - /** Retrieve the library entity with the given COLLADA id. - @param daeId The COLLADA id of the entity. - @return The library entity which matches the COLLADA id. - This pointer will be NULL if no matching entity was found. */ - T* FindDaeId(const string& daeId); - - /** Returns whether the library contains no entities. - @return Whether the library is empty. */ - inline bool IsEmpty() const { return entities.empty(); } - - /** [INTERNAL] Reads in the contents of the library from the COLLADA XML document. - @param node The COLLADA XML tree node to parse into entities. - @return The status of the import. If the status is not successful, it may be dangerous to - extract information from the library. */ - virtual FUStatus LoadFromXML(xmlNode* node); - - /** [INTERNAL] Writes out the library entities to the COLLADA XML document. - @param node The COLLADA XML tree node in which to write the library entities. */ - virtual void WriteToXML(xmlNode* node) const; - - /** @deprecated [INTERNAL] Retrieves the list of post-processing commands for the entities of this library. - @return The list of post-processing commands. */ - StringList GetPostProcessCmds() const; - - /** Retrieve the number of entities within the library. - @return the number of entities contained within the library. */ - inline size_t GetEntityCount() const { return entities.size(); } - - /** Retrieve an indexed entity from the library. - @param index The index of the entity to retrieve. - Should be within the range [0, GetEntityCount()[. - @return The indexed entity. */ - inline T* GetEntity(size_t index) { FUAssert(index < GetEntityCount(), return NULL); return entities.at(index); } - - /** Retrieve an indexed entity from the library. - @param index The index of the entity to retrieve. - Should be within the range [0, GetEntityCount()[. - @return The indexed entity. */ - inline const T* GetEntity(size_t index) const { FUAssert(index < GetEntityCount(), return NULL); return entities.at(index); } -}; - -#include "FCDocument/FCDLibrary.hpp" - -#endif // _FCD_LIBRARY_ diff --git a/Extras/FCollada/FCDocument/FCDLibrary.hpp b/Extras/FCollada/FCDocument/FCDLibrary.hpp deleted file mode 100644 index 8c8e8a043..000000000 --- a/Extras/FCollada/FCDocument/FCDLibrary.hpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "FUtils/FUDaeParser.h" - -template -FCDLibrary::FCDLibrary(FCDocument* document) : FCDObject(document, "FCDLibrary") -{ -} - -template -FCDLibrary::~FCDLibrary() -{ - CLEAR_POINTER_VECTOR(entities); -} - - -// Create a new entity within this library -template -T* FCDLibrary::AddEntity() -{ - T* entity = new T(GetDocument()); - entities.push_back(entity); - return entity; -} - -// Deletes a entity of this library -template -void FCDLibrary::ReleaseEntity(T* entity) -{ - // Not yet implemented, as this will most likely result in dangling pointers! - // Needs more structure... -} - - -// Read in a list of entities for a library of a COLLADA document -template -FUStatus FCDLibrary::LoadFromXML(xmlNode* node) -{ - FUStatus status; - for (xmlNode* entityNode = node->children; entityNode != NULL; entityNode = entityNode->next) - { - if (entityNode->type == XML_ELEMENT_NODE) - { - T* entity = AddEntity(); - status.AppendStatus(entity->LoadFromXML(entityNode)); - } - } - return status; -} - -// Write out the library to the COLLADA xml document -template -void FCDLibrary::WriteToXML(xmlNode* node) const -{ - for (typename FCDEntityList::const_iterator itEntity = entities.begin(); itEntity != entities.end(); ++itEntity) - { - const T* entity = (const T*) (*itEntity); - entity->WriteToXML(node); - } -} - -// Search for the entity in this library with a given COLLADA id. -template -T* FCDLibrary::FindDaeId(const string& _daeId) -{ - const char* daeId = FUDaeParser::SkipPound(_daeId); - for (typename FCDEntityList::iterator itEntity = entities.begin(); itEntity != entities.end(); ++itEntity) - { - if ((*itEntity)->GetDaeId() == daeId) return (*itEntity); - } - return NULL; -} - -template -StringList FCDLibrary::GetPostProcessCmds() const -{ - StringList res; - for (typename FCDEntityList::const_iterator itEntity = entities.begin(); itEntity != entities.end(); ++itEntity) - { - res = (*itEntity)->GetPostProcessCmds(); - } - return res; -} diff --git a/Extras/FCollada/FCDocument/FCDLight.cpp b/Extras/FCollada/FCDocument/FCDLight.cpp deleted file mode 100644 index 4d2ff2b5a..000000000 --- a/Extras/FCollada/FCDocument/FCDLight.cpp +++ /dev/null @@ -1,282 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDAnimated.h" -#include "FCDocument/FCDLight.h" -#include "FCDocument/FCDSceneNode.h" -#include "FUtils/FUStringConversion.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDLight::FCDLight(FCDocument* document) : FCDTargetedEntity(document, "Light") -{ - color = FMVector3(1.0f, 1.0f, 1.0f); - intensity = 1.0f; - lightType = POINT; - constantAttenuationFactor = linearAttenuationFactor = quadracticAttenuationFactor = 0.0f; - fallOffExponent = 1.0f; - outerAngle = fallOffAngle = 30.0f; - penumbraAngle = 0.0f; - dropoff = 10.0f; - overshoots = true; -} - -FCDLight::~FCDLight() -{ -} - -// Load this light from the given COLLADA document's node -FUStatus FCDLight::LoadFromXML(xmlNode* lightNode) -{ - FUStatus status = FCDEntity::LoadFromXML(lightNode); - if (!status) return status; - if (!IsEquivalent(lightNode->name, DAE_LIGHT_ELEMENT)) - { - return status.Warning(FS("Light library contains unknown element."), lightNode->line); - } - - // Grab the element. If not present, assume COLLADA 1.3 - xmlNode* commonTechniqueNode = FindChildByType(lightNode, DAE_TECHNIQUE_COMMON_ELEMENT); - bool isCollada1_3 = commonTechniqueNode == NULL; - xmlNode* maxTechniqueNode = FindTechnique(lightNode, DAEMAX_MAX_PROFILE); - xmlNode* mayaTechniqueNode = FindTechnique(lightNode, DAEMAYA_MAYA_PROFILE); - - // Create the correct light source - xmlNode* lightParameterNode = NULL; - if (isCollada1_3) - { - // COLLADA 1.3 backward-compatibility: read the 'type' attribute of the element - string type = ReadNodeProperty(lightNode, DAE_TYPE_ATTRIBUTE); - if (type == DAE_AMBIENT_LIGHT_TYPE) lightType = AMBIENT; - else if (type == DAE_DIRECTIONAL_LIGHT_TYPE) lightType = DIRECTIONAL; - else if (type == DAE_POINT_LIGHT_TYPE) lightType = POINT; - else if (type == DAE_SPOT_LIGHT_TYPE) lightType = SPOT; - else - { - status.Warning(FS("Unknown light type value for light: ") + TO_FSTRING(GetDaeId()), lightNode->line); - } - - // COLLADA 1.3.2 backward-compatibility: look for this hack for the parameters under a common-profile technique - lightParameterNode = FindTechnique(lightNode, DAE_COMMON_PROFILE); - if (lightParameterNode == NULL) lightParameterNode = lightNode; - } - else - { - // Look for the , , or element under the common-profile technique - for (xmlNode* child = commonTechniqueNode->children; child != NULL; child = child->next) - { - if (child->type != XML_ELEMENT_NODE) continue; - if (IsEquivalent(child->name, DAE_LIGHT_POINT_ELEMENT)) { lightParameterNode = child; lightType = POINT; break; } - else if (IsEquivalent(child->name, DAE_LIGHT_SPOT_ELEMENT)) { lightParameterNode = child; lightType = SPOT; break; } - else if (IsEquivalent(child->name, DAE_LIGHT_AMBIENT_ELEMENT)) { lightParameterNode = child; lightType = AMBIENT; break; } - else if (IsEquivalent(child->name, DAE_LIGHT_DIRECTIONAL_ELEMENT)) { lightParameterNode = child; lightType = DIRECTIONAL; break; } - else - { - status.Warning(FS("Unknown element under for light: ") + TO_FSTRING(GetDaeId()), child->line); - } - } - } - - // Verify the light's basic structures are found - if (lightParameterNode == NULL) - { - return status.Fail(FS("Unable to find the parameter root node for light: ") + TO_FSTRING(GetDaeId()), lightNode->line); - } - - // Retrieve the light parameters - StringList parameterNames; - xmlNodeList parameterNodes; - FindParameters(lightParameterNode, parameterNames, parameterNodes); - FindParameters(maxTechniqueNode, parameterNames, parameterNodes); - FindParameters(mayaTechniqueNode, parameterNames, parameterNodes); - xmlNode* extraNode = FindChildByType(lightNode, DAE_EXTRA_ELEMENT); - xmlNode* maxExtraNode = FindTechnique(extraNode, DAEMAX_MAX_PROFILE); - FindParameters(maxExtraNode, parameterNames, parameterNodes); - - // Parse the light parameters - FUDaeFunction::Function attenuationFunction = FUDaeFunction::CONSTANT; - float attenuationFactor = 0.0f; - xmlNode* attenuationFactorNode = NULL; - - size_t parameterCount = parameterNodes.size(); - for (size_t i = 0; i < parameterCount; ++i) - { - xmlNode* parameterNode = parameterNodes[i]; - const string& parameterName = parameterNames[i]; - const char* content = ReadNodeContentDirect(parameterNode); - if (parameterName == DAE_COLOR_LIGHT_PARAMETER || parameterName == DAE_COLOR_LIGHT_PARAMETER1_3) - { - color = FUStringConversion::ToPoint(content); - FCDAnimatedColor::Create(GetDocument(), parameterNode, &color); - } - else if (parameterName == DAE_CONST_ATTENUATION_LIGHT_PARAMETER) - { - constantAttenuationFactor = FUStringConversion::ToFloat(content); - FCDAnimatedFloat::Create(GetDocument(), parameterNode, &constantAttenuationFactor); - } - else if (parameterName == DAE_LIN_ATTENUATION_LIGHT_PARAMETER) - { - linearAttenuationFactor = FUStringConversion::ToFloat(content); - FCDAnimatedFloat::Create(GetDocument(), parameterNode, &linearAttenuationFactor); - } - else if (parameterName == DAE_QUAD_ATTENUATION_LIGHT_PARAMETER) - { - quadracticAttenuationFactor = FUStringConversion::ToFloat(content); - FCDAnimatedFloat::Create(GetDocument(), parameterNode, &quadracticAttenuationFactor); - } - else if (parameterName == DAE_ATTENUATION_LIGHT_PARAMETER1_3) - { - attenuationFunction = FUDaeFunction::FromString(content); - } - else if (parameterName == DAE_ATTENUATIONSCALE_LIGHT_PARAMETER1_3) - { - attenuationFactor = FUStringConversion::ToFloat(content); - attenuationFactorNode = parameterNode; - } - else if (parameterName == DAE_FALLOFFEXPONENT_LIGHT_PARAMETER) - { - fallOffExponent = FUStringConversion::ToFloat(content); - FCDAnimatedFloat::Create(GetDocument(), parameterNode, &fallOffExponent); - } - else if (parameterName == DAE_FALLOFF_LIGHT_PARAMETER1_3) - { - fallOffExponent = (float) FUDaeFunction::FromString(content); - } - else if (parameterName == DAE_FALLOFFANGLE_LIGHT_PARAMETER || parameterName == DAE_ANGLE_LIGHT_PARAMETER1_3) - { - fallOffAngle = FUStringConversion::ToFloat(content); - FCDAnimatedFloat::Create(GetDocument(), parameterNode, &fallOffAngle); - } - else if (parameterName == DAESHD_INTENSITY_LIGHT_PARAMETER || parameterName == DAESHD_INTENSITY_LIGHT_PARAMETER1_3) - { - intensity = FUStringConversion::ToFloat(content); - FCDAnimatedFloat::Create(GetDocument(), parameterNode, &intensity); - } - else if (parameterName == DAEMAX_OUTERCONE_LIGHT_PARAMETER || parameterName == DAEMAX_OUTERCONE_LIGHT_PARAMETER1_3) - { - outerAngle = FUStringConversion::ToFloat(content); - FCDAnimatedFloat::Create(GetDocument(), parameterNode, &outerAngle); - } - else if (parameterName == DAEMAX_OVERSHOOT_LIGHT_PARAMETER || parameterName == DAEMAX_OVERSHOOT_LIGHT_PARAMETER1_3) - { - overshoots = FUStringConversion::ToBoolean(content); - } - else if (parameterName == DAEMAX_TARGET_LIGHT_PARAMETER || parameterName == DAEMAX_TARGET_LIGHT_PARAMETER1_3) - { - SetTargetId(content); - } - else if (parameterName == DAEMAYA_PENUMBRA_LIGHT_PARAMETER || parameterName == DAEMAYA_PENUMBRA_LIGHT_PARAMETER1_3) - { - penumbraAngle = FUStringConversion::ToFloat(content); - FCDAnimatedFloat::Create(GetDocument(), parameterNode, &penumbraAngle); - } - else if (parameterName == DAEMAYA_DROPOFF_LIGHT_PARAMETER || parameterName == DAE_FALLOFFSCALE_LIGHT_PARAMETER1_3) - { - dropoff = FUStringConversion::ToFloat(content); - FCDAnimatedFloat::Create(GetDocument(), parameterNode, &dropoff); - } - else if (parameterName == DAEMAX_ASPECTRATIO_LIGHT_PARAMETER || parameterName == DAEMAX_ASPECTRATIO_LIGHT_PARAMETER1_3) - { - aspectRatio = FUStringConversion::ToFloat(content); - FCDAnimatedFloat::Create(GetDocument(), parameterNode, &aspectRatio); - } - else - { - status.Warning(FS("Unknown program parameter for light: ") + TO_FSTRING(GetDaeId()), parameterNode->line); - } - } - - if (attenuationFactorNode != NULL) - { - // Match the deprecated COLLADA 1.3 parameter's animation to the correct, new attenuation factor - switch (attenuationFunction) - { - case FUDaeFunction::CONSTANT: - constantAttenuationFactor = attenuationFactor; - FCDAnimatedFloat::Create(GetDocument(), attenuationFactorNode, &constantAttenuationFactor); - break; - case FUDaeFunction::LINEAR: - linearAttenuationFactor = attenuationFactor; - FCDAnimatedFloat::Create(GetDocument(), attenuationFactorNode, &linearAttenuationFactor); - break; - case FUDaeFunction::QUADRATIC: - quadracticAttenuationFactor = attenuationFactor; - FCDAnimatedFloat::Create(GetDocument(), attenuationFactorNode, &quadracticAttenuationFactor); - break; - default: break; - } - } - - return status; -} - -// Write out this light to the COLLADA XML document -xmlNode* FCDLight::WriteToXML(xmlNode* parentNode) const -{ - // Create the base light node - xmlNode* lightNode = WriteToEntityXML(parentNode, DAE_LIGHT_ELEMENT); - xmlNode* baseNode = AddChild(lightNode, DAE_TECHNIQUE_COMMON_ELEMENT); - const char* baseNodeName; - switch (lightType) - { - case POINT: baseNodeName = DAE_LIGHT_POINT_ELEMENT; break; - case SPOT: baseNodeName = DAE_LIGHT_SPOT_ELEMENT; break; - case AMBIENT: baseNodeName = DAE_LIGHT_AMBIENT_ELEMENT; break; - case DIRECTIONAL: baseNodeName = DAE_LIGHT_DIRECTIONAL_ELEMENT; break; - default: baseNodeName = DAEERR_UNKNOWN_INPUT; break; - } - baseNode = AddChild(baseNode, baseNodeName); - - // Add the application-specific technique - xmlNode* techniqueMayaNode = AddTechniqueChild(lightNode, DAEMAYA_MAYA_PROFILE); - xmlNode* techniqueMaxNode = AddTechniqueChild(lightNode, DAEMAX_MAX_PROFILE); - - // Write out the light parameters - string colorValue = FUStringConversion::ToString(color); - xmlNode* colorNode = AddChild(baseNode, DAE_COLOR_LIGHT_PARAMETER, colorValue); - GetDocument()->WriteAnimatedValueToXML(&color.x, colorNode, "color"); - - xmlNode* attenuationBaseNode = (lightType == POINT || lightType == SPOT) ? baseNode : techniqueMaxNode; - xmlNode* attenuationNode = AddChild(attenuationBaseNode, DAE_CONST_ATTENUATION_LIGHT_PARAMETER, constantAttenuationFactor); - GetDocument()->WriteAnimatedValueToXML(&constantAttenuationFactor, attenuationNode, "constant_attenuation"); - attenuationNode = AddChild(attenuationBaseNode, DAE_LIN_ATTENUATION_LIGHT_PARAMETER, linearAttenuationFactor); - GetDocument()->WriteAnimatedValueToXML(&linearAttenuationFactor, attenuationNode, "linear_attenuation"); - attenuationNode = AddChild(attenuationBaseNode, DAE_QUAD_ATTENUATION_LIGHT_PARAMETER, quadracticAttenuationFactor); - GetDocument()->WriteAnimatedValueToXML(&quadracticAttenuationFactor, attenuationNode, "quadratic_attenuation"); - - xmlNode* falloffBaseNode = (lightType == SPOT) ? baseNode : techniqueMaxNode; - xmlNode* falloffNode = AddChild(falloffBaseNode, DAE_FALLOFFANGLE_LIGHT_PARAMETER, fallOffAngle); - GetDocument()->WriteAnimatedValueToXML(&fallOffAngle, falloffNode, "falloff_angle"); - falloffNode = AddChild(falloffBaseNode, DAE_FALLOFFEXPONENT_LIGHT_PARAMETER, fallOffExponent); - GetDocument()->WriteAnimatedValueToXML(&fallOffExponent, falloffNode, "falloff_exponent"); - - xmlNode* intensityNode = AddChild(techniqueMaxNode, DAESHD_INTENSITY_LIGHT_PARAMETER, intensity); - AddChild(techniqueMayaNode, DAESHD_INTENSITY_LIGHT_PARAMETER, intensity); - GetDocument()->WriteAnimatedValueToXML(&intensity, intensityNode, "intensity"); - xmlNode* outerAngleNode = AddChild(techniqueMaxNode, DAEMAX_OUTERCONE_LIGHT_PARAMETER, outerAngle); - GetDocument()->WriteAnimatedValueToXML(&outerAngle, outerAngleNode, "outer_angle"); - xmlNode* penumbraAngleNode = AddChild(techniqueMayaNode, DAEMAYA_PENUMBRA_LIGHT_PARAMETER, penumbraAngle); - GetDocument()->WriteAnimatedValueToXML(&penumbraAngle, penumbraAngleNode, "penumbra_angle"); - xmlNode* aspectRatioNode = AddChild(techniqueMaxNode, DAEMAX_ASPECTRATIO_LIGHT_PARAMETER, aspectRatio); - GetDocument()->WriteAnimatedValueToXML(&aspectRatio, aspectRatioNode, "aspect_ratio"); - xmlNode* dropoffNode = AddChild(techniqueMayaNode, DAEMAYA_DROPOFF_LIGHT_PARAMETER, dropoff); - GetDocument()->WriteAnimatedValueToXML(&dropoff, dropoffNode, "dropoff"); - AddChild(techniqueMaxNode, DAEMAX_OVERSHOOT_LIGHT_PARAMETER, overshoots); - - if (GetTargetNode() != NULL) AddChild(techniqueMaxNode, DAEMAX_TARGET_LIGHT_PARAMETER, GetTargetNode()->GetDaeId()); - - FCDEntity::WriteToExtraXML(lightNode); - return lightNode; -} diff --git a/Extras/FCollada/FCDocument/FCDLight.h b/Extras/FCollada/FCDocument/FCDLight.h deleted file mode 100644 index 9ccfaae00..000000000 --- a/Extras/FCollada/FCDocument/FCDLight.h +++ /dev/null @@ -1,286 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDLight.h - This file contains the FCDLight class. -*/ - -#ifndef _FCD_LIGHT_H_ -#define _FCD_LIGHT_H_ - -#include "FCDocument/FCDTargetedEntity.h" -#include "FUtils/FUDaeEnum.h" - -class FCDocument; -class FCDSceneNode; - -/** - A COLLADA light. - Based on the FCDTargetedEntity class to supported aimed lights. - COLLADA defines four types of native lights: point, spot, ambient and directional. - These four types are fully handled by this class: make sure to check the type flag - as well as which information to expect for each light type. - - A COLLADA ambient light has a global color, which should be added to - all other lighting on all geometry. - - A COLLADA directional light has a global color, which should be multiplied - to the cosine of the angle between the normal vector of a triangle - and the direction of the light. Note that the direction will be calculated - from the transforms, for each instance, and is not provided by this class. - - A COLLADA point light has a color which attenuates as the distance increases - between the light position and the vertex being shaded. Note that the position - will be calculated from the transforms, for each instance, - and is not provided by this class. - - A COLLADA spot light is a point light which lights only the objects that - appear within a specific angle, with respect to the direction of the light. - Note that the position and the direction will be calculated from the - transforms, for each instance, and is not provided by this class. - - @ingroup FCDocument -*/ -class FCOLLADA_EXPORT FCDLight : public FCDTargetedEntity -{ -public: - /** The types of lights supported by this class. */ - enum LightType - { - POINT, /**< A point light. This is the default type. */ - SPOT, /**< A spot light. */ - AMBIENT, /**< An ambient light. */ - DIRECTIONAL /**< A directional light. */ - }; - -private: - // Common Light parameters - FMVector3 color; - float intensity; // Max and Maya - LightType lightType; - - // Point and spot light parameters - float constantAttenuationFactor; - float linearAttenuationFactor; - float quadracticAttenuationFactor; - - // Spot-specific light parameters - float fallOffExponent; - float fallOffAngle; - float outerAngle; // Max-specific - float penumbraAngle; // Maya-specifc: these last two are are related as 'penumbra = outerAngle - fallOffAngle'. - float aspectRatio; // Max-specific, for rectangle lights - float dropoff; // Maya-specific - - // Directional light parameters - // Overshoot is a Max-specific flag that sets a directional light to cover everything, - // rather than to be restricted to a cylinder defined by the fallOffAngle/outerAngle. - bool overshoots; // Max-specific - -public: - /** Constructor: do not use directly. Create new lights using the FCDLibrary::AddEntity function. - @param document The COLLADA document that contains this light entity. */ - FCDLight(FCDocument* document); - - /** Destructor: do not release directly. Release lights using the FCDLibrary::ReleaseEntity function. - All lights are also released with the document that they belong to. */ - virtual ~FCDLight(); - - /** Retrieves the entity type for this class. This function is part of the FCDEntity interface. - @return The entity type: LIGHT. */ - virtual Type GetType() const { return LIGHT; } - - /** Retrieves the base color for the light. To calculate the light color, - multiply the base color with the intensity. - @return The base color for the light. */ - FMVector3& GetColor() { return color; } - const FMVector3& GetColor() const { return color; } /**< See above. */ - - /** Sets the base color for the light. To calculate the light color, - multiply the base color with the intensity. - @param col The base color for the light. */ - void SetColor(const FMVector3& col) { color = col; } - - /** Retrieves the intensity of the light. To calculate the light color, - multiply the base color with the intensity. - @return The intensity of the light. */ - float& GetIntensity() { return intensity; } - const float& GetIntensity() const { return intensity; } /**< See above. */ - - /** Sets the intensity of the light. To calculate the light color, - multiply the base color with the intensity. - @param _intensity The intensity of the light. */ - void SetIntensity(float _intensity) { intensity = _intensity; } - - /** Retrieves the type of the light. - Make sure to check the type of light before using the values, as some values - may not make sense with some types of light. - @return The light type. */ - LightType GetLightType() const { return lightType; } - - /** Sets the type of the light. The default type of a new light is POINT. - @param type The light type. */ - void SetLightType(LightType type) { lightType = type; } - - /** Retrieves the constant attenuation factor for the light. - This value is valid only for point and spot lights. - @return The constant attenuation factor. */ - float& GetConstantAttenuationFactor() { return constantAttenuationFactor; } - const float& GetConstantAttenuationFactor() const { return constantAttenuationFactor; } /**< See above. */ - - /** Sets the constant attenuation factor for the light. - This value is valid only for point and spot lights. - @param factor The constant attenuation factor. */ - void SetConstantAttenuationFactor(float factor) { constantAttenuationFactor = factor; } - - /** Retrieves the linear attenuation factor for the light. - This value is valid only for point and spot lights. - @return The linear attenuation factor. */ - float& GetLinearAttenuationFactor() { return linearAttenuationFactor; } - const float& GetLinearAttenuationFactor() const { return linearAttenuationFactor; } /**< See above. */ - - /** Sets the linear attenuation factor for the light. - This value is valid only for point and spot lights. - @param factor The linear attenuation factor. */ - void SetLinearAttenuationFactor(float factor) { linearAttenuationFactor = factor; } - - /** Retrieves the quadratic attenuation factor for the light. - This value is valid only for point and spot lights. - @return The quadratic attenuation factor. */ - float& GetQuadraticAttenuationFactor() { return quadracticAttenuationFactor; } - const float& GetQuadraticAttenuationFactor() const { return quadracticAttenuationFactor; } /**< See above. */ - - /** Sets the quadratic attenuation factor for the light. - This value is valid only for point and spot lights. - @param factor The quadratic attenuation factor. */ - void SetQuadraticAttenuationFactor(float factor) { quadracticAttenuationFactor = factor; } - - /** Retrieves the fall-off exponent for the light. - This value is valid only for spot lights. It determines - how fast the lighting turns off, with respect to - angles greater than the fall-off angle. This results in a smooth - lighting at the spot light's edges. - - IMPORTANT NOTE: Neither ColladaMaya or ColladaMax use this value - as neither Maya or 3dsMax use this technique for soft lighting. - - @return The spot light fall-off exponent. */ - float& GetFallOffExponent() { return fallOffExponent; } - const float& GetFallOffExponent() const { return fallOffExponent; } /**< See above. */ - - /** Sets the fall-off exponent for the light. - @see GetFallOffExponent - @param exponent The spot light fall-off exponent. */ - void SetFallOffExponent(float exponent) { fallOffExponent = exponent; } - - /** Retrieves the fall-off angle for the light. - This value is valid only for spot lights. It defines - the cone of the spot light. - @return The spot light fall-off angle. */ - float& GetFallOffAngle() { return fallOffAngle; } - const float& GetFallOffAngle() const { return fallOffAngle; } /**< See above. */ - - /** Sets the fall-off angle for the light. - @see GetFallOffAngle - @param angle The spot light fall-off angle. */ - void SetFallOffAngle(float angle) { fallOffAngle = angle; } - - /** Retrieves the outer angle for the light. - This value is valid only for spot lights. This value is only used - by documents exported by ColladaMax. This value should always be - greater than the fall-off angle. It represents the angle at which - the lighting is black. All lighting between the fall-off angle and - the outer angle is a linear interpolation between the light color - and black. - @return The spot light outer angle. */ - float& GetOuterAngle() { return outerAngle; } - const float& GetOuterAngle() const { return outerAngle; } /**< See above. */ - - /** Sets the outer angle for the light. - @see GetOuterAngle - @param angle The spot light outer angle. */ - void SetOuterAngle(float angle) { outerAngle = angle; } - - /** Retrieves the penumbra angle for the light. - This value is valid only for spot lights. The value is only used - by documents exported by ColladaMaya. This value is relative to - the fall-off angle and may be negative. If this value is positive, - it determines the outer angle, as described above. If this value - is negative, the fall-off angle is used as the outer angle and the - fall-off angle + the penumbra angle is used as the full-lighting - angle. - @see GetOuterAngle - @return The spot light penumbra angle. */ - float& GetPenumbraAngle() { return penumbraAngle; } - const float& GetPenumbraAngle() const { return penumbraAngle; } /**< See above. */ - - /** Sets the penumbra angle for the light. - @see GetPenumbraAngle - @param angle The spot light penumbra angle. */ - void SetPenumbraAngle(float angle) { penumbraAngle = angle; } - - /** Retrieves the aspect ratio for the light. - This value is only used by documents exported by ColladaMax. - This value is valid only for spot lights and directional lights - which project a rectangle (for pyramidal projection). It represents the ratio - of the projection's height to the projection's width and defines - the projection's rectangle. For pyramidal projections, the fall-off and outer angles - represent the width of the projection. - Note that there is no way to know if the projection is conic or pyramidal. - @return The aspect ratio of the light pyramidal projection. */ - float& GetAspectRatio() { return aspectRatio; } - const float& GetAspectRatio() const { return aspectRatio; } /**< See above. */ - - /** Sets the aspect ratio for the light. - @see GetAspectRatio - @param ratio The aspect ratio of the light pyramidal projection. */ - void SetAspectRatio(float ratio) { aspectRatio = ratio; } - - /** Retrieves the drop-off for the light. - This value is only used by documents exported by ColladaMaya. - @return The drop-off for the light. */ - float& GetDropoff() { return dropoff; } - const float& GetDropoff() const { return dropoff; } /**< See above. */ - - /** Sets the drop-off for the light. - This value is only used by documents exported by ColladaMaya. - @param factor The drop-off for the light. */ - void SetDropoff(float factor) { dropoff = factor; } - - /** Retrieves whether the directional light overshoots. - This value is only used by documents exported by ColladaMax. - This value is valid only for directional lights. This flag - represents whether the directional light has a global projection, - as defined in COLLADA, or a cylinder/prism projection. - Note that there is no way to know if the projection is conic or pyramidal. - @return Whether the directional light overshoots. */ - bool DoesOvershoot() const { return overshoots; } - - /** Sets whether the directional light overshoots. - @see DoesOvershoot - @param _overshoots The overshoot flag for the directional light. */ - void SetOvershoot(bool _overshoots) { overshoots = _overshoots; } - - /** [INTERNAL] Reads in the \ element from a given COLLADA XML tree node. - @param lightNode A COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the light.*/ - FUStatus LoadFromXML(xmlNode* lightNode); - - /** [INTERNAL] Writes out the \ element to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the geometry information. - @return The created XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -#endif // _FCD_LIGHT_H_ - diff --git a/Extras/FCollada/FCDocument/FCDMaterial.cpp b/Extras/FCollada/FCDocument/FCDMaterial.cpp deleted file mode 100644 index 5b32a3c34..000000000 --- a/Extras/FCollada/FCDocument/FCDMaterial.cpp +++ /dev/null @@ -1,211 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDAnimated.h" -#include "FCDocument/FCDEffect.h" -#include "FCDocument/FCDEffectParameter.h" -#include "FCDocument/FCDEffectParameterFactory.h" -#include "FCDocument/FCDEffectParameterList.h" -#include "FCDocument/FCDMaterial.h" -#include "FUtils/FUStringConversion.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -#include "FUtils/FUUniqueStringMap.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDMaterial::FCDMaterial(FCDocument* document) : FCDEntity(document, "VisualMaterial") -{ - effect = NULL; - parameters = new FCDEffectParameterList(GetDocument(), true); - ownsEffect = false; -} - -FCDMaterial::~FCDMaterial() -{ - if (ownsEffect) SAFE_DELETE(effect); - effect = NULL; - SAFE_DELETE(parameters); - techniqueHints.clear(); -} - -// Cloning -FCDMaterial* FCDMaterial::Clone() -{ - FCDMaterial* clone = new FCDMaterial(GetDocument()); - FCDEntity::Clone(clone); - if (effect != NULL) - { - clone->ownsEffect = true; - clone->effect = effect->Clone(); - } - SAFE_DELETE(clone->parameters); - clone->parameters = parameters->Clone(); - return clone; -} - -#ifdef __VISUALC__ -#include -#endif // __VISUALC__ - -// Flatten the material: remove all the modifier parameters from the parameter list, permanently modifying their base parameter -void FCDMaterial::Flatten() -{ - for (FCDEffectParameterList::iterator itP = parameters->begin(); itP != parameters->end(); ++itP) - { - FCDEffectParameterList generators; - if ((*itP)->IsModifier()) - { - // Overwrite the generators - FindParametersByReference((*itP)->GetReference(), generators); - for (FCDEffectParameterList::iterator itQ = generators.begin(); itQ != generators.end(); ++itQ) - { - if ((*itP) != (*itQ)) - { - (*itP)->Overwrite(*itQ); - } - } - } - else - { - // Add this parameter to hierarchy below - if (effect != NULL) effect->AddParameter((*itP)->Clone()); - } - } - CLEAR_POINTER_VECTOR(*parameters); - - if (effect != NULL) effect->Flatten(); -} - -void FCDMaterial::AddParameter(FCDEffectParameter* parameter) -{ - parameters->push_back(parameter); -} - -// Look for the effect parameter with the correct semantic, in order to bind/set its value -FCDEffectParameter* FCDMaterial::FindParameterBySemantic(const string& semantic) -{ - return (effect != NULL) ? effect->FindParameterBySemantic(semantic) : NULL; -} - -void FCDMaterial::FindParametersBySemantic(const string& semantic, FCDEffectParameterList& _parameters) -{ - parameters->FindSemantic(semantic, _parameters); - if (effect != NULL) effect->FindParametersBySemantic(semantic, _parameters); -} - -void FCDMaterial::FindParametersByReference(const string& reference, FCDEffectParameterList& _parameters) -{ - parameters->FindReference(reference, _parameters); - if (effect != NULL) effect->FindParametersByReference(reference, _parameters); -} - -// Parse COLLADA document's element -FUStatus FCDMaterial::LoadFromXML(xmlNode* materialNode) -{ - CLEAR_POINTER_VECTOR(*parameters); - - FUStatus status = FCDEntity::LoadFromXML(materialNode); - if (!status) return status; - if (!IsEquivalent(materialNode->name, DAE_MATERIAL_ELEMENT)) - { - return status.Warning(FS("Unknown element in material library."), materialNode->line); - } - - // Read in the effect pointer node - xmlNode* effectNode = FindChildByType(materialNode, DAE_INSTANCE_EFFECT_ELEMENT); - if (effectNode != NULL) - { - FUUri url = ReadNodeUrl(effectNode); - if (!url.prefix.empty()) - { - return status.Warning(FS("Externally referenced effects are not supported. Material: ") + TO_FSTRING(GetDaeId()), effectNode->line); - } - else if (url.suffix.empty()) - { - return status.Warning(FS("Empty material's definition. Should instantiate an effect from the effect's library. Material: ") + TO_FSTRING(GetDaeId()), effectNode->line); - } - effect = GetDocument()->FindEffect(url.suffix); - - // Read in the parameter modifications - for (xmlNode* child = effectNode->children; child != NULL; child = child->next) - { - if (child->type != XML_ELEMENT_NODE) continue; - - if (IsEquivalent(child->name, DAE_FXCMN_SETPARAM_ELEMENT)) - { - AddParameter(FCDEffectParameterFactory::LoadFromXML(GetDocument(), child, &status)); - } - else if (IsEquivalent(child->name, DAE_FXCMN_HINT_ELEMENT)) - { - FCDMaterialTechniqueHint& hint = *(techniqueHints.insert(techniqueHints.end(), FCDMaterialTechniqueHint())); - hint.platform = TO_FSTRING(ReadNodeProperty(child, DAE_PLATFORM_ATTRIBUTE)); - hint.technique = ReadNodeProperty(child, DAE_REF_ATTRIBUTE); - } - } - } - else - { - // COLLADA 1.3 backward compatibility: look for the effect. - if(effect != NULL) - { - //kind of a hack: swap the ids between the material and the effect and append - //some weird extension to the effect id so that it doesn't conflict with anybody else. - effect->RemoveDaeId(); - status = FCDEntity::LoadFromXML(materialNode); - if (!status) return status; - effect->SetDaeId(GetDaeId() + "_effect1.3"); - } - } - - if (effect == NULL) - { - return status.Warning(FS("Unable to find effect for material: ") + TO_FSTRING(GetDaeId()), materialNode->line); - } - - return status; -} - -// Write out the element to the COLLADA xml tree -xmlNode* FCDMaterial::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* materialNode = WriteToEntityXML(parentNode, DAE_MATERIAL_ELEMENT); - - // The element is required in COLLADA 1.4 - xmlNode* instanceEffectNode = AddChild(materialNode, DAE_INSTANCE_EFFECT_ELEMENT); - if (effect != NULL) - { - AddAttribute(instanceEffectNode, DAE_URL_ATTRIBUTE, string("#") + effect->GetDaeId()); - - // Write out the technique hints - for (FCDMaterialTechniqueHintList::const_iterator itH = techniqueHints.begin(); itH != techniqueHints.end(); ++itH) - { - xmlNode* hintNode = AddChild(instanceEffectNode, DAE_FXCMN_HINT_ELEMENT); - AddAttribute(hintNode, DAE_PLATFORM_ATTRIBUTE, (*itH).platform); - AddAttribute(hintNode, DAE_REF_ATTRIBUTE, (*itH).technique); - } - - // Write out the parameters - for (FCDEffectParameterList::const_iterator itP = parameters->begin(); itP != parameters->end(); ++itP) - { - (*itP)->WriteToXML(instanceEffectNode); - } - } - else - { - AddAttribute(instanceEffectNode, DAE_URL_ATTRIBUTE, string("#")); - } - - FCDEntity::WriteToExtraXML(materialNode); - return materialNode; -} diff --git a/Extras/FCollada/FCDocument/FCDMaterial.h b/Extras/FCollada/FCDocument/FCDMaterial.h deleted file mode 100644 index c6751957f..000000000 --- a/Extras/FCollada/FCDocument/FCDMaterial.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDMaterial.h - This file contains the FCDMaterail class and the FCDMaterialTechniqueHint structure. -*/ - -#ifndef _FCD_MATERIAL_H_ -#define _FCD_MATERIAL_H_ - -#include "FCDocument/FCDEntity.h" - -class FCDocument; -class FCDEffect; -class FCDEffectParameter; -class FCDEffectParameterList; - -/** - A technique usage hint for a material. - This structure contains two strings to help applications - choose a technique within the material's instantiated effect - according to their application platform. -*/ -class FCOLLADA_EXPORT FCDMaterialTechniqueHint -{ -public: - fstring platform; /**< A platform semantic. COLLADA defines no platform semantics. */ - string technique; /**< The sid for the technique to choose for the platform. */ -}; - -/** A dynamically-sized list of material platform-technique hints. */ -typedef vector FCDMaterialTechniqueHintList; - -/** - A COLLADA material. - - A COLLADA material is one of many abstraction level that defines how - to render mesh polygon sets. It instantiates an effect and may - overrides some of the effect parameters with its own values. - - Unless you care about the construction history or memory, you should probably - use the FCDMaterialInstance::FlattenMaterial function. - - @ingroup FCDocument -*/ -class FCOLLADA_EXPORT FCDMaterial : public FCDEntity -{ -private: - bool ownsEffect; - FCDEffect* effect; - FCDEffectParameterList* parameters; - FCDMaterialTechniqueHintList techniqueHints; - -public: - /** Constructor: do not use directly. - Instead, use the FCDMaterialLibrary::AddMaterial function. - @param document The COLLADA document that owns the material. */ - FCDMaterial(FCDocument* document); - - /** Destructor: do not use directly. - The material library will release all the materials when it is - released. If you want to remove a material from the material library: - use the FCDMaterialLibrary::RemoveMaterial function. */ - virtual ~FCDMaterial(); - - /** Retrieves the entity type for this class. This function is part - of the FCDEntity class interface. - @return The entity type: MATERIAL. */ - virtual Type GetType() const { return FCDEntity::MATERIAL; } - - /** Retrieves the effect instantiated for this material. - The parameters of the effect may be overwritten by this material. - You should either flatten the material using the FlattenMaterial function - or verify the parameter values manually using the parameter list accessors. - @return The instantiated effect. This pointer will be NULL if the material has no rendering. */ - FCDEffect* GetEffect() { return effect; } - const FCDEffect* GetEffect() const { return effect; } /**< See above. */ - - /** Sets the effect instantiated for this material. - @param _effect The effect instantiated for this material. */ - void SetEffect(FCDEffect* _effect) { effect = _effect; } - - /** Retrieves the list of the material platform-technique hints. - @return The list of material platform-technique hints. */ - FCDMaterialTechniqueHintList& GetTechniqueHints() { return techniqueHints; } - const FCDMaterialTechniqueHintList& GetTechniqueHints() const { return techniqueHints; } /**< See above. */ - - /** Retrieves the list of effect parameter overrides. - @return The list of effect parameter overrides. */ - FCDEffectParameterList* GetParameters() { return parameters; } - const FCDEffectParameterList* GetParameters() const { return parameters; } /**< See above. */ - - /** Retrieves an effect parameter override. Looks for the effect parameter override with the correct - semantic, in order to bind or set its value. This function searches through the material and the - level of abstractions below. - @param semantic The effect parameter semantic to match. - @return The effect parameter override that matches the semantic. - This pointer will be NULL if no effect parameter override matches - the given semantic. */ - FCDEffectParameter* FindParameterBySemantic(const string& semantic); - - /** Retrieves a subset of the effect parameter override list. - Look for the effect parameter overrides with the correct semantic. - This function searches through the material and the level of abstractions below. - @param semantic The effect parameter semantic to match. - @param parameters The list of parameters to fill in. This list is not cleared. */ - void FindParametersBySemantic(const string& semantic, FCDEffectParameterList& parameters); - - /** Retrieves a subset of the effect parameter override list. - Look for the effect parameter overrides with the correct reference. - This function searches through the material and the level of abstractions below. - @param reference The effect parameter reference to match. In the case of effect - parameter generators, the reference is replaced by the sub-id. - @param parameters The list of parameters to fill in. This list is not cleared. */ - void FindParametersByReference(const string& reference, FCDEffectParameterList& parameters); - - /** [INTERNAL] Clones the material object. Everything is cloned, including the effect parameter. - You will need release the cloned material directly, by deleting the pointer. - @return The cloned material object. You will must delete this pointer. */ - FCDMaterial* Clone(); - - /** [INTERNAL] Flattens the material, pushing all the effect parameter overrides - into the effect parameter generators and moving all the parameters to the - effect technique level of abstraction. To flatten the material, use the - FCDMaterialInstance::FlattenMaterial function. */ - void Flatten(); - - /** [INTERNAL] Reads in the \ element from a given COLLADA XML tree node. - @param materialNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the material.*/ - virtual FUStatus LoadFromXML(xmlNode* materialNode); - - /** [INTERNAL] Writes out the \ element to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the material declaration. - @return The created element XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; - -private: - void AddParameter(FCDEffectParameter* parameter); -}; - -#endif // _FCD_MATERIAL_H_ diff --git a/Extras/FCollada/FCDocument/FCDMaterialInstance.cpp b/Extras/FCollada/FCDocument/FCDMaterialInstance.cpp deleted file mode 100644 index 5fe9fb009..000000000 --- a/Extras/FCollada/FCDocument/FCDMaterialInstance.cpp +++ /dev/null @@ -1,158 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDEffectParameter.h" -#include "FCDocument/FCDEffectParameterFactory.h" -#include "FCDocument/FCDEffectParameterList.h" -#include "FCDocument/FCDGeometry.h" -#include "FCDocument/FCDController.h" -#include "FCDocument/FCDGeometryInstance.h" -#include "FCDocument/FCDGeometryMesh.h" -#include "FCDocument/FCDGeometryPolygons.h" -#include "FCDocument/FCDMaterial.h" -#include "FCDocument/FCDMaterialInstance.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDMaterialInstance::FCDMaterialInstance(FCDocument* document, FCDGeometryInstance* _parent) : FCDEntityInstance(document, NULL) -{ - material = NULL; - parent = _parent; -} - -FCDMaterialInstance::~FCDMaterialInstance() -{ - bindings.clear(); - parent = NULL; - material = NULL; -} - -// Create a flattened version of the instantiated material: this is the -// prefered way to generate DCC/viewer materials from a COLLADA document -FCDMaterial* FCDMaterialInstance::FlattenMaterial() -{ - FCDGeometry* geometry = NULL; - - // Retrieve the necessary geometry and material information - if(parent->GetEntity()->GetType() == FCDEntity::CONTROLLER) - { - FCDController* controller = (FCDController*) parent->GetEntity(); - FCDEntity* baseTarget = controller->GetBaseTarget(); - if(baseTarget->GetType() == FCDEntity::GEOMETRY) - geometry = (FCDGeometry*) baseTarget; - } - else if(parent->GetEntity()->GetType() == FCDEntity::GEOMETRY) - { - geometry = (FCDGeometry*) parent->GetEntity(); - } - - if (material == NULL || geometry == NULL || !geometry->IsMesh()) return NULL; - - // Retrieve the correct polygons for this material semantic - FCDGeometryMesh* mesh = geometry->GetMesh(); - size_t polygonsCount = mesh->GetPolygonsCount(); - FCDGeometryPolygons* polygons = NULL; - for (size_t i = 0; i < polygonsCount; ++i) - { - FCDGeometryPolygons* p = mesh->GetPolygons(i); - if (semantic == p->GetMaterialSemantic()) { polygons = p; break; } - } - if (polygons == NULL) return NULL; - - FCDMaterial* clone = material->Clone(); - clone->Flatten(); - - // Flatten: Apply the bindings to the cloned material - for (FCDMaterialInstanceBindList::iterator itB = bindings.begin(); itB != bindings.end(); ++itB) - { - FCDEffectParameterList parameters; - clone->FindParametersBySemantic((*itB).semantic, parameters); - for (FCDEffectParameterList::iterator itP = parameters.begin(); itP != parameters.end(); ++itP) - { - FCDEffectParameter* param = (*itP); - if (param->GetType() == FCDEffectParameter::INTEGER) - { - FCDEffectParameterInt* intParam = (FCDEffectParameterInt*) param; - - // Fairly hacky: only supported bind type right now is the texture-texture coordinate sets, which are never animated - - // Resolve the target as a geometry source - FCDGeometryPolygonsInput* input = polygons->FindInput((*itB).target); - if (input != NULL) intParam->SetValue(input->set); - } - } - } - return clone; -} - -// Read in the element from the COLLADA document -FUStatus FCDMaterialInstance::LoadFromXML(xmlNode* instanceNode) -{ - FUStatus status = FCDEntityInstance::LoadFromXML(instanceNode); - if (!status) return status; - bindings.clear(); - - semantic = TO_FSTRING(ReadNodeProperty(instanceNode, DAE_SYMBOL_ATTRIBUTE)); - string materialId = ReadNodeProperty(instanceNode, DAE_TARGET_ATTRIBUTE); - entity = material = GetDocument()->FindMaterial(materialId); - if (material == NULL) - { - return status.Warning(FS("Invalid material binding in geometry instantiation."), instanceNode->line); - } - - // Read in the ColladaFX bindings - xmlNodeList bindNodes; - FindChildrenByType(instanceNode, DAE_BIND_ELEMENT, bindNodes); - for (xmlNodeList::iterator itB = bindNodes.begin(); itB != bindNodes.end(); ++itB) - { - FCDMaterialInstanceBind& bind = (*bindings.insert(bindings.end(), FCDMaterialInstanceBind())); - bind.semantic = ReadNodeProperty(*itB, DAE_SEMANTIC_ATTRIBUTE); - bind.target = ReadNodeProperty(*itB, DAE_TARGET_ATTRIBUTE); - } - - return status; -} - -FUStatus FCDMaterialInstance::LoadFromId(const string& materialId) -{ - FUStatus status; - bindings.clear(); - - // Copy the semantic over - semantic = TO_FSTRING(materialId); - - // Find the material associated with this Id and clone it. - entity = material = GetDocument()->FindMaterial(materialId); - if (material == NULL) - { - return status.Warning(FS("Unknown material id or semantic: ") + TO_FSTRING(materialId)); - } - - return status; -} - -// Write out the instantiation information to the xml node tree -xmlNode* FCDMaterialInstance::WriteToXML(xmlNode* parentNode) const -{ - // Intentionally skip the parent WriteToXML class - xmlNode* instanceNode = AddChild(parentNode, DAE_INSTANCE_MATERIAL_ELEMENT); - const FCDMaterial* material = GetMaterial(); - if (material != NULL) - { - AddAttribute(instanceNode, DAE_SYMBOL_ATTRIBUTE, semantic); - AddAttribute(instanceNode, DAE_TARGET_ATTRIBUTE, material->GetDaeId()); - } - return instanceNode; -} diff --git a/Extras/FCollada/FCDocument/FCDMaterialInstance.h b/Extras/FCollada/FCDocument/FCDMaterialInstance.h deleted file mode 100644 index 1c2645777..000000000 --- a/Extras/FCollada/FCDocument/FCDMaterialInstance.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _FCD_MATERIAL_BIND_H_ -#define _FCD_MATERIAL_BIND_H_ - -#include "FCDocument/FCDEntityInstance.h" - -class FCDocument; -class FCDGeometryInstance; - -class FCOLLADA_EXPORT FCDMaterialInstanceBind -{ -public: - string semantic; - string target; -}; - -typedef vector FCDMaterialInstanceBindList; - -class FCOLLADA_EXPORT FCDMaterialInstance : public FCDEntityInstance -{ -private: - FCDGeometryInstance* parent; - fstring semantic; - FCDMaterial* material; - FCDMaterialInstanceBindList bindings; - -public: - FCDMaterialInstance(FCDocument* document, FCDGeometryInstance* parent); - virtual ~FCDMaterialInstance(); - - // Accessors - virtual Type GetType() const { return MATERIAL; } - const fstring& GetSemantic() const { return semantic; } - FCDMaterial* GetMaterial() { return material; } - const FCDMaterial* GetMaterial() const { return material; } - FCDMaterialInstanceBindList& GetBindings() { return bindings; } - const FCDMaterialInstanceBindList& GetBindings() const { return bindings; } - - // Create a flattened version of the instantiated material: this is the - // prefered way to generate viewer materials from a COLLADA document - FCDMaterial* FlattenMaterial(); - - // Read in the materal instantiation from the COLLADA document - virtual FUStatus LoadFromXML(xmlNode* instanceNode); - FUStatus LoadFromId(const string& materialId); // COLLADA 1.3 backward compatibility - - // Write out the instantiation information to the xml node tree - xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -#endif // _FCD_MATERIAL_BIND_H_ diff --git a/Extras/FCollada/FCDocument/FCDMaterialLibrary.cpp b/Extras/FCollada/FCDocument/FCDMaterialLibrary.cpp deleted file mode 100644 index 31e878c68..000000000 --- a/Extras/FCollada/FCDocument/FCDMaterialLibrary.cpp +++ /dev/null @@ -1,162 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/* -* FCDMaterialLibrary covers the material and effect libraries. -* Covers as well the texture library for COLLADA 1.3 backward compatibility -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDMaterial.h" -#include "FCDocument/FCDMaterialLibrary.h" -#include "FCDocument/FCDEffect.h" -#include "FCDocument/FCDTexture.h" -#include "FUtils/FUStringConversion.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDMaterialLibrary::FCDMaterialLibrary(FCDocument* document) : FCDLibrary(document) -{ -} - -FCDMaterialLibrary::~FCDMaterialLibrary() -{ - // Textures, effects and material entities are deleted by the parent's destructor - textures.clear(); - effects.clear(); - materials.clear(); -} - -// Search for specific material elements -FCDTexture* FCDMaterialLibrary::FindTexture(const string& _daeId) -{ - const char* daeId = SkipPound(_daeId); - for (FCDTextureList::iterator it = textures.begin(); it != textures.end(); ++it) - { - if ((*it)->GetDaeId() == FUDaeWriter::CleanId(daeId)) return *it; - } - return NULL; -} -FCDEffect* FCDMaterialLibrary::FindEffect(const string& _daeId) -{ - const char* daeId = SkipPound(_daeId); - for (FCDEffectList::iterator it = effects.begin(); it != effects.end(); ++it) - { - if ((*it)->GetDaeId() == FUDaeWriter::CleanId(daeId)) return *it; - } - return NULL; -} -FCDMaterial* FCDMaterialLibrary::FindMaterial(const string& _daeId) -{ - const char* daeId = SkipPound(_daeId); - for (FCDMaterialList::iterator it = materials.begin(); it != materials.end(); ++it) - { - if ((*it)->GetDaeId() == FUDaeWriter::CleanId(daeId)) return *it; - } - return NULL; -} - -// Add new entities -FCDEffect* FCDMaterialLibrary::AddEffect() -{ - FCDEffect* effect = new FCDEffect(GetDocument()); - effects.push_back(effect); - entities.push_back(effect); - return effect; -} - -FCDMaterial* FCDMaterialLibrary::AddMaterial() -{ - FCDMaterial* material = new FCDMaterial(GetDocument()); - materials.push_back(material); - entities.push_back(material); - return material; -} - -// Releases entities -void FCDMaterialLibrary::ReleaseEffect(FCDEffect* UNUSED(effect)) -{ - // TODO: IMPLEMENT! -} - -// Releases entities -void FCDMaterialLibrary::ReleaseMaterial(FCDMaterial* UNUSED(material)) -{ - // TODO: IMPLEMENT! -} - -// Read in the COLLADA material/effect library nodes -// Also read in the texture library for COLLADA 1.3 backward compatibility -FUStatus FCDMaterialLibrary::LoadFromXML(xmlNode* node) -{ - FUStatus status; - - // Determine the library type - string libraryType = ReadNodeProperty(node, DAE_TYPE_ATTRIBUTE); - - bool loadEffect = (IsEquivalent(node->name, DAE_LIBRARY_EFFECT_ELEMENT) || - IsEquivalent(node->name, DAE_LIBRARY_ELEMENT) && (libraryType == DAE_EFFECT_TYPE || libraryType == DAE_MATERIAL_TYPE)); - bool loadMaterial = (IsEquivalent(node->name, DAE_LIBRARY_MATERIAL_ELEMENT) || - IsEquivalent(node->name, DAE_LIBRARY_ELEMENT) && libraryType == DAE_MATERIAL_TYPE); - bool loadTexture = (IsEquivalent(node->name, DAE_LIBRARY_ELEMENT) && libraryType == DAE_TEXTURE_TYPE); - - for (xmlNode* child = node->children; child != NULL; child = child->next) - { - if (child->type != XML_ELEMENT_NODE) continue; - - FCDEffect* effect = NULL; - - if(loadEffect) - { - // Parse the elements - // COLLADA 1.3. backward compatibility: also parse the elements to generate the standard effects. - effect = AddEffect(); - status.AppendStatus(effect->LoadFromXML(child)); - } - if(loadMaterial) - { - // Parse the elements - FCDMaterial* material = AddMaterial(); - if (effect != NULL) material->SetEffect(effect); - status.AppendStatus(material->LoadFromXML(child)); - } - if(loadTexture) - { - // Parse the elements - FCDTexture* texture = new FCDTexture(GetDocument()); - status.AppendStatus(texture->LoadFromXML(child)); - textures.push_back(texture); - entities.push_back(texture); - } - } - - return status; -} - -// Write out the COLLADA material and effect library nodes -void FCDMaterialLibrary::WriteToXML(xmlNode* libraryNode) const -{ - // Write out the materials - for (FCDMaterialList::const_iterator itM = materials.begin(); itM != materials.end(); ++itM) - { - (*itM)->WriteToXML(libraryNode); - } - - // Also write out the effects in their library, as a sibling of this node - xmlNode* effectLibraryNode = AddSibling(libraryNode, DAE_LIBRARY_EFFECT_ELEMENT); - for (FCDEffectList::const_iterator itE = effects.begin(); itE != effects.end(); ++itE) - { - (*itE)->WriteToXML(effectLibraryNode); - } -} diff --git a/Extras/FCollada/FCDocument/FCDMaterialLibrary.h b/Extras/FCollada/FCDocument/FCDMaterialLibrary.h deleted file mode 100644 index 183c801ff..000000000 --- a/Extras/FCollada/FCDocument/FCDMaterialLibrary.h +++ /dev/null @@ -1,138 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDMaterialLibrary.h - This file contains the FCDMaterialLibrary.h. -*/ - -#ifndef _FCD_MATERIAL_LIBRARY_H_ -#define _FCD_MATERIAL_LIBRARY_H_ - -class FCDocument; -class FCDTexture; -class FCDEffect; -class FCDMaterial; - -typedef vector FCDTextureList; /**< A dynamically-sized list of textures. */ -typedef vector FCDEffectList; /**< A dynamically-sized list of effects. */ -typedef vector FCDMaterialList; /**< A dynamically-sized list of materials. */ - -#include "FCDocument/FCDLibrary.h" - -/** - The shared COLLADA material and effect libraries. - This class covers the material and effect libraries, as well as the - texture library for COLLADA 1.3 backward compatibility. - - @todo When information push is fully implemented: split the effect library out of this one. - - @ingroup FCDocument -*/ -class FCOLLADA_EXPORT FCDMaterialLibrary : public FCDLibrary -{ -private: - FCDTextureList textures; - FCDEffectList effects; - FCDMaterialList materials; - -public: - /** Constructor: do not use directly. - The document object will create the one and only object of this class. - @param document The COLLADA document that owns this library. */ - FCDMaterialLibrary(FCDocument* document); - - /** Destructor: do not use directly. - The document object will release its libraries. */ - virtual ~FCDMaterialLibrary(); - - /** Retrieves the list of effects contained by this library. - @return The list of effects. */ - FCDEffectList& GetEffects() { return effects; } - const FCDEffectList& GetEffects() const { return effects; } /**< See above. */ - - /** Retrieves the number of effects contained by this library. - @return The number of effects within the library. */ - size_t GetEffectCount() const { return effects.size(); } - - /** Retrieves an effect contained by this library. - @param index The index of the effect. - @return The given effect. This pointer will be NULL if no effect matches the index. */ - FCDEffect* GetEffect(size_t index) { FUAssert(index < GetEffectCount(), return NULL); return effects.at(index); } - const FCDEffect* GetEffect(size_t index) const { FUAssert(index < GetEffectCount(), return NULL); return effects.at(index); } /**< See above. */ - - /** [INTERNAL] Retrieves an effect contained by this library. - @param daeId The COLLADA id of the effect. - @return The matching effect. This pointer will be NULL if no effect matches the COLLADA id. */ - FCDEffect* FindEffect(const string& daeId); - - /** Creates a new effect. - @return The newly created effect. */ - FCDEffect* AddEffect(); - - /** Releases an effect. - @todo Implement FCDMaterialLibrary::ReleaseEffect. - @param effect The effect to release. */ - void ReleaseEffect(FCDEffect* effect); - - /** Retrieves the list of materials contained by this library. - @return The list of materials. */ - FCDMaterialList& GetMaterials() { return materials; } - const FCDMaterialList& GetMaterials() const { return materials; } /**< See above. */ - - /** Retrieves the number of materials contained by this library. - @return The number of materials within the library. */ - size_t GetMaterialCount() const { return materials.size(); } - - /** Retrieves a material contained by this library. - @param index The index of the material. - @return The given material. This pointer will be NULL if no material matches the index. */ - FCDMaterial* GetMaterial(size_t index) { FUAssert(index < GetMaterialCount(), return NULL); return materials.at(index); } - const FCDMaterial* GetMaterial(size_t index) const { FUAssert(index < GetMaterialCount(), return NULL); return materials.at(index); } /**< See above. */ - - /** [INTERNAL] Retrieves a material contained by this library. - @param daeId The COLLADA id of the material. - @return The matching material. This pointer will be NULL - if no material matches the COLLADA id. */ - FCDMaterial* FindMaterial(const string& daeId); - - /** [INTERNAL] Retrieves a texture contained by this library. - @param daeId The COLLADA id of the texture. - @return The matching texture. This pointer will be NULL - if no texture matches the COLLADA id. */ - FCDTexture* FindTexture(const string& daeId); - - /** Creates a new material. - @return The newly created material. */ - FCDMaterial* AddMaterial(); - - /** Releases a material. - @todo Implement FCDMaterialLibrary::ReleaseMaterial. - @param material The material to release. */ - void ReleaseMaterial(FCDMaterial* material); - - /** [INTERNAL] Reads in the contents of the library from the COLLADA XML document. - This method will be called once for the effect library and once for the material library. - It may also be called once, for COLLADA 1.3 backward compatibility, for the texture library. - @param node The COLLADA XML tree node to parse into entities. - @return The status of the import. If the status is not successful, it may be dangerous to - extract information from the library. */ - virtual FUStatus LoadFromXML(xmlNode* node); - - /** [INTERNAL] Writes out the library entities to the COLLADA XML document. - This method writes out the material library within the given node and - writes out the effect library as a sibling node to the given node. - @param libraryNode The COLLADA XML tree node in which to write the materials. */ - virtual void WriteToXML(xmlNode* libraryNode) const; -}; - -#endif // _FCD_MATERIAL_LIBRARY_H_ - diff --git a/Extras/FCollada/FCDocument/FCDMorphController.cpp b/Extras/FCollada/FCDocument/FCDMorphController.cpp deleted file mode 100644 index dd7c9726e..000000000 --- a/Extras/FCollada/FCDocument/FCDMorphController.cpp +++ /dev/null @@ -1,355 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDAnimated.h" -#include "FCDocument/FCDController.h" -#include "FCDocument/FCDGeometry.h" -#include "FCDocument/FCDGeometryMesh.h" -#include "FCDocument/FCDGeometryPolygons.h" -#include "FCDocument/FCDGeometrySource.h" -#include "FCDocument/FCDGeometrySpline.h" -#include "FCDocument/FCDMorphController.h" -#include "FCDocument/FCDSceneNode.h" -#include "FUtils/FUStringConversion.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDMorphController::FCDMorphController(FCDocument* document, FCDController* _parent) : FCDObject(document, "FCDMorphController") -{ - parent = _parent; - baseTarget = NULL; -} - -FCDMorphController::~FCDMorphController() -{ - baseTarget = NULL; - parent = NULL; - - CLEAR_POINTER_VECTOR(morphTargets); -} - -// Changes the base target of the morpher -void FCDMorphController::SetBaseTarget(FCDEntity* entity) -{ - baseTarget = NULL; - - // Retrieve the actual base entity, as you can chain controllers. - FCDEntity* baseEntity = entity; - while (baseEntity != NULL && baseEntity->GetType() == FCDEntity::CONTROLLER) - { - baseEntity = ((FCDController*) baseEntity)->GetBaseTarget(); - } - if (baseEntity != NULL && baseEntity->GetType() == FCDEntity::GEOMETRY) - { - baseTarget = entity; - - // Remove the old morph targets which are not similar, anymore, to the new base entity. - for (size_t i = 0; i < morphTargets.size();) - { - if (IsSimilar(morphTargets[i]->GetGeometry())) - { - ++i; - } - else - { - ReleaseTarget(morphTargets[i]); - } - } - } - else - { - // The new base target is not valid. - CLEAR_POINTER_VECTOR(morphTargets); - } -} - -// Adds a new morph target. -FCDMorphTarget* FCDMorphController::AddTarget(FCDGeometry* geometry, float weight) -{ - FCDMorphTarget* target = NULL; - if (IsSimilar(geometry)) - { - target = new FCDMorphTarget(GetDocument(), this); - target->SetGeometry(geometry); - target->SetWeight(weight); - morphTargets.push_back(target); - } - return target; -} - -// Releases a morph target used in this morpher. -void FCDMorphController::ReleaseTarget(FCDMorphTarget* target) -{ - FCDMorphTargetList::iterator it = std::find(morphTargets.begin(), morphTargets.end(), target); - if (it != morphTargets.end()) - { - delete *it; - morphTargets.erase(it); - } -} - -// Retrieves whether a given entity is similar to the base target. -bool FCDMorphController::IsSimilar(FCDEntity* entity) -{ - bool similar = false; - if (entity != NULL && baseTarget != NULL) - { - size_t vertexCount = 0; - bool isMesh = false; - bool isSpline = false; - - // Find the number of vertices in the base target - FCDEntity* baseEntity = baseTarget; - while (baseEntity != NULL && baseEntity->GetType() == FCDEntity::CONTROLLER) - { - baseEntity = ((FCDController*) baseEntity)->GetBaseTarget(); - } - if (baseEntity != NULL && baseEntity->GetType() == FCDEntity::GEOMETRY) - { - FCDGeometry* g = (FCDGeometry*) baseEntity; - if (g->IsMesh()) - { - isMesh = true; - FCDGeometryMesh* m = g->GetMesh(); - FCDGeometrySource* positions = m->GetPositionSource(); - if (positions != NULL) - { - vertexCount = positions->GetSourceData().size() / positions->GetSourceStride(); - } - } - - if (g->IsSpline()) - { - isSpline = true; - FCDGeometrySpline* s = g->GetSpline(); - vertexCount = s->GetCVCount(); - } - } - - - // Find the number of vertices in the given entity - baseEntity = entity; - while (baseEntity != NULL && baseEntity->GetType() == FCDEntity::CONTROLLER) - { - baseEntity = ((FCDController*) baseEntity)->GetBaseTarget(); - } - if (baseEntity != NULL && baseEntity->GetType() == FCDEntity::GEOMETRY) - { - FCDGeometry* g = (FCDGeometry*) baseEntity; - if (g->IsMesh() && isMesh) - { - FCDGeometryMesh* m = g->GetMesh(); - FCDGeometrySource* positions = m->GetPositionSource(); - if (positions != NULL) - { - similar = (vertexCount == positions->GetSourceData().size() / positions->GetSourceStride()); - } - } - - if (g->IsSpline() && isSpline) - { - FCDGeometrySpline* s = g->GetSpline(); - similar = (vertexCount == s->GetCVCount()); - } - } - } - - return similar; -} - -// Load this controller from a Collada node -FUStatus FCDMorphController::LoadFromXML(xmlNode* morphNode) -{ - FUStatus status; - if (!IsEquivalent(morphNode->name, DAE_CONTROLLER_MORPH_ELEMENT)) - { - return status.Warning(FS("Unexpected node in controller library: ") + TO_FSTRING((const char*) morphNode->name), morphNode->line); - } - - // Parse in the morph method - string methodValue = ReadNodeProperty(morphNode, DAE_METHOD_ATTRIBUTE); - method = FUDaeMorphMethod::FromString(methodValue); - if (method == FUDaeMorphMethod::UNKNOWN) - { - status.Warning(FS("Unknown processing method from morph controller: ") + TO_FSTRING(parent->GetDaeId()), morphNode->line); - } - - // Find the base geometry - string baseTargetId = ReadNodeSource(morphNode); - baseTarget = GetDocument()->FindGeometry(baseTargetId); - if (baseTarget == NULL) GetDocument()->FindController(baseTargetId); - if (baseTarget == NULL) - { - return status.Warning(FS("Cannot find base target for morph controller: ") + TO_FSTRING(parent->GetDaeId()), morphNode->line); - } - - // Find the element and process its inputs - xmlNode* targetsNode = FindChildByType(morphNode, DAE_TARGETS_ELEMENT); - if (targetsNode == NULL) - { - return status.Fail(FS("Cannot find necessary element for morph controller: ") + TO_FSTRING(parent->GetDaeId()), morphNode->line); - } - xmlNodeList inputNodes; - FindChildrenByType(targetsNode, DAE_INPUT_ELEMENT, inputNodes); - - // Find the TARGET and WEIGHT input necessary sources - xmlNode* targetSourceNode = NULL,* weightSourceNode = NULL; - for (xmlNodeList::iterator it = inputNodes.begin(); it != inputNodes.end(); ++it) - { - xmlNode* inputNode = (*it); - string semantic = ReadNodeSemantic(inputNode); - string sourceId = ReadNodeSource(inputNode); - if (semantic == DAE_WEIGHT_MORPH_INPUT || semantic == DAE_WEIGHT_MORPH_INPUT_DEPRECATED) - { - weightSourceNode = FindChildById(morphNode, sourceId); - } - else if (semantic == DAE_TARGET_MORPH_INPUT || semantic == DAE_TARGET_MORPH_INPUT_DEPRECATED) - { - targetSourceNode = FindChildById(morphNode, sourceId); - } - else - { - status.Warning(FS("Unknown morph targets input type in morph controller: ") + TO_FSTRING(parent->GetDaeId()), inputNode->line); - } - } - if (targetSourceNode == NULL) - { - return status.Fail(FS("Cannot find TARGET source for morph controller: ") + TO_FSTRING(parent->GetDaeId()), targetsNode->line); - } - if (weightSourceNode == NULL) - { - return status.Fail(FS("Cannot find WEIGHT source for morph controller: ") + TO_FSTRING(parent->GetDaeId()), targetsNode->line); - } - - // Read in the sources - StringList morphTargetIds; - ReadSource(targetSourceNode, morphTargetIds); - FloatList weights; - ReadSource(weightSourceNode, weights); - size_t targetCount = morphTargetIds.size(); - if (weights.size() != targetCount) - { - return status.Fail(FS("TARGET and WEIGHT sources should be the same size for morph controller: ") + TO_FSTRING(parent->GetDaeId()), targetSourceNode->line); - } - - // Find the target geometries and build the morph targets - morphTargets.reserve(targetCount); - for (int32 i = 0; i < (int32) targetCount; ++i) - { - FCDGeometry* targetGeometry = GetDocument()->FindGeometry(morphTargetIds[i]); - if (targetGeometry == NULL) - { - status.Warning(FS("Unable to find target geometry, '") + TO_FSTRING(morphTargetIds[i]) + FS("' for morph controller: ") + TO_FSTRING(parent->GetDaeId()), morphNode->line); - } - FCDMorphTarget* morphTarget = AddTarget(targetGeometry, weights[i]); - - // Record the morphing weight as animatable - FCDAnimatedFloat::Create(GetDocument(), weightSourceNode, &morphTarget->GetWeight(), i); - } - - return status; -} - -// Write out this controller to a COLLADA xml node tree -xmlNode* FCDMorphController::WriteToXML(xmlNode* parentNode) const -{ - size_t targetCount = GetTargetCount(); - - // Create the node and set its attributes - xmlNode* morphNode = AddChild(parentNode, DAE_CONTROLLER_MORPH_ELEMENT); - AddAttribute(morphNode, DAE_METHOD_ATTRIBUTE, FUDaeMorphMethod::ToString(method)); - if (baseTarget != NULL) - { - AddAttribute(morphNode, DAE_SOURCE_ATTRIBUTE, string("#") + baseTarget->GetDaeId()); - } - - // Gather up the morph target ids and the morphing weights - StringList targetIds; targetIds.reserve(targetCount); - FloatList weights; weights.reserve(targetCount); - for (FCDMorphTargetList::const_iterator it = morphTargets.begin(); it != morphTargets.end(); ++it) - { - FCDMorphTarget* t = (*it); - targetIds.push_back(t->GetGeometry() != NULL ? t->GetGeometry()->GetDaeId() : DAEERR_UNKNOWN_IDREF); - weights.push_back(t->GetWeight()); - } - - // Export the target id source - FUSStringBuilder targetSourceId(parent->GetDaeId()); targetSourceId.append("-targets"); - AddSourceIDRef(morphNode, targetSourceId.ToCharPtr(), targetIds, DAE_TARGET_MORPH_INPUT); - - // Export the weight source - FUSStringBuilder weightSourceId(parent->GetDaeId()); weightSourceId.append("-morph_weights"); - xmlNode* weightSourceNode = AddSourceFloat(morphNode, weightSourceId.ToCharPtr(), weights, DAE_WEIGHT_MORPH_INPUT); - - // Export the elements - xmlNode* targetsNode = AddChild(morphNode, DAE_TARGETS_ELEMENT); - AddInput(targetsNode, targetSourceId.ToCharPtr(), DAE_TARGET_MORPH_INPUT); - AddInput(targetsNode, weightSourceId.ToCharPtr(), DAE_WEIGHT_MORPH_INPUT); - - // Record the morphing weight animations - for (int32 i = 0; i < (int32) targetCount; ++i) - { - FCDMorphTarget* t = morphTargets[i]; - GetDocument()->WriteAnimatedValueToXML(&t->GetWeight(), weightSourceNode, "morphing_weights", i); - } - - return morphNode; -} - -FUStatus FCDMorphController::Link() -{ - return FUStatus(1); -} - -// Morph Target Class Implementation -FCDMorphTarget::FCDMorphTarget(FCDocument* document, FCDMorphController* _parent) : FCDObject(document, "FCDMorphTarget") -{ - parent = _parent; - geometry = NULL; - weight = 0.0f; -} - -FCDMorphTarget::~FCDMorphTarget() -{ - parent = NULL; - geometry = NULL; - weight = 0.0f; -} - -void FCDMorphTarget::SetGeometry(FCDGeometry* _geometry) -{ - // Let go of the old geometry - geometry = NULL; - - // Check if this geometry is similar to the controller base target - if (GetParent()->IsSimilar(_geometry)) - { - geometry = _geometry; - } -} - -FCDAnimated* FCDMorphTarget::GetAnimatedWeight() -{ - return GetDocument()->FindAnimatedValue(&weight); -} -const FCDAnimated* FCDMorphTarget::GetAnimatedWeight() const -{ - return GetDocument()->FindAnimatedValue(&weight); -} - -bool FCDMorphTarget::IsAnimated() const -{ - return GetDocument()->IsValueAnimated(&weight); -} diff --git a/Extras/FCollada/FCDocument/FCDMorphController.h b/Extras/FCollada/FCDocument/FCDMorphController.h deleted file mode 100644 index da79a3c5f..000000000 --- a/Extras/FCollada/FCDocument/FCDMorphController.h +++ /dev/null @@ -1,202 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDMorphController.h - This file contains the FCDMorphController and the FCDMorphTarget classes. -*/ - -#ifndef _FCD_MORPH_CONTROLLER_H_ -#define _FCD_MORPH_CONTROLLER_H_ - -#include "FUtils/FUDaeEnum.h" -#include "FCDocument/FCDObject.h" - -class FCDocument; -class FCDController; -class FCDGeometry; -class FCDMorphController; - -/** - A COLLADA morph target. - A morph target is just a geometric entity with a weight assigned. - The weight may be animated. -*/ -class FCOLLADA_EXPORT FCDMorphTarget : public FCDObject -{ -private: - FCDMorphController* parent; - FCDGeometry* geometry; - float weight; - -public: - /** Constructor: do not use directly. - Instead, use the FCDMorphController::AddTarget function. - @param document The COLLADA document that owns the morph target. - @param parent The morph controller that contains the morph target. */ - FCDMorphTarget(FCDocument* document, FCDMorphController* parent); - - /** Destructor. */ - virtual ~FCDMorphTarget(); - - /** Retrieves the morph controller which contains this target. - @return The parent morpher. */ - FCDMorphController* GetParent() { return parent; } - const FCDMorphController* GetParent() const { return parent; } /**< See above. */ - - /** Retrieves the target geometry. - This is what the morphed geometry should look like if - the morphing weight is set to 1.0f. - @return The target geometry. */ - FCDGeometry* GetGeometry() { return geometry; } - const FCDGeometry* GetGeometry() const { return geometry; } /**< See above. */ - - /** Sets the target geometry. - This is what the morphed geometry should look like if - the morphing weight is set to 1.0f. As such, the target geometry - should be similar to the base target geometry. You can verify - this using the FCDMorphController::IsSimilar function. - @param geometry The target geometry. */ - void SetGeometry(FCDGeometry* geometry); - - /** Retrieves the morphing weight. - @return The morphing weight. */ - float& GetWeight() { return weight; } - const float& GetWeight() const { return weight; } /**< See above. */ - - /** Sets the morphing weight. - This function has no impact on any animations that target the morphing weight. - @param _weight The morphing weight. */ - void SetWeight(float _weight) { weight = _weight; } - - /** Retrieves whether the morphing weight is animated. - @return Whether the morphing weight is animated. */ - bool IsAnimated() const; - - /** Retrieves the animation associated with the morphing weight. - @return The animated value associated with the morphing weight. - This pointer will be NULL if the morphing weight is not animated. */ - FCDAnimated* GetAnimatedWeight(); - const FCDAnimated* GetAnimatedWeight() const; /**< See above. */ -}; - -/** A dynamically-sized array of morph targets. */ -typedef vector FCDMorphTargetList; - -/** - A COLLADA morpher. - - A morpher holds a base geometry and a set of morph targets - that contains a geometry and a weight. The geometry must be similar to the - base geometry and the weights are used to interpolate the vertex positions - of the base geometry. To be similar, two meshes must have the same number of - vertices and two splines must have the same number of control points. - The morphing weights can be animated. - - There are two interpolation functions defined in COLLADA. - See the FUDaeMorphMethod::Method enumerated type for more information. - - @see FCDMorphTarget FUDaeMorphMethod - @ingroup FCDGeometry -*/ -class FCOLLADA_EXPORT FCDMorphController : public FCDObject -{ -private: - FCDController* parent; - FCDocument* document; - - FUDaeMorphMethod::Method method; - FCDEntity* baseTarget; - FCDMorphTargetList morphTargets; - -public: - /** Constructor: do not use directly. - Instead, use the FCDController::CreateMorphController function. - @param document The COLLADA document that owns the morpher. - @param parent The COLLADA controller that contains this morpher. */ - FCDMorphController(FCDocument* document, FCDController* parent); - - /** Destructor: do not use directly. - Instead, release the parent controller or create a new skin/morpher. */ - virtual ~FCDMorphController(); - - /** Retrieves the base entity controlled by this morpher. - This entity may be a geometry or another controller. - @return The base target. */ - FCDEntity* GetBaseTarget() { return baseTarget; } - const FCDEntity* GetBaseTarget() const { return baseTarget; } /**< See above. */ - - /** Sets the base entity controlled by this morpher. - This entity may be a geometry or another controller. - Since the morph targets must be similar to this entity, - all the morph targets that are not similar to the new base entity will be removed. - @param entity The new base entity. */ - void SetBaseTarget(FCDEntity* entity); - - /** Retrieves the list of the morph targets. - All the morph target geometries should be similar to the base entity. - @return The morph targets. */ - FCDMorphTargetList& GetTargets() { return morphTargets; } - const FCDMorphTargetList& GetTargets() const { return morphTargets; } /**< See above. */ - - /** Retrieves the number of morph targets. - @return The number of morph targets. */ - size_t GetTargetCount() const { return morphTargets.size(); } - - /** Retrieves a specific morph target. - @param index The index of the morph target. - @return The morph target. This pointer will be NULL if the index is out-of-bounds. */ - FCDMorphTarget* GetTarget(size_t index) { FUAssert(index < GetTargetCount(), return NULL); return morphTargets.at(index); } - const FCDMorphTarget* GetTarget(size_t index) const { FUAssert(index < GetTargetCount(), return NULL); return morphTargets.at(index); } /**< See above. */ - - /** Adds a new morph target. - @param geometry The morph target geometry. - @param weight The morphing weight. - @return The new morph target. */ - FCDMorphTarget* AddTarget(FCDGeometry* geometry = NULL, float weight = 0.0f); - - /** Releases a morph target used in this morpher. - @param target The morph target to release. */ - void ReleaseTarget(FCDMorphTarget* target); - - /** Retrieves the method used to interpolate between the different morph targets. - @return The interpolation method. */ - FUDaeMorphMethod::Method GetMethod() const { return method; } - - /** Sets the method used to interpolate between the different morph targets. - @param _method The interpolation method. */ - void SetMethod(FUDaeMorphMethod::Method _method) { method = _method; } - - /** Retrieves whether a given entity is similar to the base target. - Entities must be similar to be able to morph between them. - @param entity An entity. - @return Whether the given entity is similar to the base target. */ - bool IsSimilar(FCDEntity* entity); - - /** [INTERNAL] Reads in the \ element from a given COLLADA XML tree node. - @param morphNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the morpher.*/ - FUStatus LoadFromXML(xmlNode* morphNode); - - /** [INTERNAL] Writes out the \ element to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the morphing information. - @return The created element XML tree node. */ - xmlNode* WriteToXML(xmlNode* parentNode) const; - - /** [INTERNAL] Links the controller with its entities. - Since geometries are loaded before the controllers, no linkage is necessary. - @return The status of the linkage: always successful. */ - FUStatus Link(); -}; - -#endif // _FCD_MORPH_CONTROLLER_H_ - diff --git a/Extras/FCollada/FCDocument/FCDObject.cpp b/Extras/FCollada/FCDocument/FCDObject.cpp deleted file mode 100644 index 347ba2062..000000000 --- a/Extras/FCollada/FCDocument/FCDObject.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDObject.h" -#include "FUtils/FUUniqueStringMap.h" -#include "FUtils/FUDaeWriter.h" - -// -// FCDObject -// - -FCDObject::FCDObject(FUObjectContainer* container) -: FUObject_Construct(container, "FCDObject") -{ -} - -FCDObject::FCDObject(FCDocument* document, const char* UNUSED_NDEBUG(className)) -: FUObject_Construct(document, className) -{ -} - -// -// FCDObjectWithId -// - -FCDObjectWithId::FCDObjectWithId(FCDocument* document, const char* baseId) -: FCDObject(document, baseId) -{ - daeId = baseId; - hasUniqueId = false; -} - -FCDObjectWithId::~FCDObjectWithId() -{ - RemoveDaeId(); -} - -void FCDObjectWithId::Clone(FCDObjectWithId* clone) const -{ - clone->daeId = daeId; - clone->hasUniqueId = hasUniqueId; -} - -const string& FCDObjectWithId::GetDaeId() const -{ - if (!hasUniqueId) - { - // Generate a new id - FCDObjectWithId* e = const_cast(this); - FUSUniqueStringMap* names = e->GetDocument()->GetUniqueNameMap(); - FUAssert(!e->daeId.empty(), e->daeId = "unknown_object"); - names->AddUniqueString(e->daeId); - e->hasUniqueId = true; - } - return daeId; -} - -void FCDObjectWithId::SetDaeId(const string& id) -{ - RemoveDaeId(); - - // Use this id to enforce a unique id. - FUSUniqueStringMap* names = GetDocument()->GetUniqueNameMap(); - daeId = FUDaeWriter::CleanId(id); - names->AddUniqueString(daeId); - hasUniqueId = true; -} - -void FCDObjectWithId::SetDaeId(string& id) -{ - RemoveDaeId(); - - // Use this id to enforce a unique id. - FUSUniqueStringMap* names = GetDocument()->GetUniqueNameMap(); - daeId = FUDaeWriter::CleanId(id); - names->AddUniqueString(daeId); - id = daeId; - hasUniqueId = true; -} - -void FCDObjectWithId::RemoveDaeId() -{ - if (hasUniqueId) - { - FUSUniqueStringMap* names = GetDocument()->GetUniqueNameMap(); - names->Erase(daeId); - hasUniqueId = false; - } -} diff --git a/Extras/FCollada/FCDocument/FCDObject.h b/Extras/FCollada/FCDocument/FCDObject.h deleted file mode 100644 index 38c9ed5a5..000000000 --- a/Extras/FCollada/FCDocument/FCDObject.h +++ /dev/null @@ -1,107 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDObject.h - This file contains the FCDObject and the FCDObjectWithId classes. -*/ - -#ifndef __FCD_OBJECT_H_ -#define __FCD_OBJECT_H_ - -#include "FUtils/FUObject.h" -#include "FCDocument/FCDocument.h" - -/** - A basic COLLADA document object. - All the objects owned by the COLLADA document derive from this class. - The FCDocument object is accessible through this interface to all the object which it owns. - - @ingroup FCDocument -*/ -class FCOLLADA_EXPORT FCDObject : public FUObject -{ -private: - // Don't use this constructor directly. - FCDObject(FUObjectContainer* container); - -public: - /** Constructor: sets the COLLADA document object and the informative name. - The name of the class is used only for debugging purposes and is - not accessible in release and retail builds. Therefore, it is not meant to replace or implement RTTI. - @param document The COLLADA document which owns this object. - @param className A information name to identify the class of the object. */ - FCDObject(FCDocument* document, const char* className); - - /** Destructor. */ - virtual ~FCDObject() {} - - /** Retrieves the COLLADA document which owns this object. - @return The COLLADA document. */ - inline FCDocument* GetDocument() { return (FCDocument*) GetContainer(); } - inline FCDocument* GetDocument() const { return (FCDocument*) GetContainer(); } /**< See above. */ -}; - -/** - A basic COLLADA object which has a unique COLLADA id. - - Many COLLADA structures such as entities and sources need a unique COLLADA id. - The COLLADA document contains a map of all the COLLADA ids known in its scope. - The interface of the FCDObjectWithId class allows for the retrieval and the modification - of the unique COLLADA id attached to these objects. - - A unique COLLADA id is built, if none are provided, using the 'baseId' field of the constructor. - A unique COLLADA id is generated only on demand. - - @ingroup FCDocument -*/ -class FCOLLADA_EXPORT FCDObjectWithId : public FCDObject -{ -private: - string daeId; - bool hasUniqueId; - -public: - /** Constructor: sets the prefix COLLADA id to be used if no COLLADA id is provided. - @param document The COLLADA document which owns this object. - @param baseId The prefix COLLADA id to be used if no COLLADA id is provided. */ - FCDObjectWithId(FCDocument* document, const char* baseId = "ObjectWithID"); - - /** Destructor. */ - virtual ~FCDObjectWithId(); - - /** Retrieves the unique COLLADA id for this object. - If no unique COLLADA id has been previously generated or provided, this function - has the side-effect of generating a unique COLLADA id. - @return The unique COLLADA id. */ - const string& GetDaeId() const; - - /** Sets the COLLADA id for this object. - There is no guarantee that the given COLLADA id will be used, as it may not be unique. - You can call the GetDaeId function after this call to retrieve the final, unique COLLADA id. - @param id The wanted COLLADA id for this object. This COLLADA id does not need to be unique. - If the COLLADA id is not unique, a new unique COLLADA id will be generated. */ - void SetDaeId(const string& id); - - /** Sets the COLLADA id for this object. - There is no guarantee that the given COLLADA id will be used, as it may not be unique. - @param id The wanted COLLADA id for this object. This COLLADA id does not need to be unique. - If the COLLADA id is not unique, a new unique COLLADA id will be generated and - this formal variable will be modified to contain the new COLLADA id. */ - void SetDaeId(string& id); - - /** [INTERNAL] Release the unique COLLADA id of an object. - Use this function wisely, as it leaves the object id-less and without a way to automatically - generate a COLLADA id. */ - void RemoveDaeId(); - - /** [INTERNAL] Clones the object. The unique COLLADA id will be copied over to the clone object. - Use carefully: when a cloned object with an id is released, it - does remove the unique COLLADA id from the unique name map. - @param clone The object clone. */ - void Clone(FCDObjectWithId* clone) const; -}; - -#endif // __FCD_OBJECT_H_ diff --git a/Extras/FCollada/FCDocument/FCDPhysicsAnalyticalGeometry.cpp b/Extras/FCollada/FCDocument/FCDPhysicsAnalyticalGeometry.cpp deleted file mode 100644 index 88df67a8d..000000000 --- a/Extras/FCollada/FCDocument/FCDPhysicsAnalyticalGeometry.cpp +++ /dev/null @@ -1,369 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDPhysicsAnalyticalGeometry.h" -#include "FCDocument/FCDPhysicsParameterGeneric.h" -#include "FCDocument/FCDocument.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDPhysicsAnalyticalGeometry::FCDPhysicsAnalyticalGeometry(FCDocument* document) : FCDEntity(document, "AnalyticalGeometry") -{ -} - -FCDPhysicsAnalyticalGeometry::~FCDPhysicsAnalyticalGeometry() -{ -} - - -// Load from a XML node the given physicsAnalyticalGeometry -FUStatus FCDPhysicsAnalyticalGeometry::LoadFromXML(xmlNode* node) -{ - FUStatus status = FCDEntity::LoadFromXML(node); - return status; -} - -FCDPASBox::FCDPASBox(FCDocument* document) : FCDPhysicsAnalyticalGeometry(document) -{ - halfExtents.x = halfExtents.y = halfExtents.z = 0.f; -} - -FCDPhysicsAnalyticalGeometry* FCDPASBox::Clone() -{ - FCDPASBox* clone = new FCDPASBox(GetDocument()); - FCDEntity::Clone(clone); - clone->halfExtents = halfExtents; - return clone; -} - -FUStatus FCDPASBox::LoadFromXML(xmlNode* node) -{ - FUStatus status; - - if (!IsEquivalent(node->name, DAE_BOX_ELEMENT)) - { - return status.Warning(FS("Box is not of the right type."), node->line); - } - - for (xmlNode* child = node->children; child != NULL; child = child->next) - { - if (child->type != XML_ELEMENT_NODE) continue; - - if(IsEquivalent(child->name, DAE_HALF_EXTENTS_ELEMENT)) - { - const char* halfExt = ReadNodeContentDirect(child); - halfExtents.x = FUStringConversion::ToFloat(&halfExt); - halfExtents.y = FUStringConversion::ToFloat(&halfExt); - halfExtents.z = FUStringConversion::ToFloat(&halfExt); - } - } - return status; -} - -xmlNode* FCDPASBox::WriteToXML(xmlNode* node) const -{ - xmlNode* geomNode = AddChild(node, DAE_BOX_ELEMENT); - string s = FUStringConversion::ToString(halfExtents); - AddChild(geomNode, DAE_HALF_EXTENTS_ELEMENT, s); - return geomNode; -} - - -FCDPASPlane::FCDPASPlane(FCDocument* document) : FCDPhysicsAnalyticalGeometry(document) -{ - normal.x = normal.y = normal.z = d = 0.f; -} - -FCDPhysicsAnalyticalGeometry* FCDPASPlane::Clone() -{ - FCDPASPlane* clone = new FCDPASPlane(GetDocument()); - FCDEntity::Clone(clone); - clone->normal = normal; - return clone; -} - -FUStatus FCDPASPlane::LoadFromXML(xmlNode* node) -{ - FUStatus status; - - if (!IsEquivalent(node->name, DAE_PLANE_ELEMENT)) - { - return status.Warning(FS("Plane is not of the right type."), node->line); - } - - for (xmlNode* child = node->children; child != NULL; child = child->next) - { - if (child->type != XML_ELEMENT_NODE) continue; - - if(IsEquivalent(child->name, DAE_EQUATION_ELEMENT)) - { - const char* eq = ReadNodeContentDirect(child); - normal.x = FUStringConversion::ToFloat(&eq); - normal.y = FUStringConversion::ToFloat(&eq); - normal.z = FUStringConversion::ToFloat(&eq); - d = FUStringConversion::ToFloat(&eq); - } - } - return status; -} - -xmlNode* FCDPASPlane::WriteToXML(xmlNode* node) const -{ - xmlNode* geomNode = AddChild(node, DAE_PLANE_ELEMENT); - FMVector4 equation; - equation.w = normal.x; equation.x = normal.y; equation.y = normal.z; equation.z = d; - string s = FUStringConversion::ToString(equation); - AddChild(geomNode, DAE_EQUATION_ELEMENT, s); - return geomNode; -} - - -FCDPASSphere::FCDPASSphere(FCDocument* document) : FCDPhysicsAnalyticalGeometry(document) -{ - radius = 0.f; -} - -FCDPhysicsAnalyticalGeometry* FCDPASSphere::Clone() -{ - FCDPASSphere* clone = new FCDPASSphere(GetDocument()); - FCDEntity::Clone(clone); - clone->radius = radius; - return clone; -} - -FUStatus FCDPASSphere::LoadFromXML(xmlNode* node) -{ - FUStatus status; - - if (!IsEquivalent(node->name, DAE_SPHERE_ELEMENT)) - { - return status.Warning(FS("Sphere is not of the right type."), node->line); - } - - for (xmlNode* child = node->children; child != NULL; child = child->next) - { - if (child->type != XML_ELEMENT_NODE) continue; - - if(IsEquivalent(child->name, DAE_RADIUS_ELEMENT)) - { - radius = FUStringConversion::ToFloat(ReadNodeContentDirect(child)); - } - } - return status; -} - -xmlNode* FCDPASSphere::WriteToXML(xmlNode* node) const -{ - xmlNode* geomNode = AddChild(node, DAE_SPHERE_ELEMENT); - AddChild(geomNode, DAE_RADIUS_ELEMENT, radius); - return geomNode; -} - -FCDPASCylinder::FCDPASCylinder(FCDocument* document) : FCDPhysicsAnalyticalGeometry(document) -{ - height = 0.f; - radius = 0.f; -} - -FCDPhysicsAnalyticalGeometry* FCDPASCylinder::Clone() -{ - FCDPASCylinder* clone = new FCDPASCylinder(GetDocument()); - FCDEntity::Clone(clone); - clone->radius = radius; - clone->height = height; - return clone; -} - -FUStatus FCDPASCylinder::LoadFromXML(xmlNode* node) -{ - FUStatus status; - - if (!IsEquivalent(node->name, DAE_CYLINDER_ELEMENT)) - { - return status.Warning(FS("Sphere is not of the right type."), node->line); - } - - for (xmlNode* child = node->children; child != NULL; child = child->next) - { - if (child->type != XML_ELEMENT_NODE) continue; - - if(IsEquivalent(child->name, DAE_HEIGHT_ELEMENT)) - { - height = FUStringConversion::ToFloat(ReadNodeContentDirect(child)); - } - else if(IsEquivalent(child->name, DAE_RADIUS_ELEMENT)) - { - radius = FUStringConversion::ToFloat(ReadNodeContentDirect(child)); - } - } - return status; -} - -xmlNode* FCDPASCylinder::WriteToXML(xmlNode* node) const -{ - xmlNode* geomNode = AddChild(node, DAE_CYLINDER_ELEMENT); - AddChild(geomNode, DAE_HEIGHT_ELEMENT, height); - AddChild(geomNode, DAE_RADIUS_ELEMENT, radius); - return geomNode; -} - -FCDPASCapsule::FCDPASCapsule(FCDocument* document) : FCDPhysicsAnalyticalGeometry(document) -{ - height = 0.f; - radius = 0.f; -} - -FCDPhysicsAnalyticalGeometry* FCDPASCapsule::Clone() -{ - FCDPASCapsule* clone = new FCDPASCapsule(GetDocument()); - FCDEntity::Clone(clone); - clone->radius = radius; - clone->height = height; - return clone; -} - -FUStatus FCDPASCapsule::LoadFromXML(xmlNode* node) -{ - FUStatus status; - - if (!IsEquivalent(node->name, DAE_CAPSULE_ELEMENT)) - { - return status.Warning(FS("Capsule is not of the right type."), node->line); - } - - for (xmlNode* child = node->children; child != NULL; child = child->next) - { - if (child->type != XML_ELEMENT_NODE) continue; - - if(IsEquivalent(child->name, DAE_HEIGHT_ELEMENT)) - { - height = FUStringConversion::ToFloat(ReadNodeContentDirect(child)); - } - else if(IsEquivalent(child->name, DAE_RADIUS_ELEMENT)) - { - radius = FUStringConversion::ToFloat(ReadNodeContentDirect(child)); - } - } - return status; -} - -xmlNode* FCDPASCapsule::WriteToXML(xmlNode* node) const -{ - xmlNode* geomNode = AddChild(node, DAE_CAPSULE_ELEMENT); - AddChild(geomNode, DAE_HEIGHT_ELEMENT, height); - AddChild(geomNode, DAE_RADIUS_ELEMENT, radius); - return geomNode; -} - -FCDPASTaperedCapsule::FCDPASTaperedCapsule(FCDocument* document) : FCDPASCapsule(document) -{ - radius2 = 0.f; -} - -FCDPhysicsAnalyticalGeometry* FCDPASTaperedCapsule::Clone() -{ - FCDPASTaperedCapsule* clone = new FCDPASTaperedCapsule(GetDocument()); - FCDEntity::Clone(clone); - clone->radius = radius; - return clone; -} - -FUStatus FCDPASTaperedCapsule::LoadFromXML(xmlNode* node) -{ - FUStatus status; - - if (!IsEquivalent(node->name, DAE_TAPERED_CAPSULE_ELEMENT)) - { - return status.Warning(FS("Tapered Capsule is not of the right type."), node->line); - } - - for (xmlNode* child = node->children; child != NULL; child = child->next) - { - if (child->type != XML_ELEMENT_NODE) continue; - - if(IsEquivalent(child->name, DAE_HEIGHT_ELEMENT)) - { - const char* h = ReadNodeContentDirect(child); - height = FUStringConversion::ToFloat(&h); - } - else if(IsEquivalent(child->name, DAE_RADIUS1_ELEMENT)) - { - const char* rad = ReadNodeContentDirect(child); - radius = FUStringConversion::ToFloat(&rad); - } - else if(IsEquivalent(child->name, DAE_RADIUS2_ELEMENT)) - { - const char* rad = ReadNodeContentDirect(child); - radius2 = FUStringConversion::ToFloat(&rad); - } - } - return status; -} - -xmlNode* FCDPASTaperedCapsule::WriteToXML(xmlNode* node) const -{ - xmlNode* geomNode = AddChild(node, DAE_TAPERED_CAPSULE_ELEMENT); - AddChild(geomNode, DAE_HEIGHT_ELEMENT, height); - AddChild(geomNode, DAE_RADIUS1_ELEMENT, radius); - AddChild(geomNode, DAE_RADIUS2_ELEMENT, radius2); - return geomNode; -} - -FCDPASTaperedCylinder::FCDPASTaperedCylinder(FCDocument* document) : FCDPASCylinder(document) -{ - radius2 = 0.f; -} - -FCDPhysicsAnalyticalGeometry* FCDPASTaperedCylinder::Clone() -{ - FCDPASTaperedCylinder* clone = new FCDPASTaperedCylinder(GetDocument()); - FCDEntity::Clone(clone); - clone->radius = radius; - return clone; -} - -FUStatus FCDPASTaperedCylinder::LoadFromXML(xmlNode* node) -{ - FUStatus status; - - if (!IsEquivalent(node->name, DAE_TAPERED_CYLINDER_ELEMENT)) - { - return status.Warning(FS("Tapered cylinder is not of the right type."), node->line); - } - - for (xmlNode* child = node->children; child != NULL; child = child->next) - { - if (child->type != XML_ELEMENT_NODE) continue; - - if(IsEquivalent(child->name, DAE_HEIGHT_ELEMENT)) - { - const char* h = ReadNodeContentDirect(child); - height = FUStringConversion::ToFloat(&h); - } - else if(IsEquivalent(child->name, DAE_RADIUS1_ELEMENT)) - { - const char* rad = ReadNodeContentDirect(child); - radius = FUStringConversion::ToFloat(&rad); - } - else if(IsEquivalent(child->name, DAE_RADIUS2_ELEMENT)) - { - const char* rad = ReadNodeContentDirect(child); - radius2 = FUStringConversion::ToFloat(&rad); - } - } - return status; -} - -xmlNode* FCDPASTaperedCylinder::WriteToXML(xmlNode* node) const -{ - xmlNode* geomNode = AddChild(node, DAE_TAPERED_CYLINDER_ELEMENT); - AddChild(geomNode, DAE_HEIGHT_ELEMENT, height); - AddChild(geomNode, DAE_RADIUS1_ELEMENT, radius); - AddChild(geomNode, DAE_RADIUS2_ELEMENT, radius2); - return geomNode; -} diff --git a/Extras/FCollada/FCDocument/FCDPhysicsAnalyticalGeometry.h b/Extras/FCollada/FCDocument/FCDPhysicsAnalyticalGeometry.h deleted file mode 100644 index 2a6ac7932..000000000 --- a/Extras/FCollada/FCDocument/FCDPhysicsAnalyticalGeometry.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _FCD_PHYSICS_ANALYTICAL_GEOM_H_ -#define _FCD_PHYSICS_ANALYTICAL_GEOM_H_ - -#include "FCDocument/FCDEntity.h" -#include "FCDocument/FCDEntityInstance.h" -#include "FUtils/FUDaeEnum.h" - -class FCDocument; -class FCDPhysicsParameterGeneric; - -typedef std::vector FCDPhysicsParameterList; - -class FCOLLADA_EXPORT FCDPhysicsAnalyticalGeometry : public FCDEntity -{ -public: - enum GeomType { BOX, PLANE, SPHERE, CYLINDER, CAPSULE, TAPERED_CYLINDER, TAPERED_CAPSULE }; - - FCDPhysicsAnalyticalGeometry(FCDocument* document); - virtual ~FCDPhysicsAnalyticalGeometry(); - - virtual Type GetType() const {return PHYSICS_ANALYTICAL_GEOMETRY;} - - // Returns the entity type - virtual GeomType GetGeomType() const = 0; - - // Create a copy of this analyticalGeometry - virtual FCDPhysicsAnalyticalGeometry* Clone() = 0; - - // Read in the node of the COLLADA document - virtual FUStatus LoadFromXML(xmlNode* node); - - // Write out the node to the COLLADA xml tree - virtual xmlNode* WriteToXML(xmlNode* parentNode) const = 0; -}; - -class FCOLLADA_EXPORT FCDPASBox : public FCDPhysicsAnalyticalGeometry -{ -public: - FCDPASBox(FCDocument* document); - virtual ~FCDPASBox() {} - - virtual FUStatus LoadFromXML(xmlNode* node); - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; - virtual GeomType GetGeomType() const {return BOX;} - virtual FCDPhysicsAnalyticalGeometry* Clone(); - -public: - FMVector3 halfExtents; -}; - -class FCOLLADA_EXPORT FCDPASPlane : public FCDPhysicsAnalyticalGeometry -{ -public: - FCDPASPlane(FCDocument* document); - virtual ~FCDPASPlane() {} - - virtual FUStatus LoadFromXML(xmlNode* node); - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; - virtual GeomType GetGeomType() const {return PLANE;} - virtual FCDPhysicsAnalyticalGeometry* Clone(); - -public: - FMVector3 normal; - float d; -}; - -class FCOLLADA_EXPORT FCDPASSphere : public FCDPhysicsAnalyticalGeometry -{ -public: - FCDPASSphere(FCDocument* document); - virtual ~FCDPASSphere() {} - - virtual FUStatus LoadFromXML(xmlNode* node); - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; - virtual GeomType GetGeomType() const {return SPHERE;} - virtual FCDPhysicsAnalyticalGeometry* Clone(); - -public: - float radius; -}; - -class FCOLLADA_EXPORT FCDPASCylinder : public FCDPhysicsAnalyticalGeometry -{ -public: - FCDPASCylinder(FCDocument* document); - virtual ~FCDPASCylinder() {} - - virtual FUStatus LoadFromXML(xmlNode* node); - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; - virtual GeomType GetGeomType() const {return CYLINDER;} - virtual FCDPhysicsAnalyticalGeometry* Clone(); - -public: - float height; - float radius; -}; - -class FCOLLADA_EXPORT FCDPASCapsule : public FCDPhysicsAnalyticalGeometry -{ -public: - FCDPASCapsule(FCDocument* document); - virtual ~FCDPASCapsule() {} - - virtual FUStatus LoadFromXML(xmlNode* node); - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; - virtual GeomType GetGeomType() const {return CAPSULE;} - virtual FCDPhysicsAnalyticalGeometry* Clone(); - -public: - float height; - float radius; -}; - -class FCOLLADA_EXPORT FCDPASTaperedCapsule : public FCDPASCapsule -{ -public: - FCDPASTaperedCapsule(FCDocument* document); - virtual ~FCDPASTaperedCapsule() {} - - virtual FUStatus LoadFromXML(xmlNode* node); - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; - virtual GeomType GetGeomType() const {return TAPERED_CAPSULE;} - virtual FCDPhysicsAnalyticalGeometry* Clone(); - -public: - //inherits all other attributes from Capsule - float radius2; -}; - -class FCOLLADA_EXPORT FCDPASTaperedCylinder : public FCDPASCylinder -{ -public: - FCDPASTaperedCylinder(FCDocument* document); - virtual ~FCDPASTaperedCylinder() {} - - virtual FUStatus LoadFromXML(xmlNode* node); - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; - virtual GeomType GetGeomType() const {return TAPERED_CYLINDER;} - virtual FCDPhysicsAnalyticalGeometry* Clone(); - -public: - //inherits all other attributes from Cylinder - float radius2; -}; - - -#endif // _FCD_PHYSICS_ANALYTICAL_GEOMETRY_H_ diff --git a/Extras/FCollada/FCDocument/FCDPhysicsMaterial.cpp b/Extras/FCollada/FCDocument/FCDPhysicsMaterial.cpp deleted file mode 100644 index f14656772..000000000 --- a/Extras/FCollada/FCDocument/FCDPhysicsMaterial.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDPhysicsMaterial.h" -#include "FUtils/FUStringConversion.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDPhysicsMaterial::FCDPhysicsMaterial(FCDocument* document) : FCDEntity(document, "PhysicsMaterial") -{ - staticFriction = 0.f; - dynamicFriction = 0.f; - restitution = 0.f; -} - -FCDPhysicsMaterial::~FCDPhysicsMaterial() -{ -} - -// Cloning -FCDPhysicsMaterial* FCDPhysicsMaterial::Clone() -{ - FCDPhysicsMaterial* clone = new FCDPhysicsMaterial(GetDocument()); - FCDEntity::Clone(clone); - clone->SetStaticFriction(staticFriction); - clone->SetDynamicFriction(dynamicFriction); - clone->SetRestitution(restitution); - return clone; -} - -// Parse COLLADA document's element -FUStatus FCDPhysicsMaterial::LoadFromXML(xmlNode* physicsMaterialNode) -{ - FUStatus status = FCDEntity::LoadFromXML(physicsMaterialNode); - if (!status) return status; - if (!IsEquivalent(physicsMaterialNode->name, DAE_PHYSICS_MATERIAL_ELEMENT)) - { - return status.Warning(FS("Unknown element in physics material library."), physicsMaterialNode->line); - } - - //read in the element - xmlNode* commonTechniqueNode = FindTechnique(physicsMaterialNode, DAE_COMMON_PROFILE); - if (commonTechniqueNode == NULL) - { - return status.Fail(FS("Unable to find common technique for physics material: ") + TO_FSTRING(GetDaeId()), physicsMaterialNode->line); - } - - xmlNode* paramNode = FindChildByType(commonTechniqueNode, DAE_PHYSICS_STATIC_FRICTION); - if (paramNode != NULL) - { - const char* content = ReadNodeContentDirect(paramNode); - staticFriction = FUStringConversion::ToFloat(content); - } - - paramNode = FindChildByType(commonTechniqueNode, DAE_PHYSICS_DYNAMIC_FRICTION); - if (paramNode != NULL) - { - const char* content = ReadNodeContentDirect(paramNode); - dynamicFriction = FUStringConversion::ToFloat(content); - } - - paramNode = FindChildByType(commonTechniqueNode, DAE_PHYSICS_RESTITUTION); - if (paramNode != NULL) - { - const char* content = ReadNodeContentDirect(paramNode); - restitution = FUStringConversion::ToFloat(content); - } - - return status; -} - -// Write out the element to the COLLADA xml tree -xmlNode* FCDPhysicsMaterial::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* physicsMaterialNode = WriteToEntityXML(parentNode, DAE_PHYSICS_MATERIAL_ELEMENT); - AddChild(physicsMaterialNode, DAE_PHYSICS_STATIC_FRICTION, staticFriction); - AddChild(physicsMaterialNode, DAE_PHYSICS_DYNAMIC_FRICTION, dynamicFriction); - AddChild(physicsMaterialNode, DAE_PHYSICS_RESTITUTION, restitution); - - FCDEntity::WriteToExtraXML(physicsMaterialNode); - return physicsMaterialNode; -} diff --git a/Extras/FCollada/FCDocument/FCDPhysicsMaterial.h b/Extras/FCollada/FCDocument/FCDPhysicsMaterial.h deleted file mode 100644 index 703cb46af..000000000 --- a/Extras/FCollada/FCDocument/FCDPhysicsMaterial.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _FCD_PHYSICSMATERIAL_H_ -#define _FCD_PHYSICSMATERIAL_H_ - -#include "FCDocument/FCDEntity.h" - -class FCDocument; - -class FCOLLADA_EXPORT FCDPhysicsMaterial : public FCDEntity -{ -private: - float staticFriction; - float dynamicFriction; - float restitution; - -public: - FCDPhysicsMaterial(FCDocument* document); - virtual ~FCDPhysicsMaterial(); - - // Accessors - virtual Type GetType() const { return FCDEntity::PHYSICS_MATERIAL; } - float GetStaticFriction() const { return staticFriction; } - void SetStaticFriction(float _staticFriction) { staticFriction = _staticFriction; } - float GetDynamicFriction() const { return dynamicFriction; } - void SetDynamicFriction(float _dynamicFriction) { dynamicFriction = _dynamicFriction; } - float GetRestitution() const { return restitution; } - void SetRestitution(float _restitution) { restitution = _restitution;} - - // Cloning - FCDPhysicsMaterial* Clone(); - - // Parse COLLADA document's element - virtual FUStatus LoadFromXML(xmlNode* physicsMaterialNode); - - // Write out the element to the COLLADA xml tree - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -#endif // _FCD_MATERIAL_H_ diff --git a/Extras/FCollada/FCDocument/FCDPhysicsModel.cpp b/Extras/FCollada/FCDocument/FCDPhysicsModel.cpp deleted file mode 100644 index ccd49042e..000000000 --- a/Extras/FCollada/FCDocument/FCDPhysicsModel.cpp +++ /dev/null @@ -1,134 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDPhysicsModel.h" -#include "FCDocument/FCDPhysicsRigidBody.h" -#include "FCDocument/FCDPhysicsRigidConstraint.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDAnimated.h" -#include "FUtils/FUStringConversion.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDPhysicsModel::FCDPhysicsModel(FCDocument* document) : FCDEntity(document, "PhysicsModel") -{ -} - -FCDPhysicsModel::~FCDPhysicsModel() -{ - CLEAR_POINTER_VECTOR(instances); - CLEAR_POINTER_VECTOR(rigidBodies); - CLEAR_POINTER_VECTOR(rigidConstraints); -} - -// Create a copy of this physicsModel, with the vertices overwritten -FCDPhysicsModel* FCDPhysicsModel::Clone(/*FloatList& newPositions, uint32 newPositionsStride, FloatList& newNormals, uint32 newNormalsStride*/) -{ - FCDPhysicsModel* clone = new FCDPhysicsModel(GetDocument()); - return clone; -} - -FCDPhysicsRigidBody* FCDPhysicsModel::FindRigidBodyFromSid(const string& sid) -{ - for(FCDPhysicsRigidBodyList::iterator it = rigidBodies.begin(); it!= rigidBodies.end(); ++it) - { - if((*it)->GetSid()==sid) return (*it); - } - return NULL; -} - -FCDPhysicsRigidConstraint* FCDPhysicsModel::FindRigidConstraintFromSid(const string& sid) -{ - for(FCDPhysicsRigidConstraintList::iterator it = rigidConstraints.begin(); it!= rigidConstraints.end(); ++it) - { - if((*it)->GetSid()==sid) return (*it); - } - return NULL; -} - - -// Load from a XML node the given physicsModel -FUStatus FCDPhysicsModel::LoadFromXML(xmlNode* physicsModelNode) -{ - FUStatus status = FCDEntity::LoadFromXML(physicsModelNode); - if (!status) return status; - if (!IsEquivalent(physicsModelNode->name, DAE_PHYSICS_MODEL_ELEMENT)) - { - return status.Warning(FS("PhysicsModel library contains unknown element."), physicsModelNode->line); - } - - // Read in the first valid child element found - for (xmlNode* child = physicsModelNode->children; child != NULL; child = child->next) - { - if (child->type != XML_ELEMENT_NODE) continue; - - if(IsEquivalent(child->name, DAE_RIGID_BODY_ELEMENT)) - { - FCDPhysicsRigidBody* rigidBody = new FCDPhysicsRigidBody(GetDocument()); - status.AppendStatus(rigidBody->LoadFromXML(child)); - rigidBodies.push_back(rigidBody); - - } - else if(IsEquivalent(child->name, DAE_RIGID_CONSTRAINT_ELEMENT)) - { - FCDPhysicsRigidConstraint* rigidConstraint = new FCDPhysicsRigidConstraint(GetDocument(), this); - status.AppendStatus(rigidConstraint->LoadFromXML(child)); - rigidConstraints.push_back(rigidConstraint); - } - else if(IsEquivalent(child->name, DAE_INSTANCE_PHYSICS_MODEL_ELEMENT)) - { - //FIXME: the instantiated physicsModel might not have been parsed yet - FUUri url = ReadNodeUrl(child); - if (url.prefix.empty()) - { - FCDEntity* entity = GetDocument()->FindPhysicsModel(url.suffix); - if (entity != NULL) - { - FCDEntityInstance* instance = new FCDEntityInstance(GetDocument(), entity); - instances.push_back(instance); - status.AppendStatus(instance->LoadFromXML(child)); - } - else - { - status.Warning(FS("Unable to retrieve instance for scene node: ") + TO_FSTRING(GetDaeId()), child->line); - } - } - } - else if(IsEquivalent(child->name, DAE_ASSET_ELEMENT)) - { - } - else if(IsEquivalent(child->name, DAE_EXTRA_ELEMENT)) - { - } - } - - return status; -} - -// Write out the node -xmlNode* FCDPhysicsModel::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* physicsModelNode = WriteToEntityXML(parentNode, DAE_PHYSICS_MODEL_ELEMENT); - for(FCDEntityInstanceList::const_iterator it = instances.begin(); it != instances.end(); ++it) - { - (*it)->WriteToXML(physicsModelNode); - } - for(FCDPhysicsRigidBodyList::const_iterator it = rigidBodies.begin(); it != rigidBodies.end(); ++it) - { - (*it)->WriteToXML(physicsModelNode); - } - for(FCDPhysicsRigidConstraintList::const_iterator it = rigidConstraints.begin(); it != rigidConstraints.end(); ++it) - { - (*it)->WriteToXML(physicsModelNode); - } - - //TODO: Add asset and extra - - FCDEntity::WriteToExtraXML(physicsModelNode); - return physicsModelNode; -} diff --git a/Extras/FCollada/FCDocument/FCDPhysicsModel.h b/Extras/FCollada/FCDocument/FCDPhysicsModel.h deleted file mode 100644 index 77c95c1c9..000000000 --- a/Extras/FCollada/FCDocument/FCDPhysicsModel.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _FCD_PHYSICSMODEL_H_ -#define _FCD_PHYSICSMODEL_H_ - -#include "FCDocument/FCDEntity.h" -#include "FCDocument/FCDEntityInstance.h" -#include "FUtils/FUDaeEnum.h" - -class FCDocument; -class FCDPhysicsRigidBody; -class FCDPhysicsRigidConstraint; - -typedef vector FCDEntityInstanceList; -typedef vector FCDPhysicsRigidBodyList; -typedef vector FCDPhysicsRigidConstraintList; - -class FCOLLADA_EXPORT FCDPhysicsModel : public FCDEntity -{ -private: - FCDEntityInstanceList instances; - FCDPhysicsRigidBodyList rigidBodies; - FCDPhysicsRigidConstraintList rigidConstraints; - -public: - FCDPhysicsModel(FCDocument* document); - virtual ~FCDPhysicsModel(); - - // Returns the entity type - virtual Type GetType() const { return PHYSICS_MODEL; } - - // Direct Accessors - FCDEntityInstanceList& GetInstances() { return instances; } - const FCDEntityInstanceList& GetInstances() const { return instances; } - - FCDPhysicsRigidBody* FindRigidBodyFromSid(const string& sid); - FCDPhysicsRigidConstraint* FindRigidConstraintFromSid(const string& sid); - - // Create a copy of this physicsmodel, with the vertices overwritten - FCDPhysicsModel* Clone(/*FloatList& newPositions, uint32 newPositionsStride, FloatList& newNormals, uint32 newNormalsStride*/); - - // Read in the node of the COLLADA document - virtual FUStatus LoadFromXML(xmlNode* node); - - // Write out the node to the COLLADA xml tree - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -#endif // _FCD_PHYSICSMODEL_H_ diff --git a/Extras/FCollada/FCDocument/FCDPhysicsModelInstance.cpp b/Extras/FCollada/FCDocument/FCDPhysicsModelInstance.cpp deleted file mode 100644 index 396ccb216..000000000 --- a/Extras/FCollada/FCDocument/FCDPhysicsModelInstance.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDController.h" -#include "FCDocument/FCDEntity.h" -#include "FCDocument/FCDPhysicsModel.h" -#include "FCDocument/FCDPhysicsModelInstance.h" -#include "FCDocument/FCDPhysicsRigidBodyInstance.h" -#include "FCDocument/FCDPhysicsRigidConstraintInstance.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDPhysicsModelInstance::FCDPhysicsModelInstance(FCDocument* document, FCDEntity* entity) : FCDEntityInstance(document, entity) -{ - SetClassName("FCDPhysicsModelInstance"); -} - -FCDPhysicsModelInstance::~FCDPhysicsModelInstance() -{ - CLEAR_POINTER_VECTOR(instances); -} - -// Load the geometry instance from the COLLADA document -FUStatus FCDPhysicsModelInstance::LoadFromXML(xmlNode* instanceNode) -{ - FUStatus status = FCDEntityInstance::LoadFromXML(instanceNode); - if (!status) return status; - - if (entity == NULL) - { - return status.Fail(FS("Trying to instantiate non-valid physics entity."), instanceNode->line); - } - - // Check for the expected instantiation node type - if (!IsEquivalent(instanceNode->name, DAE_INSTANCE_PHYSICS_MODEL_ELEMENT)) - { - return status.Fail(FS("Unknown element for instantiation of entity: ") + TO_FSTRING(entity->GetDaeId()), instanceNode->line); - } - - //this is already done in the FCDSceneNode -// string physicsModelId = ReadNodeProperty(instanceNode, DAE_TARGET_ATTRIBUTE); -// entity = GetDocument()->FindPhysicsModel(physicsModelId); -// if(!entity) return status.Fail(FS("Couldn't find physics model for instantiation"), instanceNode->line); - - xmlNodeList rigidBodyNodes; - FindChildrenByType(instanceNode, DAE_INSTANCE_RIGID_BODY_ELEMENT, rigidBodyNodes); - for(xmlNodeList::iterator itB = rigidBodyNodes.begin(); itB != rigidBodyNodes.end(); ++itB) - { - FCDPhysicsRigidBodyInstance* instance = new FCDPhysicsRigidBodyInstance(GetDocument(), entity); - status.AppendStatus(instance->LoadFromXML(*itB)); - instances.push_back(instance); - } - - xmlNodeList rigidConstraintNodes; - FindChildrenByType(instanceNode, DAE_INSTANCE_RIGID_CONSTRAINT_ELEMENT, rigidConstraintNodes); - for(xmlNodeList::iterator itC = rigidConstraintNodes.begin(); itC != rigidConstraintNodes.end(); ++itC) - { - FCDPhysicsRigidConstraintInstance* instance = new FCDPhysicsRigidConstraintInstance(GetDocument(), entity); - status.AppendStatus(instance->LoadFromXML(*itC)); - instances.push_back(instance); - } - - //FIXME: create a FCDPhysicsForceFieldInstance class - xmlNodeList forceFieldNodes; - FindChildrenByType(instanceNode, DAE_INSTANCE_FORCE_FIELD_ELEMENT, forceFieldNodes); - for(xmlNodeList::iterator itN = forceFieldNodes.begin(); itN != forceFieldNodes.end(); ++itN) - { - FCDEntityInstance* instance = new FCDEntityInstance(GetDocument(), NULL); - status.AppendStatus(instance->LoadFromXML(*itN)); - instances.push_back(instance); - } - - return status; -} - -// Write out the instantiation information to the xml node tree -xmlNode* FCDPhysicsModelInstance::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* instanceNode = FCDEntityInstance::WriteToXML(parentNode); - for(FCDEntityInstanceList::const_iterator it = instances.begin(); it != instances.end(); ++it) - { - (*it)->WriteToXML(instanceNode); - } - return instanceNode; -} diff --git a/Extras/FCollada/FCDocument/FCDPhysicsModelInstance.h b/Extras/FCollada/FCDocument/FCDPhysicsModelInstance.h deleted file mode 100644 index a6e55177f..000000000 --- a/Extras/FCollada/FCDocument/FCDPhysicsModelInstance.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _FCD_PHYSICS_MODEL_ENTITY_H_ -#define _FCD_PHYSICS_MODEL_ENTITY_H_ - -#include "FCDocument/FCDEntityInstance.h" - -class FCDocument; - -typedef vector FCDEntityInstanceList; - -class FCOLLADA_EXPORT FCDPhysicsModelInstance : public FCDEntityInstance -{ -private: - FCDEntityInstanceList instances; - -public: - FCDPhysicsModelInstance(FCDocument* document, FCDEntity* entity); - virtual ~FCDPhysicsModelInstance(); - - FCDEntityInstanceList& GetInstances() {return instances;} - - // FCDEntity override for RTTI-like - virtual Type GetType() const { return PHYSICS_MODEL; } - - // Load the geometry instance from the COLLADA document - virtual FUStatus LoadFromXML(xmlNode* instanceNode); - - // Write out the instantiation information to the xml node tree - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -#endif // _FCD_PHYSICS_MODEL_ENTITY_H_ diff --git a/Extras/FCollada/FCDocument/FCDPhysicsParameter.h b/Extras/FCollada/FCDocument/FCDPhysicsParameter.h deleted file mode 100644 index 3a7834fe7..000000000 --- a/Extras/FCollada/FCDocument/FCDPhysicsParameter.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _FCD_PHYSICS_PARAMETER_H_ -#define _FCD_PHYSICS_PARAMETER_H_ - -#include "FCDocument/FCDPhysicsParameterGeneric.h" - -class FCDocument; - -template - -class FCOLLADA_EXPORT FCDPhysicsParameter: public FCDPhysicsParameterGeneric -{ -public: - FCDPhysicsParameter(FCDocument* document, const string& ref); - virtual ~FCDPhysicsParameter(); - - // Clone - virtual FCDPhysicsParameterGeneric* Clone(); - - void SetValue(T val); - void SetValue(T* val); - - T* GetValue() const {return value;} - - // Flattening: overwrite the target parameter with this parameter - virtual void Overwrite(FCDPhysicsParameterGeneric* target); - - // Parse in this ColladaFX parameter from the xml node tree -// virtual FUStatus LoadFromXML(xmlNode* parameterNode); - - // Write out this ColladaFX parameter to the xml node tree - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; - -protected: - T* value; - -}; - -#include "FCDPhysicsParameter.hpp" - -#endif // _FCD_PHYSICS_PARAMETER_H_ diff --git a/Extras/FCollada/FCDocument/FCDPhysicsParameter.hpp b/Extras/FCollada/FCDocument/FCDPhysicsParameter.hpp deleted file mode 100644 index 6ff0d3c61..000000000 --- a/Extras/FCollada/FCDocument/FCDPhysicsParameter.hpp +++ /dev/null @@ -1,77 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeWriter; - -template -FCDPhysicsParameter::FCDPhysicsParameter(FCDocument* document, const string& ref) : FCDPhysicsParameterGeneric(document, ref) -{ - value = NULL; -} - -template -FCDPhysicsParameter::~FCDPhysicsParameter() -{ - SAFE_DELETE(value); -} - -// Clone -template -FCDPhysicsParameterGeneric* FCDPhysicsParameter::Clone() -{ - FCDPhysicsParameterGeneric *clone = new FCDPhysicsParameter(GetDocument(), reference); - ((FCDPhysicsParameter*)clone)->value = new T(*value); - return clone; -} - -template -void FCDPhysicsParameter::SetValue(T val) -{ - if(value) - { - SAFE_DELETE(value); - } - value = new T(); - *value = val; -} - - -template -void FCDPhysicsParameter::SetValue(T* val) -{ - if(value) - { - SAFE_DELETE(value); - } - value = val; -} - -// Flattening: overwrite the target parameter with this parameter -template -void FCDPhysicsParameter::Overwrite(FCDPhysicsParameterGeneric* target) -{ - ((FCDPhysicsParameter*) target)->SetValue(value); -} - -/* -// Parse in this Collada parameter from the xml node tree -template -FUStatus FCDPhysicsParameter::LoadFromXML(xmlNode* parameterNode) -{ - FUStatus status; - return status; -} -*/ -// Write out this ColladaFX parameter to the xml node tree -template -xmlNode* FCDPhysicsParameter::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* parameterNode = FUXmlWriter::AddChild(parentNode, reference.c_str()); - //TODO: complete - return parameterNode; -} diff --git a/Extras/FCollada/FCDocument/FCDPhysicsParameterGeneric.cpp b/Extras/FCollada/FCDocument/FCDPhysicsParameterGeneric.cpp deleted file mode 100644 index 819160948..000000000 --- a/Extras/FCollada/FCDocument/FCDPhysicsParameterGeneric.cpp +++ /dev/null @@ -1,18 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDPhysicsParameterGeneric.h" -#include "FCDocument/FCDocument.h" - -FCDPhysicsParameterGeneric::FCDPhysicsParameterGeneric(FCDocument* document, const string& ref) : FCDObject(document, "FCDPhysicsParameterGeneric") -{ - isGenerator = true; - reference = ref; -} -FCDPhysicsParameterGeneric::~FCDPhysicsParameterGeneric() -{ -} - diff --git a/Extras/FCollada/FCDocument/FCDPhysicsParameterGeneric.h b/Extras/FCollada/FCDocument/FCDPhysicsParameterGeneric.h deleted file mode 100644 index f78b52af8..000000000 --- a/Extras/FCollada/FCDocument/FCDPhysicsParameterGeneric.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _FCD_PHYSICS_PARAMETER_GENERIC_H_ -#define _FCD_PHYSICS_PARAMETER_GENERIC_H_ - -#include "FCDocument/FCDObject.h" - -class FCDocument; - -class FCOLLADA_EXPORT FCDPhysicsParameterGeneric: public FCDObject -{ -public: - FCDPhysicsParameterGeneric(FCDocument* document, const string& ref); - virtual ~FCDPhysicsParameterGeneric(); - - virtual FCDPhysicsParameterGeneric* Clone()=0; - bool IsGenerator() const { return isGenerator; } - bool IsModifier() const { return !isGenerator; } - - const string& GetReference() const {return reference;}; - void SetReference(const string& ref) {reference = ref;}; - void SetGenerator(bool val) {isGenerator = val;} - - virtual void Overwrite(FCDPhysicsParameterGeneric* target) = 0; - - // Parse in this ColladaFX parameter from the xml node tree -// virtual FUStatus LoadFromXML(xmlNode* parameterNode) = 0; - - // Write out this ColladaFX parameter to the xml node tree - virtual xmlNode* WriteToXML(xmlNode* parentNode) const = 0; - -protected: - bool isGenerator; // whether this effect parameter structure generates a new value or modifies an existing value (is ?) - string reference; - -}; - -#endif // _FCD_PHYSICS_PARAMETER_GENERIC_H_ diff --git a/Extras/FCollada/FCDocument/FCDPhysicsRigidBody.cpp b/Extras/FCollada/FCDocument/FCDPhysicsRigidBody.cpp deleted file mode 100644 index a1b32039e..000000000 --- a/Extras/FCollada/FCDocument/FCDPhysicsRigidBody.cpp +++ /dev/null @@ -1,253 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDPhysicsRigidBody.h" -#include "FCDocument/FCDPhysicsMaterial.h" -#include "FCDocument/FCDocument.h" -#include "FUtils/FUStringConversion.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDPhysicsRigidBody::FCDPhysicsRigidBody(FCDocument* document) : FCDEntity(document, "RigidBody") -{ - physicsMaterial = NULL; - SetMaterialOwnership(false); -} - -FCDPhysicsRigidBody::~FCDPhysicsRigidBody() -{ - CLEAR_POINTER_VECTOR(parameters); - CLEAR_POINTER_VECTOR(physicsShape); - - if(ownsPhysicsMaterial) - { - SAFE_DELETE(physicsMaterial); - } - else - { - physicsMaterial = NULL; - } -} - -// Create a copy of this physicsRigidBody -FCDPhysicsRigidBody* FCDPhysicsRigidBody::Clone() -{ - FCDPhysicsRigidBody* clone = new FCDPhysicsRigidBody(GetDocument()); - FCDEntity::Clone(clone); - - clone->SetParameters(parameters); - clone->SetPhysicsShapes(physicsShape); - clone->SetPhysicsMaterial(physicsMaterial); - - return clone; -} - -void FCDPhysicsRigidBody::SetParameters(FCDPhysicsParameterList& params) -{ - for (size_t i = 0; i < params.size(); ++i) - { - CopyParameter(params[i]); - } -} - - -void FCDPhysicsRigidBody::CopyParameter(FCDPhysicsParameterGeneric* parameter) -{ - FCDPhysicsParameterGeneric* p = parameter->Clone(); - parameters.push_back(p); -} - -void FCDPhysicsRigidBody::AddParameter(FCDPhysicsParameterGeneric* parameter) -{ - parameters.push_back(parameter); -} - -void FCDPhysicsRigidBody::SetPhysicsMaterial(FCDPhysicsMaterial* _physicsMaterial) -{ - if(physicsMaterial && ownsPhysicsMaterial) - SAFE_DELETE(physicsMaterial); - - physicsMaterial = _physicsMaterial; - SetMaterialOwnership(false); -} - -void FCDPhysicsRigidBody::SetPhysicsShapes(FCDPhysicsShapeList& _physicsShape) -{ - physicsShape.clear(); - - for(FCDPhysicsShapeList::iterator it = _physicsShape.begin(); it != _physicsShape.end(); it++) - physicsShape.push_back((*it)->Clone()); -} - - -// Load from a XML node the given physicsRigidBody -//FIXME: Default values not assigned if child elements not found -FUStatus FCDPhysicsRigidBody::LoadFromXML(xmlNode* physicsRigidBodyNode) -{ - FUStatus status = FCDEntity::LoadFromXML(physicsRigidBodyNode); - if (!status) return status; - if (!IsEquivalent(physicsRigidBodyNode->name, DAE_RIGID_BODY_ELEMENT)) - { - return status.Warning(FS("PhysicsRigidBody library contains unknown element."), physicsRigidBodyNode->line); - } - - sid = FUDaeParser::ReadNodeSid(physicsRigidBodyNode); - - xmlNode* techniqueNode = FindChildByType(physicsRigidBodyNode, DAE_TECHNIQUE_COMMON_ELEMENT); - if (techniqueNode != NULL) - { - xmlNode* param = FindChildByType(techniqueNode, DAE_DYNAMIC_ELEMENT); - if(param) - { - FCDPhysicsParameter* p = new FCDPhysicsParameter(GetDocument(), DAE_DYNAMIC_ELEMENT); - p->SetValue(FUStringConversion::ToBoolean(ReadNodeContentDirect(param))); - AddParameter(p); - } - - xmlNode* massFrame; - massFrame = FindChildByType(techniqueNode, DAE_MASS_FRAME_ELEMENT); - if(massFrame) - { - param = FindChildByType(massFrame, DAE_TRANSLATE_ELEMENT); - if(param) - { - FCDPhysicsParameter* p = new FCDPhysicsParameter(GetDocument(), DAE_TRANSLATE_ELEMENT); - p->SetValue(FUStringConversion::ToPoint(ReadNodeContentDirect(param))); - AddParameter(p); - } - param = FindChildByType(massFrame, DAE_ROTATE_ELEMENT); - if(param) - { - FCDPhysicsParameter* p = new FCDPhysicsParameter(GetDocument(), DAE_ROTATE_ELEMENT); - p->SetValue(FUStringConversion::ToPoint(ReadNodeContentDirect(param))); - AddParameter(p); - } - } - param = FindChildByType(techniqueNode, DAE_INERTIA_ELEMENT); - if(param) - { - FCDPhysicsParameter* p = new FCDPhysicsParameter(GetDocument(), DAE_INERTIA_ELEMENT); - p->SetValue(FUStringConversion::ToPoint(ReadNodeContentDirect(param))); - AddParameter(p); - } - - param = FindChildByType(techniqueNode, DAE_MASS_ELEMENT); - if(param) - { - FCDPhysicsParameter* p = new FCDPhysicsParameter(GetDocument(), DAE_MASS_ELEMENT); - p->SetValue(FUStringConversion::ToFloat(ReadNodeContentDirect(param))); - AddParameter(p); - } - - xmlNodeList shapeNodes; - FindChildrenByType(techniqueNode, DAE_SHAPE_ELEMENT, shapeNodes); - for(xmlNodeList::iterator itS = shapeNodes.begin(); itS != shapeNodes.end(); ++itS) - { - FCDPhysicsShape* shape = new FCDPhysicsShape(GetDocument()); - status.AppendStatus(shape->LoadFromXML(*itS)); - physicsShape.push_back(shape); - } - - param = FindChildByType(techniqueNode, DAE_PHYSICS_MATERIAL_ELEMENT); - if(param) - { - if(physicsMaterial && ownsPhysicsMaterial) - SAFE_DELETE(physicsMaterial); - physicsMaterial = new FCDPhysicsMaterial(GetDocument()); - physicsMaterial->LoadFromXML(param); - SetMaterialOwnership(true); - } - else - { - param = FindChildByType(techniqueNode, DAE_INSTANCE_PHYSICS_MATERIAL_ELEMENT); - if (param == NULL) - { - return status.Fail(FS("Error: No physics material defined in rigid body."), techniqueNode->line); - } - FUUri url = ReadNodeUrl(param); - if (url.prefix.empty()) - { - physicsMaterial = GetDocument()->FindPhysicsMaterial(url.suffix); - if(!physicsMaterial) - { - return status.Fail(FS("Error: Instantiated physics material in rigid body was not found."), techniqueNode->line); - } - } - } - } - - return status; -} - - - -// Flatten the rigid body: remove all the modifier parameters from the parameter list, permanently modifying their base parameter -void FCDPhysicsRigidBody::Flatten() -{ - vector toDelete; - for (FCDPhysicsParameterList::iterator itP = parameters.begin(); itP != parameters.end(); ++itP) - { - FCDPhysicsParameterList generators; - if ((*itP)->IsModifier()) - { - // Overwrite the generators - FCDPhysicsParameterGeneric* generator = FindParameterByReference((*itP)->GetReference()); - if(generator) - { - (*itP)->Overwrite(generator); - toDelete.push_back(itP); - } - else - { - (*itP)->SetGenerator(true); - } - - } - } - - while(!toDelete.empty()) - { - parameters.erase(*toDelete.begin()); - SAFE_DELETE(**(toDelete.begin())); - toDelete.erase(toDelete.begin()); - } - -} - - -FCDPhysicsParameterGeneric* FCDPhysicsRigidBody::FindParameterByReference(const string& reference) -{ - for (FCDPhysicsParameterList::iterator it = parameters.begin(); it != parameters.end(); ++it) - { - if ((*it)->GetReference() == reference) return (*it); - } - return NULL; -} - - -// Write out the node -xmlNode* FCDPhysicsRigidBody::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* physicsRigidBodyNode = WriteToEntityXML(parentNode, DAE_RIGID_BODY_ELEMENT); - xmlNode* baseNode = AddChild(physicsRigidBodyNode, DAE_TECHNIQUE_COMMON_ELEMENT); - - if(physicsMaterial) - physicsMaterial->WriteToXML(baseNode); - - for(FCDPhysicsShapeList::const_iterator it = physicsShape.begin(); it != physicsShape.end(); ++it) - { - (*it)->WriteToXML(baseNode); - } - for(FCDPhysicsParameterList::const_iterator it = parameters.begin(); it != parameters.end(); ++it) - { - (*it)->WriteToXML(baseNode); - } - - FCDEntity::WriteToExtraXML(physicsRigidBodyNode); - return physicsRigidBodyNode; -} diff --git a/Extras/FCollada/FCDocument/FCDPhysicsRigidBody.h b/Extras/FCollada/FCDocument/FCDPhysicsRigidBody.h deleted file mode 100644 index 4e73fed54..000000000 --- a/Extras/FCollada/FCDocument/FCDPhysicsRigidBody.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _FCD_PHYSICSRIGIDBODY_H_ -#define _FCD_PHYSICSRIGIDBODY_H_ - -#include "FCDocument/FCDEntity.h" -#include "FCDocument/FCDEntityInstance.h" -#include "FCDocument/FCDPhysicsParameter.h" -#include "FCDocument/FCDTransform.h" -#include "FCDocument/FCDPhysicsShape.h" -#include "FUtils/FUDaeEnum.h" - -class FCDocument; - -typedef std::vector FCDPhysicsParameterList; -typedef std::vector FCDPhysicsShapeList; - -class FCOLLADA_EXPORT FCDPhysicsRigidBody : public FCDEntity -{ -private: - string sid; - bool ownsPhysicsMaterial; - FCDPhysicsMaterial* physicsMaterial; - - FCDPhysicsParameterList parameters; - FCDPhysicsShapeList physicsShape; - -public: - FCDPhysicsRigidBody(FCDocument* document); - virtual ~FCDPhysicsRigidBody(); - - string GetSid() const { return sid; } - // Returns the entity type - virtual Type GetType() const { return PHYSICS_RIGID_BODY; } - - void AddParameter(FCDPhysicsParameterGeneric* parameter); - void CopyParameter(FCDPhysicsParameterGeneric* parameter); - - void SetParameters(FCDPhysicsParameterList& params); - FCDPhysicsParameterGeneric* FindParameterByReference(const string& reference); - - // Direct Accessors - FCDPhysicsMaterial* GetPhysicsMaterial() const {return physicsMaterial;} - void SetPhysicsMaterial(FCDPhysicsMaterial* _physicsMaterial); - FCDPhysicsShapeList& GetPhysicsShapeList() {return physicsShape;} - void SetPhysicsShapes(FCDPhysicsShapeList& _physicsShape); - void SetMaterialOwnership(bool val) {ownsPhysicsMaterial = val;} - - void Flatten(); - - // Create a copy of this physicsmodel, with the vertices overwritten - FCDPhysicsRigidBody* Clone(); - - // Read in the node of the COLLADA document - virtual FUStatus LoadFromXML(xmlNode* node); - - // Write out the node to the COLLADA xml tree - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -#endif // _FCD_PHYSICSRIGIDBODY_H_ diff --git a/Extras/FCollada/FCDocument/FCDPhysicsRigidBodyInstance.cpp b/Extras/FCollada/FCDocument/FCDPhysicsRigidBodyInstance.cpp deleted file mode 100644 index 157e028e9..000000000 --- a/Extras/FCollada/FCDocument/FCDPhysicsRigidBodyInstance.cpp +++ /dev/null @@ -1,198 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDEntity.h" -#include "FCDocument/FCDPhysicsMaterial.h" -#include "FCDocument/FCDPhysicsModel.h" -#include "FCDocument/FCDPhysicsModelInstance.h" -#include "FCDocument/FCDPhysicsRigidBody.h" -#include "FCDocument/FCDPhysicsRigidBodyInstance.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDPhysicsRigidBodyInstance::FCDPhysicsRigidBodyInstance(FCDocument* document, FCDEntity* _parent) : FCDEntityInstance(document, NULL) -{ - if(_parent->GetType() == FCDEntity::PHYSICS_MODEL) - parent = (FCDPhysicsModel*)_parent; - - rigidBody = NULL; - physicsMaterial = NULL; - ownsPhysicsMaterial = false; - SetClassName("FCDPhysicsRigidBodyInstance"); -} - -FCDPhysicsRigidBodyInstance::~FCDPhysicsRigidBodyInstance() -{ - parent = NULL; - rigidBody = NULL; - CLEAR_POINTER_VECTOR(parameters); - - if(ownsPhysicsMaterial) - { - SAFE_DELETE(physicsMaterial); - } - else - { - physicsMaterial = NULL; - } -} - -void FCDPhysicsRigidBodyInstance::AddParameter(FCDPhysicsParameterGeneric* parameter) -{ - parameters.push_back(parameter); -} - - -// Load the geometry instance from the COLLADA document -FUStatus FCDPhysicsRigidBodyInstance::LoadFromXML(xmlNode* instanceNode) -{ - FUStatus status = FCDEntityInstance::LoadFromXML(instanceNode); - if (!status) return status; - - // Check for the expected instantiation node type - if (!IsEquivalent(instanceNode->name, DAE_INSTANCE_RIGID_BODY_ELEMENT)) - { - return status.Fail(FS("Unknown element for instantiation of entity: ") + TO_FSTRING(entity->GetDaeId()), instanceNode->line); - } - if (parent == NULL) - { - return status.Fail(FS("No Physics Model parent for rigid body instantiation"), instanceNode->line); - } - - - string targetNodeId = ReadNodeProperty(instanceNode, DAE_TARGET_ATTRIBUTE); - targetNode = GetDocument()->FindSceneNode(SkipPound(targetNodeId)); - if(!targetNode) - { - return status.Fail(FS("Couldn't find target node for instantiation of rigid body"), instanceNode->line); - } - string physicsRigidBodySid = ReadNodeProperty(instanceNode, DAE_BODY_ATTRIBUTE); - entity = rigidBody = parent->FindRigidBodyFromSid(physicsRigidBodySid); - if(!rigidBody) - { - return status.Fail(FS("Couldn't find rigid body for instantiation"), instanceNode->line); - } - - - //Read in the same children as rigid_body + velocity and angular_velocity - xmlNode* techniqueNode = FindChildByType(instanceNode, DAE_TECHNIQUE_COMMON_ELEMENT); - xmlNode* param = FindChildByType(techniqueNode, DAE_DYNAMIC_ELEMENT); - if(param) - { - FCDPhysicsParameter* p = new FCDPhysicsParameter(GetDocument(), DAE_DYNAMIC_ELEMENT); - p->SetValue(FUStringConversion::ToBoolean(ReadNodeContentDirect(param))); - AddParameter(p); - } - - xmlNode* massFrame; - massFrame = FindChildByType(techniqueNode, DAE_MASS_FRAME_ELEMENT); - if(massFrame) - { - param = FindChildByType(massFrame, DAE_TRANSLATE_ELEMENT); - if(param) - { - FCDPhysicsParameter* p = new FCDPhysicsParameter(GetDocument(), DAE_TRANSLATE_ELEMENT); - p->SetValue(FUStringConversion::ToPoint(ReadNodeContentDirect(param))); - AddParameter(p); - } - param = FindChildByType(massFrame, DAE_ROTATE_ELEMENT); - if(param) - { - FCDPhysicsParameter* p = new FCDPhysicsParameter(GetDocument(), DAE_ROTATE_ELEMENT); - p->SetValue(FUStringConversion::ToPoint(ReadNodeContentDirect(param))); - AddParameter(p); - } - } - param = FindChildByType(techniqueNode, DAE_INERTIA_ELEMENT); - if(param) - { - FCDPhysicsParameter* p = new FCDPhysicsParameter(GetDocument(), DAE_INERTIA_ELEMENT); - p->SetValue(FUStringConversion::ToPoint(ReadNodeContentDirect(param))); - AddParameter(p); - } - - param = FindChildByType(techniqueNode, DAE_MASS_ELEMENT); - if(param) - { - FCDPhysicsParameter* p = new FCDPhysicsParameter(GetDocument(), DAE_MASS_ELEMENT); - p->SetValue(FUStringConversion::ToFloat(ReadNodeContentDirect(param))); - AddParameter(p); - } - - param = FindChildByType(techniqueNode, DAE_PHYSICS_MATERIAL_ELEMENT); - if(param) - { - if(physicsMaterial && ownsPhysicsMaterial) - SAFE_DELETE(physicsMaterial); - physicsMaterial = new FCDPhysicsMaterial(GetDocument()); - physicsMaterial->LoadFromXML(param); - ownsPhysicsMaterial = true; - } - else - { - param = FindChildByType(techniqueNode, DAE_INSTANCE_PHYSICS_MATERIAL_ELEMENT); - if(param) - { - physicsMaterial = GetDocument()->FindPhysicsMaterial(ReadNodeId(param)); - ownsPhysicsMaterial = false; - } - } - - param = FindChildByType(techniqueNode, DAE_VELOCITY_ELEMENT); - if(param) - { - FCDPhysicsParameter* p = new FCDPhysicsParameter(GetDocument(), DAE_VELOCITY_ELEMENT); - p->SetValue(FUStringConversion::ToPoint(ReadNodeContentDirect(param))); - AddParameter(p); - } - param = FindChildByType(techniqueNode, DAE_ANGULAR_VELOCITY_ELEMENT); - if(param) - { - FCDPhysicsParameter* p = new FCDPhysicsParameter(GetDocument(), DAE_ANGULAR_VELOCITY_ELEMENT); - p->SetValue(FUStringConversion::ToPoint(ReadNodeContentDirect(param))); - AddParameter(p); - } - - return status; -} - - -FCDPhysicsRigidBody* FCDPhysicsRigidBodyInstance::FlattenRigidBody() -{ - FCDPhysicsRigidBody* clone = rigidBody->Clone(); - clone->Flatten(); - - for (FCDPhysicsParameterList::iterator itP = parameters.begin(); itP != parameters.end(); ++itP) - { - FCDPhysicsParameterGeneric* param = clone->FindParameterByReference((*itP)->GetReference()); - if(param) - { - (*itP)->Overwrite(param); - } - else - { - clone->CopyParameter(*itP); - } - } - - if(physicsMaterial) - clone->SetPhysicsMaterial(physicsMaterial); - - return clone; -} - -// Write out the instantiation information to the xml node tree -xmlNode* FCDPhysicsRigidBodyInstance::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* instanceNode = FCDEntityInstance::WriteToXML(parentNode); - - //TODO - - return instanceNode; -} diff --git a/Extras/FCollada/FCDocument/FCDPhysicsRigidBodyInstance.h b/Extras/FCollada/FCDocument/FCDPhysicsRigidBodyInstance.h deleted file mode 100644 index 25b604986..000000000 --- a/Extras/FCollada/FCDocument/FCDPhysicsRigidBodyInstance.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _FCD_PHYSICS_RIGID_BODY_ENTITY_H_ -#define _FCD_PHYSICS_RIGID_BODY_ENTITY_H_ - -#include "FCDocument/FCDEntityInstance.h" - -class FCDocument; -class FCDSceneNode; -class FCDPhysicsRigidBody; -class FCDPhysicsMaterial; -class FCDPhysicsModelInstance; -class FCDPhysicsParameterGeneric; - -typedef std::vector FCDPhysicsParameterList; - -class FCOLLADA_EXPORT FCDPhysicsRigidBodyInstance : public FCDEntityInstance -{ - -private: - FCDPhysicsParameterList parameters; - - FCDPhysicsModel* parent; - FCDPhysicsRigidBody* rigidBody; - FCDPhysicsMaterial* physicsMaterial; - bool ownsPhysicsMaterial; - FCDSceneNode* targetNode; - -public: - FCDPhysicsRigidBodyInstance(FCDocument* document, FCDEntity* _parent); - virtual ~FCDPhysicsRigidBodyInstance(); - - void AddParameter(FCDPhysicsParameterGeneric* parameter); - - FCDPhysicsRigidBody* FlattenRigidBody(); - - FCDSceneNode* GetTargetNode() const {return targetNode;} - - // FCDEntity override for RTTI-like - virtual Type GetType() const { return PHYSICS_RIGID_BODY; } - - // Load the geometry instance from the COLLADA document - virtual FUStatus LoadFromXML(xmlNode* instanceNode); - - // Write out the instantiation information to the xml node tree - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -#endif // _FCD_PHYSICS_RIGID_BODY_ENTITY_H_ diff --git a/Extras/FCollada/FCDocument/FCDPhysicsRigidConstraint.cpp b/Extras/FCollada/FCDocument/FCDPhysicsRigidConstraint.cpp deleted file mode 100644 index 71b4e9830..000000000 --- a/Extras/FCollada/FCDocument/FCDPhysicsRigidConstraint.cpp +++ /dev/null @@ -1,273 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDPhysicsModel.h" -#include "FCDocument/FCDPhysicsRigidConstraint.h" -#include "FCDocument/FCDPhysicsRigidBody.h" -#include "FCDocument/FCDocument.h" -#include "FUtils/FUStringConversion.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDPhysicsRigidConstraint::FCDPhysicsRigidConstraint(FCDocument* document, FCDPhysicsModel* _parent) : FCDEntity(document, "PhysicsRigidConstraint") -{ - enabled = true; - interpenetrate = false; - parent = _parent; - - limitsLinearMin = FMVector3(0.f, 0.f, 0.f); - limitsLinearMax = FMVector3(0.f, 0.f, 0.f); - limitsSCTMin = FMVector3(0.f, 0.f, 0.f); - limitsSCTMax = FMVector3(0.f, 0.f, 0.f); - - referenceRigidBody = NULL; - targetRigidBody = NULL; - - springLinearStiffness = 1.f; - springLinearDamping = 0.f; - springLinearTargetValue = 0.f; - - springAngularStiffness = 1.f; - springAngularDamping = 0.f; - springAngularTargetValue = 0.f; -} - -FCDPhysicsRigidConstraint::~FCDPhysicsRigidConstraint() -{ - referenceRigidBody = NULL; - targetRigidBody = NULL; - CLEAR_POINTER_VECTOR(transformsRef); - CLEAR_POINTER_VECTOR(transformsTar); -} - -// Create a copy of this physicsRigidConstraint, with the vertices overwritten -FCDPhysicsRigidConstraint* FCDPhysicsRigidConstraint::Clone() -{ - FCDPhysicsRigidConstraint* clone = new FCDPhysicsRigidConstraint(GetDocument(), parent); - clone->enabled = enabled; - clone->interpenetrate = interpenetrate; - clone->referenceRigidBody = referenceRigidBody; - clone->targetRigidBody = targetRigidBody; - clone->limitsLinearMax = limitsLinearMax; - clone->limitsLinearMin = limitsLinearMin; - clone->limitsSCTMax = limitsSCTMax; - clone->limitsSCTMin = limitsSCTMin; - clone->springAngularDamping = springAngularDamping; - clone->springAngularStiffness = springAngularStiffness; - clone->springAngularTargetValue = springAngularTargetValue; - clone->springLinearDamping = springLinearDamping; - clone->springLinearStiffness = springLinearStiffness; - clone->springLinearTargetValue = springLinearTargetValue; - return clone; -} - -// Load from a XML node the given physicsRigidConstraint -FUStatus FCDPhysicsRigidConstraint::LoadFromXML(xmlNode* physicsRigidConstraintNode) -{ - FUStatus status = FCDEntity::LoadFromXML(physicsRigidConstraintNode); - if (!status) return status; - if (!IsEquivalent(physicsRigidConstraintNode->name, DAE_RIGID_CONSTRAINT_ELEMENT)) - { - return status.Warning(FS("PhysicsRigidConstraint library contains unknown element."), physicsRigidConstraintNode->line); - } - - sid = FUDaeParser::ReadNodeSid(physicsRigidConstraintNode); - -#define PARSE_TRANSFORM(node, className, nodeName, vector) { \ - xmlNodeList transformNodes; \ - FindChildrenByType(node, nodeName, transformNodes); \ - for(xmlNodeList::iterator itT = transformNodes.begin(); itT != transformNodes.end(); ++itT) { \ - if (IsEquivalent((*itT)->name, nodeName)) { \ - className* transform = new className(GetDocument(), NULL); \ - vector.push_back(transform); \ - status = transform->LoadFromXML(*itT); \ - if (!status) { \ - status.Warning(fstring(FC("Invalid <") FC(nodeName) FC("> transform in node: ")) + TO_FSTRING(GetDaeId()), (*itT)->line);} \ - } \ - } } - - - //Reference-frame body - xmlNode* referenceBodyNode = FindChildByType(physicsRigidConstraintNode, DAE_REF_ATTACHMENT_ELEMENT); - if (referenceBodyNode == NULL) - { - return status.Fail(FS("Reference-frame rigid body not defined in rigid constraint:") + TO_FSTRING(GetDaeId()), physicsRigidConstraintNode->line); - } - string strRigidBody = ReadNodeProperty(referenceBodyNode, DAE_RIGID_BODY_ELEMENT); - referenceRigidBody = parent->FindRigidBodyFromSid(strRigidBody); - if (referenceRigidBody == NULL) - { - return status.Fail(FS("Reference-frame rigid body specified in rigid_constraint ") + TO_FSTRING(GetDaeId()) + FS(" not found in physics model"), referenceBodyNode->line); - } - // Parse the node's transforms: , - PARSE_TRANSFORM(referenceBodyNode, FCDTRotation, DAE_ROTATE_ELEMENT, transformsRef) - PARSE_TRANSFORM(referenceBodyNode, FCDTTranslation, DAE_TRANSLATE_ELEMENT, transformsRef) - - // target body - xmlNode* bodyNode = FindChildByType(physicsRigidConstraintNode, DAE_ATTACHMENT_ELEMENT); - if (bodyNode == NULL) - { - return status.Fail(FS("Target rigid body not defined in rigid constraint") + TO_FSTRING(GetDaeId()), physicsRigidConstraintNode->line); - } - strRigidBody = ReadNodeProperty(bodyNode, DAE_RIGID_BODY_ELEMENT); - targetRigidBody = parent->FindRigidBodyFromSid(strRigidBody); - if (targetRigidBody == NULL) - { - return status.Fail(FS("Target rigid body specified in rigid_constraint ") + TO_FSTRING(GetDaeId()) + FS(" not found in physics model"), bodyNode->line); - } - // Parse the node's transforms: , , - PARSE_TRANSFORM(bodyNode, FCDTRotation, DAE_ROTATE_ELEMENT, transformsTar) - PARSE_TRANSFORM(bodyNode, FCDTTranslation, DAE_TRANSLATE_ELEMENT, transformsTar) - -#undef PARSE_TRANSFORM - - //technique_common - xmlNode* techniqueNode = FindChildByType(physicsRigidConstraintNode, DAE_TECHNIQUE_COMMON_ELEMENT); - if (techniqueNode == NULL) - { - return status.Fail(FS("Technique node not specified in rigid_constraint ") + TO_FSTRING(GetDaeId()), physicsRigidConstraintNode->line); - } - - xmlNode* enabledNode = FindChildByType(techniqueNode, DAE_ENABLED_ELEMENT); - if (enabledNode != NULL) - { - enabled = FUStringConversion::ToBoolean(ReadNodeContentDirect(enabledNode)); - } - xmlNode* interpenetrateNode = FindChildByType(techniqueNode, DAE_INTERPENETRATE_ELEMENT); - if (interpenetrateNode != NULL) - { - interpenetrate = FUStringConversion::ToBoolean(ReadNodeContentDirect(interpenetrateNode)); - } - - xmlNode* limitsNode = FindChildByType(techniqueNode, DAE_LIMITS_ELEMENT); - if (limitsNode != NULL) - { - xmlNode* linearNode = FindChildByType(limitsNode, DAE_LINEAR_ELEMENT); - if (linearNode != NULL) - { - xmlNode* linearMinNode = FindChildByType(linearNode, DAE_MIN_ELEMENT); - if (linearMinNode != NULL) - { - const char* min = ReadNodeContentDirect(linearMinNode); - limitsLinearMin.x = FUStringConversion::ToFloat(&min); - limitsLinearMin.y = FUStringConversion::ToFloat(&min); - limitsLinearMin.z = FUStringConversion::ToFloat(&min); - } - xmlNode* linearMaxNode = FindChildByType(linearNode, DAE_MAX_ELEMENT); - if (linearMaxNode != NULL) - { - const char* max = ReadNodeContentDirect(linearMaxNode); - limitsLinearMax.x = FUStringConversion::ToFloat(&max); - limitsLinearMax.y = FUStringConversion::ToFloat(&max); - limitsLinearMax.z = FUStringConversion::ToFloat(&max); - } - } - - xmlNode* sctNode = FindChildByType(limitsNode, DAE_SWING_CONE_AND_TWIST_ELEMENT); - if (sctNode != NULL) - { - xmlNode* sctMinNode = FindChildByType(sctNode, DAE_MIN_ELEMENT); - if (sctMinNode != NULL) - { - const char* min = ReadNodeContentDirect(sctMinNode); - limitsSCTMin.x = FUStringConversion::ToFloat(&min); - limitsSCTMin.y = FUStringConversion::ToFloat(&min); - limitsSCTMin.z = FUStringConversion::ToFloat(&min); - } - xmlNode* sctMaxNode = FindChildByType(sctNode, DAE_MAX_ELEMENT); - if (sctMaxNode != NULL) - { - const char* max = ReadNodeContentDirect(sctMaxNode); - limitsSCTMax.x = FUStringConversion::ToFloat(&max); - limitsSCTMax.y = FUStringConversion::ToFloat(&max); - limitsSCTMax.z = FUStringConversion::ToFloat(&max); - } - } - } - - xmlNode* spring = FindChildByType(physicsRigidConstraintNode, DAE_SPRING_ELEMENT); - if(spring) - { - xmlNode* linearSpring = FindChildByType(spring, DAE_LINEAR_ELEMENT); - if(linearSpring) - { - xmlNode* param = FindChildByType(linearSpring, DAE_DAMPING_ELEMENT); - if(param) springLinearDamping = FUStringConversion::ToFloat(ReadNodeContentDirect(param)); - param = FindChildByType(linearSpring, DAE_STIFFNESS_ELEMENT); - if(param) springLinearStiffness = FUStringConversion::ToFloat(ReadNodeContentDirect(param)); - param = FindChildByType(linearSpring, DAE_TARGET_VALUE_ELEMENT); - if(param) springLinearTargetValue = FUStringConversion::ToFloat(ReadNodeContentDirect(param)); - } - xmlNode* angularSpring = FindChildByType(spring, DAE_ANGULAR_ELEMENT); - if(angularSpring) - { - xmlNode* param = FindChildByType(angularSpring, DAE_DAMPING_ELEMENT); - if(param) springAngularDamping = FUStringConversion::ToFloat(ReadNodeContentDirect(param)); - param = FindChildByType(angularSpring, DAE_STIFFNESS_ELEMENT); - if(param) springAngularStiffness = FUStringConversion::ToFloat(ReadNodeContentDirect(param)); - param = FindChildByType(angularSpring, DAE_TARGET_VALUE_ELEMENT); - if(param) springAngularTargetValue = FUStringConversion::ToFloat(ReadNodeContentDirect(param)); - } - } - - return status; -} - - - -// Write out the node -xmlNode* FCDPhysicsRigidConstraint::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* physicsRigidConstraintNode = WriteToEntityXML(parentNode, DAE_RIGID_CONSTRAINT_ELEMENT); - - xmlNode* refNode = AddChild(physicsRigidConstraintNode, DAE_REF_ATTACHMENT_ELEMENT); - AddAttribute(refNode, DAE_RIGID_BODY_ELEMENT, referenceRigidBody->GetDaeId()); - for (FCDTransformList::const_iterator itT = transformsRef.begin(); itT != transformsRef.end(); ++itT) - { - (*itT)->WriteToXML(refNode); - } - - xmlNode* tarNode = AddChild(physicsRigidConstraintNode, DAE_ATTACHMENT_ELEMENT); - AddAttribute(tarNode, DAE_RIGID_BODY_ELEMENT, referenceRigidBody->GetDaeId()); - for (FCDTransformList::const_iterator itT = transformsTar.begin(); itT != transformsTar.end(); ++itT) - { - (*itT)->WriteToXML(tarNode); - } - - xmlNode* baseNode = AddChild(physicsRigidConstraintNode, DAE_TECHNIQUE_COMMON_ELEMENT); - AddChild(baseNode, DAE_ENABLED_ELEMENT, enabled); - AddChild(baseNode, DAE_INTERPENETRATE_ELEMENT, interpenetrate); - xmlNode* limitsNode = AddChild(baseNode, DAE_LIMITS_ELEMENT); - - xmlNode* linearNode = AddChild(limitsNode, DAE_LINEAR_ELEMENT); - string s = FUStringConversion::ToString(limitsLinearMin); - AddChild(linearNode, DAE_MIN_ELEMENT, s); - s = FUStringConversion::ToString(limitsLinearMax); - AddChild(linearNode, DAE_MAX_ELEMENT, s); - - xmlNode* sctNode = AddChild(limitsNode, DAE_SWING_CONE_AND_TWIST_ELEMENT); - s = FUStringConversion::ToString(limitsSCTMin); - AddChild(sctNode, DAE_MIN_ELEMENT, s); - s = FUStringConversion::ToString(limitsSCTMax); - AddChild(sctNode, DAE_MAX_ELEMENT, s); - - xmlNode* springNode = AddChild(baseNode, DAE_SPRING_ELEMENT); - xmlNode* sLinearNode = AddChild(springNode, DAE_LINEAR_ELEMENT); - AddChild(sLinearNode, DAE_STIFFNESS_ELEMENT, springLinearStiffness); - AddChild(sLinearNode, DAE_DAMPING_ELEMENT, springLinearDamping); - AddChild(sLinearNode, DAE_TARGET_VALUE_ELEMENT, springLinearTargetValue); - - xmlNode* sAngularNode = AddChild(springNode, DAE_ANGULAR_ELEMENT); - AddChild(sAngularNode, DAE_STIFFNESS_ELEMENT, springAngularStiffness); - AddChild(sAngularNode, DAE_DAMPING_ELEMENT, springAngularDamping); - AddChild(sAngularNode, DAE_TARGET_VALUE_ELEMENT, springAngularTargetValue); - - //FIXME: what about and ? - FCDEntity::WriteToExtraXML(physicsRigidConstraintNode); - return physicsRigidConstraintNode; -} diff --git a/Extras/FCollada/FCDocument/FCDPhysicsRigidConstraint.h b/Extras/FCollada/FCDocument/FCDPhysicsRigidConstraint.h deleted file mode 100644 index dce2b5eb2..000000000 --- a/Extras/FCollada/FCDocument/FCDPhysicsRigidConstraint.h +++ /dev/null @@ -1,85 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _FCD_PHYSICS_RIGID_CONSTRAINT_H_ -#define _FCD_PHYSICS_RIGID_CONSTRAINT_H_ - -#include "FCDocument/FCDEntity.h" -#include "FCDocument/FCDEntityInstance.h" -#include "FCDocument/FCDTransform.h" -#include "FUtils/FUDaeEnum.h" - -class FCDocument; -class FCDPhysicsModel; -class FCDPhysicsRigidBody; -typedef vector FCDTransformList; - - -class FCOLLADA_EXPORT FCDPhysicsRigidConstraint : public FCDEntity -{ -private: - string sid; - bool enabled; - bool interpenetrate; - FCDPhysicsRigidBody* referenceRigidBody; - FCDPhysicsRigidBody* targetRigidBody; - FMVector3 limitsLinearMin; - FMVector3 limitsLinearMax; - FMVector3 limitsSCTMin; - FMVector3 limitsSCTMax; - - FCDPhysicsModel* parent; - - float springLinearStiffness; - float springLinearDamping; - float springLinearTargetValue; - - float springAngularStiffness; - float springAngularDamping; - float springAngularTargetValue; - - FCDTransformList transformsRef; - FCDTransformList transformsTar; - -public: - FCDPhysicsRigidConstraint(FCDocument* document, FCDPhysicsModel* _parent); - virtual ~FCDPhysicsRigidConstraint(); - - string GetSid() const { return sid; } - // Returns the entity type - virtual Type GetType() const { return PHYSICS_RIGID_CONSTRAINT; } - - const bool& GetEnabled() const { return enabled;} - const bool& GetInterpenetrate() const { return interpenetrate;} - - FCDPhysicsRigidBody* GetReferenceRigidBody() const { return referenceRigidBody;} - FCDPhysicsRigidBody* GetTargetRigidBody() const { return targetRigidBody;} - - const FCDTransformList& GetTransformsRef() const { return transformsRef; } - const FCDTransformList& GetTransformsTar() const { return transformsTar; } - - FMVector3 GetLimitsLinearMin() const { return limitsLinearMin;} - FMVector3 GetLimitsLinearMax() const { return limitsLinearMax;} - FMVector3 GetLimitsSCTMin() const { return limitsSCTMin;} - FMVector3 GetLimitsSCTMax() const { return limitsSCTMax;} - - float GetSpringLinearStiffness() const { return springLinearStiffness;} - float GetSpringLinearDamping() const { return springLinearDamping;} - float GetSpringLinearTargetValue() const { return springLinearTargetValue;} - float GetSpringAngularStiffness() const { return springAngularStiffness;} - float GetSpringAngularDamping() const { return springAngularDamping;} - float GetSpringAngularTargetValue() const { return springAngularTargetValue;} - - // Create a copy of this physicsmodel, with the vertices overwritten - FCDPhysicsRigidConstraint* Clone(); - - // Read in the node of the COLLADA document - virtual FUStatus LoadFromXML(xmlNode* node); - - // Write out the node to the COLLADA xml tree - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -#endif // _FCD_PHYSICS_RIGID_CONSTRAINT_H_ diff --git a/Extras/FCollada/FCDocument/FCDPhysicsRigidConstraintInstance.cpp b/Extras/FCollada/FCDocument/FCDPhysicsRigidConstraintInstance.cpp deleted file mode 100644 index 91c2c9eac..000000000 --- a/Extras/FCollada/FCDocument/FCDPhysicsRigidConstraintInstance.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDEntity.h" -#include "FCDocument/FCDPhysicsModel.h" -#include "FCDocument/FCDPhysicsModelInstance.h" -#include "FCDocument/FCDPhysicsRigidConstraint.h" -#include "FCDocument/FCDPhysicsRigidConstraintInstance.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDPhysicsRigidConstraintInstance::FCDPhysicsRigidConstraintInstance(FCDocument* document, FCDEntity* _parent) : FCDEntityInstance(document, NULL) -{ - if (_parent->GetType() == FCDEntity::PHYSICS_MODEL) - parent = (FCDPhysicsModel*)_parent; - - rigidConstraint = NULL; - SetClassName("FCDPhysicsRigidConstraintInstance"); -} - -FCDPhysicsRigidConstraintInstance::~FCDPhysicsRigidConstraintInstance() -{ - parent = NULL; - rigidConstraint = NULL; -} - - -// Load the geometry instance from the COLLADA document -FUStatus FCDPhysicsRigidConstraintInstance::LoadFromXML(xmlNode* instanceNode) -{ - FUStatus status = FCDEntityInstance::LoadFromXML(instanceNode); - if (!status) return status; - - // Check for the expected instantiation node type - if (!IsEquivalent(instanceNode->name, DAE_INSTANCE_RIGID_CONSTRAINT_ELEMENT)) - { - return status.Fail(FS("Unknown element for instantiation of entity: ") + TO_FSTRING(entity->GetDaeId()), instanceNode->line); - } - if (parent == NULL) - { - return status.Fail(FS("No Physics Model parent for rigid constraint instantiation"), instanceNode->line); - } - - string physicsRigidConstraintSid = ReadNodeProperty(instanceNode, DAE_CONSTRAINT_ATTRIBUTE); - entity = rigidConstraint = parent->FindRigidConstraintFromSid(physicsRigidConstraintSid); - if(!rigidConstraint) - { - return status.Fail(FS("Couldn't find rigid constraint for instantiation"), instanceNode->line); - } - - return status; -} - - -// Write out the instantiation information to the xml node tree -xmlNode* FCDPhysicsRigidConstraintInstance::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* instanceNode = FCDEntityInstance::WriteToXML(parentNode); - - //TODO - - return instanceNode; -} diff --git a/Extras/FCollada/FCDocument/FCDPhysicsRigidConstraintInstance.h b/Extras/FCollada/FCDocument/FCDPhysicsRigidConstraintInstance.h deleted file mode 100644 index 084fb1f85..000000000 --- a/Extras/FCollada/FCDocument/FCDPhysicsRigidConstraintInstance.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _FCD_PHYSICS_RIGID_CONSTRAINT_INSTANCE_H_ -#define _FCD_PHYSICS_RIGID_CONSTRAINT_INSTANCE_H_ - -#include "FCDocument/FCDEntityInstance.h" - -class FCDocument; -class FCDSceneNode; -class FCDPhysicsModel; -class FCDPhysicsRigidConstraint; - - -class FCOLLADA_EXPORT FCDPhysicsRigidConstraintInstance : public FCDEntityInstance -{ - -private: - - FCDPhysicsModel* parent; - FCDPhysicsRigidConstraint* rigidConstraint; - -public: - FCDPhysicsRigidConstraintInstance(FCDocument* document, FCDEntity* _parent); - virtual ~FCDPhysicsRigidConstraintInstance(); - - // FCDEntity override for RTTI-like - virtual Type GetType() const { return PHYSICS_RIGID_CONSTRAINT; } - - // Load the geometry instance from the COLLADA document - virtual FUStatus LoadFromXML(xmlNode* instanceNode); - - // Write out the instantiation information to the xml node tree - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -#endif // _FCD_PHYSICS_RIGID_CONSTRAINT_INSTANCE_H_ diff --git a/Extras/FCollada/FCDocument/FCDPhysicsSceneNode.cpp b/Extras/FCollada/FCDocument/FCDPhysicsSceneNode.cpp deleted file mode 100644 index 3de8b7151..000000000 --- a/Extras/FCollada/FCDocument/FCDPhysicsSceneNode.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDPhysicsSceneNode.h" -#include "FCDocument/FCDPhysicsModelInstance.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -#include "FUtils/FUFileManager.h" -#include "FUtils/FUStringConversion.h" -#include "FCDocument/FCDExtra.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDPhysicsSceneNode::FCDPhysicsSceneNode(FCDocument* document) : FCDEntity(document, "PhysicsSceneNode") -{ - //FIXME: no default values are specified in the 1.4 spec! - gravity.x = 0.f; gravity.y = 0.f; gravity.z = -9.8f; - timestep = 1.f; -} - -FCDPhysicsSceneNode::~FCDPhysicsSceneNode() -{ - CLEAR_POINTER_VECTOR(instances); -} - -// Parse a or a node from a COLLADA document -FUStatus FCDPhysicsSceneNode::LoadFromXML(xmlNode* sceneNode) -{ - FUStatus status = FCDEntity::LoadFromXML(sceneNode); - if (!status) return status; - - if(IsEquivalent(sceneNode->name, DAE_PHYSICS_SCENE_ELEMENT)) - { - for (xmlNode* child = sceneNode->children; child != NULL; child = child->next) - { - if (child->type != XML_ELEMENT_NODE) continue; - - // Look for instantiation elements - if (IsEquivalent(child->name, DAE_INSTANCE_PHYSICS_MODEL_ELEMENT)) - { - FUUri url = ReadNodeUrl(child); - if (url.prefix.empty()) - { - FCDPhysicsModel* entity = GetDocument()->FindPhysicsModel(url.suffix); - if (entity != NULL) - { - FCDPhysicsModelInstance* instance = new FCDPhysicsModelInstance(GetDocument(), (FCDEntity*)entity); - instances.push_back(instance); - status.AppendStatus(instance->LoadFromXML(child)); - continue; - } - } - status.Warning(FS("Unable to retrieve FCDPhysicsModel instance for scene node: ") + TO_FSTRING(GetDaeId()), child->line); - } - else if(IsEquivalent(child->name, DAE_TECHNIQUE_COMMON_ELEMENT)) - { - xmlNode* gravityNode = FindChildByType(child, DAE_GRAVITY_ATTRIBUTE); - if(gravityNode) - { - const char* gravityVal = ReadNodeContentDirect(gravityNode); - gravity.x = FUStringConversion::ToFloat(&gravityVal); - gravity.y = FUStringConversion::ToFloat(&gravityVal); - gravity.z = FUStringConversion::ToFloat(&gravityVal); - } - xmlNode* timestepNode = FindChildByType(child, DAE_TIME_STEP_ATTRIBUTE); - if(timestepNode) - { - timestep = FUStringConversion::ToFloat(ReadNodeContentDirect(timestepNode)); - } - } - else if (IsEquivalent(child->name, DAE_EXTRA_ELEMENT)) - { - // The extra information is loaded by the FCDEntity class. - } - } - } - - return status; -} - -// Write out a element to a COLLADA xml document -xmlNode* FCDPhysicsSceneNode::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* physicsSceneNode = WriteToEntityXML(parentNode, DAE_PHYSICS_SCENE_ELEMENT); - if (physicsSceneNode == NULL) return physicsSceneNode; - WriteToNodeXML(physicsSceneNode); - return physicsSceneNode; -} - -// Write out a element to a COLLADA xml document -void FCDPhysicsSceneNode::WriteToNodeXML(xmlNode* node) const -{ - // Write out the instantiation - for (FCDPhysicsModelInstanceList::const_iterator itI = instances.begin(); itI != instances.end(); ++itI) - { - FCDEntityInstance* instance = (*itI); - instance->WriteToXML(node); - } - - // Write out the extra information - FCDEntity::WriteToExtraXML(node); -} diff --git a/Extras/FCollada/FCDocument/FCDPhysicsSceneNode.h b/Extras/FCollada/FCDocument/FCDPhysicsSceneNode.h deleted file mode 100644 index ac1c859bd..000000000 --- a/Extras/FCollada/FCDocument/FCDPhysicsSceneNode.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _FCD_PHYSICS_SCENE_NODE_ -#define _FCD_PHYSICS_SCENE_NODE_ - -#include "FCDocument/FCDEntity.h" - -class FCDocument; -class FCDEntityInstance; -class FCDExtra; - -class FCDPhysicsModelInstance; - -typedef vector FCDPhysicsModelInstanceList; - -class FCOLLADA_EXPORT FCDPhysicsSceneNode : public FCDEntity -{ -private: - FCDExtra* extra; - FMVector3 gravity; - float timestep; - FCDPhysicsModelInstanceList instances; - -public: - FCDPhysicsSceneNode(FCDocument* document); - virtual ~FCDPhysicsSceneNode(); - - // Returns the entity type - virtual Type GetType() const { return PHYSICS_SCENE_NODE; } - - FCDPhysicsModelInstanceList& GetInstances() { return instances; } - const FCDPhysicsModelInstanceList& GetInstances() const { return instances; } - size_t GetNumInstances() const { return instances.size(); }; - - // Visibility parameter - const FMVector3& GetGravity() const { return gravity; } - const float& GetTimestep() const { return timestep; } - - // Parse a node from a COLLADA document - virtual FUStatus LoadFromXML(xmlNode* sceneNode); - - // Write out a element to a COLLADA xml document - void WriteToNodeXML(xmlNode* node) const; - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; - - // Instantiating a scene node means ensuring that there is no cycles in the scene graph - void Instantiate(FCDPhysicsSceneNode* sceneNode); -}; - -#endif // _FCD_SCENE_NODE_ diff --git a/Extras/FCollada/FCDocument/FCDPhysicsShape.cpp b/Extras/FCollada/FCDocument/FCDPhysicsShape.cpp deleted file mode 100644 index 9b55c592c..000000000 --- a/Extras/FCollada/FCDocument/FCDPhysicsShape.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDPhysicsShape.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDTransform.h" -#include "FCDocument/FCDGeometryInstance.h" -#include "FCDocument/FCDPhysicsRigidBody.h" -#include "FCDocument/FCDPhysicsMaterial.h" -#include "FCDocument/FCDPhysicsAnalyticalGeometry.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDPhysicsShape::FCDPhysicsShape(FCDocument* document) : FCDEntity(document, "PhysicsShape") -{ - hollow= true; - physicsMaterial = NULL; - ownsPhysicsMaterial = true; - ownsGeometryInstance = true; - geometry = NULL; - analGeom = NULL; - mass = 1.0f; //FIXME: should be derived from density x shape volume - density = 1.0f; -} - -FCDPhysicsShape::~FCDPhysicsShape() -{ - if(ownsPhysicsMaterial) - { - SAFE_DELETE(physicsMaterial); - } - else - { - physicsMaterial = NULL; - } - - if(ownsGeometryInstance) - { - SAFE_DELETE(geometry); - } - else - { - geometry = NULL; - } - - SAFE_DELETE(analGeom); - CLEAR_POINTER_VECTOR(transforms); -} - -// Create a copy of this shape -// Note: geometries are just shallow-copied -FCDPhysicsShape* FCDPhysicsShape::Clone() -{ - FCDPhysicsShape* clone = new FCDPhysicsShape(GetDocument()); - FCDEntity::Clone(clone); - clone->SetMass(mass); - clone->SetDensity(density); - if(analGeom) - clone->SetAnalyticalGeometry(analGeom->Clone()); - else - clone->SetAnalyticalGeometry(NULL); - clone->SetGeometryInstance(geometry); //FIXME: should do Clone?! - clone->SetGeometryInstanceOwnership(false); - if(physicsMaterial) - clone->SetPhysicsMaterial(physicsMaterial->Clone()); - else - clone->SetPhysicsMaterial(NULL); - clone->SetOwnsPhysicsMaterial(true); - clone->SetHollow(hollow); - for(size_t i = 0; i < transforms.size(); ++i) - { - clone->AddTransform(transforms[i]->Clone(NULL)); - } - - return clone; -} - - -// Load from a XML node the given physicsShape -FUStatus FCDPhysicsShape::LoadFromXML(xmlNode* physicsShapeNode) -{ - FUStatus status; - if (!IsEquivalent(physicsShapeNode->name, DAE_SHAPE_ELEMENT)) - { - return status.Warning(FS("PhysicsShape library contains unknown element."), physicsShapeNode->line); - } - - // Read in the first valid child element found - for (xmlNode* child = physicsShapeNode->children; child != NULL; child = child->next) - { - if (child->type != XML_ELEMENT_NODE) continue; - - if(IsEquivalent(child->name, DAE_HOLLOW_ELEMENT)) - { - hollow = FUStringConversion::ToBoolean(ReadNodeContentDirect(child)); - } - else if(IsEquivalent(child->name, DAE_MASS_ELEMENT)) - { - mass = FUStringConversion::ToFloat(ReadNodeContentDirect(child)); - } - else if(IsEquivalent(child->name, DAE_DENSITY_ELEMENT)) - { - density = FUStringConversion::ToFloat(ReadNodeContentDirect(child)); - } - else if(IsEquivalent(child->name, DAE_PHYSICS_MATERIAL_ELEMENT)) - { - if(!HasNodeProperty(child, DAE_URL_ATTRIBUTE)) - { - //inline definition of physics_material - physicsMaterial = new FCDPhysicsMaterial(GetDocument()); - physicsMaterial->LoadFromXML(child); - ownsPhysicsMaterial = true; - } - else - { - FUUri url = ReadNodeUrl(child); - if (url.prefix.empty()) - { - physicsMaterial = GetDocument()->FindPhysicsMaterial(url.suffix); - ownsPhysicsMaterial = false; - } - } - } - else if(IsEquivalent(child->name, DAE_INSTANCE_GEOMETRY_ELEMENT)) - { - FUUri url = ReadNodeUrl(child); - if (url.prefix.empty()) - { - FCDGeometry* entity = GetDocument()->FindGeometry(url.suffix); - if (entity != NULL) - { - geometry = new FCDGeometryInstance(GetDocument(), (FCDEntity*)entity); - if(analGeom) SAFE_DELETE(analGeom); - status.AppendStatus(geometry->LoadFromXML(child)); - continue; - } - } - status.Warning(FS("Unable to retrieve FCDGeometry instance for scene node: ") + TO_FSTRING(GetDaeId()), child->line); - } - -#define PARSE_ANALYTICAL_SHAPE(className, nodeName) \ - else if (IsEquivalent(child->name, nodeName)) { \ - if(analGeom) SAFE_DELETE(analGeom); \ - analGeom = new className(GetDocument()); \ - if(geometry) SAFE_DELETE(geometry); \ - status = analGeom->LoadFromXML(child);}\ - if (!status) { status.Warning(fstring(FC("Invalid <") FC(nodeName) FC("> shape in node: ")) + TO_FSTRING(GetDaeId()), child->line); break; } - - PARSE_ANALYTICAL_SHAPE(FCDPASBox, DAE_BOX_ELEMENT) - PARSE_ANALYTICAL_SHAPE(FCDPASPlane, DAE_PLANE_ELEMENT) - PARSE_ANALYTICAL_SHAPE(FCDPASSphere, DAE_SPHERE_ELEMENT) - PARSE_ANALYTICAL_SHAPE(FCDPASCylinder, DAE_CYLINDER_ELEMENT) - PARSE_ANALYTICAL_SHAPE(FCDPASCapsule, DAE_CAPSULE_ELEMENT) - PARSE_ANALYTICAL_SHAPE(FCDPASTaperedCapsule, DAE_TAPERED_CAPSULE_ELEMENT) - PARSE_ANALYTICAL_SHAPE(FCDPASTaperedCylinder, DAE_TAPERED_CYLINDER_ELEMENT) -#undef PARSE_ANALYTICAL_SHAPE - - - // Parse the physics shape transforms , , are supported. - else if(IsEquivalent(child->name, DAE_ASSET_ELEMENT)) {} - else if(IsEquivalent(child->name, DAE_EXTRA_ELEMENT)) {} - else - { - FCDTransform* transform = FCDTFactory::CreateTransform(GetDocument(), NULL, child); - if (transform) - { - 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)); - } - } - } - } - - return status; -} - -// Write out the node -xmlNode* FCDPhysicsShape::WriteToXML(xmlNode* UNUSED(parentNode)) const -{ - xmlNode* physicsShapeNode = NULL; - - //TODO: - - return physicsShapeNode; -} diff --git a/Extras/FCollada/FCDocument/FCDPhysicsShape.h b/Extras/FCollada/FCDocument/FCDPhysicsShape.h deleted file mode 100644 index 119bbf683..000000000 --- a/Extras/FCollada/FCDocument/FCDPhysicsShape.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _FCD_PHYSICS_SHAPE_H_ -#define _FCD_PHYSICS_SHAPE_H_ - -#include "FCDocument/FCDEntity.h" -#include "FCDocument/FCDEntityInstance.h" -#include "FUtils/FUDaeEnum.h" - -class FCDocument; -class FCDPhysicsRigidBody; -class FCDPhysicsRigidConstraint; -class FCDGeometryInstance; -class FCDPhysicsAnalyticalGeometry; -class FCDTransform; - -typedef vector FCDTransformList; -typedef vector FCDPhysicsRigidBodyList; - -class FCOLLADA_EXPORT FCDPhysicsShape : public FCDEntity -{ -private: - bool hollow; - FCDPhysicsMaterial* physicsMaterial; - bool ownsPhysicsMaterial; - - //one of these two will define the rigid body - FCDGeometryInstance* geometry; - FCDPhysicsAnalyticalGeometry* analGeom; //pun not intended - - bool ownsGeometryInstance; - - float mass; - float density; - FCDTransformList transforms; - - -public: - FCDPhysicsShape(FCDocument* document); - virtual ~FCDPhysicsShape(); - - // Returns the entity type - virtual Type GetType() const { return PHYSICS_SHAPE; } - - const float& GetMass() const {return mass;} - void SetMass(float _mass) {mass = _mass;} - const float& GetDensity() const {return density;} - void SetDensity(float _density) {density = _density;} - FCDPhysicsAnalyticalGeometry* GetAnalyticalGeometry() const {return analGeom;} - void SetAnalyticalGeometry(FCDPhysicsAnalyticalGeometry* _analGeom) {analGeom = _analGeom;} - FCDGeometryInstance* GetGeometryInstance() const {return geometry;} - void SetGeometryInstance(FCDGeometryInstance* _geometry) {geometry = _geometry;} - void SetGeometryInstanceOwnership(bool val) {ownsGeometryInstance = val;} - FCDPhysicsMaterial* GetPhysicsMaterial() const {return physicsMaterial;} - void SetPhysicsMaterial(FCDPhysicsMaterial* _physicsMaterial) {physicsMaterial = _physicsMaterial;} - bool ownsItsPhysicsMaterial() const {return ownsPhysicsMaterial;} - void SetOwnsPhysicsMaterial(bool _ownsPhysicsMaterial) {ownsPhysicsMaterial = _ownsPhysicsMaterial;} - bool isHollow() const {return hollow;} - void SetHollow(bool _hollow) {hollow = _hollow;} - const FCDTransformList& GetTransforms() const {return transforms;} - void AddTransform(FCDTransform* t) {transforms.push_back(t);} - - // Create a copy of this shape - FCDPhysicsShape* Clone(); - - // Read in the node of the COLLADA document - virtual FUStatus LoadFromXML(xmlNode* node); - - // Write out the node to the COLLADA xml tree - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -#endif // _FCD_PHYSICS_SHAPE_H_ diff --git a/Extras/FCollada/FCDocument/FCDSceneNode.cpp b/Extras/FCollada/FCDocument/FCDSceneNode.cpp deleted file mode 100644 index 9b43ae571..000000000 --- a/Extras/FCollada/FCDocument/FCDSceneNode.cpp +++ /dev/null @@ -1,491 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDAnimated.h" -#include "FCDocument/FCDAnimationCurve.h" -#include "FCDocument/FCDCamera.h" -#include "FCDocument/FCDController.h" -#include "FCDocument/FCDEntityInstance.h" -#include "FCDocument/FCDExternalReference.h" -#include "FCDocument/FCDExtra.h" -#include "FCDocument/FCDGeometry.h" -#include "FCDocument/FCDGeometryInstance.h" -#include "FCDocument/FCDLight.h" -#include "FCDocument/FCDPhysicsModelInstance.h" -#include "FCDocument/FCDPhysicsRigidBodyInstance.h" -#include "FCDocument/FCDSceneNode.h" -#include "FCDocument/FCDTransform.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -#include "FUtils/FUFileManager.h" -#include "FUtils/FUStringConversion.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDSceneNode::FCDSceneNode(FCDocument* document) : FCDEntity(document, "VisualSceneNode") -{ - isJoint = false; - targetCount = 0; - visibility = 1.0f; -} - -FCDSceneNode::~FCDSceneNode() -{ - CLEAR_POINTER_VECTOR(instances); - CLEAR_POINTER_VECTOR(transforms); - parents.clear(); - - // Delete the children, be watchful for the instantiated node - for (FCDSceneNodeList::iterator it = children.begin(); it != children.end(); ++it) - { - FCDSceneNode* child = (*it); - for (FCDSceneNodeList::iterator itParent = child->parents.begin(); itParent != child->parents.end(); ++itParent) - { - if ((*itParent) == this) - { - child->parents.erase(itParent); - break; - } - } - - if (child->parents.empty()) delete child; - } - children.clear(); -} - -// Add this scene node to the list of children scene node -bool FCDSceneNode::AddChildNode(FCDSceneNode* sceneNode) -{ - if (this == sceneNode || sceneNode == NULL) - { - return false; - } - - // Verify that we don't already contain this child node. - FCDSceneNodeList::iterator it = std::find(children.begin(), children.end(), sceneNode); - if (it != children.end()) return false; - - // Verify that this node is not one of the parents in the full hierarchically. - FCDSceneNodeList queue = parents; - while (!queue.empty()) - { - FCDSceneNode* parent = queue.back(); - queue.pop_back(); - if (parent == sceneNode) return false; - queue.insert(queue.end(), parent->parents.begin(), parent->parents.end()); - } - - children.push_back(sceneNode); - sceneNode->parents.push_back(this); - return true; -} - -FCDSceneNode* FCDSceneNode::AddChildNode() -{ - FCDSceneNode* node = new FCDSceneNode(GetDocument()); - AddChildNode(node); - return node; -} - -FCDTransform* FCDSceneNode::AddTransform(FCDTransform::Type type, size_t index) -{ - FCDTransform* transform = FCDTFactory::CreateTransform(GetDocument(), this, type); - if (transform != NULL) - { - if (index > transforms.size()) transforms.push_back(transform); - else transforms.insert(transforms.begin() + index, transform); - } - return transform; -} - -// Traverse the scene graph, searching for a node with the given COLLADA id -FCDEntity* FCDSceneNode::FindDaeId(const string& daeId) -{ - if (GetDaeId() == daeId) return this; - - for (FCDSceneNodeList::iterator it = children.begin(); it != children.end(); ++it) - { - FCDEntity* found = (*it)->FindDaeId(daeId); - if (found != NULL) return found; - } - return NULL; -} - -// Calculate the transform matrix for a given scene node -FMMatrix44 FCDSceneNode::ToMatrix() const -{ - FMMatrix44 localTransform = FMMatrix44::Identity; - for (FCDTransformList::const_iterator it = transforms.begin(); it != transforms.end(); ++it) - { - localTransform = localTransform * (*it)->ToMatrix(); - } - return localTransform; -} - -void FCDSceneNode::GenerateSampledMatrixAnimation(FloatList& sampleKeys, FMMatrix44List& sampleValues) -{ - FCDAnimatedList animateds; - - // Collect all the animation curves - for (FCDTransformList::iterator it = transforms.begin(); it != transforms.end(); ++it) - { - FCDAnimated* animated = (*it)->GetAnimated(); - if (animated != NULL && animated->HasCurve()) animateds.push_back(animated); - } - if (animateds.empty()) return; - - // Make a list of the ordered key times to sample - for (FCDAnimatedList::iterator it = animateds.begin(); it != animateds.end(); ++it) - { - const FCDAnimationCurveList& curves = (*it)->GetCurves(); - for (FCDAnimationCurveList::const_iterator curveIt = curves.begin(); curveIt != curves.end(); ++curveIt) - { - if ((*curveIt) == NULL) continue; - - const FloatList& curveKeys = (*curveIt)->GetKeys(); - size_t sampleKeyCount = sampleKeys.size(); - size_t curveKeyCount = curveKeys.size(); - - // Merge this curve's keys in with the sample keys - // This assumes both key lists are in increasing order - size_t s = 0, c = 0; - while (s < sampleKeyCount && c < curveKeyCount) - { - float sampleKey = sampleKeys[s], curveKey = curveKeys[c]; - if (IsEquivalent(sampleKey, curveKey)) { ++s; ++c; } - else if (sampleKey < curveKey) { ++s; } - else - { - // Add this curve key to the sampling key list - sampleKeys.insert(sampleKeys.begin() + (s++), curveKeys[c++]); - sampleKeyCount++; - } - } - - // Add all the left-over curve keys to the sampling key list - if (c < curveKeyCount) sampleKeys.insert(sampleKeys.end(), curveKeys.begin() + c, curveKeys.end()); - } - } - size_t sampleKeyCount = sampleKeys.size(); - if (sampleKeyCount == 0) return; - - // Pre-allocate the value array; - sampleValues.reserve(sampleKeyCount); - - // Sample the scene node transform - for (size_t i = 0; i < sampleKeyCount; ++i) - { - float sampleTime = sampleKeys[i]; - for (FCDAnimatedList::iterator it = animateds.begin(); it != animateds.end(); ++it) - { - // Sample each animated, which changes the transform values directly - (*it)->Evaluate(sampleTime); - } - - // Retrieve the new transform matrix for the COLLADA scene node - sampleValues.push_back(ToMatrix()); - } -} - -// Parse a or a node from a COLLADA document -FUStatus FCDSceneNode::LoadFromXML(xmlNode* sceneNode) -{ - FUStatus status = FCDEntity::LoadFromXML(sceneNode); - if (!status) return status; - if (!IsEquivalent(sceneNode->name, DAE_VSCENE_ELEMENT) && !IsEquivalent(sceneNode->name, DAE_NODE_ELEMENT) - && !IsEquivalent(sceneNode->name, DAE_SCENE_ELEMENT)) - { - // The element is accepted here only as COLLADA 1.3 backward compatibility - return status.Fail(FS("Unknown scene node element with id: ") + TO_FSTRING(GetDaeId()), sceneNode->line); - } - - // look up the visual scene to extrace bind info - if (IsEquivalent(sceneNode->name, DAE_VSCENE_ELEMENT)) BindMaterial(sceneNode); - - // Read in the element's type - string nodeType = ReadNodeProperty(sceneNode, DAE_TYPE_ATTRIBUTE); - if (nodeType == DAE_JOINT_NODE_TYPE) SetJointFlag(true); - else if (nodeType.length() == 0 || nodeType == DAE_NODE_NODE_TYPE) {} // No special consideration - else - { - status.Warning(FS("Unknown node type for scene's element: ") + TO_FSTRING(GetDaeId()), sceneNode->line); - } - - // The scene node has ordered elements, so process them directly and in order. - for (xmlNode* child = sceneNode->children; child != NULL; child = child->next) - { - if (child->type != XML_ELEMENT_NODE) continue; - - if (IsEquivalent(child->name, DAE_NODE_ELEMENT)) - { - // Load the child scene node - FCDSceneNode* node = AddChildNode(); - status = node->LoadFromXML(child); - if (!status) break; - } - - // Look for instantiation elements -# define INSTANTIATE(name, instanceType) { \ - FUUri url = ReadNodeUrl(child); \ - if (url.prefix.empty()) { \ - FCD##name* entity = GetDocument()->Find##name(url.suffix); \ - if (entity != NULL) { \ - instanceType* instance = new instanceType(GetDocument(), entity); \ - instances.push_back(instance); \ - status.AppendStatus(instance->LoadFromXML(child)); \ - continue; } } \ - status.Warning(fstring(FC("Unable to retrieve '") FC(#name) FC("' instance for scene node: ")) + TO_FSTRING(GetDaeId()), child->line); } - - else if (IsEquivalent(child->name, DAE_INSTANCE_CAMERA_ELEMENT)) { INSTANTIATE(Camera, FCDEntityInstance); } - else if (IsEquivalent(child->name, DAE_INSTANCE_CONTROLLER_ELEMENT)) { INSTANTIATE(Controller, FCDGeometryInstance); } - else if (IsEquivalent(child->name, DAE_INSTANCE_GEOMETRY_ELEMENT)) { INSTANTIATE(Geometry, FCDGeometryInstance); } - else if (IsEquivalent(child->name, DAE_INSTANCE_LIGHT_ELEMENT)) { INSTANTIATE(Light, FCDEntityInstance); } - else if (IsEquivalent(child->name, DAE_INSTANCE_NODE_ELEMENT)) - { - FUUri url = ReadNodeUrl(child); - if (url.prefix.empty()) - { - FCDSceneNode* node = GetDocument()->FindSceneNode(url.suffix); - if (node != NULL) - { - if (!AddChildNode(node)) - { - status.Warning(FS("A cycle was found in the visual scene at node: ") + TO_FSTRING(GetDaeId()), child->line); - } - } - else - { - status.Warning(FS("Unable to retrieve node instance for scene node: ") + TO_FSTRING(GetDaeId()), child->line); - } - } - } -# undef INSTANTIATE - - else if (IsEquivalent(child->name, DAE_INSTANCE_ELEMENT)) - { - // COLLADA 1.3 backward compatibility: Weakly-typed instantiation - // Might be a geometry, controller, camera or light. - - FUUri url = ReadNodeUrl(child); - if (url.prefix.empty()) - { -# define INSTANTIATE(name, instanceType) { \ - FCD##name* entity = GetDocument()->Find##name(url.suffix); \ - if (entity != NULL) { \ - instanceType* instance = new instanceType(GetDocument(), entity); \ - instances.push_back(instance); \ - instance->LoadFromXML(child); \ - continue; } } - - INSTANTIATE(Geometry, FCDGeometryInstance); - INSTANTIATE(Controller, FCDGeometryInstance); - INSTANTIATE(Camera, FCDEntityInstance); - INSTANTIATE(Light, FCDEntityInstance); -# undef INSTANTIATE - - FCDSceneNode* node = GetDocument()->FindSceneNode(url.suffix); - if (node != NULL) - { - if (!AddChildNode(node)) - { - status.Warning(FS("A cycle was found in the visual scene at node: ") + TO_FSTRING(GetDaeId()), child->line); - } - } - else - { - status.Warning(FS("Unable to retrieve node instance for scene node: ") + TO_FSTRING(GetDaeId()), child->line); - } - - status.Warning(FS("Unable to retrieve weakly-typed instance for scene node: ") + TO_FSTRING(GetDaeId()), child->line); - } - else - { - GetDocument()->GetFileManager()->GetFilePath(url.prefix); - instances.push_back(new FCDExternalReference(GetDocument(), url)); - } - } - else if (IsEquivalent(child->name, DAE_EXTRA_ELEMENT)) {} - else if (IsEquivalent(child->name, DAE_ASSET_ELEMENT)) {} - else - { - FCDTransform* transform = FCDTFactory::CreateTransform(GetDocument(), this, child); - if (transform != NULL) - { - transforms.push_back(transform); - status.AppendStatus(transform->LoadFromXML(child)); - } - else - { - status.Warning(FS("Unknown element or bad transform in scene node: ") + TO_FSTRING(GetDaeId()), child->line); - } - } - } - - status.AppendStatus(LoadFromExtra()); - return status; -} - -FUStatus FCDSceneNode::LoadFromExtra() -{ - FUStatus status; - - FCDENodeList parameterNodes; - StringList parameterNames; - - // Retrieve the extra information from the base entity class - FCDExtra* extra = GetExtra(); - - // Read the Maya-specific technique - FCDETechnique* mayaTechnique = extra->FindTechnique(DAEMAYA_MAYA_PROFILE); - if (mayaTechnique == NULL) return status; - - mayaTechnique->FindParameters(parameterNodes, parameterNames); - size_t parameterCount = parameterNodes.size(); - for (size_t i = 0; i < parameterCount; ++i) - { - FCDENode* parameterNode = parameterNodes[i]; - const string& parameterName = parameterNames[i]; - FCDEAttribute* parameterType = parameterNode->FindAttribute(DAE_TYPE_ATTRIBUTE); - if (parameterName == DAEMAYA_STARTTIME_PARAMETER || parameterName == DAEMAYA_STARTTIME_PARAMETER1_3) - { - GetDocument()->SetStartTime(FUStringConversion::ToFloat(parameterNode->GetContent())); - parameterNode->Release(); - } - else if (parameterName == DAEMAYA_ENDTIME_PARAMETER || parameterName == DAEMAYA_ENDTIME_PARAMETER1_3) - { - GetDocument()->SetEndTime(FUStringConversion::ToFloat(parameterNode->GetContent())); - parameterNode->Release(); - } - else if (parameterName == DAEMAYA_VISIBILITY_PARAMETER || parameterName == DAEMAYA_VISIBILITY_PARAMETER1_3) - { - visibility = FUStringConversion::ToBoolean(parameterNode->GetContent()) ? 1.0f : 0.0f; - FCDAnimatedCustom* animated = parameterNode->GetAnimated(); - if (animated != NULL) - { - FCDAnimatedFloat::Clone(GetDocument(), &animated->GetDummy(), &visibility); - } - parameterNode->Release(); - } - else if (parameterName == DAEMAYA_LAYER_PARAMETER || (parameterType != NULL && FUStringConversion::ToString(parameterType->value) == DAEMAYA_LAYER_PARAMETER)) - { - FCDEAttribute* nameAttribute = parameterNode->FindAttribute(DAE_NAME_ATTRIBUTE); - if (nameAttribute == NULL) continue; - - // Create a new layer object list - FCDLayerList& layers = GetDocument()->GetLayers(); - FCDLayer* layer = new FCDLayer(); layers.push_back(layer); - - // Parse in the layer - layer->name = FUStringConversion::ToString(nameAttribute->value); - FUStringConversion::ToStringList(parameterNode->GetContent(), layer->objects); - parameterNode->Release(); - } - } - - return status; -} - -// bind material info -void FCDSceneNode::BindMaterial(xmlNode* node) -{ - xmlNodeList nodelist; - FindChildrenByType(node, DAE_NODE_ELEMENT, nodelist); - if(nodelist.size() == 0) return; - for(xmlNodeList::iterator itN = nodelist.begin(); itN != nodelist.end(); ++itN) - { - BindMaterial(*itN); - - xmlNode* geometry = FindChildByType(*itN, DAE_INSTANCE_GEOMETRY_ELEMENT); - if(geometry == NULL) continue; - - xmlNode* bindmatNode = FindChildByType(geometry, DAE_BINDMATERIAL_ELEMENT); - xmlNode* techniqueNode = FindChildByType(bindmatNode, DAE_TECHNIQUE_COMMON_ELEMENT); - xmlNode* materialNode = FindChildByType(techniqueNode, DAE_INSTANCE_MATERIAL_ELEMENT); - string shadername = ReadNodeProperty(materialNode, DAE_SYMBOL_ATTRIBUTE); - - xmlNodeList bindNodes; - FindChildrenByType( materialNode, DAE_BIND_ELEMENT, bindNodes); - for (xmlNodeList::iterator itB = bindNodes.begin(); itB != bindNodes.end(); ++itB) - { - string semantic = ReadNodeSemantic(*itB); - string target = ReadNodeProperty(*itB, DAE_TARGET_ATTRIBUTE); - - GetPostProcessCmds().push_back(shadername); - GetPostProcessCmds().push_back(target); - GetPostProcessCmds().push_back(semantic); - } - } -} - - -// Write out a element to a COLLADA xml document -xmlNode* FCDSceneNode::WriteToXML(xmlNode* parentNode) const -{ - xmlNode* visualSceneNode = WriteToEntityXML(parentNode, DAE_VSCENE_ELEMENT); - if (visualSceneNode != NULL) - { - WriteToNodeXML(visualSceneNode, true); - } - return visualSceneNode; -} - -// Write out a or a element to a COLLADA xml document -void FCDSceneNode::WriteToNodeXML(xmlNode* node, bool isVisualScene) const -{ - // Write out the extra attributes - if (!isVisualScene) - { - if (isJoint) - { - AddAttribute(node, DAE_SID_ATTRIBUTE, GetDaeId()); - AddAttribute(node, DAE_TYPE_ATTRIBUTE, DAE_JOINT_NODE_TYPE); - } - else - { - AddAttribute(node, DAE_TYPE_ATTRIBUTE, DAE_NODE_NODE_TYPE); - } - } - - // Write out the transforms - for (FCDTransformList::const_iterator itT = transforms.begin(); itT != transforms.end(); ++itT) - { - FCDTransform* transform = (*itT); - transform->WriteToXML(node); - } - - // Write out the instantiation - for (FCDEntityInstanceList::const_iterator itI = instances.begin(); itI != instances.end(); ++itI) - { - FCDEntityInstance* instance = (*itI); - instance->WriteToXML(node); - } - - // Write out the child scene graph nodes as elements - if (!isVisualScene || !children.empty()) - { - for (FCDSceneNodeList::const_iterator itC = children.begin(); itC != children.end(); ++itC) - { - FCDSceneNode* child = (*itC); - xmlNode* nodeNode = child->WriteToEntityXML(node, DAE_NODE_ELEMENT); - if (nodeNode != NULL) child->WriteToNodeXML(nodeNode, false); - } - } - else - { - // In COLLADA 1.4, the visual scene must contain at least one . - UNUSED(xmlNode* dummyNodeNode =) FUXmlWriter::AddChild(node, DAE_NODE_ELEMENT); - } - - // Write out the extra information - FCDEntity::WriteToExtraXML(node); -} diff --git a/Extras/FCollada/FCDocument/FCDSceneNode.h b/Extras/FCollada/FCDocument/FCDSceneNode.h deleted file mode 100644 index 2a7c8aea1..000000000 --- a/Extras/FCollada/FCDocument/FCDSceneNode.h +++ /dev/null @@ -1,240 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDSceneNode.h - This file contains the FCDSceneNode class. -*/ - -#ifndef _FCD_SCENE_NODE_ -#define _FCD_SCENE_NODE_ - -#include "FCDocument/FCDEntity.h" -#include "FCDocument/FCDTransform.h" /** @todo Remove this include by moving the FCDTransform::Type enum to FUDaeEnum.h. */ - -class FCDocument; -class FCDEntityInstance; -class FCDSceneNode; -class FCDTransform; -class FCDExtra; -class FCDTRotation; -class FCDTTranslation; -class FCDTScale; -class FCDTSkew; -class FCDTLookAt; -class FCDTMatrix; - -typedef vector FCDSceneNodeList; /**< A dynamically-sized array of scene nodes. */ -typedef vector FCDEntityInstanceList; /**< A dynamically-sized array of entitiy instances. */ -typedef vector FCDTransformList; /**< A dynamically-sized array of transforms. */ - -/** - A COLLADA visual scene node. - This class is also used to represent COLLADA visual scene entities. - - A visual scene node contains child scene nodes to make a tree. - A visual scene node may appear multiple times within the scene graph, - but checks are made to verify that there are no cycles within the graph. - - A visual scene node also contained an ordered list of transformations - and a list of entity instances. - - @ingroup FCDocument -*/ -class FCOLLADA_EXPORT FCDSceneNode : public FCDEntity -{ -private: - FCDSceneNodeList parents; - FCDSceneNodeList children; - FCDTransformList transforms; - FCDEntityInstanceList instances; - FCDExtra* extra; - - // Visibility parameter. Should be a boolean, but is animated - float visibility; // Maya-specific - - // The number of entities that target this node - uint32 targetCount; - - // Whether this node is a joint. - bool isJoint; - -public: - /** Constructor: do not use directly. - Instead, use the FCDSceneNode::AddChild function for child - visual scene nodes or the FCDLibrary::AddEntity function - for visual scenes. - @param document The COLLADA document that owns the scene node. */ - FCDSceneNode(FCDocument* document); - - /** Destructor: do not use directly. - Instead, use the FCDSceneNode::ReleaseChild function for visual - scene nodes or the FCDLibrary::ReleaseEntity function for visual scenes. */ - virtual ~FCDSceneNode(); - - /** Retrieves the type of the entity class. - @return The type of entity class: SCENE_NODE. */ - inline virtual Type GetType() const { return SCENE_NODE; } - - /** Retrieves the number of parent nodes for this visual scene node. - @return The number of parents. */ - inline size_t GetParentCount() const { return parents.size(); }; - - /** Retrieves a specific parent of the visual scene node. - @param index The index of the parent. - @return The parent visual scene node. This pointer will be NULL if - the scene node has no parents or if the index is out-of-bounds. */ - inline FCDSceneNode* GetParent(size_t index = 0) { FUAssert(index == 0 || index < parents.size(), return NULL); return (!parents.empty()) ? parents.at(index) : NULL; } - inline const FCDSceneNode* GetParent(size_t index = 0) const { FUAssert(index == 0 || index < parents.size(), return NULL); return (!parents.empty()) ? parents.at(index) : NULL; } /**< See above. */ - - /** Retrieves the number of child nodes for this visual scene node. - @return The number of children. */ - inline size_t GetChildrenCount() const { return children.size(); }; - - /** Retrieves a specific child of the visual scene node. - @param index The index of the child. - @return The child scene node. This pointer will be NULL if the - index is out-of-bounds. */ - inline FCDSceneNode* GetChild(size_t index) { FUAssert(index < children.size(), return NULL); return children.at(index); } - inline const FCDSceneNode* GetChild(size_t index) const { FUAssert(index < children.size(), return NULL); return children.at(index); } /**< See above. */ - - /** Retrieves the list of children of the visual scene node. - @return The list of child scene nodes. */ - inline FCDSceneNodeList& GetChildren() { return children; } - inline const FCDSceneNodeList& GetChildren() const { return children; } /**< See above. */ - - /** Creates a new child scene node. - @return The new child scene node. */ - FCDSceneNode* AddChildNode(); - - /** Attaches a existing scene node to this visual scene node. - This function will fail if attaching the given scene node - to this visual scene node creates a cycle within the scene graph. - @param sceneNode The scene node to attach. - @return Whether the given scene node was attached to this scene node. */ - bool AddChildNode(FCDSceneNode* sceneNode); - - /** Retrieves the number of entity instances at this node of the scene graph. - @return The number of entity instances. */ - inline size_t GetInstanceCount() const { return instances.size(); }; - - /** Retrieves a specific entity instance. - @param index The index of the instance. - @return The entity instance at the given index. This pointer will be - NULL if the index is out-of-bounds. */ - inline FCDEntityInstance* GetInstance(size_t index) { FUAssert(index < instances.size(), return NULL); return instances.at(index); } - inline const FCDEntityInstance* GetInstance(size_t index) const { FUAssert(index < instances.size(), return NULL); return instances.at(index); } /**< See above. */ - - /** Retrieves the list of entity instances at this node of the scene graph. - @return The list of entity instances. */ - inline FCDEntityInstanceList& GetInstances() { return instances; } - inline const FCDEntityInstanceList& GetInstances() const { return instances; } /**< See above. */ - - /** Retrieves the number of transforms for this node of the scene graph. - @return The number of transforms. */ - inline size_t GetTransformCount() const { return transforms.size(); }; - - /** Retrieves a specific transform. - @param index The index of the transform. - @return The transform at the given index. This pointer will be NULL - if the index is out-of-bounds. */ - inline FCDTransform* GetTransform(size_t index) { FUAssert(index < transforms.size(), return NULL); return transforms.at(index); } - inline const FCDTransform* GetTransform(size_t index) const { FUAssert(index < transforms.size(), return NULL); return transforms.at(index); } /**< See above. */ - - /** Retrieves the list of transforms for this node of the scene graph. - @return The list of transforms. */ - inline FCDTransformList& GetTransforms() { return transforms; } - inline const FCDTransformList& GetTransforms() const { return transforms; } /**< See above. */ - - /** Creates a new transform for this visual scene node. - The transforms are processed in order and COLLADA is column-major. - For row-major matrix stacks, such as DirectX, this implies that the - transformations will be processed in reverse order. - By default, a transform is added at the end of the list. - @param type The type of transform to create. - @param index The index at which to insert the transform. Set this value to -1 - to indicate that you want this transform at the end of the stack. - @return The created transform. */ - FCDTransform* AddTransform(FCDTransform::Type type, size_t index = (size_t)-1); - - /** Retrieves the visual scene node with the given id. - This function looks through the whole tree of visual scene nodes - for the wanted COLLADA id. - @param daeId The COLLADA id to look for. - @return The visual scene node which has the given COLLADA id. This pointer - will be NULL if no visual scene node can be found with the given COLLADA id. */ - virtual FCDEntity* FindDaeId(const string& daeId); - - /** Retrieves whether the visual scene node is visible. - A hidden visual scene node will not be rendered but will - still affect the world. This parameter is a floating-point value - because it is animated. It should be intepreted as a Boolean value. - @return Whether the scene node is visible. */ - inline float& GetVisibility() { return visibility; } - inline const float& GetVisibility() const { return visibility; } /**< See above. */ - - /** Sets the visibility of the visual scene node. - A hidden visual scene node will not be rendered but will - still affect the world. - @param isVisible Whether the visual scene node is visible. */ - inline void SetVisibility(bool isVisible) { visibility = isVisible; } - - /** Retrieves whether this visual scene node is the target of an entity. - @return Whether this is an entity target. */ - inline bool IsTarget() const { return targetCount > 0; } - - /** Retrieves whether this visual scene node is a joint. - Joints are called bones in 3dsMax. A joint is a scene node that is used in skinning. - @return Whether this node is a joint. */ - bool IsJoint() const { return isJoint; } - - /** Sets whether a visual scene node is a joint. - Joints are called bones in 3dsMax. A joint is a scene node that is used in skinning. - @param _isJoint Whether this node is a joint. */ - void SetJointFlag(bool _isJoint) { isJoint = _isJoint; } - - /** Retrieves the local transform for this visual scene node. - This function does not handle or apply animations. - @return The local transform. */ - FMMatrix44 ToMatrix() const; - - /** Generates a list of local transform samples for this visual scene node. - This function will permanently modify the transforms of this visual scene node. - @param keys A list of key inputs that will be filled in with the sample times. - @param values A list of matrices that will be filled in with the sampled local transforms. */ - void GenerateSampledMatrixAnimation(FloatList& keys, FMMatrix44List& values); - - /** [INTERNAL] Increments the number of entities target this node. - To set targets, use the FCDTargetedEntity::SetTarget function. */ - inline void IncrementTargetCount() { ++targetCount; } - - /** [INTERNAL] Decrements the number of entities target this node. - To set targets, use the FCDTargetedEntity::SetTarget function. */ - inline void DecrementTargetCount() { if (targetCount > 0) --targetCount; } - - /** [INTERNAL] Reads in the visual scene node from a given COLLADA XML tree node. - @param sceneNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the node.*/ - virtual FUStatus LoadFromXML(xmlNode* sceneNode); - - /** [INTERNAL] Writes out the visual scene node to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the node. - @return The created XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; - -private: - FUStatus LoadFromExtra(); - void BindMaterial(xmlNode* node); - void WriteToNodeXML(xmlNode* node, bool isVisualScene) const; -}; - -#endif // _FCD_SCENE_NODE_ diff --git a/Extras/FCollada/FCDocument/FCDSkinController.cpp b/Extras/FCollada/FCDocument/FCDSkinController.cpp deleted file mode 100644 index b9216ca12..000000000 --- a/Extras/FCollada/FCDocument/FCDSkinController.cpp +++ /dev/null @@ -1,612 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDController.h" -#include "FCDocument/FCDGeometry.h" -#include "FCDocument/FCDGeometryMesh.h" -#include "FCDocument/FCDGeometryPolygons.h" -#include "FCDocument/FCDGeometrySource.h" -#include "FCDocument/FCDGeometrySpline.h" -#include "FCDocument/FCDSceneNode.h" -#include "FCDocument/FCDSkinController.h" -#include "FUtils/FUStringConversion.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDSkinController::FCDSkinController(FCDocument* document, FCDController* _parent) : FCDObject(document, "FCDSkinController") -{ - parent = _parent; - target = NULL; - ownsTarget = false; - bindShapeTransform = FMMatrix44::Identity; -} - -FCDSkinController::~FCDSkinController() -{ - if (ownsTarget) { SAFE_DELETE(target); } - else target = NULL; - parent = NULL; -} - -void FCDSkinController::SetTarget(FCDEntity* _target) -{ - target = NULL; - weightedMatches.clear(); - - // Retrieve the actual base entity, as you can chain controllers. - FCDEntity* baseEntity = _target; - while (baseEntity != NULL && baseEntity->GetType() == FCDEntity::CONTROLLER) - { - baseEntity = ((FCDController*) baseEntity)->GetBaseTarget(); - } - - if (baseEntity == NULL || baseEntity->GetType() != FCDEntity::GEOMETRY) - { - // The new target is no good! - return; - } - - target = _target; - FCDGeometry* geometry = (FCDGeometry*) baseEntity; - - // Retrieve the new vertex count - size_t vertexCount = 0; - if (geometry->IsMesh()) - { - FCDGeometryMesh* mesh = geometry->GetMesh(); - FCDGeometrySource* positionSource = mesh->GetPositionSource(); - if (positionSource != NULL) - { - vertexCount = positionSource->GetSourceData().size() / positionSource->GetSourceStride(); - } - } - else if (geometry->IsSpline()) - { - FCDGeometrySpline* spline = geometry->GetSpline(); - vertexCount = spline->GetCVCount(); - } - - // Modify the list of influences to match the new target's vertex count. - weightedMatches.resize(vertexCount); -} - -// Adds a joint and its bind-pose to the list of joint influencing the skin. -void FCDSkinController::AddJoint(FCDSceneNode* joint, const FMMatrix44& bindPose) -{ - FCDJointMatrixPair pair; - pair.joint = joint; - pair.invertedBindPose = bindPose.Inverted(); - joints.push_back(pair); - - // Also set the scene node's joint flag. - joint->SetJointFlag(true); -} - -// Removes a joint from the list of joints influencing the skin. -void FCDSkinController::RemoveJoint(FCDSceneNode* joint) -{ - // Find the joint within the joint list. - size_t index = 0; - for (index = 0; index < joints.size(); ++index) - { - if (joints[index].joint == joint) break; - } - if (index == joints.size()) return; - - // Look through the per-vertex influences and remove the influences - // that use this joint. Also, shift down the influences that use - // the joints that appear after this one in the list. - for (FCDWeightedMatches::iterator itM = weightedMatches.begin(); itM != weightedMatches.end(); ++itM) - { - FCDJointWeightPairList& pairs = (*itM); - for (FCDJointWeightPairList::iterator itP = pairs.begin(); itP != pairs.end();) - { - FCDJointWeightPair& p = (*itP); - if (p.jointIndex == index) - { - pairs.erase(itP); - } - else if (p.jointIndex > index) - { - --p.jointIndex; - ++itP; - } - else - { - ++itP; - } - } - } -} - -// Look for the information on a given joint -FCDJointMatrixPair* FCDSkinController::FindJoint(FCDSceneNode* joint) -{ - if (joint == NULL) return NULL; - for (FCDJointList::iterator itJ = joints.begin(); itJ != joints.end(); ++itJ) - { - if ((*itJ).joint == joint) return &(*itJ); - } - return NULL; -} - -const FCDJointMatrixPair* FCDSkinController::FindJoint(const FCDSceneNode* joint) const -{ - if (joint == NULL) return NULL; - for (FCDJointList::const_iterator itJ = joints.begin(); itJ != joints.end(); ++itJ) - { - if ((*itJ).joint == joint) return &(*itJ); - } - return NULL; -} - -// Reduce the number of joints influencing each vertex to a maximum count -void FCDSkinController::ReduceInfluences(uint32 maxInfluenceCount, float minimumWeight) -{ - // Pre-cache an empty weight list to the reduced count - FCDJointWeightPairList reducedWeights; - reducedWeights.reserve(maxInfluenceCount + 1); - - for (FCDWeightedMatches::iterator itM = weightedMatches.begin(); itM != weightedMatches.end(); ++itM) - { - FCDJointWeightPairList& weights = (*itM); - size_t oldWeightCount = weights.size(); - - // Reduce the weights, keeping only the more important ones using a sorting algorithm. - // Also, calculate the current total of the weights, to re-normalize the reduced weights - float oldTotal = 0.0f; - reducedWeights.clear(); - for (FCDJointWeightPairList::iterator itW = weights.begin(); itW != weights.end(); ++itW) - { - FCDJointWeightPairList::iterator itRW = reducedWeights.begin(); - if ((*itW).weight >= minimumWeight) - { - for (; itRW != reducedWeights.end() && (*itRW).weight < (*itW).weight; ++itRW) {} - if (itRW != reducedWeights.end() || reducedWeights.size() <= maxInfluenceCount) - { - reducedWeights.insert(itRW, (*itW)); - if (reducedWeights.size() > maxInfluenceCount) reducedWeights.pop_back(); - } - } - oldTotal += (*itW).weight; - } - - if (oldWeightCount > reducedWeights.size()) - { - // Replace the old weights and re-normalize to their old total - weights = reducedWeights; - float newTotal = 0.0f; - for (FCDJointWeightPairList::iterator itW = weights.begin(); itW != weights.end(); ++itW) newTotal += (*itW).weight; - float renormalizingFactor = oldTotal / newTotal; - for (FCDJointWeightPairList::iterator itW = weights.begin(); itW != weights.end(); ++itW) (*itW).weight *= renormalizingFactor; - } - } -} - -// Load this controller from a COLLADA node -FUStatus FCDSkinController::LoadFromXML(xmlNode* skinNode) -{ - FUStatus status; - if (!IsEquivalent(skinNode->name, DAE_CONTROLLER_SKIN_ELEMENT)) - { - return status.Warning(FS("Unexpected node in controller library: ") + TO_FSTRING((const char*) skinNode->name), skinNode->line); - } - - // Get the element and process the inner element - xmlNode* verticesNode = FindChildByType(skinNode, DAE_VERTICES_ELEMENT); - bool isCollada1_3 = verticesNode != NULL; - - // Read in the element - xmlNode* bindShapeTransformNode = FindChildByType(skinNode, DAE_BINDSHAPEMX_SKIN_PARAMETER); - if (bindShapeTransformNode == NULL) bindShapeTransform = FMMatrix44::Identity; - else - { - const char* content = ReadNodeContentDirect(bindShapeTransformNode); - FUStringConversion::ToMatrix(&content, bindShapeTransform, GetDocument()->GetLengthUnitConversion()); - } - - // Find the target geometry - string targetId = (isCollada1_3) ? parent->GetTargetId() : ReadNodeProperty(skinNode, DAE_SOURCE_ATTRIBUTE); - target = GetDocument()->FindGeometry(targetId); - if (target == NULL) target = GetDocument()->FindController(targetId); - if (target == NULL) - { - return status.Warning(FS("Target not found for controller: ") + TO_FSTRING(parent->GetDaeId()), skinNode->line); - } - - // Retrieve the and elements - xmlNode* jointsNode = NULL,* combinerNode = NULL,* containerNode = NULL; - if (isCollada1_3) - { - // COLLADA 1.3 backward compatibility: read in the bind-shape positions/normals - xmlNodeList vertexInputNodes; - FindChildrenByType(verticesNode, DAE_INPUT_ELEMENT, vertexInputNodes); - xmlNode* bindShapePositionSourceNode = NULL,* jointWeightSourceNode = NULL,* bindShapeNormalSourceNode = NULL; - for (xmlNodeList::iterator it = vertexInputNodes.begin(); it != vertexInputNodes.end(); ++it) - { - string semantic = ReadNodeSemantic(*it); - string sourceId = ReadNodeSource(*it); - if (semantic == DAE_BINDPOS_SKIN_INPUT) bindShapePositionSourceNode = FindChildById(skinNode, sourceId); - else if (semantic == DAE_BINDNORMAL_SKIN_INPUT) bindShapeNormalSourceNode = FindChildById(skinNode, sourceId); - else if (semantic == DAE_JOINTWEIGHT_SKIN_INPUT) jointWeightSourceNode = FindChildById(skinNode, sourceId); - else - { - status.Warning(FS("Unknown vertex input in skin controller: ") + TO_FSTRING(parent->GetDaeId()), (*it)->line); - } - } - if (jointWeightSourceNode == NULL) - { - return status.Fail(FS("Cannot find 'JOINTS_AND_WEIGHTS' input in element for controller: ") + TO_FSTRING(parent->GetDaeId()), jointWeightSourceNode->line); - } - if (bindShapePositionSourceNode == NULL) - { - return status.Fail(FS("Cannot find 'BIND_SHAPE_POSITION' input in element for controller: ") + TO_FSTRING(parent->GetDaeId()), jointWeightSourceNode->line); - } - - // Read in the bindshape positions/normals and override the original mesh's positions/normals - FloatList bindShapePositions, bindShapeNormals; - uint32 positionStride = ReadSource(bindShapePositionSourceNode, bindShapePositions); - uint32 normalsStride = ReadSource(bindShapeNormalSourceNode, bindShapeNormals); - if (target->GetType() != FCDEntity::GEOMETRY) - { - return status.Fail(FS("COLLADA 1.3 only supports geometric bind shapes for skin controller: ") + TO_FSTRING(parent->GetDaeId()), skinNode->line); - } - target = ((FCDGeometry*)target)->Clone(bindShapePositions, positionStride, bindShapeNormals, normalsStride); - ownsTarget = true; - - // Retrieve the element and the element - xmlNode* jointWeightTechniqueNode = FindTechnique(jointWeightSourceNode, DAE_COMMON_PROFILE); - jointsNode = FindChildByType(jointWeightTechniqueNode, DAE_JOINTS_ELEMENT); - combinerNode = FindChildByType(jointWeightTechniqueNode, DAE_COMBINER_ELEMENT); - containerNode = jointWeightSourceNode; - } - else - { - // COLLADA 1.4: use the target geometry directly as the bind-shape. - - // Retrieve the element and the element - jointsNode = FindChildByType(skinNode, DAE_JOINTS_ELEMENT); - combinerNode = FindChildByType(skinNode, DAE_WEIGHTS_ELEMENT); - } - - // Verify that we have the necessary data structures: bind-shape, elements, element - if (target == NULL) - { - return status.Warning(FS("Unable to clone/find the target geometry for controller: ") + TO_FSTRING(parent->GetDaeId()), skinNode->line); - } - if (jointsNode == NULL) - { - return status.Fail(FS("No element found in the skin weight source for controller: ") + TO_FSTRING(parent->GetDaeId()), skinNode->line); - } - if (combinerNode == NULL) - { - return status.Fail(FS("No node found in the skin weight source for controller: ") + TO_FSTRING(parent->GetDaeId()), skinNode->line); - } - - // Gather the inputs for the element and the element - xmlNode* firstCombinerValueNode = NULL; - xmlNodeList skinningInputNodes; - FindChildrenByType(jointsNode, DAE_INPUT_ELEMENT, skinningInputNodes); - uint32 combinerValueCount = ReadNodeCount(combinerNode); - for (xmlNode* child = combinerNode->children; child != NULL; child = child->next) - { - if (child->type != XML_ELEMENT_NODE) continue; - if (IsEquivalent(child->name, DAE_INPUT_ELEMENT)) skinningInputNodes.push_back(child); - else if (IsEquivalent(child->name, DAE_VERTEX_ELEMENT) || IsEquivalent(child->name, DAE_VERTEXCOUNT_ELEMENT)) - { - firstCombinerValueNode = child; - break; - } - } - if (firstCombinerValueNode == NULL) - { - return status.Fail(FS("Unable to find element's value nodes for controller: ") + TO_FSTRING(parent->GetDaeId()), combinerNode->line); - } - - // Process these inputs - FloatList weights; - FMMatrix44List invertedBindPoses; - int32 jointIdx = 0, weightIdx = 1; - for (xmlNodeList::iterator it = skinningInputNodes.begin(); it != skinningInputNodes.end(); ++it) - { - string semantic = ReadNodeSemantic(*it); - string sourceId = ReadNodeSource(*it); - - const char* arrayContent = NULL; - uint32 count = 0; - xmlNode* sourceNode = NULL; - if (isCollada1_3) - { - // COLLADA 1.3 backward compatibility: retrieve the node and its - xmlNode* techniqueNode = FindTechnique(containerNode, DAE_COMMON_PROFILE); - xmlNode* accessorNode = FindChildById(techniqueNode, sourceId); - string arrayId = ReadNodeSource(accessorNode); - xmlNode* arrayNode = FindChildById(containerNode, arrayId); - arrayContent = ReadNodeContentDirect(arrayNode); - count = ReadNodeCount(accessorNode); - } - else - { - // Find the source node for this source id - sourceNode = FindChildById(skinNode, sourceId); - } - - if (semantic == DAE_JOINT_SKIN_INPUT) - { - string idx = ReadNodeProperty(*it, DAE_OFFSET_ATTRIBUTE); - if (idx.empty()) idx = ReadNodeProperty(*it, DAE_IDX_ATTRIBUTE); // COLLADA 1.3 Backward-compatibility - if (!idx.empty()) jointIdx = FUStringConversion::ToInt32(idx); - if (!jointIds.empty()) continue; - - // Read in joint ids element - if (isCollada1_3) - { - // COLLADA 1.3 backward compatibility: read in the joint Ids directly - jointIds.resize(count); - FUStringConversion::ToStringList(arrayContent, jointIds); - } - else ReadSource(sourceNode, jointIds); - } - else if (semantic == DAE_BINDMATRIX_SKIN_INPUT) - { - if (!invertedBindPoses.empty()) - { - return status.Fail(FS("No inverted bind matrix input in controller: ") + TO_FSTRING(parent->GetDaeId()), (*it)->line); - } - - // Read in the bind-pose matrices element - if (isCollada1_3) - { - // COLLADA 1.3 backward compatibility: read in the bind-pose matrices directly - invertedBindPoses.resize(count); - FUStringConversion::ToMatrixList(arrayContent, invertedBindPoses, GetDocument()->GetLengthUnitConversion()); - } - else ReadSource(sourceNode, invertedBindPoses, GetDocument()->GetLengthUnitConversion()); - } - else if (semantic == DAE_WEIGHT_SKIN_INPUT) - { - string idx = ReadNodeProperty(*it, DAE_OFFSET_ATTRIBUTE); - if (idx.empty()) idx = ReadNodeProperty(*it, DAE_IDX_ATTRIBUTE); // COLLADA 1.3 Backward-compatibility - if (!idx.empty()) weightIdx = FUStringConversion::ToInt32(idx); - - // Read in the weights element - if (isCollada1_3) - { - // COLLADA 1.3 backward compatibility: read in the weights directly - weights.resize(count); - FUStringConversion::ToFloatList(arrayContent, weights); - } - else ReadSource(sourceNode, weights); - } - } - - // Parse the and the elements - UInt32List combinerVertexCounts; combinerVertexCounts.reserve(combinerValueCount); - Int32List combinerVertexIndices; combinerVertexIndices.reserve(combinerValueCount * 5); - if (!isCollada1_3) - { - // The and the elements are ordered. Read the element first. - if (!IsEquivalent(firstCombinerValueNode->name, DAE_VERTEXCOUNT_ELEMENT)) - { - return status.Fail(FS("Expecting element in combiner for controller: ") + TO_FSTRING(parent->GetDaeId()), firstCombinerValueNode->line); - } - const char* content = ReadNodeContentDirect(firstCombinerValueNode); - FUStringConversion::ToUInt32List(content, combinerVertexCounts); - - // Read the element second. - xmlNode* vNode = firstCombinerValueNode->next; - while (vNode != NULL && vNode->type != XML_ELEMENT_NODE) vNode = vNode->next; - if (vNode == NULL || !IsEquivalent(vNode->name, DAE_VERTEX_ELEMENT)) - { - return status.Fail(FS("Expecting element after element in combiner for controller: ") + TO_FSTRING(parent->GetDaeId()), vNode->line); - } - content = ReadNodeContentDirect(vNode); - FUStringConversion::ToInt32List(content, combinerVertexIndices); - } - else - { - // COLLADA 1.3 backward compatibility: Read in the many elements, - // creating the vertex counts array along the way - Int32List indices; indices.reserve(32); - for (xmlNode* valueNode = firstCombinerValueNode; valueNode != NULL; valueNode = valueNode->next) - { - if (valueNode->type != XML_ELEMENT_NODE) continue; - - indices.clear(); - const char* valueNodeContent = ReadNodeContentDirect(valueNode); - FUStringConversion::ToInt32List(valueNodeContent, indices); - size_t indexCount = indices.size() / 2; - combinerVertexCounts.push_back((uint32) indexCount); - combinerVertexIndices.insert(combinerVertexIndices.end(), indices.begin(), indices.end()); - } - } - size_t combinerVertexIndexCount = combinerVertexIndices.size(); - - // Validate the inputs - if (jointIds.size() != invertedBindPoses.size()) - { - return status.Fail(FS("Joint count and bind pose matrix count aren't equal for controller: ") + TO_FSTRING(parent->GetDaeId()), skinNode->line); - } - if (combinerVertexCounts.size() != combinerValueCount) - { - return status.Fail(FS("The element list should contains the number of values determined by the 's 'count' attribute: ") + TO_FSTRING(parent->GetDaeId()), skinNode->line); - } - - // Setup the joint-weight-vertex matches - weightedMatches.resize(combinerValueCount); - size_t jointCount = jointIds.size(), weightCount = weights.size(), offset = 0; - for (size_t j = 0; j < combinerValueCount; ++j) - { - FCDJointWeightPairList& pairList = weightedMatches[j]; - uint32 localValueCount = combinerVertexCounts[j]; - pairList.resize(localValueCount); - for (size_t i = 0; i < localValueCount && offset < combinerVertexIndexCount - 1; ++i) - { - pairList[i].jointIndex = combinerVertexIndices[offset + jointIdx]; - if (pairList[i].jointIndex >= jointCount) - { - status.Warning(FS("Joint index out of bounds in combiner for controller: ") + TO_FSTRING(parent->GetDaeId())); - pairList[i].jointIndex = 0; - } - uint32 weightIndex = combinerVertexIndices[offset + weightIdx]; - if (weightIndex >= weightCount) - { - status.Warning(FS("Weight index out of bounds in combiner for controller: ") + TO_FSTRING(parent->GetDaeId())); - weightIndex = 0; - } - pairList[i].weight = weights[weightIndex]; - offset += 2; - } - } - - // Normalize the weights, per-vertex, to 1 (or 0) - // This step is still being debated as necessary or not, for COLLADA 1.4. - for (FCDWeightedMatches::iterator it = weightedMatches.begin(); it != weightedMatches.end(); ++it) - { - FCDJointWeightPairList& pair = (*it); - float weightSum = 0.0f; - for (FCDJointWeightPairList::iterator itP = pair.begin(); itP != pair.end(); ++itP) - { - weightSum += (*itP).weight; - } - - if (IsEquivalent(weightSum, 0.0f) || IsEquivalent(weightSum, 1.0f)) continue; - - float invWeightSum = 1.0f / weightSum; - for (FCDJointWeightPairList::iterator itP = pair.begin(); itP != pair.end(); ++itP) - { - (*itP).weight *= invWeightSum; - } - } - - // Setup the bind poses. - // Joints are linked later, as they are loaded last: with the scene graph - joints.resize(jointCount); - for (uint32 i = 0; i < jointCount; ++i) - { - FCDJointMatrixPair& joint = joints[i]; - joint.invertedBindPose = invertedBindPoses[i]; - joint.joint = NULL; - } - - return status; -} - -// Write out this controller to a COLLADA xml node tree -xmlNode* FCDSkinController::WriteToXML(xmlNode* parentNode) const -{ - // Create the element - xmlNode* skinNode = AddChild(parentNode, DAE_CONTROLLER_SKIN_ELEMENT); - if (target != NULL) AddAttribute(skinNode, DAE_SOURCE_ATTRIBUTE, string("#") + target->GetDaeId()); - - // Create the element - string bindShapeMatrixString = FUStringConversion::ToString(bindShapeTransform); - AddChild(skinNode, DAE_BINDSHAPEMX_SKIN_PARAMETER, bindShapeMatrixString); - - // Create the joint source - FUSStringBuilder jointSourceId(parent->GetDaeId()); jointSourceId += "-joints"; - StringList jointIds; - for (FCDJointList::const_iterator itJ = joints.begin(); itJ != joints.end(); ++itJ) - { - if ((*itJ).joint != NULL) jointIds.push_back((*itJ).joint->GetDaeId()); - else jointIds.push_back(DAEERR_UNKNOWN_INPUT); - } - AddSourceIDRef(skinNode, jointSourceId.ToCharPtr(), jointIds, DAE_JOINT_SKIN_INPUT); - - // Create the joint bind matrix source - FUSStringBuilder jointBindSourceId(parent->GetDaeId()); jointBindSourceId += "-bind_poses"; - FMMatrix44List jointBindPoses; - for (FCDJointList::const_iterator itJ = joints.begin(); itJ != joints.end(); ++itJ) - { - jointBindPoses.push_back((*itJ).invertedBindPose); - } - AddSourceMatrix(skinNode, jointBindSourceId.ToCharPtr(), jointBindPoses); - - // Create the weight source - FloatList weights; - weights.push_back(1.0f); - for (FCDWeightedMatches::const_iterator itW = weightedMatches.begin(); itW != weightedMatches.end(); ++itW) - { - const FCDJointWeightPairList& pairs = (*itW); - for (FCDJointWeightPairList::const_iterator itP = pairs.begin(); itP != pairs.end(); ++itP) - { - float w = (*itP).weight; - if (!IsEquivalent(w, 1.0f)) weights.push_back(w); - } - } - FUSStringBuilder weightSourceId(parent->GetDaeId()); weightSourceId += "-weights"; - AddSourceFloat(skinNode, weightSourceId.ToCharPtr(), weights, DAE_WEIGHT_SKIN_INPUT); - - // Create the element - xmlNode* jointsNode = AddChild(skinNode, DAE_JOINTS_ELEMENT); - AddInput(jointsNode, jointSourceId.ToCharPtr(), DAE_JOINT_SKIN_INPUT); - AddInput(jointsNode, jointBindSourceId.ToCharPtr(), DAE_BINDMATRIX_SKIN_INPUT); - - // Create the element - xmlNode* matchesNode = AddChild(skinNode, DAE_WEIGHTS_ELEMENT); - AddInput(matchesNode, jointSourceId.ToCharPtr(), DAE_JOINT_SKIN_INPUT, 0); - AddInput(matchesNode, weightSourceId.ToCharPtr(), DAE_WEIGHT_SKIN_INPUT, 1); - AddAttribute(matchesNode, DAE_COUNT_ATTRIBUTE, weightedMatches.size()); - - // Generate the vertex count and match value strings and export the and elements - FUSStringBuilder vertexCounts; vertexCounts.reserve(1024); - FUSStringBuilder vertexMatches; vertexMatches.reserve(1024); - uint32 weightOffset = 1; - for (FCDWeightedMatches::const_iterator itW = weightedMatches.begin(); itW != weightedMatches.end(); ++itW) - { - const FCDJointWeightPairList& pairs = (*itW); - vertexCounts.append((uint32) pairs.size()); vertexCounts.append(' '); - for (FCDJointWeightPairList::const_iterator itP = pairs.begin(); itP != pairs.end(); ++itP) - { - vertexMatches.append((*itP).jointIndex); vertexMatches.append(' '); - if (!IsEquivalent((*itP).weight, 1.0f)) vertexMatches.append(weightOffset++); - else vertexMatches.append('0'); - vertexMatches.append(' '); - } - } - if (!vertexMatches.empty()) vertexMatches.pop_back(); - AddChild(matchesNode, DAE_VERTEXCOUNT_ELEMENT, vertexCounts); - AddChild(matchesNode, DAE_VERTEX_ELEMENT, vertexMatches); - return skinNode; -} - -// Done after the scene graph is loaded, link this controller to its joints -FUStatus FCDSkinController::Link() -{ - FUStatus status; - - // Look for each joint, by COLLADA id, within the scene graph - size_t jointCount = joints.size(); - if (jointCount != jointIds.size()) - { - return status.Fail(FS("Parsing programming error in controller: ") + TO_FSTRING(parent->GetDaeId())); - } - for (size_t i = 0; i < jointCount; ++i) - { - FCDJointMatrixPair& joint = joints[i]; - joint.joint = GetDocument()->FindSceneNode(jointIds[i]); - if (joint.joint != NULL) - { - joint.joint->SetJointFlag(true); - } - else - { - status.Warning(FS("Unknown joint '") + TO_FSTRING(jointIds[i]) + FS("' referenced in controller: ") + TO_FSTRING(parent->GetDaeId())); - } - } - jointIds.clear(); - - return status; -} diff --git a/Extras/FCollada/FCDocument/FCDSkinController.h b/Extras/FCollada/FCDocument/FCDSkinController.h deleted file mode 100644 index a983f4f0d..000000000 --- a/Extras/FCollada/FCDocument/FCDSkinController.h +++ /dev/null @@ -1,207 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDSkinController.h - This file contains the FCDSkinController class. -*/ - -#ifndef _FCD_SKIN_CONTROLLER_H_ -#define _FCD_SKIN_CONTROLLER_H_ - -#include "FCDocument/FCDObject.h" - -class FCDocument; -class FCDController; -class FCDGeometry; -class FCDSceneNode; - -/** - A weighted joint index used in skinning. -*/ -struct FCDJointWeightPair -{ - /** Default constructor: sets both the joint index and the weight to zero. */ - FCDJointWeightPair() { jointIndex = 0; weight = 0.0f; } - - /** Constructor: sets the joint index and the weight to the given values. - @param _jointIndex The jointIndex. - @param _weight Its weight. */ - FCDJointWeightPair(uint32 _jointIndex, float _weight) { jointIndex = _jointIndex; weight = _weight; } - - uint32 jointIndex; /**< A joint index. Use this index within the skin's joint list. */ - float weight; /**< A skinning weight. */ -}; - -/** - A joint and its bind pose used in skinning. -*/ -struct FCDJointMatrixPair -{ - FMMatrix44 invertedBindPose; /**< The inverse matrix of the bind pose of the joint. */ - FCDSceneNode* joint; /**< A joint. */ -}; - -/** A dynamically-sized array of joints and bind poses. */ -typedef vector FCDJointList; - -/** A dynamically-sized array of weighted joint indices. - The sum of the weights within this list should always add up to one. */ -typedef vector FCDJointWeightPairList; - -/** A dynamically-sized array of weighted joint index lists. - Each entry within this list represents one vertex of the skinned geometry. */ -typedef vector FCDWeightedMatches; - -/** - A COLLADA skin controller. - - The skin controller holds the information to skin a geometric object. - That information includes a target/base entity and its bind-pose matrix, - a list of joints and their bind pose and the influences for the joints. - - The influences are a list, for each vertex of the target entity, of which - joints affect the vertex and by how much. - - @ingroup FCDGeometry -*/ -class FCOLLADA_EXPORT FCDSkinController : public FCDObject -{ -private: - FCDController* parent; - - bool ownsTarget; - FCDEntity* target; - FMMatrix44 bindShapeTransform; - - StringList jointIds; - FCDJointList joints; - FCDWeightedMatches weightedMatches; - -public: - /** Constructor: do not use directly. - Instead, use the FCDController::CreateSkinController function. - @param document The COLLADA document that owns the skin. - @param parent The COLLADA controller that contains this skin. */ - FCDSkinController(FCDocument* document, FCDController* parent); - - /** Destructor: do not use directly. - Instead, release the parent controller or create a new skin/morpher. */ - virtual ~FCDSkinController(); - - /** Retrieves the target entity. - This entity may be a geometric entity or another controller. - @return The target entity. */ - FCDEntity* GetTarget() { return target; } - const FCDEntity* GetTarget() const { return target; } /**< See above. */ - - /** Sets the target entity. - This function has very important ramifications, as the number - of vertices may change. The influences list will be modified to - follow the number of vertices. - This entity may be a geometric entity or another controller. - @param _target The target entity. */ - void SetTarget(FCDEntity* _target); - - /** Retrieves the bind-pose transform of the target entity. - @return The bind-pose transform. */ - const FMMatrix44& GetBindShapeTransform() const { return bindShapeTransform; } - - /** Sets the bind-pose transform of the target entity. - @param bindPose The bind-pose transform. */ - void SetBindShapeTransform(const FMMatrix44& bindPose) { bindShapeTransform = bindPose; } - - /** Retrieves a list of the joints that influence this skin. - @return The list of joints. */ - FCDJointList& GetJoints() { return joints; } - const FCDJointList& GetJoints() const { return joints; } /**< See above. */ - - /** Retrieves the number of joints that influence the skin. - @return The number of joints. */ - size_t GetJointCount() const { return joints.size(); } - - /** Retrieves a specific joint. - @param index The index of the joint. - @return The joint. This pointer will be NULL, if the index is out-of-bounds. */ - FCDJointMatrixPair* GetJoint(size_t index) { FUAssert(index < GetJointCount(), return NULL); return &joints.at(index); } - const FCDJointMatrixPair* GetJoint(size_t index) const { FUAssert(index < GetJointCount(), return NULL); return &joints.at(index); } /**< See above. */ - - /** Retrieves the information specific to a given joint. - @param joint The joint. - @return The information specific to this joint. This pointer will be NULL - if the given joint does not influence this skin. */ - FCDJointMatrixPair* FindJoint(FCDSceneNode* joint); - const FCDJointMatrixPair* FindJoint(const FCDSceneNode* joint) const; /**< See above. */ - - /** Adds a joint and its bind-pose to the list of joint influencing the skin. - @param joint The joint. - @param bindPose The joint's bind-pose. This matrix will be inverted by this function. */ - void AddJoint(FCDSceneNode* joint, const FMMatrix44& bindPose); - - /** Removes a joint from the list of joints influencing the skin. - All the per-vertex influences that use this joint will be removed. - @param joint The joint. */ - void RemoveJoint(FCDSceneNode* joint); - - /** Retrieves a list of the per-vertex influences for the skin. - You should not modify the size of the list. Instead, use the SetTarget function. - @deprecated Will be replaces by GetVertexInfluences. - @return The list of per-vertex influences. */ - FCDWeightedMatches& GetWeightedMatches() { return weightedMatches; } - const FCDWeightedMatches& GetWeightedMatches() const { return weightedMatches; } /**< See above. */ - - /** Retrieves a list of the per-vertex influences for the skin. - You should not modify the size of the list. Instead, use the SetTarget function. - @return The list of per-vertex influences. */ - FCDWeightedMatches& GetVertexInfluences() { return weightedMatches; } - const FCDWeightedMatches& GetVertexInfluences() const { return weightedMatches; } /**< See above. */ - - /** Retrieves the number of per-vertex influences. - This value should be equal to the number of vertices/control points - within the target geometric entity. - @return The number of per-vertex influences. */ - size_t GetVertexInfluenceCount() const { return weightedMatches.size(); } - - /** Retrieves the per-vertex influences for a given vertex. - @param index The vertex index. - @return The per-vertex influences. */ - FCDJointWeightPairList* GetInfluences(size_t index) { FUAssert(index < GetVertexInfluenceCount(), return NULL); return &weightedMatches.at(index); } - const FCDJointWeightPairList* GetInfluences(size_t index) const { FUAssert(index < GetVertexInfluenceCount(), return NULL); return &weightedMatches.at(index); } /**< See above. */ - - /** Reduces the number of joints influencing each vertex. - 1) All the influences with a weight less than the minimum will be removed. - 2) If a vertex has more influences than the given maximum, they will be sorted and the - most important influences will be kept. - If some of the influences for a vertex are removed, the weight will be normalized. - @param maxInfluenceCount The maximum number of influence to keep for each vertex. - @param minimumWeight The smallest weight to keep. */ - void ReduceInfluences(uint32 maxInfluenceCount, float minimumWeight=0.0f); - - /** [INTERNAL] Reads in the \ element from a given COLLADA XML tree node. - @param skinNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the skin.*/ - FUStatus LoadFromXML(xmlNode* skinNode); - - /** [INTERNAL] Writes out the \ element to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the skin information. - @return The created element XML tree node. */ - xmlNode* WriteToXML(xmlNode* parentNode) const; - - /** [INTERNAL] Links the skin with its joints. - Since the scene graph is imported after the controllers, this function is used - to link the skin with its joints. - @return The status of the linkage.*/ - FUStatus Link(); -}; - -#endif // _FCD_SKIN_CONTROLLER_H_ - diff --git a/Extras/FCollada/FCDocument/FCDTargetedEntity.cpp b/Extras/FCollada/FCDocument/FCDTargetedEntity.cpp deleted file mode 100644 index cbf0852d4..000000000 --- a/Extras/FCollada/FCDocument/FCDTargetedEntity.cpp +++ /dev/null @@ -1,62 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDTargetedEntity.h" -#include "FCDocument/FCDSceneNode.h" - -FCDTargetedEntity::FCDTargetedEntity(FCDocument* document, const char* className) : FCDEntity(document, className) -{ - targetNode = NULL; -} - -FCDTargetedEntity::~FCDTargetedEntity() -{ - targetNode = NULL; -} - -// Sets a new target -void FCDTargetedEntity::SetTargetNode(FCDSceneNode* target) -{ - if (targetNode != NULL) - { - targetNode->DecrementTargetCount(); - } - - targetNode = target; - - if (targetNode != NULL) - { - targetNode->IncrementTargetCount(); - } -} - -// Link this camera with its target, if there is one -FUStatus FCDTargetedEntity::LinkTarget(FCDSceneNode* sceneRoot) -{ - FUStatus status; - if (targetId.empty()) return status; - - if (targetId[0] == '#') targetId = targetId.substr(1); - - if (sceneRoot == NULL) - { - return status.Fail(FS("Invalid parameter in call to FCDTargetEntity::LinkTarget.")); - } - FCDSceneNode* target = (FCDSceneNode*) sceneRoot->FindDaeId(targetId); - if (target == NULL) - { - return status.Fail(FS("Unable to find target scene node for object: ") + TO_FSTRING(GetDaeId())); - } - SetTargetNode(target); - - return status; -} diff --git a/Extras/FCollada/FCDocument/FCDTargetedEntity.h b/Extras/FCollada/FCDocument/FCDTargetedEntity.h deleted file mode 100644 index a8996a3cf..000000000 --- a/Extras/FCollada/FCDocument/FCDTargetedEntity.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDTargetedEntity.h - This file contains the FCDTargetedEntity class. -*/ - -#ifndef _FCD_TARGETED_ENTITY_H_ -#define _FCD_TARGETED_ENTITY_H_ - -#include "FCDocument/FCDEntity.h" - -class FCDSceneNode; - -/** - A targeted entity. - - COLLADA doesn't have targeted entity. - Therefore: the behavior of a targeted entity is application-defined. - - This class is used to support 3dsMax's targeted cameras and lights - and we also plan to support Maya's targeted cameras and lights. - - @see FCDCamera FCDLight - @ingroup FCDEntity -*/ -class FCOLLADA_EXPORT FCDTargetedEntity : public FCDEntity -{ -private: - // Target - string targetId; // only valid during the import - FCDSceneNode* targetNode; - -public: - /** Constructor: do not use directly. - Instead, create objects of the up-classes. - @param document The COLLADA document that owns the targeted entity. - @param baseId The prefix COLLADA id to be used if no COLLADA id is provided. */ - FCDTargetedEntity(FCDocument* document, const char* baseId); - - /** Destructor: do not use directly. - Instead, release objects through their libraries or their parent entities. */ - virtual ~FCDTargetedEntity(); - - /** Retrieves whether a target is defined for this entity. - @return Whether a target is defined for this entity. */ - inline bool HasTarget() const { return targetNode != NULL; } - - /** Retrieves the target visual scene node for this entity. - @return The target visual scene node. */ - inline FCDSceneNode* GetTargetNode() { return targetNode; } - inline const FCDSceneNode* GetTargetNode() const { return targetNode; } /**< See above. */ - - /** Sets the target visual scene node for this entity. - @param target The new target node. */ - void SetTargetNode(FCDSceneNode* target); - - /** [INTERNAL] Links the entity with its target. - This function is used during the import of a COLLADA document. - @todo Modify this function to support multiple visual scenes. - @param sceneRoot The root visual scene. - @return The status of the linkage. */ - FUStatus LinkTarget(FCDSceneNode* sceneRoot); - -protected: - /** [INTERNAL] Retrieves the COLLADA id of the target entity. - The actual resolution of the COLLADA id into a visual scene node happens - during the LinkTarget function. - @return The COLLADA id of the target entity. */ - inline const string& GetTargetId() { return targetId; } - - /** [INTERNAL] Sets the COLLADA id of the target entity. - This function is used during the import of a COLLADA document. - The actual resolution of the COLLADA id into a visual scene node happens - during the LinkTarget function. - @param _targetId A COLLADA id. */ - inline void SetTargetId(const string& _targetId) { targetId = _targetId; } - inline void SetTargetId(const char* _targetId) { targetId = _targetId; } /**< See above. */ -}; - -#endif // _FCD_TARGETED_ENTITY_H_ - diff --git a/Extras/FCollada/FCDocument/FCDTexture.cpp b/Extras/FCollada/FCDocument/FCDTexture.cpp deleted file mode 100644 index e00a72d63..000000000 --- a/Extras/FCollada/FCDocument/FCDTexture.cpp +++ /dev/null @@ -1,353 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDAnimated.h" -#include "FCDocument/FCDEffectParameter.h" -#include "FCDocument/FCDEffectParameterList.h" -#include "FCDocument/FCDImage.h" -#include "FCDocument/FCDTexture.h" -#include "FUtils/FUStringConversion.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDTexture::FCDTexture(FCDocument* document) : FCDEntity(document, "Texture") -{ - textureChannel = FUDaeTextureChannel::DEFAULT; - image = NULL; - set = new FCDEffectParameterInt(document); - set->SetValue(-1); - multiplier = 1.0f; - blendMode = FUDaeBlendMode::DEFAULT; - ClearPlacement2D(); - hasProjection3D = false; - hasPlacement2D = false; -} - -FCDTexture::~FCDTexture() -{ - image = NULL; - SAFE_DELETE(set); -} - -void FCDTexture::ClearPlacement2D() -{ - hasPlacement2D = false; - wrapU = wrapV = mirrorU = mirrorV = stagger = fast = 0.0f; // false - translateFrameU = translateFrameV = rotateFrame = 0.0f; - offsetU = offsetV = rotateUV = noiseU = noiseV = 0.0f; - coverageU = coverageV = repeatU = repeatV = 1.0f; -} - -void FCDTexture::ClearProjection3D() -{ - hasProjection3D = false; - projectionMatrix = FMMatrix44::Identity; - projectionType.clear(); -} - -// Look for the effect parameter with the correct semantic, in order to bind/set its value -FCDEffectParameter* FCDTexture::FindParameterBySemantic(const string& semantic) -{ - if (set->GetSemantic() == semantic) return set; - else return NULL; -} - -void FCDTexture::FindParametersBySemantic(const string& semantic, FCDEffectParameterList& parameters) -{ - if (set->GetSemantic() == semantic) parameters.push_back(set); -} - -void FCDTexture::FindParametersByReference(const string& reference, FCDEffectParameterList& parameters) -{ - if (set->GetReference() == reference) parameters.push_back(set); -} - -// Returns a copy of the texture/sampler, with all the animations attached -FCDTexture* FCDTexture::Clone() -{ - FCDTexture* clone = new FCDTexture(GetDocument()); - FCDEntity::Clone(clone); - clone->textureChannel = textureChannel; - clone->image = image; // copy only the pointer. - SAFE_DELETE(clone->set); - clone->set = (FCDEffectParameterInt*) set->Clone(); - - clone->hasProjection3D = hasProjection3D; - clone->hasPlacement2D = hasPlacement2D; - clone->blendMode = blendMode; - clone->projectionMatrix = projectionMatrix; - -# define CLONE_ANIMATED(flt) clone->flt = flt; FCDAnimatedFloat::Clone(GetDocument(), &flt, &clone->flt); - CLONE_ANIMATED(multiplier); - CLONE_ANIMATED(wrapU); CLONE_ANIMATED(wrapV); - CLONE_ANIMATED(mirrorU); CLONE_ANIMATED(mirrorV); - CLONE_ANIMATED(stagger); CLONE_ANIMATED(fast); - CLONE_ANIMATED(translateFrameU); CLONE_ANIMATED(translateFrameV); - CLONE_ANIMATED(offsetU); CLONE_ANIMATED(offsetV); - CLONE_ANIMATED(rotateUV); - CLONE_ANIMATED(noiseU); CLONE_ANIMATED(noiseV); - CLONE_ANIMATED(coverageU); CLONE_ANIMATED(coverageV); - CLONE_ANIMATED(repeatU); CLONE_ANIMATED(repeatV); -# undef CLONE_ANIMATED - - return clone; -} - -// Read in the texture element for a standard effect COLLADA texture -FUStatus FCDTexture::LoadFromTextureXML(xmlNode* textureNode) -{ - FUStatus status; - - // Verify that this is a sampler node - if (!IsEquivalent(textureNode->name, DAE_FXSTD_SAMPLER_ELEMENT)) - { - return status.Fail(FS("Unknown texture sampler element."), textureNode->line); - } - - // Read in the 'texture' attribute: points to an image - string imageId = ReadNodeProperty(textureNode, DAE_FXSTD_TEXTURE_ATTRIBUTE); - image = GetDocument()->FindImage(imageId); - if (image == NULL) - { - status.Warning(FS("Unable to find image source for sampler."), textureNode->line); - } - - // Read in the 'texcoord' attribute: a texture coordinate set identifier - string semantic = ReadNodeProperty(textureNode, DAE_FXSTD_TEXTURESET_ATTRIBUTE); - if (!semantic.empty()) - { - set->SetSemantic(semantic); - - // [GLaforte 06-01-06] Also attempt to convert the value to a signed integer - // since that was done quite a bit in COLLADA 1.4 preview exporters. - set->SetValue(FUStringConversion::ToInt32(semantic)); - } - - // Look for/parse in the texture placement parameters - xmlNode* extraNode = FindChildByType(textureNode, DAE_EXTRA_ELEMENT); - xmlNode* mayaTechniqueNode = FindTechnique(extraNode, DAEMAYA_MAYA_PROFILE); - status.AppendStatus(LoadPlacementXML(mayaTechniqueNode)); - xmlNode* maxTechniqueNode = FindTechnique(extraNode, DAEMAX_MAX_PROFILE); - status.AppendStatus(LoadPlacementXML(maxTechniqueNode)); - - return status; -} - -// COLLADA 1.3 Backward compatibility: Read in a node from the COLLADA document -FUStatus FCDTexture::LoadFromXML(xmlNode* textureNode) -{ - FUStatus status = FCDEntity::LoadFromXML(textureNode); - if (!status) return status; - if (!IsEquivalent(textureNode->name, DAE_TEXTURE_ELEMENT)) - { - return status.Warning(FS("Texture library contains unknown element."), textureNode->line); - } - - // Read the channel usage for this texture - xmlNode* usageParameterNode = FindChildByType(textureNode, DAE_PARAMETER_ELEMENT); - string channelUsage = ReadNodeName(usageParameterNode); - textureChannel = FUDaeTextureChannel::FromString(channelUsage); - if (textureChannel == FUDaeTextureChannel::UNKNOWN) - { - textureChannel = FUDaeTextureChannel::DEFAULT; - status.Warning(FS("Unknown channel usage for texture: ") + TO_FSTRING(GetDaeId()), textureNode->line); - } - - // Retrieve the common technique and verify that the input node inside points to an image - xmlNode* commonTechniqueNode = FindTechnique(textureNode, DAE_COMMON_PROFILE); - xmlNode* imageInputNode = FindChildByType(commonTechniqueNode, DAE_INPUT_ELEMENT); - string inputSemantic = ReadNodeSemantic(imageInputNode); - if (inputSemantic != DAE_IMAGE_INPUT) - { - status.Warning(FS("Unknown input semantic for texture: ") + TO_FSTRING(GetDaeId()), imageInputNode->line); - } - else - { - // Link to the image input - string imageId = ReadNodeSource(imageInputNode); - if (imageId.empty() || imageId[0] != '#') - { - status.Warning(FS("Unknown or external image source for texture: ") + TO_FSTRING(GetDaeId()), imageInputNode->line); - } - else - { - image = GetDocument()->FindImage(imageId); - if (image == NULL) - { - status.Warning(FS("Unable to find image source: ") + TO_FSTRING(imageId), imageInputNode->line); - } - } - } - - // Read in the Maya-specific texture placement parameters - // and look for a texture program - xmlNode* mayaTechniqueNode = FindTechnique(textureNode, DAEMAYA_MAYA_PROFILE); - status.AppendStatus(LoadPlacementXML(mayaTechniqueNode)); - return status; -} - -// Read in the Maya-specific texture placement parameters and look for a texture program -FUStatus FCDTexture::LoadPlacementXML(xmlNode* techniqueNode) -{ - // This function loads extra functionality, so it should NEVER fail. - // It can throw all the warnings it wants, though! - FUStatus status; - - if (techniqueNode == NULL) return status; - - // Look for some placement 2D parameters - StringList parameterNames; - xmlNodeList parameterNodes; - FindParameters(techniqueNode, parameterNames, parameterNodes); - size_t parameterCount = parameterNames.size(); - for (size_t i = 0; i < parameterCount; ++i) - { - const string& parameterName = parameterNames[i]; - xmlNode* parameterNode = parameterNodes[i]; - const char* content = ReadNodeContentDirect(parameterNode); - if (content == NULL || *content == 0 || parameterName.empty()) continue; - - #define CHECKBOOLPARAM(memberName, paramName2) \ - if (parameterName == paramName2) { \ - memberName = (float) FUStringConversion::ToBoolean(content); \ - FCDAnimatedFloat::Create(GetDocument(), parameterNode, &memberName); \ - hasPlacement2D = true; } else - - #define CHECKFLOATPARAM(memberName, paramName2) \ - if (parameterName == paramName2) { \ - memberName = FUStringConversion::ToFloat(content); \ - FCDAnimatedFloat::Create(GetDocument(), parameterNode, &memberName); \ - hasPlacement2D = true; } else - - CHECKBOOLPARAM(wrapU, DAEMAYA_TEXTURE_WRAPU_PARAMETER) - CHECKBOOLPARAM(wrapV, DAEMAYA_TEXTURE_WRAPV_PARAMETER) - CHECKBOOLPARAM(mirrorU, DAEMAYA_TEXTURE_MIRRORU_PARAMETER) - CHECKBOOLPARAM(mirrorV, DAEMAYA_TEXTURE_MIRRORV_PARAMETER) - CHECKFLOATPARAM(coverageU, DAEMAYA_TEXTURE_COVERAGEU_PARAMETER) - CHECKFLOATPARAM(coverageV, DAEMAYA_TEXTURE_COVERAGEV_PARAMETER) - CHECKFLOATPARAM(translateFrameU, DAEMAYA_TEXTURE_TRANSFRAMEU_PARAMETER) - CHECKFLOATPARAM(translateFrameV, DAEMAYA_TEXTURE_TRANSFRAMEV_PARAMETER) - CHECKFLOATPARAM(rotateFrame, DAEMAYA_TEXTURE_ROTFRAME_PARAMETER) - CHECKBOOLPARAM(stagger, DAEMAYA_TEXTURE_STAGGER_PARAMETER) - CHECKBOOLPARAM(fast, DAEMAYA_TEXTURE_FAST_PARAMETER) - CHECKFLOATPARAM(repeatU, DAEMAYA_TEXTURE_REPEATU_PARAMETER) - CHECKFLOATPARAM(repeatV, DAEMAYA_TEXTURE_REPEATV_PARAMETER) - CHECKFLOATPARAM(offsetU, DAEMAYA_TEXTURE_OFFSETU_PARAMETER) - CHECKFLOATPARAM(offsetV, DAEMAYA_TEXTURE_OFFSETV_PARAMETER) - CHECKFLOATPARAM(rotateUV, DAEMAYA_TEXTURE_ROTATEUV_PARAMETER) - CHECKFLOATPARAM(noiseU, DAEMAYA_TEXTURE_NOISEU_PARAMETER) - CHECKFLOATPARAM(noiseV, DAEMAYA_TEXTURE_NOISEV_PARAMETER) - - CHECKFLOATPARAM(multiplier, DAEMAX_AMOUNT_TEXTURE_PARAMETER) - - #undef CHECKFLOATPARAM - #undef CHECKBOOLPARAM - - if (parameterName == DAEMAYA_TEXTURE_BLENDMODE_PARAMETER || parameterName == DAEMAYA_TEXTURE_BLENDMODE_PARAMETER1_3) - { - blendMode = FUDaeBlendMode::FromString(content); - } - else - { - status.Warning(FS("Unknown texture parameter: ") + TO_FSTRING(parameterName) + FS(" in texture: ") + TO_FSTRING(GetDaeId()), parameterNode->line); - } - } - - xmlNode* mayaProjectionNode = FindChildByType(techniqueNode, DAEMAYA_PROJECTION_ELEMENT); - - // COLLADA 1.3 backward compatibility: check for a , also. - if (mayaProjectionNode == NULL) mayaProjectionNode = FindChildByType(techniqueNode, DAE_PROGRAM_ELEMENT); - if (mayaProjectionNode != NULL) - { - xmlNodeList parameters; - FindChildrenByType(mayaProjectionNode, DAE_PARAMETER_ELEMENT, parameters); - for (xmlNodeList::iterator itP = parameters.begin(); itP != parameters.end(); ++itP) - { - xmlNode* param = *itP; - string paramName = ReadNodeName(param); - const char* content = ReadNodeContentDirect(param); - - if (paramName == DAEMAYA_PROJECTION_TYPE_PARAMETER || paramName == DAEMAYA_PROJECTION_TYPE_PARAMETER1_3) - { - projectionType = TO_FSTRING(content); - } - else if (paramName == DAEMAYA_PROJECTION_MATRIX_PARAMETER || paramName == DAEMAYA_PROJECTION_MATRIX_PARAMETER1_3) - { - FUStringConversion::ToMatrix(&content, projectionMatrix, GetDocument()->GetLengthUnitConversion()); - } - else - { - status.Warning(FS("Unknown projection program parameter: '") + TO_FSTRING(paramName) + FS("' in texture : ") + TO_FSTRING(GetDaeId()), param->line); - } - } - hasProjection3D = true; - } - - return status; -} - -// Write out the texture to the COLLADA xml node tree -xmlNode* FCDTexture::WriteToXML(xmlNode* parentNode) -{ - // Create the element - xmlNode* textureNode = AddChild(parentNode, DAE_TEXTURE_ELEMENT); - AddAttribute(textureNode, DAE_FXSTD_TEXTURE_ATTRIBUTE, image != NULL ? image->GetDaeId() : ""); - AddAttribute(textureNode, DAE_FXSTD_TEXTURESET_ATTRIBUTE, set->GetValue()); - - if (hasPlacement2D || hasProjection3D) - { - // Create the element with the texture placement parameters and their animations - xmlNode* techniqueNode = AddExtraTechniqueChild(textureNode, DAEMAYA_MAYA_PROFILE); - if (hasPlacement2D) - { -#define ADD_PARAM_BOOL(memberName, paramName) { xmlNode* x = AddChild(techniqueNode, paramName, !IsEquivalent(memberName, 0.0f)); GetDocument()->WriteAnimatedValueToXML(&memberName, x, paramName); } -#define ADD_PARAM_FLOAT(memberName, paramName) { xmlNode* x = AddChild(techniqueNode, paramName, memberName); GetDocument()->WriteAnimatedValueToXML(&memberName, x, paramName); } - - ADD_PARAM_BOOL(wrapU, DAEMAYA_TEXTURE_WRAPU_PARAMETER) - ADD_PARAM_BOOL(wrapV, DAEMAYA_TEXTURE_WRAPV_PARAMETER) - ADD_PARAM_BOOL(mirrorU, DAEMAYA_TEXTURE_MIRRORU_PARAMETER) - ADD_PARAM_BOOL(mirrorV, DAEMAYA_TEXTURE_MIRRORV_PARAMETER) - ADD_PARAM_FLOAT(coverageU, DAEMAYA_TEXTURE_COVERAGEU_PARAMETER) - ADD_PARAM_FLOAT(coverageV, DAEMAYA_TEXTURE_COVERAGEV_PARAMETER) - ADD_PARAM_FLOAT(translateFrameU, DAEMAYA_TEXTURE_TRANSFRAMEU_PARAMETER) - ADD_PARAM_FLOAT(translateFrameV, DAEMAYA_TEXTURE_TRANSFRAMEV_PARAMETER) - ADD_PARAM_FLOAT(rotateFrame, DAEMAYA_TEXTURE_ROTFRAME_PARAMETER) - ADD_PARAM_BOOL(stagger, DAEMAYA_TEXTURE_STAGGER_PARAMETER) - ADD_PARAM_BOOL(fast, DAEMAYA_TEXTURE_FAST_PARAMETER) - ADD_PARAM_FLOAT(repeatU, DAEMAYA_TEXTURE_REPEATU_PARAMETER) - ADD_PARAM_FLOAT(repeatV, DAEMAYA_TEXTURE_REPEATV_PARAMETER) - ADD_PARAM_FLOAT(offsetU, DAEMAYA_TEXTURE_OFFSETU_PARAMETER) - ADD_PARAM_FLOAT(offsetV, DAEMAYA_TEXTURE_OFFSETV_PARAMETER) - ADD_PARAM_FLOAT(rotateUV, DAEMAYA_TEXTURE_ROTATEUV_PARAMETER) - ADD_PARAM_FLOAT(noiseU, DAEMAYA_TEXTURE_NOISEU_PARAMETER) - ADD_PARAM_FLOAT(noiseV, DAEMAYA_TEXTURE_NOISEV_PARAMETER) - ADD_PARAM_FLOAT(multiplier, DAEMAX_AMOUNT_TEXTURE_PARAMETER) - -#undef ADD_PARAM_BOOL -#undef ADD_PARAM_FLOAT - - string blendModeValue = FUDaeBlendMode::ToString(blendMode); - AddChild(techniqueNode, DAEMAYA_TEXTURE_BLENDMODE_PARAMETER, blendModeValue); - } - - if (hasProjection3D) - { - xmlNode* projectionNode = AddChild(techniqueNode, DAEMAYA_PROJECTION_ELEMENT); - AddChild(projectionNode, DAEMAYA_PROJECTION_TYPE_PARAMETER, projectionType); - AddChild(projectionNode, DAEMAYA_PROJECTION_MATRIX_PARAMETER, FUStringConversion::ToString(projectionMatrix, GetDocument()->GetLengthUnitConversion())); - } - } - return textureNode; -} diff --git a/Extras/FCollada/FCDocument/FCDTexture.h b/Extras/FCollada/FCDocument/FCDTexture.h deleted file mode 100644 index de0b550f4..000000000 --- a/Extras/FCollada/FCDocument/FCDTexture.h +++ /dev/null @@ -1,451 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDTexture.h - This file contains the FCDTexture class. -*/ - -#ifndef _FCD_TEXTURE_H_ -#define _FCD_TEXTURE_H_ - -#include "FCDocument/FCDEntity.h" -#include "FUtils/FUDaeEnum.h" - -class FCDocument; -class FCDEffectParameter; -class FCDEffectParameterInt; -class FCDEffectParameterList; -class FCDImage; - -/** - A COLLADA texture. - - Textures are used by the COMMON profile materials. For COLLADA 1.3 backward - compatibility, the textures may also be entities contained within - the material library. The ColladaFX profiles use the FCDEffectParameterSampler - and the FCDEffectParameterSurface classes, instead, to hold the texturing information. - - Textures hold the information necessary to place an image onto polygon sets. - This information includes: which texture coordinate set to use, which image - contains the texels, the blend mode, the components of the texture matrix, etc. - - Most of the texturing information does not belong to COLLADA and is specific to - either Maya or 3dsMax. - - @ingroup FCDEffect -*/ -class FCOLLADA_EXPORT FCDTexture : public FCDEntity -{ -private: - FUDaeTextureChannel::Channel textureChannel; // COLLADA 1.3 backward compatibility - FCDImage* image; - string subId; - - // Always preset, this parameter hold the map channel/uv set index - FCDEffectParameterInt* set; - - // Texture color multiplier - float multiplier; // Max-specific - - // Placement parameters. Yes, there's a ton of them [Maya-only] - bool hasProjection3D; - bool hasPlacement2D; - FUDaeBlendMode::Mode blendMode; - - // 2D placement [Maya-only] - float wrapU, wrapV, mirrorU, mirrorV, stagger, fast; // animated, but should really be booleans - float coverageU, coverageV, translateFrameU, translateFrameV, rotateFrame; - float repeatU, repeatV, offsetU, offsetV, rotateUV, noiseU, noiseV; - - // 3D projection [Maya-only] - FMMatrix44 projectionMatrix; - fstring projectionType; - -public: - /** Constructor: do not use directly. - Instead, use the FCDEffectStandard::AddTexture function. - @param document The COLLADA document that owns this texture. */ - FCDTexture(FCDocument* document); - - /** Destructor: do not use directly. - Instead, use the FCDEffectStandard::ReleaseTexture function. */ - virtual ~FCDTexture(); - - /** Retrieves the type of the entity class. - This function is part of the FCDEntity interface and is used - for COLLADA 1.3 backward compatibility. - @return The entity class type: TEXTURE. */ - virtual Type GetType() const { return TEXTURE; } - - /** Retrieves which texture channel to use for this texture. - As it is directly tied in with which buckets holds this texture, you - cannot modify this value. Instead, create a new texture in the correct - bucket of the FCDEffectStandard object. - @return The texture channel. */ - FUDaeTextureChannel::Channel GetTextureChannel() const { return textureChannel; } - - /** Retrieves the image information for this texture. - @return The image. This pointer will be NULL if this texture is not yet - tied to a valid image. */ - FCDImage* GetImage() { return image; } - const FCDImage* GetImage() const { return image; } /**< See above. */ - - /** Sets the image to be used with this texture. - @param _image An image. */ - void SetImage(FCDImage* _image) { image = _image; } - - /** Retrieves the texture coordinate set to use with this texture. - This information is duplicated from the material instance abstraction level. - @return The effect parameter containing the set. */ - FCDEffectParameterInt* GetSet() { return set; } - const FCDEffectParameterInt* GetSet() const { return set; } /**< See above. */ - - /** Retrieves the blend mode to use if this texture is not the first one - within its channel's bucket. - @return The blend mode. */ - FUDaeBlendMode::Mode GetBlendMode() const { return blendMode; } - - /** Sets the blend mode to use if this texture is not the first one - within its channel's bucket. - @param mode The blend mode. */ - void SetBlendMode(FUDaeBlendMode::Mode mode) { blendMode = mode; } - - /** @deprecated Retrieves the sub-id of the texture. - @return The sub-id. */ - const string& GetSubId() const { return subId; } - - /** @deprecated Sets the sub-id of the texture. - @param _subId The sub-id. */ - void SetSubId(const string& _subId) { subId = _subId; } - - /** Retrieves the generic multiplier to apply on the texture. - This parameter is specific to ColladaMax. The meaning of this parameter - depends on the channel that the texture belongs to. - This value is animatable. - @return The generic multiplier. */ - float& GetMultiplier() { return multiplier; } - const float& GetMultiplier() const { return multiplier; } /**< See above. */ - - /** Sets the generic multiplier. - This parameter is specific to ColladaMax. The meaning of this parameter - depends on the channel that the texture belongs to. - @param _multiplier The generic multiplier. */ - void SetMultiplier(float _multiplier) { multiplier = _multiplier; } - - /** Retrieves whether the texturing information includes the - ColladaMaya-specific 2D placement parameters. - @return Whether the ColladaMaya-specific 2D placement parameters are valid. */ - bool HasPlacement2D() const { return hasPlacement2D; } - - /** Removes the ColladaMaya-specific 2D placement parameters and resets them. */ - void ClearPlacement2D(); - - /** Retrieves whether to wrap the U texture coordinates. - This parameter is specific to ColladaMaya. This value is a float because - it is animatable: it should be interpreted as a boolean. - @return Whether to wrap the U texture coordinates. */ - float& GetWrapU() { return wrapU; } - const float& GetWrapU() const { return wrapU; } /**< See above. */ - - /** Sets whether to wrap the U texture coordinates. - This parameter is specific to ColladaMaya. - @param _wrapU Whether to wrap the U texture coordinate. */ - void SetWrapU(bool _wrapU) { wrapU = _wrapU ? 1.0f : 0.0f; hasPlacement2D = true; } - - /** Retrieves whether to wrap the V texture coordinates. - This parameter is specific to ColladaMaya. This value is a float because - it is animatable: it should be interpreted as a boolean. - @return Whether to wrap the V texture coordinates. */ - float& GetWrapV() { return wrapV; } - const float& GetWrapV() const { return wrapV; } /**< See above. */ - - /** Sets whether to wrap the V texture coordinates. - This parameter is specific to ColladaMaya. - @param _wrapV Whether to wrap the V texture coordinate. */ - void SetWrapV(bool _wrapV) { wrapV = _wrapV ? 1.0f : 0.0f; hasPlacement2D = true; } - - /** Retrieves whether to mirror the U texture coordinates. - This parameter is specific to ColladaMaya. This value is a float - because it is animatable: it should be interpreted as a boolean. - @return Whether to mirror the U texture coordinate. */ - float& GetMirrorU() { return mirrorU; } - const float& GetMirrorU() const { return mirrorU; } /**< See above. */ - - /** Sets whether to mirror the U texture coordinates. - This parameter is specific to ColladaMaya. - @param _mirrorU Whether to mirror the U texture coordinates. */ - void SetMirrorU(bool _mirrorU) { mirrorU = _mirrorU ? 1.0f : 0.0f; hasPlacement2D = true; } - - /** Retrieves whether to mirror the V texture coordinates. - This parameter is specific to ColladaMaya. This value is a float - because it is animatable: it should be interpreted as a boolean. - @return Whether to mirror the V texture coordinate. */ - float& GetMirrorV() { return mirrorV; } - const float& GetMirrorV() const { return mirrorV; } /**< See above. */ - - /** Sets whether to mirror the V texture coordinates. - This parameter is specific to ColladaMaya. - @param _mirrorV Whether to mirror the V texture coordinates. */ - void SetMirrorV(bool _mirrorV) { mirrorV = _mirrorV ? 1.0f : 0.0f; hasPlacement2D = true; } - - /** Retrieves whether to stagger the texture. - This parameter is specific to ColladaMaya. This value is a float - because it is animatable: it should be interpreted as a boolean. - @return Whether to stagger the texture. */ - float& GetStagger() { return stagger; } - const float& GetStagger() const { return stagger; } /**< See above. */ - - /** Sets whether to stagger the texture. - This parameter is specific to ColladaMaya. - @param _stagger Whether to stagger the texture. */ - void SetStagger(bool _stagger) { stagger = _stagger ? 1.0f : 0.0f; hasPlacement2D = true; } - - /** Retrieves the 'fast' flag. - This parameter is specific to ColladaMaya. This value is a float - because it is animatable: it should be interpreted as a boolean. - This parameter has no meaning outside of Maya. - @return The 'fast' flag. */ - float& GetFast() { return fast; } - const float& GetFast() const { return fast; } /**< See above. */ - - /** Sets the 'fast' flag. - This parameter is specific to ColladaMaya and has no meaning - outside of Maya. - @param _fast The 'fast' flag. */ - void SetFast(bool _fast) { fast = _fast ? 1.0f : 0.0f; hasPlacement2D = true; } - - /** Retrieves the scale factor of the texture frame, in the U coordinates. - This parameter is specific to ColladaMaya. - This value is animatable. For more information on this parameter, - check the Maya documentation. - @return The scale factor. */ - float& GetCoverageU() { return coverageU; } - const float& GetCoverageU() const { return coverageU; } /**< See above. */ - - /** Sets the scale factor of the texture frame, in the U coordinates. - This parameter is specific to ColladaMaya. - @param _coverageU The scale factor. */ - void SetCoverageU(float _coverageU) { coverageU = _coverageU; hasPlacement2D = true; } - - /** Retrieves the scale factor of the texture frame, in the V coordinates. - This parameter is specific to ColladaMaya. - This value is animatable. For more information on this parameter, - check the Maya documentation. - @return The scale factor. */ - float& GetCoverageV() { return coverageV; } - const float& GetCoverageV() const { return coverageV; } /**< See above. */ - - /** Sets the scale factor of the texture frame, in the V coordinates. - This parameter is specific to ColladaMaya. - @param _coverageV The scale factor. */ - void SetCoverageV(float _coverageV) { coverageV = _coverageV; hasPlacement2D = true; } - - /** Retrieves the translation of the texture frame, in the U coordinate. - This parameter is specific to ColladaMaya. - This value is animatable. For more information on this parameter, - check the Maya documentation. - @return The translation offset. */ - float& GetTranslateFrameU() { return translateFrameU; } - const float& GetTranslateFrameU() const { return translateFrameU; } /**< See above. */ - - /** Sets the translation of the texture frame, in the U coordinate. - This parameter is specific to ColladaMaya. - For more information on this parameter, check the Maya documentation. - @param _translateFrameU The translation offset. */ - void SetTranslateFrameU(float _translateFrameU) { translateFrameU = _translateFrameU; hasPlacement2D = true; } - - /** Retrieves the translation of the texture frame, in the V coordinate. - This parameter is specific to ColladaMaya. - This value is animatable. For more information on this parameter, - check the Maya documentation. - @return The translation offset. */ - float& GetTranslateFrameV() { return translateFrameV; } - const float& GetTranslateFrameV() const { return translateFrameV; } /**< See above. */ - - /** Sets the translation of the texture frame, in the V coordinate. - This parameter is specific to ColladaMaya. - For more information on this parameter, check the Maya documentation. - @param _translateFrameV The translation offset. */ - void SetTranslateFrameV(float _translateFrameV) { translateFrameV = _translateFrameV; hasPlacement2D = true; } - - /** Retrieves the angle of rotation of the texture frame. - This parameter is specific to ColladaMaya. - This value is animatable. For more information on this parameter, - check the Maya documentation. - @return The angle of rotation (in degrees). */ - float& GetRotateFrame() { return rotateFrame; } - const float& GetRotateFrame() const { return rotateFrame; } /**< See above. */ - - /** Sets the angle of rotation of the texture frame. - This parameter is specific to ColladaMaya. - For more information on this parameter, check the Maya documentation. - @param _rotateFrame The angle of rotation (in degrees). */ - void SetRotateFrame(float _rotateFrame) { rotateFrame = _rotateFrame; hasPlacement2D = true; } - - /** Retrieves the scale factor applied on the U coordinates of the rendered polygons. - This parameter is specific to ColladaMaya. This value is animatable. - @return The scale factor. */ - float& GetRepeatU() { return repeatU; } - const float& GetRepeatU() const { return repeatU; } /**< See above. */ - - /** Sets the scale factor applied on the U coordinates of the rendered polygons. - This parameter is specific to ColladaMaya. - @param _repeatU The scale factor. */ - void SetRepeatU(float _repeatU) { repeatU = _repeatU; hasPlacement2D = true; } - - /** Retrieves the scale factor applied on the V coordinates of the rendered polygons. - This parameter is specific to ColladaMaya. This value is animatable. - @return The scale factor. */ - float& GetRepeatV() { return repeatV; } - const float& GetRepeatV() const { return repeatV; } /**< See above. */ - - /** Sets the scale factor applied on the V coordinates of the rendered polygons. - This parameter is specific to ColladaMaya. - @param _repeatV The scale factor. */ - void SetRepeatV(float _repeatV) { repeatV = _repeatV; hasPlacement2D = true; } - - /** Retrieves the translation offset applied on the U coordinates of the rendered polygons. - This parameter is specific to ColladaMaya. This value is animatable. - @return The translation offset. */ - float& GetOffsetU() { return offsetU; } - const float& GetOffsetU() const { return offsetU; } /**< See above. */ - - /** Sets the translation offset applied on the U coordinates of the rendered polygons. - This parameter is specific to ColladaMaya. - @param _offsetU The translation offset. */ - void SetOffsetU(float _offsetU) { offsetU = _offsetU; hasPlacement2D = true; } - - /** Retrieves the translation offset applied on the V coordinates of the rendered polygons. - This parameter is specific to ColladaMaya. This value is animatable. - @return The translation offset. */ - float& GetOffsetV() { return offsetV; } - const float& GetOffsetV() const { return offsetV; } /**< See above. */ - - /** Sets the translation offset applied on the V coordinates of the rendered polygons. - This parameter is specific to ColladaMaya. - @param _offsetV The translation offset. */ - void SetOffsetV(float _offsetV) { offsetV = _offsetV; hasPlacement2D = true; } - - /** Retrieves the rotation angle applied on the texture coordinates of the rendered polygons. - This parameter is specific to ColladaMaya. This value is animatable. - @return The rotation angle (in degrees). */ - float& GetRotateUV() { return rotateUV; } - const float& GetRotateUV() const { return rotateUV; } /**< See above. */ - - /** Sets the rotation angle applied on the texture coordinates of the rendered polygons. - This parameter is specific to ColladaMaya. This value is animatable. - @param _rotateUV The rotation angle (in degrees). */ - void SetRotateUV(float _rotateUV) { rotateUV = _rotateUV; hasPlacement2D = true; } - - /** Retrieves the maxmimum amount of noise to add to each of the U coordinates of the rendered polygons. - This parameter is specific to ColladaMaya. This value is animatable. - @return The maxmimum amount of noise. */ - float& GetNoiseU() { return noiseU; } - const float& GetNoiseU() const { return noiseU; } /**< See above. */ - - /** Sets the maximum amount of noise to add to each of the U coordinates of the rendered polygons. - This parameter is specific to ColladaMaya. - @param _noiseU The maximum amount of noise. */ - void SetNoiseU(float _noiseU) { noiseU = _noiseU; hasPlacement2D = true; } - - /** Retrieves the maxmimum amount of noise to add to each of the V coordinates of the rendered polygons. - This parameter is specific to ColladaMaya. This value is animatable. - @return The maxmimum amount of noise. */ - float& GetNoiseV() { return noiseV; } - const float& GetNoiseV() const { return noiseV; } /**< See above. */ - - /** Sets the maximum amount of noise to add to each of the V coordinates of the rendered polygons. - This parameter is specific to ColladaMaya. - @param _noiseV The maximum amount of noise. */ - void SetNoiseV(float _noiseV) { noiseV = _noiseV; hasPlacement2D = true; } - - /** Retrieves whether the texturing information includes the - ColladaMaya-specific 3D projection parameters. - @return Whether the ColladaMaya-specific 3D projection parameters are valid. */ - bool HasProjection3D() const { return hasProjection3D; } - - /** Removes the ColladaMaya-specific 3D projection parameters and resets them. */ - void ClearProjection3D(); - - /** Retrieves the texture projection matrix. - This matrix transforms the 3D texture coordinates into valid 2D texture coordinates. - This parameter is specific to ColladaMaya. - @return The texture projection matrix. */ - FMMatrix44& GetProjectionMatrix() { return projectionMatrix; } - const FMMatrix44& GetProjectionMatrix() const { return projectionMatrix; } /**< See above. */ - - /** Sets the texture projection matrix. - This matrix transforms the 3D texture coordinates into valid 2D texture coordinates. - This parameter is specific to ColladaMaya. - @param matrix The texture projection matrix. */ - void SetProjectionMatrix(const FMMatrix44& matrix) { projectionMatrix = matrix; hasProjection3D = true; } - - /** Retrieves the type of projection to use on the 3D texture coordinates. - This parameter is specific to ColladaMaya. - @return The type string. */ - const fstring& GetProjectionType() const { return projectionType; } - - /** Sets the type of projection to use on the 3D texture coordinates. - This paramter is specific to ColladaMaya. - @param type The type string. */ - void SetProjectionType(const fstring& type) { projectionType = type; hasProjection3D = true; } - - /** Retrieves an effect parameter. - Looks for the effect parameter with the correct semantic, in order to bind or override its value. - This function compares the local effect parameters with the given semantic. - @param semantic The effect parameter semantic to match. - @return The effect parameter that matches the semantic. This pointer may be - NULL if no effect parameter matches the given semantic. */ - FCDEffectParameter* FindParameterBySemantic(const string& semantic); - - /** Retrieves a subset of the local effect parameter list. - Look for local effect parameters with the correct semantic. - This function searches through the effect profile and the level of abstractions below. - @param semantic The effect parameter semantic to match. - @param parameters The list of parameters to fill in. This list is not cleared. */ - void FindParametersBySemantic(const string& semantic, FCDEffectParameterList& parameters); - - /** Retrieves a subset of the local effect parameter list. - Look for the local effect parameter with the correct reference. - @param reference The effect parameter reference to match. - @param parameters The list of parameters to fill in. This list is not cleared. */ - void FindParametersByReference(const string& reference, FCDEffectParameterList& parameters); - - /** [INTERNAL] Clones the texture. - Does not clone the image: both texture objects will point to the same image object. - @return The cloned texture. This pointer will never be NULL. */ - FCDTexture* Clone(); - - /** [INTERNAL] Reads in the texture from a given COLLADA XML tree node. - @param textureNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the texture.*/ - FUStatus LoadFromTextureXML(xmlNode* textureNode); - - /** [INTERNAL] Reads in the texture from a given COLLADA XML tree node. - This function is useful only for COLLADA 1.3 backward compatibility. - @param textureNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the texture.*/ - virtual FUStatus LoadFromXML(xmlNode* textureNode); - - /** [INTERNAL] Writes out the texture to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the texture. - @return The created element XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode); - -private: - // Read in the Maya-specific texture placement parameters and look for a texture projection program - FUStatus LoadPlacementXML(xmlNode* techniqueNode); -}; - -#endif // _FCD_TEXTURE_H_ diff --git a/Extras/FCollada/FCDocument/FCDTransform.cpp b/Extras/FCollada/FCDocument/FCDTransform.cpp deleted file mode 100644 index 4cf895346..000000000 --- a/Extras/FCollada/FCDocument/FCDTransform.cpp +++ /dev/null @@ -1,418 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDAnimated.h" -#include "FCDocument/FCDTransform.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -#include "FUtils/FUStringConversion.h" - -#ifdef HAS_MAYATYPES -#include -#endif - -FCDTTranslation::FCDTTranslation(FCDocument* document, FCDSceneNode* parent) : FCDTransform(document, parent) {} -FCDTTranslation::~FCDTTranslation() {} - -FCDTransform* FCDTTranslation::Clone(FCDSceneNode* newParent) -{ - FCDTTranslation* t = new FCDTTranslation(GetDocument(), newParent); - t->translation = translation; - if(IsAnimated()) - GetAnimated()->Clone(GetDocument()); - return t; -} - -// Parse a node from the COLLADA document -FUStatus FCDTTranslation::LoadFromXML(xmlNode* node) -{ - float lengthFactor = GetDocument()->GetLengthUnitConversion(); - - const char* content = FUDaeParser::ReadNodeContentDirect(node); - FloatList factors; - factors.reserve(3); - FUStringConversion::ToFloatList(content, factors); - if (factors.size() != 3) return FUStatus(false); - - translation.x = factors[0] * lengthFactor; - translation.y = factors[1] * lengthFactor; - translation.z = factors[2] * lengthFactor; - FCDAnimatedPoint3::Create(GetDocument(), node, &translation); - return FUStatus(true); -} - -// Write the node to the COLLADA xml document -xmlNode* FCDTTranslation::WriteToXML(xmlNode* parentNode) const -{ - string content = FUStringConversion::ToString(translation); - xmlNode* transformNode = FUDaeWriter::AddChild(parentNode, DAE_TRANSLATE_ELEMENT, content); - GetDocument()->WriteAnimatedValueToXML(&translation.x, transformNode, "translation"); - return transformNode; -} - -FMMatrix44 FCDTTranslation::ToMatrix() const -{ - return FMMatrix44::TranslationMatrix(translation); -} - -FCDAnimated* FCDTTranslation::GetAnimated() -{ - // Returns a FCDAnimatedAngleAxis - return GetDocument()->FindAnimatedValue(&translation.x); -} - -bool FCDTTranslation::IsAnimated() const -{ - // Only need to check against the first value, because we created a FCDAnimatedPoint3 - return GetDocument()->IsValueAnimated(&translation.x); -} - -bool FCDTTranslation::IsInverse(const FCDTransform* transform) const -{ - return transform->GetType() == FCDTransform::TRANSLATION - && IsEquivalent(-1.0f * translation, ((const FCDTTranslation*)transform)->translation); -} - -FCDTRotation::FCDTRotation(FCDocument* document, FCDSceneNode* parent) : FCDTransform(document, parent) {} -FCDTRotation::~FCDTRotation() {} - -FCDTransform* FCDTRotation::Clone(FCDSceneNode* newParent) -{ - FCDTRotation* t = new FCDTRotation(GetDocument(), newParent); - t->angle = angle; - t->axis = axis; - if(IsAnimated()) - GetAnimated()->Clone(GetDocument()); - return t; -} -// Parse a node from the COLLADA document -FUStatus FCDTRotation::LoadFromXML(xmlNode* node) -{ - const char* content = FUDaeParser::ReadNodeContentDirect(node); - FloatList factors; - factors.reserve(4); - FUStringConversion::ToFloatList(content, factors); - if (factors.size() != 4) return FUStatus(false); - - axis.x = factors[0]; axis.y = factors[1]; axis.z = factors[2]; - angle = factors[3]; - FCDAnimatedAngleAxis::Create(GetDocument(), node, &axis, &angle); - return FUStatus(true); -} - -// Write the node to the COLLADA xml document -xmlNode* FCDTRotation::WriteToXML(xmlNode* parent) const -{ - globalSBuilder.clear(); - FUStringConversion::ToString(globalSBuilder, axis); globalSBuilder += ' '; globalSBuilder += angle; - xmlNode* transformNode = FUDaeWriter::AddChild(parent, DAE_ROTATE_ELEMENT, globalSBuilder); - GetDocument()->WriteAnimatedValueToXML(&axis.x, transformNode, "rotation"); - return transformNode; -} - -FMMatrix44 FCDTRotation::ToMatrix() const -{ - return FMMatrix44::AxisRotationMatrix(axis, FMath::DegToRad(angle)); -} - -FCDAnimated* FCDTRotation::GetAnimated() -{ - // Returns a FCDAnimatedAngleAxis - return GetDocument()->FindAnimatedValue(&axis.x); -} - -bool FCDTRotation::IsAnimated() const -{ - // For the axis, we only need to check against the first value, because we created a FCDAnimatedAngleAxis - return GetDocument()->IsValueAnimated(&axis.x); -} - -bool FCDTRotation::IsInverse(const FCDTransform* transform) const -{ - return transform->GetType() == FCDTransform::TRANSLATION - && IsEquivalent(axis, ((const FCDTRotation*)transform)->axis) - && IsEquivalent(-angle, ((const FCDTRotation*)transform)->angle); -} - -FCDTScale::FCDTScale(FCDocument* document, FCDSceneNode* parent) : FCDTransform(document, parent) {} -FCDTScale::~FCDTScale() {} - -FCDTransform* FCDTScale::Clone(FCDSceneNode* newParent) -{ - FCDTScale* t = new FCDTScale(GetDocument(), newParent); - t->scale = scale; - if(IsAnimated()) - GetAnimated()->Clone(GetDocument()); - return t; -} - -// Parse a node from the COLLADA document -FUStatus FCDTScale::LoadFromXML(xmlNode* node) -{ - const char* content = FUDaeParser::ReadNodeContentDirect(node); - FloatList factors; - factors.reserve(3); - FUStringConversion::ToFloatList(content, factors); - if (factors.size() != 3) return FUStatus(false); - - scale.x = factors[0]; scale.y = factors[1]; scale.z = factors[2]; - - // Register the animated values - FCDAnimatedPoint3::Create(GetDocument(), node, &scale); - - return FUStatus(true); -} - -// Write the node to the COLLADA xml document -xmlNode* FCDTScale::WriteToXML(xmlNode* parentNode) const -{ - string content = FUStringConversion::ToString(scale); - xmlNode* transformNode = FUDaeWriter::AddChild(parentNode, DAE_SCALE_ELEMENT, content); - GetDocument()->WriteAnimatedValueToXML(&scale.x, transformNode, "scale"); - return transformNode; -} - -FMMatrix44 FCDTScale::ToMatrix() const -{ - FMMatrix44 mx = FMMatrix44::Identity; - mx[0][0] = scale.x; mx[1][1] = scale.y; mx[2][2] = scale.z; - return mx; -} - -FCDAnimated* FCDTScale::GetAnimated() -{ - // Returns a FCDAnimatedPoint3 - return GetDocument()->FindAnimatedValue(&scale.x); -} - -bool FCDTScale::IsAnimated() const -{ - // We only need to check against the first value, because we created a FCDAnimatedPoint3 - return GetDocument()->IsValueAnimated(&scale.x); -} - -FCDTMatrix::FCDTMatrix(FCDocument* document, FCDSceneNode* parent) : FCDTransform(document, parent) {} -FCDTMatrix::~FCDTMatrix() {} - -FCDTransform* FCDTMatrix::Clone(FCDSceneNode* newParent) -{ - FCDTMatrix* t = new FCDTMatrix(GetDocument(), newParent); - t->transform = transform; - if(IsAnimated()) - GetAnimated()->Clone(GetDocument()); - return t; -} -// Parse a node from the COLLADA document -FUStatus FCDTMatrix::LoadFromXML(xmlNode* node) -{ - const char* content = FUDaeParser::ReadNodeContentDirect(node); - FUStringConversion::ToMatrix(&content, transform, GetDocument()->GetLengthUnitConversion()); - - // Register the matrix in the animation system for transform animations - FCDAnimatedMatrix::Create(GetDocument(), node, &transform); - - return FUStatus(true); -} - -// Write the node to the COLLADA xml document -xmlNode* FCDTMatrix::WriteToXML(xmlNode* parentNode) const -{ - string content = FUStringConversion::ToString(transform); - xmlNode* transformNode = FUDaeWriter::AddChild(parentNode, DAE_MATRIX_ELEMENT, content); - GetDocument()->WriteAnimatedValueToXML(&transform[0][0], transformNode, "transform"); - return transformNode; -} - -FCDAnimated* FCDTMatrix::GetAnimated() -{ - // Returns a FCDAnimatedMatrix - return GetDocument()->FindAnimatedValue(&transform[0][0]); -} - -bool FCDTMatrix::IsAnimated() const -{ - // We only need to check against the first value, because we created a FCDAnimatedMatrix - return GetDocument()->IsValueAnimated(&transform[0][0]); -} - -FCDTLookAt::FCDTLookAt(FCDocument* document, FCDSceneNode* parent) : FCDTransform(document, parent) {} -FCDTLookAt::~FCDTLookAt() {} - -FCDTransform* FCDTLookAt::Clone(FCDSceneNode* newParent) -{ - FCDTLookAt* t = new FCDTLookAt(GetDocument(), newParent); - t->position = position; - t->target = target; - t->up = up; - return t; -} -// Parse a node from the COLLADA document -FUStatus FCDTLookAt::LoadFromXML(xmlNode* lookAtNode) -{ - float lengthFactor = GetDocument()->GetLengthUnitConversion(); - const char* content = FUDaeParser::ReadNodeContentDirect(lookAtNode); - FloatList factors; - factors.reserve(9); - FUStringConversion::ToFloatList(content, factors); - if (factors.size() != 9) return FUStatus(false); - - position.x = factors[0] * lengthFactor; position.y = factors[1] * lengthFactor; position.z = factors[2] * lengthFactor; - target.x = factors[3] * lengthFactor; target.y = factors[4] * lengthFactor; target.z = factors[5] * lengthFactor; - up.x = factors[6]; up.y = factors[7]; up.z = factors[8]; - - return FUStatus(true); -} - -// Write the node to the COLLADA xml document -xmlNode* FCDTLookAt::WriteToXML(xmlNode* parentNode) const -{ - globalSBuilder.clear(); - FUStringConversion::ToString(globalSBuilder, position); globalSBuilder += ' '; - FUStringConversion::ToString(globalSBuilder, target); globalSBuilder += ' '; - FUStringConversion::ToString(globalSBuilder, up); - xmlNode* transformNode = FUDaeWriter::AddChild(parentNode, DAE_LOOKAT_ELEMENT, globalSBuilder); - return transformNode; -} - -FMMatrix44 FCDTLookAt::ToMatrix() const -{ - FMMatrix44 mx = FMMatrix44::Identity; - FMVector3 front = ((FMVector3)(position - target)).Normalize(); - FMVector3 side = ((FMVector3)(up ^ front)).Normalize(); - - mx[0][0] = side.x; mx[0][1] = side.y; mx[0][2] = side.z; - mx[1][0] = up.x; mx[1][1] = up.y; mx[1][2] = up.z; - mx[2][0] = front.x; mx[2][1] = front.y; mx[2][2] = front.z; - mx[3][0] = position.x; mx[3][1] = position.y; mx[3][2] = position.z; - - return mx; -} - -FCDAnimated* FCDTLookAt::GetAnimated() -{ - // Does not support animations - return NULL; -} - -bool FCDTLookAt::IsAnimated() const -{ - // Does not support animations - return false; -} - -FCDTSkew::FCDTSkew(FCDocument* document, FCDSceneNode* parent) : FCDTransform(document, parent) {} -FCDTSkew::~FCDTSkew() {} -FCDTransform* FCDTSkew::Clone(FCDSceneNode* newParent) -{ - FCDTSkew* t = new FCDTSkew(GetDocument(), newParent); - t->rotateAxis = rotateAxis; - t->aroundAxis = aroundAxis; - t->angle = angle; - return t; -} - -// Parse a element from the COLLADA document -FUStatus FCDTSkew::LoadFromXML(xmlNode* skewNode) -{ - const char* content = FUDaeParser::ReadNodeContentDirect(skewNode); - FloatList factors; - factors.reserve(7); - FUStringConversion::ToFloatList(content, factors); - if (factors.size() != 7) return FUStatus(false); - - angle = factors[0]; - rotateAxis.x = factors[1]; rotateAxis.y = factors[2]; rotateAxis.z = factors[3]; - aroundAxis.x = factors[4]; aroundAxis.y = factors[5]; aroundAxis.z = factors[6]; - - // Check and pre-process the axises - if (IsEquivalent(rotateAxis, FMVector3::Origin) || IsEquivalent(aroundAxis, FMVector3::Origin)) return FUStatus(false); - rotateAxis = rotateAxis.Normalize(); - aroundAxis = aroundAxis.Normalize(); - - // Register the animated values - FCDAnimatedAngle::Create(GetDocument(), skewNode, &angle); - - return FUStatus(true); -} - -// Write the node to the COLLADA xml document -xmlNode* FCDTSkew::WriteToXML(xmlNode* parentNode) const -{ - globalSBuilder.clear(); - globalSBuilder.set(angle); globalSBuilder += ' '; - FUStringConversion::ToString(globalSBuilder, rotateAxis); globalSBuilder += ' '; - FUStringConversion::ToString(globalSBuilder, aroundAxis); - xmlNode* transformNode = FUDaeWriter::AddChild(parentNode, DAE_SKEW_ELEMENT, globalSBuilder); - GetDocument()->WriteAnimatedValueToXML(&angle, transformNode, "skew"); - return transformNode; -} - -FMMatrix44 FCDTSkew::ToMatrix() const -{ - float v[4][4]; - - float s = tanf(FMath::DegToRad(angle)); - - for (int row = 0; row < 3; ++row) - { - for (int col = 0; col < 3; ++col) - { - v[col][row] = ((row == col) ? 1.0f : 0.0f) + s * rotateAxis[col] * aroundAxis[row]; - } - } - - v[0][3] = v[1][3] = v[2][3] = 0.0f; - v[3][0] = v[3][1] = v[3][2] = 0.0f; - v[3][3] = 1.0f; - - return FMMatrix44((float*) v); -} - -FCDAnimated* FCDTSkew::GetAnimated() -{ - return GetDocument()->FindAnimatedValue(&angle); -} - -bool FCDTSkew::IsAnimated() const -{ - // Only angle may be animated for now. - return GetDocument()->IsValueAnimated(&angle); -} - -// Creates a new COLLADA transform, given a transform type. -FCDTransform* FCDTFactory::CreateTransform(FCDocument* document, FCDSceneNode* parent, FCDTransform::Type type) -{ - switch (type) - { - case FCDTransform::TRANSLATION: return new FCDTTranslation(document, parent); - case FCDTransform::ROTATION: return new FCDTRotation(document, parent); - case FCDTransform::SCALE: return new FCDTScale(document, parent); - case FCDTransform::SKEW: return new FCDTSkew(document, parent); - case FCDTransform::MATRIX: return new FCDTMatrix(document, parent); - case FCDTransform::LOOKAT: return new FCDTLookAt(document, parent); - default: return NULL; - } -} - -// Imports a COLLADA transform, given an XML tree node. -FCDTransform* FCDTFactory::CreateTransform(FCDocument* document, FCDSceneNode* parent, xmlNode* node) -{ - FCDTransform* transform = NULL; - 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_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_MATRIX_ELEMENT)) transform = new FCDTMatrix(document, parent); - else if (IsEquivalent(node->name, DAE_LOOKAT_ELEMENT)) transform = new FCDTLookAt(document, parent); - return transform; -} diff --git a/Extras/FCollada/FCDocument/FCDTransform.h b/Extras/FCollada/FCDocument/FCDTransform.h deleted file mode 100644 index 0e2aade66..000000000 --- a/Extras/FCollada/FCDocument/FCDTransform.h +++ /dev/null @@ -1,660 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDTransform.h - This file contains the FCDTransform class and its up-classes: - FCDTTranslation, FCDTScale, FCDTRotation, FCDTMatrix, FCDTLookAt and FCDTSkew. -*/ - -#ifndef _FCD_TRANSFORM_H_ -#define _FCD_TRANSFORM_H_ - -class FCDocument; -class FCDSceneNode; - -#include "FCDocument/FCDObject.h" - -/** - A COLLADA transform. - - COLLADA supports six transformation types: translations(FCDTTranslation), - rotations(FCDTRotation), scales(FCDTScale), matrices(FCDTMatrix), - skews(FCDTSkew) and the 'look-at' transform(FCDTLookAt). - - @ingroup FCDocument -*/ -class FCOLLADA_EXPORT FCDTransform : public FCDObject -{ -public: - /** The COLLADA transform types. */ - enum Type - { - TRANSLATION, /**< A translation(FCDTTranslation). */ - ROTATION, /**< A rotation(FCDTRotation). */ - SCALE, /**< A non-uniform scale(FCDTScale). */ - MATRIX, /**< A matrix multiplication(FCDTMatrix). */ - LOOKAT, /**< A targeted, 'look-at' transformation(FCDTLookAt). */ - SKEW /**< A skew(FCDTSkew). */ - }; - -private: - FCDSceneNode* parent; - -public: - /** Constructor: do not use directly. - Instead, use the FCDSceneNode::AddTransform function. - @param document The COLLADA document that owns the transform. - @param _parent The visual scene node that contains the transform. - Set this pointer to NULL if this transform is not owned by a - visual scene node. */ - FCDTransform(FCDocument* document, FCDSceneNode* _parent) : FCDObject(document, "FCDTransform") { parent = _parent; } - - /** Destructor: do not use directly. - Instead, use the FCDSceneNode::ReleaseTransform function. */ - virtual ~FCDTransform() { parent = NULL; } - - /** Retrieves the visual scene node that contains this transformation. - @return The parent visual scene node. This pointer will be NULL - if the transformation is not contained by a visual scene node. */ - FCDSceneNode* GetParent() { return parent; } - const FCDSceneNode* GetParent() const { return parent; } /**< See above. */ - - /** Creates a copy of a transformation. - @param newParent The visual scene node that will contain the clone. - @return The cloned transformation. */ - virtual FCDTransform* Clone(FCDSceneNode* newParent) = 0; - - /** Retrieves the class type of the transformation. - The class type should be used to up-case the transformation pointer. - @return The class type. */ - virtual Type GetType() const = 0; - - /** Converts the transformation into a matrix. - Useful for visual scene nodes with a weird transformation stack. - @return A matrix equivalent of the transformation. */ - virtual FMMatrix44 ToMatrix() const = 0; - - /** Retrieves whether this transformation has an animation tied to its values. - @return Whether the transformation is animated. */ - virtual bool IsAnimated() const = 0; - - /** Retrieves the animated element for the transformation. - @return The animated element. This pointer will be NULL if the transformation - is not animated. */ - virtual FCDAnimated* GetAnimated() = 0; - - /** Retrieves whether a given transformation is the exact opposite of - this transformation. Executing two opposite transformations, one after the - other will not give any resulting transformation. This function is useful - to detect pivots within the transform stack. - @param UNUSED A second transformation. - @return Whether the two transformations are opposites. */ - virtual bool IsInverse(const FCDTransform* UNUSED(transform)) const { return false; } - - /** [INTERNAL] Reads in the transformation from a given COLLADA XML tree node. - @param transformNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the transformation.*/ - virtual FUStatus LoadFromXML(xmlNode* transformNode) = 0; - - /** [INTERNAL] Writes out the transformation to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the transformation. - @return The created XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const = 0; -}; - -/** - A COLLADA translation. - A translation is a simple 3D displacement. - - @ingroup FCDocument -*/ -class FCOLLADA_EXPORT FCDTTranslation : public FCDTransform -{ -private: - FMVector3 translation; - -public: - /** Constructor: do not use directly. - Instead, use the FCDSceneNode::AddTransform function with - the TRANSLATION transformation type. - @param document The COLLADA document that owns the translation. - @param parent The visual scene node that contains the translation. - Set this pointer to NULL if the translation is not owned - by a visual scene node. */ - FCDTTranslation(FCDocument* document, FCDSceneNode* parent); - - /** Destructor: do not use directly. - Instead, use the FCDSceneNode::ReleaseTransform function. */ - virtual ~FCDTTranslation(); - - /** Retrieves the transformation class type for the translation. - @return The transformation class type: TRANSLATION. */ - virtual Type GetType() const { return TRANSLATION; } - - /** Retrieves the translation 3D displacement vector. - This displacement vector may be animated. - @return The displacement vector. */ - inline FMVector3& GetTranslation() { return translation; } - inline const FMVector3& GetTranslation() const { return translation; } /**< See above. */ - - /** Sets the translation 3D displacement vector. - @param _translation The displacement vector. */ - inline void SetTranslation(const FMVector3& _translation) { translation = _translation; } - - /** Sets the translation 3D displacement vector. - @param x The x-component displacement. - @param y The y-component displacement. - @param z The z-component displacement. */ - inline void SetTranslation(float x, float y, float z) { translation = FMVector3(x, y, z); } - - /** Converts the translation into a matrix. - @return A matrix equivalent of the translation. */ - virtual FMMatrix44 ToMatrix() const; - - /** Retrieves whether this translation is affected by an animation. - @return Whether the translation is animated. */ - virtual bool IsAnimated() const; - - /** Retrieves the animated element for the translation. - @see FCDAnimatedPoint3 - @return The animated element. This pointer will be NULL if the translation - is not animated. */ - virtual FCDAnimated* GetAnimated(); - - /** Retrieves whether a given transform is the exact opposite of - this translation. The opposite of a translation has a displacement - vector with all the components multiplied by -1. - @param transform A second transformation. - @return Whether the two transformations are opposites. */ - virtual bool IsInverse(const FCDTransform* transform) const; - - /** Creates a copy of the translation. - @param newParent The visual scene node that will contain the clone. - @return The cloned translation. */ - virtual FCDTransform* Clone(FCDSceneNode* newParent); - - /** [INTERNAL] Reads in the translation from a given COLLADA XML tree node. - @param translationNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the translation.*/ - virtual FUStatus LoadFromXML(xmlNode* translationNode); - - /** [INTERNAL] Writes out the translation to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the translation. - @return The created XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -/** - A COLLADA non-uniform scale. - A non-uniform scale contains three scale factors. - @ingroup FCDocument -*/ -class FCOLLADA_EXPORT FCDTScale : public FCDTransform -{ -private: - FMVector3 scale; - -public: - /** Constructor: do not use directly. - Instead, use the FCDSceneNode::AddTransform function with - the SCALE transformation type. - @param document The COLLADA document that owns the non-uniform scale. - @param parent The visual scene node that contains the non-uniform scale. - Set this pointer to NULL if the non-uniform scale is not owned - by a visual scene node. */ - FCDTScale(FCDocument* document, FCDSceneNode* parent); - - /** Destructor: do not use directly. - Instead, use the FCDSceneNode::ReleaseTransform function. */ - virtual ~FCDTScale(); - - /** Retrieves the transformation class type for the non-uniform scale. - @return The class type: SCALE. */ - virtual Type GetType() const { return SCALE; } - - /** Retrieves the factors of the non-uniform scale. - These factors may be animated. - @return The scale factors. */ - FMVector3& GetScale() { return scale; } - const FMVector3& GetScale() const { return scale; } /**< See above. */ - - /** Sets the factors of the non-uniform scale. - @param _scale The scale factors. */ - inline void SetScale(const FMVector3& _scale) { scale = _scale; } - - /** Sets the factors of the non-uniform scale. - @param x The x-component scale factor. - @param y The y-component scale factor. - @param z The z-component scale factor. */ - inline void SetScale(float x, float y, float z) { scale = FMVector3(x, y, z); } - - /** Converts the non-uniform scale into a matrix. - @return A matrix equivalent of the non-uniform scale. */ - virtual FMMatrix44 ToMatrix() const; - - /** Retrieves whether the factors of the non-uniform scale are animated. - @return Whether the scale factors are animated. */ - virtual bool IsAnimated() const; - - /** Retrieves the animated element for the non-uniform scale factors. - @see FCDAnimatedPoint3 - @return The animated element. This pointer will be NULL if the - scale factors are not animated. */ - virtual FCDAnimated* GetAnimated(); - - /** Creates a copy of the non-uniform scale. - @param newParent The visual scene node that will contain the clone. - @return The cloned non-uniform scale. */ - virtual FCDTransform* Clone(FCDSceneNode* newParent); - - /** [INTERNAL] Reads in the non-uniform scale from a given COLLADA XML tree node. - @param scaleNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the transformation.*/ - virtual FUStatus LoadFromXML(xmlNode* scaleNode); - - /** [INTERNAL] Writes out the non-uniform scale to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the transformation. - @return The created XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -/** - A COLLADA angle-axis rotation. - This rotation defines an axis around which the 3D points - are rotated by a given angle. - @todo (clock-wise/counter-clock-wise?) - @ingroup FCDocument -*/ -class FCOLLADA_EXPORT FCDTRotation : public FCDTransform -{ -private: - float angle; - FMVector3 axis; - -public: - /** Constructor: do not use directly. - Instead, use the FCDSceneNode::AddTransform function with - the transformation type: ROTATION. - @param document The COLLADA document that owns the rotation. - @param parent The visual scene node that contains the rotation. - Set this pointer to NULL if the rotation is not owned - by a visual scene node. */ - FCDTRotation(FCDocument* document, FCDSceneNode* parent); - - /** Destructor: do not use directly. - Instead, use the FCDSceneNode::ReleaseTransform function. */ - virtual ~FCDTRotation(); - - /** Retrieves the transformation class type for the rotation. - @return The class type: ROTATION. */ - virtual Type GetType() const { return ROTATION; } - - /** Retrieves the rotation axis. - This 3D vector may be animated. - @return The rotation axis. */ - inline FMVector3& GetAxis() { return axis; } - inline const FMVector3& GetAxis() const { return axis; } /**< See above. */ - - /** Sets the rotation axis. - @param _axis The rotation axis. */ - inline void SetAxis(const FMVector3& _axis) { axis = _axis; } - - /** Sets the rotation axis. - @param x The x-component of the rotation axis. - @param y The y-component of the rotation axis. - @param z The z-component of the rotation axis. */ - inline void SetAxis(float x, float y, float z) { axis = FMVector3(x, y, z); } - - /** Retrieves the rotation angle. - This angle may be animated. - @return The rotation angle, in degrees. */ - inline float& GetAngle() { return angle; } - inline const float& GetAngle() const { return angle; } /**< See above. */ - - /** Sets the rotation angle. - @param a The rotation angle, in degrees. */ - inline void SetAngle(float a) { angle = a; } - - /** Sets the rotation components - @param _axis The rotation axis. - @param a The rotation angle, in degrees. */ - inline void SetRotation(const FMVector3& _axis, float a) { axis = _axis; angle = a; } - - /** Converts the rotation into a matrix. - @return A matrix equivalent of the rotation. */ - virtual FMMatrix44 ToMatrix() const; - - /** Retrieves whether the axis or the angle of the rotation are animated. - @return Whether the rotation is animated. */ - virtual bool IsAnimated() const; - - /** Retrieves the animated element for the angle-axis rotation. - @see FCDAnimatedAngleAxis - @return The animated element. This pointer will be NULL if the - rotation is not animated. */ - virtual FCDAnimated* GetAnimated(); - - /** Retrieves whether a given transform is the exact opposite of - this rotation. The opposite of an angle-axis rotation has the - same axis as this rotation but the angle is multiplied by -1. - @param transform A second transformation. - @return Whether the two rotation are opposites. */ - virtual bool IsInverse(const FCDTransform* transform) const; - - /** Creates a copy of the angle-axis rotation. - @param newParent The visual scene node that will contain the clone. - @return The cloned angle-axis rotation. */ - virtual FCDTransform* Clone(FCDSceneNode* newParent); - - /** [INTERNAL] Reads in the rotation from a given COLLADA XML tree node. - @param rotationNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the rotation.*/ - virtual FUStatus LoadFromXML(xmlNode* rotationNode); - - /** [INTERNAL] Writes out the rotation to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the rotation. - @return The created XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -/** - A COLLADA matrix transformation. - This transformation contains a matrix that should be - multiplied to the local transformation matrix. - @ingroup FCDocument -*/ -class FCOLLADA_EXPORT FCDTMatrix : public FCDTransform -{ -private: - FMMatrix44 transform; - -public: - /** Constructor: do not use directly. - Instead, use the FCDSceneNode::AddTransform function with - the transformation type: MATRIX. - @param document The COLLADA document that owns the transformation. - @param parent The visual scene node that contains the transformation. */ - FCDTMatrix(FCDocument* document, FCDSceneNode* parent); - - /** Destructor: do not use directly. - Instead, use the FCDSceneNode::ReleaseTransform function. */ - virtual ~FCDTMatrix(); - - /** Retrieves the transformation class type for the transformation. - @return The class type: MATRIX. */ - virtual Type GetType() const { return MATRIX; } - - /** Retrieves the matrix for the transformation. - All 16 values of the matrix may be animated. - @return The transformation matrix. */ - FMMatrix44& GetTransform() { return transform; } - const FMMatrix44& GetTransform() const { return transform; } /**< See above. */ - - /** Sets the matrix for the transformation. - @param mx The transformation matrix. */ - inline void SetTransform(const FMMatrix44& mx) { transform = mx; } - - /** Converts the transformation into a matrix. - For matrix transformations, that's simply the transformation matrix. - @return The transformation matrix. */ - virtual FMMatrix44 ToMatrix() const { return transform; } - - /** Retrieves whether the transformation matrix is animated. - @return Whether the transformation matrix is animated. */ - virtual bool IsAnimated() const; - - /** Retrieves the animated element for the transformation matrix. - @see FCDAnimatedMatrix - @return The animated element. This pointer will be NULL if the - transformation matrix is not animated. */ - virtual FCDAnimated* GetAnimated(); - - /** Creates a copy of the matrix transformation. - @param newParent The visual scene node that will contain the clone. - @return The cloned matrix transformation. */ - virtual FCDTransform* Clone(FCDSceneNode* newParent); - - /** [INTERNAL] Reads in the matrix transformation from a given COLLADA XML tree node. - @param matrixNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the transformation.*/ - virtual FUStatus LoadFromXML(xmlNode* matrixNode); - - /** [INTERNAL] Writes out the matrix transformation to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the transformation. - @return The created XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -/** - A COLLADA 'look-at' transformation. - This transformation type fully defines a position - and an orientation with a 3D world by using three - 3D vectors: the viewer's position, the position - that the viewer is looking at, and the up-vector - for camera rolls. */ -class FCOLLADA_EXPORT FCDTLookAt : public FCDTransform -{ -private: - FMVector3 position; - FMVector3 target; - FMVector3 up; - -public: - /** Constructor: do not use directly. - Instead, use the FCDSceneNode::AddTransform function with - the transformation type: LOOKAT. - @param document The COLLADA document that owns the transformation. - @param parent The visual scene node that contains the transformation. */ - FCDTLookAt(FCDocument* document, FCDSceneNode* parent); - - /** Destructor: do not use directly. - Instead, use the FCDSceneNode::ReleaseTransform function. */ - virtual ~FCDTLookAt(); - - /** Retrieves the transformation class type for the transformation. - @return The class type: LOOKAT. */ - virtual Type GetType() const { return LOOKAT; } - - /** Retrieves the viewer's position. - @see FCDAnimatedPoint3 - @return The viewer's position. */ - FMVector3& GetPosition() { return position; } - const FMVector3& GetPosition() const { return position; } /**< See above. */ - - /** Sets the viewer's position. - @param pos The viewer's position. */ - inline void SetPosition(const FMVector3& pos) { position = pos; } - - /** Sets the viewer's position. - @param x The x-component of the position. - @param y The y-component of the position. - @param z The z-component of the position. */ - inline void SetPosition(float x, float y, float z) { position = FMVector3(x, y, z); } - - /** Retrieves the position that the viewer is looking at. - @see FCDAnimatedPoint3 - @return The viewer's target. */ - FMVector3& GetTarget() { return target; } - const FMVector3& GetTarget() const { return target; } /**< See above. */ - - /** Sets the position that the viewer is looking at. - @param _target The target position. */ - inline void SetTarget(const FMVector3& _target) { target = _target; } - - /** Sets the position that the viewer is looking at. - @param x The x-component of the target position. - @param y The y-component of the target position. - @param z The z-component of the target position. */ - inline void SetTarget(float x, float y, float z) { target = FMVector3(x, y, z); } - - /** Retrieves the viewer's up-vector. - @see FCDAnimatedPoint3 - @return The up-vector. */ - FMVector3& GetUp() { return up; } - const FMVector3& GetUp() const { return up; } /**< See above. */ - - /** Sets the viewer's up-vector. - @param _up The up-vector. */ - inline void SetUp(const FMVector3& _up) { up = _up; } - - /** Sets the viewer's up-vector. - @param x The x-component of the up-vector. - @param y The y-component of the up-vector. - @param z The z-component of the up-vector. */ - inline void SetUp(float x, float y, float z) { up = FMVector3(x, y, z); } - - /** Converts the transformation into a matrix. - @return The transformation matrix. */ - virtual FMMatrix44 ToMatrix() const; - - /** Retrieves whether the transformation is animated. - @return FCollada doesn't support animated 'look-at' transforms: false. */ - virtual bool IsAnimated() const; - - /** Retrieves the animated element for the transformation matrix. - @return FCollada doesn't support animated 'look-at' transforms: NULL. */ - virtual FCDAnimated* GetAnimated(); - - /** Creates a copy of the transformation. - @param newParent The visual scene node that will contain the clone. - @return The cloned 'look-at' transformation. */ - virtual FCDTransform* Clone(FCDSceneNode* newParent); - - /** [INTERNAL] Reads in the transformation from a given COLLADA XML tree node. - @param lookAtNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the transformation.*/ - virtual FUStatus LoadFromXML(xmlNode* lookAtNode); - - /** [INTERNAL] Writes out the transformation to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the transformation. - @return The created XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -/** - A COLLADA skew. - In COLLADA, the skew transformation follows the Renderman convention. - A skew is defined by two axis and one angle: the axis which is rotated, the axis around - which the rotation is done and the angle of the rotation. - @ingroup FCDocument -*/ -class FCOLLADA_EXPORT FCDTSkew : public FCDTransform -{ -private: - FMVector3 rotateAxis; - FMVector3 aroundAxis; - float angle; - -public: - /** Constructor: do not use directly. - Instead, use the FCDSceneNode::AddTransform function with - the transformation type: SKEW. - @param document The COLLADA document that owns the skew. - @param parent The visual scene node that contains the skew. */ - FCDTSkew(FCDocument* document, FCDSceneNode* parent); - - /** Destructor: do not use directly. - Instead, use the FCDSceneNode::ReleaseTransform function. */ - virtual ~FCDTSkew(); - - /** Retrieves the transformation class type for the transformation. - @return The class type: SKEW. */ - virtual Type GetType() const { return SKEW; } - - /** Retrieves the axis which is rotated. - @return The rotated axis. */ - const FMVector3& GetRotateAxis() const { return rotateAxis; } - - /** Sets the axis which is rotated. - @param axis The rotated axis. */ - inline void SetRotateAxis(const FMVector3& axis) { rotateAxis = axis; } - - /** Retrieves the axis around which the rotation is done. - @return The rotation axis. */ - const FMVector3& GetAroundAxis() const { return aroundAxis; } - - /** Sets the axis around which the rotation is done. - @param axis The rotation axis. */ - inline void SetAroundAxis(const FMVector3& axis) { aroundAxis = axis; } - - /** Retrieves the rotation angle. - @return The rotation angle. */ - const float& GetAngle() { return angle; } - - /** Sets the rotation angle. - @param _angle The rotation angle. */ - inline void SetAngle(float _angle) { angle = _angle; } - - /** Converts the skew into a matrix. - @return The transformation matrix. */ - virtual FMMatrix44 ToMatrix() const; - - /** Retrieves whether the transformation is animated. - @return FCollada doesn't support animated skews: false. */ - virtual bool IsAnimated() const; - - /** Retrieves the animated element for the skew. - @return FCollada doesn't support animated skews: NULL. */ - virtual FCDAnimated* GetAnimated(); - - /** Creates a copy of the skew. - @param newParent The visual scene node that will contain the clone. - @return The cloned skew. */ - virtual FCDTransform* Clone(FCDSceneNode* newParent); - - /** [INTERNAL] Reads in the skew from a given COLLADA XML tree node. - @param skewNode The COLLADA XML tree node. - @return The status of the import. If the status is not successful, - it may be dangerous to extract information from the skew.*/ - virtual FUStatus LoadFromXML(xmlNode* skewNode); - - /** [INTERNAL] Writes out the skew to the given COLLADA XML tree node. - @param parentNode The COLLADA XML parent node in which to insert the skew. - @return The created XML tree node. */ - virtual xmlNode* WriteToXML(xmlNode* parentNode) const; -}; - -/** - [INTERNAL] A factory for COLLADA transforms. - Creates the correct transform object for a given transform type/XML tree node. - To create new transforms, use the FCDSceneNode::AddTransform function. -*/ -class FCOLLADA_EXPORT FCDTFactory -{ -private: - FCDTFactory() {} // Static class: do not instantiate. - -public: - /** Creates a new COLLADA transform, given a transform type. - @param document The COLLADA document that will own the new transform. - @param parent The visual scene node that will contain the transform. - @param type The type of transform object to create. - @return The new COLLADA transform. This pointer will be NULL - if the given type is invalid. */ - static FCDTransform* CreateTransform(FCDocument* document, FCDSceneNode* parent, FCDTransform::Type type); - - /** [INTERNAL] Imports a COLLADA transform, given an XML tree node. - @param document The COLLADA document that will own the new transform. - @param parent The visual scene node that will contain the transform. - @param node The XML tree node. - @return The imported COLLADA transform. This pointer will be NULL - if the XML tree node does not describe a COLLADA transform. */ - static FCDTransform* CreateTransform(FCDocument* document, FCDSceneNode* parent, xmlNode* node); -}; - -#endif // _FR_TRANSFORM_H_ diff --git a/Extras/FCollada/FCDocument/FCDocument.cpp b/Extras/FCollada/FCDocument/FCDocument.cpp deleted file mode 100644 index f94c264a2..000000000 --- a/Extras/FCollada/FCDocument/FCDocument.cpp +++ /dev/null @@ -1,775 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDAnimated.h" -#include "FCDocument/FCDAnimation.h" -#include "FCDocument/FCDAnimationChannel.h" -#include "FCDocument/FCDAnimationClip.h" -#include "FCDocument/FCDAnimationCurve.h" -#include "FCDocument/FCDAsset.h" -#include "FCDocument/FCDCamera.h" -#include "FCDocument/FCDController.h" -#include "FCDocument/FCDGeometry.h" -#include "FCDocument/FCDImage.h" -#include "FCDocument/FCDLight.h" -#include "FCDocument/FCDLibrary.h" -#include "FCDocument/FCDMaterial.h" -#include "FCDocument/FCDMaterialLibrary.h" -#include "FCDocument/FCDPhysicsMaterial.h" -#include "FCDocument/FCDPhysicsModel.h" -#include "FCDocument/FCDPhysicsSceneNode.h" -#include "FCDocument/FCDSceneNode.h" -#include "FCDocument/FCDTexture.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -#include "FUtils/FUFileManager.h" -#include "FUtils/FUUniqueStringMap.h" -using namespace FUDaeParser; -using namespace FUDaeWriter; - -FCDocument::FCDocument() -{ - fileManager = new FUFileManager(); - asset = new FCDAsset(this); - uniqueNameMap = new FUSUniqueStringMap(); - - animationLibrary = new FCDLibrary(this); - animationClipLibrary = new FCDLibrary(this); - cameraLibrary = new FCDLibrary(this); - controllerLibrary = new FCDLibrary(this); - geometryLibrary = new FCDLibrary(this); - imageLibrary = new FCDLibrary(this); - lightLibrary = new FCDLibrary(this); - materialLibrary = new FCDMaterialLibrary(this); - visualSceneLibrary = new FCDLibrary(this); - - //physics - physicsMaterialLibrary = new FCDLibrary(this); - physicsModelLibrary = new FCDLibrary(this); - physicsSceneLibrary = new FCDLibrary(this); - physicsSceneRoot = NULL; - - animatedValues.reserve(1024); - visualSceneRoot = NULL; - - // Document global parameters - lengthUnitConversion = 1.0f; - lengthUnitWanted = -1.0f; - hasStartTime = hasEndTime = false; - startTime = endTime = 0.0f; -} - -FCDocument::~FCDocument() -{ - // Must be released first - CLEAR_POINTER_VECTOR(layers); - CLEAR_POINTER_VECTOR(animatedValues); - animatedValueMap.clear(); - SAFE_DELETE(visualSceneLibrary); - - SAFE_DELETE(animationLibrary); - SAFE_DELETE(animationClipLibrary); - SAFE_DELETE(cameraLibrary); - SAFE_DELETE(controllerLibrary); - SAFE_DELETE(geometryLibrary); - SAFE_DELETE(imageLibrary); - SAFE_DELETE(lightLibrary); - SAFE_DELETE(materialLibrary); - SAFE_DELETE(physicsModelLibrary); - SAFE_DELETE(physicsMaterialLibrary); - SAFE_DELETE(physicsSceneLibrary); - - physicsSceneRoot = NULL; - visualSceneRoot = NULL; - - SAFE_DELETE(fileManager); - SAFE_DELETE(asset); -} - -// Retrieve the list of all the COLLADA materials in this document -const FCDMaterialList& FCDocument::GetMaterialList() -{ - return materialLibrary->GetMaterials(); -} - -// These two parameters now belong to FCDAsset. Keep them here for a few version, for backward compatibility -const FMVector3& FCDocument::GetUpAxis() const { return asset->GetUpAxis(); } -float FCDocument::GetLengthUnit() const { return asset->GetUnitConversionFactor(); } - -// Search for a driven curve that needs this animated value as a driver -bool FCDocument::LinkDriver(FCDAnimated* animated) -{ - if (animated->GetTargetPointer().empty()) return false; - - bool driven = false; - size_t animationCount = animationLibrary->GetEntityCount(); - for (size_t i = 0; i < animationCount; ++i) - { - FCDAnimation* animation = animationLibrary->GetEntity(i); - driven |= animation->LinkDriver(animated); - } - return driven; -} - -// Search for an animation channel targeting the given pointer -void FCDocument::FindAnimationChannels(const string& pointer, FCDAnimationChannelList& channels) -{ - if (pointer.empty()) return; - - size_t animationCount = (uint32) animationLibrary->GetEntityCount(); - for (size_t i = 0; i < animationCount; ++i) - { - FCDAnimation* animation = animationLibrary->GetEntity(i); - animation->FindAnimationChannels(pointer, channels); - } -} - -// Gather a list of the indices of animated array element belonging to the node -void FCDocument::FindAnimationChannelsArrayIndices(xmlNode* targetArray, Int32List& animatedIndices) -{ - // Calculte the node's pointer - string pointer; - CalculateNodeTargetPointer(targetArray, pointer); - if (pointer.empty()) return; - - // Retrieve the channels for this pointer and extract their matrix indices. - FCDAnimationChannelList channels; - FindAnimationChannels(pointer, channels); - for (vector::iterator it = channels.begin(); it != channels.end(); ++it) - { - string qualifier = (*it)->GetTargetQualifier(); - int32 animatedIndex = ReadTargetMatrixElement(qualifier); - if (animatedIndex != -1) animatedIndices.push_back(animatedIndex); - } -} - -// Search for a specific COLLADA library items with a given COLLADA id. -FCDAnimation* FCDocument::FindAnimation(const string& daeId) { return animationLibrary->FindDaeId(daeId); } -FCDAnimationClip* FCDocument::FindAnimationClip(const string& daeId) { return animationClipLibrary->FindDaeId(daeId); } -FCDCamera* FCDocument::FindCamera(const string& daeId) { return cameraLibrary->FindDaeId(daeId); } -FCDController* FCDocument::FindController(const string& daeId) { return controllerLibrary->FindDaeId(daeId); } -FCDGeometry* FCDocument::FindGeometry(const string& daeId) { return geometryLibrary->FindDaeId(daeId); } -FCDImage* FCDocument::FindImage(const string& daeId) { return imageLibrary->FindDaeId(daeId); } -FCDLight* FCDocument::FindLight(const string& daeId) { return lightLibrary->FindDaeId(daeId); } -FCDTexture* FCDocument::FindTexture(const string& daeId) { return materialLibrary->FindTexture(daeId); } -FCDMaterial* FCDocument::FindMaterial(const string& daeId) { return materialLibrary->FindMaterial(daeId); } -FCDEffect* FCDocument::FindEffect(const string& daeId) { return materialLibrary->FindEffect(daeId); } -FCDSceneNode* FCDocument::FindVisualScene(const string& daeId) { return visualSceneLibrary->FindDaeId(daeId); } -FCDPhysicsSceneNode* FCDocument::FindPhysicsScene(const string& daeId) { return physicsSceneLibrary->FindDaeId(daeId); } -FCDPhysicsMaterial* FCDocument::FindPhysicsMaterial(const string& daeId) { return physicsMaterialLibrary->FindDaeId(daeId); } -FCDPhysicsModel* FCDocument::FindPhysicsModel(const string& daeId) { return physicsModelLibrary->FindDaeId(daeId); } -FCDSceneNode* FCDocument::FindSceneNode(const string& daeId) -{ - // Nasty special case: look through all the visual_scenes for the scene node - size_t visualSceneCount = visualSceneLibrary->GetEntityCount(); - for (size_t i = 0; i < visualSceneCount; ++i) - { - FCDSceneNode* visualScene = visualSceneLibrary->GetEntity(i); - FCDEntity* found = visualScene->FindDaeId(daeId); - if (found != NULL) return (FCDSceneNode*) found; - } - return NULL; -} - -// Add an animated value to the list -void FCDocument::RegisterAnimatedValue(FCDAnimated* animated) -{ - // Look for a duplicate in order to avoid memory loss - //if (animated->GetValueCount() == 0 || FindAnimatedValue(animated->GetValue(0)) != NULL) - if (animated->GetValueCount() == 0) - { - SAFE_DELETE(animated); - return; - } - - // List the new animated value - animatedValues.push_back(animated); - - // Also add to the map the individual values for easy retrieval - size_t count = animated->GetValueCount(); - for (size_t i = 0; i < count; ++i) - { - const float* value = animated->GetValue(i); - animatedValueMap[value] = animated; - } -} - -// Unregisters an animated value of the document. -void FCDocument::UnregisterAnimatedValue(FCDAnimated* animated) -{ - if (animated != NULL) - { - FCDAnimatedList::iterator it = std::find(animatedValues.begin(), animatedValues.end(), animated); - if (it != animatedValues.end()) - { - animatedValues.erase(it); - - // Also remove to the map the individual values contained - size_t count = animated->GetValueCount(); - for (size_t i = 0; i < count; ++i) - { - const float* value = animated->GetValue(i); - FCDAnimatedValueMap::iterator itV = animatedValueMap.find(value); - if (itV != animatedValueMap.end() && (*itV).second == animated) - { - animatedValueMap.erase(itV); - } - } - } - } -} - -// Retrieve an animated value, given a value pointer -FCDAnimated* FCDocument::FindAnimatedValue(float* ptr) -{ - FCDAnimatedValueMap::iterator it = animatedValueMap.find((const float*) ptr); - return (it != animatedValueMap.end()) ? (*it).second : NULL; -} - -// Retrieve an animated value, given a value pointer -const FCDAnimated* FCDocument::FindAnimatedValue(const float* ptr) const -{ - FCDAnimatedValueMap::const_iterator it = animatedValueMap.find(ptr); - return (it != animatedValueMap.end()) ? (*it).second : NULL; -} - -const FCDAnimated* FCDocument::FindNamedAnimated(const string& shader, const string& attribute) const -{ - string::size_type loc = attribute.find('.', 0); - string attrname = attribute.substr(loc+1); - string shdname = attribute.substr(0, loc); - - string name0 = shader; - name0.append(string("-fx/")); - name0.append(attrname); - - string name1 = shader; - name1.append(string("-fx/")); - name1.append(shdname); - name1.append(attrname); - - for(FCDAnimatedList::const_iterator itA = animatedValues.begin(); itA != animatedValues.end(); ++itA) - { - if(strcmp((*itA)->GetTargetPointer().c_str(), name0.c_str()) == 0 || strcmp((*itA)->GetTargetPointer().c_str(), name1.c_str()) == 0) return (*itA); - } - - return NULL; -} - -// Retrieve an animated float value for a given fully qualified target -const float* FCDocument::FindAnimatedTarget(const string& fullyQualifiedTarget) -{ - if (fullyQualifiedTarget.empty()) return NULL; - string target = (fullyQualifiedTarget[0] == '#') ? fullyQualifiedTarget.substr(1) : fullyQualifiedTarget; - string pointer, qualifier; - SplitTarget(target, pointer, qualifier); - - // Find the pointer - FCDAnimated* animatedValue = NULL; - for (FCDAnimatedList::iterator itA = animatedValues.begin(); itA != animatedValues.end(); ++itA) - { - FCDAnimated* animated = (*itA); - if (animated->GetTargetPointer() == pointer) { animatedValue = animated; break; } - } - if (animatedValue == NULL) return NULL; - - // Return the qualified value - size_t index = animatedValue->FindQualifier(qualifier); - if (index == size_t(-1)) return NULL; - return animatedValue->GetValue(index); -} - -// Returns whether a given value pointer is animated -bool FCDocument::IsValueAnimated(const float* ptr) const -{ - const FCDAnimated* animated = FindAnimatedValue(ptr); - return (animated != NULL) ? animated->HasCurve() : false; -} - -// Insert new library elements -FCDSceneNode* FCDocument::AddVisualScene() -{ - return visualSceneRoot = visualSceneLibrary->AddEntity(); -} -FCDPhysicsSceneNode* FCDocument::AddPhysicsScene() -{ - return physicsSceneRoot = physicsSceneLibrary->AddEntity(); -} - -// Structure and enumeration used to order the libraries -enum nodeOrder { ANIMATION=0, ANIMATION_CLIP, IMAGE, TEXTURE, EFFECT, MATERIAL, GEOMETRY, CONTROLLER, CAMERA, LIGHT, VISUAL_SCENE, PHYSICS_MATERIAL, PHYSICS_MODEL, PHYSICS_SCENE, UNKNOWN }; -struct xmlOrderedNode { xmlNode* node; nodeOrder order; }; -typedef vector xmlOrderedNodeList; - -// Loads an entire COLLADA document file -FUStatus FCDocument::LoadFromFile(const fstring& filename) -{ - FUStatus status; - - // Push the filename's path unto the file manager's stack - fileManager->PushRootFile(filename); - -#if FCOLLADA_EXCEPTION - try { -#endif - - // Parse the document into a XML tree - string xmlFilename = FUStringConversion::ToString(filename); - xmlDoc* daeDocument = xmlParseFile(xmlFilename.c_str()); - if (daeDocument != NULL) - { - xmlNode* rootNode = xmlDocGetRootElement(daeDocument); - - // Read in the whole document from the root node - status.AppendStatus(LoadDocumentFromXML(rootNode)); - - // Free the XML document - xmlFreeDoc(daeDocument); - } - else - { - status.Fail(FS("Corrupted COLLADA document: malformed XML.")); - } - - // Clean-up the XML reader - xmlCleanupParser(); - -#if FCOLLADA_EXCEPTION - } catch(const char* sz) { - status.Fail(FS("Exception caught while parsing a COLLADA document from file: ") + TO_FSTRING(sz)); -#ifdef UNICODE - } catch(const fchar* sz) { - status.Fail(FS("Exception caught while parsing a COLLADA document from file: ") + sz); -#endif - } catch(...) { - status.Fail(FS("Exception caught while parsing a COLLADA document from file.")); - } -#endif - - // Restore the orignal OS current folder - fileManager->PopRootFile(); - - if (status.IsSuccessful()) status.AppendString(FC("COLLADA document loaded successfully.")); - return status; -} - -// Loads an entire COLLADA document from a given NULL-terminated fstring -FUStatus FCDocument::LoadFromText(const fstring& basePath, const fchar* text) -{ - FUStatus status; - - // Push the given path unto the file manager's stack - fileManager->PushRootPath(basePath); - -#if FCOLLADA_EXCEPTION - try { -#endif - -#ifdef UNICODE - // Downsize the text document into something 8-bit - string xmlTextString = FUStringConversion::ToString(text); - const xmlChar* xmlText = (const xmlChar*) xmlTextString.c_str(); -#else - const xmlChar* xmlText = (const xmlChar*) text; -#endif - - // Parse the document into a XML tree - xmlDoc* daeDocument = xmlParseDoc(const_cast(xmlText)); - if (daeDocument != NULL) - { - xmlNode* rootNode = xmlDocGetRootElement(daeDocument); - - // Read in the whole document from the root node - status.AppendStatus(LoadDocumentFromXML(rootNode)); - - // Free the XML document - xmlFreeDoc(daeDocument); - } - else - { - status.Fail(FS("Corrupted COLLADA document: malformed XML.")); - } - - // Clean-up the XML reader - xmlCleanupParser(); - -#if FCOLLADA_EXCEPTION - } catch(const char* sz) { - status.Fail(FS("Exception caught while parsing a COLLADA document from a string: ") + TO_FSTRING(sz)); -#ifdef UNICODE - } catch(const fchar* sz) { - status.Fail(FS("Exception caught while parsing a COLLADA document from a string: ") + sz); -#endif - } catch(...) { - status.Fail(FC("Exception caught while parsing a COLLADA document from a string.")); - } -#endif - - // Restore the orignal OS current folder - fileManager->PopRootPath(); - - if (status.IsSuccessful()) status.AppendString(FC("COLLADA document loaded successfully.")); - return status; -} - -FUStatus FCDocument::LoadDocumentFromXML(xmlNode* colladaNode) -{ - FUStatus status; - - // The only root node supported is "COLLADA" - if (!IsEquivalent(colladaNode->name, DAE_COLLADA_ELEMENT)) - { - return status.Fail(FS("Valid document contain only the root element."), colladaNode->line); - } - - // Bucket the libraries, so that we can read them in our specific order - // COLLADA 1.4: the libraries are now strongly-typed, so process all the elements - xmlNode* sceneNode = NULL; - xmlOrderedNodeList orderedLibraryNodes; - for (xmlNode* child = colladaNode->children; child != NULL; child = child->next) - { - if (child->type != XML_ELEMENT_NODE) continue; - - xmlOrderedNode n; - n.node = child; - n.order = UNKNOWN; - if (IsEquivalent(child->name, DAE_LIBRARY_ELEMENT)) - { - // COLLADA 1.3: Read in the type attribute of the library to know its content - string libraryType = ReadNodeProperty(n.node, DAE_TYPE_ATTRIBUTE); - if (libraryType == DAE_ANIMATION_TYPE) n.order = ANIMATION; - else if (libraryType == DAE_EFFECT_TYPE) n.order = EFFECT; - else if (libraryType == DAE_IMAGE_TYPE) n.order = IMAGE; - else if (libraryType == DAE_TEXTURE_TYPE) n.order = TEXTURE; - else if (libraryType == DAE_MATERIAL_TYPE) n.order = MATERIAL; - else if (libraryType == DAE_GEOMETRY_TYPE) n.order = GEOMETRY; - else if (libraryType == DAE_CAMERA_TYPE) n.order = CAMERA; - else if (libraryType == DAE_CONTROLLER_TYPE) n.order = CONTROLLER; - else if (libraryType == DAE_LIGHT_TYPE) n.order = LIGHT; - } - else if (IsEquivalent(child->name, DAE_LIBRARY_ANIMATION_ELEMENT)) n.order = ANIMATION; - else if (IsEquivalent(child->name, DAE_LIBRARY_ANIMATION_CLIP_ELEMENT)) n.order = ANIMATION_CLIP; - else if (IsEquivalent(child->name, DAE_LIBRARY_CAMERA_ELEMENT)) n.order = CAMERA; - else if (IsEquivalent(child->name, DAE_LIBRARY_CONTROLLER_ELEMENT)) n.order = CONTROLLER; - else if (IsEquivalent(child->name, DAE_LIBRARY_EFFECT_ELEMENT)) n.order = EFFECT; - else if (IsEquivalent(child->name, DAE_LIBRARY_GEOMETRY_ELEMENT)) n.order = GEOMETRY; - else if (IsEquivalent(child->name, DAE_LIBRARY_IMAGE_ELEMENT)) n.order = IMAGE; - else if (IsEquivalent(child->name, DAE_LIBRARY_LIGHT_ELEMENT)) n.order = LIGHT; - else if (IsEquivalent(child->name, DAE_LIBRARY_MATERIAL_ELEMENT)) n.order = MATERIAL; - else if (IsEquivalent(child->name, DAE_LIBRARY_VSCENE_ELEMENT)) n.order = VISUAL_SCENE; - else if (IsEquivalent(child->name, DAE_LIBRARY_FFIELDS_ELEMENT)) continue; // Valid, but not processed - else if (IsEquivalent(child->name, DAE_LIBRARY_NODE_ELEMENT)) continue; // Valid, but not processed - else if (IsEquivalent(child->name, DAE_LIBRARY_PMATERIAL_ELEMENT)) n.order = PHYSICS_MATERIAL; - else if (IsEquivalent(child->name, DAE_LIBRARY_PMODEL_ELEMENT)) n.order = PHYSICS_MODEL; - else if (IsEquivalent(child->name, DAE_LIBRARY_PSCENE_ELEMENT)) n.order = PHYSICS_SCENE; - else if (IsEquivalent(child->name, DAE_ASSET_ELEMENT)) - { - // Read in the asset information - status.AppendStatus(asset->LoadFromXML(child)); - - // Calculate the length conversion unit - // If the wanted unit length is negative, it implies that no conversion is wanted or that the flag was not set - if (lengthUnitWanted > 0.0f) lengthUnitConversion = asset->GetUnitConversionFactor() / lengthUnitWanted; - continue; - } - else if (IsEquivalent(child->name, DAE_SCENE_ELEMENT)) - { - // The element should be the last element of the document - sceneNode = child; - continue; - } - else - { - status.Warning(FS("Unknown base node type: ") + TO_FSTRING((const char*) child->name), child->line); - continue; - } - - xmlOrderedNodeList::iterator it; - for (it = orderedLibraryNodes.begin(); it != orderedLibraryNodes.end(); ++it) - { - if ((uint32) n.order < (uint32) (*it).order) break; - } - orderedLibraryNodes.insert(it, n); - } - - // Process the ordered libraries - size_t libraryNodeCount = orderedLibraryNodes.size(); - for (size_t i = 0; i < libraryNodeCount; ++i) - { - xmlOrderedNode& n = orderedLibraryNodes[i]; - switch (n.order) - { - case ANIMATION: status.AppendStatus(animationLibrary->LoadFromXML(n.node)); break; - case ANIMATION_CLIP: status.AppendStatus(animationClipLibrary->LoadFromXML(n.node)); break; - case CAMERA: status.AppendStatus(cameraLibrary->LoadFromXML(n.node)); break; - case CONTROLLER: status.AppendStatus(controllerLibrary->LoadFromXML(n.node)); break; - case GEOMETRY: status.AppendStatus(geometryLibrary->LoadFromXML(n.node)); break; - case EFFECT: status.AppendStatus(materialLibrary->LoadFromXML(n.node)); break; - case IMAGE: status.AppendStatus(imageLibrary->LoadFromXML(n.node)); break; - case LIGHT: status.AppendStatus(lightLibrary->LoadFromXML(n.node)); break; - case MATERIAL: status.AppendStatus(materialLibrary->LoadFromXML(n.node)); break; - case TEXTURE: status.AppendStatus(materialLibrary->LoadFromXML(n.node)); break; - case PHYSICS_MODEL: status.AppendStatus(physicsModelLibrary->LoadFromXML(n.node)); break; - case PHYSICS_MATERIAL: status.AppendStatus(physicsMaterialLibrary->LoadFromXML(n.node)); break; - case PHYSICS_SCENE: status.AppendStatus(physicsSceneLibrary->LoadFromXML(n.node)); break; - case VISUAL_SCENE: status.AppendStatus(visualSceneLibrary->LoadFromXML(n.node)); break; - case UNKNOWN: default: break; - } - } - - // Read in the element - if (sceneNode == NULL) - { - return status.Warning(FS("No base element found."), colladaNode->line); - } - - // COLLADA 1.4: Look for a element - xmlNode* instancePhysicsNode = FindChildByType(sceneNode, DAE_INSTANCE_PHYSICS_SCENE_ELEMENT); - if (instancePhysicsNode != NULL) - { - FUUri instanceUri = ReadNodeUrl(instancePhysicsNode); - if (instanceUri.prefix.length() > 0) - { - status.Fail(FS("Cannot externally reference a element."), sceneNode->line); - } - else if (instanceUri.suffix.length() == 0) - { - status.Fail(FS("No valid URI fragment for the instantiation of the physics scene."), sceneNode->line); - } - else - { - // Look for the correct physics scene to instantiate in the libraries - physicsSceneRoot = FindPhysicsScene(instanceUri.suffix); - if (physicsSceneRoot == NULL) - { - status.Fail(FS("Cannot find the correct element to instantiate."), sceneNode->line); - } - } - } - - // COLLADA 1.4: Look for a element - xmlNode* instanceSceneNode = FindChildByType(sceneNode, DAE_INSTANCE_VSCENE_ELEMENT); - if (instanceSceneNode != NULL) - { - FUUri instanceUri = ReadNodeUrl(instanceSceneNode); - if (instanceUri.prefix.length() > 0) - { - status.Fail(FS("Cannot externally reference a element."), sceneNode->line); - } - else if (instanceUri.suffix.length() == 0) - { - status.Fail(FS("No valid URI fragment for the instantiation of the visual scene."), sceneNode->line); - } - else - { - // Look for the correct visual scene to instantiate in the libraries - visualSceneRoot = FindVisualScene(instanceUri.suffix); - if (visualSceneRoot == NULL) - { - status.Fail(FS("Cannot find the correct element to instantiate."), sceneNode->line); - } - } - } - else - { - // COLLADA 1.3 backward-compatibility, use this as the element - visualSceneRoot = visualSceneLibrary->AddEntity(); - status.AppendStatus(visualSceneRoot->LoadFromXML(sceneNode)); - } - - - if (visualSceneRoot != NULL) - { - // Link the controllers and the joints - size_t controllerCount = controllerLibrary->GetEntityCount(); - for (size_t i = 0; i < controllerCount; ++i) - { - FCDController* controller = controllerLibrary->GetEntity(i); - status.AppendStatus(controller->Link()); - } - - // Link the targeted entities, for 3dsMax cameras and lights - size_t cameraCount = cameraLibrary->GetEntityCount(); - for (size_t i = 0; i < cameraCount; ++i) - { - FCDCamera* camera = cameraLibrary->GetEntity(i); - status.AppendStatus(camera->LinkTarget(visualSceneRoot)); - } - size_t lightCount = lightLibrary->GetEntityCount(); - for (size_t i = 0; i < lightCount; ++i) - { - FCDLight* light = lightLibrary->GetEntity(i); - status.AppendStatus(light->LinkTarget(visualSceneRoot)); - } - } - - // Check that all the animation curves that need them, have found drivers - size_t animationCount = animationLibrary->GetEntityCount(); - for (size_t i = 0; i < animationCount; ++i) - { - FCDAnimation* animation = animationLibrary->GetEntity(i); - status.AppendStatus(animation->Link()); - } - - // store the post process commands - postCmds = visualSceneLibrary->GetPostProcessCmds(); - - return status; -} - -// Writes out the COLLADA document to a file -FUStatus FCDocument::WriteToFile(const fstring& filename) const -{ - FUStatus status; - - // Push the filename's path unto the file manager's stack - fileManager->PushRootFile(filename); - -#if FCOLLADA_EXCEPTION - try { -#endif - // Create a new xml root node from this COLLADA document - xmlNode* rootNode = CreateNode(DAE_COLLADA_ELEMENT); - status = WriteDocumentToXML(rootNode); - if (status.IsSuccessful()) - { - // Create the XML document and write it out to the given filename - xmlDoc* daeDocument = xmlNewDoc(NULL); // NULL implies version 1.0 - xmlDocSetRootElement(daeDocument, rootNode); - intptr_t bytesWritten = xmlSaveFormatFileEnc(FUStringConversion::ToString(filename).c_str(), daeDocument, "utf-8", 1); - if (bytesWritten < 0) - { - status.Fail(FS("Unable to write COLLADA document to file '") + filename + FS("'. Verify that the folder exists and the file is writable."), rootNode->line); - } - else if (status.IsSuccessful()) - { - status.AppendString(FC("COLLADA document written successfully.")); - } - xmlFreeDoc(daeDocument); - } - else - { - xmlFreeNode(rootNode); - } - - // Clean-up - xmlCleanupParser(); - -#if FCOLLADA_EXCEPTION - } catch(const char* sz) { - status.Fail(FS("Exception caught while parsing a COLLADA document from a string: ") + TO_FSTRING(sz)); -#ifdef UNICODE - } catch(const fchar* sz) { - status.Fail(FS("Exception caught while parsing a COLLADA document from a string: ") + sz); -#endif - } catch(...) { - status.Fail(FC("Exception caught while parsing a COLLADA document from a string.")); - } -#endif - - fileManager->PopRootFile(); - return status; -} - -// Writes out the entire COLLADA document to the given XML root node. -FUStatus FCDocument::WriteDocumentToXML(xmlNode* colladaNode) const -{ - FUStatus status; - if (colladaNode != NULL) - { - // Write the COLLADA document version and namespace: schema-required attributes - AddAttribute(colladaNode, DAE_NAMESPACE_ATTRIBUTE, DAE_SCHEMA_LOCATION); - AddAttribute(colladaNode, DAE_VERSION_ATTRIBUTE, DAE_SCHEMA_VERSION); - - // Write out the asset tag - asset->WriteToXML(colladaNode); - - // Record the animation library. This library is built at the end, but should appear before the element. - xmlNode* animationLibraryNode = NULL; - if (!animationLibrary->IsEmpty()) - { - animationLibraryNode = AddChild(colladaNode, DAE_LIBRARY_ANIMATION_ELEMENT); - } - - // Export the libraries -#define EXPORT_LIBRARY(memberName, daeElementName) if (!(memberName)->IsEmpty()) { \ - xmlNode* libraryNode = AddChild(colladaNode, daeElementName); \ - memberName->WriteToXML(libraryNode); } - - EXPORT_LIBRARY(animationClipLibrary, DAE_LIBRARY_ANIMATION_CLIP_ELEMENT); - EXPORT_LIBRARY(cameraLibrary, DAE_LIBRARY_CAMERA_ELEMENT); - EXPORT_LIBRARY(lightLibrary, DAE_LIBRARY_LIGHT_ELEMENT); - EXPORT_LIBRARY(imageLibrary, DAE_LIBRARY_IMAGE_ELEMENT); - EXPORT_LIBRARY(materialLibrary, DAE_LIBRARY_MATERIAL_ELEMENT); - EXPORT_LIBRARY(geometryLibrary, DAE_LIBRARY_GEOMETRY_ELEMENT); - EXPORT_LIBRARY(controllerLibrary, DAE_LIBRARY_CONTROLLER_ELEMENT); - EXPORT_LIBRARY(visualSceneLibrary, DAE_LIBRARY_VSCENE_ELEMENT); - -#undef EXPORT_LIBRARY - - // Create the element and instantiate the selected visual scene. - xmlNode* sceneNode = AddChild(colladaNode, DAE_SCENE_ELEMENT); - if (visualSceneRoot != NULL) - { - xmlNode* instanceVisualSceneNode = AddChild(sceneNode, DAE_INSTANCE_VSCENE_ELEMENT); - AddAttribute(instanceVisualSceneNode, DAE_URL_ATTRIBUTE, string("#") + visualSceneRoot->GetDaeId()); - } - if (physicsSceneRoot != NULL) - { - xmlNode* instancePhysicsSceneNode = AddChild(sceneNode, DAE_INSTANCE_PHYSICS_SCENE_ELEMENT); - AddAttribute(instancePhysicsSceneNode, DAE_URL_ATTRIBUTE, string("#") + physicsSceneRoot->GetDaeId()); - } - - // Write out the animations - if (animationLibraryNode != NULL) - { - animationLibrary->WriteToXML(animationLibraryNode); - } - } - return status; -} - -// Writes out a value's animations, if any, to the animation library of a COLLADA xml document. -void FCDocument::WriteAnimatedValueToXML(const float* value, xmlNode* valueNode, const char* wantedSid, int32 arrayElement) const -{ - // Find the value's animations - FCDAnimated* animated = const_cast(FindAnimatedValue(value)); - if (animated != NULL && animated->HasCurve() && valueNode != NULL) - { - animated->SetArrayElement(arrayElement); - - // Set a sid unto the xml tree node, in order to support animations - if (!HasNodeProperty(valueNode, DAE_SID_ATTRIBUTE)) - { - AddNodeSid(valueNode, wantedSid); - } - - // Calculate the xml tree node's target for the animation channel and write the animation out - string target; - CalculateNodeTargetPointer(valueNode, target); - if (!target.empty()) - { - for (uint32 i = 0; i < animated->GetValueCount(); ++i) - { - FCDAnimationCurve* curve = animated->GetCurve(i); - if (curve == NULL) continue; - curve->SetTargetElement(arrayElement); - - FCDAnimationChannel* channel = curve->GetParent(); - FUAssert(channel != NULL, continue); - - channel->SetTargetPointer(target); - } - } - } -} diff --git a/Extras/FCollada/FCDocument/FCDocument.h b/Extras/FCollada/FCDocument/FCDocument.h deleted file mode 100644 index 9e13aa20d..000000000 --- a/Extras/FCollada/FCDocument/FCDocument.h +++ /dev/null @@ -1,491 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FCDocument.h - This file declares the COLLADA document object model top class: FCDocument. -*/ - -#ifndef _FC_DOCUMENT_H_ -#define _FC_DOCUMENT_H_ - -#include "FUtils/FUObject.h" - -template class FCDLibrary; -template class FUUniqueStringMapT; - -class FCDAnimation; -class FCDAnimationChannel; -class FCDAnimationClip; -class FCDAnimated; -class FCDAsset; -class FCDCamera; -class FCDController; -class FCDEffect; -class FCDGeometry; -class FCDImage; -class FCDLight; -class FCDMaterial; -class FCDMaterialLibrary; -class FCDObject; -class FCDPhysicsMaterial; -class FCDPhysicsModel; -class FCDPhysicsSceneNode; -class FCDTexture; -class FCDSceneNode; -class FUFileManager; - -/** - A layer declaration. - Contains a name for the layer and the ids of all the entities within the layer. -*/ -class FCOLLADA_EXPORT FCDLayer -{ -public: - string name; /**< The layer name. There is no guarantee of uniqueness. */ - StringList objects; /**< The list of COLLADA entity ids which are contained by this layer. */ -}; - -typedef vector FCDMaterialList; /**< A dynamically-sized array of visual material entities. */ -typedef vector FCDAnimatedList; /**< A dynamically-sized array of animated values. */ -typedef vector FCDAnimationChannelList; /**< A dynamically-sized array of animation channels. */ -typedef map FCDAnimatedValueMap; /**< A map of animatable values to animated values. */ -typedef vector FCDLayerList; /**< A dynamically-sized array of layer declarations. */ -typedef vector FCDObjectList; /**< A dynamically-sized array of material entities. */ - -typedef FCDLibrary FCDAnimationLibrary; /**< A COLLADA library of animation entities. */ -typedef FCDLibrary FCDAnimationClipLibrary; /**< A COLLADA library of animation clip entities. */ -typedef FCDLibrary FCDCameraLibrary; /**< A COLLADA library of camera entities. */ -typedef FCDLibrary FCDControllerLibrary; /**< A COLLADA library of controller entities. */ -typedef FCDLibrary FCDGeometryLibrary; /**< A COLLADA library of geometric entities. */ -typedef FCDLibrary FCDImageLibrary; /**< A COLLADA library of images. */ -typedef FCDLibrary FCDLightLibrary; /**< A COLLADA library of light entities. */ -typedef FCDLibrary FCDVisualSceneNodeLibrary; /**< A COLLADA library of visual scene nodes. */ -typedef FCDLibrary FCDPhysicsModelLibrary; /**< A COLLADA library of physics model entities. */ -typedef FCDLibrary FCDPhysicsMaterialLibrary; /**< A COLLADA library of physics material entities. */ -typedef FCDLibrary FCDPhysicsSceneLibrary; /**< A COLLADA library of physics scene nodes. */ -typedef FUUniqueStringMapT FUSUniqueStringMap; /**< A set of unique strings. */ - -/** @defgroup FCDocument COLLADA Document Object Model. */ - -/** The top class for the COLLADA object model. - - @ingroup FCDocument COLLADA Document Object Model -*/ -class FCOLLADA_EXPORT FCDocument : public FUObjectContainer -{ -private: - FUFileManager* fileManager; - FCDSceneNode* visualSceneRoot; - FCDPhysicsSceneNode* physicsSceneRoot; - FUSUniqueStringMap* uniqueNameMap; - - // Document parameters - FCDAsset* asset; - float lengthUnitWanted, lengthUnitConversion; - bool hasStartTime, hasEndTime; - float startTime, endTime; // Maya-only - FCDLayerList layers; // Maya-only - - // Parsed and merged libraries - FCDAnimationLibrary* animationLibrary; - FCDAnimationClipLibrary* animationClipLibrary; - FCDCameraLibrary* cameraLibrary; - FCDControllerLibrary* controllerLibrary; - FCDGeometryLibrary* geometryLibrary; - FCDImageLibrary* imageLibrary; - FCDLightLibrary* lightLibrary; - FCDMaterialLibrary* materialLibrary; - FCDPhysicsModelLibrary* physicsModelLibrary; - FCDPhysicsMaterialLibrary* physicsMaterialLibrary; - FCDPhysicsSceneLibrary* physicsSceneLibrary; - FCDVisualSceneNodeLibrary* visualSceneLibrary; - - // Animated values - FCDAnimatedList animatedValues; - FCDAnimatedValueMap animatedValueMap; - - StringList postCmds; - -public: - /** Construct a new COLLADA document. */ - FCDocument(); - - /** COLLADA document destructor. This clears out all the memory related to the document. */ - virtual ~FCDocument(); - - /** Retrieves the asset information for this COLLADA document. The asset information should always be present. - @return A pointer to the asset information structure. This pointer should never be NULL. */ - FCDAsset* GetAsset() { return asset; } - const FCDAsset* GetAsset() const { return asset; } /**< See above. */ - - /** [INTERNAL] Retrieves the local file manager for the COLLADA document. Used to resolve URIs and transform file - paths into their relative or absolute equivalent. May be deprecated in future versions. - @return The file manager for this COLLADA document. This pointer should never be NULL. */ - FUFileManager* GetFileManager() { return fileManager; } - const FUFileManager* GetFileManager() const { return fileManager; } /**< See above. */ - - /** Retrieves the currently selected visual scene. - @return The currently selected visual scene structure. */ - FCDSceneNode* GetVisualSceneRoot() { return visualSceneRoot; } - const FCDSceneNode* GetVisualSceneRoot() const { return visualSceneRoot; } /**< See above. */ - - /** Retrieves the currently selected physics scene. - @return The currently selected physics scene structure. */ - FCDPhysicsSceneNode* GetPhysicsSceneRoot() { return physicsSceneRoot; } - const FCDPhysicsSceneNode* GetPhysicsSceneRoot() const { return physicsSceneRoot; } /**< See above. */ - - /** @deprecated Retrieves a list of all the visual materials contained by the document. - @return The materials contained by this document. */ - const FCDMaterialList& GetMaterialList(); - - /** [INTERNAL] Retrieves the map of unique ids for this document. - @return The map of unique ids for this document. */ - FUSUniqueStringMap* GetUniqueNameMap() { return uniqueNameMap; } - const FUSUniqueStringMap* GetUniqueNameMap() const { return uniqueNameMap; } /**< See above. */ - - /** @deprecated Retrieves the vector pre-determined by the document as the up-axis. - This information is now contained within the asset structure. Please use GetAsset()->GetUpAxis(). - @return A 3D vector for the up axis direction. */ - const FMVector3& GetUpAxis() const; - - /** @deprecated Retrieves the length of 1 distance unit for this document, in meters. The default is 1.0, - which means that the 1 unit in the document is equal to 1 meter. This information is - now contained within the asset structure. Please use GetAsset()->GetLengthUnit(). - @return The length of 1 distance unit for this document. */ - float GetLengthUnit() const; - - /** [INTERNAL] Retrieves the conversion factor between the requested distance unit - and the document's distance unit. - @return The distance unit conversion factor. */ - float GetLengthUnitConversion() const { return lengthUnitConversion; } - - /** Sets the wanted distance unit factor, in meters, for this document. - For example, Maya uses centimeters internally and sets the wanted distance unit factor to 0.01. - @param wantedLengthUnit The wanted distance unit, in meters. */ - inline void SetLengthUnitWanted(float wantedLengthUnit) { lengthUnitWanted = wantedLengthUnit; } - - /** Returns whether a start time is being enforced for the document. - @return Whether the document has a start time. */ - bool HasStartTime() const { return hasStartTime; } - /** Retrieves the start time set for the document. - @return The document start time. */ - float GetStartTime() const { return startTime; } - /** Enforces a certain time as the start time for the document. - @param time The document start time. */ - void SetStartTime(float time) { startTime = time; hasStartTime = true; } - - /** Returns whether a end time is being enforced for the document. - @return Whether the document has a end time. */ - bool HasEndTime() const { return hasEndTime; } - /** Retrieves the end time set for the document. - @return The document end time. */ - float GetEndTime() const { return endTime; } - /** Enforces a certain time as the end time for the document. - @param time The document end time. */ - void SetEndTime(float time) { endTime = time; hasEndTime = true; } - - /** Retrieves the list of entity layers. - @return The list of entity layers. */ - FCDLayerList& GetLayers() { return layers; } - const FCDLayerList& GetLayers() const { return layers; } /**< See above. */ - - /** Retrieves the animation library. The animation library contains the animation curves - within a tree structure. To create and find animation curves, do not use the animation - library directly: use the FCDAnimated class, the FindAnimatedValue() function and the - RegisterAnimatedValue() function. - @return The animation library. */ - FCDAnimationLibrary* GetAnimationLibrary() { return animationLibrary; } - const FCDAnimationLibrary* GetAnimationLibrary() const { return animationLibrary; } /**< See above. */ - - /** Retrieves the animation clip library. The animation clip library contains a list of animation clips. - Each animation clip instantiates nodes from the animation library. Sections of the animation curves - belonging to the instantiated animation nodes are thereby packaged together as animation clips. - @return The animation clip library. */ - FCDAnimationClipLibrary* GetAnimationClipLibrary() { return animationClipLibrary; } - const FCDAnimationClipLibrary* GetAnimationClipLibrary() const { return animationClipLibrary; } /**< See above. */ - - /** Retrieves the camera library. The camera library contains a list of cameras, which may be - instantiated within the scene graph. COLLADA supports two camera types: perspective and orthographic. - @return The camera library. */ - FCDCameraLibrary* GetCameraLibrary() { return cameraLibrary; } - const FCDCameraLibrary* GetCameraLibrary() const { return cameraLibrary; } /**< See above. */ - - /** Retrieves the controller library. The controller library contains a list of controllers, which may - be instantiated within the scene graph. COLLADA supports two controller types: skin and morph. - @return The controller library. */ - FCDControllerLibrary* GetControllerLibrary() { return controllerLibrary; } - const FCDControllerLibrary* GetControllerLibrary() const { return controllerLibrary; } /**< See above. */ - - /** Retrieves the geometry library. The geometry library contains a list of basic geometries, which may - be instantiated within the scene graph and may be used by controllers. - COLLADA supports two geometry types: mesh and spline. - @return The geometry library. */ - FCDGeometryLibrary* GetGeometryLibrary() { return geometryLibrary; } - const FCDGeometryLibrary* GetGeometryLibrary() const { return geometryLibrary; } /**< See above. */ - - /** Retrieves the image library. The image library contains a list of images. Images are used - by effects for textures. - @return The image library. */ - FCDImageLibrary* GetImageLibrary() { return imageLibrary; } - const FCDImageLibrary* GetImageLibrary() const { return imageLibrary; } /**< See above. */ - - /** Retrieves the light library. The light library contains a list of light, which may be - instantiated within the scene graph. COLLADA supports four light types: ambient, directional, - point and spot lights. - @return The light library. */ - FCDLightLibrary* GetLightLibrary() { return lightLibrary; } - const FCDLightLibrary* GetLightLibrary() const { return lightLibrary; } /**< See above. */ - - /** Retrieves the visual material library. The visual material library contains a list of visual materials, - which are bound to mesh polygons within the scene graph. A visual material instantiates an effect and - presets the effect parameters for a given visual result. - @return The visual material library. */ - FCDMaterialLibrary* GetMaterialLibrary() { return materialLibrary; } - const FCDMaterialLibrary* GetMaterialLibrary() const { return materialLibrary; } /**< See above. */ - - /** Retrieves the effect library. The effect library contains a list of effects, which may be instantiated - by materials. An effect defines an interface for a rendering shader. A ColladaFX effect may contain multiple - passes and techniques for different platforms or level of details. - @return The effect library. */ - FCDMaterialLibrary* GetEffectLibrary() { return materialLibrary; } - const FCDMaterialLibrary* GetEffectLibrary() const { return materialLibrary; } /**< See above. */ - - /** Retrieves the visual scene library. The visual scene library contains an acyclic directed graph of - visual scene nodes: a visual scene node contains one or more parent nodes and zero or more child nodes. - A visual scene node also contains 3D transformations: translation, rotation, scale, skew, as well as - the compound transformations: lookAt and matrix. A visual scene node also contains instances of - geometries, controllers, cameras and/or lights. Only one visual scene should be used at one time - by the global scene. - @return The visual scene library. */ - FCDVisualSceneNodeLibrary* GetVisualSceneLibrary() { return visualSceneLibrary; } - const FCDVisualSceneNodeLibrary* GetVisualSceneLibrary() const { return visualSceneLibrary; } /**< See above. */ - - /** Retrieves the physics model library. The physics model library contains a list of physics models. - @return The physics model library. */ - FCDPhysicsModelLibrary* GetPhysicsModelLibrary() { return physicsModelLibrary; } - const FCDPhysicsModelLibrary* GetPhysicsModelLibrary() const { return physicsModelLibrary; } /**< See above. */ - - /** Retrieves the physics material library. The physics material library contains a list of physics material. - @return The physics material library. */ - FCDPhysicsMaterialLibrary* GetPhysicsMaterialLibrary() { return physicsMaterialLibrary; } - const FCDPhysicsMaterialLibrary* GetPhysicsMaterialLibrary() const { return physicsMaterialLibrary; } /**< See above. */ - - /** Retrieves the physics scene library. The physics scene library contains an acyclic directed graph of - physics scene nodes. - @return The physics scene library. */ - FCDPhysicsSceneLibrary* GetPhysicsSceneLibrary() { return physicsSceneLibrary;} - const FCDPhysicsSceneLibrary* GetPhysicsSceneLibrary() const { return physicsSceneLibrary;} /**< See above. */ - - /** Insert a new visual scene within the visual scene library. - The new visual scene will be used as the root visual scene. - @return The newly created visual scene. */ - FCDSceneNode* AddVisualScene(); - - /** Insert a new physics scene within the physics material library. - The new physics scene will be used as the root physics scene. - @return The newly created physics scene. */ - FCDPhysicsSceneNode* AddPhysicsScene(); - - /** [INTERNAL] Retrieves all the animation channels which include a given target pointer. - @param pointer A valid COLLADA target pointer. Example: "node01/translate.X". - @param channels A list to be filled with the animation channels which target the given pointer. - This list is not emptied by the function. If no animation channels are found, this list will be empty. */ - void FindAnimationChannels(const string& pointer, FCDAnimationChannelList& channels); - - /** [INTERNAL] Retrieves the array indices of animation channels which target the given XML node. - @param targetArray A XML node that contains an array of animatable values. - @param animatedIndices A list to be filled with the array indices of the animation channels - which target the given XML node. If no animation channel indices are found, this list will be empty. */ - void FindAnimationChannelsArrayIndices(xmlNode* targetArray, Int32List& animatedIndices); - - /** Retrieves the animation tree node that matches the given COLLADA id. - @param daeId A valid COLLADA id. - @return The animation tree node. This pointer will be NULL if - no matching animation tree node was found. */ - FCDAnimation* FindAnimation(const string& daeId); - - /** Retrieves the animation clip that matches the given COLLADA id. - @param daeId A valid COLLADA id. - @return The animation clip. This pointer will be NULL if - no matching animation clip was found. */ - FCDAnimationClip* FindAnimationClip(const string& daeId); - - /** Retrieves the camera that matches the given COLLADA id. - @param daeId A valid COLLADA id. - @return The camera. This pointer will be NULL if no matching camera was found. */ - FCDCamera* FindCamera(const string& daeId); - - /** Retrieves the controller that matches the given COLLADA id. - @param daeId A valid COLLADA id. - @return The controller. This pointer will be NULL if no matching controller was found. */ - FCDController* FindController(const string& daeId); - - /** Retrieves the effect that matches the given COLLADA id. - @param daeId A valid COLLADA id. - @return The effect. This pointer will be NULL if no matching effect was found. */ - FCDEffect* FindEffect(const string& daeId); - - /** Retrieves the geometry that matches the given COLLADA id. - @param daeId A valid COLLADA id. - @return The geometry. This pointer will be NULL if no matching geometry was found. */ - FCDGeometry* FindGeometry(const string& daeId); - - /** Retrieves the image that matches the given COLLADA id. - @param daeId A valid COLLADA id. - @return The image. This pointer will be NULL if no matching image was found. */ - FCDImage* FindImage(const string& daeId); - - /** Retrieves the light that matches the given COLLADA id. - @param daeId A valid COLLADA id. - @return The light. This pointer will be NULL if no matching light was found. */ - FCDLight* FindLight(const string& daeId); - - /** Retrieves the visual material that matches the given COLLADA id. - @param daeId A valid COLLADA id. - @return The visual material. This pointer will be NULL if no matching visual material was found. */ - FCDMaterial* FindMaterial(const string& daeId); - - /** @deprecated Retrieves the texture that matches the given COLLADA id. - @param daeId A valid COLLADA id. - @return The texture. This pointer will be NULL if no matching texture was found. */ - FCDTexture* FindTexture(const string& daeId); - - /** Retrieves the visual scene that matches the given COLLADA id. - @param daeId A valid COLLADA id. - @return The visual scene. This pointer will be NULL if no matching visual scene was found. */ - FCDSceneNode* FindVisualScene(const string& daeId); - - /** Retrieves the physics scene that matches the given COLLADA id. - @param daeId A valid COLLADA id. - @return The physics scene. This pointer will be NULL if no matching physics scene was found. */ - FCDPhysicsSceneNode* FindPhysicsScene(const string& daeId); - - /** Retrieves the physics material that matches the given COLLADA id. - @param daeId A valid COLLADA id. - @return The physics material. This pointer will be NULL if no matching physics material was found. */ - FCDPhysicsMaterial* FindPhysicsMaterial(const string& daeId); - - /** Retrieves the physics model that matches the given COLLADA id. - @param daeId A valid COLLADA id. - @return The physics model. This pointer will be NULL if no matching physics model was found. */ - FCDPhysicsModel* FindPhysicsModel(const string& daeId); - - /** Retrieves the visual scene node that matches the given COLLADA id. - This method searches through all the visual scenes within the visual scene library and - their child visual scene nodes to find the correct visual scene node. - @param daeId A valid COLLADA id. - @return The visual scene node. This pointer will be NULL if no matching visual scene node was found. */ - FCDSceneNode* FindSceneNode(const string& daeId); - - /** [INTERNAL] Registers an animated value with the document. All animated values are - listed within the document. - @param animated The new animated value to list within the document. */ - void RegisterAnimatedValue(FCDAnimated* animated); - - /** [INTERNAL] Unregisters an animated value of the document. All animated values are - listed within the document. This function must be called before deleting an animated value. - @param animated The animated value to un-list from the document. */ - void UnregisterAnimatedValue(FCDAnimated* animated); - - /** [INTERNAL] Links the given animated value as a possible driver to other animated value(s). This step is - done during the import, after new animated values are imported. The whole list of animated values is checked - for potential driven values. - @param animated The animated value to verify. - @return Whether a driver was found. */ - bool LinkDriver(FCDAnimated* animated); - - /** Retrieves an animated value given an animatable value. - @param ptr A pointer to an animatable value contained within the document. - @return The animated value. This pointer will NULL if no matching animated value was found. */ - FCDAnimated* FindAnimatedValue(float* ptr); - const FCDAnimated* FindAnimatedValue(const float* ptr) const; /**< See above. */ - - /** [INTERNAL] Retrieves an animated value given a COLLADA target pointer. Used during the resolving of drivers/driven - animated values. - @param fullyQualifiedTarget A valid COLLADA target pointer. - @return A pointer to the animatable value. */ - const float* FindAnimatedTarget(const string& fullyQualifiedTarget); - - /** @deprecated Retrieves an animated value associated with a shader attribute, given the id of the material. - Do not use this function. Instead, find the material/effect within its library, - find the parameter and use the FindAnimatedValue function on its animatable value(s). - @param shader A valid material id. - @param attribute A valid attribute sub-id. - @return The animated value. This pointer will be NULL if no matching animated value was found. */ - const FCDAnimated* FindNamedAnimated(const string& shader, const string& attribute) const; - - /** Retrieves whether a given animatable value is animated. - @param ptr The animatable value. - @return Whether the animatable value is animated. */ - bool IsValueAnimated(const float* ptr) const; - - /** Loads a COLLADA file into this document object. This function appends into the document object all - the COLLADA assets found within the file identified by the given filename. - @param filename An OS-dependant filename. - @return The status of the import. If the status is not successful, it may be dangerous to - extract information from the document. */ - FUStatus LoadFromFile(const fstring& filename); - - /** Loads a COLLADA string into this document object. This function appends into the document object all - the COLLADA assets found within the given string. The string should be in XML format. - @param basePath The base file path for this import. Used when transforming the relative filenames - found within the COLLADA string into absolute and OS-dependent filenames. - @param text The COLLADA string. - @return The status of the import. If the status is not successful, it may be dangerous to - extract information from the document. */ - FUStatus LoadFromText(const fstring& basePath, const fchar* text); - - /** [INTERNAL] Reads the full document information from the given XML node tree. This step is done after - a successfull import, by LibXML2, of the COLLADA string/file into a full XML node tree. - @param colladaNode The base XML node tree to parse. - @return The status of the import. If the status is not successful, it may be dangerous to - extract information from the document. */ - FUStatus LoadDocumentFromXML(xmlNode* colladaNode); - - /** Writes the document out to a file identified by its OS-dependent filename. This function is done - in two steps. First, the document is fully translated into a XML node tree. Then, the XML node tree - is written to a file by LibXML2. - @param filename The OS-dependent filename. - @return The status of the import. If the status is not successful, it may be dangerous to - extract information from the document. */ - FUStatus WriteToFile(const fstring& filename) const; - - /** [INTERNAL] Writes out the document to a XML node tree. This is the first step of the document - export. This function traverses the full COLLADA document, writing all the entities into - the given XML node tree. - @param colladaNode The base XML node tree to write to. - @return The status of the import. If the status is not successful, it may be dangerous to - extract information from the document. */ - FUStatus WriteDocumentToXML(xmlNode* colladaNode) const; - - /** [INTERNAL] Writes out the animation curves contained within an animated value to the given XML node tree. - @param value An animatable value. - @param valueNode The XML node associated with the animatable value. This XML node is used to generate a - valid COLLADA target pointer. - @param wantedSid The sub-id for the animatable value. If the animatable value is animated, this sub-id - will be added as an attribute to the XML node. If another node, within the sid range already uses this sub-id, - a unique sub-id will be generated using the wanted sub-id as a base. - @param arrayElement The array index for this animatable value. Defaults to -1, which implies that the - animatable value does not belong to an array. */ - void WriteAnimatedValueToXML(const float* value, xmlNode* valueNode, const char* wantedSid, int32 arrayElement = -1) const; - - /** @deprecated Retrieves a list of post-processing commands. - @return The list of post-processing commands. */ - const StringList& GetPostProcessCmds() const { return postCmds; } - - /** @deprecated Retrieves the list of the animated values defined within the document. - Do not use this function: use FindAnimatedValue() instead. - @return The list of animated values defined within the document. */ - const FCDAnimatedList& getAnimatedValues() { return animatedValues; } -}; - -#endif //_FC_DOCUMENT_H_ diff --git a/Extras/FCollada/FCDocument/Makefile b/Extras/FCollada/FCDocument/Makefile deleted file mode 100644 index 8a2a6def8..000000000 --- a/Extras/FCollada/FCDocument/Makefile +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/make -# FCDocument Makefile for PS3 - -include ../../MakeDefs - -LIBNAME = libfcdocument - -prefix=.. - -LIBPATH=$(prefix)/lib - -PPU_INCDIRS=-I.. -I../LibXML/include -PPU_OPTIMIZE_LV= -O3 -funroll-loops - -PPU_LIB_TARGET=$(LIBNAME).a -PPU_SRCS = \ - FCDAnimated.cpp \ - FCDAnimation.cpp \ - FCDAnimationChannel.cpp \ - FCDAnimationClip.cpp \ - FCDAnimationCurve.cpp \ - FCDAnimationMultiCurve.cpp \ - FCDAsset.cpp \ - FCDCamera.cpp \ - FCDController.cpp \ - FCDEffect.cpp \ - FCDEffectCode.cpp \ - FCDEffectParameter.cpp \ - FCDEffectParameterFactory.cpp \ - FCDEffectParameterList.cpp \ - FCDEffectPass.cpp \ - FCDEffectPassShader.cpp \ - FCDEffectProfile.cpp \ - FCDEffectStandard.cpp \ - FCDEffectTechnique.cpp \ - FCDEntity.cpp \ - FCDExtra.cpp \ - FCDGeometry.cpp \ - FCDGeometryInstance.cpp \ - FCDGeometryMesh.cpp \ - FCDGeometryPolygons.cpp \ - FCDGeometrySource.cpp \ - FCDGeometrySpline.cpp \ - FCDImage.cpp \ - FCDLight.cpp \ - FCDMaterial.cpp \ - FCDMaterialInstance.cpp \ - FCDMaterialLibrary.cpp \ - FCDMorphController.cpp \ - FCDocument.cpp \ - FCDPhysicsAnalyticalGeometry.cpp \ - FCDPhysicsMaterial.cpp \ - FCDPhysicsModel.cpp \ - FCDPhysicsModelInstance.cpp \ - FCDPhysicsParameterGeneric.cpp \ - FCDPhysicsRigidBody.cpp \ - FCDPhysicsRigidBodyInstance.cpp \ - FCDPhysicsRigidConstraint.cpp \ - FCDPhysicsRigidConstraintInstance.cpp \ - FCDPhysicsSceneNode.cpp \ - FCDPhysicsShape.cpp \ - FCDSceneNode.cpp \ - FCDSkinController.cpp \ - FCDTargetedEntity.cpp \ - FCDTexture.cpp \ - FCDTransform.cpp - -include ../../MakeRules diff --git a/Extras/FCollada/FCDocument/Makefile.am b/Extras/FCollada/FCDocument/Makefile.am deleted file mode 100644 index 800b4507d..000000000 --- a/Extras/FCollada/FCDocument/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -INCLUDES = -I$(top_srcdir)/. -I/usr/include/libxml2 -METASOURCES = AUTO -noinst_LIBRARIES = libFCDocument.a -libFCDocument_a_SOURCES = FCDAnimated.cpp FCDAnimatedColor.cpp\ - FCDAnimatedFloat.cpp FCDAnimatedVector.cpp FCDAnimation.cpp\ - FCDAnimationChannel.cpp FCDGeometry.cpp FCDGeometryInput.cpp\ - FCDGeometryPolygons.cpp FCDImage.cpp FCDMaterial.cpp FCDocument.cpp\ - FCDSceneNode.cpp FCDTexture.cpp FCDTMatrix.cpp FCDTRotation.cpp\ - FCDTScale.cpp FCDTTranslation.cpp - diff --git a/Extras/FCollada/FCollada.def b/Extras/FCollada/FCollada.def deleted file mode 100644 index 8027dd776..000000000 --- a/Extras/FCollada/FCollada.def +++ /dev/null @@ -1,10 +0,0 @@ -EXPORTS - - xmlFree - xmlMalloc - xmlMallocAtomic - xmlRealloc - xmlMemStrdup - -SECTIONS - .data READ WRITE diff --git a/Extras/FCollada/FCollada.h b/Extras/FCollada/FCollada.h deleted file mode 100644 index 2d27bf185..000000000 --- a/Extras/FCollada/FCollada.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - * @mainpage FCollada Documentation - * - * @section intro_sec Introduction - * The FCollada classes are designed to read and write Collada files. - * - * @section install_sec Installation - * - * @subsection step1 Step 1: Download - * You can download the FCollada libraries from our website: http://www.feelingsoftware.com - * - * @section copyright Copyright - * Copyright (C) 2005-2006 Feeling Software Inc. - * MIT License: http://www.opensource.org/licenses/mit-license.php - */ - -#ifndef _FCOLLADA_H_ -#define _FCOLLADA_H_ - -#ifdef FCOLLADA_DLL -#error DO NOT USE THE DLL VERSION: IT IS STILL IN PROGRESS. -#endif - -/** - FCollada exception handling. - Force this #define to 0 to disallow exception handling within the FCollada library. - By default, a debug library will no handle exceptions so that your debugger can. - In release, all exceptions should be handled so that your users receive a meaningful message, - rather than crash your application. Force this #define to 0 only if your platform does not - support exception handling. -*/ -#ifdef _DEBUG -#define FCOLLADA_EXCEPTION 0 -#else -#define FCOLLADA_EXCEPTION 1 -#endif - -#include "FUtils/FUtils.h" - -/** - FCollada version number. - You should verify that you have the correct version, if you use the FCollada library as a DLLs. - For a history of version, check the Changes.txt file. -*/ -#define FCOLLADA_VERSION 0x00010008 /* MMMM.NNNN */ - -/** - This namespace contains FCollada global functions and member variables -*/ -namespace FCollada -{ - /** Retrieves the FCollada version number. - Used for DLL-versions of the FCollada library: verify that you have a compatible version - of the FCollada library using this function. - @return The FCollada version number. */ - FCOLLADA_EXPORT unsigned long GetVersion(); -} - -#endif // _FCOLLADA_H_ diff --git a/Extras/FCollada/FCollada.xcodeproj/project.pbxproj b/Extras/FCollada/FCollada.xcodeproj/project.pbxproj deleted file mode 100644 index 580c9766b..000000000 --- a/Extras/FCollada/FCollada.xcodeproj/project.pbxproj +++ /dev/null @@ -1,595 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 42; - objects = { - -/* Begin PBXBuildFile section */ - C315DFE0097840F5005D77BE /* DaeSyntax.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DF83097840BD005D77BE /* DaeSyntax.h */; }; - C315DFE1097840F5005D77BE /* FCDAnimated.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DF99097840CE005D77BE /* FCDAnimated.cpp */; }; - C315DFE2097840F6005D77BE /* FCDAnimated.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DF9A097840CE005D77BE /* FCDAnimated.h */; }; - C315DFE3097840F6005D77BE /* FCDAnimation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DF9B097840CE005D77BE /* FCDAnimation.cpp */; }; - C315DFE4097840F7005D77BE /* FCDAnimation.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DF9C097840CE005D77BE /* FCDAnimation.h */; }; - C315DFE5097840F7005D77BE /* FCDAnimationChannel.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DF9D097840CE005D77BE /* FCDAnimationChannel.cpp */; }; - C315DFE6097840FA005D77BE /* FCDAnimationChannel.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DF9E097840CE005D77BE /* FCDAnimationChannel.h */; }; - C315DFE7097840FA005D77BE /* FCDAnimationClip.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DF9F097840CE005D77BE /* FCDAnimationClip.cpp */; }; - C315DFE8097840FB005D77BE /* FCDAnimationClip.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFA0097840CE005D77BE /* FCDAnimationClip.h */; }; - C315DFE9097840FB005D77BE /* FCDAnimationCurve.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DFA1097840CE005D77BE /* FCDAnimationCurve.cpp */; }; - C315DFEA097840FC005D77BE /* FCDAnimationCurve.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFA2097840CE005D77BE /* FCDAnimationCurve.h */; }; - C315DFEB097840FD005D77BE /* FCDAnimationMultiCurve.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DFA3097840CE005D77BE /* FCDAnimationMultiCurve.cpp */; }; - C315DFEC097840FD005D77BE /* FCDAnimationMultiCurve.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFA4097840CE005D77BE /* FCDAnimationMultiCurve.h */; }; - C315DFED097840FE005D77BE /* FCDCamera.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DFA5097840CE005D77BE /* FCDCamera.cpp */; }; - C315DFEE097840FE005D77BE /* FCDCamera.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFA6097840CE005D77BE /* FCDCamera.h */; }; - C315DFF009784100005D77BE /* FCDController.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFA8097840CE005D77BE /* FCDController.h */; }; - C315DFF109784101005D77BE /* FCDController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DFA7097840CE005D77BE /* FCDController.cpp */; }; - C315DFF209784101005D77BE /* FCDEffect.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DFA9097840CE005D77BE /* FCDEffect.cpp */; }; - C315DFF309784104005D77BE /* FCDEffect.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFAA097840CE005D77BE /* FCDEffect.h */; }; - C315DFF409784104005D77BE /* FCDEffectParameter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DFAB097840CE005D77BE /* FCDEffectParameter.cpp */; }; - C315DFF509784105005D77BE /* FCDEffectProfile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DFAD097840CE005D77BE /* FCDEffectProfile.cpp */; }; - C315DFF609784105005D77BE /* FCDEffectParameter.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFAC097840CE005D77BE /* FCDEffectParameter.h */; }; - C315DFF709784106005D77BE /* FCDEffectProfile.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFAE097840CE005D77BE /* FCDEffectProfile.h */; }; - C315DFF809784106005D77BE /* FCDEffectStandard.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFB0097840CE005D77BE /* FCDEffectStandard.h */; }; - C315DFF909784106005D77BE /* FCDEffectStandard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DFAF097840CE005D77BE /* FCDEffectStandard.cpp */; }; - C315DFFA09784107005D77BE /* FCDEntity.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DFB1097840CE005D77BE /* FCDEntity.cpp */; }; - C315DFFB09784107005D77BE /* FCDEntity.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFB2097840CE005D77BE /* FCDEntity.h */; }; - C315DFFD09784108005D77BE /* FCDEntityInstance.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFB3097840CE005D77BE /* FCDEntityInstance.h */; }; - C315DFFE09784109005D77BE /* FCDExternalReference.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFB4097840CE005D77BE /* FCDExternalReference.h */; }; - C315DFFF09784109005D77BE /* FCDGeometry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DFB5097840CE005D77BE /* FCDGeometry.cpp */; }; - C315E0000978410A005D77BE /* FCDGeometry.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFB6097840CE005D77BE /* FCDGeometry.h */; }; - C315E0010978410A005D77BE /* FCDGeometryInput.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DFB7097840CE005D77BE /* FCDGeometryInput.cpp */; }; - C315E0020978410A005D77BE /* FCDGeometryInput.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFB8097840CE005D77BE /* FCDGeometryInput.h */; }; - C315E0030978410B005D77BE /* FCDGeometryInstance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DFB9097840CE005D77BE /* FCDGeometryInstance.cpp */; }; - C315E0040978410B005D77BE /* FCDGeometryInstance.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFBA097840CE005D77BE /* FCDGeometryInstance.h */; }; - C315E0050978410C005D77BE /* FCDGeometryPolygons.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DFBB097840CE005D77BE /* FCDGeometryPolygons.cpp */; }; - C315E0060978410E005D77BE /* FCDGeometryPolygons.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFBC097840CE005D77BE /* FCDGeometryPolygons.h */; }; - C315E0070978410E005D77BE /* FCDImage.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DFBD097840CE005D77BE /* FCDImage.cpp */; }; - C315E0080978410E005D77BE /* FCDImage.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFBE097840CE005D77BE /* FCDImage.h */; }; - C315E0090978410F005D77BE /* FCDLibrary.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFBF097840CE005D77BE /* FCDLibrary.h */; }; - C315E00C09784111005D77BE /* FCDLight.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DFC1097840CE005D77BE /* FCDLight.cpp */; }; - C315E00D09784111005D77BE /* FCDLibrary.hpp in Headers */ = {isa = PBXBuildFile; fileRef = C315DFC0097840CE005D77BE /* FCDLibrary.hpp */; }; - C315E00E09784112005D77BE /* FCDLight.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFC2097840CE005D77BE /* FCDLight.h */; }; - C315E00F09784113005D77BE /* FCDMaterial.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DFC3097840CE005D77BE /* FCDMaterial.cpp */; }; - C315E01009784113005D77BE /* FCDMaterial.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFC4097840CE005D77BE /* FCDMaterial.h */; }; - C315E01109784113005D77BE /* FCDMaterialInstance.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DFC5097840CE005D77BE /* FCDMaterialInstance.cpp */; }; - C315E01209784114005D77BE /* FCDMaterialInstance.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFC6097840CE005D77BE /* FCDMaterialInstance.h */; }; - C315E01309784114005D77BE /* FCDMaterialLibrary.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFC8097840CE005D77BE /* FCDMaterialLibrary.h */; }; - C315E01409784115005D77BE /* FCDMaterialLibrary.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DFC7097840CE005D77BE /* FCDMaterialLibrary.cpp */; }; - C315E01509784116005D77BE /* FCDMorphController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DFC9097840CE005D77BE /* FCDMorphController.cpp */; }; - C315E01609784116005D77BE /* FCDMorphController.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFCA097840CE005D77BE /* FCDMorphController.h */; }; - C315E01709784117005D77BE /* FCDocument.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DFCB097840CE005D77BE /* FCDocument.cpp */; }; - C315E01909784118005D77BE /* FCDocument.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFCC097840CE005D77BE /* FCDocument.h */; }; - C315E01F09784121005D77BE /* FCDSkinController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DFCF097840CE005D77BE /* FCDSkinController.cpp */; }; - C315E02109784123005D77BE /* FCDSkinController.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFD0097840CE005D77BE /* FCDSkinController.h */; }; - C315E02309784128005D77BE /* FCDSceneNode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DFCD097840CE005D77BE /* FCDSceneNode.cpp */; }; - C315E02409784129005D77BE /* FCDSceneNode.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFCE097840CE005D77BE /* FCDSceneNode.h */; }; - C315E0250978412A005D77BE /* FCDTargetedEntity.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DFD1097840CE005D77BE /* FCDTargetedEntity.cpp */; }; - C315E0260978412A005D77BE /* FCDTexture.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DFD3097840CE005D77BE /* FCDTexture.cpp */; }; - C315E0270978412A005D77BE /* FCDTargetedEntity.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFD2097840CE005D77BE /* FCDTargetedEntity.h */; }; - C315E0280978412A005D77BE /* FCDTexture.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFD4097840CE005D77BE /* FCDTexture.h */; }; - C315E0290978412B005D77BE /* FCDTransform.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DFD5097840CE005D77BE /* FCDTransform.cpp */; }; - C315E02A0978412C005D77BE /* FCDTransform.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DFD6097840CE005D77BE /* FCDTransform.h */; }; - C315E02B0978412C005D77BE /* FCollada.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DF7909784075005D77BE /* FCollada.h */; }; - C315E02C0978412D005D77BE /* FMath.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DF7C0978408D005D77BE /* FMath.h */; }; - C315E02D0978412D005D77BE /* FMMatrix44.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DF7D0978408D005D77BE /* FMMatrix44.cpp */; }; - C315E02E0978412E005D77BE /* FMMatrix44.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DF7E0978408D005D77BE /* FMMatrix44.h */; }; - C315E02F0978412F005D77BE /* FMVector3.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DF7F0978408D005D77BE /* FMVector3.cpp */; }; - C315E0300978412F005D77BE /* FMVector3.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DF800978408D005D77BE /* FMVector3.h */; }; - C315E03109784131005D77BE /* FMVector4.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DF810978408D005D77BE /* FMVector4.h */; }; - C315E03309784133005D77BE /* FUCrc32.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DF85097840BD005D77BE /* FUCrc32.h */; }; - C315E03409784134005D77BE /* FUCrc32.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DF84097840BD005D77BE /* FUCrc32.cpp */; }; - C315E03509784134005D77BE /* FUDaeEnum.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DF86097840BD005D77BE /* FUDaeEnum.cpp */; }; - C315E03609784135005D77BE /* FUDaeEnum.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DF87097840BD005D77BE /* FUDaeEnum.h */; }; - C315E03709784135005D77BE /* FUDaeParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DF88097840BD005D77BE /* FUDaeParser.cpp */; }; - C315E03809784136005D77BE /* FUDaeParser.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DF89097840BD005D77BE /* FUDaeParser.h */; }; - C315E03909784136005D77BE /* FUDebug.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DF8A097840BD005D77BE /* FUDebug.cpp */; }; - C315E03A09784137005D77BE /* FUDebug.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DF8B097840BD005D77BE /* FUDebug.h */; }; - C315E03B09784137005D77BE /* FUFileManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DF8C097840BD005D77BE /* FUFileManager.cpp */; }; - C315E03C09784138005D77BE /* FUFileManager.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DF8D097840BD005D77BE /* FUFileManager.h */; }; - C315E03D09784139005D77BE /* FUStatus.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DF8E097840BD005D77BE /* FUStatus.h */; }; - C315E03E0978413A005D77BE /* FUStringBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DF8F097840BD005D77BE /* FUStringBuilder.h */; }; - C315E03F0978413A005D77BE /* FUStringBuilder.hpp in Headers */ = {isa = PBXBuildFile; fileRef = C315DF90097840BD005D77BE /* FUStringBuilder.hpp */; }; - C315E0400978413A005D77BE /* FUStringConversion.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DF91097840BD005D77BE /* FUStringConversion.cpp */; }; - C315E0410978413B005D77BE /* FUStringConversion.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DF92097840BD005D77BE /* FUStringConversion.h */; }; - C315E0420978413B005D77BE /* FUtils.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DF93097840BD005D77BE /* FUtils.h */; }; - C315E0430978413C005D77BE /* FUUri.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DF94097840BD005D77BE /* FUUri.h */; }; - C315E0440978413C005D77BE /* FUXmlNodeIdPair.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DF95097840BD005D77BE /* FUXmlNodeIdPair.h */; }; - C315E0450978413E005D77BE /* FUXmlParser.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DF96097840BD005D77BE /* FUXmlParser.cpp */; }; - C315E0460978413F005D77BE /* FUXmlParser.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DF97097840BD005D77BE /* FUXmlParser.h */; }; - C315E04809784141005D77BE /* Platforms.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DF98097840BD005D77BE /* Platforms.h */; }; - C315E04909784142005D77BE /* StdAfx.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C315DF7A09784075005D77BE /* StdAfx.cpp */; }; - C315E04A09784143005D77BE /* StdAfx.h in Headers */ = {isa = PBXBuildFile; fileRef = C315DF7B09784075005D77BE /* StdAfx.h */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - C315DF7909784075005D77BE /* FCollada.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FCollada.h; sourceTree = ""; }; - C315DF7A09784075005D77BE /* StdAfx.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StdAfx.cpp; sourceTree = ""; }; - C315DF7B09784075005D77BE /* StdAfx.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StdAfx.h; sourceTree = ""; }; - C315DF7C0978408D005D77BE /* FMath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FMath.h; path = FMath/FMath.h; sourceTree = ""; }; - C315DF7D0978408D005D77BE /* FMMatrix44.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FMMatrix44.cpp; path = FMath/FMMatrix44.cpp; sourceTree = ""; }; - C315DF7E0978408D005D77BE /* FMMatrix44.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FMMatrix44.h; path = FMath/FMMatrix44.h; sourceTree = ""; }; - C315DF7F0978408D005D77BE /* FMVector3.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FMVector3.cpp; path = FMath/FMVector3.cpp; sourceTree = ""; }; - C315DF800978408D005D77BE /* FMVector3.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FMVector3.h; path = FMath/FMVector3.h; sourceTree = ""; }; - C315DF810978408D005D77BE /* FMVector4.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FMVector4.h; path = FMath/FMVector4.h; sourceTree = ""; }; - C315DF82097840A9005D77BE /* libxml2.la */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = libxml2.la; path = /usr/lib/libxml2.la; sourceTree = ""; }; - C315DF83097840BD005D77BE /* DaeSyntax.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DaeSyntax.h; path = FUtils/DaeSyntax.h; sourceTree = ""; }; - C315DF84097840BD005D77BE /* FUCrc32.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FUCrc32.cpp; path = FUtils/FUCrc32.cpp; sourceTree = ""; }; - C315DF85097840BD005D77BE /* FUCrc32.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FUCrc32.h; path = FUtils/FUCrc32.h; sourceTree = ""; }; - C315DF86097840BD005D77BE /* FUDaeEnum.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FUDaeEnum.cpp; path = FUtils/FUDaeEnum.cpp; sourceTree = ""; }; - C315DF87097840BD005D77BE /* FUDaeEnum.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FUDaeEnum.h; path = FUtils/FUDaeEnum.h; sourceTree = ""; }; - C315DF88097840BD005D77BE /* FUDaeParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FUDaeParser.cpp; path = FUtils/FUDaeParser.cpp; sourceTree = ""; }; - C315DF89097840BD005D77BE /* FUDaeParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FUDaeParser.h; path = FUtils/FUDaeParser.h; sourceTree = ""; }; - C315DF8A097840BD005D77BE /* FUDebug.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FUDebug.cpp; path = FUtils/FUDebug.cpp; sourceTree = ""; }; - C315DF8B097840BD005D77BE /* FUDebug.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FUDebug.h; path = FUtils/FUDebug.h; sourceTree = ""; }; - C315DF8C097840BD005D77BE /* FUFileManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FUFileManager.cpp; path = FUtils/FUFileManager.cpp; sourceTree = ""; }; - C315DF8D097840BD005D77BE /* FUFileManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FUFileManager.h; path = FUtils/FUFileManager.h; sourceTree = ""; }; - C315DF8E097840BD005D77BE /* FUStatus.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FUStatus.h; path = FUtils/FUStatus.h; sourceTree = ""; }; - C315DF8F097840BD005D77BE /* FUStringBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FUStringBuilder.h; path = FUtils/FUStringBuilder.h; sourceTree = ""; }; - C315DF90097840BD005D77BE /* FUStringBuilder.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = FUStringBuilder.hpp; path = FUtils/FUStringBuilder.hpp; sourceTree = ""; }; - C315DF91097840BD005D77BE /* FUStringConversion.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FUStringConversion.cpp; path = FUtils/FUStringConversion.cpp; sourceTree = ""; }; - C315DF92097840BD005D77BE /* FUStringConversion.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FUStringConversion.h; path = FUtils/FUStringConversion.h; sourceTree = ""; }; - C315DF93097840BD005D77BE /* FUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FUtils.h; path = FUtils/FUtils.h; sourceTree = ""; }; - C315DF94097840BD005D77BE /* FUUri.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FUUri.h; path = FUtils/FUUri.h; sourceTree = ""; }; - C315DF95097840BD005D77BE /* FUXmlNodeIdPair.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FUXmlNodeIdPair.h; path = FUtils/FUXmlNodeIdPair.h; sourceTree = ""; }; - C315DF96097840BD005D77BE /* FUXmlParser.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FUXmlParser.cpp; path = FUtils/FUXmlParser.cpp; sourceTree = ""; }; - C315DF97097840BD005D77BE /* FUXmlParser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FUXmlParser.h; path = FUtils/FUXmlParser.h; sourceTree = ""; }; - C315DF98097840BD005D77BE /* Platforms.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Platforms.h; path = FUtils/Platforms.h; sourceTree = ""; }; - C315DF99097840CE005D77BE /* FCDAnimated.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDAnimated.cpp; path = FCDocument/FCDAnimated.cpp; sourceTree = ""; }; - C315DF9A097840CE005D77BE /* FCDAnimated.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDAnimated.h; path = FCDocument/FCDAnimated.h; sourceTree = ""; }; - C315DF9B097840CE005D77BE /* FCDAnimation.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDAnimation.cpp; path = FCDocument/FCDAnimation.cpp; sourceTree = ""; }; - C315DF9C097840CE005D77BE /* FCDAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDAnimation.h; path = FCDocument/FCDAnimation.h; sourceTree = ""; }; - C315DF9D097840CE005D77BE /* FCDAnimationChannel.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDAnimationChannel.cpp; path = FCDocument/FCDAnimationChannel.cpp; sourceTree = ""; }; - C315DF9E097840CE005D77BE /* FCDAnimationChannel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDAnimationChannel.h; path = FCDocument/FCDAnimationChannel.h; sourceTree = ""; }; - C315DF9F097840CE005D77BE /* FCDAnimationClip.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDAnimationClip.cpp; path = FCDocument/FCDAnimationClip.cpp; sourceTree = ""; }; - C315DFA0097840CE005D77BE /* FCDAnimationClip.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDAnimationClip.h; path = FCDocument/FCDAnimationClip.h; sourceTree = ""; }; - C315DFA1097840CE005D77BE /* FCDAnimationCurve.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDAnimationCurve.cpp; path = FCDocument/FCDAnimationCurve.cpp; sourceTree = ""; }; - C315DFA2097840CE005D77BE /* FCDAnimationCurve.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDAnimationCurve.h; path = FCDocument/FCDAnimationCurve.h; sourceTree = ""; }; - C315DFA3097840CE005D77BE /* FCDAnimationMultiCurve.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDAnimationMultiCurve.cpp; path = FCDocument/FCDAnimationMultiCurve.cpp; sourceTree = ""; }; - C315DFA4097840CE005D77BE /* FCDAnimationMultiCurve.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDAnimationMultiCurve.h; path = FCDocument/FCDAnimationMultiCurve.h; sourceTree = ""; }; - C315DFA5097840CE005D77BE /* FCDCamera.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDCamera.cpp; path = FCDocument/FCDCamera.cpp; sourceTree = ""; }; - C315DFA6097840CE005D77BE /* FCDCamera.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDCamera.h; path = FCDocument/FCDCamera.h; sourceTree = ""; }; - C315DFA7097840CE005D77BE /* FCDController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDController.cpp; path = FCDocument/FCDController.cpp; sourceTree = ""; }; - C315DFA8097840CE005D77BE /* FCDController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDController.h; path = FCDocument/FCDController.h; sourceTree = ""; }; - C315DFA9097840CE005D77BE /* FCDEffect.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDEffect.cpp; path = FCDocument/FCDEffect.cpp; sourceTree = ""; }; - C315DFAA097840CE005D77BE /* FCDEffect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDEffect.h; path = FCDocument/FCDEffect.h; sourceTree = ""; }; - C315DFAB097840CE005D77BE /* FCDEffectParameter.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDEffectParameter.cpp; path = FCDocument/FCDEffectParameter.cpp; sourceTree = ""; }; - C315DFAC097840CE005D77BE /* FCDEffectParameter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDEffectParameter.h; path = FCDocument/FCDEffectParameter.h; sourceTree = ""; }; - C315DFAD097840CE005D77BE /* FCDEffectProfile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDEffectProfile.cpp; path = FCDocument/FCDEffectProfile.cpp; sourceTree = ""; }; - C315DFAE097840CE005D77BE /* FCDEffectProfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDEffectProfile.h; path = FCDocument/FCDEffectProfile.h; sourceTree = ""; }; - C315DFAF097840CE005D77BE /* FCDEffectStandard.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDEffectStandard.cpp; path = FCDocument/FCDEffectStandard.cpp; sourceTree = ""; }; - C315DFB0097840CE005D77BE /* FCDEffectStandard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDEffectStandard.h; path = FCDocument/FCDEffectStandard.h; sourceTree = ""; }; - C315DFB1097840CE005D77BE /* FCDEntity.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDEntity.cpp; path = FCDocument/FCDEntity.cpp; sourceTree = ""; }; - C315DFB2097840CE005D77BE /* FCDEntity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDEntity.h; path = FCDocument/FCDEntity.h; sourceTree = ""; }; - C315DFB3097840CE005D77BE /* FCDEntityInstance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDEntityInstance.h; path = FCDocument/FCDEntityInstance.h; sourceTree = ""; }; - C315DFB4097840CE005D77BE /* FCDExternalReference.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDExternalReference.h; path = FCDocument/FCDExternalReference.h; sourceTree = ""; }; - C315DFB5097840CE005D77BE /* FCDGeometry.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDGeometry.cpp; path = FCDocument/FCDGeometry.cpp; sourceTree = ""; }; - C315DFB6097840CE005D77BE /* FCDGeometry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDGeometry.h; path = FCDocument/FCDGeometry.h; sourceTree = ""; }; - C315DFB7097840CE005D77BE /* FCDGeometryInput.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDGeometryInput.cpp; path = FCDocument/FCDGeometryInput.cpp; sourceTree = ""; }; - C315DFB8097840CE005D77BE /* FCDGeometryInput.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDGeometryInput.h; path = FCDocument/FCDGeometryInput.h; sourceTree = ""; }; - C315DFB9097840CE005D77BE /* FCDGeometryInstance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDGeometryInstance.cpp; path = FCDocument/FCDGeometryInstance.cpp; sourceTree = ""; }; - C315DFBA097840CE005D77BE /* FCDGeometryInstance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDGeometryInstance.h; path = FCDocument/FCDGeometryInstance.h; sourceTree = ""; }; - C315DFBB097840CE005D77BE /* FCDGeometryPolygons.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDGeometryPolygons.cpp; path = FCDocument/FCDGeometryPolygons.cpp; sourceTree = ""; }; - C315DFBC097840CE005D77BE /* FCDGeometryPolygons.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDGeometryPolygons.h; path = FCDocument/FCDGeometryPolygons.h; sourceTree = ""; }; - C315DFBD097840CE005D77BE /* FCDImage.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDImage.cpp; path = FCDocument/FCDImage.cpp; sourceTree = ""; }; - C315DFBE097840CE005D77BE /* FCDImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDImage.h; path = FCDocument/FCDImage.h; sourceTree = ""; }; - C315DFBF097840CE005D77BE /* FCDLibrary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDLibrary.h; path = FCDocument/FCDLibrary.h; sourceTree = ""; }; - C315DFC0097840CE005D77BE /* FCDLibrary.hpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.h; name = FCDLibrary.hpp; path = FCDocument/FCDLibrary.hpp; sourceTree = ""; }; - C315DFC1097840CE005D77BE /* FCDLight.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDLight.cpp; path = FCDocument/FCDLight.cpp; sourceTree = ""; }; - C315DFC2097840CE005D77BE /* FCDLight.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDLight.h; path = FCDocument/FCDLight.h; sourceTree = ""; }; - C315DFC3097840CE005D77BE /* FCDMaterial.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDMaterial.cpp; path = FCDocument/FCDMaterial.cpp; sourceTree = ""; }; - C315DFC4097840CE005D77BE /* FCDMaterial.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDMaterial.h; path = FCDocument/FCDMaterial.h; sourceTree = ""; }; - C315DFC5097840CE005D77BE /* FCDMaterialInstance.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDMaterialInstance.cpp; path = FCDocument/FCDMaterialInstance.cpp; sourceTree = ""; }; - C315DFC6097840CE005D77BE /* FCDMaterialInstance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDMaterialInstance.h; path = FCDocument/FCDMaterialInstance.h; sourceTree = ""; }; - C315DFC7097840CE005D77BE /* FCDMaterialLibrary.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDMaterialLibrary.cpp; path = FCDocument/FCDMaterialLibrary.cpp; sourceTree = ""; }; - C315DFC8097840CE005D77BE /* FCDMaterialLibrary.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDMaterialLibrary.h; path = FCDocument/FCDMaterialLibrary.h; sourceTree = ""; }; - C315DFC9097840CE005D77BE /* FCDMorphController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDMorphController.cpp; path = FCDocument/FCDMorphController.cpp; sourceTree = ""; }; - C315DFCA097840CE005D77BE /* FCDMorphController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDMorphController.h; path = FCDocument/FCDMorphController.h; sourceTree = ""; }; - C315DFCB097840CE005D77BE /* FCDocument.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDocument.cpp; path = FCDocument/FCDocument.cpp; sourceTree = ""; }; - C315DFCC097840CE005D77BE /* FCDocument.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDocument.h; path = FCDocument/FCDocument.h; sourceTree = ""; }; - C315DFCD097840CE005D77BE /* FCDSceneNode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDSceneNode.cpp; path = FCDocument/FCDSceneNode.cpp; sourceTree = ""; }; - C315DFCE097840CE005D77BE /* FCDSceneNode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDSceneNode.h; path = FCDocument/FCDSceneNode.h; sourceTree = ""; }; - C315DFCF097840CE005D77BE /* FCDSkinController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDSkinController.cpp; path = FCDocument/FCDSkinController.cpp; sourceTree = ""; }; - C315DFD0097840CE005D77BE /* FCDSkinController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDSkinController.h; path = FCDocument/FCDSkinController.h; sourceTree = ""; }; - C315DFD1097840CE005D77BE /* FCDTargetedEntity.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDTargetedEntity.cpp; path = FCDocument/FCDTargetedEntity.cpp; sourceTree = ""; }; - C315DFD2097840CE005D77BE /* FCDTargetedEntity.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDTargetedEntity.h; path = FCDocument/FCDTargetedEntity.h; sourceTree = ""; }; - C315DFD3097840CE005D77BE /* FCDTexture.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDTexture.cpp; path = FCDocument/FCDTexture.cpp; sourceTree = ""; }; - C315DFD4097840CE005D77BE /* FCDTexture.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDTexture.h; path = FCDocument/FCDTexture.h; sourceTree = ""; }; - C315DFD5097840CE005D77BE /* FCDTransform.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FCDTransform.cpp; path = FCDocument/FCDTransform.cpp; sourceTree = ""; }; - C315DFD6097840CE005D77BE /* FCDTransform.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FCDTransform.h; path = FCDocument/FCDTransform.h; sourceTree = ""; }; - C315DFDB097840EB005D77BE /* libFCollada.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libFCollada.a; sourceTree = BUILT_PRODUCTS_DIR; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - C315DFD9097840EB005D77BE /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - C315DF5D09783EFB005D77BE = { - isa = PBXGroup; - children = ( - C315DF99097840CE005D77BE /* FCDAnimated.cpp */, - C315DF9A097840CE005D77BE /* FCDAnimated.h */, - C315DF9B097840CE005D77BE /* FCDAnimation.cpp */, - C315DF9C097840CE005D77BE /* FCDAnimation.h */, - C315DF9D097840CE005D77BE /* FCDAnimationChannel.cpp */, - C315DF9E097840CE005D77BE /* FCDAnimationChannel.h */, - C315DF9F097840CE005D77BE /* FCDAnimationClip.cpp */, - C315DFA0097840CE005D77BE /* FCDAnimationClip.h */, - C315DFA1097840CE005D77BE /* FCDAnimationCurve.cpp */, - C315DFA2097840CE005D77BE /* FCDAnimationCurve.h */, - C315DFA3097840CE005D77BE /* FCDAnimationMultiCurve.cpp */, - C315DFA4097840CE005D77BE /* FCDAnimationMultiCurve.h */, - C315DFA5097840CE005D77BE /* FCDCamera.cpp */, - C315DFA6097840CE005D77BE /* FCDCamera.h */, - C315DFA7097840CE005D77BE /* FCDController.cpp */, - C315DFA8097840CE005D77BE /* FCDController.h */, - C315DFA9097840CE005D77BE /* FCDEffect.cpp */, - C315DFAA097840CE005D77BE /* FCDEffect.h */, - C315DFAB097840CE005D77BE /* FCDEffectParameter.cpp */, - C315DFAC097840CE005D77BE /* FCDEffectParameter.h */, - C315DFAD097840CE005D77BE /* FCDEffectProfile.cpp */, - C315DFAE097840CE005D77BE /* FCDEffectProfile.h */, - C315DFAF097840CE005D77BE /* FCDEffectStandard.cpp */, - C315DFB0097840CE005D77BE /* FCDEffectStandard.h */, - C315DFB1097840CE005D77BE /* FCDEntity.cpp */, - C315DFB2097840CE005D77BE /* FCDEntity.h */, - C315DFB3097840CE005D77BE /* FCDEntityInstance.h */, - C315DFB4097840CE005D77BE /* FCDExternalReference.h */, - C315DFB5097840CE005D77BE /* FCDGeometry.cpp */, - C315DFB6097840CE005D77BE /* FCDGeometry.h */, - C315DFB7097840CE005D77BE /* FCDGeometryInput.cpp */, - C315DFB8097840CE005D77BE /* FCDGeometryInput.h */, - C315DFB9097840CE005D77BE /* FCDGeometryInstance.cpp */, - C315DFBA097840CE005D77BE /* FCDGeometryInstance.h */, - C315DFBB097840CE005D77BE /* FCDGeometryPolygons.cpp */, - C315DFBC097840CE005D77BE /* FCDGeometryPolygons.h */, - C315DFBD097840CE005D77BE /* FCDImage.cpp */, - C315DFBE097840CE005D77BE /* FCDImage.h */, - C315DFBF097840CE005D77BE /* FCDLibrary.h */, - C315DFC0097840CE005D77BE /* FCDLibrary.hpp */, - C315DFC1097840CE005D77BE /* FCDLight.cpp */, - C315DFC2097840CE005D77BE /* FCDLight.h */, - C315DFC3097840CE005D77BE /* FCDMaterial.cpp */, - C315DFC4097840CE005D77BE /* FCDMaterial.h */, - C315DFC5097840CE005D77BE /* FCDMaterialInstance.cpp */, - C315DFC6097840CE005D77BE /* FCDMaterialInstance.h */, - C315DFC7097840CE005D77BE /* FCDMaterialLibrary.cpp */, - C315DFC8097840CE005D77BE /* FCDMaterialLibrary.h */, - C315DFC9097840CE005D77BE /* FCDMorphController.cpp */, - C315DFCA097840CE005D77BE /* FCDMorphController.h */, - C315DFCB097840CE005D77BE /* FCDocument.cpp */, - C315DFCC097840CE005D77BE /* FCDocument.h */, - C315DFCD097840CE005D77BE /* FCDSceneNode.cpp */, - C315DFCE097840CE005D77BE /* FCDSceneNode.h */, - C315DFCF097840CE005D77BE /* FCDSkinController.cpp */, - C315DFD0097840CE005D77BE /* FCDSkinController.h */, - C315DFD1097840CE005D77BE /* FCDTargetedEntity.cpp */, - C315DFD2097840CE005D77BE /* FCDTargetedEntity.h */, - C315DFD3097840CE005D77BE /* FCDTexture.cpp */, - C315DFD4097840CE005D77BE /* FCDTexture.h */, - C315DFD5097840CE005D77BE /* FCDTransform.cpp */, - C315DFD6097840CE005D77BE /* FCDTransform.h */, - C315DF83097840BD005D77BE /* DaeSyntax.h */, - C315DF84097840BD005D77BE /* FUCrc32.cpp */, - C315DF85097840BD005D77BE /* FUCrc32.h */, - C315DF86097840BD005D77BE /* FUDaeEnum.cpp */, - C315DF87097840BD005D77BE /* FUDaeEnum.h */, - C315DF88097840BD005D77BE /* FUDaeParser.cpp */, - C315DF89097840BD005D77BE /* FUDaeParser.h */, - C315DF8A097840BD005D77BE /* FUDebug.cpp */, - C315DF8B097840BD005D77BE /* FUDebug.h */, - C315DF8C097840BD005D77BE /* FUFileManager.cpp */, - C315DF8D097840BD005D77BE /* FUFileManager.h */, - C315DF8E097840BD005D77BE /* FUStatus.h */, - C315DF8F097840BD005D77BE /* FUStringBuilder.h */, - C315DF90097840BD005D77BE /* FUStringBuilder.hpp */, - C315DF91097840BD005D77BE /* FUStringConversion.cpp */, - C315DF92097840BD005D77BE /* FUStringConversion.h */, - C315DF93097840BD005D77BE /* FUtils.h */, - C315DF94097840BD005D77BE /* FUUri.h */, - C315DF95097840BD005D77BE /* FUXmlNodeIdPair.h */, - C315DF96097840BD005D77BE /* FUXmlParser.cpp */, - C315DF97097840BD005D77BE /* FUXmlParser.h */, - C315DF98097840BD005D77BE /* Platforms.h */, - C315DF82097840A9005D77BE /* libxml2.la */, - C315DF7C0978408D005D77BE /* FMath.h */, - C315DF7D0978408D005D77BE /* FMMatrix44.cpp */, - C315DF7E0978408D005D77BE /* FMMatrix44.h */, - C315DF7F0978408D005D77BE /* FMVector3.cpp */, - C315DF800978408D005D77BE /* FMVector3.h */, - C315DF810978408D005D77BE /* FMVector4.h */, - C315DF7909784075005D77BE /* FCollada.h */, - C315DF7A09784075005D77BE /* StdAfx.cpp */, - C315DF7B09784075005D77BE /* StdAfx.h */, - C315DFDC097840EB005D77BE /* Products */, - ); - sourceTree = ""; - }; - C315DFDC097840EB005D77BE /* Products */ = { - isa = PBXGroup; - children = ( - C315DFDB097840EB005D77BE /* libFCollada.a */, - ); - name = Products; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - C315DFD7097840EB005D77BE /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - C315DFE0097840F5005D77BE /* DaeSyntax.h in Headers */, - C315DFE2097840F6005D77BE /* FCDAnimated.h in Headers */, - C315DFE4097840F7005D77BE /* FCDAnimation.h in Headers */, - C315DFE6097840FA005D77BE /* FCDAnimationChannel.h in Headers */, - C315DFE8097840FB005D77BE /* FCDAnimationClip.h in Headers */, - C315DFEA097840FC005D77BE /* FCDAnimationCurve.h in Headers */, - C315DFEC097840FD005D77BE /* FCDAnimationMultiCurve.h in Headers */, - C315DFEE097840FE005D77BE /* FCDCamera.h in Headers */, - C315DFF009784100005D77BE /* FCDController.h in Headers */, - C315DFF309784104005D77BE /* FCDEffect.h in Headers */, - C315DFF609784105005D77BE /* FCDEffectParameter.h in Headers */, - C315DFF709784106005D77BE /* FCDEffectProfile.h in Headers */, - C315DFF809784106005D77BE /* FCDEffectStandard.h in Headers */, - C315DFFB09784107005D77BE /* FCDEntity.h in Headers */, - C315DFFD09784108005D77BE /* FCDEntityInstance.h in Headers */, - C315DFFE09784109005D77BE /* FCDExternalReference.h in Headers */, - C315E0000978410A005D77BE /* FCDGeometry.h in Headers */, - C315E0020978410A005D77BE /* FCDGeometryInput.h in Headers */, - C315E0040978410B005D77BE /* FCDGeometryInstance.h in Headers */, - C315E0060978410E005D77BE /* FCDGeometryPolygons.h in Headers */, - C315E0080978410E005D77BE /* FCDImage.h in Headers */, - C315E0090978410F005D77BE /* FCDLibrary.h in Headers */, - C315E00D09784111005D77BE /* FCDLibrary.hpp in Headers */, - C315E00E09784112005D77BE /* FCDLight.h in Headers */, - C315E01009784113005D77BE /* FCDMaterial.h in Headers */, - C315E01209784114005D77BE /* FCDMaterialInstance.h in Headers */, - C315E01309784114005D77BE /* FCDMaterialLibrary.h in Headers */, - C315E01609784116005D77BE /* FCDMorphController.h in Headers */, - C315E01909784118005D77BE /* FCDocument.h in Headers */, - C315E02109784123005D77BE /* FCDSkinController.h in Headers */, - C315E02409784129005D77BE /* FCDSceneNode.h in Headers */, - C315E0270978412A005D77BE /* FCDTargetedEntity.h in Headers */, - C315E0280978412A005D77BE /* FCDTexture.h in Headers */, - C315E02A0978412C005D77BE /* FCDTransform.h in Headers */, - C315E02B0978412C005D77BE /* FCollada.h in Headers */, - C315E02C0978412D005D77BE /* FMath.h in Headers */, - C315E02E0978412E005D77BE /* FMMatrix44.h in Headers */, - C315E0300978412F005D77BE /* FMVector3.h in Headers */, - C315E03109784131005D77BE /* FMVector4.h in Headers */, - C315E03309784133005D77BE /* FUCrc32.h in Headers */, - C315E03609784135005D77BE /* FUDaeEnum.h in Headers */, - C315E03809784136005D77BE /* FUDaeParser.h in Headers */, - C315E03A09784137005D77BE /* FUDebug.h in Headers */, - C315E03C09784138005D77BE /* FUFileManager.h in Headers */, - C315E03D09784139005D77BE /* FUStatus.h in Headers */, - C315E03E0978413A005D77BE /* FUStringBuilder.h in Headers */, - C315E03F0978413A005D77BE /* FUStringBuilder.hpp in Headers */, - C315E0410978413B005D77BE /* FUStringConversion.h in Headers */, - C315E0420978413B005D77BE /* FUtils.h in Headers */, - C315E0430978413C005D77BE /* FUUri.h in Headers */, - C315E0440978413C005D77BE /* FUXmlNodeIdPair.h in Headers */, - C315E0460978413F005D77BE /* FUXmlParser.h in Headers */, - C315E04809784141005D77BE /* Platforms.h in Headers */, - C315E04A09784143005D77BE /* StdAfx.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXNativeTarget section */ - C315DFDA097840EB005D77BE /* FCollada */ = { - isa = PBXNativeTarget; - buildConfigurationList = C315DFDD097840EB005D77BE /* Build configuration list for PBXNativeTarget "FCollada" */; - buildPhases = ( - C315DFD7097840EB005D77BE /* Headers */, - C315DFD8097840EB005D77BE /* Sources */, - C315DFD9097840EB005D77BE /* Frameworks */, - ); - buildRules = ( - ); - buildSettings = { - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - INSTALL_PATH = "$(HOME)/lib"; - LIBRARY_STYLE = STATIC; - OPTIMIZATION_CFLAGS = ""; - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PREBINDING = NO; - PRODUCT_NAME = FCollada; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = ( - "-Wmost", - "-Wno-four-char-constants", - "-Wno-unknown-pragmas", - ); - }; - dependencies = ( - ); - name = FCollada; - productName = FCollada; - productReference = C315DFDB097840EB005D77BE /* libFCollada.a */; - productType = "com.apple.product-type.library.static"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - C315DF5F09783EFB005D77BE /* Project object */ = { - isa = PBXProject; - buildConfigurationList = C315DF6009783EFB005D77BE /* Build configuration list for PBXProject "FCollada" */; - buildStyles = ( - ); - hasScannedForEncodings = 0; - mainGroup = C315DF5D09783EFB005D77BE; - productRefGroup = C315DFDC097840EB005D77BE /* Products */; - projectDirPath = ""; - targets = ( - C315DFDA097840EB005D77BE /* FCollada */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXSourcesBuildPhase section */ - C315DFD8097840EB005D77BE /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - C315DFE1097840F5005D77BE /* FCDAnimated.cpp in Sources */, - C315DFE3097840F6005D77BE /* FCDAnimation.cpp in Sources */, - C315DFE5097840F7005D77BE /* FCDAnimationChannel.cpp in Sources */, - C315DFE7097840FA005D77BE /* FCDAnimationClip.cpp in Sources */, - C315DFE9097840FB005D77BE /* FCDAnimationCurve.cpp in Sources */, - C315DFEB097840FD005D77BE /* FCDAnimationMultiCurve.cpp in Sources */, - C315DFED097840FE005D77BE /* FCDCamera.cpp in Sources */, - C315DFF109784101005D77BE /* FCDController.cpp in Sources */, - C315DFF209784101005D77BE /* FCDEffect.cpp in Sources */, - C315DFF409784104005D77BE /* FCDEffectParameter.cpp in Sources */, - C315DFF509784105005D77BE /* FCDEffectProfile.cpp in Sources */, - C315DFF909784106005D77BE /* FCDEffectStandard.cpp in Sources */, - C315DFFA09784107005D77BE /* FCDEntity.cpp in Sources */, - C315DFFF09784109005D77BE /* FCDGeometry.cpp in Sources */, - C315E0010978410A005D77BE /* FCDGeometryInput.cpp in Sources */, - C315E0030978410B005D77BE /* FCDGeometryInstance.cpp in Sources */, - C315E0050978410C005D77BE /* FCDGeometryPolygons.cpp in Sources */, - C315E0070978410E005D77BE /* FCDImage.cpp in Sources */, - C315E00C09784111005D77BE /* FCDLight.cpp in Sources */, - C315E00F09784113005D77BE /* FCDMaterial.cpp in Sources */, - C315E01109784113005D77BE /* FCDMaterialInstance.cpp in Sources */, - C315E01409784115005D77BE /* FCDMaterialLibrary.cpp in Sources */, - C315E01509784116005D77BE /* FCDMorphController.cpp in Sources */, - C315E01709784117005D77BE /* FCDocument.cpp in Sources */, - C315E01F09784121005D77BE /* FCDSkinController.cpp in Sources */, - C315E02309784128005D77BE /* FCDSceneNode.cpp in Sources */, - C315E0250978412A005D77BE /* FCDTargetedEntity.cpp in Sources */, - C315E0260978412A005D77BE /* FCDTexture.cpp in Sources */, - C315E0290978412B005D77BE /* FCDTransform.cpp in Sources */, - C315E02D0978412D005D77BE /* FMMatrix44.cpp in Sources */, - C315E02F0978412F005D77BE /* FMVector3.cpp in Sources */, - C315E03409784134005D77BE /* FUCrc32.cpp in Sources */, - C315E03509784134005D77BE /* FUDaeEnum.cpp in Sources */, - C315E03709784135005D77BE /* FUDaeParser.cpp in Sources */, - C315E03909784136005D77BE /* FUDebug.cpp in Sources */, - C315E03B09784137005D77BE /* FUFileManager.cpp in Sources */, - C315E0400978413A005D77BE /* FUStringConversion.cpp in Sources */, - C315E0450978413E005D77BE /* FUXmlParser.cpp in Sources */, - C315E04909784142005D77BE /* StdAfx.cpp in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - C315DF6109783EFB005D77BE /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_MODEL_TUNING = G4; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = StdAfx.h; - GCC_PREPROCESSOR_DEFINITIONS = MAC_TIGER; - HEADER_SEARCH_PATHS = ( - /usr/include/libxml2, - ., - ); - LIBRARY_SEARCH_PATHS = /usr/lib; - OTHER_LDFLAGS = "-lxml2"; - }; - name = Debug; - }; - C315DF6209783EFB005D77BE /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - GCC_MODEL_TUNING = G4; - GCC_PRECOMPILE_PREFIX_HEADER = YES; - GCC_PREFIX_HEADER = StdAfx.h; - GCC_PREPROCESSOR_DEFINITIONS = MAC_TIGER; - HEADER_SEARCH_PATHS = ( - /usr/include/libxml2, - ., - ); - LIBRARY_SEARCH_PATHS = /usr/lib; - OTHER_LDFLAGS = "-lxml2"; - }; - name = Release; - }; - C315DFDE097840EB005D77BE /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = NO; - GCC_GENERATE_DEBUGGING_SYMBOLS = YES; - GCC_MODEL_TUNING = G5; - INSTALL_PATH = "$(HOME)/lib"; - LIBRARY_STYLE = STATIC; - OPTIMIZATION_CFLAGS = ""; - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PREBINDING = NO; - PRODUCT_NAME = FCollada; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = ( - "-Wmost", - "-Wno-four-char-constants", - "-Wno-unknown-pragmas", - ); - }; - name = Debug; - }; - C315DFDF097840EB005D77BE /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - COPY_PHASE_STRIP = YES; - GCC_GENERATE_DEBUGGING_SYMBOLS = NO; - GCC_MODEL_TUNING = G5; - INSTALL_PATH = "$(HOME)/lib"; - LIBRARY_STYLE = STATIC; - OPTIMIZATION_CFLAGS = ""; - OTHER_CFLAGS = ""; - OTHER_LDFLAGS = ""; - OTHER_REZFLAGS = ""; - PREBINDING = NO; - PRODUCT_NAME = FCollada; - SECTORDER_FLAGS = ""; - WARNING_CFLAGS = ( - "-Wmost", - "-Wno-four-char-constants", - "-Wno-unknown-pragmas", - ); - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - C315DF6009783EFB005D77BE /* Build configuration list for PBXProject "FCollada" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - C315DF6109783EFB005D77BE /* Debug */, - C315DF6209783EFB005D77BE /* Release */, - ); - defaultConfigurationIsVisible = 0; - }; - C315DFDD097840EB005D77BE /* Build configuration list for PBXNativeTarget "FCollada" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - C315DFDE097840EB005D77BE /* Debug */, - C315DFDF097840EB005D77BE /* Release */, - ); - defaultConfigurationIsVisible = 0; - }; -/* End XCConfigurationList section */ - }; - rootObject = C315DF5F09783EFB005D77BE /* Project object */; -} diff --git a/Extras/FCollada/FColladaLib.cpp b/Extras/FCollada/FColladaLib.cpp deleted file mode 100644 index 76159d060..000000000 --- a/Extras/FCollada/FColladaLib.cpp +++ /dev/null @@ -1,11 +0,0 @@ -/* -* Copyright (C) 2005-2006 Feeling Software Inc -* MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -// This file contains just a dummy to force MSVC to generate an output for -// this project, using the correct FCollada library. - -void Dummy() -{ -} \ No newline at end of file diff --git a/Extras/FCollada/FColladaLib_vc7.vcproj b/Extras/FCollada/FColladaLib_vc7.vcproj deleted file mode 100644 index 24ff0b9f1..000000000 --- a/Extras/FCollada/FColladaLib_vc7.vcproj +++ /dev/null @@ -1,1158 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/FCollada/FColladaLib_vc8.vcproj b/Extras/FCollada/FColladaLib_vc8.vcproj deleted file mode 100644 index 261aff37a..000000000 --- a/Extras/FCollada/FColladaLib_vc8.vcproj +++ /dev/null @@ -1,1158 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/FCollada/FColladaTest/FCTest.cpp b/Extras/FCollada/FColladaTest/FCTest.cpp deleted file mode 100644 index 68fe29d2d..000000000 --- a/Extras/FCollada/FColladaTest/FCTest.cpp +++ /dev/null @@ -1,24 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - Available only to licensees. - Distribution of this file or its content is strictly prohibited. -*/ - -#include "StdAfx.h" -#include - -int _tmain(int UNUSED(argc), TCHAR* UNUSED(argv)[]) -{ - // Set the current folder to the folder with the samples DAE files - chdir("Samples\\"); - - // First, declare all the test functions. -#define FCTEST(test_fn) extern void test_fn() -#include "FCTestList.h" -#undef FCTEST - - // Second, call them one at a time. -#define FCTEST(test_fn) test_fn() -#include "FCTestList.h" -#undef FCTEST -} \ No newline at end of file diff --git a/Extras/FCollada/FColladaTest/FCTest.h b/Extras/FCollada/FColladaTest/FCTest.h deleted file mode 100644 index deb2e0906..000000000 --- a/Extras/FCollada/FColladaTest/FCTest.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - Available only to licensees. - Distribution of this file or its content is strictly prohibited. -*/ - -#ifndef _FC_TEST_H_ -#define _FC_TEST_H_ - -inline void PassIf(bool condition) -{ - if (!condition) - { - FUFail(exit(-1)); - } -} -inline void FailIf(bool condition) { return PassIf(!condition); } -inline void CheckStatus(const FUStatus& s) { PassIf(s.IsSuccessful()); } - -#endif // _FC_TEST_H_ \ No newline at end of file diff --git a/Extras/FCollada/FColladaTest/FCTestAnimation.cpp b/Extras/FCollada/FColladaTest/FCTestAnimation.cpp deleted file mode 100644 index 2364aaa21..000000000 --- a/Extras/FCollada/FColladaTest/FCTestAnimation.cpp +++ /dev/null @@ -1,23 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - Available only to licensees. - Distribution of this file or its content is strictly prohibited. -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDSceneNode.h" - -// Test import of the Eagle sample, retrieves the "Bone09" joint and does the import sampling to verify its correctness. -void TestImportSampling() -{ - FCDocument document; - CheckStatus(document.LoadFromFile(FC("Eagle.DAE"))); - FCDSceneNode* node = document.FindSceneNode("Bone09"); - FailIf(node == NULL); - - FloatList keys; FMMatrix44List values; - node->GenerateSampledMatrixAnimation(keys, values); - FailIf(keys.size() > 30); - PassIf(keys.size() == values.size()); -} diff --git a/Extras/FCollada/FColladaTest/FCTestExportImport/FCTEIAnimation.cpp b/Extras/FCollada/FColladaTest/FCTestExportImport/FCTEIAnimation.cpp deleted file mode 100644 index 0f38546e1..000000000 --- a/Extras/FCollada/FColladaTest/FCTestExportImport/FCTEIAnimation.cpp +++ /dev/null @@ -1,110 +0,0 @@ -/* - Copyright (C) 2006 Feeling Software Inc. - Available only to licensees. - Distribution of this file or its content is strictly prohibited. -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDAnimated.h" -#include "FCDocument/FCDAnimation.h" -#include "FCDocument/FCDAnimationChannel.h" -#include "FCDocument/FCDAnimationCurve.h" -#include "FCDocument/FCDLight.h" -#include "FCTestExportImport.h" - -static string animId1 = "GrossAnimation"; -static string animId2 = "GrossAnimation"; -static string animatedLightId; -static const fstring animSubTreeNote = FS("TestingSTNote"); - -namespace FCTestExportImport -{ - void FillAnimationLibrary(FCDAnimationLibrary* library) - { - // Create two more tree within the animation library - FailIf(library == NULL); - size_t startAnimCount = library->GetEntityCount(); - FCDAnimation* animTree1 = library->AddEntity(); - FCDAnimation* animTree2 = library->AddEntity(); - PassIf(library->GetEntityCount() == startAnimCount + 2); - - // Retrieve the ids of the created entities. - animTree2->SetDaeId(animId2); - animTree1->SetDaeId(animId1); - FailIf(animId1.empty()); - FailIf(animId2.empty()); - FailIf(animId1 == animId2); - - // Add to the first animation tree some sub-trees. - FCDAnimation* animSubTree1 = animTree1->AddChild(); - FCDAnimation* animSubTree2 = animTree1->AddChild(); - animSubTree1->SetNote(animSubTreeNote); - animSubTree2->SetNote(animSubTreeNote); - FailIf(animTree1->GetChildCount() != 2); - - // Animate some selected parameters - FillAnimationLight(library->GetDocument(), animSubTree2); - } - - void CheckAnimationLibrary(FCDAnimationLibrary* library) - { - FailIf(library == NULL); - - // Retrieve the animation trees using the saved ids. - FCDAnimation* animTree1 = library->FindDaeId(animId1); - FCDAnimation* animTree2 = library->FindDaeId(animId2); - FailIf(animTree1 == NULL); - FailIf(animTree2 == NULL); - - // Verify that the first animation tree has the correct sub-trees. - // Retrieve the animation sub-tree which contains our channels. - FCDAnimation* ourChannels = NULL; - FailIf(animTree1->GetChildCount() != 2); - for (size_t i = 0; i < 2; ++i) - { - FCDAnimation* subTree = animTree1->GetChild(i); - FailIf(subTree == NULL); - PassIf(subTree->GetNote() == animSubTreeNote); - if (subTree->GetChannelCount() > 0) - { - PassIf(ourChannels == NULL); - ourChannels = subTree; - } - } - - PassIf(ourChannels != NULL); - CheckAnimationLight(library->GetDocument(), ourChannels); - } - - void FillAnimationLight(FCDocument* document, FCDAnimation* animationTree) - { - // Retrieve a light entity and add an animation to its color - FCDLightLibrary* lightLibrary = document->GetLightLibrary(); - PassIf(lightLibrary != NULL); - PassIf(lightLibrary->GetEntityCount() > 0); - FCDLight* light1 = lightLibrary->GetEntity(0); - animatedLightId = light1->GetDaeId(); - - // Create the animated object for the color - PassIf(document->FindAnimatedValue(&light1->GetColor().x) == NULL); - FCDAnimatedColor* animated = FCDAnimatedColor::Create(document, &light1->GetColor()); - FailIf(animated == NULL); - - // Create a channel for the animation curves - FCDAnimationChannel* channel = animationTree->AddChannel(); - FailIf(channel == NULL); - - FCDAnimationCurve* curve = channel->AddCurve(); - animated->SetCurve(0, curve); - } - - void CheckAnimationLight(FCDocument* document, FCDAnimation* UNUSED(animationTree)) - { - // Retrieve the light whose color is animated. - FCDLightLibrary* lightLibrary = document->GetLightLibrary(); - PassIf(lightLibrary != NULL); - PassIf(lightLibrary->GetEntityCount() > 0); - FCDLight* light1 = lightLibrary->FindDaeId(animatedLightId); - PassIf(light1 != NULL); - } -}; \ No newline at end of file diff --git a/Extras/FCollada/FColladaTest/FCTestExportImport/FCTEICamera.cpp b/Extras/FCollada/FColladaTest/FCTestExportImport/FCTEICamera.cpp deleted file mode 100644 index 8606afef6..000000000 --- a/Extras/FCollada/FColladaTest/FCTestExportImport/FCTEICamera.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - Copyright (C) 2006 Feeling Software Inc. - Available only to licensees. - Distribution of this file or its content is strictly prohibited. -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDCamera.h" -#include "FCTestExportImport.h" - -namespace FCTestExportImport -{ - void FillCameraLibrary(FCDCameraLibrary* library) - { - // Export a perspective camera. - FCDCamera* persp = library->AddEntity(); - PassIf(library->GetEntityCount() == 1); - PassIf(library->GetEntity(0) == persp); - PassIf(persp->GetType() == FCDEntity::CAMERA); - persp->SetPerspective(); - PassIf(persp->IsPerspective()); - FailIf(persp->IsOrthographic()); - - persp->SetAspectRatio(1.5f); - persp->SetFarZ(128.0f); - persp->SetNearZ(0.5f); - persp->SetNote(FC("Testing Camera support.")); - persp->SetVerticalAperture(6.0f); - persp->SetHorizontalAperture(9.0f); - persp->SetFovX(1.5f); - PassIf(!persp->HasVerticalFov()); - - // Export an orthographic camera. - FCDCamera* ortho = library->AddEntity(); - PassIf(library->GetEntityCount() == 2); - ortho->SetOrthographic(); - ortho->SetMagY(1.5f); - ortho->SetAspectRatio(0.3f); - ortho->SetNearZ(0.01f); - ortho->SetFarZ(41.2f); - FailIf(ortho->IsPerspective()); - PassIf(ortho->IsOrthographic()); - } - - void CheckCameraLibrary(FCDCameraLibrary* library) - { - PassIf(library->GetEntityCount() == 2); - - // Find the perspective and the orthographic camera. - FCDCamera* persp = NULL,* ortho = NULL; - for (size_t i = 0; i < 2; ++i) - { - FCDCamera* camera = library->GetEntity(i); - PassIf(camera->GetType() == FCDEntity::CAMERA); - if (camera->IsPerspective()) { FailIf(persp != NULL); persp = camera; } - else if (camera->IsOrthographic()) { FailIf(ortho != NULL); ortho = camera; } - else FailIf(true); - } - PassIf(persp != NULL && ortho != NULL); - FailIf(persp->IsOrthographic()); - FailIf(ortho->IsPerspective()); - - // Verify the perspective camera parameters - PassIf(IsEquivalent(persp->GetAspectRatio(), 1.5f)); - PassIf(IsEquivalent(persp->GetFarZ(), 128.0f)); - PassIf(IsEquivalent(persp->GetNearZ(), 0.5f)); - PassIf(persp->GetNote() == FC("Testing Camera support.")); - PassIf(IsEquivalent(persp->GetVerticalAperture(), 6.0f)); - PassIf(IsEquivalent(persp->GetHorizontalAperture(), 9.0f)); - PassIf(IsEquivalent(persp->GetFovX(), 1.5f)); - PassIf(!persp->HasVerticalFov()); - - // Verify the orthographic camera parameters - PassIf(IsEquivalent(ortho->GetAspectRatio(), 0.3f)); - PassIf(IsEquivalent(ortho->GetFarZ(), 41.2f)); - PassIf(IsEquivalent(ortho->GetNearZ(), 0.01f)); - PassIf(IsEquivalent(ortho->GetMagY(), 1.5f)); - PassIf(ortho->HasVerticalMag()); - FailIf(ortho->HasHorizontalMag()); - } -}; \ No newline at end of file diff --git a/Extras/FCollada/FColladaTest/FCTestExportImport/FCTEIExtra.cpp b/Extras/FCollada/FColladaTest/FCTestExportImport/FCTEIExtra.cpp deleted file mode 100644 index d819ce712..000000000 --- a/Extras/FCollada/FColladaTest/FCTestExportImport/FCTEIExtra.cpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - Copyright (C) 2006 Feeling Software Inc. - Available only to licensees. - Distribution of this file or its content is strictly prohibited. -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDExtra.h" -#include "FCTestExportImport.h" - -namespace FCTestExportImport -{ - void FillExtraTree(FCDExtra* extra) - { - FailIf(extra == NULL); - - // Add a test technique. - PassIf(extra->GetTechniqueCount() == 0); - FCDETechnique* technique1 = extra->AddTechnique("FCTEI_TestProfile"); - FCDETechnique* technique2 = extra->AddTechnique("FCTEI_TestProfile"); - FailIf(technique1 == NULL); - FailIf(technique2 == NULL); - PassIf(technique1 == technique2); - PassIf(extra->GetTechniqueCount() == 1); - - // Add a parent parameter to the technique and two subsequent parameters with the same name. - FCDENode* parameterTree = technique1->AddChildNode(); - parameterTree->SetName("MainParameterTree"); - FCDENode* firstParameter = parameterTree->AddChildNode(); - firstParameter->SetName("SomeParameter"); - firstParameter->SetContent(FS("Test_SomeParameter")); - firstParameter->AddAttribute("Guts", 0); - FCDENode* secondParameter = parameterTree->AddChildNode(); - secondParameter->SetName("SomeParameter"); - secondParameter->AddAttribute("Guts", 3); - secondParameter->SetContent(FS("Test_ThatParameter!")); - PassIf(parameterTree->GetChildNodeCount() == 2); - - // Add some attributes to the parameter tree - parameterTree->AddAttribute("Vicious", FC("Squirrel")); - parameterTree->AddAttribute("Gross", 1002); - } - - void CheckExtraTree(FCDExtra* extra) - { - FailIf(extra == NULL); - - // Find and verify the one technique - FailIf(extra->GetTechniqueCount() != 1); - FCDETechnique* technique = extra->GetTechnique(0); - FailIf(technique == NULL); - PassIf(IsEquivalent(technique->GetProfile(), "FCTEI_TestProfile")); - PassIf(extra->FindTechnique("FCTEI_TestProfile") == technique); - - // Find and verify the base parameter tree node - FailIf(technique->GetChildNodeCount() != 1); - FCDENode* baseNode = technique->GetChildNode(0); - PassIf(baseNode != NULL); - PassIf(extra->FindRootNode("MainParameterTree") == baseNode); - - // Verify the base node attributes - PassIf(baseNode->GetAttributeCount() == 2); - FCDEAttribute* a1 = baseNode->FindAttribute("Vicious"); - FCDEAttribute* a2 = baseNode->FindAttribute("Gross"); - FailIf(a1 == NULL); - FailIf(a2 == NULL); - FailIf(a1 == a2); - PassIf(IsEquivalent(a1->value, FC("Squirrel"))); - PassIf(IsEquivalent(FUStringConversion::ToUInt32(a2->value), 1002)); - - // Identify the base node leaves - PassIf(baseNode->GetChildNodeCount() == 2); - FCDENode* leaf0 = NULL,* leaf3 = NULL; - for (size_t i = 0; i < 2; ++i) - { - FCDENode* leaf = baseNode->GetChildNode(i); - PassIf(IsEquivalent(leaf->GetName(), "SomeParameter")); - FCDEAttribute* guts = leaf->FindAttribute("Guts"); - FailIf(guts == NULL || guts->value.empty()); - uint32 gutsIndex = FUStringConversion::ToUInt32(guts->value); - if (gutsIndex == 0) { FailIf(leaf0 != NULL); leaf0 = leaf; } - else if (gutsIndex == 3) { FailIf(leaf3 != NULL); leaf3 = leaf; } - else FailIf(true); - } - FailIf(leaf0 == NULL || leaf3 == NULL); - - // Verify the base node leaves - PassIf(leaf0->GetChildNodeCount() == 0); - PassIf(leaf3->GetChildNodeCount() == 0); - PassIf(leaf0->GetAttributeCount() == 1); - PassIf(leaf3->GetAttributeCount() == 1); - PassIf(IsEquivalent(leaf0->GetContent(), FC("Test_SomeParameter"))); - PassIf(IsEquivalent(leaf3->GetContent(), FS("Test_ThatParameter!"))); - } -} \ No newline at end of file diff --git a/Extras/FCollada/FColladaTest/FCTestExportImport/FCTEIGeometry.cpp b/Extras/FCollada/FColladaTest/FCTestExportImport/FCTEIGeometry.cpp deleted file mode 100644 index 361f17c80..000000000 --- a/Extras/FCollada/FColladaTest/FCTestExportImport/FCTEIGeometry.cpp +++ /dev/null @@ -1,370 +0,0 @@ -/* - Copyright (C) 2006 Feeling Software Inc. - Available only to licensees. - Distribution of this file or its content is strictly prohibited. -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDController.h" -#include "FCDocument/FCDGeometry.h" -#include "FCDocument/FCDGeometryMesh.h" -#include "FCDocument/FCDGeometryPolygons.h" -#include "FCDocument/FCDGeometrySource.h" -#include "FCDocument/FCDGeometrySpline.h" -#include "FCDocument/FCDMorphController.h" -#include "FCDocument/FCDSceneNode.h" -#include "FCDocument/FCDSkinController.h" -#include "FCTestExportImport.h" - -static const float positionData[12] = { 0.0f, 0.0f, 3.0f, 5.0f, 0.0f, -2.0f, -3.0f, 4.0f, -2.0f, -3.0f, -4.0f, -2.0f }; -static const float colorData[12] = { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f }; -static const float dummyData[10] = { 0.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f }; -static const uint32 positionIndices[12] = { 0, 1, 2, 0, 2, 3, 0, 3, 1, 3, 2, 1 }; -static const uint32 colorIndices[12] = { 0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2 }; - -static const float sampleBindPose1[16] = { 1.0f, 0.4f, 0.4f, 0.0f, 7.77f, 0.0f, 0.3f, 2.5f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f }; -static const float sampleBindPose2[16] = { 0.3f, 0.0f, -0.3f, -21.0f, 0.96f, 0.0f, 2.0f, 2.5f, 0.0f, -5.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f }; -static string splineId, meshId, jointId1, jointId2; - -namespace FCTestExportImport -{ - void FillGeometryLibrary(FCDGeometryLibrary* library) - { - FCDGeometry* geometry = library->AddEntity(); - PassIf(geometry->GetType() == FCDEntity::GEOMETRY); - FailIf(geometry->IsMesh()); - FailIf(geometry->IsSpline()); - meshId = geometry->GetDaeId(); - FailIf(meshId.empty()); - - // Creates a mesh to export - FCDGeometryMesh* mesh = geometry->CreateMesh(); - FailIf(geometry->IsSpline()); - PassIf(geometry->IsMesh()); - PassIf(geometry->GetMesh() == mesh); - PassIf(geometry->GetSpline() == NULL); - FillGeometryMesh(mesh); - - // Create a spline to export - geometry = library->AddEntity(); - geometry->CreateMesh(); - FCDGeometrySpline* spline = geometry->CreateSpline(); - PassIf(geometry->IsSpline()); - FailIf(geometry->IsMesh()); - PassIf(geometry->GetMesh() == NULL); - PassIf(geometry->GetSpline() == spline); - FillGeometrySpline(spline); - splineId = geometry->GetDaeId(); - FailIf(splineId.empty()); - } - - void FillGeometryMesh(FCDGeometryMesh* mesh) - { - FCDGeometrySource* posSource = mesh->AddVertexSource(); - FailIf(posSource == NULL); - posSource->SetName(FC("TestPositionSource")); - posSource->SetSourceType(FUDaeGeometryInput::POSITION); - posSource->SetSourceData(FloatList(positionData, 12), 3); - - FCDGeometrySource* colorSource = mesh->AddSource(); - FailIf(colorSource == NULL); - colorSource->SetName(FC("TestColorSource")); - colorSource->SetSourceType(FUDaeGeometryInput::COLOR); - colorSource->SetSourceData(FloatList(colorData, 12), 4); - - FCDGeometrySource* dummySource = mesh->AddSource(); - FailIf(dummySource == NULL); - dummySource->SetName(FC("TestDummySource")); - dummySource->SetSourceType(FUDaeGeometryInput::EXTRA); - dummySource->SetSourceData(FloatList(dummyData, 10), 3); - - FCDGeometryPolygons* polys1 = mesh->AddPolygons(); - FailIf(polys1 == NULL || polys1->GetInputCount() != 1); - FCDGeometryPolygons* polys2 = mesh->AddPolygons(); - FailIf(polys2 == NULL || polys2->GetInputCount() != 1); - FCDGeometryPolygonsInput* pInput1 = polys1->AddInput(colorSource, 1); - PassIf(polys1->GetInputCount() == 2); - PassIf(pInput1 != NULL && pInput1->source == colorSource && pInput1->idx == 1); - FCDGeometryPolygonsInput* pInput2 = polys2->AddInput(colorSource, 1); - PassIf(polys2->GetInputCount() == 2); - PassIf(pInput2 != NULL && pInput2->source == colorSource && pInput2->idx == 1); - FCDGeometryPolygonsInput* pInput3 = polys1->AddInput(dummySource, 2); - PassIf(pInput3 != NULL && pInput3->source == dummySource && pInput3->idx == 2); - - // Fill in some indices in order to form a tetrahedron - polys1->AddFace(3); polys1->AddFace(3); polys1->AddFace(3); polys1->AddFace(3); - UInt32List* posIndices = polys1->FindIndices(posSource); - UInt32List* colIndices = polys1->FindIndices(colorSource); - FailIf(posIndices == NULL || posIndices->size() != 12); - FailIf(colIndices == NULL || colIndices == posIndices || colIndices->size() != 12); - *posIndices = UInt32List(positionIndices, 12); - *colIndices = UInt32List(colorIndices, 12); - } - - void FillGeometrySpline(FCDGeometrySpline* spline) - { - FCDCVs cvs; - cvs.push_back(FMVector3(1.0f, 2.0f, 4.0f)); - cvs.push_back(FMVector3::XAxis); - spline->SetCVs(cvs); - PassIf(spline->GetCVCount() == 2); - - FCDKnots knots; - knots.push_back(1.4); - knots.push_back(7.4); - spline->SetKnots(knots); - PassIf(spline->GetKnotCount() == 2); - } - - void CheckGeometryLibrary(FCDGeometryLibrary* library) - { - PassIf(library->GetEntityCount() == 2); - - // Find the one mesh and the one spline geometries. - FCDGeometryMesh* mesh = NULL; FCDGeometrySpline* spline = NULL; - for (size_t i = 0; i < 2; ++i) - { - FCDGeometry* g = library->GetEntity(i); - if (g->IsMesh()) mesh = g->GetMesh(); - else if (g->IsSpline()) spline = g->GetSpline(); - else FailIf(true); - } - FailIf(mesh == NULL || spline == NULL); - - CheckGeometryMesh(mesh); - CheckGeometrySpline(spline); - } - - void CheckGeometryMesh(FCDGeometryMesh* mesh) - { - // Verify the mesh and its sources - PassIf(mesh->GetSourceCount() == 3); - FCDGeometrySource* posSource = NULL,* colorSource = NULL,* dummySource = NULL; - for (size_t i = 0; i < 3; ++i) - { - FCDGeometrySource* source = mesh->GetSource(i); - FailIf(source == NULL); - switch (source->GetSourceType()) - { - case FUDaeGeometryInput::POSITION: posSource = source; PassIf(source->GetName() == FC("TestPositionSource")); break; - case FUDaeGeometryInput::COLOR: colorSource = source; PassIf(source->GetName() == FC("TestColorSource")); break; - case FUDaeGeometryInput::EXTRA: dummySource = source; PassIf(source->GetName() == FC("TestDummySource")); break; - default: FailIf(true); break; - } - } - FailIf(posSource == NULL || colorSource == NULL || dummySource == NULL); - PassIf(IsEquivalent(posSource->GetSourceData(), positionData, 12)); - PassIf(posSource->GetSourceStride() == 3); - PassIf(IsEquivalent(colorSource->GetSourceData(), colorData, 12)); - PassIf(colorSource->GetSourceStride() == 4); - PassIf(IsEquivalent(dummySource->GetSourceData(), dummyData, 10)); - PassIf(dummySource->GetSourceStride() == 3); - - // Find the non-empty polygon set and verify that one of the polygon set is, in fact, empty. - FCDGeometryPolygons* polys1 = NULL,* polysEmpty = NULL; - for (size_t i = 0; i < mesh->GetPolygonsCount(); ++i) - { - FCDGeometryPolygons* p = mesh->GetPolygons(i); - if (p->GetFaceCount() == 0) { PassIf(polysEmpty == NULL); polysEmpty = p; } - else { PassIf(polys1 == NULL); polys1 = p; } - } - PassIf(polys1 != NULL && polysEmpty != NULL); - - // Check that we have the wanted tetrahedron in the non-empty polygon set. - PassIf(polys1->GetFaceCount() == 4); - PassIf(polys1->GetHoleCount() == 0); - PassIf(polys1->GetFaceVertexCount(0) == 3 && polys1->GetFaceVertexCount(1) == 3 && polys1->GetFaceVertexCount(2) == 3 && polys1->GetFaceVertexCount(3) == 3); - UInt32List* posIndices = polys1->FindIndices(posSource); - UInt32List* colIndices = polys1->FindIndices(colorSource); - FailIf(posIndices == NULL || posIndices->size() != 12); - FailIf(colIndices == NULL || colIndices == posIndices || colIndices->size() != 12); - PassIf(IsEquivalent(*posIndices, positionIndices, 12)); - PassIf(IsEquivalent(*colIndices, colorIndices, 12)); - } - - void CheckGeometrySpline(FCDGeometrySpline* spline) - { - // Verify the spline and its data - FailIf(spline->GetCVCount() != 2); - FailIf(spline->GetKnotCount() != 2); - PassIf(IsEquivalent(*spline->GetCV(0), FMVector3(1.0f, 2.0f, 4.0f))); - PassIf(IsEquivalent(*spline->GetCV(1), FMVector3::XAxis)); - PassIf(IsEquivalent(spline->GetKnot(0), 1.4)); - PassIf(IsEquivalent(spline->GetKnot(1), 7.4)); - } - - void FillControllerLibrary(FCDControllerLibrary* library) - { - FailIf(library == NULL); - - // Create a morph controller on the previously created spline. - FCDController* morpher = library->AddEntity(); - FillControllerMorph(morpher->CreateMorphController()); - - // Create a skin controller on the previously created mesh. - FCDController* skin = library->AddEntity(); - skin->SetNote(FS("A nicey skinny controller. ")); - FillControllerSkin(skin->CreateSkinController()); - } - - void FillControllerMorph(FCDMorphController* controller) - { - FailIf(controller == NULL); - controller->SetMethod(FUDaeMorphMethod::RELATIVE); - - // Retrieve the base spline entity that will be morphed - // (and for this test only: it'll be the morph targets) - // Also retrieve the mesh, for similarity checks. - FCDGeometry* spline = controller->GetDocument()->FindGeometry(splineId); - FailIf(spline == NULL); - FCDGeometry* mesh = controller->GetDocument()->FindGeometry(meshId); - FailIf(mesh == NULL); - FailIf(controller->IsSimilar(mesh)); - FailIf(controller->IsSimilar(spline)); - - controller->SetBaseTarget(spline); - PassIf(controller->IsSimilar(spline)); - FailIf(controller->IsSimilar(mesh)); - - controller->AddTarget(spline, 0.3f); - controller->AddTarget(spline, 0.6f); - PassIf(controller->GetTargetCount() == 2); - } - - void FillControllerSkin(FCDSkinController* controller) - { - FailIf(controller == NULL); - - // Create two joints. - FCDSceneNode* visualScene = controller->GetDocument()->GetVisualSceneLibrary()->AddEntity(); - PassIf(visualScene != NULL); - FCDSceneNode* joint1 = visualScene->AddChildNode(); - PassIf(joint1 != NULL); - FCDSceneNode* joint2 = joint1->AddChildNode(); - PassIf(joint2 != NULL); - jointId1 = joint1->GetDaeId(); - jointId2 = joint2->GetDaeId(); - FailIf(jointId1.empty() || jointId2.empty()); - controller->AddJoint(joint1, FMMatrix44::Identity); - controller->AddJoint(joint2, FMMatrix44(sampleBindPose1)); - controller->SetBindShapeTransform(FMMatrix44(sampleBindPose2)); - PassIf(controller->GetJointCount() == 2); - - // Retrieve and assign the base target - FCDGeometry* geometricTarget = controller->GetDocument()->FindGeometry(meshId); - controller->SetTarget(geometricTarget); - - // Set some influences - PassIf(controller->GetVertexInfluenceCount() == 4); - FCDJointWeightPairList* influence = controller->GetInfluences(0); - FailIf(influence == NULL); - influence->push_back(FCDJointWeightPair(0, 0.5f)); - influence->push_back(FCDJointWeightPair(1, 0.5f)); - - influence = controller->GetInfluences(3); - FailIf(influence == NULL); - influence->push_back(FCDJointWeightPair(1, 1.0f)); - - influence = controller->GetInfluences(2); - FailIf(influence == NULL); - influence->push_back(FCDJointWeightPair(0, 0.1f)); - } - - void CheckControllerLibrary(FCDControllerLibrary* library) - { - FailIf(library == NULL); - - FCDController* morpher = NULL,* skin = NULL; - for (size_t i = 0; i < library->GetEntityCount(); ++i) - { - FCDController* c = library->GetEntity(i); - if (c->HasMorphController()) { PassIf(morpher == NULL); morpher = c; } - else if (c->HasSkinController()) { PassIf(skin == NULL); skin = c; } - else FailIf(true); - } - PassIf(morpher != NULL && skin != NULL); - - // Check the morpher - FailIf(morpher->HasSkinController()); - PassIf(morpher->GetMorphController() != NULL); - CheckControllerMorph(morpher->GetMorphController()); - - // Check the skin - PassIf(skin->GetSkinController() != NULL); - FailIf(skin->HasMorphController()); - PassIf(skin->GetNote() == FC("A nicey skinny controller. ")); - CheckControllerSkin(skin->GetSkinController()); - } - - void CheckControllerMorph(FCDMorphController* controller) - { - FailIf(controller == NULL); - PassIf(controller->GetMethod() == FUDaeMorphMethod::RELATIVE); - - // Check that there are two targets, that the weights are correct, as well as the ids. - PassIf(controller->GetTargetCount() == 2); - PassIf(controller->GetBaseTarget() != NULL); - PassIf(controller->GetBaseTarget()->GetDaeId() == splineId); - - FCDMorphTarget* target1 = controller->GetTarget(0); - FailIf(target1 == NULL); - FCDMorphTarget* target2 = controller->GetTarget(1); - FailIf(target2 == NULL); - PassIf(target1->GetGeometry() == controller->GetBaseTarget()); - PassIf(target2->GetGeometry() == controller->GetBaseTarget()); - PassIf(IsEquivalent(target1->GetWeight(), 0.6f) || IsEquivalent(target1->GetWeight(), 0.3f)); - PassIf(IsEquivalent(target2->GetWeight(), 0.6f) || IsEquivalent(target2->GetWeight(), 0.3f)); - FailIf(IsEquivalent(target1->GetWeight(), target2->GetWeight())); - } - - void CheckControllerSkin(FCDSkinController* controller) - { - FailIf(controller == NULL); - - // Check the base target's identity - FailIf(controller->GetTarget() == NULL); - PassIf(controller->GetTarget()->GetType() == FCDEntity::GEOMETRY); - PassIf(controller->GetTarget()->GetDaeId() == meshId); - - // Retrieve the two joints and verify their ids/bind-pose. - PassIf(controller->GetJointCount() == 2); - FCDJointMatrixPair* joint1 = NULL,* joint2 = NULL; - for (size_t i = 0; i < 2; ++i) - { - FCDJointMatrixPair* p = controller->GetJoint(i); - FailIf(p->joint == NULL); - if (p->joint->GetDaeId() == jointId1) { FailIf(joint1 != NULL); joint1 = p; } - else if (p->joint->GetDaeId() == jointId2) { FailIf(joint2 != NULL); joint2 = p; } - else FailIf(true); - } - FailIf(joint1 == NULL || joint2 == NULL); - PassIf(IsEquivalent(joint1->invertedBindPose, FMMatrix44::Identity)); - PassIf(IsEquivalent(joint2->invertedBindPose, FMMatrix44(sampleBindPose1).Inverted())); - - // Verify the influences - PassIf(controller->GetVertexInfluenceCount() == 4); - FCDJointWeightPairList* influence = controller->GetInfluences(0); - FailIf(influence == NULL); - PassIf(influence->size() == 2); - PassIf(IsEquivalent(influence->at(0).jointIndex, 0)); - PassIf(IsEquivalent(influence->at(0).weight, 0.5f)); - PassIf(IsEquivalent(influence->at(1).jointIndex, 1)); - PassIf(IsEquivalent(influence->at(1).weight, 0.5f)); - - influence = controller->GetInfluences(1); - FailIf(influence == NULL); - PassIf(influence->empty()); - - influence = controller->GetInfluences(2); - FailIf(influence == NULL); - PassIf(influence->size() == 1); - PassIf(IsEquivalent(influence->at(0).jointIndex, 0)); - PassIf(IsEquivalent(influence->at(0).weight, 1.0f)); // the weight should have been normalized. - - influence = controller->GetInfluences(3); - FailIf(influence == NULL); - PassIf(influence->size() == 1); - PassIf(IsEquivalent(influence->at(0).jointIndex, 1)); - PassIf(IsEquivalent(influence->at(0).weight, 1.0f)); - } -}; \ No newline at end of file diff --git a/Extras/FCollada/FColladaTest/FCTestExportImport/FCTEILight.cpp b/Extras/FCollada/FColladaTest/FCTestExportImport/FCTEILight.cpp deleted file mode 100644 index 2609ba6c8..000000000 --- a/Extras/FCollada/FColladaTest/FCTestExportImport/FCTEILight.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - Copyright (C) 2006 Feeling Software Inc. - Available only to licensees. - Distribution of this file or its content is strictly prohibited. -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDLight.h" -#include "FCTestExportImport.h" - -namespace FCTestExportImport -{ - void FillLightLibrary(FCDLightLibrary* library) - { - // Create four lights of different types. - FCDLight* pointLight = library->AddEntity(); - pointLight->SetLightType(FCDLight::POINT); - FCDLight* spotLight = library->AddEntity(); - spotLight->SetLightType(FCDLight::SPOT); - FCDLight* directionalLight = library->AddEntity(); - directionalLight->SetLightType(FCDLight::DIRECTIONAL); - FCDLight* ambientLight = library->AddEntity(); - ambientLight->SetLightType(FCDLight::AMBIENT); - - // Set the base colors - pointLight->SetColor(FMVector3(0.5f, 0.2f, 0.7f)); - spotLight->SetColor(FMVector3(0.25f, 0.25f, 0.75f)); - directionalLight->SetColor(FMVector3(0.1f, 0.0f, -1.0f)); - ambientLight->SetColor(FMVector3(5.0f, 0.0f, 0.4f)); - - // Set some intensity - pointLight->SetIntensity(2.5f); - spotLight->SetIntensity(1.5f); - directionalLight->SetIntensity(0.5f); - ambientLight->SetIntensity(-2.5f); - - // Test the extra tree: - FillExtraTree(ambientLight->GetExtra()); - } - - void CheckLightLibrary(FCDLightLibrary* library) - { - // Verify that the library contains four lights and one of each type. - FCDLight* pointLight = NULL,* spotLight = NULL,* directionalLight = NULL,* ambientLight = NULL; - for (size_t i = 0; i < library->GetEntityCount(); ++i) - { - FCDLight* light = library->GetEntity(i); - switch (light->GetLightType()) - { - case FCDLight::AMBIENT: FailIf(ambientLight != NULL); ambientLight = light; break; - case FCDLight::DIRECTIONAL: FailIf(directionalLight != NULL); directionalLight = light; break; - case FCDLight::POINT: FailIf(pointLight != NULL); pointLight = light; break; - case FCDLight::SPOT: FailIf(spotLight != NULL); spotLight = light; break; - default: FailIf(true); break; - } - } - PassIf(ambientLight != NULL && spotLight != NULL && directionalLight != NULL && pointLight != NULL); - - // Verify the base colors - PassIf(IsEquivalent(pointLight->GetColor(), FMVector3(0.5f, 0.2f, 0.7f))); - PassIf(IsEquivalent(spotLight->GetColor(), FMVector3(0.25f, 0.25f, 0.75f))); - PassIf(IsEquivalent(directionalLight->GetColor(), FMVector3(0.1f, 0.0f, -1.0f))); - PassIf(IsEquivalent(ambientLight->GetColor(), FMVector3(5.0f, 0.0f, 0.4f))); - - // Verify the intensities - PassIf(IsEquivalent(pointLight->GetIntensity(), 2.5f)); - PassIf(IsEquivalent(spotLight->GetIntensity(), 1.5f)); - PassIf(IsEquivalent(directionalLight->GetIntensity(), 0.5f)); - PassIf(IsEquivalent(ambientLight->GetIntensity(), -2.5f)); - - // Test the extra tree - CheckExtraTree(ambientLight->GetExtra()); - } -}; \ No newline at end of file diff --git a/Extras/FCollada/FColladaTest/FCTestExportImport/FCTEIMaterial.cpp b/Extras/FCollada/FColladaTest/FCTestExportImport/FCTEIMaterial.cpp deleted file mode 100644 index 48abefa1c..000000000 --- a/Extras/FCollada/FColladaTest/FCTestExportImport/FCTEIMaterial.cpp +++ /dev/null @@ -1,198 +0,0 @@ -/* - Copyright (C) 2006 Feeling Software Inc. - Available only to licensees. - Distribution of this file or its content is strictly prohibited. -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDEffect.h" -#include "FCDocument/FCDEffectStandard.h" -#include "FCDocument/FCDEffectProfileFX.h" -#include "FCDocument/FCDImage.h" -#include "FCDocument/FCDMaterial.h" -#include "FCDocument/FCDMaterialLibrary.h" -#include "FCDocument/FCDTexture.h" -#include "FCTestExportImport.h" - -static const float sampleMatrix[16] = { 0.5f, 0.1f, 0.7f, 2.0f, 1.11f, 0.5e-2f, 111.0f, 0.5f, 0.0f, 0.0f, 0.557f, -10.02f, 0.001f, 12.0f, 1.02e-3f }; -static string wantedImageId = "test_image"; -static string wantedImage2Id = "test_image"; - -namespace FCTestExportImport -{ - void FillMaterialLibrary(FCDMaterialLibrary* library) - { - // Create an empty material - FCDMaterial* material = library->AddMaterial(); - material->SetNote(FS("EmptyMaterial244")); - - // Create an effect and attach it to a new material - FCDEffect* effect = library->AddEffect(); - material = library->AddMaterial(); - material->SetEffect(effect); - effect->SetNote(FS("EmptyEffect.. for now!")); - - FillEffectStandard((FCDEffectStandard*) effect->AddProfile(FUDaeProfileType::COMMON)); - FillEffectFX((FCDEffectProfileFX*) effect->AddProfile(FUDaeProfileType::CG)); - } - - void FillEffectStandard(FCDEffectStandard* profile) - { - FailIf(profile == NULL); - profile->SetLightingType(FCDEffectStandard::PHONG); - profile->SetDiffuseColor(FMVector3(1.0f, 0.0f, -2.0f)); - profile->SetSpecularColor(FMVector3(0.0f, 1.0f, 0.4f)); - profile->SetShininess(40.0f); - - // Retrieve two images created earlier - FCDImage* image1 = profile->GetDocument()->FindImage(wantedImageId); - FCDImage* image2 = profile->GetDocument()->FindImage(wantedImage2Id); - PassIf("Dependency: FillImageLibrary!" && image1 != NULL && image2 != NULL); - - // The first bump texture should have placement parameters. - FCDTexture* texture1 = profile->AddTexture(FUDaeTextureChannel::BUMP); - texture1->SetImage(image2); - texture1->SetWrapU(true); - texture1->SetWrapV(true); - texture1->SetRepeatU(2.0f); - texture1->SetRepeatV(2.0f); - texture1->SetTranslateFrameU(5.0f); - texture1->SetTranslateFrameV(-0.4f); - - // The second bump texture should have an image and projection parameters. - FCDTexture* texture2 = profile->AddTexture(FUDaeTextureChannel::BUMP); - texture2->SetImage(image1); - texture2->SetProjectionMatrix(FMMatrix44(sampleMatrix)); - - // The third texture is a filter texture and will remain empty. - UNUSED(FCDTexture* texture3 = )profile->AddTexture(FUDaeTextureChannel::FILTER); - } - - void FillEffectFX(FCDEffectProfileFX* profile) - { - FailIf(profile == NULL); - profile->AddTechnique(); - profile->AddCode(); - } - - void CheckMaterialLibrary(FCDMaterialLibrary* library) - { - // There should be two materials within the material library: one is empty, the other is not. - PassIf(library->GetMaterialCount() == 2); - PassIf(library->GetEffectCount() == 1); - - FCDMaterial* emptyMaterial = NULL,* material = NULL; - for (size_t i = 0; i < library->GetMaterialCount(); ++i) - { - FCDMaterial* m = library->GetMaterial(i); - if (m->GetEffect() == NULL) { PassIf(emptyMaterial == NULL); emptyMaterial = m; } - else { PassIf(material == NULL); material = m; } - } - PassIf(emptyMaterial != NULL && material != NULL); - - // Verify the empty material. It should only have a note. - PassIf(emptyMaterial->GetNote() == FC("EmptyMaterial244")); - - // Verify the other material and its effect. - FCDEffect* effect = material->GetEffect(); - PassIf(library->GetEffect(0) == effect); - PassIf(effect->GetNote() == FC("EmptyEffect.. for now!")); - PassIf(effect->GetProfileCount() == 2); - - CheckEffectStandard((FCDEffectStandard*) effect->FindProfile(FUDaeProfileType::COMMON)); - CheckEffectFX((FCDEffectProfileFX*) effect->FindProfile(FUDaeProfileType::CG)); - } - - void CheckEffectStandard(FCDEffectStandard* profile) - { - FailIf(profile == NULL); - PassIf(profile->GetLightingType() == FCDEffectStandard::PHONG); - PassIf(IsEquivalent(profile->GetDiffuseColor(), FMVector3(1.0f, 0.0f, -2.0f))); - PassIf(IsEquivalent(profile->GetSpecularColor(), FMVector3(0.0f, 1.0f, 0.4f))); - PassIf(IsEquivalent(profile->GetShininess(), 40.0f)); - - // There should be two textures in the bump channel. - PassIf(profile->GetTextureCount(FUDaeTextureChannel::BUMP) == 2); - FCDTexture* texture1 = NULL,* texture2 = NULL; - for (size_t i = 0; i < 2; ++i) - { - FCDTexture* texture = profile->GetTexture(FUDaeTextureChannel::BUMP, i); - FailIf(texture == NULL); - if (texture->HasPlacement2D()) { FailIf(texture1 != NULL); texture1 = texture; } - else if (texture->HasProjection3D()) { FailIf(texture2 != NULL); texture2 = texture; } - else FailIf(true); - } - PassIf(texture1 != NULL && texture2 != NULL); - - // Verify the texture images - FCDImage* image1 = profile->GetDocument()->FindImage(wantedImageId); - FCDImage* image2 = profile->GetDocument()->FindImage(wantedImage2Id); - PassIf("Dependency: CheckImageLibrary" && image1 != NULL && image2 != NULL); - PassIf(texture1->GetImage() == image2); - PassIf(texture2->GetImage() == image1); - - // Verify the placement parameters - PassIf(IsEquivalent(texture1->GetWrapU(), 1.0f)); - PassIf(IsEquivalent(texture1->GetWrapV(), 1.0f)); - PassIf(IsEquivalent(texture1->GetRepeatU(), 2.0f)); - PassIf(IsEquivalent(texture1->GetRepeatV(), 2.0f)); - PassIf(IsEquivalent(texture1->GetTranslateFrameU(), 5.0f)); - PassIf(IsEquivalent(texture1->GetTranslateFrameV(), -0.4f)); - - // There should be an empty texture in the filter channel - PassIf(profile->GetTextureCount(FUDaeTextureChannel::FILTER) == 1); - FCDTexture* texture3 = profile->GetTexture(FUDaeTextureChannel::FILTER, 0); - FailIf(texture3 == NULL || texture3->GetImage() != NULL); - } - - void CheckEffectFX(FCDEffectProfileFX* profile) - { - FailIf(profile == NULL); - PassIf(profile->GetTechniqueCount() == 1); - PassIf(profile->GetCodeCount() == 1); - } - - void FillImageLibrary(FCDImageLibrary* library) - { - FailIf(library == NULL || library->GetEntityCount() > 0); - FCDImage* image1 = library->AddEntity(); - FCDImage* image2 = library->AddEntity(); - FCDImage* image3 = library->AddEntity(); - - image1->SetDaeId(wantedImageId); - image1->SetFilename(FS("Texture1.jpg")); - image2->SetDaeId(wantedImage2Id); - image2->SetFilename(FC("Texture3D.jpg")); - image2->SetWidth(256); - image2->SetHeight(135); - image3->SetWidth(33); - image3->SetDepth(521); - - FailIf(image1->GetDaeId() == image2->GetDaeId()); - } - - void CheckImageLibrary(FCDImageLibrary* library) - { - FailIf(library == NULL || library->GetEntityCount() != 3); - - // Retrieve the three images, verify that they match the id/filenames that we created. - FCDImage* image1 = NULL,* image2 = NULL,* image3 = NULL; - for (size_t i = 0; i < 3; ++i) - { - FCDImage* image = library->GetEntity(i); - if (IsEquivalent(image->GetDaeId(), wantedImageId)) { FailIf(image1 != NULL); image1 = image; } - else if (IsEquivalent(image->GetDaeId(), wantedImage2Id)) { FailIf(image2 != NULL); image2 = image; } - else { FailIf(image3 != NULL); image3 = image; } - } - PassIf(image1 != NULL && image2 != NULL && image3 != NULL); - - // Verify the depth/width/height. - PassIf(image1->GetWidth() == 0 && image1->GetHeight() == 0 && image1->GetDepth() == 0); - PassIf(image2->GetWidth() == 256 && image2->GetHeight() == 135 && image2->GetDepth() == 0); - PassIf(image3->GetWidth() == 33 && image3->GetHeight() == 0 && image3->GetDepth() == 521); - - // Verify the filenames. They should be absolute filenames now, so look for the wanted substrings. - PassIf(strstr(TO_STRING(image1->GetFilename()).c_str(), "Texture1.jpg") != NULL); - PassIf(strstr(TO_STRING(image2->GetFilename()).c_str(), "Texture3D.jpg") != NULL); - } -}; \ No newline at end of file diff --git a/Extras/FCollada/FColladaTest/FCTestExportImport/FCTEIVisualScene.cpp b/Extras/FCollada/FColladaTest/FCTestExportImport/FCTEIVisualScene.cpp deleted file mode 100644 index 83a21981e..000000000 --- a/Extras/FCollada/FColladaTest/FCTestExportImport/FCTEIVisualScene.cpp +++ /dev/null @@ -1,96 +0,0 @@ -/* -Copyright (C) 2006 Feeling Software Inc. -Available only to licensees. -Distribution of this file or its content is strictly prohibited. -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDSceneNode.h" -#include "FCDocument/FCDTransform.h" -#include "FCTestExportImport.h" - -static const float sampleMatrix[16] = { 0.0f, 2.0f, 0.4f, 2.0f, 7.0f, 0.2f, 991.0f, 2.5f, 11.0f, 25.0f, 1.55f, 0.02f, 0.001f, 12.0f, 1.02e-3f }; - -namespace FCTestExportImport -{ - void FillVisualScene(FCDSceneNode* scene) - { - FCDSceneNode* child = scene->AddChildNode(); - FCDTRotation* rotation = (FCDTRotation*) child->AddTransform(FCDTransform::ROTATION); - rotation->SetAxis(FMVector3::ZAxis); - rotation->SetAngle(45.0f); - FCDTTranslation* translation = (FCDTTranslation*) child->AddTransform(FCDTransform::TRANSLATION); - translation->SetTranslation(0.0f, 4.0f, 6.0f); - FCDTScale* scale = (FCDTScale*) child->AddTransform(FCDTransform::SCALE); - scale->SetScale(FMVector3(3.0f, 0.5f, 2.0f)); - FCDTMatrix* matrix = (FCDTMatrix*) child->AddTransform(FCDTransform::MATRIX); - matrix->SetTransform(FMMatrix44(sampleMatrix)); - FCDTLookAt* lookAt = (FCDTLookAt*) child->AddTransform(FCDTransform::LOOKAT); - lookAt->SetPosition(1.0f, 2.0f, 3.0f); - lookAt->SetTarget(5.0f, 6.0f, 9.0f); - lookAt->SetUp(12.0f, 0.3f, 0.4f); - FCDTSkew* skew = (FCDTSkew*) child->AddTransform(FCDTransform::SKEW); - skew->SetAroundAxis(FMVector3::ZAxis); - skew->SetRotateAxis(FMVector3::XAxis); - skew->SetAngle(60.0f); - } - - void CheckVisualScene(FCDSceneNode* imported) - { - // NOTE: the transforms must be in the same order as the exported order. - - PassIf(imported->GetChildrenCount() == 1); - PassIf(imported->GetParent() == NULL); - FCDSceneNode* child = imported->GetChild(0); - FailIf(child == NULL); - PassIf(child->GetParent() == imported); - PassIf(child->GetTransformCount() == 6); - - FCDTransform* transform = child->GetTransform(0); - FailIf(transform == NULL); - FailIf(transform->GetParent() != child); - PassIf(transform->GetType() == FCDTransform::ROTATION); - FCDTRotation* rotation = (FCDTRotation*) transform; - PassIf(IsEquivalent(rotation->GetAxis(), FMVector3::ZAxis)); - PassIf(IsEquivalent(rotation->GetAngle(), 45.0f)); - - transform = child->GetTransform(1); - FailIf(transform == NULL); - FailIf(transform->GetParent() != child); - PassIf(transform->GetType() == FCDTransform::TRANSLATION); - FCDTTranslation* translation = (FCDTTranslation*) transform; - PassIf(IsEquivalent(translation->GetTranslation(), FMVector3(0.0f, 4.0f, 6.0f))); - - transform = child->GetTransform(2); - FailIf(transform == NULL); - FailIf(transform->GetParent() != child); - PassIf(transform->GetType() == FCDTransform::SCALE); - FCDTScale* scale = (FCDTScale*) transform; - PassIf(IsEquivalent(scale->GetScale(), FMVector3(3.0f, 0.5f, 2.0f))); - - transform = child->GetTransform(3); - FailIf(transform == NULL); - FailIf(transform->GetParent() != child); - PassIf(transform->GetType() == FCDTransform::MATRIX); - FCDTMatrix* mx = (FCDTMatrix*) transform; - PassIf(IsEquivalent(mx->GetTransform(), FMMatrix44(sampleMatrix))); - - transform = child->GetTransform(4); - FailIf(transform == NULL); - FailIf(transform->GetParent() != child); - PassIf(transform->GetType() == FCDTransform::LOOKAT); - FCDTLookAt* lookAt = (FCDTLookAt*) transform; - PassIf(IsEquivalent(lookAt->GetPosition(), FMVector3(1.0f, 2.0f, 3.0f))); - PassIf(IsEquivalent(lookAt->GetTarget(), FMVector3(5.0f, 6.0f, 9.0f))); - PassIf(IsEquivalent(lookAt->GetUp(), FMVector3(12.0f, 0.3f, 0.4f))); - - transform = child->GetTransform(5); - FailIf(transform == NULL); - FailIf(transform->GetParent() != child); - PassIf(transform->GetType() == FCDTransform::SKEW); - FCDTSkew* skew = (FCDTSkew*) transform; - PassIf(IsEquivalent(skew->GetAroundAxis(), FMVector3::ZAxis)); - PassIf(IsEquivalent(skew->GetRotateAxis(), FMVector3::XAxis)); - PassIf(IsEquivalent(skew->GetAngle(), 60.0f)); - } -}; \ No newline at end of file diff --git a/Extras/FCollada/FColladaTest/FCTestExportImport/FCTestExportImport.cpp b/Extras/FCollada/FColladaTest/FCTestExportImport/FCTestExportImport.cpp deleted file mode 100644 index 2b85cc431..000000000 --- a/Extras/FCollada/FColladaTest/FCTestExportImport/FCTestExportImport.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - Copyright (C) 2006 Feeling Software Inc. - Available only to licensees. - Distribution of this file or its content is strictly prohibited. -*/ - -#include "StdAfx.h" -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDCamera.h" -#include "FCDocument/FCDGeometry.h" -#include "FCDocument/FCDGeometryMesh.h" -#include "FCDocument/FCDGeometrySource.h" -#include "FCDocument/FCDGeometrySpline.h" -#include "FCDocument/FCDGeometryPolygons.h" -#include "FCDocument/FCDLibrary.h" -#include "FCDocument/FCDSceneNode.h" -#include "FCDocument/FCDTransform.h" - -#include "FCTestExportImport.h" -using namespace FCTestExportImport; - -// Test import of a code-generated scene, with library entities. -// Does the export, re-import and validates that the information is intact. -void TestUniqueScene() -{ - // Write out a simple document with three visual scenes - FCDocument* doc = new FCDocument(); - FCDSceneNode* sceneNode1 = doc->AddVisualScene(); - sceneNode1->SetName(FC("Scene1")); - FCDSceneNode* sceneNode2 = doc->AddVisualScene(); - sceneNode2->SetName(FC("Scene2")); - FCDSceneNode* sceneNode3 = doc->AddVisualScene(); - sceneNode3->SetName(FC("Scene3")); - FillVisualScene(sceneNode2); - - // Fill in the other libraries - FillImageLibrary(doc->GetImageLibrary()); - FillCameraLibrary(doc->GetCameraLibrary()); - FillLightLibrary(doc->GetLightLibrary()); - FillGeometryLibrary(doc->GetGeometryLibrary()); - FillControllerLibrary(doc->GetControllerLibrary()); // must occur after FillGeometryLibrary. - FillMaterialLibrary(doc->GetMaterialLibrary()); // must occur after FillImageLibrary. - FillAnimationLibrary(doc->GetAnimationLibrary()); // must occur last. - doc->WriteToFile(FC("TestOut.dae")); - FailIf(sceneNode1->GetDaeId() == sceneNode2->GetDaeId()); - FailIf(sceneNode1->GetDaeId() == sceneNode3->GetDaeId()); - FailIf(sceneNode2->GetDaeId() == sceneNode3->GetDaeId()); - - // Import back this document - FCDocument* idoc = new FCDocument(); - FUStatus stat = idoc->LoadFromFile(FC("TestOut.dae")); -#ifdef _WIN32 - OutputDebugStringW(stat.GetErrorString()); -#endif - PassIf(stat.IsSuccessful()); - - // Verify that all the data we pushed is still available - // Note that visual scenes may be added by other tests: such as for joints. - FCDVisualSceneNodeLibrary* vsl = idoc->GetVisualSceneLibrary(); - PassIf(vsl->GetEntityCount() >= 3); - - // Verify that the visual scene ids are unique. - for (size_t i = 0; i < vsl->GetEntityCount(); ++i) - { - FCDSceneNode* inode = vsl->GetEntity(i); - for (size_t j = 0; j < i; ++j) - { - FCDSceneNode* jnode = vsl->GetEntity(j); - FailIf(inode->GetDaeId() == jnode->GetDaeId()); - } - } - - // Verify that the three wanted visual scene ids exist and find the one we fill in. - bool found1 = false, found3 = false; - FCDSceneNode* found2 = NULL; - for (size_t i = 0; i < vsl->GetEntityCount(); ++i) - { - FCDSceneNode* inode = vsl->GetEntity(i); - if (inode->GetDaeId() == sceneNode1->GetDaeId()) - { - FailIf(found1); - PassIf(inode->GetName() == FC("Scene1")); - found1 = true; - } - else if (inode->GetDaeId() == sceneNode3->GetDaeId()) - { - FailIf(found3); - PassIf(inode->GetName() == FC("Scene3")); - found3 = true; - } - else if (inode->GetDaeId() == sceneNode2->GetDaeId()) - { - FailIf(found2 != NULL); - PassIf(inode->GetName() == FC("Scene2")); - found2 = inode; - } - } - PassIf(found2 != NULL); - CheckVisualScene(found2); - - // Compare all these re-imported library contents - CheckImageLibrary(idoc->GetImageLibrary()); - CheckCameraLibrary(idoc->GetCameraLibrary()); - CheckLightLibrary(idoc->GetLightLibrary()); - CheckGeometryLibrary(idoc->GetGeometryLibrary()); - CheckControllerLibrary(idoc->GetControllerLibrary()); - CheckMaterialLibrary(idoc->GetMaterialLibrary()); - CheckAnimationLibrary(idoc->GetAnimationLibrary()); -} diff --git a/Extras/FCollada/FColladaTest/FCTestExportImport/FCTestExportImport.h b/Extras/FCollada/FColladaTest/FCTestExportImport/FCTestExportImport.h deleted file mode 100644 index 3c3703f59..000000000 --- a/Extras/FCollada/FColladaTest/FCTestExportImport/FCTestExportImport.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - Copyright (C) 2006 Feeling Software Inc. - Available only to licensees. - Distribution of this file or its content is strictly prohibited. -*/ - -#ifndef _FC_TEST_SCENE_ -#define _FC_TEST_SCENE_ - -#include "FCDocument/FCDocument.h" -#include "FCDocument/FCDLibrary.h" - -class FCDAnimation; -class FCDEffectProfileFX; -class FCDEffectStandard; -class FCDExtra; -class FCDGeometryMesh; -class FCDGeometrySpline; -class FCDMorphController; -class FCDSceneNode; -class FCDSkinController; - -namespace FCTestExportImport -{ - // Information pushing functions for the export - void FillCameraLibrary(FCDCameraLibrary* library); - void FillLightLibrary(FCDLightLibrary* library); - void FillVisualScene(FCDSceneNode* scene); - void FillExtraTree(FCDExtra* extra); - - void FillGeometryLibrary(FCDGeometryLibrary* library); - void FillGeometryMesh(FCDGeometryMesh* mesh); - void FillGeometrySpline(FCDGeometrySpline* spline); - void FillControllerLibrary(FCDControllerLibrary* library); - void FillControllerMorph(FCDMorphController* controller); - void FillControllerSkin(FCDSkinController* controller); - - void FillImageLibrary(FCDImageLibrary* library); - void FillMaterialLibrary(FCDMaterialLibrary* library); - void FillEffectStandard(FCDEffectStandard* profile); - void FillEffectFX(FCDEffectProfileFX* profile); - - void FillAnimationLibrary(FCDAnimationLibrary* library); - void FillAnimationLight(FCDocument* document, FCDAnimation* animationTree); - - // Re-import verification functions - void CheckCameraLibrary(FCDCameraLibrary* library); - void CheckLightLibrary(FCDLightLibrary* library); - void CheckVisualScene(FCDSceneNode* imported); - void CheckExtraTree(FCDExtra* extra); - - void CheckGeometryLibrary(FCDGeometryLibrary* library); - void CheckGeometryMesh(FCDGeometryMesh* mesh); - void CheckGeometrySpline(FCDGeometrySpline* spline); - void CheckControllerLibrary(FCDControllerLibrary* library); - void CheckControllerMorph(FCDMorphController* controller); - void CheckControllerSkin(FCDSkinController* controller); - - void CheckImageLibrary(FCDImageLibrary* library); - void CheckMaterialLibrary(FCDMaterialLibrary* library); - void CheckEffectStandard(FCDEffectStandard* profile); - void CheckEffectFX(FCDEffectProfileFX* profile); - - void CheckAnimationLibrary(FCDAnimationLibrary* library); - void CheckAnimationLight(FCDocument* document, FCDAnimation* animationTree); -}; - -#endif // _FC_TEST_SCENE_ \ No newline at end of file diff --git a/Extras/FCollada/FColladaTest/FCTestList.h b/Extras/FCollada/FColladaTest/FCTestList.h deleted file mode 100644 index 8240a107a..000000000 --- a/Extras/FCollada/FColladaTest/FCTestList.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - Available only to licensees. - Distribution of this file or its content is strictly prohibited. -*/ - -/* It is intentional that there is no multiple #include barrier here. */ -/* This function is included directly twice by FCTest.cpp */ - -// FCTestUtils.cpp -FCTEST(TestUniqueStringMap); - -// FCTestAnimation.cpp -FCTEST(TestImportSampling); - -// FCTestScene.cpp -FCTEST(TestUniqueScene); diff --git a/Extras/FCollada/FColladaTest/FCTestUtils.cpp b/Extras/FCollada/FColladaTest/FCTestUtils.cpp deleted file mode 100644 index 16bd7e5a8..000000000 --- a/Extras/FCollada/FColladaTest/FCTestUtils.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - Available only to licensees. - Distribution of this file or its content is strictly prohibited. -*/ - -#include "StdAfx.h" -#include "FUtils/FUUniqueStringMap.h" - -void TestUniqueStringMap() -{ -#define VERIFY_UNIQUE(c) { for (StringList::iterator itN = uniqueNames.begin(); itN != uniqueNames.end(); ++itN) { FailIf((*itN) == (c)); } } - StringList uniqueNames; - - FUSUniqueStringMap names; - FailIf(names.Exists("Test")); - FailIf(names.Exists("Test0")); - FailIf(names.Exists("Test1")); - FailIf(names.Exists("Test2")); - - // Add a first name: should always be unique - string name1 = "Test"; - names.AddUniqueString(name1); - PassIf(names.Exists("Test")); - PassIf(name1 == "Test"); - uniqueNames.push_back(name1); - - // Add a second name that should also be unique - string name2 = "Glad"; - names.AddUniqueString(name2); - PassIf(names.Exists("Glad")); - PassIf(name2 == "Glad"); - uniqueNames.push_back(name2); - - // Add the first name a couple more times - string name3 = name1; - names.AddUniqueString(name3); - PassIf(names.Exists(name3)); - VERIFY_UNIQUE(name3); - uniqueNames.push_back(name3); - - name3 = name1; - names.AddUniqueString(name3); - PassIf(names.Exists(name3)); - VERIFY_UNIQUE(name3); - uniqueNames.push_back(name3); - - // Add the second name a couple more times - name3 = name2; - names.AddUniqueString(name3); - PassIf(names.Exists(name3)); - VERIFY_UNIQUE(name3); - uniqueNames.push_back(name3); - - name3 = name2; - names.AddUniqueString(name3); - PassIf(names.Exists(name3)); - VERIFY_UNIQUE(name3); - uniqueNames.push_back(name3); - - // There should now be 6 unique names, so pick some randomly and verify that we're always getting more unique names. - for (int32 i = 0; i < 5; ++i) - { - int32 index = rand() % ((int32)uniqueNames.size()); - name3 = uniqueNames[index]; - names.AddUniqueString(name3); - PassIf(names.Exists(name3)); - VERIFY_UNIQUE(name3); - uniqueNames.push_back(name3); - } -} \ No newline at end of file diff --git a/Extras/FCollada/FColladaTest/Samples/Eagle.DAE b/Extras/FCollada/FColladaTest/Samples/Eagle.DAE deleted file mode 100644 index 327447a17..000000000 --- a/Extras/FCollada/FColladaTest/Samples/Eagle.DAE +++ /dev/null @@ -1,1899 +0,0 @@ - - - - - Guillaume Laforte - Feeling ColladaMax v0.01 with FCollada v0.03. - file://C:/Work/ColladaMax/Conformance/Data/SourceData/Max/06_Animation/simple_003_SkeletalAnimation_04.max - - 2006-02-21T14:49:36Z - 2006-02-21T14:49:36Z - 1.0 - - Z_UP - - - - - - 0.066667 0.133333 1.300000 1.433333 1.633333 - - - - - - - - 71.388931 71.388931 71.388931 71.388931 71.388931 - - - - - - - - BEZIER BEZIER BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 0 0 - - - - - - - - 0 0 0 0 0 - - - - - - - - 0.066667 0.133333 1.300000 1.433333 1.633333 - - - - - - - - 0.000062 0.000062 0.000062 0.000062 0.000062 - - - - - - - - BEZIER BEZIER BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 0 0 - - - - - - - - 0 0 0 0 0 - - - - - - - - 0.066667 0.133333 1.300000 1.433333 1.633333 - - - - - - - - 10.399197 10.399197 10.399197 10.399197 10.399197 - - - - - - - - BEZIER BEZIER BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 0 0 - - - - - - - - 0 0 0 0 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 0.066667 0.100000 0.133333 0.166667 0.233333 0.300000 0.366667 0.433333 0.500000 0.566667 0.633333 0.700000 0.766667 0.833333 0.900000 0.966667 1.033333 1.100000 1.166667 1.233333 1.300000 1.366667 1.433333 1.466667 1.566667 1.633333 1.700000 1.766667 1.833333 - - - - - - - - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - - - - - - - - BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - - - - - - - - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - - - - - - - - 0 0.066667 0.100000 0.133333 0.166667 0.233333 0.300000 0.366667 0.433333 0.500000 0.566667 0.633333 0.700000 0.766667 0.833333 0.900000 0.966667 1.033333 1.100000 1.166667 1.233333 1.300000 1.366667 1.433333 1.466667 1.566667 1.633333 1.700000 1.766667 1.833333 - - - - - - - - 0 -3.009404 -5.220536 -5.220536 -9.179274 -11.161325 -14.509405 -16.219240 -19.378359 -21.868347 -25.696596 -27.495636 -31.392754 -34.431156 -33.771015 -31.393372 -29.720545 -28.323740 -24.995041 -23.734964 -19.420639 -17.647865 -16.480913 -13.145423 -10.297379 -6.017621 -3.416764 -1.910502 -1.390901 -1.390901 - - - - - - - - BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER - - - - - - - - 0 0.326283 0 0 0.371299 0.249850 0.237090 0.228232 0.264802 0.296167 0.263779 0.267007 0.325103 0 -0.142396 -0.189866 -0.143889 -0.221508 -0.215099 -0.261300 -0.285333 -0.137800 -0.211052 -0.386471 -0.334116 -0.258023 -0.192521 -0.094962 0 0 - - - - - - - - 0 -0.326283 0 0 -0.371299 -0.249850 -0.237090 -0.228232 -0.264802 -0.296167 -0.263779 -0.267007 -0.325103 0 0.142396 0.189866 0.143889 0.221508 0.215099 0.261300 0.285333 0.137800 0.211052 0.386471 0.334116 0.258023 0.192521 0.094962 0 0 - - - - - - - - 0 0.066667 0.100000 0.133333 0.166667 0.233333 0.300000 0.366667 0.433333 0.500000 0.566667 0.633333 0.700000 0.766667 0.833333 0.900000 0.966667 1.033333 1.100000 1.166667 1.233333 1.300000 1.366667 1.433333 1.466667 1.566667 1.633333 1.700000 1.766667 1.833333 - - - - - - - - -180.000168 -180.000168 -180.000168 -180.000168 -180.000168 -180.000168 -180.000168 -180.000168 -180.000168 -180.000168 -180.000168 -180.000168 -180.000168 -180.000168 -180.000168 -180.000168 -180.000168 -180.000168 -180.000168 -180.000168 -180.000168 -180.000168 -180.000168 -180.000168 -180.000168 -180.000168 -180.000168 -180.000168 -180.000168 -180.000168 - - - - - - - - BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - - - - - - - - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0.066667 0.133333 1.300000 1.433333 1.633333 - - - - - - - - 1.000000 1.000000 1.000000 1.000000 1.000000 - - - - - - - - BEZIER BEZIER BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 0 0 - - - - - - - - 0 0 0 0 0 - - - - - - - - 0.066667 0.133333 1.300000 1.433333 1.633333 - - - - - - - - 0 0 0 0 0 - - - - - - - - BEZIER BEZIER BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 0 0 - - - - - - - - 0 0 0 0 0 - - - - - - - - 0.066667 0.133333 1.300000 1.433333 1.633333 - - - - - - - - 0 0 0 0 0 - - - - - - - - BEZIER BEZIER BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 0 0 - - - - - - - - 0 0 0 0 0 - - - - - - - - 0.066667 0.133333 1.300000 1.433333 1.633333 - - - - - - - - 0 0 0 0 0 - - - - - - - - BEZIER BEZIER BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 0 0 - - - - - - - - 0 0 0 0 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0.066667 0.133333 1.300000 1.433333 1.633333 - - - - - - - - 1.000000 1.000000 1.000000 1.000000 1.000000 - - - - - - - - BEZIER BEZIER BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 0 0 - - - - - - - - 0 0 0 0 0 - - - - - - - - 0.066667 0.133333 1.300000 1.433333 1.633333 - - - - - - - - 1.000000 1.000000 1.000000 1.000000 1.000000 - - - - - - - - BEZIER BEZIER BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 0 0 - - - - - - - - 0 0 0 0 0 - - - - - - - - 0.066667 0.133333 1.300000 1.433333 1.633333 - - - - - - - - 1.000000 1.000000 1.000000 1.000000 1.000000 - - - - - - - - BEZIER BEZIER BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 0 0 - - - - - - - - 0 0 0 0 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0.066667 0.133333 1.300000 1.433333 1.633333 - - - - - - - - 1.000000 1.000000 1.000000 1.000000 1.000000 - - - - - - - - BEZIER BEZIER BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 0 0 - - - - - - - - 0 0 0 0 0 - - - - - - - - 0.066667 0.133333 1.300000 1.433333 1.633333 - - - - - - - - 0 0 0 0 0 - - - - - - - - BEZIER BEZIER BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 0 0 - - - - - - - - 0 0 0 0 0 - - - - - - - - 0.066667 0.133333 1.300000 1.433333 1.633333 - - - - - - - - 0 0 0 0 0 - - - - - - - - BEZIER BEZIER BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 0 0 - - - - - - - - 0 0 0 0 0 - - - - - - - - 0.066667 0.133333 1.300000 1.433333 1.633333 - - - - - - - - 0 0 0 0 0 - - - - - - - - BEZIER BEZIER BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 0 0 - - - - - - - - 0 0 0 0 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1.566667 1.700000 1.766667 - - - - - - - - 99.001984 99.001984 99.001984 - - - - - - - - BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 - - - - - - - - 0 0 0 - - - - - - - - 1.566667 1.700000 1.766667 - - - - - - - - 0.000012 0.000012 0.000012 - - - - - - - - BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 - - - - - - - - 0 0 0 - - - - - - - - 1.566667 1.700000 1.766667 - - - - - - - - 0 0 0 - - - - - - - - BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 - - - - - - - - 0 0 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 0.233333 0.300000 0.366667 0.433333 0.500000 0.566667 0.700000 0.900000 0.966667 1.100000 1.233333 1.366667 1.466667 1.566667 1.700000 1.766667 1.833333 - - - - - - - - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - - - - - - - - BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - - - - - - - - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - - - - - - - - 0 0.233333 0.300000 0.366667 0.433333 0.500000 0.566667 0.700000 0.900000 0.966667 1.100000 1.233333 1.366667 1.466667 1.566667 1.700000 1.766667 1.833333 - - - - - - - - 0 3.654185 7.221884 11.749501 15.230330 17.414125 24.071526 32.524971 29.217825 26.283381 21.052565 23.170980 18.224821 12.278664 7.881567 5.763361 2.786477 1.920451 - - - - - - - - BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER - - - - - - - - 0 -0.150456 -0.379468 -0.375396 -0.265529 -0.414431 -0.472214 0 0.146287 0.255164 0 0 0.291759 0.323227 0.174517 0.159222 0.180136 0 - - - - - - - - 0 0.150456 0.379468 0.375396 0.265529 0.414431 0.472214 0 -0.146287 -0.255164 0 0 -0.291759 -0.323227 -0.174517 -0.159222 -0.180136 0 - - - - - - - - 0 0.233333 0.300000 0.366667 0.433333 0.500000 0.566667 0.700000 0.900000 0.966667 1.100000 1.233333 1.366667 1.466667 1.566667 1.700000 1.766667 1.833333 - - - - - - - - 0.000082 0.000082 0.000082 0.000082 0.000082 0.000082 0.000082 0.000082 0.000082 0.000082 0.000082 0.000082 0.000082 0.000082 0.000082 0.000082 0.000082 0.000082 - - - - - - - - BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - - - - - - - - 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1.566667 1.700000 1.766667 - - - - - - - - 1.000000 1.000000 1.000000 - - - - - - - - BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 - - - - - - - - 0 0 0 - - - - - - - - 1.566667 1.700000 1.766667 - - - - - - - - 0 0 0 - - - - - - - - BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 - - - - - - - - 0 0 0 - - - - - - - - 1.566667 1.700000 1.766667 - - - - - - - - 0 0 0 - - - - - - - - BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 - - - - - - - - 0 0 0 - - - - - - - - 1.566667 1.700000 1.766667 - - - - - - - - 0 0 0 - - - - - - - - BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 - - - - - - - - 0 0 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1.566667 1.700000 1.766667 - - - - - - - - 1.000000 1.000000 1.000000 - - - - - - - - BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 - - - - - - - - 0 0 0 - - - - - - - - 1.566667 1.700000 1.766667 - - - - - - - - 1.000000 1.000000 1.000000 - - - - - - - - BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 - - - - - - - - 0 0 0 - - - - - - - - 1.566667 1.700000 1.766667 - - - - - - - - 1.000000 1.000000 1.000000 - - - - - - - - BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 - - - - - - - - 0 0 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1.566667 1.700000 1.766667 - - - - - - - - 1.000000 1.000000 1.000000 - - - - - - - - BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 - - - - - - - - 0 0 0 - - - - - - - - 1.566667 1.700000 1.766667 - - - - - - - - 0 0 0 - - - - - - - - BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 - - - - - - - - 0 0 0 - - - - - - - - 1.566667 1.700000 1.766667 - - - - - - - - 0 0 0 - - - - - - - - BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 - - - - - - - - 0 0 0 - - - - - - - - 1.566667 1.700000 1.766667 - - - - - - - - 0 0 0 - - - - - - - - BEZIER BEZIER BEZIER - - - - - - - - 0 0 0 - - - - - - - - 0 0 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0.803922 0.588235 0.92549 1 - - - 0.803922 0.588235 0.92549 1 - - - 0.631373 0.631373 0.631373 1 - - - 1 - - - 0 0 0 1 - - - 1 1 1 1 - - - 0 - - - - - - 0 - - - 0 - - false - false - false - false - - - - - - - - - - - - 45 - 1 - 100 - 2500 - - - - - - - - - - 1 1 1 - 0.025 - 0 - 0 - - - - 1 - - - - - - 1 1 1 - 0.025 - 0 - 0 - - - - 1 - - - - - - 0.427451 0.427451 0.427451 - - - - - - - - - 1.560513 79.044914 0 32.698235 39.921673 0 32.698235 19.960840 0 -56.722916 10.379636 0 -77.481400 10.379636 0 -77.481400 -9.581203 0 -57.521317 -9.581203 0 32.698235 -20.759268 0 32.698235 -40.720112 0 2.358915 -79.843353 0 -128.579193 -30.340471 0 -103.828697 -60.680946 0 2.358915 -114.175987 0 72.618385 -41.518539 0 72.618385 -18.363970 0 152.458710 -11.976501 0 152.458710 13.573371 0 72.618385 19.960840 0 72.618385 43.115406 0 2.358915 112.579117 0 -106.223907 58.285645 0 -126.982384 30.340475 0 2.358915 -79.843353 20.000000 -128.579193 -30.340471 20.000000 -103.828697 -60.680946 20.000000 2.358915 -114.175987 20.000000 72.618385 -41.518539 20.000000 72.618385 -18.363970 20.000000 152.458710 -11.976501 14.375423 152.458710 13.573371 14.375423 72.618385 19.960840 20.000000 72.618385 43.115406 20.000000 2.358915 112.579117 20.000000 -106.223907 58.285645 20.000000 -126.982384 30.340475 20.000000 1.560513 79.044914 20.000000 32.698235 39.921673 20.000000 32.698235 19.960840 20.000000 -56.722916 10.379636 14.375423 -77.481400 10.379636 14.375423 -77.481400 -9.581203 14.375423 -57.521317 -9.581203 14.375423 32.698235 -20.759268 20.000000 32.698235 -40.720112 20.000000 - - - - - - - - - - 0.070274 0 0.997528 0.070274 0 0.997528 0.022631 0 0.999744 0 0 1.000000 0 0 1.000000 0 0 1.000000 0 0 1.000000 0 0 1.000000 0 0 1.000000 -0.019827 0.000115 0.999803 0 0 1.000000 0 0 1.000000 -0.031844 0.000939 0.999492 -0.033348 0.001334 0.999443 -0.019637 0 0.999807 0 0 1.000000 0 0 1.000000 0 0 1.000000 0 0 1.000000 0 0 1.000000 0 0 1.000000 0.022631 0 0.999744 0.353634 0.935384 0 0.353634 0.935384 0 0.353634 0.935384 0 0.353634 0.935384 0 0.353634 0.935384 0 0.353634 0.935384 0 -0.774877 -0.632112 0 -0.774877 -0.632112 0 -0.774877 -0.632112 0 -0.774877 -0.632112 0 -0.774877 -0.632112 0 -0.774877 -0.632112 0 -0.449911 -0.893073 0 -0.449911 -0.893073 0 -0.449911 -0.893073 0 -0.449911 -0.893073 0 -0.449911 -0.893073 0 -0.449911 -0.893073 0 0.718870 -0.695144 0 0.718870 -0.695145 0 0.718870 -0.695145 0 0.718870 -0.695144 0 0.718870 -0.695145 0 0.718870 -0.695145 0 1.000000 0 0 1.000000 0 0 1.000000 0 0 1.000000 0 0 1.000000 0 0 1.000000 0 0 0.079748 -0.996815 0 0.079748 -0.996815 0 0.079748 -0.996815 0 0.079748 -0.996815 0 0.079748 -0.996815 0 0.079748 -0.996815 0 1.000000 0 0 1.000000 0 0 1.000000 0 0 1.000000 0 0 1.000000 0 0 1.000000 0 0 0.079748 0.996815 0 0.079748 0.996815 0 0.079748 0.996815 0 0.079748 0.996815 0 0.079748 0.996815 0 0.079748 0.996815 0 1.000000 0 0 1.000000 0 0 1.000000 0 0 1.000000 0 0 1.000000 0 0 1.000000 0 0 0.703068 0.711122 0 0.703068 0.711122 0 0.703068 0.711122 0 0.703068 0.711122 0 0.703068 0.711122 0 0.703068 0.711122 0 -0.447227 0.894420 0 -0.447227 0.894420 0 -0.447227 0.894420 0 -0.447227 0.894420 0 -0.447227 0.894420 0 -0.447227 0.894420 0 -0.802755 0.596309 0 -0.802755 0.596309 0 -0.802755 0.596309 0 -0.802755 0.596309 0 -0.802755 0.596309 0 -0.802755 0.596309 0 0.354316 -0.935126 0 0.354316 -0.935126 0 0.354316 -0.935126 0 0.354316 -0.935126 0 0.354316 -0.935126 0 0.354316 -0.935126 0 -0.782436 -0.622731 0 -0.782436 -0.622731 0 -0.782436 -0.622731 0 -0.782436 -0.622731 0 -0.782436 -0.622731 0 -0.782436 -0.622731 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -0.106537 0.994309 0 -0.106537 0.994309 0 -0.106537 0.994309 0 -0.106537 0.994309 0 -0.106537 0.994309 0 -0.106537 0.994309 0 0 1.000000 0 0 1.000000 0 0 1.000000 0 0 1.000000 0 0 1.000000 0 0 1.000000 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 -0.122958 -0.992412 0 -0.122958 -0.992412 0 -0.122958 -0.992412 0 -0.122958 -0.992412 0 -0.122958 -0.992412 0 -0.122958 -0.992412 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -0.790231 0.612809 0 -0.790231 0.612809 0 -0.790231 0.612809 0 -0.790231 0.612809 0 -0.790231 0.612809 0 -0.790231 0.612809 0 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 0 0 -1.000000 - - - - - - - - - - - - - - -

28 0 29 1 30 2 33 3 34 4 35 5 32 6 33 3 35 5 31 7 32 6 35 5 31 7 35 5 36 8 30 2 31 7 36 8 30 2 36 8 37 9 39 10 40 11 41 12 38 13 39 10 41 12 37 9 38 13 41 12 37 9 41 12 42 14 22 15 23 16 24 17 22 15 24 17 25 18 22 15 25 18 26 19 43 20 22 15 26 19 43 20 26 19 27 21 42 14 43 20 27 21 37 9 42 14 27 21 30 2 37 9 27 21 28 0 30 2 27 21 9 22 10 23 23 24 23 25 22 26 9 27 10 28 11 29 24 30 24 31 23 32 10 33 11 34 12 35 25 36 25 37 24 38 11 39 12 40 13 41 26 42 26 43 25 44 12 45 13 46 14 47 27 48 27 49 26 50 13 51 14 52 15 53 28 54 28 55 27 56 14 57 15 58 16 59 29 60 29 61 28 62 15 63 16 64 17 65 30 66 30 67 29 68 16 69 17 70 18 71 31 72 31 73 30 74 17 75 18 76 19 77 32 78 32 79 31 80 18 81 19 82 20 83 33 84 33 85 32 86 19 87 20 88 21 89 34 90 34 91 33 92 20 93 21 94 0 95 35 96 35 97 34 98 21 99 0 100 1 101 36 102 36 103 35 104 0 105 1 106 2 107 37 108 37 109 36 110 1 111 2 112 3 113 38 114 38 115 37 116 2 117 3 118 4 119 39 120 39 121 38 122 3 123 4 124 5 125 40 126 40 127 39 128 4 129 5 130 6 131 41 132 41 133 40 134 5 135 6 136 7 137 42 138 42 139 41 140 6 141 7 142 8 143 43 144 43 145 42 146 7 147 8 148 9 149 22 150 22 151 43 152 8 153 6 154 5 155 4 156 7 157 6 158 4 159 7 160 4 161 3 162 7 163 3 164 2 165 0 166 21 167 20 168 0 169 20 170 19 171 1 172 0 173 19 174 19 175 18 176 17 177 17 178 16 179 15 180 17 181 15 182 14 183 19 184 17 185 14 186 1 187 19 188 14 189 2 190 1 191 14 192 7 193 2 194 14 195 8 196 7 197 14 198 9 199 8 200 14 201 14 202 13 203 12 204 9 205 14 206 12 207 9 208 12 209 11 210 9 211 11 212 10 213

- -
-
- - - - - 1 0 0 27.1823 0 1 0 5.20186e-005 0 0 1 0 0 0 0 1 - - Bone09 Bone10 Bone11 - - - - - - - - -1.000000 0.000000 0 71.388931 -0.000000 -1.000000 0 0.000086 0 0 1.000000 -10.399197 0 0 0 1 -1.000000 -0.000001 0 -27.613052 0.000001 -1.000000 0 0.000113 0 0 1.000000 -10.399197 0 0 0 1 -1.000000 -0.000001 0 -46.774727 0.000001 -1.000000 0 0.000119 0 0 1.000000 -10.399197 0 0 0 1 - - - - - - - - 0 1 0.306916 0.693084 0.262203 0.737797 0.393212 0.606788 0.012221 0.987779 0.030148 0.969852 0.365805 0.634195 - - - - - - - - - - - - - - 1 1 1 2 1 1 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 1 1 - 0 1 0 1 0 1 0 2 1 3 1 1 1 1 0 4 1 5 0 1 0 1 0 1 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 0 1 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 1 1 0 1 0 1 0 1 0 6 1 7 2 8 1 9 2 10 1 11 0 12 1 13 0 1 0 1 - - - - - - - - - #Bone09 - - - - - - - - - 71.3889 6.24014e-005 10.3992 - 0 0 1 180 - 0 1 0 0 - 1 0 0 0 - 1 0 0 0 - 1 1 1 - 1 0 0 0 - - 99.002 1.17796e-005 0 - 0 0 1 8.19623e-005 - 0 1 0 0 - 1 0 0 0 - 1 0 0 0 - 1 1 1 - 1 0 0 0 - - 19.1617 2.49494e-006 0 - - - - - -159.297 -809.548 933.846 - -0.963465 0.259968 -0.0644414 -39.9892 - - - - -1421.76 -14.7271 1114.5 - - - - -744.717 534.595 731.262 - - - - - - - - - - - \ No newline at end of file diff --git a/Extras/FCollada/FColladaTest/StdAfx.cpp b/Extras/FCollada/FColladaTest/StdAfx.cpp deleted file mode 100644 index 033c087ad..000000000 --- a/Extras/FCollada/FColladaTest/StdAfx.cpp +++ /dev/null @@ -1,7 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - Available only to licensees. - Distribution of this file or its content is strictly prohibited. -*/ - -#include "StdAfx.h" \ No newline at end of file diff --git a/Extras/FCollada/FColladaTest/StdAfx.h b/Extras/FCollada/FColladaTest/StdAfx.h deleted file mode 100644 index 08ee83ade..000000000 --- a/Extras/FCollada/FColladaTest/StdAfx.h +++ /dev/null @@ -1,20 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - Available only to licensees. - Distribution of this file or its content is strictly prohibited. -*/ - -#ifndef _STDAFX_H_ -#define _STDAFX_H_ - -// FCollada -#include "FCollada.h" -#include "FUtils/FUAssert.h" - -// STL -#include - -// FColladaTest -#include "FCTest.h" - -#endif // _STDAFX_H_ diff --git a/Extras/FCollada/FCollada_vc7.vcproj b/Extras/FCollada/FCollada_vc7.vcproj deleted file mode 100644 index 68f472a74..000000000 --- a/Extras/FCollada/FCollada_vc7.vcproj +++ /dev/null @@ -1,1338 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/FCollada/FCollada_vc8.vcproj b/Extras/FCollada/FCollada_vc8.vcproj deleted file mode 100644 index 75f4c4897..000000000 --- a/Extras/FCollada/FCollada_vc8.vcproj +++ /dev/null @@ -1,1338 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/FCollada/FMath/FMArray.h b/Extras/FCollada/FMath/FMArray.h deleted file mode 100644 index 6a18d873a..000000000 --- a/Extras/FCollada/FMath/FMArray.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FMArray.h - The file contains the vector class, which improves on the standard C++ vector class. - */ - -/** - A dynamically-sized array. - Built on top of the standard C++ vector class, this class improves on the interface - by adding the following functionality: - - constructor that takes in a constant-sized array. - - comparison which a constant-sized array. - - @ingroup FMath -*/ - -template -class FCOLLADA_EXPORT vector : public std::vector -{ -public: - /** Default constructor. */ - vector() : std::vector() {} - - /** Constructor: Builds a dynamically-sized array of the wanted size. - @param size The wanted size of the array. */ - vector(size_t size) : std::vector(size) {} - - /** Constructor: Builds a dynamically-sized array of the wanted size. - @param size The wanted size of the array - @param defaultValue The default value to use for all the entries of the array. */ - vector(size_t size, const T& defaultValue) : std::vector(size, defaultValue) {} - - /** Copy constructor. - @param copy The dynamically-sized array to copy the values from. */ - 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. - @param count The size of the constant-sized array. */ - vector(const T* values, size_t count) : std::vector() - { - resize(count); - memcpy(&at(0), values, count * sizeof(T)); - } -}; - -/** Returns whether a dynamically-sized array is equivalent to a constant-sized array. - @param dl A dynamically-sized array. - @param cl A constant-sized array. - @param count The size of the constant-sized array. - @return Whether the two arrays are equivalent. */ -template -inline bool IsEquivalent(const vector& dl, const T* cl, size_t count) -{ - if (dl.size() != count) return false; - bool equivalent = true; - for (size_t i = 0; i < count && equivalent; ++i) equivalent = IsEquivalent(dl.at(i), cl[i]); - return equivalent; -} \ No newline at end of file diff --git a/Extras/FCollada/FMath/FMColor.cpp b/Extras/FCollada/FMath/FMColor.cpp deleted file mode 100644 index 13a8ab374..000000000 --- a/Extras/FCollada/FMath/FMColor.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FMColor.h" - -FMColor::FMColor(const float* components, uint32 componentCount) -{ - switch (componentCount) - { - case 1: - r = (uint8) (components[0] * 255.0f); - g = 0; b = 0; a = 255; - break; - - case 2: - r = (uint8) (components[0] * 255.0f); - g = (uint8) (components[1] * 255.0f); - b = 0; a = 255; - break; - - case 3: - r = (uint8) (components[0] * 255.0f); - g = (uint8) (components[1] * 255.0f); - b = (uint8) (components[2] * 255.0f); - a = 255; - break; - - case 4: - r = (uint8) (components[0] * 255.0f); - g = (uint8) (components[1] * 255.0f); - b = (uint8) (components[2] * 255.0f); - a = (uint8) (components[3] * 255.0f); - break; - - default: - r = 0; g = 0; b = 0; a = 255; - break; - } -} - -void FMColor::ToFloats(float* components, uint32 componentCount) -{ - switch (componentCount) - { - case 1: - components[0] = float(r) / 255.0f; - break; - - case 2: - components[0] = float(r) / 255.0f; - components[1] = float(g) / 255.0f; - break; - - case 3: - components[0] = float(r) / 255.0f; - components[1] = float(g) / 255.0f; - components[2] = float(b) / 255.0f; - break; - - case 4: - components[0] = float(r) / 255.0f; - components[1] = float(g) / 255.0f; - components[2] = float(b) / 255.0f; - break; - - default: - for (uint32 i = 0; i < componentCount; ++i) components[i] = 0.0f; - break; - } -} - diff --git a/Extras/FCollada/FMath/FMColor.h b/Extras/FCollada/FMath/FMColor.h deleted file mode 100644 index 780286384..000000000 --- a/Extras/FCollada/FMath/FMColor.h +++ /dev/null @@ -1,113 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FMColor.h - The file containing the class and global functions for RBGA colors. -*/ - -#ifndef _FM_COLOR_H_ -#define _FM_COLOR_H_ - -/** - A RBGA color. - Not used within FCollada. - - @ingroup FMath -*/ -class FCOLLADA_EXPORT FMColor -{ -public: - uint8 r; /**< The red component. */ - uint8 g; /**< The green component. */ - uint8 b; /**< The blue component. */ - uint8 a; /**< The alpha component. */ - - /** - * Creates an empty FMColor. - * - * The default values are non deterministic. - */ - FMColor() {} - - /** - * Creates the FMColor with the coordinates values. - * - * The first three coordinates are taken from the FMVector3, where the - * first one is the x value, the second is that y, and the third is the z. - * The forth value is the \c float specified. - * - * - * @param _r The red value. - * @param _g The green value. - * @param _b The blue value. - * @param _a The alpha value. - */ - FMColor(uint8 _r, uint8 _g, uint8 _b, uint8 _a) { r = _r; g = _g; b = _b; a = _a; } - - /** - * Creates the FMColor from a color encoded into a uint32. - * - * The most significant byte makes up the red value. The second most - * significant makes up the green value, the third the blue, and the forth - * the alpha. - * - * @param hex The uint to decode the color values from. - */ - FMColor(uint32 hex) { r = uint8((hex & 0xFF000000) >> 24); g = uint8((hex & 0xFF0000) >> 16); b = uint8((hex & 0xFF00) >> 8); a = uint8(hex & 0xFF); } - - /** - * Creates the FMColor from a list of \c floats. - * - * It creates the FMColor with the values specified in the \c floats, which - * range from 0.0f to 1.0f. - * - * \a componentCount is used to determined how many values to take from the - * \c float array. If there are insufficient values, then it will give the - * remaining values default values. The default values are 0 for the colors - * and 255 for the alpha. It fills in the values in this order: red, green, - * blue, alpha. - * - * @param components The \c float array to get values from. - * @param componentCount The amount of \c float to take from the array. - */ - FMColor(const float* components, uint32 componentCount); - - /** - * Get this FMColor as an array of \c floats. - * - * It fills the first \a componentCount elements (max 4) of \c components - * with the red, green, blue, alpha values of this FMColor in that order. - * - * @param components The \c float array to fill. - * @param componentCount The amount of \c float to fill into the array. - */ - void ToFloats(float* components, uint32 componentCount); - - /** - * Get the average of the three color values of this FMColor. - * - * @return The averages of the three colors values of this FMColor. - */ - inline uint8 ComponentAverage() { return uint8((uint32(r) + uint32(g) + uint32(b)) / 3); } - - /** - * Get this FMColor as an array of uint8s. - * - * @return The \c uint8 array. - */ - operator uint8*() { return &b; } -}; - -/** - * Multiplication of a scalar with the FMColor. - * - * @param s The scalar to multiply by. - * @param c The FMColor to multiply with. - * @return the FMColor representing the resulting color. - */ -inline FMColor operator*(float s, const FMColor& c) { return FMColor(uint8(c.r * s), uint8(c.g * s), uint8(c.b * s), uint8(c.a * s)); } - -#endif // _FM_COLOR_H_ diff --git a/Extras/FCollada/FMath/FMFloat.h b/Extras/FCollada/FMath/FMFloat.h deleted file mode 100644 index adfa83790..000000000 --- a/Extras/FCollada/FMath/FMFloat.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FMFloat.h - The file containing functions and constants for floating point values. - */ - -#ifdef WIN32 -#include -#endif - -/** The default tolerance for double-sized floating-point comparison functions. */ -#define DBL_TOLERANCE 0.0001 -/** The default tolerance for single-sized floating-point comparison functions. */ -#define FLT_TOLERANCE 0.0001f - -/** A dynamically-sized array of double-sized floating-point values. */ -typedef vector DoubleList; - -/** A dynamically-sized array of floating-point values. */ -typedef vector FloatList; - -/** Returns whether two floating-point values are equivalent within a given tolerance. - @param f1 A first floating-point value. - @param f2 A second floating-point value. */ -inline bool IsEquivalent(float f1, float f2) { return f1 - f2 < FLT_TOLERANCE && f2 - f1 < FLT_TOLERANCE; } - -/** Returns whether two floating-point values are equivalent within a given tolerance. - @param f1 A first floating-point value. - @param f2 A second floating-point value. - @param tolerance The tolerance in which to accept the two floating-point values as equivalent. */ -inline bool IsEquivalent(float f1, float f2, float tolerance) { return f1 - f2 < tolerance && f2 - f1 < tolerance; } - -/** Returns whether two double-sized floating-point values are equivalent. - @param f1 A first double-sized floating-point value. - @param f2 A second double-sized floating-point value. */ -inline bool IsEquivalent(double f1, double f2) { return f1 - f2 < DBL_TOLERANCE && f2 - f1 < DBL_TOLERANCE; } - -/** Returns whether two double-sized floating-point values are equivalent within a given tolerance. - @param f1 A first double-sized floating-point value. - @param f2 A second double-sized floating-point value. - @param tolerance The tolerance in which to accept the two double-sized floating-point values as equivalent. */ -inline bool IsEquivalent(double f1, double f2, double tolerance) { return f1 - f2 < tolerance && f2 - f1 < tolerance; } diff --git a/Extras/FCollada/FMath/FMInteger.h b/Extras/FCollada/FMath/FMInteger.h deleted file mode 100644 index d9a8e4ee8..000000000 --- a/Extras/FCollada/FMath/FMInteger.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FMInteger.h - The file containing functions and constants for integer values. - */ - -/** A dynamically-sized array of 32-bit signed integer values. */ -typedef vector Int32List; -/** A dynamically-sized array of 32-bit unsigned integer values. */ -typedef vector UInt32List; -/** A dynamically-sized array of 16-bit unsigned integer values. */ -typedef vector UInt16List; -/** A dynamically-sized array of 8-bit unsigned integer values. */ -typedef vector UInt8List; -/** A dynamically-sized array of 8-bit signed integer values. */ -typedef vector Int8List; -/** A dynamically-sized array of boolean values. */ -typedef vector BooleanList; - -/** Returns whether two signed or unsigned integers are equivalent. - For integers, this function simply wraps around the operator==. - @param i1 A first integer. - @param i2 A second integer. - @return Whether the two integers are equivalent. */ -inline bool IsEquivalent(int8 i1, int8 i2) { return i1 == i2; } -inline bool IsEquivalent(uint8 i1, uint8 i2) { return i1 == i2; } /**< See above. */ -inline bool IsEquivalent(int16 i1, int16 i2) { return i1 == i2; } /**< See above. */ -inline bool IsEquivalent(uint16 i1, uint16 i2) { return i1 == i2; } /**< See above. */ -inline bool IsEquivalent(int32 i1, int32 i2) { return i1 == i2; } /**< See above. */ -inline bool IsEquivalent(uint32 i1, uint32 i2) { return i1 == i2; } /**< See above. */ -inline bool IsEquivalent(int64 i1, int64 i2) { return i1 == i2; } /**< See above. */ -inline bool IsEquivalent(uint64 i1, uint64 i2) { return i1 == i2; } /**< See above. */ - diff --git a/Extras/FCollada/FMath/FMInterpolation.cpp b/Extras/FCollada/FMath/FMInterpolation.cpp deleted file mode 100644 index 1134f0d06..000000000 --- a/Extras/FCollada/FMath/FMInterpolation.cpp +++ /dev/null @@ -1,9 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FMath/FMInterpolation.h" - -// TODO: Move the float-float interpolations here, instead of within the animation system: va_list, anyone? diff --git a/Extras/FCollada/FMath/FMInterpolation.h b/Extras/FCollada/FMath/FMInterpolation.h deleted file mode 100644 index 40b272a8d..000000000 --- a/Extras/FCollada/FMath/FMInterpolation.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FMInterpolation.h - The file containing the enum for interpolation. -*/ - -#ifndef _FM_INTERPOLATION_H_ -#define _FM_INTERPOLATION_H_ - -/** - A namespace for interpolations. - - @ingroup FMath -*/ -namespace FMInterpolation -{ - /** The different types of interpolation. */ - enum Interpolation - { - NONE = 0, /**< No interpolation. Also called step interpolation. */ - LINEAR, /**< Linear interpolation. */ - BEZIER, /**< Bezier interpolation. */ - - UNKNOWN, /**< Unknown interpolation. */ - DEFAULT = NONE, /**< Default interpolation (None). */ - }; -}; - -#endif // _FM_INTERPOLATION_H_ diff --git a/Extras/FCollada/FMath/FMMatrix33.cpp b/Extras/FCollada/FMath/FMMatrix33.cpp deleted file mode 100644 index 5772e0f24..000000000 --- a/Extras/FCollada/FMath/FMMatrix33.cpp +++ /dev/null @@ -1,118 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" - -static float __identity[] = { 1, 0, 0, 0, 1, 0 ,0, 0, 1 }; -FMMatrix33 FMMatrix33::identity(__identity); - -FMMatrix33::FMMatrix33(float* _m) -{ - m[0][0] = _m[0]; m[1][0] = _m[1]; m[2][0] = _m[2]; - m[0][1] = _m[3]; m[1][1] = _m[4]; m[2][1] = _m[5]; - m[0][2] = _m[6]; m[1][2] = _m[7]; m[2][2] = _m[8]; -} - -FMMatrix33& FMMatrix33::operator=(const FMMatrix33& copy) -{ - m[0][0] = copy.m[0][0]; m[0][1] = copy.m[0][1]; m[0][2] = copy.m[0][2]; - m[1][0] = copy.m[1][0]; m[1][1] = copy.m[1][1]; m[1][2] = copy.m[1][2]; - m[2][0] = copy.m[2][0]; m[2][1] = copy.m[2][1]; m[2][2] = copy.m[2][2]; - return *this; -} - -// Returns the transpose of this matrix -FMMatrix33 FMMatrix33::Transposed() const -{ - FMMatrix33 mx; - mx.m[0][0] = m[0][0]; mx.m[1][0] = m[0][1]; mx.m[2][0] = m[0][2]; - mx.m[0][1] = m[1][0]; mx.m[1][1] = m[1][1]; mx.m[2][1] = m[1][2]; - mx.m[0][2] = m[2][0]; mx.m[1][2] = m[2][1]; mx.m[2][2] = m[2][2]; - return mx; -} - -FMMatrix33 FMMatrix33::RotationMatrix(float angle) -{ - FMMatrix33 m(identity); - float c = cosf(angle), s = sinf(angle); - m[0][0] = c; m[1][1] = c; - m[0][1] = -s; m[1][0] = s; - return m; -} - -FMMatrix33 FMMatrix33::TranslationMatrix(float tx, float ty) -{ - FMMatrix33 m(identity); - m[2][0] = tx; m[2][1] = ty; - return m; -} - -FMMatrix33 FMMatrix33::ScaleMatrix(float sx, float sy) -{ - FMMatrix33 m(identity); - m[0][0] = sx; m[1][1] = sy; - return m; -} - -// Code taken and adapted from nVidia's nv_algebra: det2x2, invert, multiply -// ----- -// Calculate the determinent of a 2x2 matrix -static inline float det2x2(float a1, float a2, float b1, float b2) -{ - return a1 * b2 - b1 * a2; -} - -// Returns the inverse of this matrix -FMMatrix33 FMMatrix33::Inverted() const -{ - FMMatrix33 b; - - b.m[0][0] = det2x2(m[1][1], m[1][2], m[2][1], m[2][2]); - b.m[0][1] = -det2x2(m[0][1], m[0][2], m[2][1], m[2][2]); - b.m[0][2] = det2x2(m[0][1], m[0][2], m[1][1], m[1][2]); - - b.m[1][0] = -det2x2(m[1][0], m[1][2], m[2][0], m[2][2]); - b.m[1][1] = det2x2(m[0][0], m[0][2], m[2][0], m[2][2]); - b.m[1][2] = -det2x2(m[0][0], m[0][2], m[1][0], m[1][2]); - - b.m[2][0] = det2x2(m[1][0], m[1][1], m[2][0], m[2][1]); - b.m[2][1] = -det2x2(m[0][0], m[0][1], m[2][0], m[2][1]); - b.m[2][2] = det2x2(m[0][0], m[0][1], m[1][0], m[1][1]); - - float det = (m[0][0] * b.m[0][0]) + (m[1][0] * b.m[0][1]) + (m[2][0] * b.m[0][2]); - - // We should consider throwing an exception if det < eps. - if (IsEquivalent(det, 0.0f)) det = 0.01f; - float oodet = 1.0f / det; - - b.m[0][0] *= oodet; - b.m[0][1] *= oodet; - b.m[0][2] *= oodet; - - b.m[1][0] *= oodet; - b.m[1][1] *= oodet; - b.m[1][2] *= oodet; - - b.m[2][0] *= oodet; - b.m[2][1] *= oodet; - b.m[2][2] *= oodet; - - return b; -} - -FMMatrix33 operator*(const FMMatrix33& m1, const FMMatrix33& m2) -{ - FMMatrix33 mx; - mx.m[0][0] = m1.m[0][0] * m2.m[0][0] + m1.m[1][0] * m2.m[0][1] + m1.m[2][0] * m2.m[0][2]; - mx.m[0][1] = m1.m[0][1] * m2.m[0][0] + m1.m[1][1] * m2.m[0][1] + m1.m[2][1] * m2.m[0][2]; - mx.m[0][2] = m1.m[0][2] * m2.m[0][0] + m1.m[1][2] * m2.m[0][1] + m1.m[2][2] * m2.m[0][2]; - mx.m[1][0] = m1.m[0][0] * m2.m[1][0] + m1.m[1][0] * m2.m[1][1] + m1.m[2][0] * m2.m[1][2]; - mx.m[1][1] = m1.m[0][1] * m2.m[1][0] + m1.m[1][1] * m2.m[1][1] + m1.m[2][1] * m2.m[1][2]; - mx.m[1][2] = m1.m[0][2] * m2.m[1][0] + m1.m[1][2] * m2.m[1][1] + m1.m[2][2] * m2.m[1][2]; - mx.m[2][0] = m1.m[0][0] * m2.m[2][0] + m1.m[1][0] * m2.m[2][1] + m1.m[2][0] * m2.m[2][2]; - mx.m[2][1] = m1.m[0][1] * m2.m[2][0] + m1.m[1][1] * m2.m[2][1] + m1.m[2][1] * m2.m[2][2]; - mx.m[2][2] = m1.m[0][2] * m2.m[2][0] + m1.m[1][2] * m2.m[2][1] + m1.m[2][2] * m2.m[2][2]; - return mx; -} diff --git a/Extras/FCollada/FMath/FMMatrix33.h b/Extras/FCollada/FMath/FMMatrix33.h deleted file mode 100644 index 16c9e8195..000000000 --- a/Extras/FCollada/FMath/FMMatrix33.h +++ /dev/null @@ -1,159 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FMMatrix33.h - The file containing the class and global functions for 3x3 matrices. -*/ - -#ifndef _FM_MATRIX33_H_ -#define _FM_MATRIX33_H_ - -/** - A 3x3 matrix: use to represent 2D transformations. - Not used within FCollada. - - @ingroup FMath -*/ -class FCOLLADA_EXPORT FMMatrix33 -{ -public: - float m[3][3]; /**< The matrix elements stored in a 2D array. */ - - /** - * Creates a FMMatrix33 from the \c float array. - * - * The float array stores the elements in the following order: m[0][0], - * m[1][0], m[2][0], m[0][1], m[1][1], m[2][1], m[0][2], m[1][2], m[2][2]. - * - * @param _m The \c float array to create the matrix from. - */ - FMMatrix33(float* _m); - - /** - * Creates an empty FMMatrix33. - * - * The default values are non deterministic. - */ - #ifndef _DEBUG - FMMatrix33() {} - #else - FMMatrix33() { memset(m, 55, 3 * 3 * sizeof(float)); } - #endif - - /** - * Get this FMMatrix33 as an array of \c floats. - * - * The array contains the elements in the following order: m[0][0], - * m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2]. - * - * @return The \c float array. - */ - operator float*() { return &m[0][0]; } - - /** - * Get this FMMatrix as an array of \c floats. - * - * The array contains the elements in the following order: m[0][0], - * m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2]. - * - * @return The \c float array. - */ - operator const float*() const { return &m[0][0]; } - - /** - * Get a specified row of FMMatrix33 as an array of \c floats. - * - * @param a The row index, starting at 0, of the row to get. - * @return The \c float array of the elements in the specified row. - */ - float* operator[](int a) { return m[a]; } - - /** - * Assign this FMMatrix33's elements to be the same as that of the given - * FMMatrix33. - * - * @param copy The FMMatrix to copy elements from. - * @return This FMMatrix. - */ - FMMatrix33& operator=(const FMMatrix33& copy); - - /** - * Gets the transposed of this FMMatrix33. - * - * @return The transposed of this FMMatrix. - */ - FMMatrix33 Transposed() const; - - /** - * Gets the inversion of this FMMatrix33. - * - * @return The inversion of this FMMatrix. - */ - FMMatrix33 Inverted() const; - -public: - static FMMatrix33 identity; /**< The identity FMMatrix33. */ - - /** - * Gets the FMMatrix33 representation of a 2D counter-clockwise rotation - * about the z-axis. - * - * @param angle The angle of rotation in radians. - * @return The rotation FMMatrix. - */ - static FMMatrix33 RotationMatrix(float angle); - - /** - * Gets the FMMatrix33 representation of a 2D translation. - * - * @param tx The translation in the x direction. - * @param ty The translation in the y direction. - * @return The translation FMMatrix. - */ - static FMMatrix33 TranslationMatrix(float tx, float ty); - - /** - * Gets the FMMatrix33 representation of a 2D scale. - * - * @param sx The scale factor in the x direction. - * @param sy The scale factor in the y direction. - * @return The scale FMMatrix. - */ - static FMMatrix33 ScaleMatrix(float sx, float sy); - - /** - * Gets the FMMatrix33 representation of a 2D translation. - * - * The translation in the x direction is the \a u componenet of the given - * FMVector2 and the translation in the y direction is the \a v component. - * - * @param translation The FMVector2 to get the translation components from. - * @return The translation FMMatrix33. - */ - static inline FMMatrix33 TranslationMatrix(FMVector2 translation) { return TranslationMatrix(translation.u, translation.v); } - - /** - * Gets the FMMatrix33 representation of a 2D scale. - * - * The scale in the x direction is the \a u componenet of the given - * FMVector and the scale in the y direction is the \a v component. - * - * @param scale The FMVector2 to get the scale components from. - * @return The scale FMMatrix33. - */ - static inline FMMatrix33 ScaleMatrix(FMVector2 scale) { return ScaleMatrix(scale.u, scale.v); } -}; - -/** - * Matrix multiplication with two FMMatrix33. - * - * @param m1 The first matrix. - * @param m2 The second matrix. - * @return The FMMatrix44 representation of the resulting matrix. - */ -FMMatrix33 FCOLLADA_EXPORT operator*(const FMMatrix33& m1, const FMMatrix33& m2); - -#endif // _FM_MATRIX33_H_ diff --git a/Extras/FCollada/FMath/FMMatrix44.cpp b/Extras/FCollada/FMath/FMMatrix44.cpp deleted file mode 100644 index 98ae9beeb..000000000 --- a/Extras/FCollada/FMath/FMMatrix44.cpp +++ /dev/null @@ -1,251 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FMath/FMMatrix44.h" - -static float __identity[] = { 1, 0, 0, 0, 0, 1, 0 ,0 ,0, 0, 1, 0, 0, 0, 0, 1 }; -FMMatrix44 FMMatrix44::Identity(__identity); - -FMMatrix44::FMMatrix44(const float* _m) -{ - m[0][0] = _m[0]; m[1][0] = _m[1]; m[2][0] = _m[2]; m[3][0] = _m[3]; - m[0][1] = _m[4]; m[1][1] = _m[5]; m[2][1] = _m[6]; m[3][1] = _m[7]; - m[0][2] = _m[8]; m[1][2] = _m[9]; m[2][2] = _m[10]; m[3][2] = _m[11]; - m[0][3] = _m[12]; m[1][3] = _m[13]; m[2][3] = _m[14]; m[3][3] = _m[15]; -} - -FMMatrix44& FMMatrix44::operator=(const FMMatrix44& copy) -{ - m[0][0] = copy.m[0][0]; m[0][1] = copy.m[0][1]; m[0][2] = copy.m[0][2]; m[0][3] = copy.m[0][3]; - m[1][0] = copy.m[1][0]; m[1][1] = copy.m[1][1]; m[1][2] = copy.m[1][2]; m[1][3] = copy.m[1][3]; - m[2][0] = copy.m[2][0]; m[2][1] = copy.m[2][1]; m[2][2] = copy.m[2][2]; m[2][3] = copy.m[2][3]; - m[3][0] = copy.m[3][0]; m[3][1] = copy.m[3][1]; m[3][2] = copy.m[3][2]; m[3][3] = copy.m[3][3]; - return *this; -} - -// Returns the transpose of this matrix -FMMatrix44 FMMatrix44::Transposed() const -{ - FMMatrix44 mx; - mx.m[0][0] = m[0][0]; mx.m[1][0] = m[0][1]; mx.m[2][0] = m[0][2]; mx.m[3][0] = m[0][3]; - mx.m[0][1] = m[1][0]; mx.m[1][1] = m[1][1]; mx.m[2][1] = m[1][2]; mx.m[3][1] = m[1][3]; - mx.m[0][2] = m[2][0]; mx.m[1][2] = m[2][1]; mx.m[2][2] = m[2][2]; mx.m[3][2] = m[2][3]; - mx.m[0][3] = m[3][0]; mx.m[1][3] = m[3][1]; mx.m[2][3] = m[3][2]; mx.m[3][3] = m[3][3]; - return mx; -} - -FMVector3 FMMatrix44::TransformCoordinate(const FMVector3& coordinate) const -{ - FMVector3 out; - out.x = m[0][0] * coordinate.x + m[1][0] * coordinate.y + m[2][0] * coordinate.z + m[3][0]; - out.y = m[0][1] * coordinate.x + m[1][1] * coordinate.y + m[2][1] * coordinate.z + m[3][1]; - out.z = m[0][2] * coordinate.x + m[1][2] * coordinate.y + m[2][2] * coordinate.z + m[3][2]; - return out; -} - -FMVector3 FMMatrix44::TransformVector(const FMVector3& v) const -{ - FMVector3 out; - out.x = m[0][0] * v.x + m[1][0] * v.y + m[2][0] * v.z; - out.y = m[0][1] * v.x + m[1][1] * v.y + m[2][1] * v.z; - out.z = m[0][2] * v.x + m[1][2] * v.y + m[2][2] * v.z; - return out; -} - -FMVector3 FMMatrix44::GetTranslation() const -{ - return FMVector3(m[3][0], m[3][1], m[3][2]); -} - -static float det3x3(float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2, float c3); - -void FMMatrix44::Decompose(FMVector3& scale, FMVector3& rotation, FMVector3& translation, float& inverted) const -{ - // Assume Scale/Rotation/Translation, in this order. - scale.x = sqrtf(m[0][0] * m[0][0] + m[1][0] * m[1][0] + m[2][0] * m[2][0]); - scale.y = sqrtf(m[0][1] * m[0][1] + m[1][1] * m[1][1] + m[2][1] * m[2][1]); - scale.z = sqrtf(m[0][2] * m[0][2] + m[1][2] * m[1][2] + m[2][2] * m[2][2]); - - inverted = FMath::Sign(det3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2])); - - // Calculate the rotation in Y first, using m[0][2], checking for out-of-bounds values - float c; - if (m[0][2] / scale.x >= 1.0f - FLT_TOLERANCE) - { - rotation.y = ((float) FMath::Pi) / -2.0f; - c = 0.0f; - } - else if (m[0][2] / scale.x <= -1.0f + FLT_TOLERANCE) - { - rotation.y = ((float) FMath::Pi) / 2.0f; - c = 0.0f; - } - else - { - rotation.y = asinf(-m[0][2] / scale.x); - c = cosf(rotation.y); - } - - // Using the cosine of the Y rotation will give us the rotation in X and Z. - // Check for the infamous Gimbal Lock. - if (fabsf(c) > 0.01f) - { - float rx = m[2][2] / scale.z / c; - float ry = m[1][2] / scale.z / c; - rotation.x = atan2f(ry, rx); - rx = m[0][0] / scale.x / c; - ry = m[0][1] / scale.y / c; - rotation.z = atan2f(ry, rx); - } - else - { - rotation.z = 0; - float rx = m[1][1] / scale.y; - float ry = -m[1][0] / scale.y; - rotation.x = atan2f(ry, rx); - } - - translation = GetTranslation(); -} - -// Code taken and adapted from nVidia's nv_algebra: det2x2, det3x3, invert, multiply -// ----- -// Calculate the determinant of a 2x2 matrix -static float det2x2(float a1, float a2, float b1, float b2) -{ - return a1 * b2 - b1 * a2; -} - -// Calculate the determinent of a 3x3 matrix -static float det3x3(float a1, float a2, float a3, float b1, float b2, float b3, float c1, float c2, float c3) -{ - return a1 * det2x2(b2, b3, c2, c3) - b1 * det2x2(a2, a3, c2, c3) + c1 * det2x2(a2, a3, b2, b3); -} - -// Returns the inverse of this matrix -FMMatrix44 FMMatrix44::Inverted() const -{ - FMMatrix44 b; - - b.m[0][0] = det3x3(m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]); - b.m[0][1] = -det3x3(m[0][1], m[0][2], m[0][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]); - b.m[0][2] = det3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[3][1], m[3][2], m[3][3]); - b.m[0][3] = -det3x3(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3]); - - b.m[1][0] = -det3x3(m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]); - b.m[1][1] = det3x3(m[0][0], m[0][2], m[0][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]); - b.m[1][2] = -det3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[3][0], m[3][2], m[3][3]); - b.m[1][3] = det3x3(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3]); - - b.m[2][0] = det3x3(m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], m[3][3]); - b.m[2][1] = -det3x3(m[0][0], m[0][1], m[0][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], m[3][3]); - b.m[2][2] = det3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[3][0], m[3][1], m[3][3]); - b.m[2][3] = -det3x3(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3]); - - b.m[3][0] = -det3x3(m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]); - b.m[3][1] = det3x3(m[0][0], m[0][1], m[0][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]); - b.m[3][2] = -det3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[3][0], m[3][1], m[3][2]); - b.m[3][3] = det3x3(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2]); - - float det = (m[0][0] * b.m[0][0]) + (m[1][0] * b.m[0][1]) + (m[2][0] * b.m[0][2]) + (m[3][0] * b.m[0][3]); - - if (IsEquivalent(det, 0.0f)) det = 0.01f; - float oodet = 1.0f / det; - - b.m[0][0] *= oodet; - b.m[0][1] *= oodet; - b.m[0][2] *= oodet; - b.m[0][3] *= oodet; - - b.m[1][0] *= oodet; - b.m[1][1] *= oodet; - b.m[1][2] *= oodet; - b.m[1][3] *= oodet; - - b.m[2][0] *= oodet; - b.m[2][1] *= oodet; - b.m[2][2] *= oodet; - b.m[2][3] *= oodet; - - b.m[3][0] *= oodet; - b.m[3][1] *= oodet; - b.m[3][2] *= oodet; - b.m[3][3] *= oodet; - - return b; -} - -FMMatrix44 operator*(const FMMatrix44& m1, const FMMatrix44& m2) -{ - FMMatrix44 mx; - mx.m[0][0] = m1.m[0][0] * m2.m[0][0] + m1.m[1][0] * m2.m[0][1] + m1.m[2][0] * m2.m[0][2] + m1.m[3][0] * m2.m[0][3]; - mx.m[0][1] = m1.m[0][1] * m2.m[0][0] + m1.m[1][1] * m2.m[0][1] + m1.m[2][1] * m2.m[0][2] + m1.m[3][1] * m2.m[0][3]; - mx.m[0][2] = m1.m[0][2] * m2.m[0][0] + m1.m[1][2] * m2.m[0][1] + m1.m[2][2] * m2.m[0][2] + m1.m[3][2] * m2.m[0][3]; - mx.m[0][3] = m1.m[0][3] * m2.m[0][0] + m1.m[1][3] * m2.m[0][1] + m1.m[2][3] * m2.m[0][2] + m1.m[3][3] * m2.m[0][3]; - mx.m[1][0] = m1.m[0][0] * m2.m[1][0] + m1.m[1][0] * m2.m[1][1] + m1.m[2][0] * m2.m[1][2] + m1.m[3][0] * m2.m[1][3]; - mx.m[1][1] = m1.m[0][1] * m2.m[1][0] + m1.m[1][1] * m2.m[1][1] + m1.m[2][1] * m2.m[1][2] + m1.m[3][1] * m2.m[1][3]; - mx.m[1][2] = m1.m[0][2] * m2.m[1][0] + m1.m[1][2] * m2.m[1][1] + m1.m[2][2] * m2.m[1][2] + m1.m[3][2] * m2.m[1][3]; - mx.m[1][3] = m1.m[0][3] * m2.m[1][0] + m1.m[1][3] * m2.m[1][1] + m1.m[2][3] * m2.m[1][2] + m1.m[3][3] * m2.m[1][3]; - mx.m[2][0] = m1.m[0][0] * m2.m[2][0] + m1.m[1][0] * m2.m[2][1] + m1.m[2][0] * m2.m[2][2] + m1.m[3][0] * m2.m[2][3]; - mx.m[2][1] = m1.m[0][1] * m2.m[2][0] + m1.m[1][1] * m2.m[2][1] + m1.m[2][1] * m2.m[2][2] + m1.m[3][1] * m2.m[2][3]; - mx.m[2][2] = m1.m[0][2] * m2.m[2][0] + m1.m[1][2] * m2.m[2][1] + m1.m[2][2] * m2.m[2][2] + m1.m[3][2] * m2.m[2][3]; - mx.m[2][3] = m1.m[0][3] * m2.m[2][0] + m1.m[1][3] * m2.m[2][1] + m1.m[2][3] * m2.m[2][2] + m1.m[3][3] * m2.m[2][3]; - mx.m[3][0] = m1.m[0][0] * m2.m[3][0] + m1.m[1][0] * m2.m[3][1] + m1.m[2][0] * m2.m[3][2] + m1.m[3][0] * m2.m[3][3]; - mx.m[3][1] = m1.m[0][1] * m2.m[3][0] + m1.m[1][1] * m2.m[3][1] + m1.m[2][1] * m2.m[3][2] + m1.m[3][1] * m2.m[3][3]; - mx.m[3][2] = m1.m[0][2] * m2.m[3][0] + m1.m[1][2] * m2.m[3][1] + m1.m[2][2] * m2.m[3][2] + m1.m[3][2] * m2.m[3][3]; - mx.m[3][3] = m1.m[0][3] * m2.m[3][0] + m1.m[1][3] * m2.m[3][1] + m1.m[2][3] * m2.m[3][2] + m1.m[3][3] * m2.m[3][3]; - return mx; -} - -FMMatrix44 FMMatrix44::TranslationMatrix(const FMVector3& translation) -{ - FMMatrix44 matrix; - matrix[0][0] = 1.0f; matrix[0][1] = 0.0f; matrix[0][2] = 0.0f; matrix[0][3] = 0.0f; - matrix[1][0] = 0.0f; matrix[1][1] = 1.0f; matrix[1][2] = 0.0f; matrix[1][3] = 0.0f; - matrix[2][0] = 0.0f; matrix[2][1] = 0.0f; matrix[2][2] = 1.0f; matrix[2][3] = 0.0f; - matrix[3][0] = translation.x; matrix[3][1] = translation.y; matrix[3][2] = translation.z; matrix[3][3] = 1.0f; - return matrix; -} - -FMMatrix44 FMMatrix44::AxisRotationMatrix(const FMVector3& axis, float angle) -{ - // Formulae comes from http://www.mines.edu/~gmurray/ArbitraryAxisRotation/ArbitraryAxisRotation.html - FMMatrix44 matrix; - FMVector3 a = (IsEquivalent(axis.LengthSquared(), 1.0f)) ? axis : axis.Normalize(); - float xSq = a.x * a.x; - float ySq = a.y * a.y; - float zSq = a.z * a.z; - float cT = cosf(angle); - float sT = sinf(angle); - - matrix[0][0] = xSq + (ySq + zSq) * cT; - matrix[0][1] = a.x * a.y * (1.0f - cT) + a.z * sT; - matrix[0][2] = a.x * a.z * (1.0f - cT) - a.y * sT; - matrix[0][3] = 0; - matrix[1][0] = a.x * a.y * (1.0f - cT) - a.z * sT; - matrix[1][1] = ySq + (xSq + zSq) * cT; - matrix[1][2] = a.y * a.z * (1.0f - cT) + a.x * sT; - matrix[1][3] = 0; - matrix[2][0] = a.x * a.z * (1.0f - cT) + a.y * sT; - matrix[2][1] = a.y * a.z * (1.0f - cT) - a.x * sT; - matrix[2][2] = zSq + (xSq + ySq) * cT; - matrix[2][3] = 0; - matrix[3][2] = matrix[3][1] = matrix[3][0] = 0; - matrix[3][3] = 1; - return matrix; -} - -bool IsEquivalent(const FMMatrix44& m1, const FMMatrix44& m2) -{ - return IsEquivalent(m1.m[0][0], m2.m[0][0]) && IsEquivalent(m1.m[1][0], m2.m[1][0]) - && IsEquivalent(m1.m[2][0], m2.m[2][0]) && IsEquivalent(m1.m[3][0], m2.m[3][0]) - && IsEquivalent(m1.m[0][1], m2.m[0][1]) && IsEquivalent(m1.m[1][1], m2.m[1][1]) - && IsEquivalent(m1.m[2][1], m2.m[2][1]) && IsEquivalent(m1.m[3][1], m2.m[3][1]) - && IsEquivalent(m1.m[0][2], m2.m[0][2]) && IsEquivalent(m1.m[1][2], m2.m[1][2]) - && IsEquivalent(m1.m[2][2], m2.m[2][2]) && IsEquivalent(m1.m[3][2], m2.m[3][2]) - && IsEquivalent(m1.m[0][3], m2.m[0][3]) && IsEquivalent(m1.m[1][3], m2.m[1][3]) - && IsEquivalent(m1.m[2][3], m2.m[2][3]) && IsEquivalent(m1.m[3][3], m2.m[3][3]); -} diff --git a/Extras/FCollada/FMath/FMMatrix44.h b/Extras/FCollada/FMath/FMMatrix44.h deleted file mode 100644 index fdf5defb2..000000000 --- a/Extras/FCollada/FMath/FMMatrix44.h +++ /dev/null @@ -1,195 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FMMatrix44.h - The file containing the class and global functions for 4x4 matrices. -*/ - -#ifndef _FM_MATRIX44_H_ -#define _FM_MATRIX44_H_ - -/** - A 4x4 matrix: use to represent 3D transformations. - - @ingroup FMath -*/ -class FCOLLADA_EXPORT FMMatrix44 -{ -public: - float m[4][4]; /**< The matrix elements stored in a 2D array. */ - - /** - * Creates a FMMatrix44 from the \c float array. - * - * The float array stores the elements in the following order: m[0][0], - * m[1][0], m[2][0], m[3][0], m[0][1], m[1][1], m[2][1], m[3][1], m[0][2], - * m[1][2], m[2][2], m[3][2], m[0][3], m[1][3], m[2][3], m[3][3]. - * - * @param _m The \c float array to create the matrix from. - */ - FMMatrix44(const float* _m); - - /** - * Creates an empty FMMatrix44. - * - * The default values are non deterministic. - */ - #ifndef _DEBUG - FMMatrix44() {} - #else - FMMatrix44() { memset(m, 55, 16 * sizeof(float)); } - #endif - - /** - * Get this FMMatrix44 as an array of \c floats. - * - * The array contains the elements in the following order: m[0][0], - * m[0][1], m[0][2], m[0][3], m[1][0], m[1][1], m[1][2], m[1][3], m[2][0], - * m[2][1], m[2][2], m[0][3], m[3][0], m[3][1], m[3][2], m[3][3]. - * - * @return The \c float array. - */ - operator float*() { return &m[0][0]; } - - /** - * Get this FMMatrix44 as an array of \c floats. - * - * The array contains the elements in the following order: m[0][0], - * m[0][1], m[0][2], m[0][3], m[1][0], m[1][1], m[1][2], m[1][3], m[2][0], - * m[2][1], m[2][2], m[0][3], m[3][0], m[3][1], m[3][2], m[3][3]. - * - * @return The \c float array. - */ - operator const float*() const { return &m[0][0]; } - - /** - * Get a specified row of FMMatrix44 as an array of \c floats. - * - * @param a The row index, starting at 0, of the row to get. - * @return The \c float array of the elements in the specified row. - */ - float* operator[](int a) { return m[a]; } - - /** - * Get a specified row of FMMatrix44 as an array of \c floats. - * - * @param a The row index, starting at 0, of the row to get. - * @return The \c float array of the elements in the specified row. - */ - const float* operator[](int a) const { return m[a]; } - - /** - * Assign this FMMatrix44's elements to be the same as that of the given - * FMMatrix44. - * - * @param copy The FMMatrix to copy elements from. - * @return This FMMatrix. - */ - FMMatrix44& operator=(const FMMatrix44& copy); - - /** - * Gets the transposed of this FMMatrix44. - * - * @return The transposed of this FMMatrix. - */ - FMMatrix44 Transposed() const; - - /** - * Gets the inversion of this FMMatrix33. - * - * @return The inversion of this FMMatrix. - */ - FMMatrix44 Inverted() const; - - /** - * Decompose this FMMatrix44 into it's scale, rotation, and translation - * components; it also tells whether it is inverted. - * - * @param Scale The FMVector to place the scale components to. - * @param Rotation The FMVector to place the rotation components to. - * @param Translation The FMVector to place the translation components to. - * @param inverted The value corresponding to if it was inverted (-1.0f or - * 1.0f) - */ - void Decompose(FMVector3& Scale, FMVector3& Rotation, FMVector3& Translation, float& inverted) const; - - /** - * Transforms the given point by this FMMatrix44. - * - * @param coordinate The point to transform. - * @return The FMVector3 representation of the transformed point. - */ - FMVector3 TransformCoordinate(const FMVector3& coordinate) const; - - /** - * Transforms the given vector by this FMMatrix44. - * - * @param v The vector to transform. - * @return The FMVector3 representation of the transformed vector. - */ - FMVector3 TransformVector(const FMVector3& v) const; - - /** - * Gets the translation component of this FMMatrix44. - * - * @return The FMVector3 representation of the translation. - */ - FMVector3 GetTranslation() const; - -public: - static FMMatrix44 Identity; /**< The identity FMMatrix44. */ - - /** - * Gets the FMMatrix44 representation of a 3D translation. - * - * The translation in the x, y and z directions correspond to the \a x, - * \a y, and \a z components of the FMVector3. - * - * @param translation The FMVector3 to get the translation components from. - * @return The translation FMMatrix44. - */ - static FMMatrix44 TranslationMatrix(const FMVector3& translation); - - /** - * Gets the FMMatrix44 representation of a 3D rotation about a given axis - * by an angle. - * - * @param axis The axis of rotation. - * @param angle The angle of rotation in radians. - * @return The rotation FMMatrix44. - */ - static FMMatrix44 AxisRotationMatrix(const FMVector3& axis, float angle); -}; - -/** - * Matrix multiplication with two FMMatrix44. - * - * @param m1 The first matrix. - * @param m2 The second matrix. - * @return The FMMatrix44 representation of the resulting matrix. - */ -FMMatrix44 FCOLLADA_EXPORT operator*(const FMMatrix44& m1, const FMMatrix44& m2); - -/** - Matrix equality comparison function. - @param m1 The first matrix. - @param m2 The second matrix. - @return Whether the given matrices are equal. -*/ -bool IsEquivalent(const FMMatrix44& m1, const FMMatrix44& m2); - -/** - Matrix equality operator override. - @param m1 The first matrix. - @param m2 The second matrix. - @return Whether the given matrices are equal. -*/ -inline bool operator==(const FMMatrix44& m1, const FMMatrix44& m2) { return IsEquivalent(m1, m2); } - -/** A dynamically-sized array of 4x4 matrices. */ -typedef vector FMMatrix44List; - -#endif // _FM_MATRIX44_H_ diff --git a/Extras/FCollada/FMath/FMQuaternion.cpp b/Extras/FCollada/FMath/FMQuaternion.cpp deleted file mode 100644 index 9348aa6f9..000000000 --- a/Extras/FCollada/FMath/FMQuaternion.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FMath/FMath.h" -#include "FMath/FMVector3.h" -#include "FMath/FMQuaternion.h" - -// [Glaforte 03-08-2006] VERY EXPERIMENTAL CODE: DON'T USE. - -FMQuaternion::FMQuaternion(const FMVector3& axis, float angle) -{ - float s = sinf(angle / 2.0f); - x = axis.x * s; - y = axis.y * s; - z = axis.z * s; - w = cosf(angle / 2.0f); -} - -FMQuaternion FMQuaternion::operator*(const FMQuaternion& q) const -{ - FMQuaternion r; - r.w = w * q.w - x * q.x - y * q.y - z * q.z; - r.x = w * q.x + x * q.w + y * q.z - z * q.y; - r.y = w * q.y + y * q.w + z * q.x - x * q.z; - r.z = w * q.z + z * q.w + x * q.y - y * q.x; - return r; -} - -FMQuaternion FMQuaternion::EulerRotationQuaternion(float x, float y, float z) -{ - FMQuaternion qx(FMVector3::XAxis, x); - FMQuaternion qy(FMVector3::YAxis, y); - FMQuaternion qz(FMVector3::ZAxis, z); - return qx * qy * qz; -} diff --git a/Extras/FCollada/FMath/FMQuaternion.h b/Extras/FCollada/FMath/FMQuaternion.h deleted file mode 100644 index 224e431d7..000000000 --- a/Extras/FCollada/FMath/FMQuaternion.h +++ /dev/null @@ -1,105 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FMQuaternion.h - The file containing the class for quaternions. -*/ - -#ifndef _FM_QUATERNION_H_ -#define _FM_QUATERNION_H_ - -/** - A quaternion. - Not used within FCollada - - [Glaforte 03-08-2006] VERY EXPERIMENTAL CODE: DON'T USE. - - @ingroup FMath -*/ -class FCOLLADA_EXPORT FMQuaternion -{ -public: - float x; /**< The i component. */ - float y; /**< The j component. */ - float z; /**< The k component. */ - float w; /**< The scalar component. */ - - #ifndef _DEBUG - /** - * Creates an empty FMQuaternion. - * - * The default values are non deterministic. - */ - FMQuaternion() {} - #else - FMQuaternion() { x = 123456789.0f; y = 123456789.0f; z = 123456789.0f; w = 123456789.0f; } - #endif - - /** - * Creates the FMQuaternion with the given component values. - * - * @param _x The i component. - * @param _y The j component. - * @param _z The k component. - * @param _w The scalar component. - */ - FMQuaternion(float _x, float _y, float _z, float _w) { x = _x; y = _y; z = _z; w = _w; } - - /** - * Creates the FMQuaternion from a given axis and angle of rotation. - * - * @param axis The axis of rotation. - * @param angle The angle of rotation in radians. - */ - FMQuaternion(const FMVector3& axis, float angle); - - /** - * Get this FMQuaternion as an array of \c floats. - * - * @return The \c float array. - */ - inline operator float*() { return &x; } - - /** - * Get this FMQuaternion as an array of \c floats. - * - * @return The \c float array. - */ - inline operator const float*() const { return &x; } - - /** - * Assign this FMQuaternion to the given \c float array. - * - * Assigns each coordinate of this FMQuaternion to the elements in the - * \c float array. The first element to the i component, the second to the - * j, the third to the k, and the forth to the scalar. It returns this - * FMQuaternion. - * - * @param v The \c float array to assign with. - * @return This FMQuaternion. - */ - inline FMQuaternion& operator =(const float* v) { x = *v; y = *(v + 1); z = *(v + 2); w = *(v + 3); return *this; } - - /** - * Applys quaternion multiplication of the given FMQuaternion with this - * FMQuaternion and returns the value. - * - * @param q The FMQuaternion multiply with. - * @return The resulting FMQuaternion. - */ - FMQuaternion operator*(const FMQuaternion& q) const; - - /** - * Get the FMQuaternion representation of the Euler rotation angles. - * - * @param _x The rotation about the x-axis (roll), in radians. - * @param _y The rotation about the y-axis (pitch), in radians. - * @param _z The rotation about the z-axis (yaw), in radians. - */ - static FMQuaternion EulerRotationQuaternion(float _x, float _y, float _z); -}; - -#endif // _FM_QUATERNION_H_ diff --git a/Extras/FCollada/FMath/FMVector2.h b/Extras/FCollada/FMath/FMVector2.h deleted file mode 100644 index 59e44c64d..000000000 --- a/Extras/FCollada/FMath/FMVector2.h +++ /dev/null @@ -1,132 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FMVector2.h - The file containing the class and global functions for 2 dimensional - vectors. -*/ - -#ifndef _FM_VECTOR2_H_ -#define _FM_VECTOR2_H_ - -/** - A 2 dimensional vector. - Not used within FCollada. - - @ingroup FMath -*/ -class FCOLLADA_EXPORT FMVector2 -{ -public: - float u; /**< The first coordinate. */ - float v; /**< The second coordinate. */ - -public: - /** - * Creates an empty FMVector2. - */ - #ifndef _DEBUG - FMVector2() {} - #else - FMVector2() { u = 123456789.0f; v = 123456789.0f; } - #endif - - /** - * Creates the FMVector2 with the coordinates given. - * - * @param _u The first coordinate. - * @param _v The second coordinate. - */ - FMVector2(float _u, float _v) { u = _u; v = _v; } - - /** - * Get this FMVector2 as an array of \c floats. - * - * @return The \c float array. - */ - inline operator float*() { return &u; } - - /** - * Adds two FMVector2. - * - * Adds to this FMVector2's coordinates the individual components of the - * given FMVector2 and returns this FMVector2. - * - * @param a The FMVector2 to add with this one. - * @return This FMVector2. - */ - inline FMVector2& operator +=(const FMVector2& a) { u += a.u; v += a.v; return *this; } - - /** - * Multiplies this FMVector2 by a scaler. - * - * Multiplies each of this FMVector2's coordinates with the scaler and - * returns this FMVector2. - * - * @param a The scalar to multiply with. - * @return This FMVector2. - */ - inline FMVector2& operator *=(float a) { u *= a; v *= a; return *this; } - - /** - * Assign this FMVector2 to the given float array. - * - * Assigns each coordinate of this FMVector2 to the elements in the \c - * float array. The first element to the first coordinate and the second to - * the second. It returns this FMVector2. - * - * @param f The \c float array to assign with. - * @return This FMVector2. - */ - inline FMVector2& operator =(const float* f) { u = *f; v = *(f + 1); return *this; } -}; - -/** - * Vector addition with two FMVector2. - * - * @param a The first vector. - * @param b The second vector. - * @return The FMVector2 representation of the resulting vector. - */ -inline FMVector2 operator + (const FMVector2& a, const FMVector2& b) { return FMVector2(a.u + b.u, a.v + b.v); } - -/** - * Vector subtraction with two FMVector2. - * - * @param a The first vector. - * @param b The second vector. - * @return The FMVector2 representation of the resulting vector. - */ -inline FMVector2 operator -(const FMVector2& a, const FMVector2& b) { return FMVector2(a.u - b.u, a.v - b.v); } - -/** - * Dot product of two FMVector2. - * - * @param a The first vector. - * @param b The second vector. - * @return The result of the dot product. - */ -inline float operator *(const FMVector2& a, const FMVector2& b) { return a.u * b.u + a.v * b.v; } - -/** - * Scalar multiplication with a FMVector2. - * - * @param a The vector. - * @param b The scalar. - * @return The FMVector2 representing the resulting the vector. - */ -inline FMVector2 operator *(const FMVector2& a, float b) { return FMVector2(a.u * b, a.v * b); } - -/** - * Scalar multiplication with a FMVector2. - * - * @param a The scalar. - * @param b The vector. - * @return The FMVector2 representing the resulting the vector. - */ -inline FMVector2 operator *(float a, const FMVector2& b) { return FMVector2(a * b.u, a * b.v); } - -#endif // _FM_VECTOR2_H_ diff --git a/Extras/FCollada/FMath/FMVector3.cpp b/Extras/FCollada/FMath/FMVector3.cpp deleted file mode 100644 index 45c91b1d3..000000000 --- a/Extras/FCollada/FMath/FMVector3.cpp +++ /dev/null @@ -1,25 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FMath/FMVector2.h" -#include "FMath/FMVector3.h" -#include "FMath/FMVector4.h" - -// Vector constants -const FMVector3 FMVector3::Zero(0.0f, 0.0f, 0.0f); -const FMVector3 FMVector3::XAxis(1.0f, 0.0f, 0.0f); -const FMVector3 FMVector3::YAxis(0.0f, 1.0f, 0.0f); -const FMVector3 FMVector3::ZAxis(0.0f, 0.0f, 1.0f); -const FMVector3 FMVector3::Origin = FMVector3::Zero; -const FMVector4 FMVector4::Zero(0.0f, 0.0f, 0.0f, 0.0f); - -// Read in the vector from a source -FMVector3::FMVector3(const float* source, uint32 startIndex) -{ - x = source[startIndex]; - y = source[startIndex + 1]; - z = source[startIndex + 2]; -} diff --git a/Extras/FCollada/FMath/FMVector3.h b/Extras/FCollada/FMath/FMVector3.h deleted file mode 100644 index 6f6ed8291..000000000 --- a/Extras/FCollada/FMath/FMVector3.h +++ /dev/null @@ -1,299 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FMVector3.h The file containing the class and global functions for 3 dimensional vectors. -*/ - -#ifndef _FM_VECTOR3_H_ -#define _FM_VECTOR3_H_ - -/** - A 3 dimensional vector. - - Simple, non-optimized vector class: * is the dot-product, ^ is the - cross-product. - - @ingroup FMath -*/ -class FCOLLADA_EXPORT FMVector3 -{ -public: - float x; /**< The first coordinate. */ - float y; /**< The second coordinate. */ - float z; /**< The third coordinate. */ - -public: - /** - * Creates an empty FMVector3. - */ - #ifndef _DEBUG - FMVector3() {} - #else - FMVector3() { x = 123456789.0f; y = 123456789.0f; z = 123456789.0f; } - #endif - - /** - * Creates the FMVector3 with the coordinates given. - * - * @param _x The first coordinate. - * @param _y The second coordinate. - * @param _z The third coordinate. - */ - FMVector3(float _x, float _y, float _z) { x = _x; y = _y; z = _z; } - - /** - * Creates the FMVector3 from a list of \c floats. - * - * It takes the first 3 \c floats starting from and including \a startIndex - * (0 indexing) in the array as the 3 coordinates. The first as the first - * coordinate, the second as the second, and the third as the third. - * - * @param source The \c float array. - * @param startIndex The index of the first element. - */ - FMVector3(const float* source, uint32 startIndex = 0); - - /** - * Get the squared length. - * - * @return The squared length of this FMVector3. - */ - inline float LengthSquared() const { return x * x + y * y + z * z; } - - /** - * Retrieves the length of the vector. - * - * @return The length of this FMVector3. - */ - inline float Length() const { return sqrtf(x * x + y * y + z * z); } - - /** - * Normalize this FMVector3. - */ - inline void NormalizeIt() { float l = Length(); if (!IsEquivalent(l, 0.0f)) { x /= l; y /= l; z /= l; }} - - /** - * Get a normalized FMVector3 with the same direction as this FMVector3. - * - * @return A FMVector3 with length 1 and same direction as this FMVector3. - */ - inline FMVector3 Normalize() const { float l = Length(); return FMVector3(x / l, y / l, z / l); } - - /** - * Project this FMVector3 onto another FMVector3. - * - * @param unto The FMVector3 to project onto. - */ - inline void Project(const FMVector3& unto) { (*this) = Projected(unto); } - - /** - * Get the projection of this FMVector3 onto another FMVector3. - * - * @param unto The FMVector3 to project onto. - * @return The projected FMVector3. - */ - inline FMVector3 Projected(const FMVector3& unto); - - /** - * Get this FMVector3 as an array of \c floats. - * - * @return The \c float array. - */ - inline operator float*() { return &x; } - - /** - * Get this FMVector3 as an array of \c floats. - * - * @return The \c float array. - */ - inline operator const float*() const { return &x; } - - /** - * Assign this FMVector3 to the given float array. - * - * Assigns each coordinate of this FMVector3 to the elements in the \c - * float array. The first element to the first coordinate, the second to - * the second, and the third to the third. It returns this FMVector3. - * - * @param v The \c float array to assign with. - * @return This FMVector3. - */ - inline FMVector3& operator =(const float* v) { x = *v; y = *(v + 1); z = *(v + 2); return *this; } - - /** - * Update each component of this FMVector to the minimum of two FMVector3s. - * - * Updates each of the three components to be the minimum of the current - * value and that of the corresponding value of the given FMVector3. - * - * @param min The FMVector to take values from. - */ - inline void ComponentMinimum(const FMVector3& min) { if (x < min.x) x = min.x; if (y < min.y) y = min.y; if (z < min.z) z = min.z; } - - /** - * Update each component of this FMVector to the maximum of two FMVector3s. - * - * Updates each of the three components to be the maximum of the current - * value and that of the corresponding value of the given FMVector3. - * - * @param max The FMVector to take values from. - */ - inline void ComponentMaximum(const FMVector3& max) { if (x > max.x) x = max.x; if (y > max.y) y = max.y; if (z > max.z) z = max.z; } - - /** - * Clamp each component of this FMVector by the corresponding components - * in the specified min and max FMVector3. - * - * Clamp refers to setting a value within a given range. If the value is - * lower than the minimum of the range, it is set to the minimum; same for - * the maximum. - * - * @param min The FMVector to take the minimum values from. - * @param max The FMVector to take the maximum values from. - */ - inline void ComponentClamp(const FMVector3& min, const FMVector3& max) { ComponentMinimum(min); ComponentMaximum(max); } - -public: - static const FMVector3 XAxis; /**< The FMVector3 representing the x axis */ - static const FMVector3 YAxis; /**< The FMVector3 representing the y axis */ - static const FMVector3 ZAxis; /**< The FMVector3 representing the z axis */ - static const FMVector3 Zero; /**< The FMVector3 representing zero */ - static const FMVector3 Origin;/**< The FMVector3 representing the origin */ -}; - -/** - * Vector addition with two FMVector3. - * - * @param a The first vector. - * @param b The second vector. - * @return The FMVector3 representation of the resulting vector. - */ -inline FMVector3 operator +(const FMVector3& a, const FMVector3& b) { return FMVector3(a.x + b.x, a.y + b.y, a.z + b.z); } - -/** - * Vector subtraction with two FMVector3. - * - * @param a The first vector. - * @param b The second vector. - * @return The FMVector3 representation of the resulting vector. - */ -inline FMVector3 operator -(const FMVector3& a, const FMVector3& b) { return FMVector3(a.x - b.x, a.y - b.y, a.z - b.z); } - -/** - * Positive operator of the given FMVector3. - * - * It applies the positive operator to each of the components of the FMVector3. - * - * @param a The vector to apply the positive operator to. - * @return The FMVector3 representation of the resulting vector. - */ -inline FMVector3 operator +(const FMVector3& a) { return FMVector3(+a.x, +a.y, +a.z); } - -/** - * Negates the given FMVector3. - * - * It negates each of the components of the FMVector3. - * - * @param a The vector to negate. - * @return The FMVector3 representation of the resulting vector. - */ -inline FMVector3 operator -(const FMVector3& a) { return FMVector3(-a.x, -a.y, -a.z); } - -/** - * Dot product of two FMVector3. - * - * @param a The first vector. - * @param b The second vector. - * @return The result of the dot product. - */ -inline float operator *(const FMVector3& a, const FMVector3& b) { return a.x * b.x + a.y * b.y + a.z * b.z; } - -/** - * Scalar multiplication with a FMVector3. - * - * @param a The vector. - * @param b The scalar. - * @return The FMVector3 representing the resulting vector. - */ -inline FMVector3 operator *(const FMVector3& a, float b) { return FMVector3(a.x * b, a.y * b, a.z * b); } - -/** - * Scalar multiplication with a FMVector3. - * - * @param a The scalar. - * @param b The vector. - * @return The FMVector3 representing the resulting vector. - */ -inline FMVector3 operator *(float a, const FMVector3& b) { return FMVector3(a * b.x, a * b.y, a * b.z); } - -/** - * Cross product of two FMVector3. - * - * @param a The first vector. - * @param b The second vector. - * @return The result of the dot product. - */ -inline FMVector3 operator ^(const FMVector3& a, const FMVector3& b) { return FMVector3(a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x); } - -/** - * Assignment of the addition of two FMVector3. - * - * @param b The first vector, which will also be assigned to the result. - * @param a The second vector. - * @return The first vector, after it has been assigned new values. - */ -inline FMVector3& operator +=(FMVector3& b, const FMVector3& a) { b.x += a.x; b.y += a.y; b.z += a.z; return b; } - -/** - * Assignment of the subtraction of two FMVector3. - * - * @param b The first vector, which will also be assigned to the result. - * @param a The second vector. - * @return The first vector, after it has been assigned new values. - */ -inline FMVector3& operator -=(FMVector3& b, const FMVector3& a) { b.x -= a.x; b.y -= a.y; b.z -= a.z; return b; } - -/** - * Assignment of the scalar multiplication of a FMVector3. - * - * @param b The vector, which will also be assigned to the result. - * @param a The scalar. - * @return The vector, after it has been assigned new values. - */ -inline FMVector3& operator *=(FMVector3& b, float a) { b.x *= a; b.y *= a; b.z *= a; return b; } - -/** - * Assignment of the scalar division of a FMVector3. - * - * @param b The vector, which will also be assigned to the result. - * @param a The scalar. - * @return The vector, after it has been assigned new values. - */ -inline FMVector3& operator /=(FMVector3& b, float a) { b.x /= a; b.y /= a; b.z /= a; return b; } - -/** - Returns whether two 3D vectors or points are equivalent. - @param p A first vector. - @param q A second vector. - @return Whether the vectors are equivalent. -*/ -inline bool IsEquivalent(const FMVector3& p, const FMVector3& q) { return IsEquivalent(p.x, q.x) && IsEquivalent(p.y, q.y) && IsEquivalent(p.z, q.z); } - -/** - Check if two FMVector3 are equivalent (they have relatively the same component values). - @param a The first vector. - @param b The second vector. - @return Whether the vectors are equivalent. -*/ -inline bool operator == (const FMVector3& a, const FMVector3& b) { return IsEquivalent(a, b); } - -// Already documented above. -inline FMVector3 FMVector3::Projected(const FMVector3& unto) { return ((*this) * unto) / unto.LengthSquared() * unto; } - -/** A dynamically-sized array of 3D vectors or points. */ -typedef vector FMVector3List; - -#endif // _FM_VECTOR3_H_ diff --git a/Extras/FCollada/FMath/FMVector4.h b/Extras/FCollada/FMath/FMVector4.h deleted file mode 100644 index a626a5d3d..000000000 --- a/Extras/FCollada/FMath/FMVector4.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FMVector4.h - This file contains the class for 4 dimensional vectors. -*/ - -#ifndef _FM_VECTOR4_H_ -#define _FM_VECTOR4_H_ - -/** - A 4 dimensional vector. - Not used within FCollada. - - @ingroup FMath -*/ -class FCOLLADA_EXPORT FMVector4 -{ -public: - float x; /**< The first coordinate. */ - float y; /**< The second coordinate. */ - float z; /**< The third coordinate. */ - float w; /**< The forth coordinate. */ - - /** - * Creates an empty FMVector4. - */ - #ifndef _DEBUG - FMVector4() {} - #else - FMVector4() { x = 123456789.0f; y = 123456789.0f; z = 123456789.0f; w = 123456789.0f; } - #endif - - /** - * Creates the FMVector4 with the coordinates given. - * - * The first three coordinates are taken from the FMVector3, where the - * first one is the x value, the second is that y, and the third is the z. - * The forth value is the \c float specified. - * - * - * @param v The FMVector3 representing the first three coordinates. - * @param _w The final coordinate. - */ - FMVector4(FMVector3 v, float _w) { x = v.x; y = v.y; z = v.z; w = _w; } - - /** - * Creates the FMVector4 with the coordinates given. - * - * @param _x The first coordinate. - * @param _y The second coordinate. - * @param _z The third coordinate. - * @param _w The forth coordinate. - */ - FMVector4(float _x, float _y, float _z, float _w) { x = _x; y = _y; z = _z; w = _w; } - -public: - /** - * Get this FMVector4 as an array of \c floats. - * - * @return The \c float array. - */ - inline operator float*() { return &x; } - - /** - * Get this FMVector4 as an array of \c floats. - * - * @return The \c float array. - */ - inline operator const float*() const { return &x; } - -public: - static const FMVector4 Zero; /**< The FMVector4 representing zero */ -}; - -#endif // _FM_VECTOR4_H_ diff --git a/Extras/FCollada/FMath/FMath.h b/Extras/FCollada/FMath/FMath.h deleted file mode 100644 index c760c9906..000000000 --- a/Extras/FCollada/FMath/FMath.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FMath.h - The file containing functions and constants for math. - - @defgroup FMath Mathematics Classes. -*/ - -#ifndef _F_MATH_H_ -#define _F_MATH_H_ - -#include -#include - -// Includes the improved vector class. -#include "FMath/FMArray.h" - -// Includes the common integer and floating-point definitions and functions. -#include "FMath/FMFloat.h" -#include "FMath/FMInteger.h" - -/** - A namespace for common math functions. - - @ingroup FMath -*/ -namespace FMath -{ - const double Pi = 3.14159; /**< Mathematical value of pi to 5 decimals. */ - - /** - * Convert radians to degrees. - * - * @param val The value in radians. - * @return The value in degrees. - */ - inline double RadToDeg(double val) { return (val * 180.0/Pi); } - - /** - * Convert radians to degrees. - * - * @param val The value in radians. - * @return The value in degrees. - */ - inline float RadToDeg(float val) { return (val * 180.0f/(float)Pi); } - - /** - * Convert degrees to radians. - * - * @param val The value in degrees. - * @return The value in radians. - */ - inline double DegToRad(double val) { return (val * Pi/180.0); } - - /** - * Convert degrees to radians. - * - * @param val The value in degrees. - * @return The value in radians. - */ - inline float DegToRad(float val) { return (val * (float)Pi/180.0f); } - -/** - * Determines if given float is encoding for not a number (NAN). - * - * @param f The float to check. - * @return 0 if it is a number, something else if is NAN. - */ -#ifdef WIN32 - inline int IsNotANumber(float f) { return _isnan(f); } -#else // Linux and Mac - inline int IsNotANumber(float f) { return !finite(f); } -#endif - - /** - * Determine the sign of a number. - * - * @param val The number to check. - * @return 1.0 if positive, -1.0 if negative. - */ - inline double Sign(double val) { return (val >= 0.0) ? 1.0 : -1.0; } - - /** - * Determine the sign of a number. - * - * @param val The number to check. - * @return 1.0f if positive, -1.0f if negative. - */ - inline float Sign(float val) { return (val >= 0.0f) ? 1.0f : -1.0f; } - - /** - * Determine the sign of a number. - * - * @param val The number to check. - * @return 1 if positive, -1 if negative. - */ - inline int32 Sign(int32 val) { return (val >= 0) ? 1 : -1; } - - /** - * Clamp the specified object within a range specified by two other objects - * of the same class. - * - * Clamp refers to setting a value within a given range. If the value is - * lower than the minimum of the range, it is set to the minimum; same for - * the maximum. - * - * @param val The object to clamp. - * @param mx The highest object of the range. - * @param mn The lowest object of the range. - * @return The clamped value. - */ - template - inline T Clamp(T val, T mn, T mx) { return std::max(std::min(val, mx), mn); } -}; - -// Include commonly used mathematical classes -#include "FMath/FMVector2.h" -#include "FMath/FMVector3.h" -#include "FMath/FMVector4.h" -#include "FMath/FMColor.h" -#include "FMath/FMMatrix33.h" -#include "FMath/FMMatrix44.h" - -#endif // _F_MATH_H_ diff --git a/Extras/FCollada/FMath/FMath_vc7.vcproj b/Extras/FCollada/FMath/FMath_vc7.vcproj deleted file mode 100644 index 463cfee4b..000000000 --- a/Extras/FCollada/FMath/FMath_vc7.vcproj +++ /dev/null @@ -1,865 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/FCollada/FMath/FMath_vc8.vcproj b/Extras/FCollada/FMath/FMath_vc8.vcproj deleted file mode 100644 index 0971ab902..000000000 --- a/Extras/FCollada/FMath/FMath_vc8.vcproj +++ /dev/null @@ -1,865 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/FCollada/FMath/Makefile b/Extras/FCollada/FMath/Makefile deleted file mode 100644 index 30d229a7e..000000000 --- a/Extras/FCollada/FMath/Makefile +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/make -# FMath Makefile for PS3 - -include ../../MakeDefs - -LIBNAME = libfmath - -prefix=.. - -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib - -PPU_INCDIRS=-I$(INCPATH) -I.. -PPU_OPTIMIZE_LV= -O3 -funroll-loops - -PPU_LIB_TARGET=$(LIBNAME).a -PPU_SRCS = \ - FMColor.cpp \ - FMInterpolation.cpp \ - FMMatrix33.cpp \ - FMMatrix44.cpp \ - FMQuaternion.cpp \ - FMVector3.cpp \ - StdAfx.cpp - -include ../../MakeRules diff --git a/Extras/FCollada/FMath/StdAfx.cpp b/Extras/FCollada/FMath/StdAfx.cpp deleted file mode 100644 index a20183c65..000000000 --- a/Extras/FCollada/FMath/StdAfx.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include "StdAfx.h" - -// [claforte] Changing temporarily to test trigger of automated build \ No newline at end of file diff --git a/Extras/FCollada/FMath/StdAfx.h b/Extras/FCollada/FMath/StdAfx.h deleted file mode 100644 index d22835799..000000000 --- a/Extras/FCollada/FMath/StdAfx.h +++ /dev/null @@ -1,12 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _STD_AFX_H_ -#define _STD_AFX_H_ - -#define NO_LIBXML -#include "FUtils/FUtils.h" - -#endif // _STD_AFX_H_ diff --git a/Extras/FCollada/FUtils/FUAssert.h b/Extras/FCollada/FUtils/FUAssert.h deleted file mode 100644 index 6362bd8c9..000000000 --- a/Extras/FCollada/FUtils/FUAssert.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FUAssert.h - This file contains a simple debugging assertion mechanism. -*/ - -#ifndef _FU_ASSERT_H_ -#define _FU_ASSERT_H_ - -/** - Breaks into the debugger. - In debug builds, this intentionally crashes the application. - In release builds, this is an empty function. -*/ -inline void DEBUGGER_BREAK() -{ -#ifdef _DEBUG -#ifdef WIN32 - - _asm int 3; -#else - - // Force a crash? - uint32* __p = NULL; - uint32 __v = *__p; - *__p = 0xD1ED0D1E; - __v = __v + 1; - -#endif // WIN32 -#endif // _DEBUG -} - -/** Forces the debugger to break, or take the fall-back. - @param command The fall_back command to execute. */ -#define FUFail(command) { DEBUGGER_BREAK(); command; } - -/** Asserts that a condition is met. - Use this macro, instead of 'if' statements - when you are asserting for a programmer's error. - @param condition The condition to assert. - @param fall_back The command to execute if the condition is not met. */ -#define FUAssert(condition, fall_back) { if (!(condition)) { DEBUGGER_BREAK(); fall_back; } } - -#endif // _FU_ASSERT_H_ diff --git a/Extras/FCollada/FUtils/FUCrc32.cpp b/Extras/FCollada/FUtils/FUCrc32.cpp deleted file mode 100644 index 2706641e7..000000000 --- a/Extras/FCollada/FUtils/FUCrc32.cpp +++ /dev/null @@ -1,122 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FUtils/FUCrc32.h" - -namespace FUCrc32 -{ - -const uint32 kCRCTable[256] = { - 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, - 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988, 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91, - 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE, 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7, - 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC, 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5, - 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172, 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B, - 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940, 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59, - 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116, 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F, - 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924, 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D, - 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A, 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433, - 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818, 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01, - 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E, 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457, - 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C, 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65, - 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2, 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB, - 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0, 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9, - 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086, 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F, - 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4, 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD, - 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A, 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683, - 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8, 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1, - 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE, 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7, - 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC, 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5, - 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252, 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B, - 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60, 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79, - 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236, 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F, - 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04, 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D, - 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A, 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713, - 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38, 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21, - 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E, 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777, - 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C, 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45, - 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2, 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB, - 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0, 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9, - 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6, 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF, - 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94, 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D -}; - -#ifdef UNICODE -crc32 CRC32(const fstring& s) { return CRC32(s.c_str()); } -crc32 CRC32(const fchar* sz) -{ - uint32 crc = 0xffffffff; - - while(*sz != 0) - { - crc = (crc >> 8) ^ kCRCTable[(crc & 0xFF) ^ (uint8)(*sz++)]; - } - - return (crc32) (crc ^ 0xffffffff); -} -#endif // UNICODE - -crc32 CRC32(const string& s) { return CRC32(s.c_str()); } -crc32 CRC32(const char* sz) -{ - uint32 crc = 0xffffffff; - - while(*sz != 0) - { - crc = (crc >> 8) ^ kCRCTable[(crc & 0xFF) ^ (uint8)(*sz++)]; - } - - return (crc32) (crc ^ 0xffffffff); -} - -/* - -// ** The above table was created using the following code: - ** Adapted from http://www.createwindow.com/programming/crc32/ - -unsigned long Reflect(unsigned long ref, char ch) -{ - unsigned long value(0); - for(long i = 1; i < (ch + 1); i++) - { - if(ref & 1) - value |= 1 << (ch - i); - ref >>= 1; - } - return value; -} - -static void InitCRCTable() -{ - unsigned long ulPolynomial = 0x04c11db7; - - ofstream fOut; - fOut.open("CRCTable.txt", ios_base::out | ios_base::binary); - assert(fOut.is_open()); - - for(long i = 0; i <= 0xFF; i++) - { - g_uiCRCTable[i]=Reflect(i, 8) << 24; - for (long j = 0; j < 8; j++) - g_uiCRCTable[i] = (g_uiCRCTable[i] << 1) ^ (g_uiCRCTable[i] & (1 << 31) ? ulPolynomial : 0); - g_uiCRCTable[i] = Reflect(g_uiCRCTable[i], 32); - - char sz[256]; - snprintf(sz, 256, "0x%08X, ", g_uiCRCTable[i]); - fOut << sz; - } - - fOut.close(); -} -*/ - -}; diff --git a/Extras/FCollada/FUtils/FUCrc32.h b/Extras/FCollada/FUtils/FUCrc32.h deleted file mode 100644 index 1cb07528e..000000000 --- a/Extras/FCollada/FUtils/FUCrc32.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FUCrc32.h - This file contains the CRC-32 hashing functions. -*/ - -#ifndef _FU_CRC32_H_ -#define _FU_CRC32_H_ - -/** - CRC-32 hashing functions. - CRC-32 is a commonly used hashing mechanism for strings. - - @ingroup FUtils -*/ -namespace FUCrc32 -{ - /** A CRC32 hash value. */ - typedef uint32 crc32; - - /** Hashes a string. - @param text The string to hash. - @return The 32-bit hash value. */ - crc32 FCOLLADA_EXPORT CRC32(const fstring& text); - crc32 FCOLLADA_EXPORT CRC32(const fchar* text); /**< See above. */ - crc32 FCOLLADA_EXPORT CRC32(const string& text); /**< See above. */ - crc32 FCOLLADA_EXPORT CRC32(const char* text); /**< See above. */ -}; - -#endif // _FU_CRC32_H_ - diff --git a/Extras/FCollada/FUtils/FUDaeEnum.cpp b/Extras/FCollada/FUtils/FUDaeEnum.cpp deleted file mode 100644 index c2897a0cd..000000000 --- a/Extras/FCollada/FUtils/FUDaeEnum.cpp +++ /dev/null @@ -1,228 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FUtils/FUDaeEnum.h" -#include "FUtils/FUDaeSyntax.h" - -namespace FUDaeInterpolation -{ - Interpolation FromString(const string& value) - { - if (value == DAE_NONE_INTERPOLATION) return STEP; - else if (value == DAE_STEP_INTERPOLATION) return STEP; - else if (value == DAE_LINEAR_INTERPOLATION) return LINEAR; - else if (value == DAE_BEZIER_INTERPOLATION) return BEZIER; - else return UNKNOWN; - } - - const char* ToString(const Interpolation& value) - { - switch (value) - { - case STEP: return DAE_STEP_INTERPOLATION; - case LINEAR: return DAE_LINEAR_INTERPOLATION; - case BEZIER: return DAE_BEZIER_INTERPOLATION; - - case UNKNOWN: - default: return DAEERR_UNKNOWN_ELEMENT; - } - } -}; - -namespace FUDaeFunction -{ - Function FromString(const char* value) - { - if (IsEquivalent(value, DAE_CONSTANT_FUNCTION)) return CONSTANT; - else if (IsEquivalent(value, DAE_LINEAR_FUNCTION)) return LINEAR; - else if (IsEquivalent(value, DAE_QUADRATIC_FUNCTION)) return QUADRATIC; - else return UNKNOWN; - } -}; - -namespace FUDaeTextureChannel -{ - Channel FromString(const string& value) - { - if (value == DAE_AMBIENT_TEXTURE_CHANNEL) return AMBIENT; - else if (value == DAE_BUMP_TEXTURE_CHANNEL) return BUMP; - else if (value == DAE_DIFFUSE_TEXTURE_CHANNEL) return DIFFUSE; - else if (value == DAE_DISPLACEMENT_TEXTURE_CHANNEL) return DISPLACEMENT; - else if (value == DAE_EMISSION_TEXTURE_CHANNEL) return EMISSION; - else if (value == DAE_FILTER_TEXTURE_CHANNEL) return FILTER; - else if (value == DAE_OPACITY_TEXTURE_CHANNEL) return OPACITY; - else if (value == DAE_REFLECTION_TEXTURE_CHANNEL) return REFLECTION; - else if (value == DAE_REFRACTION_TEXTURE_CHANNEL) return REFRACTION; - else if (value == DAE_SHININESS_TEXTURE_CHANNEL) return SHININESS; - else if (value == DAE_SPECULAR_TEXTURE_CHANNEL) return SPECULAR; - else if (value == DAE_SPECULARLEVEL_TEXTURE_CHANNEL) return SPECULAR_LEVEL; - else if (value == DAE_TRANSPARENT_TEXTURE_CHANNEL) return TRANSPARENT; - else return UNKNOWN; - } -}; - -namespace FUDaeMorphMethod -{ - Method FromString(const char* value) - { - if (IsEquivalent(value, DAE_NORMALIZED_MORPH_METHOD)) return NORMALIZED; - else if (IsEquivalent(value, DAE_RELATIVE_MORPH_METHOD)) return RELATIVE; - else return DEFAULT; - } - - const char* ToString(Method method) - { - switch (method) - { - case NORMALIZED: return DAE_NORMALIZED_MORPH_METHOD; - case RELATIVE: return DAE_RELATIVE_MORPH_METHOD; - case UNKNOWN: - default: return DAEERR_UNKNOWN_MORPH_METHOD; - } - } -}; - -namespace FUDaeInfinity -{ - Infinity FromString(const char* value) - { - if (IsEquivalent(value, DAEMAYA_CONSTANT_INFINITY)) return CONSTANT; - else if (IsEquivalent(value, DAEMAYA_LINEAR_INFINITY)) return LINEAR; - else if (IsEquivalent(value, DAEMAYA_CYCLE_INFINITY)) return CYCLE; - else if (IsEquivalent(value, DAEMAYA_CYCLE_RELATIVE_INFINITY)) return CYCLE_RELATIVE; - else if (IsEquivalent(value, DAEMAYA_OSCILLATE_INFINITY)) return OSCILLATE; - else return DEFAULT; - } - - const char* ToString(Infinity type) - { - switch (type) - { - case CONSTANT: return DAEMAYA_CONSTANT_INFINITY; - case LINEAR: return DAEMAYA_LINEAR_INFINITY; - case CYCLE: return DAEMAYA_CYCLE_INFINITY; - case CYCLE_RELATIVE: return DAEMAYA_CYCLE_RELATIVE_INFINITY; - case OSCILLATE: return DAEMAYA_OSCILLATE_INFINITY; - default: return DAEMAYA_CONSTANT_INFINITY; - } - } -}; - -namespace FUDaeBlendMode -{ - Mode FromString(const char* value) - { - if (IsEquivalent(value, DAEMAYA_NONE_BLENDMODE)) return NONE; - else if (IsEquivalent(value, DAEMAYA_OVER_BLENDMODE)) return OVER; - else if (IsEquivalent(value, DAEMAYA_IN_BLENDMODE)) return IN; - else if (IsEquivalent(value, DAEMAYA_OUT_BLENDMODE)) return OUT; - else if (IsEquivalent(value, DAEMAYA_ADD_BLENDMODE)) return ADD; - else if (IsEquivalent(value, DAEMAYA_SUBSTRACT_BLENDMODE)) return SUBSTRACT; - else if (IsEquivalent(value, DAEMAYA_MULTIPLY_BLENDMODE)) return MULTIPLY; - else if (IsEquivalent(value, DAEMAYA_DIFFERENCE_BLENDMODE)) return DIFFERENCE; - else if (IsEquivalent(value, DAEMAYA_LIGHTEN_BLENDMODE)) return LIGHTEN; - else if (IsEquivalent(value, DAEMAYA_DARKEN_BLENDMODE)) return DARKEN; - else if (IsEquivalent(value, DAEMAYA_SATURATE_BLENDMODE)) return SATURATE; - else if (IsEquivalent(value, DAEMAYA_DESATURATE_BLENDMODE)) return DESATURATE; - else if (IsEquivalent(value, DAEMAYA_ILLUMINATE_BLENDMODE)) return ILLUMINATE; - else return UNKNOWN; - } - - const char* ToString(Mode mode) - { - switch (mode) - { - case NONE: return DAEMAYA_NONE_BLENDMODE; - case OVER: return DAEMAYA_OVER_BLENDMODE; - case IN: return DAEMAYA_IN_BLENDMODE; - case OUT: return DAEMAYA_OUT_BLENDMODE; - case ADD: return DAEMAYA_ADD_BLENDMODE; - case SUBSTRACT: return DAEMAYA_SUBSTRACT_BLENDMODE; - case MULTIPLY: return DAEMAYA_MULTIPLY_BLENDMODE; - case DIFFERENCE: return DAEMAYA_DIFFERENCE_BLENDMODE; - case LIGHTEN: return DAEMAYA_LIGHTEN_BLENDMODE; - case DARKEN: return DAEMAYA_DARKEN_BLENDMODE; - case SATURATE: return DAEMAYA_SATURATE_BLENDMODE; - case DESATURATE: return DAEMAYA_DESATURATE_BLENDMODE; - case ILLUMINATE: return DAEMAYA_ILLUMINATE_BLENDMODE; - default: return DAEMAYA_NONE_BLENDMODE; - } - } -} - -namespace FUDaeGeometryInput -{ - Semantic FromString(const char* value) - { - if (IsEquivalent(value, DAE_POSITION_INPUT)) return POSITION; - else if (IsEquivalent(value, DAE_VERTEX_INPUT)) return VERTEX; - else if (IsEquivalent(value, DAE_NORMAL_INPUT)) return NORMAL; - else if (IsEquivalent(value, DAE_GEOTANGENT_INPUT)) return GEOTANGENT; - else if (IsEquivalent(value, DAE_GEOBINORMAL_INPUT)) return GEOBINORMAL; - else if (IsEquivalent(value, DAE_TEXCOORD_INPUT)) return TEXCOORD; - else if (IsEquivalent(value, DAE_TEXTANGENT_INPUT)) return TEXTANGENT; - else if (IsEquivalent(value, DAE_TEXBINORMAL_INPUT)) return TEXBINORMAL; - else if (IsEquivalent(value, DAE_MAPPING_INPUT)) return UV; - else if (IsEquivalent(value, DAE_COLOR_INPUT)) return COLOR; - else if (IsEquivalent(value, DAEMAYA_EXTRA_INPUT)) return EXTRA; - else return UNKNOWN; - } - - const char* ToString(Semantic semantic) - { - switch(semantic) - { - case POSITION: return DAE_POSITION_INPUT; - case VERTEX: return DAE_VERTEX_INPUT; - case NORMAL: return DAE_NORMAL_INPUT; - case GEOTANGENT: return DAE_GEOTANGENT_INPUT; - case GEOBINORMAL: return DAE_GEOBINORMAL_INPUT; - case TEXCOORD: return DAE_TEXCOORD_INPUT; - case TEXTANGENT: return DAE_TEXTANGENT_INPUT; - case TEXBINORMAL: return DAE_TEXBINORMAL_INPUT; - case UV: return DAE_MAPPING_INPUT; - case COLOR: return DAE_COLOR_INPUT; - case EXTRA: return DAEMAYA_EXTRA_INPUT; - - case UNKNOWN: - default: return DAEERR_UNKNOWN_INPUT; - } - } -} - -namespace FUDaeProfileType -{ - Type FromString(const char* value) - { - if (IsEquivalent(value, DAE_FX_PROFILE_COMMON_ELEMENT)) return COMMON; - else if (IsEquivalent(value, DAE_FX_PROFILE_CG_ELEMENT)) return CG; - else if (IsEquivalent(value, DAE_FX_PROFILE_HLSL_ELEMENT)) return HLSL; - else if (IsEquivalent(value, DAE_FX_PROFILE_GLSL_ELEMENT)) return GLSL; - else if (IsEquivalent(value, DAE_FX_PROFILE_GLES_ELEMENT)) return GLES; - else return UNKNOWN; - } - - const char* ToString(Type type) - { - switch(type) - { - case COMMON: return DAE_FX_PROFILE_COMMON_ELEMENT; - case CG: return DAE_FX_PROFILE_CG_ELEMENT; - case HLSL: return DAE_FX_PROFILE_HLSL_ELEMENT; - case GLSL: return DAE_FX_PROFILE_GLSL_ELEMENT; - case GLES: return DAE_FX_PROFILE_GLES_ELEMENT; - - case UNKNOWN: - default: return DAEERR_UNKNOWN_INPUT; - } - } -} diff --git a/Extras/FCollada/FUtils/FUDaeEnum.h b/Extras/FCollada/FUtils/FUDaeEnum.h deleted file mode 100644 index 41d808204..000000000 --- a/Extras/FCollada/FUtils/FUDaeEnum.h +++ /dev/null @@ -1,220 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _FU_DAE_ENUM_H_ -#define _FU_DAE_ENUM_H_ - -// Animation curve interpolation function -// Defaults to the STEP interpolation by definition in COLLADA. -// BEZIER is the more common interpolation type -namespace FUDaeInterpolation -{ - enum Interpolation - { - STEP = 0, //equivalent to no interpolation - LINEAR, - BEZIER, - - UNKNOWN, - DEFAULT = STEP, - }; - - FCOLLADA_EXPORT Interpolation FromString(const string& value); - const char* ToString(const Interpolation& value); -}; - -typedef vector FUDaeInterpolationList; - -// COLLADA generic degree function. Used by lights and the profile_COMMON materials. -namespace FUDaeFunction -{ - enum Function - { - CONSTANT = 0, - LINEAR, - QUADRATIC, - - UNKNOWN, - DEFAULT = CONSTANT, - }; - - FCOLLADA_EXPORT Function FromString(const char* value); - inline Function FromString(const string& value) { return FromString(value.c_str()); } -}; - - -// Material texture channels. Used by profile_common materials to assign textures to channels/slots -// Multi-texturing is done by assigning more than one texture per slot. -// Defaults to diffuse texture slot -#undef TRANSPARENT // Win32: GDI stupidely defines this in the global namespace -namespace FUDaeTextureChannel -{ - enum Channel - { - AMBIENT = 0, - BUMP, - DIFFUSE, - DISPLACEMENT, - EMISSION, - FILTER, - OPACITY, - REFLECTION, - REFRACTION, - SHININESS, - SPECULAR, - SPECULAR_LEVEL, - TRANSPARENT, - - COUNT, - UNKNOWN, - DEFAULT = DIFFUSE, - }; - - FCOLLADA_EXPORT Channel FromString(const string& value); -}; - -// Morph controller method -// NORMALIZED implies that the morph targets all have absolute vertex positions -// RELATIVE implies that the morph targets have relative vertex positions -// -// Whether the vertex position is relative or absolute is irrelevant, -// as long as you use the correct weight generation function: -// NORMALIZED: base_weight = 1.0f - SUM(weight[t]) -// RELATIVE: base_weight = 1.0f -// and position[k] = SUM(weight[t][k] * position[t][k]) -#undef RELATIVE // Win32: GDI stupidely defines this in the global namespace -namespace FUDaeMorphMethod -{ - enum Method - { - NORMALIZED = 0, - RELATIVE, - - UNKNOWN, - DEFAULT = NORMALIZED, - }; - - FCOLLADA_EXPORT Method FromString(const char* value); - FCOLLADA_EXPORT const char* ToString(Method method); - inline Method FromString(const string& value) { return FromString(value.c_str()); } -}; - -// Maya uses the infinity to determine what happens outside an animation curve -// Intentionally matches the MFnAnimCurve::InfinityType enum -namespace FUDaeInfinity -{ - enum Infinity - { - CONSTANT = 0, - LINEAR, - CYCLE, - CYCLE_RELATIVE, - OSCILLATE, - - UNKNOWN, - DEFAULT = CONSTANT - }; - - FCOLLADA_EXPORT Infinity FromString(const char* value); - FCOLLADA_EXPORT const char* ToString(Infinity infinity); - inline Infinity FromString(const string& value) { return FromString(value.c_str()); } -}; - -// Maya uses the blend mode for texturing purposes -// Intentionally matches the equivalent Maya enum -#undef IN -#undef OUT -#undef DIFFERENCE -namespace FUDaeBlendMode -{ - enum Mode - { - NONE, - OVER, - IN, - OUT, - ADD, - SUBSTRACT, - MULTIPLY, - DIFFERENCE, - LIGHTEN, - DARKEN, - SATURATE, - DESATURATE, - ILLUMINATE, - - UNKNOWN, - DEFAULT = NONE, - }; - - FCOLLADA_EXPORT Mode FromString(const char* value); - FCOLLADA_EXPORT const char* ToString(Mode mode); - inline Mode FromString(const string& value) { return FromString(value.c_str()); } -} - -// Geometry Input Semantics -// Found in the , ... -namespace FUDaeGeometryInput -{ - enum Semantic - { - POSITION = 0, - VERTEX, - NORMAL, - GEOTANGENT, - GEOBINORMAL, - TEXCOORD, - TEXTANGENT, - TEXBINORMAL, - UV, - COLOR, - EXTRA, // Maya-specific, used for blind data - - UNKNOWN = -1, - }; - typedef vector SemanticList; - - FCOLLADA_EXPORT Semantic FromString(const char* value); - FCOLLADA_EXPORT const char* ToString(Semantic semantic); - inline Semantic FromString(const string& value) { return FromString(value.c_str()); } -} - -/** The types of effect profiles. */ -namespace FUDaeProfileType -{ - /** Enumerates the types of effect profiles. */ - enum Type - { - CG, /**< The CG profile. */ - HLSL, /**< The HLSL profile for DirectX. */ - GLSL, /**< The GLSL profile for OpenGL. */ - GLES, /**< The GLES profile for OpenGL ES. */ - COMMON, /**< The common profile which encapsulates the standard lighting equations: Lambert, Phong, Blinn. */ - - UNKNOWN /**< Not a valid profile type. */ - }; - - /** Converts the COLLADA profile name string to a profile type. - Examples of COLLADA profile name strings are 'profile_CG' and 'profile_COMMON'. - @param value The profile name string. - @return The profile type. */ - FCOLLADA_EXPORT Type FromString(const char* value); - inline Type FromString(const string& value) { return FromString(value.c_str()); } /**< See above. */ - - /** Converts the profile type to its COLLADA profile name string. - Examples of COLLADA profile name strings are 'profile_CG' and 'profile_COMMON'. - @param type The profile type. - @return The name string for the profile type. */ - FCOLLADA_EXPORT const char* ToString(Type type); -} - -#endif // _FU_DAE_ENUM_H_ - diff --git a/Extras/FCollada/FUtils/FUDaeParser.cpp b/Extras/FCollada/FUtils/FUDaeParser.cpp deleted file mode 100644 index 7ddb2b858..000000000 --- a/Extras/FCollada/FUtils/FUDaeParser.cpp +++ /dev/null @@ -1,446 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeEnum.h" -#include "FUtils/FUStringConversion.h" -#include "FUtils/FUXmlNodeIdPair.h" - -namespace FUDaeParser -{ - // Returns the first child node with a given id - xmlNode* FindChildById(xmlNode* parent, const string& id) - { - if (parent != NULL && !id.empty()) - { - const char* localId = id.c_str(); - if (localId[0] == '#') ++localId; - for (xmlNode* child = parent->children; child != NULL; child = child->next) - { - if (child->type == XML_ELEMENT_NODE) - { - string nodeId = ReadNodeId(child); - if (nodeId == localId) return child; - } - } - } - return NULL; - } - - // Returns the first child node of a given "ref" property - xmlNode* FindChildByRef(xmlNode* parent, const char* ref) - { - return FindChildByProperty(parent, DAE_REF_ATTRIBUTE, ref); - } - - // Returns the first child with the given 'sid' value within a given xml hierarchy - xmlNode* FindHierarchyChildBySid(xmlNode* hierarchyRoot, const char* sid) - { - xmlNode* found = NULL; - for (xmlNode* child = hierarchyRoot->children; child != NULL && found == NULL; child = child->next) - { - if (child->type != XML_ELEMENT_NODE) continue; - if (ReadNodeProperty(child, DAE_SID_ATTRIBUTE) == sid) return child; - found = FindHierarchyChildBySid(child, sid); - } - return found; - } - - // Returns the first technique node with a given profile - xmlNode* FindTechnique(xmlNode* parent, const char* profile) - { - if (parent != NULL) - { - if (IsEquivalent(profile, DAE_COMMON_PROFILE)) - { - // COLLADA 1.4: Look for the element - xmlNode* techniqueNode = FindChildByType(parent, DAE_TECHNIQUE_COMMON_ELEMENT); - if (techniqueNode != NULL) return techniqueNode; - } - - xmlNodeList techniqueNodes; - FindChildrenByType(parent, DAE_TECHNIQUE_ELEMENT, techniqueNodes); - size_t techniqueNodeCount = techniqueNodes.size(); - for (size_t i = 0; i < techniqueNodeCount; ++i) - { - xmlNode* techniqueNode = techniqueNodes[i]; - string techniqueProfile = ReadNodeProperty(techniqueNode, DAE_PROFILE_ATTRIBUTE); - if (techniqueProfile == profile) return techniqueNode; - } - } - return NULL; - } - - // Returns the accessor node for a given source node - xmlNode* FindTechniqueAccessor(xmlNode* parent) - { - xmlNode* techniqueNode = FindTechnique(parent, DAE_COMMON_PROFILE); - return FindChildByType(techniqueNode, DAE_ACCESSOR_ELEMENT); - } - - // Returns the array node from a given array type - xmlNode* FindArray(xmlNode* parent, const char* arrayType) - { - xmlNode* stronglyTypedArrayNode = FindChildByType(parent, arrayType); - if (stronglyTypedArrayNode != NULL) return stronglyTypedArrayNode; - - xmlNode* weaklyTypedArrayNode = FindChildByType(parent, DAE_ARRAY_ELEMENT); - if (weaklyTypedArrayNode != NULL) return weaklyTypedArrayNode; - - return NULL; - } - - // Returns a list of parameter names and nodes held by a given XML node - // Useful for COLLADA 1.3 backward-compatibility: the names are taken from the node's 'name' attribute - void FindParameters(xmlNode* parent, StringList& parameterNames, xmlNodeList& parameterNodes) - { - if (parent == NULL || parameterNames.size() != parameterNodes.size()) return; - - size_t originalCount = parameterNodes.size(); - for (xmlNode* child = parent->children; child != NULL; child = child->next) - { - if (child->type != XML_ELEMENT_NODE) continue; - - // Drop the technique and exta elements that may be found - if (IsEquivalent(child->name, DAE_TECHNIQUE_ELEMENT) || - IsEquivalent(child->name, DAE_EXTRA_ELEMENT)) continue; - - // Buffer this parameter node - parameterNodes.push_back(child); - } - - // Retrieve all the parameter's names - size_t parameterNodeCount = parameterNodes.size(); - parameterNames.resize(parameterNodeCount); - for (size_t i = originalCount; i < parameterNodeCount; ++i) - { - xmlNode* node = parameterNodes[i]; - if (IsEquivalent(node->name, DAE_PARAMETER_ELEMENT)) parameterNames[i] = ReadNodeName(node); - else parameterNames[i] = (const char*) node->name; - } - } - - // Retrieves a list of floats from a source node - // Returns the data's stride. - uint32 ReadSource(xmlNode* sourceNode, FloatList& array) - { - uint32 stride = 0; - if (sourceNode != NULL) - { - // Get the accessor's count - xmlNode* accessorNode = FindTechniqueAccessor(sourceNode); - stride = ReadNodeStride(accessorNode); - array.resize(ReadNodeCount(accessorNode) * stride); - - xmlNode* arrayNode = FindArray(sourceNode, DAE_FLOAT_ARRAY_ELEMENT); - const char* arrayContent = ReadNodeContentDirect(arrayNode); - FUStringConversion::ToFloatList(arrayContent, array); - } - return stride; - } - - // Retrieves a list of signed integers from a source node - void ReadSource(xmlNode* sourceNode, Int32List& array) - { - if (sourceNode != NULL) - { - // Get the accessor's count - xmlNode* accessorNode = FindTechniqueAccessor(sourceNode); - array.resize(ReadNodeCount(accessorNode)); - - xmlNode* arrayNode = FindArray(sourceNode, DAE_FLOAT_ARRAY_ELEMENT); - const char* arrayContent = ReadNodeContentDirect(arrayNode); - FUStringConversion::ToInt32List(arrayContent, array); - } - } - - // Retrieves a list of strings from a source node - void ReadSource(xmlNode* sourceNode, StringList& array) - { - if (sourceNode != NULL) - { - // Get the accessor's count - xmlNode* accessorNode = FindTechniqueAccessor(sourceNode); - array.resize(ReadNodeCount(accessorNode)); - - xmlNode* arrayNode = FindArray(sourceNode, DAE_NAME_ARRAY_ELEMENT); - if (arrayNode == NULL) arrayNode = FindArray(sourceNode, DAE_IDREF_ARRAY_ELEMENT); - const char* arrayContent = ReadNodeContentDirect(arrayNode); - FUStringConversion::ToStringList(arrayContent, array); - } - } - - // Retrieves a list of points from a source node - void ReadSource(xmlNode* sourceNode, FMVector3List& array, float lengthFactor) - { - if (sourceNode != NULL) - { - // Get the accessor's count - xmlNode* accessorNode = FindTechniqueAccessor(sourceNode); - array.resize(ReadNodeCount(accessorNode)); - - xmlNode* arrayNode = FindArray(sourceNode, DAE_FLOAT_ARRAY_ELEMENT); - const char* arrayContent = ReadNodeContentDirect(arrayNode); - FUStringConversion::ToPointList(arrayContent, array, lengthFactor); - } - } - - // Retrieves a list of matrices from a source node - void ReadSource(xmlNode* sourceNode, FMMatrix44List& array, float lengthFactor) - { - if (sourceNode != NULL) - { - // Get the accessor's count - xmlNode* accessorNode = FindTechniqueAccessor(sourceNode); - array.resize(ReadNodeCount(accessorNode)); - - xmlNode* arrayNode = FindArray(sourceNode, DAE_FLOAT_ARRAY_ELEMENT); - const char* arrayContent = ReadNodeContentDirect(arrayNode); - FUStringConversion::ToMatrixList(arrayContent, array, lengthFactor); - } - } - - // Retrieves a series of interleaved floats from a source node - void ReadSourceInterleaved(xmlNode* sourceNode, vector& arrays) - { - if (sourceNode != NULL) - { - // Get the accessor's count - xmlNode* accessorNode = FindTechniqueAccessor(sourceNode); - uint32 count = ReadNodeCount(accessorNode); - for (vector::iterator it = arrays.begin(); it != arrays.end(); ++it) - { - (*it)->resize(count); - } - - // Use the stride to pad the interleaved float lists or remove extra elements - uint32 stride = ReadNodeStride(accessorNode); - while (stride < arrays.size()) arrays.pop_back(); - while (stride > arrays.size()) arrays.push_back(NULL); - - // Read and parse the float array - xmlNode* arrayNode = FindArray(sourceNode, DAE_FLOAT_ARRAY_ELEMENT); - const char* arrayContent = ReadNodeContentDirect(arrayNode); - FUStringConversion::ToInterleavedFloatList(arrayContent, arrays); - } - } - - // Retrieves a series of interpolation values from a source node - void ReadSourceInterpolation(xmlNode* sourceNode, UInt32List& array) - { - if (sourceNode != NULL) - { - // Get the accessor's count - xmlNode* accessorNode = FindTechniqueAccessor(sourceNode); - uint32 count = ReadNodeCount(accessorNode); - array.resize(count); - - StringList stringArray(count); - xmlNode* arrayNode = FindArray(sourceNode, DAE_NAME_ARRAY_ELEMENT); - const char* arrayContent = ReadNodeContentDirect(arrayNode); - FUStringConversion::ToStringList(arrayContent, stringArray); - for (uint32 i = 0; i < count; ++i) - { - array[i] = (uint32) FUDaeInterpolation::FromString(stringArray[i]); - } - } - } - - // Retrieves a series of interpolation values from a source node - void ReadSourceInterpolationInterleaved(xmlNode* sourceNode, vector& arrays) - { - if (sourceNode != NULL) - { - // Get the accessor's count - xmlNode* accessorNode = FindTechniqueAccessor(sourceNode); - uint32 count = ReadNodeCount(accessorNode); - for (vector::iterator it = arrays.begin(); it != arrays.end(); ++it) - { - (*it)->resize(count); - } - - // Get the source node's stride from the accessor node - uint32 stride = ReadNodeStride(accessorNode); - while (stride < arrays.size()) arrays.pop_back(); - - StringList stringArray(count * stride); - xmlNode* arrayNode = FindArray(sourceNode, DAE_NAME_ARRAY_ELEMENT); - const char* arrayContent = ReadNodeContentDirect(arrayNode); - FUStringConversion::ToStringList(arrayContent, stringArray); - for (uint32 i = 0; i < count; ++i) - { - for (size_t j = 0; j < arrays.size(); ++j) - { - arrays[j]->at(i) = (uint32) FUDaeInterpolation::FromString(stringArray[i * stride + j]); - } - } - } - } - - // Retrieves the target property of a targeting node, split into its pointer and its qualifier(s) - void ReadNodeTargetProperty(xmlNode* targetingNode, string& pointer, string& qualifier) - { - string target = ReadNodeProperty(targetingNode, DAE_TARGET_ATTRIBUTE); - SplitTarget(target, pointer, qualifier); - } - - // Split the target string into its pointer and its qualifier(s) - void SplitTarget(const string& target, string& pointer, string& qualifier) - { - uint32 splitIndex = (uint32) target.find_first_of("([."); - if (splitIndex != string::npos) - { - pointer = target.substr(0, splitIndex); - qualifier = target.substr(splitIndex); - } - else - { - pointer = target; - qualifier.clear(); - } - } - - // Calculate the target pointer for a targetable node - void CalculateNodeTargetPointer(xmlNode* target, string& pointer) - { - if (target != NULL) - { - // The target node should have either a subid or an id - if (HasNodeProperty(target, DAE_ID_ATTRIBUTE)) - { - pointer = ReadNodeId(target); - return; - } - else if (!HasNodeProperty(target, DAE_SID_ATTRIBUTE)) - { - pointer.clear(); - return; - } - - // Generate a list of parent nodes up to the first properly identified parent - xmlNodeList traversal; - traversal.push_back(target); - xmlNode* current = target->parent; - while (current != NULL) - { - traversal.push_back(current); - if (HasNodeProperty(current, DAE_ID_ATTRIBUTE)) break; - current = current->parent; - } - - // The top parent should have the ID property - FUSStringBuilder builder; - intptr_t nodeCount = (intptr_t) traversal.size(); - builder.append(ReadNodeId(traversal[nodeCount - 1])); - if (builder.empty()) { pointer.clear(); return; } - - // Build up the target string - for (intptr_t i = nodeCount - 2; i >= 0; --i) - { - xmlNode* node = traversal[i]; - string subId = ReadNodeProperty(node, DAE_SID_ATTRIBUTE); - if (!subId.empty()) - { - builder.append('/'); - builder.append(subId); - } - } - - pointer = builder.ToString(); - } - else pointer.clear(); - } - - // Parse the target elements of the matrix - int32 ReadTargetMatrixElement(string& qualifier) - { - int32 returnValue = -1; - const char* c = qualifier.c_str(); - while(*c == '(' || *c == '[') - { - const char* number = ++c; - while (*c >= '0' && *c <= '9') ++c; - if (*c == ')' || *c == ']') - { - returnValue = FUStringConversion::ToInt32(number); - string temp = c + 1; - qualifier = temp; - break; - } - } - return returnValue; - } - - // Parse the Url attribute off a node - FUUri ReadNodeUrl(xmlNode* node, const char* attribute) - { - FUUri out; - string uriString = ReadNodeProperty(node, attribute); - uint32 suffixStart = (uint32) uriString.find('#'); - if (suffixStart == string::npos) out.prefix = TO_FSTRING(uriString); - else - { - out.prefix = TO_FSTRING(uriString.substr(0, suffixStart)); - out.suffix = uriString.substr(suffixStart + 1); - } - return out; - } - - // Parse the count attribute off a node - uint32 ReadNodeCount(xmlNode* node) - { - string countString = ReadNodeProperty(node, DAE_COUNT_ATTRIBUTE); - return FUStringConversion::ToUInt32(countString); - } - - // Parse the stride attribute off a node - uint32 ReadNodeStride(xmlNode* node) - { - string strideString = ReadNodeProperty(node, DAE_STRIDE_ATTRIBUTE); - uint32 stride = FUStringConversion::ToUInt32(strideString); - if (stride == 0) stride = 1; - return stride; - } - - // Pre-buffer the children of a node, with their ids for performance optimization - void ReadChildrenIds(xmlNode* node, FUXmlNodeIdPairList& pairs) - { - // To avoid unnecessary memory copies: - // Start with calculating the maximum child count - uint32 nodeCount = 0; - for (xmlNode* child = node->children; child != NULL; child = child->next) - { - if (child->type == XML_ELEMENT_NODE) ++nodeCount; - } - - // Now, buffer the child nodes and their ids - pairs.reserve(nodeCount); - for (xmlNode* child = node->children; child != NULL; child = child->next) - { - if (child->type == XML_ELEMENT_NODE) - { - FUXmlNodeIdPairList::iterator it = pairs.insert(pairs.end(), FUXmlNodeIdPair()); - (*it).node = child; - (*it).id = ReadNodePropertyCRC(child, DAE_ID_ATTRIBUTE); - } - } - } - - // Skip the pound(#) character from a COLLADA id string - const char* SkipPound(const string& id) - { - const char* s = id.c_str(); - if (s == NULL) return NULL; - else if (*s == '#') ++s; - return s; - } -} diff --git a/Extras/FCollada/FUtils/FUDaeParser.h b/Extras/FCollada/FUtils/FUDaeParser.h deleted file mode 100644 index 10335d206..000000000 --- a/Extras/FCollada/FUtils/FUDaeParser.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _FU_DAE_PARSER_ -#define _FU_DAE_PARSER_ - -#ifdef HAS_LIBXML - -#include "FUtils/FUDaeSyntax.h" -#include "FUtils/FUUri.h" -#include "FUtils/FUXmlParser.h" -#include "FUtils/FUXmlNodeIdPair.h" - -namespace FUDaeParser -{ - using namespace FUXmlParser; - - // Retrieve specific child nodes - FCOLLADA_EXPORT xmlNode* FindChildById(xmlNode* parent, const string& id); - FCOLLADA_EXPORT xmlNode* FindChildByRef(xmlNode* parent, const char* ref); - FCOLLADA_EXPORT xmlNode* FindHierarchyChildBySid(xmlNode* hierarchyRoot, const char* sid); - FCOLLADA_EXPORT xmlNode* FindTechnique(xmlNode* parent, const char* profile); - FCOLLADA_EXPORT xmlNode* FindTechniqueAccessor(xmlNode* parent); - FCOLLADA_EXPORT xmlNode* FindArray(xmlNode* parent, const char* arrayType); - FCOLLADA_EXPORT void FindParameters(xmlNode* parent, StringList& parameterNames, xmlNodeList& parameterNodes); - - // Import source arrays - FCOLLADA_EXPORT uint32 ReadSource(xmlNode* sourceNode, FloatList& array); - FCOLLADA_EXPORT void ReadSource(xmlNode* sourceNode, Int32List& array); - FCOLLADA_EXPORT void ReadSource(xmlNode* sourceNode, StringList& array); - FCOLLADA_EXPORT void ReadSource(xmlNode* sourceNode, FMVector3List& array, float lengthFactor=1.0f); - FCOLLADA_EXPORT void ReadSource(xmlNode* sourceNode, FMMatrix44List& array, float lengthFactor=1.0f); - FCOLLADA_EXPORT void ReadSourceInterleaved(xmlNode* sourceNode, vector& arrays); - FCOLLADA_EXPORT void ReadSourceInterpolation(xmlNode* sourceNode, UInt32List& array); - FCOLLADA_EXPORT void ReadSourceInterpolationInterleaved(xmlNode* sourceNode, vector& arrays); - - // Target support - FCOLLADA_EXPORT void ReadNodeTargetProperty(xmlNode* targetingNode, string& pointer, string& qualifier); - FCOLLADA_EXPORT void SplitTarget(const string& target, string& pointer, string& qualifier); - FCOLLADA_EXPORT void CalculateNodeTargetPointer(xmlNode* targetedNode, string& pointer); - FCOLLADA_EXPORT int32 ReadTargetMatrixElement(string& qualifier); - - // Retrieve common node properties - inline string ReadNodeId(xmlNode* node) { return ReadNodeProperty(node, DAE_ID_ATTRIBUTE); } - inline string ReadNodeSid(xmlNode* node) { return ReadNodeProperty(node, DAE_SID_ATTRIBUTE); } - inline string ReadNodeSemantic(xmlNode* node) { return ReadNodeProperty(node, DAE_SEMANTIC_ATTRIBUTE); } - inline string ReadNodeName(xmlNode* node) { return ReadNodeProperty(node, DAE_NAME_ATTRIBUTE); } - inline string ReadNodeSource(xmlNode* node) { return ReadNodeProperty(node, DAE_SOURCE_ATTRIBUTE); } - inline string ReadNodeStage(xmlNode* node) { return ReadNodeProperty(node, DAE_STAGE_ATTRIBUTE); } - FCOLLADA_EXPORT FUUri ReadNodeUrl(xmlNode* node, const char* attribute=DAE_URL_ATTRIBUTE); - FCOLLADA_EXPORT uint32 ReadNodeCount(xmlNode* node); - FCOLLADA_EXPORT uint32 ReadNodeStride(xmlNode* node); - - // Pre-buffer the children of a node, with their ids, for performance optimization - FCOLLADA_EXPORT void ReadChildrenIds(xmlNode* node, FUXmlNodeIdPairList& pairs); - - // Skip the pound(#) character from a COLLADA id string - FCOLLADA_EXPORT const char* SkipPound(const string& id); -}; - -#endif // HAS_LIBXML - -#endif // _FU_DAE_PARSER_ diff --git a/Extras/FCollada/FUtils/FUDaeSyntax.h b/Extras/FCollada/FUtils/FUDaeSyntax.h deleted file mode 100644 index e4cde4bb2..000000000 --- a/Extras/FCollada/FUtils/FUDaeSyntax.h +++ /dev/null @@ -1,611 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _DAE_SYNTAX_H_ -#define _DAE_SYNTAX_H_ - -// COLLADA Versioning information -#define DAE_NAMESPACE_ATTRIBUTE "xmlns" -#define DAE_SCHEMA_LOCATION "http://www.collada.org/2005/11/COLLADASchema" -#define DAE_VERSION_ATTRIBUTE "version" -#define DAE_SCHEMA_VERSION "1.4.0" - -// COLLADA 1.4 elements -#define DAE_LIBRARY_ANIMATION_ELEMENT "library_animations" -#define DAE_LIBRARY_ANIMATION_CLIP_ELEMENT "library_animation_clips" -#define DAE_LIBRARY_CAMERA_ELEMENT "library_cameras" -#define DAE_LIBRARY_CONTROLLER_ELEMENT "library_controllers" -#define DAE_LIBRARY_EFFECT_ELEMENT "library_effects" -#define DAE_LIBRARY_FFIELDS_ELEMENT "library_force_fields" -#define DAE_LIBRARY_GEOMETRY_ELEMENT "library_geometries" -#define DAE_LIBRARY_IMAGE_ELEMENT "library_images" -#define DAE_LIBRARY_LIGHT_ELEMENT "library_lights" -#define DAE_LIBRARY_MATERIAL_ELEMENT "library_materials" -#define DAE_LIBRARY_NODE_ELEMENT "library_nodes" -#define DAE_LIBRARY_PMATERIAL_ELEMENT "library_physics_materials" -#define DAE_LIBRARY_PMODEL_ELEMENT "library_physics_models" -#define DAE_LIBRARY_PSCENE_ELEMENT "library_physics_scenes" -#define DAE_LIBRARY_VSCENE_ELEMENT "library_visual_scenes" - -#define DAE_INSTANCE_ANIMATION_ELEMENT "instance_animation" -#define DAE_INSTANCE_CAMERA_ELEMENT "instance_camera" -#define DAE_INSTANCE_CONTROLLER_ELEMENT "instance_controller" -#define DAE_INSTANCE_EFFECT_ELEMENT "instance_effect" -#define DAE_INSTANCE_GEOMETRY_ELEMENT "instance_geometry" -#define DAE_INSTANCE_LIGHT_ELEMENT "instance_light" -#define DAE_INSTANCE_MATERIAL_ELEMENT "instance_material" -#define DAE_INSTANCE_NODE_ELEMENT "instance_node" -#define DAE_INSTANCE_VSCENE_ELEMENT "instance_visual_scene" - -#define DAE_ANIMCLIP_ELEMENT "animation_clip" -#define DAE_BIND_ELEMENT "bind" -#define DAE_BINDMATERIAL_ELEMENT "bind_material" -#define DAE_COLOR_ELEMENT "color" -#define DAE_CONTROL_VERTICES_ELEMENT "control_vertices" -#define DAE_EFFECT_ELEMENT "effect" -#define DAE_MIP_LEVELS "mip_levels" -#define DAE_MIPMAP_GENERATE "mipmap_generate" -#define DAE_SAMPLER_ELEMENT "sampler" -#define DAE_SKELETON_ELEMENT "skeleton" -#define DAE_TARGETS_ELEMENT "targets" -#define DAE_TECHNIQUE_COMMON_ELEMENT "technique_common" -#define DAE_VIEWPORT_RATIO "viewport_ratio" -#define DAE_VSCENE_ELEMENT "visual_scene" -#define DAE_WEIGHTS_ELEMENT "vertex_weights" -#define DAE_VERTEXCOUNT_ELEMENT "vcount" - -#define DAE_INITASNULL_ELEMENT "init_as_null" -#define DAE_INITASTARGET_ELEMENT "init_as_target" -#define DAE_INITCUBE_ELEMENT "init_cube" -#define DAE_INITVOLUME_ELEMENT "init_volume" -#define DAE_INITPLANAR_ELEMENT "init_planar" -#define DAE_INITFROM_ELEMENT "init_from" -#define DAE_ALL_ELEMENT "all" -#define DAE_PRIMARY_ELEMENT "primary" -#define DAE_FACE_ELEMENT "face" -#define DAE_ORDER_ELEMENT "order" - -#define DAE_FX_PROFILE_COMMON_ELEMENT "profile_COMMON" -#define DAE_FX_PROFILE_CG_ELEMENT "profile_CG" -#define DAE_FX_PROFILE_HLSL_ELEMENT "profile_HLSL" -#define DAE_FX_PROFILE_GLSL_ELEMENT "profile_GLSL" -#define DAE_FX_PROFILE_GLES_ELEMENT "profile_GLES" - -#define DAE_FXCMN_ANNOTATE_ELEMENT "annotate" -#define DAE_FXCMN_BIND_ELEMENT "bind" -#define DAE_FXCMN_BOOL_ELEMENT "bool" -#define DAE_FXCMN_CODE_ELEMENT "code" -#define DAE_FXCMN_COMPILERTARGET_ELEMENT "compiler_target" -#define DAE_FXCMN_COMPILEROPTIONS_ELEMENT "compiler_options" -#define DAE_FXCMN_INT_ELEMENT "int" -#define DAE_FXCMN_HALF_ELEMENT "half" -#define DAE_FXCMN_HALF2_ELEMENT "half2" -#define DAE_FXCMN_HALF3_ELEMENT "half3" -#define DAE_FXCMN_HALF4_ELEMENT "half4" -#define DAE_FXCMN_HALF4X4_ELEMENT "half4x4" -#define DAE_FXCMN_FLOAT_ELEMENT "float" -#define DAE_FXCMN_FLOAT2_ELEMENT "float2" -#define DAE_FXCMN_FLOAT3_ELEMENT "float3" -#define DAE_FXCMN_FLOAT4_ELEMENT "float4" -#define DAE_FXCMN_FLOAT4X4_ELEMENT "float4x4" -#define DAE_FXCMN_HINT_ELEMENT "technique_hint" -#define DAE_FXCMN_INCLUDE_ELEMENT "include" -#define DAE_FXCMN_SURFACE_ELEMENT "surface" -#define DAE_FXCMN_SAMPLER1D_ELEMENT "sampler1D" -#define DAE_FXCMN_SAMPLER2D_ELEMENT "sampler2D" -#define DAE_FXCMN_SAMPLER3D_ELEMENT "sampler3D" -#define DAE_FXCMN_SAMPLERCUBE_ELEMENT "samplerCUBE" -#define DAE_FXCMN_SEMANTIC_ELEMENT "semantic" -#define DAE_FXCMN_SETPARAM_ELEMENT "setparam" -#define DAE_FXCMN_NEWPARAM_ELEMENT "newparam" -#define DAE_FXCMN_STRING_ELEMENT "string" -#define DAE_FXCMN_NAME_ELEMENT "name" - -#define DAE_FXCMN_VERTEX_SHADER "VERTEX" -#define DAE_FXCMN_FRAGMENT_SHADER "FRAGMENT" - -#define DAE_FXSTD_CONSTANT_ELEMENT "constant" -#define DAE_FXSTD_LAMBERT_ELEMENT "lambert" -#define DAE_FXSTD_PHONG_ELEMENT "phong" -#define DAE_FXSTD_BLINN_ELEMENT "blinn" -#define DAE_FXSTD_COLOR_ELEMENT "color" -#define DAE_FXSTD_FLOAT_ELEMENT "float" -#define DAE_FXSTD_SAMPLER_ELEMENT "texture" -#define DAE_FXSTD_TEXTURE_ATTRIBUTE "texture" -#define DAE_FXSTD_TEXTURESET_ATTRIBUTE "texcoord" - -#define DAE_CONTROLLER_SKIN_ELEMENT "skin" -#define DAE_CONTROLLER_MORPH_ELEMENT "morph" - -#define DAE_CAMERA_PERSP_ELEMENT "perspective" -#define DAE_CAMERA_ORTHO_ELEMENT "orthographic" - -#define DAE_ASPECT_CAMERA_PARAMETER "aspect_ratio" -#define DAE_XFOV_CAMERA_PARAMETER "xfov" -#define DAE_YFOV_CAMERA_PARAMETER "yfov" -#define DAE_ZNEAR_CAMERA_PARAMETER "znear" -#define DAE_ZFAR_CAMERA_PARAMETER "zfar" -#define DAE_XMAG_CAMERA_PARAMETER "xmag" -#define DAE_YMAG_CAMERA_PARAMETER "ymag" - -#define DAE_AMBIENT_MATERIAL_PARAMETER "ambient" -#define DAE_BUMP_MATERIAL_PARAMETER "bump" -#define DAE_DIFFUSE_MATERIAL_PARAMETER "diffuse" -#define DAE_EMISSION_MATERIAL_PARAMETER "emission" -#define DAE_TRANSPARENCY_MATERIAL_PARAMETER "transparency" -#define DAE_TRANSPARENT_MATERIAL_PARAMETER "transparent" -#define DAE_REFLECTIVE_MATERIAL_PARAMETER "reflective" -#define DAE_REFLECTIVITY_MATERIAL_PARAMETER "reflectivity" -#define DAE_SHININESS_MATERIAL_PARAMETER "shininess" -#define DAE_SPECULAR_MATERIAL_PARAMETER "specular" - -#define DAE_LIGHT_AMBIENT_ELEMENT "ambient" -#define DAE_LIGHT_POINT_ELEMENT "point" -#define DAE_LIGHT_DIRECTIONAL_ELEMENT "directional" -#define DAE_LIGHT_SPOT_ELEMENT "spot" - -#define DAE_COLOR_LIGHT_PARAMETER "color" -#define DAE_CONST_ATTENUATION_LIGHT_PARAMETER "constant_attenuation" -#define DAE_LIN_ATTENUATION_LIGHT_PARAMETER "linear_attenuation" -#define DAE_QUAD_ATTENUATION_LIGHT_PARAMETER "quadratic_attenuation" -#define DAE_FALLOFFEXPONENT_LIGHT_PARAMETER "falloff_exponent" -#define DAE_FALLOFFANGLE_LIGHT_PARAMETER "falloff_angle" - -#define DAE_BINDSHAPEMX_SKIN_PARAMETER "bind_shape_matrix" - -#define DAE_CONTRIBUTOR_ASSET_ELEMENT "contributor" -#define DAE_AUTHOR_ASSET_PARAMETER "author" -#define DAE_AUTHORINGTOOL_ASSET_PARAMETER "authoring_tool" -#define DAE_CREATED_ASSET_PARAMETER "created" -#define DAE_COMMENTS_ASSET_PARAMETER "comments" -#define DAE_COPYRIGHT_ASSET_PARAMETER "copyright" -#define DAE_KEYWORDS_ASSET_PARAMETER "keywords" -#define DAE_MODIFIED_ASSET_PARAMETER "modified" -#define DAE_REVISION_ASSET_PARAMETER "revision" -#define DAE_SOURCEDATA_ASSET_PARAMETER "source_data" -#define DAE_SUBJECT_ASSET_PARAMETER "subject" -#define DAE_TITLE_ASSET_PARAMETER "title" -#define DAE_UNITS_ASSET_PARAMETER "unit" -#define DAE_UPAXIS_ASSET_PARAMETER "up_axis" - -#define DAE_PHYSICS_STATIC_FRICTION "static_friction" -#define DAE_PHYSICS_DYNAMIC_FRICTION "dynamic_friction" -#define DAE_PHYSICS_RESTITUTION "restitution" - -// COLLADA 1.4 attributes -#define DAE_CLOSED_ATTRIBUTE "closed" -#define DAE_COUNT_ATTRIBUTE "count" -#define DAE_END_ATTRIBUTE "end" -#define DAE_ID_ATTRIBUTE "id" -#define DAE_MATERIAL_ATTRIBUTE "material" -#define DAE_METERS_ATTRIBUTE "meter" -#define DAE_METHOD_ATTRIBUTE "method" -#define DAE_NAME_ATTRIBUTE "name" -#define DAE_OFFSET_ATTRIBUTE "offset" -#define DAE_PLATFORM_ATTRIBUTE "platform" -#define DAE_PROFILE_ATTRIBUTE "profile" -#define DAE_REF_ATTRIBUTE "ref" -#define DAE_SEMANTIC_ATTRIBUTE "semantic" -#define DAE_SET_ATTRIBUTE "set" -#define DAE_SID_ATTRIBUTE "sid" -#define DAE_START_ATTRIBUTE "start" -#define DAE_STRIDE_ATTRIBUTE "stride" -#define DAE_SOURCE_ATTRIBUTE "source" -#define DAE_SYMBOL_ATTRIBUTE "symbol" -#define DAE_TARGET_ATTRIBUTE "target" -#define DAE_URL_ATTRIBUTE "url" -#define DAE_STAGE_ATTRIBUTE "stage" - -#define DAE_MIP_ATTRIBUTE "mip" -#define DAE_SLICE_ATTRIBUTE "slice" -#define DAE_FACE_ATTRIBUTE "face" - -// COLLADA 1.4 types -#define DAE_FLOAT_TYPE "float" -#define DAE_IDREF_TYPE "IDREF" -#define DAE_MATRIX_TYPE "float4x4" -#define DAE_NAME_TYPE "Name" - -// COLLADA 1.4 enumerations -#define DAE_AMBIENT_TEXTURE_CHANNEL "AMBIENT" -#define DAE_BUMP_TEXTURE_CHANNEL "BUMP" -#define DAE_DIFFUSE_TEXTURE_CHANNEL "DIFFUSE" -#define DAE_DISPLACEMENT_TEXTURE_CHANNEL "DISPLACEMENT" -#define DAE_EMISSION_TEXTURE_CHANNEL "GLOW" -#define DAE_FILTER_TEXTURE_CHANNEL "FILTER" -#define DAE_OPACITY_TEXTURE_CHANNEL "OPACITY" -#define DAE_REFLECTION_TEXTURE_CHANNEL "REFLECTION" -#define DAE_REFRACTION_TEXTURE_CHANNEL "REFRACTION" -#define DAE_SHININESS_TEXTURE_CHANNEL "SHININESS" -#define DAE_SPECULAR_TEXTURE_CHANNEL "SPECULAR" -#define DAE_SPECULARLEVEL_TEXTURE_CHANNEL "SPECULAR-LEVEL" -#define DAE_TRANSPARENT_TEXTURE_CHANNEL "TRANSPARENT" - -#define DAE_NORMALIZED_MORPH_METHOD "NORMALIZED" -#define DAE_RELATIVE_MORPH_METHOD "RELATIVE" - -#define DAE_WEIGHT_MORPH_INPUT "MORPH_WEIGHT" -#define DAE_WEIGHT_MORPH_INPUT_DEPRECATED "WEIGHT" -#define DAE_TARGET_MORPH_INPUT "MORPH_TARGET" -#define DAE_TARGET_MORPH_INPUT_DEPRECATED "TARGET" - -#define DAE_TIME_TARGET "TIME" - -#define DAE_JOINT_NODE_TYPE "JOINT" -#define DAE_NODE_NODE_TYPE "NODE" - -#define DAE_POSITION_SPLINE_INPUT "POSITION" -#define DAE_KNOT_SPLINE_INPUT "KNOTSEQUENCES" - -// Collada 1.4 physics -#define DAE_PHYSICS_MATERIAL_ELEMENT "physics_material" -#define DAE_PHYSICS_MODEL_ELEMENT "physics_model" -#define DAE_PHYSICS_SCENE_ELEMENT "physics_scene" -#define DAE_INSTANCE_PHYSICS_MATERIAL_ELEMENT "instance_physics_material" -#define DAE_INSTANCE_PHYSICS_MODEL_ELEMENT "instance_physics_model" -#define DAE_INSTANCE_PHYSICS_SCENE_ELEMENT "instance_physics_scene" -#define DAE_INSTANCE_RIGID_BODY_ELEMENT "instance_rigid_body" -#define DAE_INSTANCE_RIGID_CONSTRAINT_ELEMENT "instance_rigid_constraint" -#define DAE_INSTANCE_FORCE_FIELD_ELEMENT "instance_force_field" -#define DAE_TIME_STEP_ATTRIBUTE "time_step" -#define DAE_GRAVITY_ATTRIBUTE "gravity" -#define DAE_RESTITUTION_ATTRIBUTE "restitution" -#define DAE_STATIC_FRICTION_ATTRIBUTE "static_friction" -#define DAE_DYNAMIC_FRICTION_ATTRIBUTE "dynamic_friction" -#define DAE_VELOCITY_ELEMENT "velocity" -#define DAE_ANGULAR_VELOCITY_ELEMENT "angular_velocity" -#define DAE_BODY_ATTRIBUTE "body" -#define DAE_CONSTRAINT_ATTRIBUTE "constraint" -#define DAE_MASS_FRAME_ELEMENT "mass_frame" -#define DAE_LIMITS_ELEMENT "limits" -#define DAE_LINEAR_ELEMENT "linear" -#define DAE_ANGULAR_ELEMENT "angular" -#define DAE_SWING_CONE_AND_TWIST_ELEMENT "swing_cone_and_twist" -#define DAE_CONVEX_HULL_OF_ATTRIBUTE "convex_hull_of" -#define DAE_HEIGHT_ELEMENT "height" - -// Physics extension. Currently in prototype phase. -#define DAE_MIN_ELEMENT "min" -#define DAE_MAX_ELEMENT "max" -#define DAE_SHAPE_ELEMENT "shape" -#define DAE_RIGID_BODY_ELEMENT "rigid_body" -#define DAE_DYNAMIC_ELEMENT "dynamic" -#define DAE_HOLLOW_ELEMENT "hollow" -#define DAE_MASS_ELEMENT "mass" -#define DAE_BOX_ELEMENT "box" -#define DAE_SPHERE_ELEMENT "sphere" -#define DAE_CAPSULE_ELEMENT "capsule" -#define DAE_CYLINDER_ELEMENT "cylinder" -#define DAE_ELLIPSOID_ELEMENT "ellipsoid" -#define DAE_TAPERED_CAPSULE_ELEMENT "tapered_capsule" -#define DAE_TAPERED_CYLINDER_ELEMENT "tapered_cylinder" -#define DAE_PLANE_ELEMENT "plane" -#define DAE_FORMAT_ELEMENT "format" -#define DAE_FORMAT_HINT_ELEMENT "format_hint" -#define DAE_HALF_EXTENTS_ELEMENT "half_extents" -#define DAE_EQUATION_ELEMENT "equation" -#define DAE_SIZE_ELEMENT "size" -#define DAE_RADIUS_ELEMENT "radius" -#define DAE_RADIUS1_ELEMENT "radius1" -#define DAE_RADIUS2_ELEMENT "radius2" -#define DAE_CONVEX_MESH_ELEMENT "convex_mesh" -#define DAE_INERTIA_ELEMENT "inertia" -#define DAE_DENSITY_ELEMENT "density" -#define DAE_CENTER_OF_MASS_ELEMENT "center_of_mass" -#define DAE_DYNAMICS_ELEMENT "dynamics" -#define DAE_RIGID_CONSTRAINT_ELEMENT "rigid_constraint" -#define DAE_FORCE_FIELD_ELEMENT "force_field" -#define DAE_ATTACHMENT_ELEMENT "attachment" -#define DAE_REF_ATTACHMENT_ELEMENT "ref_attachment" -#define DAE_ROT_LIMIT_MIN_ELEMENT "rot_limit_min" -#define DAE_ROT_LIMIT_MAX_ELEMENT "rot_limit_max" -#define DAE_TRANS_LIMIT_MIN_ELEMENT "trans_limit_min" -#define DAE_TRANS_LIMIT_MAX_ELEMENT "trans_limit_max" -#define DAE_ENABLED_ELEMENT "enabled" -#define DAE_INTERPENETRATE_ELEMENT "interpenetrate" -#define DAE_SPRING_ELEMENT "spring" -#define DAE_STIFFNESS_ELEMENT "stiffness" -#define DAE_DAMPING_ELEMENT "damping" -#define DAE_TARGET_VALUE_ELEMENT "target_value" -#define DAE_REST_LENGTH_ELEMENT "rest_length" -#define DAE_ANNOTATE_ELEMENT "annotate" -#define DAE_TRUE_KEYWORD "true" -#define DAE_FALSE_KEYWORD "false" - -// COLLADA 1.3 elements -#define DAE_ACCESSOR_ELEMENT "accessor" -#define DAE_ANIMATION_ELEMENT "animation" -#define DAE_ASSET_ELEMENT "asset" -#define DAE_CAMERA_ELEMENT "camera" -#define DAE_CHANNEL_ELEMENT "channel" -#define DAE_CHANNELS_ELEMENT "channels" -#define DAE_COLLADA_ELEMENT "COLLADA" -#define DAE_COMBINER_ELEMENT "combiner" // [Deprecated 1.4] -#define DAE_CONTROLLER_ELEMENT "controller" -#define DAE_DEPTH_ELEMENT "depth" -#define DAE_EXTRA_ELEMENT "extra" -#define DAE_RANGE_ELEMENT "range" -#define DAE_FLOAT_ARRAY_ELEMENT "float_array" -#define DAE_GEOMETRY_ELEMENT "geometry" -#define DAE_HOLE_ELEMENT "h" -#define DAE_IDREF_ARRAY_ELEMENT "IDREF_array" -#define DAE_IMAGE_ELEMENT "image" -#define DAE_INPUT_ELEMENT "input" -#define DAE_INT_ARRAY_ELEMENT "int_array" -#define DAE_INSTANCE_ELEMENT "instance" // [Deprecated 1.4] -#define DAE_JOINTS_ELEMENT "joints" -#define DAE_LIBRARY_ELEMENT "library" // [Deprecated 1.4] -#define DAE_LIGHT_ELEMENT "light" -#define DAE_LOOKAT_ELEMENT "lookat" -#define DAE_MATERIAL_ELEMENT "material" -#define DAE_MATRIX_ELEMENT "matrix" -#define DAE_MESH_ELEMENT "mesh" -#define DAE_NAME_ARRAY_ELEMENT "Name_array" -#define DAE_NODE_ELEMENT "node" -#define DAE_OPTICS_ELEMENT "optics" -#define DAE_PARAMETER_ELEMENT "param" -#define DAE_PASS_ELEMENT "pass" -#define DAE_POLYGON_ELEMENT "p" -#define DAE_POLYGONHOLED_ELEMENT "ph" -#define DAE_POLYGONS_ELEMENT "polygons" -#define DAE_POLYLIST_ELEMENT "polylist" -#define DAE_PROGRAM_ELEMENT "program" // [Deprecated 1.4] -#define DAE_ROTATE_ELEMENT "rotate" -#define DAE_SCALE_ELEMENT "scale" -#define DAE_SCENE_ELEMENT "scene" -#define DAE_SHADER_ELEMENT "shader" -#define DAE_SOURCE_ELEMENT "source" -#define DAE_SPLINE_ELEMENT "spline" -#define DAE_SKEW_ELEMENT "skew" -#define DAE_TECHNIQUE_ELEMENT "technique" -#define DAE_TEXTURE_ELEMENT "texture" -#define DAE_TRANSLATE_ELEMENT "translate" -#define DAE_TRIANGLES_ELEMENT "triangles" -#define DAE_VERTEX_ELEMENT "v" -#define DAE_VERTICES_ELEMENT "vertices" -#define DAE_WIDTH_ELEMENT "width" - -// COLLADA 1.3 attributes -#define DAE_IDX_ATTRIBUTE "idx" // [Deprecated 1.4] - Replaced by 'offset' -#define DAE_TYPE_ATTRIBUTE "type" // [Deprecated 1.4] - -// COLLADA 1.3 enumerations -#define DAE_COMMON_PROFILE "COMMON" // [Deprecated 1.4] - Replaced by the element - -#define DAE_COLOR_INPUT "COLOR" -#define DAE_GEOBINORMAL_INPUT "BINORMAL" -#define DAE_GEOTANGENT_INPUT "TANGENT" -#define DAE_IMAGE_INPUT "IMAGE" -#define DAE_MAPPING_INPUT "UV" -#define DAE_NORMAL_INPUT "NORMAL" -#define DAE_POSITION_INPUT "POSITION" -#define DAE_TEXCOORD_INPUT "TEXCOORD" -#define DAE_TEXBINORMAL_INPUT "TEXBINORMAL" -#define DAE_TEXTANGENT_INPUT "TEXTANGENT" -#define DAE_TEXTURE_INPUT "TEXTURE" -#define DAE_VERTEX_INPUT "VERTEX" -#define DAE_BINDMATRIX_SKIN_INPUT "INV_BIND_MATRIX" -#define DAE_BINDNORMAL_SKIN_INPUT "BIND_SHAPE_NORMAL" // [Deprecated 1.4] -#define DAE_BINDPOS_SKIN_INPUT "BIND_SHAPE_POSITION" // [Deprecated 1.4] -#define DAE_JOINT_SKIN_INPUT "JOINT" -#define DAE_JOINTWEIGHT_SKIN_INPUT "JOINTS_AND_WEIGHTS" // [Deprecated 1.4] -#define DAE_WEIGHT_SKIN_INPUT "WEIGHT" - -#define DAE_INPUT_ANIMATION_INPUT "INPUT" -#define DAE_OUTPUT_ANIMATION_INPUT "OUTPUT" -#define DAE_INTANGENT_ANIMATION_INPUT "IN_TANGENT" -#define DAE_OUTTANGENT_ANIMATION_INPUT "OUT_TANGENT" -#define DAE_INTERPOLATION_ANIMATION_INPUT "INTERPOLATION" - -#define DAE_ANIMATION_TYPE "ANIMATION" // [Deprecated 1.4] -#define DAE_CAMERA_TYPE "CAMERA" // [Deprecated 1.4] -#define DAE_CONTROLLER_TYPE "CONTROLLER" // [Deprecated 1.4] -#define DAE_EFFECT_TYPE "EFFECT" // [Deprecated 1.4] -#define DAE_IMAGE_TYPE "IMAGE" // [Deprecated 1.4] -#define DAE_GEOMETRY_TYPE "GEOMETRY" // [Deprecated 1.4] -#define DAE_LIGHT_TYPE "LIGHT" // [Deprecated 1.4] -#define DAE_MATERIAL_TYPE "MATERIAL" // [Deprecated 1.4] -#define DAE_TEXTURE_TYPE "TEXTURE" // [Deprecated 1.4] - -#define DAE_PERSPECTIVE_CAMERA_TYPE "PERSPECTIVE" // [Deprecated 1.4] -#define DAE_ORTHOGRAPHIC_CAMERA_TYPE "ORTHOGRAPHIC" // [Deprecated 1.4] - -#define DAE_XFOV_CAMERA_PARAMETER1_3 "XFOV" // [Deprecated 1.4] -#define DAE_YFOV_CAMERA_PARAMETER1_3 "YFOV" // [Deprecated 1.4] -#define DAE_ZNEAR_CAMERA_PARAMETER1_3 "ZNEAR" // [Deprecated 1.4] -#define DAE_ZFAR_CAMERA_PARAMETER1_3 "ZFAR" // [Deprecated 1.4] -#define DAE_LEFT_CAMERA_PARAMETER1_3 "LEFT" // [Deprecated 1.4] -#define DAE_RIGHT_CAMERA_PARAMETER1_3 "RIGHT" // [Deprecated 1.4] -#define DAE_TOP_CAMERA_PARAMETER1_3 "TOP" // [Deprecated 1.4] -#define DAE_BOTTOM_CAMERA_PARAMETER1_3 "BOTTOM" // [Deprecated 1.4] - -#define DAE_AMBIENT_LIGHT_TYPE "AMBIENT" // [Deprecated 1.4] -#define DAE_POINT_LIGHT_TYPE "POINT" // [Deprecated 1.4] -#define DAE_DIRECTIONAL_LIGHT_TYPE "DIRECTIONAL" // [Deprecated 1.4] -#define DAE_SPOT_LIGHT_TYPE "SPOT" // [Deprecated 1.4] - -#define DAE_COLOR_LIGHT_PARAMETER1_3 "COLOR" // [Deprecated 1.4] -#define DAE_ATTENUATION_LIGHT_PARAMETER1_3 "ATTENUATION" // [Deprecated 1.4] -#define DAE_ATTENUATIONSCALE_LIGHT_PARAMETER1_3 "ATTENUATION_SCALE" // [Deprecated 1.4] -#define DAE_FALLOFF_LIGHT_PARAMETER1_3 "FALLOFF" // [Deprecated 1.4] -#define DAE_FALLOFFSCALE_LIGHT_PARAMETER1_3 "FALLOFF_SCALE" // [Deprecated 1.4] -#define DAE_ANGLE_LIGHT_PARAMETER1_3 "ANGLE" // [Deprecated 1.4] - -#define DAE_X_UP "X_UP" -#define DAE_Y_UP "Y_UP" -#define DAE_Z_UP "Z_UP" - -#define DAE_NONE_INTERPOLATION "NONE" // [Deprecated 1.3] ColladaMaya exported this until September 2005 -#define DAE_STEP_INTERPOLATION "STEP" -#define DAE_LINEAR_INTERPOLATION "LINEAR" -#define DAE_BEZIER_INTERPOLATION "BEZIER" - -#define DAE_CONSTANT_FUNCTION "CONSTANT" -#define DAE_LINEAR_FUNCTION "LINEAR" -#define DAE_QUADRATIC_FUNCTION "QUADRATIC" - -#define DAE_CONSTANT_MATERIAL_PROGRAM "CONSTANT" // [Deprecated 1.4] -#define DAE_LAMBERT_MATERIAL_PROGRAM "LAMBERT" // [Deprecated 1.4] -#define DAE_PHONG_MATERIAL_PROGRAM "PHONG" // [Deprecated 1.4] - -#define DAE_AMBIENT_MATERIAL_PARAMETER1_3 "AMBIENT" // [Deprecated 1.4] -#define DAE_DIFFUSE_MATERIAL_PARAMETER1_3 "DIFFUSE" // [Deprecated 1.4] -#define DAE_EMISSION_MATERIAL_PARAMETER1_3 "EMISSION" // [Deprecated 1.4] -#define DAE_TRANSPARENCY_MATERIAL_PARAMETER1_3 "TRANSPARENCY" // [Deprecated 1.4] -#define DAE_TRANSPARENT_MATERIAL_PARAMETER1_3 "TRANSPARENT" // [Deprecated 1.4] -#define DAE_REFLECTIVE_MATERIAL_PARAMETER1_3 "REFLECTIVE" // [Deprecated 1.4] -#define DAE_REFLECTIVITY_MATERIAL_PARAMETER1_3 "REFLECTIVITY" // [Deprecated 1.4] -#define DAE_SHININESS_MATERIAL_PARAMETER1_3 "SHININESS" // [Deprecated 1.4] -#define DAE_SPECULAR_MATERIAL_PARAMETER1_3 "SPECULAR" // [Deprecated 1.4] - -// COLLADA 1.2 elements -#define DAE_ARRAY_ELEMENT "array" // [Deprecated 1.3] - -// COLLADA 1.4 Shared elements -#define DAESHD_DOUBLESIDED_PARAMETER "double_sided" -#define DAESHD_INTENSITY_LIGHT_PARAMETER "intensity" - -// COLLADA 1.3 Shared elements -#define DAESHD_INTENSITY_LIGHT_PARAMETER1_3 "INTENSITY" // [Deprecated 1.4] - -// COLLADA 1.4 Max-specific profile -#define DAEMAX_MAX_PROFILE "MAX3D" - -#define DAEMAX_TARGET_CAMERA_PARAMETER "target" -#define DAEMAX_ASPECTRATIO_LIGHT_PARAMETER "aspect_ratio" -#define DAEMAX_TARGET_LIGHT_PARAMETER "target" -#define DAEMAX_OUTERCONE_LIGHT_PARAMETER "outer_cone" -#define DAEMAX_OVERSHOOT_LIGHT_PARAMETER "overshoot" -#define DAEMAX_SPECLEVEL_MATERIAL_PARAMETER "spec_level" -#define DAEMAX_DISPLACEMENT_MATERIAL_PARAMETER "displacement" -#define DAEMAX_EMISSIONLEVEL_MATERIAL_PARAMETER "emission_level" -#define DAEMAX_FACETED_MATERIAL_PARAMETER "faceted" -#define DAEMAX_FILTERCOLOR_MATERIAL_PARAMETER "filter_color" -#define DAEMAX_INDEXOFREFRACTION_MATERIAL_PARAMETER "index_of_refraction" -#define DAEMAX_USERPROPERTIES_NODE_PARAMETER "user_properties" -#define DAEMAX_WIREFRAME_MATERIAL_PARAMETER "wireframe" -#define DAEMAX_FACEMAP_MATERIAL_PARAMETER "face_map" -#define DAEMAX_AMOUNT_TEXTURE_PARAMETER "amount" - -// COLLADA 1.3 Max-specific profile -#define DAEMAX_TARGET_CAMERA_PARAMETER1_3 "TARGET" // [Deprecated 1.4] -#define DAEMAX_ASPECTRATIO_LIGHT_PARAMETER1_3 "ASPECT_RATIO" // [Deprecated 1.4] -#define DAEMAX_TARGET_LIGHT_PARAMETER1_3 "TARGET" // [Deprecated 1.4] -#define DAEMAX_OUTERCONE_LIGHT_PARAMETER1_3 "OUTERCONE" // [Deprecated 1.4] -#define DAEMAX_OVERSHOOT_LIGHT_PARAMETER1_3 "OVERSHOOT" // [Deprecated 1.4] -#define DAEMAX_SPECLEVEL_MATERIAL_PARAMETER1_3 "SPEC_LEVEL" // [Deprecated 1.4] -#define DAEMAX_EMISSIONLEVEL_MATERIAL_PARAMETER1_3 "EMISSION_LEVEL" // [Deprecated 1.4] -#define DAEMAX_FACETED_MATERIAL_PARAMETER1_3 "FACETED" // [Deprecated 1.4] -#define DAEMAX_USERPROPERTIES_NODE_PARAMETER1_3 "USER_PROPERTIES" // [Deprecated 1.4] - -// MAYA Profile Syntax Definitions - -// COLLADA 1.4 Maya-specific definitions -#define DAEMAYA_MAYA_PROFILE "MAYA" - -#define DAEMAYA_VAPERTURE_PARAMETER "vertical_aperture" -#define DAEMAYA_HAPERTURE_PARAMETER "horizontal_aperture" -#define DAEMAYA_LENSSQUEEZE_PARAMETER "lens_squeeze" - -#define DAEMAYA_PENUMBRA_LIGHT_PARAMETER "penumbra_angle" -#define DAEMAYA_DROPOFF_LIGHT_PARAMETER "dropoff" - -#define DAEMAYA_NOTE_PARAMETER "note" -#define DAEMAYA_VISIBILITY_PARAMETER "visibility" -#define DAEMAYA_ENDTIME_PARAMETER "end_time" -#define DAEMAYA_STARTTIME_PARAMETER "start_time" - -#define DAEMAYA_DRIVER_INPUT "DRIVER" -#define DAEMAYA_EXTRA_INPUT "EXTRA" -#define DAEMAYA_WEIGHT_INPUT "WEIGHT" -#define DAEMAYA_INTANGENTWEIGHT_ANIMATION_INPUT "IN_TANGENT_WEIGHT" -#define DAEMAYA_OUTTANGENTWEIGHT_ANIMATION_INPUT "OUT_TANGENT_WEIGHT" - -// COLLADA 1.3 Maya-specific definitions -#define DAEMAYA_BLINDNAME_PARAMETER "BLINDNAME" -#define DAEMAYA_BLINDTYPEID_PARAMETER "BLINDTYPEID" -#define DAEMAYA_DOUBLE_SIDED_PARAMETER "DOUBLE_SIDED" -#define DAEMAYA_LAYER_PARAMETER "layer" -#define DAEMAYA_LONGNAME_PARAMETER "long_name" -#define DAEMAYA_PREINFINITY_PARAMETER "pre_infinity" -#define DAEMAYA_POSTINFINITY_PARAMETER "post_infinity" -#define DAEMAYA_PREINFINITY_PARAMETER1_3 "PRE_INFINITY" -#define DAEMAYA_POSTINFINITY_PARAMETER1_3 "POST_INFINITY" -#define DAEMAYA_SHORTNAME_PARAMETER "short_name" - -#define DAEMAYA_MAYA_NOTE_PARAMETER1_3 "MAYA_NOTE" // [Deprecated 1.4] -#define DAEMAYA_VISIBILITY_PARAMETER1_3 "VISIBILITY" // [Deprecated 1.4] -#define DAEMAYA_ENDTIME_PARAMETER1_3 "END_TIME" // [Deprecated 1.4] -#define DAEMAYA_STARTTIME_PARAMETER1_3 "START_TIME" // [Deprecated 1.4] - -#define DAEMAYA_VAPERTURE_PARAMETER1_3 "VERTICAL_APERTURE" // [Deprecated 1.4] -#define DAEMAYA_HAPERTURE_PARAMETER1_3 "HORIZONTAL_APERTURE" // [Deprecated 1.4] -#define DAEMAYA_LENSSQUEEZE_PARAMETER1_3 "LENS_SQUEEZE" // [Deprecated 1.4] - -#define DAEMAYA_TEXTURE_WRAPU_PARAMETER "wrapU" -#define DAEMAYA_TEXTURE_WRAPV_PARAMETER "wrapV" -#define DAEMAYA_TEXTURE_MIRRORU_PARAMETER "mirrorU" -#define DAEMAYA_TEXTURE_MIRRORV_PARAMETER "mirrorV" -#define DAEMAYA_TEXTURE_COVERAGEU_PARAMETER "coverageU" -#define DAEMAYA_TEXTURE_COVERAGEV_PARAMETER "coverageV" -#define DAEMAYA_TEXTURE_TRANSFRAMEU_PARAMETER "translateFrameU" -#define DAEMAYA_TEXTURE_TRANSFRAMEV_PARAMETER "translateFrameV" -#define DAEMAYA_TEXTURE_ROTFRAME_PARAMETER "rotateFrame" -#define DAEMAYA_TEXTURE_STAGGER_PARAMETER "stagger" -#define DAEMAYA_TEXTURE_REPEATU_PARAMETER "repeatU" -#define DAEMAYA_TEXTURE_REPEATV_PARAMETER "repeatV" -#define DAEMAYA_TEXTURE_OFFSETU_PARAMETER "offsetU" -#define DAEMAYA_TEXTURE_OFFSETV_PARAMETER "offsetV" -#define DAEMAYA_TEXTURE_ROTATEUV_PARAMETER "rotateUV" -#define DAEMAYA_TEXTURE_NOISEU_PARAMETER "noiseU" -#define DAEMAYA_TEXTURE_NOISEV_PARAMETER "noiseV" -#define DAEMAYA_TEXTURE_FAST_PARAMETER "fast" -#define DAEMAYA_TEXTURE_BLENDMODE_PARAMETER "blend_mode" -#define DAEMAYA_TEXTURE_BLENDMODE_PARAMETER1_3 "BLEND_MODE" - -#define DAEMAYA_PENUMBRA_LIGHT_PARAMETER1_3 "PENUMBRA_ANGLE" // [Deprecated 1.4] - -#define DAEMAYA_CONSTANT_INFINITY "CONSTANT" -#define DAEMAYA_LINEAR_INFINITY "LINEAR" -#define DAEMAYA_CYCLE_INFINITY "CYCLE" -#define DAEMAYA_CYCLE_RELATIVE_INFINITY "CYCLE_RELATIVE" -#define DAEMAYA_OSCILLATE_INFINITY "OSCILLATE" - -#define DAEMAYA_NONE_BLENDMODE "NONE" -#define DAEMAYA_OVER_BLENDMODE "OVER" -#define DAEMAYA_IN_BLENDMODE "IN" -#define DAEMAYA_OUT_BLENDMODE "OUT" -#define DAEMAYA_ADD_BLENDMODE "ADD" -#define DAEMAYA_SUBSTRACT_BLENDMODE "SUBSTRACT" -#define DAEMAYA_MULTIPLY_BLENDMODE "MULTIPLY" -#define DAEMAYA_DIFFERENCE_BLENDMODE "DIFFERENCE" -#define DAEMAYA_LIGHTEN_BLENDMODE "LIGHTEN" -#define DAEMAYA_DARKEN_BLENDMODE "DARKEN" -#define DAEMAYA_SATURATE_BLENDMODE "SATURATE" -#define DAEMAYA_DESATURATE_BLENDMODE "DESATURATE" -#define DAEMAYA_ILLUMINATE_BLENDMODE "ILLUMINATE" - -#define DAEMAYA_PROJECTION_ELEMENT "projection" -#define DAEMAYA_PROJECTION_TYPE_PARAMETER "type" -#define DAEMAYA_PROJECTION_MATRIX_PARAMETER "matrix" - -#define DAEMAYA_PROJECTION_PROGRAM "PROJECTION" // [Deprecated 1.4] -#define DAEMAYA_PROJECTION_TYPE_PARAMETER1_3 "TYPE" // [Deprecated 1.4] -#define DAEMAYA_PROJECTION_MATRIX_PARAMETER1_3 "MATRIX" // [Deprecated 1.4] - -// COLLADA Error export syntax - -#define DAEERR_UNKNOWN_ELEMENT "unknown" -#define DAEERR_UNKNOWN_IDREF "UNKNOWN_IDREF" -#define DAEERR_UNKNOWN_INPUT "UNKNOWN" -#define DAEERR_UNKNOWN_MORPH_METHOD "UNKNOWN" - -#endif // _DAE_SYNTAX_H_ diff --git a/Extras/FCollada/FUtils/FUDaeWriter.cpp b/Extras/FCollada/FUtils/FUDaeWriter.cpp deleted file mode 100644 index dd20f3713..000000000 --- a/Extras/FCollada/FUtils/FUDaeWriter.cpp +++ /dev/null @@ -1,351 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FUtils/FUDaeParser.h" -#include "FUtils/FUDaeWriter.h" -using namespace FUDaeParser; - -#define FLOAT_STR_ESTIMATE 12 - -namespace FUDaeWriter -{ - // List of common accessor types - const char* FUDaeAccessor::XYZW[] = { "X", "Y", "Z", "W", 0 }; - const char* FUDaeAccessor::RGBA[] = { "R", "G", "B", "A", 0 }; - const char* FUDaeAccessor::STPQ[] = { "S", "T", "P", "Q", 0 }; - - // Write out the element unto the given parent xml tree node. - // Check for only one element for this profile. - xmlNode* AddExtraTechniqueChild(xmlNode* parent, const char* profile) - { - xmlNode* techniqueNode = NULL; - if (parent != NULL) - { - xmlNode* extraNode = AddChildOnce(parent, DAE_EXTRA_ELEMENT); - techniqueNode = AddTechniqueChild(extraNode, profile); - } - return techniqueNode; - } - - // Write out the element unto the given parent xml tree node. - // Check for only one element for this profile. - xmlNode* AddTechniqueChild(xmlNode* parent, const char* profile) - { - xmlNode* techniqueNode = NULL; - if (parent != NULL) - { - techniqueNode = FindTechnique(parent, profile); - if (techniqueNode == NULL) - { - techniqueNode = AddChild(parent, DAE_TECHNIQUE_ELEMENT); - AddAttribute(techniqueNode, DAE_PROFILE_ATTRIBUTE, profile); - } - } - return techniqueNode; - } - - xmlNode* AddParameter(xmlNode* parent, const char* name, const char* type) - { - xmlNode* parameterNode = AddChild(parent, DAE_PARAMETER_ELEMENT); - if (name != NULL) AddAttribute(parameterNode, DAE_NAME_ATTRIBUTE, name); - if (type == NULL) type = DAE_FLOAT_TYPE; - AddAttribute(parameterNode, DAE_TYPE_ATTRIBUTE, type); - return parameterNode; - } - - xmlNode* AddInput(xmlNode* parent, const char* sourceId, const char* semantic, int32 offset, int32 set) - { - if (sourceId == NULL || *sourceId == 0 || semantic == NULL || *semantic == 0) return NULL; - xmlNode* inputNode = AddChild(parent, DAE_INPUT_ELEMENT); - AddAttribute(inputNode, DAE_SEMANTIC_ATTRIBUTE, semantic); - AddAttribute(inputNode, DAE_SOURCE_ATTRIBUTE, string("#") + sourceId); - if (offset >= 0) AddAttribute(inputNode, DAE_OFFSET_ATTRIBUTE, offset); - if (set >= 0) AddAttribute(inputNode, DAE_SET_ATTRIBUTE, set); - return inputNode; - } - - xmlNode* AddArray(xmlNode* parent, const char* id, const char* arrayType, const char* content, size_t count) - { - xmlNode* arrayNode = AddChild(parent, arrayType, content); - AddAttribute(arrayNode, DAE_ID_ATTRIBUTE, id); - AddAttribute(arrayNode, DAE_COUNT_ATTRIBUTE, count); - return arrayNode; - } - - xmlNode* AddArray(xmlNode* parent, const char* id, const FMVector3List& values, float lengthFactor) - { - // Reserve the necessary space within the string builder - globalSBuilder.clear(); - size_t valueCount = values.size(); - globalSBuilder.reserve(valueCount * 3 * FLOAT_STR_ESTIMATE); - if (valueCount > 0) - { - // Write out the values - FMVector3List::const_iterator itP = values.begin(); - FUStringConversion::ToString(globalSBuilder, *itP, lengthFactor); - for (++itP; itP != values.end(); ++itP) { globalSBuilder.append(' '); FUStringConversion::ToString(globalSBuilder, *itP, lengthFactor); } - } - - // Create the typed array node. - return AddArray(parent, id, DAE_FLOAT_ARRAY_ELEMENT, globalSBuilder.ToCharPtr(), valueCount * 3); - } - - xmlNode* AddArray(xmlNode* parent, const char* id, const FMMatrix44List& values, float lengthFactor) - { - globalSBuilder.clear(); - size_t valueCount = values.size(); - globalSBuilder.reserve(valueCount * 16 * FLOAT_STR_ESTIMATE); - if (valueCount > 0) - { - FMMatrix44List::const_iterator itM = values.begin(); - FUStringConversion::ToString(globalSBuilder, *itM, lengthFactor); - for (++itM; itM != values.end(); ++itM) { globalSBuilder.append(' '); FUStringConversion::ToString(globalSBuilder, *itM, lengthFactor); } - } - return AddArray(parent, id, DAE_FLOAT_ARRAY_ELEMENT, globalSBuilder.ToCharPtr(), valueCount * 16); - } - - xmlNode* AddArray(xmlNode* parent, const char* id, const FloatList& values, float lengthFactor) - { - size_t valueCount = values.size(); - globalSBuilder.clear(); - globalSBuilder.reserve(valueCount * FLOAT_STR_ESTIMATE); - FUStringConversion::ToString(globalSBuilder, values, lengthFactor); - return AddArray(parent, id, DAE_FLOAT_ARRAY_ELEMENT, globalSBuilder.ToCharPtr(), valueCount); - } - - xmlNode* AddArray(xmlNode* parent, const char* id, const StringList& values, const char* arrayType) - { - size_t valueCount = values.size(); - globalSBuilder.reserve(valueCount * 18); // Pulled out of a hat - globalSBuilder.clear(); - if (valueCount > 0) - { - StringList::const_iterator itV = values.begin(); - globalSBuilder.set(*itV); - for (++itV; itV != values.end(); ++itV) { globalSBuilder.append(' '); globalSBuilder.append(*itV); } - } - return AddArray(parent, id, arrayType, globalSBuilder.ToCharPtr(), valueCount); - } - - xmlNode* AddAccessor(xmlNode* parent, const char* arrayId, size_t count, size_t stride, const char** parameters, const char* type) - { - // Create the accessor element and fill its basic properties - xmlNode* accessorNode = AddChild(parent, DAE_ACCESSOR_ELEMENT); - AddAttribute(accessorNode, DAE_SOURCE_ATTRIBUTE, string("#") + arrayId); - AddAttribute(accessorNode, DAE_COUNT_ATTRIBUTE, count); - AddAttribute(accessorNode, DAE_STRIDE_ATTRIBUTE, stride); - - // Create the stride parameters - if (type == NULL) type = DAE_FLOAT_TYPE; - if (!IsEquivalent(type, DAE_MATRIX_TYPE)) - { - size_t p = 0; - for (size_t i = 0; i < stride; ++i) - { - const char* parameter = NULL; - if (parameters != NULL) - { - parameter = parameters[p++]; - if (parameter == NULL) { parameter = parameters[0]; p = 0; } - } - AddParameter(accessorNode, parameter, type); - } - } - else - { - const char* parameter = (parameters != NULL) ? *parameters : NULL; - AddParameter(accessorNode, parameter, type); - } - return accessorNode; - } - - xmlNode* AddSourceMatrix(xmlNode* parent, const char* id, const FMMatrix44List& values, float lengthFactor) - { - xmlNode* sourceNode = AddChild(parent, DAE_SOURCE_ELEMENT); - AddAttribute(sourceNode, DAE_ID_ATTRIBUTE, id); - FUSStringBuilder arrayId(id); arrayId.append("-array"); - AddArray(sourceNode, arrayId.ToCharPtr(), values, lengthFactor); - xmlNode* techniqueCommonNode = AddChild(sourceNode, DAE_TECHNIQUE_COMMON_ELEMENT); - AddAccessor(techniqueCommonNode, arrayId.ToCharPtr(), values.size(), 16, NULL, DAE_MATRIX_TYPE); - return sourceNode; - } - - xmlNode* AddSourceColor(xmlNode* parent, const char* id, const FMVector3List& values) - { - xmlNode* sourceNode = AddChild(parent, DAE_SOURCE_ELEMENT); - AddAttribute(sourceNode, DAE_ID_ATTRIBUTE, id); - FUSStringBuilder arrayId(id); arrayId.append("-array"); - AddArray(sourceNode, arrayId.ToCharPtr(), values); - xmlNode* techniqueCommonNode = AddChild(sourceNode, DAE_TECHNIQUE_COMMON_ELEMENT); - AddAccessor(techniqueCommonNode, arrayId.ToCharPtr(), values.size(), 3, FUDaeAccessor::RGBA, DAE_FLOAT_TYPE); - return sourceNode; - } - - xmlNode* AddSourceTexcoord(xmlNode* parent, const char* id, const FMVector3List& values) - { - xmlNode* sourceNode = AddChild(parent, DAE_SOURCE_ELEMENT); - AddAttribute(sourceNode, DAE_ID_ATTRIBUTE, id); - FUSStringBuilder arrayId(id); arrayId.append("-array"); - AddArray(sourceNode, arrayId.ToCharPtr(), values); - xmlNode* techniqueCommonNode = AddChild(sourceNode, DAE_TECHNIQUE_COMMON_ELEMENT); - AddAccessor(techniqueCommonNode, arrayId.ToCharPtr(), values.size(), 3, FUDaeAccessor::STPQ, DAE_FLOAT_TYPE); - return sourceNode; - } - - xmlNode* AddSourcePosition(xmlNode* parent, const char* id, const FMVector3List& values, float lengthFactor) - { - xmlNode* sourceNode = AddChild(parent, DAE_SOURCE_ELEMENT); - AddAttribute(sourceNode, DAE_ID_ATTRIBUTE, id); - FUSStringBuilder arrayId(id); arrayId.append("-array"); - AddArray(sourceNode, arrayId.ToCharPtr(), values, lengthFactor); - xmlNode* techniqueCommonNode = AddChild(sourceNode, DAE_TECHNIQUE_COMMON_ELEMENT); - AddAccessor(techniqueCommonNode, arrayId.ToCharPtr(), values.size(), 3, FUDaeAccessor::XYZW, DAE_FLOAT_TYPE); - return sourceNode; - } - - xmlNode* AddSourceFloat(xmlNode* parent, const char* id, const FloatList& values, const char* parameter, float lengthFactor) - { return AddSourceFloat(parent, id, values, 1, ¶meter, lengthFactor); } - xmlNode* AddSourceFloat(xmlNode* parent, const char* id, const FloatList& values, size_t stride, const char** parameters, float lengthFactor) - { - xmlNode* sourceNode = AddChild(parent, DAE_SOURCE_ELEMENT); - AddAttribute(sourceNode, DAE_ID_ATTRIBUTE, id); - FUSStringBuilder arrayId(id); arrayId.append("-array"); - AddArray(sourceNode, arrayId.ToCharPtr(), values, lengthFactor); - xmlNode* techniqueCommonNode = AddChild(sourceNode, DAE_TECHNIQUE_COMMON_ELEMENT); - if (stride == 0) stride = 1; - AddAccessor(techniqueCommonNode, arrayId.ToCharPtr(), values.size() / stride, stride, parameters, DAE_FLOAT_TYPE); - return sourceNode; - } - - xmlNode* AddSourceString(xmlNode* parent, const char* id, const StringList& values, const char* parameter) - { - xmlNode* sourceNode = AddChild(parent, DAE_SOURCE_ELEMENT); - AddAttribute(sourceNode, DAE_ID_ATTRIBUTE, id); - FUSStringBuilder arrayId(id); arrayId.append("-array"); - AddArray(sourceNode, arrayId.ToCharPtr(), values, DAE_NAME_ARRAY_ELEMENT); - xmlNode* techniqueCommonNode = AddChild(sourceNode, DAE_TECHNIQUE_COMMON_ELEMENT); - AddAccessor(techniqueCommonNode, arrayId.ToCharPtr(), values.size(), 1, ¶meter, DAE_NAME_TYPE); - return sourceNode; - } - - xmlNode* AddSourceIDRef(xmlNode* parent, const char* id, const StringList& values, const char* parameter) - { - xmlNode* sourceNode = AddChild(parent, DAE_SOURCE_ELEMENT); - AddAttribute(sourceNode, DAE_ID_ATTRIBUTE, id); - FUSStringBuilder arrayId(id); arrayId.append("-array"); - AddArray(sourceNode, arrayId.ToCharPtr(), values, DAE_IDREF_ARRAY_ELEMENT); - xmlNode* techniqueCommonNode = AddChild(sourceNode, DAE_TECHNIQUE_COMMON_ELEMENT); - AddAccessor(techniqueCommonNode, arrayId.ToCharPtr(), values.size(), 1, ¶meter, DAE_IDREF_TYPE); - return sourceNode; - } - - xmlNode* AddSourceInterpolation(xmlNode* parent, const char* id, const FUDaeInterpolationList& interpolations) - { - xmlNode* sourceNode = AddChild(parent, DAE_SOURCE_ELEMENT); - AddAttribute(sourceNode, DAE_ID_ATTRIBUTE, id); - FUSStringBuilder arrayId(id); arrayId.append("-array"); - - globalSBuilder.clear(); - size_t valueCount = interpolations.size(); - if (valueCount > 0) - { - FUDaeInterpolationList::const_iterator itI = interpolations.begin(); - globalSBuilder.append(FUDaeInterpolation::ToString(*itI)); - for (++itI; itI != interpolations.end(); ++itI) - { - globalSBuilder.append(' '); globalSBuilder.append(FUDaeInterpolation::ToString(*itI)); - } - } - AddArray(sourceNode, arrayId.ToCharPtr(), DAE_NAME_ARRAY_ELEMENT, globalSBuilder.ToCharPtr(), valueCount); - xmlNode* techniqueCommonNode = AddChild(sourceNode, DAE_TECHNIQUE_COMMON_ELEMENT); - const char* parameter = "INTERPOLATION"; - AddAccessor(techniqueCommonNode, arrayId.ToCharPtr(), valueCount, 1, ¶meter, DAE_NAME_TYPE); - return sourceNode; - } - - // Clean-up the id and names to match the schema definitions of 'IDref' and 'Name'. - string CleanId(const char* c) - { - globalSBuilder.clear(); - if (*c != 0) - { - // First character: alphabetic or '_'. - if ((*c >= 'a' && *c <= 'z') || (*c >= 'A' && *c <= 'Z') || *c == '_') globalSBuilder += *c; - else globalSBuilder += '_'; - - // Other characters: alphabetic, numeric or '_'. - // Otherwise, use HTML extended character write-up: &#; - for (++c; *c != 0; ++c) - { - if ((*c >= 'a' && *c <= 'z') || (*c >= 'A' && *c <= 'Z') || (*c >= '0' && *c <= '9') || *c == '_' || *c == '-') globalSBuilder += *c; - else globalSBuilder += '_'; - } - } - return globalSBuilder.ToString(); - } - - fstring CleanName(const fchar* c) - { - globalBuilder.clear(); - if (*c != 0) - { - // First character: alphabetic, '_' or ':'. - if ((*c >= 'a' && *c <= 'z') || (*c >= 'A' && *c <= 'Z') || *c == '_' || *c == ':') globalBuilder += *c; - else globalBuilder += '_'; - - // Other characters: alphabetic, numeric, '_', ':', '-' or '.'. - // Otherwise, use HTML extended character write-up: &#; - for (++c; *c != 0; ++c) - { - if ((*c >= 'a' && *c <= 'z') || (*c >= 'A' && *c <= 'Z') || (*c >= '0' && *c <= '9') || *c == '_' || *c == ':' || *c == '-' || *c == '.') globalBuilder += *c; - else { globalBuilder += '%'; globalBuilder += (uint32) *c; } - } - } - return globalBuilder.ToString(); - } - - // Add an 'sid' attribute to the given xml node, ensuring unicity. Returns the final 'sid' value. - FCOLLADA_EXPORT string AddNodeSid(xmlNode* node, const char* wantedSid) - { - // Find the first parent node with an id or sid. If this node has an id, return right away. - xmlNode* parentNode = node; - for (parentNode = node; parentNode != NULL; parentNode = parentNode->parent) - { - if (HasNodeProperty(parentNode, DAE_ID_ATTRIBUTE) || HasNodeProperty(parentNode, DAE_SID_ATTRIBUTE)) break; - } - if (parentNode == node) - { - if (!HasNodeProperty(parentNode, DAE_SID_ATTRIBUTE)) AddAttribute(node, DAE_SID_ATTRIBUTE, wantedSid); - return wantedSid; - } - if (parentNode == NULL) - { - // Retrieve the last parent node available - for (parentNode = node; parentNode->parent != NULL; parentNode = parentNode->parent) {} - } - - // Check the wanted sid for unicity - xmlNode* existingNode = FindHierarchyChildBySid(parentNode, wantedSid); - if (existingNode == NULL) - { - AddAttribute(node, DAE_SID_ATTRIBUTE, wantedSid); - return wantedSid; - } - - // Generate new sids with an incremental counter. - for (uint32 counter = 2; counter < 100; ++counter) - { - globalSBuilder.set(wantedSid); globalSBuilder.append(counter); - existingNode = FindHierarchyChildBySid(parentNode, globalSBuilder.ToCharPtr()); - if (existingNode == NULL) - { - AddAttribute(node, DAE_SID_ATTRIBUTE, globalSBuilder); - return globalSBuilder.ToString(); - } - } - return string(""); - } -}; diff --git a/Extras/FCollada/FUtils/FUDaeWriter.h b/Extras/FCollada/FUtils/FUDaeWriter.h deleted file mode 100644 index e8d7a8adb..000000000 --- a/Extras/FCollada/FUtils/FUDaeWriter.h +++ /dev/null @@ -1,263 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FUDaeWriter.h - This file contains the FUDaeWriter namespace. -*/ - -#ifndef _FU_DAE_WRITER_H_ -#define _FU_DAE_WRITER_H_ - -#ifdef HAS_LIBXML - -#include "FUtils/FUDaeEnum.h" -#include "FUtils/FUDaeSyntax.h" -#include "FUtils/FUUri.h" -#include "FUtils/FUXmlWriter.h" - -/** - Common COLLADA XML writing functions. - Based on top of the FUXmlWriter namespace and the LibXML2 library. - This whole namespace is considered external and should only be used - by the FCollada library. - - @ingroup FUtils -*/ -namespace FUDaeWriter -{ - using namespace FUXmlWriter; - - /** Common accessor type string arrays. - These are NULL-terminated and can be used with the AddAccessor function. */ - struct FCOLLADA_EXPORT FUDaeAccessor - { - static const char* XYZW[]; /**< Use for vector and position sources. */ - static const char* RGBA[]; /**< Use for color sources. */ - static const char* STPQ[]; /**< Use for texture coordinate sources. */ - }; - - /** Writes out the \\ element unto the given parent xml tree node. - This function ensures that only one \ element exists and that only - one \ element exists for the given profile. - @param parent The parent XML tree node. - @param profile The application-specific profile name. - @return The \ XML tree node. */ - FCOLLADA_EXPORT xmlNode* AddExtraTechniqueChild(xmlNode* parent, const char* profile); - - /** Writes out the \ element unto the given parent xml tree node. - This function ensures that only one \ element exists for the given profile. - @param parent The parent XML tree node. - @param profile The application-specific profile name. - @return The \ XML tree node. */ - FCOLLADA_EXPORT xmlNode* AddTechniqueChild(xmlNode* parent, const char* profile); - - /** Writes out a COLLADA parameter element. - This is used for the source accessors. - A COLLADA parameter has the form: \value\. - @param parent The parent XML tree node. - @param name The name attribute value. - @param type The type attribute value. - @return The created \ XML tree node. */ - FCOLLADA_EXPORT xmlNode* AddParameter(xmlNode* parent, const char* name, const char* type); - - /** Writes out a COLLADA input element. - This is a very common element. For example, it is used in - the \, \ and \ elements. - A COLLADA input has the form: \. - @param parent The parent XML tree node. - @param sourceId The source attribute value. - This is the COLLADA id of a valid \ element. - @param semantic The semantic attribute value. - This is a valid COLLADA semantic. - For example: POSITION, TEXCOORD, WEIGHT, IN_TANGENT. - @param offset The optional offset attribute value. - When used in conjunction with the \ or the \ elements, this is - the offset for the input data indices within the interleaved indices. - @param set The optional set attribute value. - This unsigned integer is used to tied together multiple inputs. - @return The created \ XML tree node. */ - FCOLLADA_EXPORT xmlNode* AddInput(xmlNode* parent, const char* sourceId, const char* semantic, int32 offset=-1, int32 set=-1); - inline xmlNode* AddInput(xmlNode* parent, const string& sourceId, const char* semantic, int32 offset=-1, int32 set=-1) { return AddInput(parent, sourceId.c_str(), semantic, offset, set); } /**< See above. */ - - /** Writes out a COLLADA strongly-typed data array. - To write out data values, it is preferable to use the AddSourceX functions. - @param parent The parent XML tree node. - @param id The COLLADA id of the array. - This id is used only by the accessor of a source. - @param arrayType The strongly-typed name of the array. - For example: \, \. - @param content The array content. - @param count The number of entries within the content of the array. - @return The created XML tree node. */ - FCOLLADA_EXPORT xmlNode* AddArray(xmlNode* parent, const char* id, const char* arrayType, const char* content, size_t count); - - /** Writes out a COLLADA array of matrices. - To write out data values, it is preferable to use the AddSourceX functions. - @param parent The parent XML tree node. - @param id The COLLADA id of the array. - This id is used only by the accessor of a source. - @param values A list of matrices. - @param lengthFactor An optional scale factor for - the translation column of the matrices. - @return The created XML tree node. */ - FCOLLADA_EXPORT xmlNode* AddArray(xmlNode* parent, const char* id, const FMMatrix44List& values, float lengthFactor=1.0f); - - /** Writes out a COLLADA array of 3D vectors. - To write out data values, it is preferable to use the AddSourceX functions. - @param parent The parent XML tree node. - @param id The COLLADA id of the array. - This id is used only by the accessor of a source. - @param values A list of 3D vectors. - @param lengthFactor An optional scale factor for all the 3D vectors. - @return The created XML tree node. */ - FCOLLADA_EXPORT xmlNode* AddArray(xmlNode* parent, const char* id, const FMVector3List& values, float lengthFactor=1.0f); - - /** Writes out a COLLADA array of floating-point values. - To write out data values, it is preferable to use the AddSourceX functions. - @param parent The parent XML tree node. - @param id The COLLADA id of the array. - This id is used only by the accessor of a source. - @param values A list of floating-point values. - @param lengthFactor An optional scale factor for all the floating-point values. - @return The created XML tree node. */ - FCOLLADA_EXPORT xmlNode* AddArray(xmlNode* parent, const char* id, const FloatList& values, float lengthFactor=1.0f); - - /** Writes out a COLLADA array of UTF-8 tokens. - To write out data values, it is preferable to use the AddSourceX functions. - @param parent The parent XML tree node. - @param id The COLLADA id of the array. - This id is used only by the accessor of a source. - @param values A list of UTF-8 tokens. The members of this list will appear - space-separated within the COLLADA document. - @param arrayType The COLLADA element name for the output array. - Defaults to \. This might also be \. - @return The created XML tree node. */ - FCOLLADA_EXPORT xmlNode* AddArray(xmlNode* parent, const char* id, const StringList& values, const char* arrayType=DAE_NAME_ARRAY_ELEMENT); - - /** Writes out a COLLADA accessor to be used within a source. - This function should really be called only from within AddSourceX functions. - @param parent The parent XML tree node. - @param arrayId The COLLADA id of the array. - @param count The number of complete elements within the array. - @param stride The number of values that should be used together to create one array element. - @param parameters The list of parameter names. - Some valid parameter names are available in the FUDaeAccessor class. - @param type The type name of the parameters. Examples: float, float4x4, Name or IDRef. - @return The created XML tree node. */ - FCOLLADA_EXPORT xmlNode* AddAccessor(xmlNode* parent, const char* arrayId, size_t count, size_t stride=1, const char** parameters=NULL, const char* type=NULL); - inline xmlNode* AddAccessor(xmlNode* parent, const string& arrayId, size_t count, size_t stride=1, const char** parameters=NULL, const char* type=NULL) { return AddAccessor(parent, arrayId.c_str(), count, stride, parameters, type); } /**< See above. */ - - /** Writes out a COLLADA multi-dimensional source of floating-point values. - @param parent The parent XML tree node. - @param id The COLLADA id of the source. - @param values The list of floating-point values. - @param stride The number of dimensions. This is the number of - floating-point values that should be used together to create one element. - @param parameters The list of accessor parameter names. - Some valid parameter names are available in the FUDaeAccessor class. - @param lengthFactor An optional scale factor for all the floating-point values. - @return The created XML tree node. */ - FCOLLADA_EXPORT xmlNode* AddSourceFloat(xmlNode* parent, const char* id, const FloatList& values, size_t stride=1, const char** parameters=NULL, float lengthFactor=1.0f); - inline xmlNode* AddSourceFloat(xmlNode* parent, const string& id, const FloatList& values, size_t stride=1, const char** parameters=NULL, float lengthFactor=1.0f) { return AddSourceFloat(parent, id.c_str(), values, stride, parameters, lengthFactor); } /**< See above. */ - - /** Writes out a COLLADA source of floating-point values. - @param parent The parent XML tree node. - @param id The COLLADA id of the source. - @param values The list of floating-point values. - @param parameter The accessor parameter name. - Some valid parameter names are available in the FUDaeAccessor class. - @param lengthFactor An optional scale factor for all the floating-point values. - @return The created XML tree node. */ - FCOLLADA_EXPORT xmlNode* AddSourceFloat(xmlNode* parent, const char* id, const FloatList& values, const char* parameter=NULL, float lengthFactor=1.0f); - inline xmlNode* AddSourceFloat(xmlNode* parent, const string& id, const FloatList& values, const char* parameter=NULL, float lengthFactor=1.0f) { return AddSourceFloat(parent, id.c_str(), values, parameter, lengthFactor); } /**< See above. */ - - /** Writes out a COLLADA source of matrices. - @param parent The parent XML tree node. - @param id The COLLADA id of the source. - @param values The list of matrices. - @param lengthFactor An optional scale factor for all the floating-point values. - @return The created XML tree node. */ - FCOLLADA_EXPORT xmlNode* AddSourceMatrix(xmlNode* parent, const char* id, const FMMatrix44List& values, float lengthFactor=1.0f); - inline xmlNode* AddSourceMatrix(xmlNode* parent, const string& id, const FMMatrix44List& values, float lengthFactor=1.0f) { return AddSourceMatrix(parent, id.c_str(), values, lengthFactor); } /**< See above. */ - - /** Writes out a COLLADA source of matrices. - @param parent The parent XML tree node. - @param id The COLLADA id of the source. - @param values The list of matrices. - @return The created XML tree node. */ - FCOLLADA_EXPORT xmlNode* AddSourceColor(xmlNode* parent, const char* id, const FMVector3List& values); - inline xmlNode* AddSourceColor(xmlNode* parent, const string& id, const FMVector3List& values) { return AddSourceColor(parent, id.c_str(), values); } /**< See above. */ - - /** Writes out a COLLADA source of texture coordinates. - @param parent The parent XML tree node. - @param id The COLLADA id of the source. - @param values The list of 3D texture coordinates. - @return The created XML tree node. */ - FCOLLADA_EXPORT xmlNode* AddSourceTexcoord(xmlNode* parent, const char* id, const FMVector3List& values); - inline xmlNode* AddSourceTexcoord(xmlNode* parent, const string& id, const FMVector3List& values) { return AddSourceTexcoord(parent, id.c_str(), values); } /**< See above. */ - - /** Writes out a COLLADA source of 3D positions or vectors. - @param parent The parent XML tree node. - @param id The COLLADA id of the source. - @param values The list of 3D vectors. - @param lengthFactor An optional scale factor for all the 3D vectors. - @return The created XML tree node. */ - FCOLLADA_EXPORT xmlNode* AddSourcePosition(xmlNode* parent, const char* id, const FMVector3List& values, float lengthFactor=1.0f); - inline xmlNode* AddSourcePosition(xmlNode* parent, const string& id, const FMVector3List& values, float lengthFactor=1.0f) { return AddSourcePosition(parent, id.c_str(), values, lengthFactor); } /**< See above. */ - - /** Writes out a COLLADA source of UTF-8 tokens. - @param parent The parent XML tree node. - @param id The COLLADA id of the source. - @param values The list of UTF-8 tokens. This list will be space- - separated within the COLLADA document, so you none of the - token should have spaces in them. - @param parameter The name of the accessor parameter. - @return The created XML tree node. */ - FCOLLADA_EXPORT xmlNode* AddSourceString(xmlNode* parent, const char* id, const StringList& values, const char* parameter=NULL); - inline xmlNode* AddSourceString(xmlNode* parent, const string& id, const StringList& values, const char* parameter=NULL) { return AddSourceString(parent, id.c_str(), values, parameter); } /**< See above. */ - - /** Writes out a COLLADA source of COLLADA references. - @param parent The parent XML tree node. - @param id The COLLADA id of the source. - @param values The list of COLLADA references. - @param parameter The name of the accessor parameter. - @return The created XML tree node. */ - FCOLLADA_EXPORT xmlNode* AddSourceIDRef(xmlNode* parent, const char* id, const StringList& values, const char* parameter=NULL); - inline xmlNode* AddSourceIDRef(xmlNode* parent, const string& id, const StringList& values, const char* parameter=NULL) { return AddSourceIDRef(parent, id.c_str(), values, parameter); } /**< See above. */ - - /** Writes out a COLLADA source of interpolation tokens. - This function is used within the export of animation curves. - @param parent The parent XML tree node. - @param id The COLLADA id of the source. - @param interpolations The list of interpolation tokens. - @return The created XML tree node. */ - FCOLLADA_EXPORT xmlNode* AddSourceInterpolation(xmlNode* parent, const char* id, const FUDaeInterpolationList& interpolations); - inline xmlNode* AddSourceInterpolation(xmlNode* parent, const string& id, const FUDaeInterpolationList& values) { return AddSourceInterpolation(parent, id.c_str(), values); } /**< See above. */ - - /** Cleans up a given name into a valid COLLADA id. - This function does no check for uniqueness. - @param id A name. - @return A valid COLLADA id. */ - FCOLLADA_EXPORT string CleanId(const char* id); - inline string CleanId(const string& id) { return CleanId(id.c_str()); } /**< See above. */ - - /** Cleans up a given name into a valid COLLADA name. - @param name A name. - @return A valid COLLADA name. */ - FCOLLADA_EXPORT fstring CleanName(const fchar* name); - inline fstring CleanName(const fstring& name) { return CleanName(name.c_str()); } /**< See above. */ - - /** Adds the 'sid' attribute to a given XML tree node. - The sub-id is verified to ensure uniqueness within the scope. - @param node The XML tree node. - @param wantedSid The wanted sub-id. - @return The actual sub-id written to the XML tree node. */ - FCOLLADA_EXPORT string AddNodeSid(xmlNode* node, const char* wantedSid); -}; - -#endif // HAS_LIBXML - -#endif // _FU_DAE_WRITER_H_ diff --git a/Extras/FCollada/FUtils/FUDateTime.cpp b/Extras/FCollada/FUtils/FUDateTime.cpp deleted file mode 100644 index 6f8a93273..000000000 --- a/Extras/FCollada/FUtils/FUDateTime.cpp +++ /dev/null @@ -1,51 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FUtils/FUDateTime.h" - -#include - -FUDateTime::FUDateTime(const FUDateTime& time) -{ - seconds = time.seconds; - minutes = time.minutes; - hour = time.hour; - day = time.day; - month = time.month; - year = time.year; -} - -FUDateTime::FUDateTime() -{ - seconds = minutes = hour = 0; - day = month = 1; - year = 1900; -} - -FUDateTime::~FUDateTime() -{ -} - -FUDateTime FUDateTime::GetNow() -{ - FUDateTime dateTime; - - // Get current UTC time - time_t currentTime; - - time(¤tTime); - tm* utcTime = gmtime(¤tTime); - - // Convert to our own data structure - dateTime.SetSeconds(utcTime->tm_sec); - dateTime.SetMinutes(utcTime->tm_min); - dateTime.SetHour(utcTime->tm_hour); - dateTime.SetDay(utcTime->tm_mday); - dateTime.SetMonth(utcTime->tm_mon + 1); - dateTime.SetYear(utcTime->tm_year + 1900); - - return dateTime; -} diff --git a/Extras/FCollada/FUtils/FUDateTime.h b/Extras/FCollada/FUtils/FUDateTime.h deleted file mode 100644 index ecfbb0ae8..000000000 --- a/Extras/FCollada/FUtils/FUDateTime.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - Copyright (C) 2006 Feeling Software Inc - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FUDateTime.h - This file contains the FUDateTime class. -*/ - -#ifndef _FU_DATETIME_H_ -#define _FU_DATETIME_H_ - -/** - A common date-time. - Encapsulates the OS-dependant timing functions. Use the static member function: GetNow() - to sample the current time. The day and month values are 1-indexed, to be user-friendly. - - @ingroup FUtils -*/ -class FCOLLADA_EXPORT FUDateTime -{ -private: - // To be more friendly, 'day' and 'month' are 1-indexed - uint32 seconds; - uint32 minutes; - uint32 hour; - uint32 day; - uint32 month; - uint32 year; - -public: - /** Default constructor. The default date-time is set to 01/01/1900 at 00:00:00. */ - FUDateTime(); - /** Copy constructor. Creates an identical clone of the given date-time structure. - @param time The date-time structure to copy. */ - FUDateTime(const FUDateTime& time); - /** Destructor. */ - ~FUDateTime(); - - /** Retrieves the seconds component of the date-time structure. - @returns The seconds component. The seconds component is always in the range [0, 60[. */ - inline uint32 GetSeconds() const { return seconds; } - /** Retrieves the minutes component of the date-time structure. - @returns The minutes component. The minutes component is always in the range [0, 60[. */ - inline uint32 GetMinutes() const { return minutes; } - /** Retrieves the hour component of the date-time structure. - @returns The hour component. The hour component is always in the range [0, 24[. */ - inline uint32 GetHour() const { return hour; } - /** Retrieves the day component of the date-time structure. - @returns The day component. The day component is 1-indexed and has an upper range - that depends on the month component. The valid range for the day component is [1, 31].*/ - inline uint32 GetDay() const { return day; } - /** Retrieves the month component of the date-time structure. - @returns The month component. The month component is 1-indexed and is always in the range [1, 12].*/ - inline uint32 GetMonth() const { return month; } - /** Retrieves the year component of the date-time structure. - @returns The year component. The year component represents the full year value, - where a value of 2000 is returned for the year 2000.*/ - inline uint32 GetYear() const { return year; } - - /** Sets the seconds component of the date-time structure. - @param _seconds The new seconds value. No verification is made - to verify that the new value is within the valid range. */ - inline void SetSeconds(uint32 _seconds) { seconds = _seconds; } - /** Sets the minutes component of the date-time structure. - @param _minutes The new seconds value. No verification is made - to verify that the new value is within the valid range. */ - inline void SetMinutes(uint32 _minutes) { minutes = _minutes; } - /** Sets the hour component of the date-time structure. - @param _hour The new seconds value. No verification is made - to verify that the new value is within the valid range. */ - inline void SetHour(uint32 _hour) { hour = _hour; } - /** Sets the day component of the date-time structure. - @param _day The new seconds value. No verification is made - to verify that the new value is within the valid range. */ - inline void SetDay(uint32 _day) { day = _day; } - /** Sets the month component of the date-time structure. - @param _month The new seconds value. No verification is made - to verify that the new value is within the valid range. */ - inline void SetMonth(uint32 _month) { month = _month; } - /** Sets the year component of the date-time structure. - @param _year The new seconds value. No verification is made - to verify that the new value is within the valid range. */ - inline void SetYear(uint32 _year) { year = _year; } - - /** Creates a date-time structure to represent the current time. - Encapsulates the OS-dependant time() function. - @return The current date-time. */ - static FUDateTime GetNow(); -}; - -#endif // _FU_DATETIME_H_ diff --git a/Extras/FCollada/FUtils/FUDebug.cpp b/Extras/FCollada/FUtils/FUDebug.cpp deleted file mode 100644 index c2d1527cb..000000000 --- a/Extras/FCollada/FUtils/FUDebug.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FUtils/FUDebug.h" -#include "FUtils/FUStringConversion.h" - -#ifdef _DEBUG - -#if defined(LINUX) || defined(MAC_TIGER) -#define STRING_OUT(sz) cerr << (sz) << endl -#elif defined(WIN32) -#define STRING_OUT(sz) OutputDebugString(sz); OutputDebugString(FC("\n")) -#endif - -static void DebugString(const fchar* message) -{ - STRING_OUT(message); -} - -#ifdef UNICODE -static void DebugString(const char* message) -{ - fstring str = TO_FSTRING(message); - DebugString(str.c_str()); -} -#endif // UNICODE - -void DebugOut(const char* filename, uint32 line, const char* message, ...) -{ - va_list vars; - va_start(vars, message); - DebugOutV(filename, line, message, vars); - va_end(vars); -} - -void DebugOut(const char* message, ...) -{ - va_list vars; - va_start(vars, message); - DebugOutV(message, vars); - va_end(vars); -} - -void DebugOutV(const char* filename, uint32 line, const char* message, va_list& vars) -{ - char buffer[256]; - snprintf(buffer, 256, "[%s@%lu] ", filename, line); - buffer[255] = 0; - DebugString(buffer); - - DebugOutV(message, vars); -} - -void DebugOutV(const char* message, va_list& vars) -{ - uint32 length = (uint32) strlen(message); - char* buffer = new char[length + 256]; - vsnprintf(buffer, length + 256, message, vars); - buffer[length + 255] = 0; - - DebugString(buffer); - SAFE_DELETE_ARRAY(buffer); -} - -#ifdef UNICODE -void DebugOut(const char* filename, uint32 line, const fchar* message, ...) -{ - va_list vars; - va_start(vars, message); - DebugOutV(filename, line, message, vars); - va_end(vars); -} - -void DebugOut(const fchar* message, ...) -{ - va_list vars; - va_start(vars, message); - DebugOutV(message, vars); - va_end(vars); -} - -void DebugOutV(const char* filename, uint32 line, const fchar* message, va_list& vars) -{ - char buffer[256]; - snprintf(buffer, 256, "[%s@%lu] ", filename, line); - buffer[255] = 0; - DebugString(buffer); - - DebugOutV(message, vars); -} - -void DebugOutV(const fchar* message, va_list& vars) -{ - uint32 length = (uint32) fstrlen(message); - fchar* buffer = new fchar[length + 256]; - fvsnprintf(buffer, length + 256, message, vars); - buffer[length + 255] = 0; - - DebugString(buffer); - SAFE_DELETE_ARRAY(buffer); -} -#endif // UNICODE -#endif // _DEBUG - diff --git a/Extras/FCollada/FUtils/FUDebug.h b/Extras/FCollada/FUtils/FUDebug.h deleted file mode 100644 index 5c5d14d31..000000000 --- a/Extras/FCollada/FUtils/FUDebug.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FUDebug.h - This file contains macros useful to write debugging output. -*/ - -#ifndef _FU_DEBUG_H_ -#define _FU_DEBUG_H_ - -/** Outputs a string to the debug monitor. - @param token The string to output. */ -#define DEBUG_OUT(token) ::DebugOut(__FILE__, __LINE__, token); - -/** Outputs a string to the debug monitor. - @param token The formatted string to output. - @param arg1 A first argument. */ -#define DEBUG_OUT1(token, arg1) ::DebugOut(__FILE__, __LINE__, token, arg1); - -/** Outputs a string to the debug monitor. - @param token The formatted string to output. - @param arg1 A first argument. - @param arg2 A second argument. */ -#define DEBUG_OUT2(token, arg1, arg2) ::DebugOut(__FILE__, __LINE__, token, arg1, arg2); - -#ifndef _DEBUG - - /** Outputs a string to the debug monitor. - The formatted message is the first parameter. */ - inline void DebugOut(const char*, ...) {} -#ifdef UNICODE - inline void DebugOut(const fchar*, ...) {} /**< See above. */ -#endif // UNICODE - - /** Outputs a string to the debug monitor. - The formatted message is the first parameter. - The second parameter is the variable parmeter list. */ - inline void DebugOutV(const char*, va_list&) {} -#ifdef UNICODE - inline void DebugOutV(const fchar*, va_list&) {} /**< See above. */ -#endif // UNICODE - - /** Outputs a string to the debug monitor. - The filename and line number are the first two parameters. - The formatted message is the third parameter. */ - inline void DebugOut(const char*, uint32, const char*, ...) {} -#ifdef UNICODE - inline void DebugOut(const char*, uint32, const fchar*, ...) {} /**< See above. */ -#endif // UNICODE - - /** Outputs a string to the debug monitor. - The filename and line number are the first two parameters. - The formatted message is the third parameter. - The fourth parameter is the variable parameter list. */ - inline void DebugOutV(const char*, uint32, const char*, va_list&) {} -#ifdef UNICODE - inline void DebugOutV(const char*, uint32, const fchar*, va_list&) {} /**< See above. */ -#endif // UNICODE - -#else // _DEBUG - -#ifdef UNICODE - void FCOLLADA_EXPORT DebugOut(const char* filename, uint32 line, const fchar* message, ...); - void FCOLLADA_EXPORT DebugOut(const fchar* message, ...); - void FCOLLADA_EXPORT DebugOutV(const char* filename, uint32 line, const fchar* message, va_list& vars); - void FCOLLADA_EXPORT DebugOutV(const fchar* message, va_list& vars); -#endif // UNICODE - void FCOLLADA_EXPORT DebugOut(const char* filename, uint32 line, const char* message, ...); - void FCOLLADA_EXPORT DebugOut(const char* message, ...); - void FCOLLADA_EXPORT DebugOutV(const char* filename, uint32 line, const char* message, va_list& vars); - void FCOLLADA_EXPORT DebugOutV(const char* message, va_list& vars); - -#endif // _DEBUG - -#endif // _FU_DEBUG_H_ - diff --git a/Extras/FCollada/FUtils/FUEvent.h b/Extras/FCollada/FUtils/FUEvent.h deleted file mode 100644 index 1310dde36..000000000 --- a/Extras/FCollada/FUtils/FUEvent.h +++ /dev/null @@ -1,167 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - This file was taken off the Protect project on 26-09-2005 -*/ - - -#ifndef _EVENT_H_ -#define _EVENT_H_ - -// Zero argument Event -class FUEvent0 -{ -private: - typedef IFunctor0 THandler; - typedef vector THandlerList; - THandlerList m_xHandlers; - -public: - FUEvent0() {} - ~FUEvent0() - { - CLEAR_POINTER_VECTOR(m_xHandlers); - } - - size_t GetHandlerCount() { return m_xHandlers.size(); } - - void InsertHandler(THandler* pFunctor) - { - m_xHandlers.push_back(pFunctor); - } - - void RemoveHandler(void* pObject, void* pFunction) - { - THandlerList::iterator it; - for (it = m_xHandlers.begin(); it != m_xHandlers.end(); ++it) - { - if ((*it)->Compare(pObject, pFunction)) - { - delete (*it); - m_xHandlers.erase(it); - break; - } - } - } - - void operator()() - { - THandlerList::iterator it; - for (it = m_xHandlers.begin(); it != m_xHandlers.end(); ++it) - { - (*(*it))(); - } - } -}; - -// One argument Event -template -class FUEvent1 -{ -private: - typedef IFunctor1 THandler; - typedef vector THandlerList; - THandlerList m_xHandlers; - -public: - FUEvent1() {} - - ~FUEvent1() - { - assert(m_xHandlers.empty()); - } - - size_t GetHandlerCount() { return m_xHandlers.size(); } - - void InsertHandler(THandler* pFunctor) - { - m_xHandlers.push_back(pFunctor); - } - - void RemoveHandler(void* pObject, void* pFunction) - { - typename THandlerList::iterator it; - for (it = m_xHandlers.begin(); it != m_xHandlers.end(); ++it) - { - if ((*it)->Compare(pObject, pFunction)) - { - delete (*it); - m_xHandlers.erase(it); - break; - } - } - } - - void operator()(Arg1 sArgument1) - { - typename THandlerList::iterator it; - for (it = m_xHandlers.begin(); it != m_xHandlers.end(); ++it) - { - (*(*it))(sArgument1); - } - } -}; - -// Two arguments Event -template -class FUEvent2 -{ -private: - typedef IFunctor2 THandler; - typedef vector THandlerList; - THandlerList m_xHandlers; - -public: - FUEvent2() {} - - ~FUEvent2() - { - assert(m_xHandlers.empty()); - } - - size_t GetHandlerCount() { return m_xHandlers.size(); } - - void InsertHandler(THandler* pFunctor) - { - m_xHandlers.push_back(pFunctor); - } - - void RemoveHandler(void* pObject, void* pFunction) - { - typename THandlerList::iterator it; - for (it = m_xHandlers.begin(); it != m_xHandlers.end(); ++it) - { - if ((*it)->Compare(pObject, pFunction)) - { - delete (*it); - m_xHandlers.erase(it); - break; - } - } - } - - void operator()(Arg1 sArgument1, Arg2 sArgument2) - { - typename THandlerList::iterator it; - for (it = m_xHandlers.begin(); it != m_xHandlers.end(); ++it) - { - (*(*it))(sArgument1, sArgument2); - } - } -}; - -// Macro for member function pointer type bypass -template -class FURemoveHandler0 -{ -public: - void operator() (FUEvent0* event, Class* pObject, void (Class::*pFunction)(void)) - { - void* pVoid = *(void**)&pFunction; - event->RemoveHandler(pObject, pVoid); - } -}; - -#endif // _EVENT_H_ diff --git a/Extras/FCollada/FUtils/FUFile.cpp b/Extras/FCollada/FUtils/FUFile.cpp deleted file mode 100644 index f57d13f18..000000000 --- a/Extras/FCollada/FUtils/FUFile.cpp +++ /dev/null @@ -1,75 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FUtils/FUFile.h" - -FUFile::FUFile(const char* filename, Mode mode) -{ - const char* openMode; - switch (mode) - { - case READ: openMode = "rb"; break; - case WRITE: openMode = "wb"; break; - default: openMode = "rb"; break; - } - - filePtr = fopen(filename, openMode); -} - -FUFile::FUFile() -{ - filePtr = NULL; -} - -FUFile::~FUFile() -{ - if (filePtr != NULL) - { - Close(); - } -} - -// Retrieve the file length -uint32 FUFile::GetLength() -{ - FUAssert(IsOpen(), return 0); - - uint32 currentPosition = ftell(filePtr); - if (fseek(filePtr, 0, SEEK_END) != 0) return 0; - - uint32 length = ftell(filePtr); - if (fseek(filePtr, currentPosition, SEEK_SET) != 0) return 0; - - return length; -} - -// Reads in a piece of the file into the given buffer -bool FUFile::Read(void* buffer, size_t length) -{ - FUAssert(IsOpen(), return false); - return fread(buffer, length, 1, filePtr) == 1; -} - -// Write out some data to a file -bool FUFile::Write(const void* buffer, size_t length) -{ - FUAssert(IsOpen(), return false); - return fwrite(buffer, length, 1, filePtr) == 1; -} - -// Flush/close the file stream -void FUFile::Flush() -{ - FUAssert(IsOpen(), ); - fflush(filePtr); -} - -void FUFile::Close() -{ - FUAssert(IsOpen(), ); - fclose(filePtr); - filePtr = NULL; -} diff --git a/Extras/FCollada/FUtils/FUFile.h b/Extras/FCollada/FUtils/FUFile.h deleted file mode 100644 index 4d656c1ef..000000000 --- a/Extras/FCollada/FUtils/FUFile.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _FU_FILE_H_ -#define _FU_FILE_H_ - -class FCOLLADA_EXPORT FUFile -{ -public: - enum Mode - { - READ, - WRITE - }; - -private: - FILE* filePtr; - -public: - FUFile(const char* filename, Mode mode); - FUFile(); - ~FUFile(); - - bool IsOpen() { return filePtr != NULL; } - - // Retrieve the file length - uint32 GetLength(); - - // Writes/Reads in a piece of the file from/into the given buffer - bool Read(void* buffer, size_t length); - bool Write(const void* buffer, size_t length); - - // Flush/close the file stream - void Flush(); - void Close(); -}; - -#endif // _FU_FILE_H_ diff --git a/Extras/FCollada/FUtils/FUFileManager.cpp b/Extras/FCollada/FUtils/FUFileManager.cpp deleted file mode 100644 index 82a7f62ab..000000000 --- a/Extras/FCollada/FUtils/FUFileManager.cpp +++ /dev/null @@ -1,305 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FUtils/FUFile.h" -#include "FUtils/FUFileManager.h" -#include "FUtils/FUStringConversion.h" - -#if defined(WIN32) - #include -#endif - -FUFileManager::FUFileManager() -{ - // Push on the stack the original root path - char fullPath[MAX_PATH]; - getcwd(fullPath, MAX_PATH); - pathStack.push_back(TO_FSTRING(fullPath)); -} - -FUFileManager::~FUFileManager() -{ -} - -// Set a new root path -void FUFileManager::PushRootPath(const fstring& path) -{ - // Ensure that the new root path is an absolute root path. - fstring absolutePath = MakeFilePathAbsolute(path); - pathStack.push_back(absolutePath); - fchdir(path.c_str()); -} - -// Go back to the previous root path -void FUFileManager::PopRootPath() -{ - if (pathStack.size() > 1) - { - pathStack.pop_back(); - fchdir(pathStack.back().c_str()); - } -} - -// Set the current path root, using a known filename -void FUFileManager::PushRootFile(const fstring& filename) -{ - // Strip the filename of the actual file's name - fstring path = StripFileFromPath(filename); - PushRootPath(path); -} - -void FUFileManager::PopRootFile() -{ - PopRootPath(); -} - -// Open a file to read -FUFile* FUFileManager::OpenFile(const fstring& filename, bool write) -{ - fstring absoluteFilename = MakeFilePathAbsolute(filename); - string dumpFilename = FUStringConversion::ToString(absoluteFilename); - return new FUFile(dumpFilename.c_str(), write ? FUFile::WRITE : FUFile::READ); -} - -// Massage a given filename to be absolute -fstring FUFileManager::GetFilePath(const fstring& fileURL) -{ - // Strip any prefix - fstring filename = fileURL; - std::replace(filename.begin(), filename.end(), '\\', '/'); - if (filename.size() > 7 && filename.substr(0, 7) == FC("file://")) - { - filename = filename.c_str() + 7; - - if (filename.size() > 3 && filename[0] == '/' && (filename[2] == ':' || filename[2] == '|')) - { - filename = filename.c_str() + 1; - } - - if (filename[1] == '|') filename[1] = ':'; - } - - // Replace any '%' character string into the wanted characters: %20 is common. - for (size_t pos = filename.find('%'); pos != fstring::npos; pos = filename.find('%')) - { - const fchar* pc = filename.c_str() + pos + 1; // +1 to skip/erase the '%' character - uint32 value = FUStringConversion::HexToUInt32(&pc, 2); - size_t count = (pc - filename.c_str()) - pos; - filename.erase(pos, count); - filename.insert(pos, 1, (fchar) value); - } - - return MakeFilePathAbsolute(filename); -} - -// Transform a file path into a file URL -fstring FUFileManager::GetFileURL(const fstring& filepath, bool relative) -{ - fstring url; - if (relative) - { - url = MakeFilePathRelative(filepath); - if (!url.empty() && url[0] != '.') - { - // Unable to make the path relative, so return an absolute path - relative = false; - } - } - - if (!relative) - { - // Transform into an absolute file path - fstring url = MakeFilePathAbsolute(filepath); - std::replace(url.begin(), url.end(), ':', '|'); - std::replace(url.begin(), url.end(), '\\', '/'); - url = fstring(FC("file://")) + url; - } - - // Remove any invalid character(s) using the %X guideline - /*for (size_t p = 0; p < url.size(); ++p) - { - fchar c = url[p]; - if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || - c == '.' || c == '|' || c == '/' || c == '-' || c == '_') - { - // Valid characters - } - else - { - url.erase(p, 1); - globalBuilder.set('%'); <---- NEED TO BE IN HEX - globalBuilder.append(c); - url.append(globalBuilder.ToCharPtr()); - } - }*/ - - return url; -} - -// Strip a full filename of its filename, returning the path -fstring FUFileManager::StripFileFromPath(const fstring& filename) -{ - fchar fullPath[MAX_PATH + 1]; - fstrncpy(fullPath, filename.c_str(), MAX_PATH); - fullPath[MAX_PATH] = 0; - fchar* lastSlash = fstrrchr(fullPath, FC('/')); - fchar* lastBackslash = fstrrchr(fullPath, FC('\\')); - lastSlash = max(lastSlash, lastBackslash); - if (lastSlash != NULL) *lastSlash = 0; - return fstring(fullPath); -} - -// Extract the file extension out of a filename -fstring FUFileManager::GetFileExtension(const fstring& _filename) -{ - fchar filename[MAX_PATH]; - fstrncpy(filename, _filename.c_str(), MAX_PATH); - filename[MAX_PATH - 1] = 0; - - fchar* lastPeriod = fstrrchr(filename, '.'); - if (lastPeriod == NULL) return fstring(); - - fchar* lastSlash = fstrrchr(filename, '/'); - fchar* lastBackslash = fstrrchr(filename, '\\'); - lastSlash = max(lastSlash, lastBackslash); - if (lastSlash > lastPeriod) return fstring(); - - fstrlower(lastPeriod + 1); - return fstring(lastPeriod + 1); -} - -// For a relative path, extract the list of the individual paths that must be traversed to get to the file. -void FUFileManager::ExtractPathStack(const fstring& name, FStringList& list, bool includeFilename) -{ - list.clear(); - list.reserve(6); - - fstring split = name; - while (split.length() > 0) - { - // Extract out the next path - size_t slashIndex = split.find_first_of('/'); - size_t bslashIndex = split.find_first_of('\\'); - size_t pathSeparator; - if (slashIndex != fstring::npos && bslashIndex != fstring::npos) pathSeparator = min(slashIndex, bslashIndex); - else if (bslashIndex != fstring::npos) pathSeparator = bslashIndex; - else if (slashIndex != fstring::npos) pathSeparator = slashIndex; - else - { - if (includeFilename) list.push_back(split); - break; - } - - list.push_back(split.substr(0, pathSeparator)); - split = split.substr(pathSeparator + 1, split.length() - pathSeparator - 1); - } -} - -// Make a file path relative/absolute -fstring FUFileManager::MakeFilePathAbsolute(const fstring& _filePath) -{ - fstring filePath = _filePath; - if ((filePath.size() > 1 && (filePath[0] == '/' || filePath[0] == '\\')) || - (filePath.size() > 2 && (filePath[1] == ':' || filePath[1] == '|'))) - { - // Already an absolute filepath - } - else - { - // Relative file path. - FStringList documentPaths, localPaths; - ExtractPathStack(pathStack.back(), documentPaths, true); - ExtractPathStack(filePath, localPaths, true); - for (FStringList::iterator it = localPaths.begin(); it != localPaths.end(); ++it) - { - // Look for special relative path tokens: '.' and '..' - if ((*it) == FC(".")) {} // do nothing - else if ((*it) == FC("..")) { documentPaths.pop_back(); } // pop one path out - else { documentPaths.push_back(*it); } // traverse this path - } - - // Recreate the absolute filename - filePath.clear(); - for (FStringList::iterator it = documentPaths.begin(); it != documentPaths.end(); ++it) - { - if (!filePath.empty()) filePath.push_back('/'); - filePath += (*it); - } - - if (filePath.size() < 2 || (filePath[1] != ':' && filePath[1] != '|')) - { - filePath.insert(0, "/");//'/'); - } - } - -#ifdef WIN32 - std::replace(filePath.begin(), filePath.end(), '/', '\\'); -#endif // WIN32 - - return filePath; -} - -fstring FUFileManager::MakeFilePathRelative(const fstring& _filePath) -{ - fstring filePath = _filePath; - if (!filePath.empty() && filePath[0] != '.') - { - // First, ensure we have an absolute file path - filePath = MakeFilePathAbsolute(_filePath); - - // Relative file path. - FStringList documentPaths, localPaths; - ExtractPathStack(pathStack.back(), documentPaths, true); - ExtractPathStack(filePath, localPaths, true); - - // Extract the filename from the path stack - fstring filename = localPaths.back(); - localPaths.pop_back(); - - // Look for commonality in the path stacks - size_t documentPathCount = documentPaths.size(); - size_t filePathCount = localPaths.size(); - size_t matchIndex = 0; - for (; matchIndex < filePathCount && matchIndex < documentPathCount; ++matchIndex) - { - if (fstricmp(documentPaths[matchIndex].c_str(), localPaths[matchIndex].c_str()) != 0) break; - } - - if (matchIndex != 0) - { - // There is some similar part, so generate the relative filename - fstring relativePath; - - if (documentPathCount > matchIndex) - { - // Backtrack the document's path - for (size_t i = matchIndex; i < documentPathCount; ++i) - { - relativePath += fstring(FC("../")); - } - } - else - { - // Start at the document's root folder - relativePath = FC("./"); - } - - // Add the file's relative path - for (size_t i = matchIndex; i < filePathCount; ++i) - { - relativePath += filePath[i] + fstring(FC("/")); - } - filePath = relativePath + filename; - } - } - return filePath; -} diff --git a/Extras/FCollada/FUtils/FUFileManager.h b/Extras/FCollada/FUtils/FUFileManager.h deleted file mode 100644 index 755d8ee18..000000000 --- a/Extras/FCollada/FUtils/FUFileManager.h +++ /dev/null @@ -1,55 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _FU_FILE_MANAGER_H_ -#define _FU_FILE_MANAGER_H_ - -class FUFile; - -class FCOLLADA_EXPORT FUFileManager -{ -private: - FStringList pathStack; - -public: - FUFileManager(); - ~FUFileManager(); - - // Root path stack - const fstring& GetCurrentPath() { return pathStack.back(); } - void PushRootPath(const fstring& path); - void PopRootPath(); - void PushRootFile(const fstring& filename); - void PopRootFile(); - - // Some file access - FUFile* OpenFile(const fstring& filename, bool write=true); - - // Extract information from filenames - static fstring StripFileFromPath(const fstring& filename); - static fstring GetFileExtension(const fstring& filename); - - // Make a file path relative/absolute - fstring MakeFilePathAbsolute(const fstring& filePath); - fstring MakeFilePathRelative(const fstring& filePath); - - // Transform a file URL into a file path - fstring GetFilePath(const fstring& fileURL); - - // Transform a file path into a file URL - fstring GetFileURL(const fstring& filepath, bool relative); - - // For a relative path, extract the list of the individual paths that must be traversed to get to the file. - static void ExtractPathStack(const fstring& filename, FStringList& list, bool includeFilename); -}; - -#endif // _FU_FILE_MANAGER_H_ - diff --git a/Extras/FCollada/FUtils/FUFunctor.h b/Extras/FCollada/FUtils/FUFunctor.h deleted file mode 100644 index b8c013c45..000000000 --- a/Extras/FCollada/FUtils/FUFunctor.h +++ /dev/null @@ -1,149 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - This file was taken off the Protect project on 26-09-2005 -*/ - -#ifndef _FUNCTOR_H_ -#define _FUNCTOR_H_ - -// Functor with no argument. -template -class IFunctor0 -{ -public: - virtual ~IFunctor0() {} - virtual ReturnType operator()() const = 0; - virtual bool Compare(void* pObject, void* pFunction) const = 0; -}; - -template -class FUFunctor0 : public IFunctor0 -{ -private: - Class* m_pObject; - ReturnType (Class::*m_pFunction) (); - -public: - FUFunctor0(Class* pObject, ReturnType (Class::*pFunction) ()) { m_pObject = pObject; m_pFunction = pFunction; } - - virtual ReturnType operator()() const - { return ((*m_pObject).*m_pFunction)(); } - - virtual bool Compare(void* pObject, void* pFunction) const - { return pObject == m_pObject && (unsigned long)pFunction == *(unsigned long*)&m_pFunction; } -}; - -template -class FUStaticFunctor0 : public IFunctor0 -{ -private: - ReturnType (*m_pFunction) (); - -public: - FUStaticFunctor0(ReturnType (*pFunction) ()) { m_pFunction = pFunction; } - - virtual ReturnType operator()() const - { return (*m_pFunction)(); } - - virtual bool Compare(void*, void* pFunction) const - { return (unsigned long)pFunction == *(unsigned long*)&m_pFunction; } -}; - -// Functor with one argument. -template -class IFunctor1 -{ -public: - virtual ~IFunctor1() {} - virtual ReturnType operator()(Arg1 sArgument1) const = 0; - virtual bool Compare(void* pObject, void* pFunction) const = 0; -}; - -template -class FUFunctor1 : public IFunctor1 -{ -private: - Class* m_pObject; - ReturnType (Class::*m_pFunction) (Arg1); - -public: - FUFunctor1(Class* pObject, ReturnType (Class::*pFunction) (Arg1)) { m_pObject = pObject; m_pFunction = pFunction; } - - virtual ReturnType operator()(Arg1 sArgument1) const - { return ((*m_pObject).*m_pFunction)(sArgument1); } - - virtual bool Compare(void* pObject, void* pFunction) const - { return pObject == m_pObject && (unsigned long)pFunction == *(unsigned long*)&m_pFunction; } -}; - -template -class FUStaticFunctor1 : public IFunctor1 -{ -private: - ReturnType (*m_pFunction) (Arg1); - -public: - FUStaticFunctor1(ReturnType (*pFunction) (Arg1)) { m_pFunction = pFunction; } - - virtual ReturnType operator()(Arg1 sArgument1) const - { return (*m_pFunction)(sArgument1); } - - virtual bool Compare(void*, void* pFunction) const - { return (unsigned long)pFunction == *(unsigned long*)&m_pFunction; } -}; - -// Functor with two argument. -template -class IFunctor2 -{ -public: - virtual ~IFunctor2() {} - virtual ReturnType operator()(Arg1 sArgument1, Arg2 sArgument2) const = 0; - virtual bool Compare(void* pObject, void* pFunction) const = 0; -}; - -template -class FUFunctor2 : public IFunctor2 -{ -private: - Class* m_pObject; - ReturnType (Class::*m_pFunction) (Arg1, Arg2); - -public: - FUFunctor2(Class* pObject, ReturnType (Class::*pFunction) (Arg1, Arg2)) { m_pObject = pObject; m_pFunction = pFunction; } - - virtual ReturnType operator()(Arg1 sArgument1, Arg2 sArgument2) const - { return ((*m_pObject).*m_pFunction)(sArgument1, sArgument2); } - - virtual bool Compare(void* pObject, void* pFunction) const - { return pObject == m_pObject && (unsigned long)pFunction == *(unsigned long*)&m_pFunction; } -}; - -template -class FUStaticFunctor2 : public IFunctor2 -{ -private: - ReturnType (*m_pFunction) (Arg1, Arg2); - -public: - FUStaticFunctor2(ReturnType (*pFunction) (Arg1, Arg2)) { m_pFunction = pFunction; } - - virtual ReturnType operator()(Arg1 sArgument1, Arg2 sArgument2) const - { return (*m_pFunction)(sArgument1, sArgument2); } - - virtual bool Compare(void*, void* pFunction) const - { return (unsigned long)pFunction == *(unsigned long*)&m_pFunction; } -}; - -// Macro for member function pointer type bypass -#define FUNCTOR_COMPARE(sFunctor, pObject, pFunction, bRet) \ -{ \ - void* pVoid; \ - __asm { __asm push eax __asm mov eax, pFunction __asm mov pVoid, eax __asm pop eax } \ - bRet = sFunctor.Compare(pObject, pVoid); \ -} - -#endif //_FUNCTOR_H_ diff --git a/Extras/FCollada/FUtils/FULogFile.cpp b/Extras/FCollada/FUtils/FULogFile.cpp deleted file mode 100644 index 7529b98f9..000000000 --- a/Extras/FCollada/FUtils/FULogFile.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FUtils/FULogFile.h" -#include "FUtils/FUFile.h" - -FULogFile::FULogFile(const char* filename) -{ - file = new FUFile(filename, FUFile::WRITE); -} - -FULogFile::~FULogFile() -{ - SAFE_DELETE(file); -} - -void FULogFile::WriteLine(const char* filename, uint32 linenum, const char* message, ...) -{ - WriteLine("[%s:%d]", filename, (unsigned int) linenum); - - va_list vars; - va_start(vars, message); - WriteLineV(message, vars); - va_end(vars); -} - -void FULogFile::WriteLine(const char* message, ...) -{ - va_list vars; - va_start(vars, message); - WriteLineV(message, vars); - va_end(vars); -} - -void FULogFile::WriteLineV(const char* message, va_list& vars) -{ - size_t len = strlen(message); - char* buffer = new char[len + 1024]; - vsnprintf(buffer, len + 1024, message, vars); - buffer[len + 1023] = 0; - - if (file->IsOpen()) - { - file->Write(buffer, strlen(buffer) - 1); - file->Write("\n\r", 2); - } - - SAFE_DELETE_ARRAY(buffer); -} - -void FULogFile::Flush() -{ - file->Flush(); -} diff --git a/Extras/FCollada/FUtils/FULogFile.h b/Extras/FCollada/FUtils/FULogFile.h deleted file mode 100644 index 366c4a3bd..000000000 --- a/Extras/FCollada/FUtils/FULogFile.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _FU_LOG_FILE_H_ -#define _FU_LOG_FILE_H_ - -class FUFile; - -class FCOLLADA_EXPORT FULogFile -{ -private: - FUFile* file; - -public: - FULogFile(const char* filename); - ~FULogFile(); - - void WriteLine(const char* filename, uint32 linenum, const char* message, ...); - void WriteLine(const char* message, ...); - void WriteLineV(const char* message, va_list& vars); - - void Flush(); -}; - -#endif // _FU_LOG_FILE_H_ diff --git a/Extras/FCollada/FUtils/FUObject.cpp b/Extras/FCollada/FUtils/FUObject.cpp deleted file mode 100644 index 50328037c..000000000 --- a/Extras/FCollada/FUtils/FUObject.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* -* The idea is simple: the object registers itself in the constructor, with the container. -* It keeps a pointer to this container, so that the parent can easily access it -* In the destructor, the object unregisters itself with the container. -*/ - -#include "StdAfx.h" -#include "FUtils/FUObject.h" - -#ifdef _DEBUG -FUObject::FUObject(FUObjectContainer* _container, const char* _className) -#else -FUObject::FUObject(FUObjectContainer* _container) -#endif -{ - container = _container; -#ifdef _DEBUG - className = _className; -#endif - if (container != NULL) - { - container->RegisterObject(this); - } -} - -FUObject::~FUObject() -{ - if (container != NULL) - { - container->UnregisterObject(this); - container = NULL; - } -} - -FUObjectContainer::~FUObjectContainer() -{ -#ifdef _DEBUG - while (!objects.empty()) - { - FUObject* o = objects.back(); - SAFE_DELETE(o); //FIXME: this might cause a crash, but it's good for finding bugs or memory leaks. - } -#endif -} -void FUObjectContainer::RegisterObject(FUObject* object) -{ -#if defined(_DEBUG) && defined(_WIN32) - // If the check below fails, you are registering an object twice with this container - FUObjectList::iterator it = std::find(objects.begin(), objects.end(), object); - if (it != objects.end()) { __asm int 3 }; -#endif - objects.push_back(object); -} - -void FUObjectContainer::UnregisterObject(FUObject* object) -{ - FUObjectList::iterator it = std::find(objects.begin(), objects.end(), object); - if (it != objects.end()) objects.erase(it); -#if defined(_DEBUG) && defined(_WIN32) - else { __asm int 3 }; -#endif -} - diff --git a/Extras/FCollada/FUtils/FUObject.h b/Extras/FCollada/FUtils/FUObject.h deleted file mode 100644 index 491ed2a57..000000000 --- a/Extras/FCollada/FUtils/FUObject.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - The idea is simple: the object registers itself in the constructor, with the container. - It keeps a pointer to this container, so that the parent can easily access it - In the destructor, the object unregisters itself with the container. -*/ - -/** - @file FUObject.h - This file contains the FUObject class and the FUObjectContaimer class. -*/ - -#ifndef _FU_OBJECT_H_ -#define _FU_OBJECT_H_ - -class FUObjectContainer; - -/** - A contained object. - Each object holds a pointer to the container that contains it. - This pointer is useful so that the container can be notified if the object - gets released by someone else. -*/ -class FCOLLADA_EXPORT FUObject -{ -private: - FUObjectContainer* container; -#ifdef _DEBUG - const char* className; -#endif // _DEBUG - -protected: - /** Retrieves the container of the object. - @return A pointer to the container. */ - inline FUObjectContainer* GetContainer() { return container; } - inline const FUObjectContainer* GetContainer() const { return container; } /**< See above. */ - -public: -#ifndef _DEBUG - /** Constructor. - Although it is not an abstract class, class is - not meant to be used directly. This constructor - informs the container of the object's creation. - @param container The container that contains this object. */ - FUObject(FUObjectContainer* container); - - /** Overwrites the token name of the object. - This token name is used for debugging purposes only. - @param UNUSED The token name for the class of the object. */ - inline void SetClassName(const char* UNUSED(_className)) {}; -#else - - FUObject(FUObjectContainer* container, const char* className); - inline void SetClassName(const char* _className) {className = _className;} -#endif - - /** Destructor. - This function informs the container of this object's release. */ - ~FUObject(); -}; - -/** A dynamically-sized array of contained objects. */ -typedef vector FUObjectList; - -/** - An object container - Each container holds a list of contained objects. - It will release all the objects when it is released and the - objects inform it of their creation/destruction. -*/ -class FCOLLADA_EXPORT FUObjectContainer -{ -private: - friend class FUObject; - FUObjectList objects; - - void RegisterObject(FUObject* object); - void UnregisterObject(FUObject* object); - -public: - /** Constructor: empty. */ - FUObjectContainer() {} - - /** Destructor. - Releases all the objects contained within this container. */ - virtual ~FUObjectContainer(); -}; - -#ifndef _DEBUG -/** Encapsulates the FUObject class constructor. - This macro is useful to rid ourselves of the 'className' parameter in retail builds. - @param container The container that contains the object. - @param className The token name used only for debugging purposes. */ -#define FUObject_Construct(container, className) FUObject(container) -#else -#define FUObject_Construct(container, className) FUObject(container, className) -#endif - -#endif // _FU_OBJECT_H_ diff --git a/Extras/FCollada/FUtils/FUSingleton.h b/Extras/FCollada/FUtils/FUSingleton.h deleted file mode 100644 index d77bd9b4c..000000000 --- a/Extras/FCollada/FUtils/FUSingleton.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Taken off the Protect project in 2005. -*/ - -/** - @file FUSingleton.h - This file contains macros to easily implement singletons. - A singleton is a class which has only one object of this class. - The advantage of a singleton over a static class is that the - application controls when and how the singleton is created and - destroyed. The disadvantage of a singleton is that you have one - extra memory lookup to do. -*/ - -#ifndef _FU_SINGLETON_H_ -#define _FU_SINGLETON_H_ - -/** Declares a singleton. - Use this macros within the class declaration. - @param className The name of the class. */ -#define DECLARE_SINGLETON_CLASS(className) \ -private: \ - static className* m_pSingleton; \ -public: \ - static bool CreateSingleton(); \ - static void DestroySingleton(); \ - friend className* Get##className(); - -/** Declares a singleton. - Use this macros within the class declaration. - @param className The name of the class. - @param createArgs An argument for the constructor of the singleton. */ -#define DECLARE_SINGLETON_CLASS_WITH_ARGS(className, createArgs) \ -private: \ - static className* m_pSingleton; \ -public: \ - static bool CreateSingleton(createArgs); \ - static void DestroySingleton(); \ - friend className* Get##className(); - -/** Declares a singleton. - Use this macros within the class declaration. - @param className The name of the class. - @param createArgs1 A first argument for the constructor of the singleton. - @param createArgs2 A second argument for the constructor of the singleton. */ -#define DECLARE_SINGLETON_CLASS_WITH_ARGS2(className, createArgs1, createArgs2) \ -private: \ - static className* m_pSingleton; \ -public: \ - static bool CreateSingleton(createArgs1, createArgs2); \ - static void DestroySingleton(); \ - friend className* Get##className(); - -/** Implements the singleton. - Use this macros within the class implementation. - @param className The name of the class. */ -#define IMPLEMENT_SINGLETON(className) \ - IMPLEMENT_CREATE_SINGLETON(className) \ - IMPLEMENT_DESTROY_SINGLETON(className) - -/** Implements the singleton. - Use this macros within the class implementation. - @param className The name of the class. - @param createArg1 The argument for the constructor of the singleton. */ -#define IMPLEMENT_SINGLETON_WITH_ARGS(className, createArg1) \ - IMPLEMENT_CREATE_SINGLETON_WITH_ARGS(className, createArg1) \ - IMPLEMENT_DESTROY_SINGLETON(className) - -/** Implements the singleton. - Use this macros within the class implementation. - @param className The name of the class. - @param createArg1 A first argument for the constructor of the singleton. - @param createArg2 A second argument for the constructor of the singleton. */ -#define IMPLEMENT_SINGLETON_WITH_ARGS2(className, createArg1, createArg2) \ - IMPLEMENT_CREATE_SINGLETON_WITH_ARGS2(className, createArg1, createArg2) \ - IMPLEMENT_DESTROY_SINGLETON(className) - -/** Implements the construction of a singleton. - Use this macros within the class implementation. - @param className The name of the class. */ -#define IMPLEMENT_CREATE_SINGLETON(className) \ - className* className::m_pSingleton; \ - className* Get##className() { return className::m_pSingleton; } \ - bool className::CreateSingleton() { \ - m_pSingleton = new className(); \ - return true; } - -/** Implements the construction of a singleton. - Use this macros within the class implementation. - @param className The name of the class. - @param createArg1 The argument for the constructor of the singleton. */ -#define IMPLEMENT_CREATE_SINGLETON_WITH_ARGS(className, createArg1) \ - className* className::m_pSingleton; \ - className* Get##className() { return className::m_pSingleton; } \ - bool className::CreateSingleton(createArg1 argument1) { \ - m_pSingleton = new className(argument1); } - -/** Implements the construction of a singleton. - Use this macros within the class implementation. - @param className The name of the class. - @param createArg1 A first argument for the constructor of the singleton. - @param createArg2 A second argument for the constructor of the singleton. */ -#define IMPLEMENT_CREATE_SINGLETON_WITH_ARGS2(className, createArg1, createArg2) \ - className* className::m_pSingleton; \ - className* Get##className() { return className::m_pSingleton; } \ - bool className::CreateSingleton(createArg1 argument1, createArg2 argument2) { \ - m_pSingleton = new className(argument1, argument2); } - -/** Implements the destruction of a singleton. - Use this macros within the class implementation. - @param className The name of the class. */ -#define IMPLEMENT_DESTROY_SINGLETON(className) \ - void className::DestroySingleton() \ - { SAFE_DELETE(m_pSingleton); } - -#endif // _FU_SINGLETON_H_ diff --git a/Extras/FCollada/FUtils/FUStatus.h b/Extras/FCollada/FUtils/FUStatus.h deleted file mode 100644 index 3e3e10c74..000000000 --- a/Extras/FCollada/FUtils/FUStatus.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FUStatus.h - This file contains the FUStatus class. -*/ - -#ifndef _FU_STATUS_H_ -#define _FU_STATUS_H_ - -/** - A return status structure that includes a string. - Contains a return code as well as a string which explains the errors and warnings - attached to the return code. The return code is either 'successful' or 'failure'. - If the return code is 'failure', proceeding normally may be dangerous. - This structure is used by the FCDocument classes to explain parsing errors. - - @ingroup FUtils -*/ -class FCOLLADA_EXPORT FUStatus -{ -private: - fstring errorString; - bool callSuccessful; - -public: - /** Default Constructor. - The default return code is 'successful'. - @param _callSuccessful Whether the return code should be set to 'successful'. */ - FUStatus(bool _callSuccessful=true) { callSuccessful = _callSuccessful; } - - /** Sets the value of the return code to 'failure'. - @return The error code structure. Returns itself to support - multiple subsequent operations in one statement. */ - FUStatus& Fail() { callSuccessful = false; return *this; } - - /** Sets the value of the return code to 'failure'. - @param str The error string for the error encountered. - @param line A line number. - @return The return status structure. Returns itself to support - multiple subsequent operations in one statement. */ - FUStatus& Fail(const fstring& str, size_t line=0) { callSuccessful = false; AppendString(FS("ERROR[") + TO_FSTRING(line) + FS("]: ") + str); return *this; } - FUStatus& Fail(const fchar* str, size_t line=0) { callSuccessful = false; AppendString(FS("ERROR[") + TO_FSTRING(line) + FS("]: ") + str); return *this; } /**< See above. */ - - /** Adds a warning to the return status. A warning does not set the return code to 'failure'. - @param str The warning string for the error encountered. - @param line A line number. - @return The return status structure. Returns itself to support - multiple subsequent operations in one statement. */ - FUStatus& Warning(const fstring& str, size_t line=0) { AppendString(FS("WARNING[") + TO_FSTRING(line) + FS("]: ") + str); return *this; } - FUStatus& Warning(const fchar* str, size_t line=0) { AppendString(FS("WARNING[") + TO_FSTRING(line) + FS("]: ") + str); return *this; } /**< See above. */ - - /** Merges two return stati together. - Appends to this return status the error string from the given status. - The merged return code is 'failure', if either return codes are 'failure'. - @param a The return status to merge with. */ - void AppendStatus(const FUStatus& a) { AppendString(a.errorString); callSuccessful &= a.callSuccessful; } - - /** Appends a return string to the return status. - A 'newline' code is added between return strings. - @param str The return string to append. */ - void AppendString(const fstring& str) { AppendString(str.c_str()); } - void AppendString(const fchar* str) { if (*str != 0) { if (!errorString.empty()) errorString += FC("\r\n"); errorString += str; } } /**< See above. */ - - /** Retrieves the error/return string for this return status. - @return The return string. */ - const fchar* GetErrorString() const { return errorString.empty() ? (callSuccessful ? FC("Success") : FC("Failure")) : errorString.c_str(); } - - /** Retrieves whether the return status is 'successful'. - @return Whether the return status is 'successful'. */ - bool IsSuccessful() const { return callSuccessful; } - - /** Retrieves whether the return status is 'failure'. - @return Whether the return status is 'failure'. */ - bool IsFailure() const { return !callSuccessful; } - - /** Transforms the return status into a boolean primitive. - @return Whether the return status is 'successful'. */ - operator bool() const { return callSuccessful; } -}; - -#endif // _FU_STATUS_H_ diff --git a/Extras/FCollada/FUtils/FUString.h b/Extras/FCollada/FUtils/FUString.h deleted file mode 100644 index d9cbf68ec..000000000 --- a/Extras/FCollada/FUtils/FUString.h +++ /dev/null @@ -1,84 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FUString.h - This file includes FUStringBuilder.h and FUStringConversion.h - and defines important string-related macros and inline functions. -*/ - -#ifndef _FU_STRING_H_ -#define _FU_STRING_H_ - -/** A dynamically-sized array of Unicode strings. */ -typedef vector FStringList; - -/** A dynamically-sized array of simple strings. */ -typedef vector StringList; - -/** Returns whether two 8-bit strings are equivalent. This is a case-sensitive comparison. - @param sz1 The first 8-bit string to compare. - @param sz2 The second 8-bit string to compare. - @return Whether the two 8-bit strings are equivalent. */ -inline bool IsEquivalent(const char* sz1, const char* sz2) { return strcmp(sz1, sz2) == 0; } -inline bool IsEquivalent(const string& sz1, const char* sz2) { return strcmp(sz1.c_str(), sz2) == 0; } /**< See above. */ -inline bool IsEquivalent(const char* sz1, const string& sz2) { return strcmp(sz1, sz2.c_str()) == 0; } /**< See above. */ -inline bool IsEquivalent(const string& sz1, const string& sz2) { return strcmp(sz1.c_str(), sz2.c_str()) == 0; } /**< See above. */ - -/** Returns whether two 8-bit strings are equivalent. This is a case-sensitive comparison. - @param sz1 The first 8-bit string to compare. - @param sz2 The second 8-bit string to compare. - @return Whether the two 8-bit strings are equivalent. */ -inline bool operator==(const string& sz1, const char* sz2) { return strcmp(sz1.c_str(), sz2) == 0; } - -/** Appends a signed integer to an 8-bit string. This function is meant - for debugging purposes. Use the FUStringBuilder class instead. - @param sz1 The 8-bit string prefix. - @param i The signed integer to convert and append. - @return The final 8-bit string. */ -FCOLLADA_EXPORT string operator+(const string& sz1, int32 i); - -#ifdef UNICODE -/** Returns whether two Unicode strings are equivalent. This is a case-sensitive comparison. - @param sz1 The first Unicode string to compare. - @param sz2 The second Unicode string to compare. - @return Whether the two Unicode strings are equivalent. */ -inline bool IsEquivalent(const fchar* sz1, const fchar* sz2) { return fstrcmp(sz1, sz2) == 0; } -inline bool IsEquivalent(const fstring& sz1, const fchar* sz2) { return fstrcmp(sz1.c_str(), sz2) == 0; } /**< See above. */ -inline bool IsEquivalent(const fchar* sz1, const fstring& sz2) { return fstrcmp(sz1, sz2.c_str()) == 0; } /**< See above. */ -inline bool IsEquivalent(const fstring& sz1, const fstring& sz2) { return fstrcmp(sz1.c_str(), sz2.c_str()) == 0; } /**< See above. */ - -/** Returns whether two Unicode strings are equivalent. This is a case-sensitive comparison. - @param sz1 The first Unicode string to compare. - @param sz2 The second Unicode string to compare. - @return Whether the two Unicode strings are equivalent. */ -inline bool operator==(const fstring& sz1, const fchar* sz2) { return fstrcmp(sz1.c_str(), sz2) == 0; } - -/** Appends a signed integer to a Unicode string. This function is meant - for debugging purposes. Use the FUStringBuilder class instead. - @param sz1 The Unicode string prefix. - @param i The signed integer to convert and append. - @return The final Unicode string. */ -FCOLLADA_EXPORT fstring operator+(const fstring& sz1, int32 i); -#endif // UNICODE - -// Include the main string modification classes. -#include "FUtils/FUStringBuilder.h" -#include "FUtils/FUStringConversion.h" - -/** A Unicode string from a constant 8-bit string. */ -#define FS(a) fstring(FC(a)) -/** A Unicode string from any convertable value: string, vector-type or simple numeric. */ -#define TO_FSTRING(a) FUStringConversion::ToFString(a) -/** An 8-bit string from any convertable value: Unicode string, vector-type or simple numeric. */ -#define TO_STRING(a) FUStringConversion::ToString(a) - -/** An empty UTF-8 string. This string is returned in many functions when there is an error. */ -extern FCOLLADA_EXPORT const string emptyString; -/** An empty Unicode string. This string is returned in many functions when there is an error. */ -extern FCOLLADA_EXPORT const fstring emptyFString; - - -#endif // _FU_STRING_H_ diff --git a/Extras/FCollada/FUtils/FUStringBuilder.h b/Extras/FCollada/FUtils/FUStringBuilder.h deleted file mode 100644 index b3ab63b30..000000000 --- a/Extras/FCollada/FUtils/FUStringBuilder.h +++ /dev/null @@ -1,276 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FUStringBuilder.h - This file contains the FUStringBuilderT template class, - its defined template classes and its helper classes. -*/ - -#ifndef _FCU_STRING_BUILDER_ -#define _FCU_STRING_BUILDER_ - -/** - A dynamically-sized string object. - The template has two arguments: the character definition and - the sprintf() functor class for float to string conversions. - - This class should be used for all the string operations, as it contains a - dynamically-resized buffer that is not directly tied to its content's length. - - @ingroup FUtils -*/ -template -class FUStringBuilderT -{ -private: - Char* buffer; - size_t reserved; - size_t size; - -public: - /** The standard string object which correspond to the builder. */ - typedef std::basic_string String; - - /** Creates a new builder with the content of the given string. - @param sz A string. Its content will be copied within the builder. */ - FUStringBuilderT(const String& sz); - - /** Creates a new builder with the content of the given character array. - @param sz A character array. Its content will be copied within the builder. - It must terminate with an element containing the 'zero' value. */ - FUStringBuilderT(const Char* sz); - - /** Creates a new builder with an empty buffer. - @see reserve - @param reserved The number of character slots to reserve within the empty buffer. */ - FUStringBuilderT(size_t reserved); - - /** Creates a new builder with an empty buffer. */ - FUStringBuilderT(); - - /** Deletes the builder. Its buffer will be cleared. - Any pointers to its data will be dangling. */ - ~FUStringBuilderT(); - - /** Reserves a given number of character slots. - If the builder has a buffer with a different number of character slots, a new - buffer will be allocated. If the builder has contents, it will be copied within - the new buffer. If there is more content than the new buffer can handle, it will - be discarded. - @param length The number of character slots to reserve. */ - void reserve(size_t length); - - /** Retrieves the length of the content within the builder. - @return The length of the string. */ - inline size_t length() { return size; } - - /** Clears the content of the builder. - This does not re-allocate a new buffer. */ - void clear(); - - /** Retrieves whether the builder is empty. - A builder is considered empty when it has no content, regardless of - the size or allocation status of its buffer. - @return Whether the builder is empty. */ - inline bool empty() { return size == 0; } - - /** Appends a character to the content of the builder. - @param c A character. May not be the 'zero' value. */ - void append(Char c); - - /** Appends a string to the content of the builder. - @param sz A string. */ - void append(const String& sz); - - /** Appends a character array to the content of the builder. - @param sz A character array. It must terminate with an - element containing the 'zero' value. */ - void append(const Char* sz); - - /** Appends the content of a builder to the content of this builder. - @param b A string builder. */ - void append(const FUStringBuilderT& b); - - /** Appends the integer value, after converting it to a string, - to the content of the builder. - @param i An integer value. */ - void append(int32 i); - void append(uint32 i); /**< See above. */ - void append(uint64 i); /**< See above. */ - - inline void append(int i) { append((int32) i); } /**< See above. */ -#ifdef _W64 - inline void append(_W64 unsigned int i) { append((uint32) i); } /**< See above. */ -#else - inline void append(unsigned int i) { append((uint32) i); } /**< See above. */ -#endif - - /** Appends the floating-point value, after converting it to a string, - to the content of the builder. If the floating-point value is the special token - that represents infinity, the string "INF" is appended. If it represents - the negative infinity, the string "-INF" is appended. If it represents the - impossibility, the string "NaN" is appended. - @param f A floating-point value. */ - void append(float f); - void append(double f); /**< See above. */ - - /** Appends a value to the content of the builder. - This is a shortcut for the append function. - @see append - @param val A value. This may be numerical, a character, a character array or a string. */ - template inline FUStringBuilderT& operator+=(const TYPE& val) { append(val); return *this; } - - /** Appends a character array to the content of the builder. - A newline character will be appended after the character array. - @param sz A character array. It must terminate with an - element containing the 'zero' value. */ - void appendLine(const Char* sz); - - /** Removes a section of the content of the builder. - Every character that occurs after the given index will be removed, - resulting in a shrunk string. - @param start An index within the content of the builder. */ - void remove(int32 start); - - /** Removes a section of the content of the builder. - The substring defined by the 'start' and 'end' indices will be - removed. The 'start' character is removed and is replaced by - the 'end' character. - @param start The index of the first character of the substring to remove. - @param end The index of the first character after the removed substring. */ - void remove(int32 start, int32 end); - - /** Removes the last character of the content of the builder. */ - inline void pop_back() { if (size > 0) --size; } - - /** Sets the content of the builder to a given value. - This clears the builder of all its content and appends the given value. - @param val A value. This may be numerical, a character, a character array or a string. */ - template inline void set(const TYPE& val) { clear(); append(val); } - template inline FUStringBuilderT& operator=(const TYPE& val) { clear(); append(val); return *this; } /**< See above. */ - - /** Converts the content of the builder to a standard string. - @return A string with the content of the builder. */ - String ToString(); - operator String() { return ToString(); } /**< See above. */ - - /** Converts the content of the builder to a character array. - @return A character array with the content of the builder. - This pointer is valid for the lifetime of the buffer of the builder, so - do not keep it around. This character array should not be modified. */ - const Char* ToCharPtr(); - operator const Char*() { return ToCharPtr(); } /**< See above. */ - - /** Retrieves the index of the first character within the content of the builder - that is equivalent to the given character. - @param c The character to match. - @return The index of the first equivalent character. -1 is returned if no - character matches the given character. */ - int32 index(Char c); - - /** Retrieves the index of the last character within the content of the builder - that is equivalent to the given character. - @param c The character to match. - @return The index of the last equivalent character. -1 is returned if no - character matches the given character. */ - int32 rindex(Char c); - -private: - void enlarge(size_t minimum); -}; - -/** - Encapsulates the 8-bit string numerical conversion functions. - The 'snprintf' function is used so no locale information is handled. -*/ -class SprintF -{ -public: - /** Converts a signed integer into the given constant-sized string. - @param output A constant-sized string. - @param length The size of the constant-sized string. - @param i A signed integer. */ - void PrintInt32(char* output, uint32 length, int32 i) { snprintf(output, length, "%i", i); } - - /** Converts an unsigned integer into the given constant-sized string. - @param output A constant-sized string. - @param length The size of the constant-sized string. - @param i An unsigned integer. */ - void PrintUInt32(char* output, uint32 length, uint32 i) { snprintf(output, length, "%u", i); } - void PrintUInt64(char* output, uint32 length, uint64 i) { snprintf(output, length, "%u", i); } /**< See above. */ - - /** Converts a floating-point value into the given constant-sized string. - @param output A constant-sized string. - @param length The size of the constant-sized string. - @param f A floating-point value. */ - void PrintFloat(char* output, uint32 length, double f) { snprintf(output, length, "%f", f); } - - /** Retrieves the length of a constant-sized string. - @param in A character array which is terminated with a 'zero' element. - @return The number of element preceeding the 'zero' element. */ - size_t StrLen(const char* in) { return strlen(in); } -}; - -/** - Encapsulates the Unicode string numerical conversion functions. - The 'fsnprintf' function is used so no locale information is handled. -*/ -class SFprintF -{ -public: - /** Converts a signed integer into the given constant-sized string. - @param output A constant-sized string. - @param length The size of the constant-sized string. - @param i A signed integer. */ - void PrintInt32(fchar* output, uint32 length, int32 i) { fsnprintf(output, length, FC("%i"), i); } - - /** Converts an unsigned integer into the given constant-sized string. - @param output A constant-sized string. - @param length The size of the constant-sized string. - @param i An unsigned integer. */ - void PrintUInt32(fchar* output, uint32 length, uint32 i) { fsnprintf(output, length, FC("%u"), i); } - - /** Converts an unsigned integer into the given constant-sized string. - @param output A constant-sized string. - @param length The size of the constant-sized string. - @param i An unsigned integer. */ - void PrintUInt64(fchar* output, uint32 length, uint64 i) { fsnprintf(output, length, FC("%u"), i); } - - /** Converts a floating-point value into the given constant-sized string. - @param output A constant-sized string. - @param length The size of the constant-sized string. - @param f A floating-point value. */ - void PrintFloat(fchar* output, uint32 length, double f) { fsnprintf(output, length, FC("%f"), f); } - - /** Retrieves the length of a constant-sized string. - @param in A character array which is terminated with a 'zero' element. - @return The number of element preceeding the 'zero' element. */ - size_t StrLen(const fchar* in) { return fstrlen(in); } -}; - -typedef FUStringBuilderT FUStringBuilder; /**< A Unicode string builder. */ -typedef FUStringBuilderT FUSStringBuilder; /**< A 8-bit string builder. */ - -/** Declares a global Unicode string builder. - As many functions within FCollada use the global string builders, their content is often overwritten. - Use this builder only for quick conversion or character accumulation. */ -FCOLLADA_EXPORT extern FUStringBuilder globalBuilder; - -/** Declares a global 8-bit string builder. - As many functions within FCollada use the global string builders, their content is often overwritten. - Use this builder only for quick conversion or character accumulation. */ -FCOLLADA_EXPORT extern FUSStringBuilder globalSBuilder; - -#include "FUtils/FUStringBuilder.hpp" - -#endif // _FCU_STRING_BUILDER_ - diff --git a/Extras/FCollada/FUtils/FUStringBuilder.hpp b/Extras/FCollada/FUtils/FUStringBuilder.hpp deleted file mode 100644 index e37772ddb..000000000 --- a/Extras/FCollada/FUtils/FUStringBuilder.hpp +++ /dev/null @@ -1,275 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include - -#ifdef WIN32 -#include -#endif - -#ifndef SAFE_DELETE_ARRAY -#define SAFE_DELETE_ARRAY(ptr) if (ptr != NULL) { delete [] ptr; ptr = NULL; } -#endif - -template -FUStringBuilderT::FUStringBuilderT(const String& sz) -{ - this->buffer = NULL; - this->size = 0; - this->reserved = 0; - - reserve(sz.size() + 32); - append(sz.c_str()); -} - -template -FUStringBuilderT::FUStringBuilderT(const Char* sz) -{ - this->buffer = NULL; - this->size = 0; - this->reserved = 0; - - SPrintF s; - reserve(s.StrLen(sz) + 32); - append(sz); -} - -template -FUStringBuilderT::FUStringBuilderT(size_t reservation) -{ - this->buffer = NULL; - this->size = 0; - this->reserved = 0; - - reserve(reservation); -} - -template -FUStringBuilderT::FUStringBuilderT() -{ - this->buffer = NULL; - this->size = 0; - this->reserved = 0; - -#ifndef _DEBUG - reserve(32); -#endif -} - -template -FUStringBuilderT::~FUStringBuilderT() -{ - reserve(0); -} - -template -void FUStringBuilderT::enlarge(size_t minimum) -{ - reserve(max(reserved + minimum + 32, 2 * reserved + 32)); -} - -template -void FUStringBuilderT::clear() -{ - size = 0; -} - -template -void FUStringBuilderT::reserve(size_t _length) -{ - FUAssert(size <= reserved, ); - if (_length > reserved) - { - Char* b = new Char[_length]; - memcpy(b, buffer, size * sizeof(Char)); - SAFE_DELETE_ARRAY(buffer); - buffer = b; - reserved = _length; - } - else if (_length == 0) - { - SAFE_DELETE_ARRAY(buffer); - size = reserved = 0; - } - else if (_length < reserved) - { - size_t realSize = min(size, _length); - Char* b = new Char[_length]; - memcpy(b, buffer, realSize * sizeof(Char)); - SAFE_DELETE_ARRAY(buffer); - buffer = b; - reserved = _length; - size = realSize; - } -} - -template -void FUStringBuilderT::append(Char c) -{ - if (size + 1 >= reserved) enlarge(2); - - buffer[size++] = c; -} - -template -void FUStringBuilderT::append(const String& sz) { append(sz.c_str()); } -template -void FUStringBuilderT::append(const Char* sz) -{ - // This is optimized for SMALL strings. - for (; *sz != 0; ++sz) - { - if (size >= reserved) enlarge(64); - buffer[size++] = *sz; - } -} -template -void FUStringBuilderT::append(const FUStringBuilderT& b) -{ - if (size + b.size >= reserved) enlarge(64 + size + b.size - reserved); - memcpy(buffer + size, b.buffer, b.size * sizeof(Char)); - size += b.size; -} - -template -void FUStringBuilderT::append(uint32 i) -{ - Char sz[128]; - SPrintF writer; writer.PrintUInt32(sz, 128, i); - append(sz); -} - -template -void FUStringBuilderT::append(uint64 i) -{ - Char sz[128]; - SPrintF writer; writer.PrintUInt64(sz, 128, i); - append(sz); -} - -template -void FUStringBuilderT::append(int32 i) -{ - Char sz[128]; - SPrintF writer; writer.PrintInt32(sz, 128, i); - append(sz); -} - -template -void FUStringBuilderT::append(float f) -{ - if (f != std::numeric_limits::infinity() && f != -std::numeric_limits::infinity() && f != std::numeric_limits::quiet_NaN() && f != std::numeric_limits::signaling_NaN()) - { - if (IsEquivalent(f, 0.0f, std::numeric_limits::epsilon())) append('0'); - else - { - Char sz[128]; - SPrintF writer; writer.PrintFloat(sz, 128, f); - append(sz); - } - } - else if (f == std::numeric_limits::infinity()) - { append('I'); append('N'); append('F'); } - else if (f == -std::numeric_limits::infinity()) - { append('-'); append('I'); append('N'); append('F'); } - else - { append('N'); append('a'); append('N'); } -} - -template -void FUStringBuilderT::append(double f) -{ - if (f != std::numeric_limits::infinity() && f != -std::numeric_limits::infinity() && f != std::numeric_limits::quiet_NaN() && f != std::numeric_limits::signaling_NaN()) - { - if (IsEquivalent(f, 0.0, std::numeric_limits::epsilon())) append('0'); - else - { - Char sz[128]; - SPrintF writer; writer.PrintFloat(sz, 128, f); - append(sz); - } - } - else if (f == std::numeric_limits::infinity()) - { append('I'); append('N'); append('F'); } - else if (f == -std::numeric_limits::infinity()) - { append('-'); append('I'); append('N'); append('F'); } - else - { append('N'); append('a'); append('N'); } -} - -template -void FUStringBuilderT::appendLine(const Char* sz) -{ - append(sz); - append("\n"); -} - -template -void FUStringBuilderT::remove(int32 start) -{ - if ((int32)size > start && start >= 0) size = start; -} - -template -void FUStringBuilderT::remove(int32 start, int32 end) -{ - int32 diff = end - start; - if ((int32)size >= end && start >= 0 && diff > 0) - { - const Char* stop = buffer + size - diff; - for (Char* p = buffer + start; p != stop; ++p) - { - *p = *(p + diff); - } - size -= diff; - } -} - -template -typename FUStringBuilderT::String FUStringBuilderT::ToString() -{ - return String((const Char*)*this); -} - -template -const Char* FUStringBuilderT::ToCharPtr() -{ - if (size + 1 > reserved) enlarge(1); - buffer[size] = 0; - return buffer; -} - -template -int32 FUStringBuilderT::index(Char c) -{ - if (buffer != NULL && size > 0) - { - const Char* end = buffer + size + 1; - for (const Char* p = buffer; p != end; ++p) - { - if (*p == c) return (int32)(p - buffer); - } - } - return -1; -} - -template -int32 FUStringBuilderT::rindex(Char c) -{ - if (buffer != NULL && size > 0) - { - for (const Char* p = buffer + size - 1; p != buffer; --p) - { - if (*p == c) return (int32)(p - buffer); - } - } - return -1; -} diff --git a/Extras/FCollada/FUtils/FUStringConversion.cpp b/Extras/FCollada/FUtils/FUStringConversion.cpp deleted file mode 100644 index 808942fcf..000000000 --- a/Extras/FCollada/FUtils/FUStringConversion.cpp +++ /dev/null @@ -1,830 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FUtils/FUStringConversion.h" -#include "FUtils/FUStringBuilder.h" -#include "FUtils/FUDateTime.h" - -FUStringBuilder globalBuilder; -FUSStringBuilder globalSBuilder; - -// Some string writer macros -#define SPACE builder.append(' ') -#define VAL(x) builder.append(x) - -// Convert a UTF-8 string to a fstring -#ifdef UNICODE - fstring FUStringConversion::ToFString(const char* value) - { - globalBuilder.clear(); - uint32 length = (uint32) strlen(value); - globalBuilder.reserve(length + 1); - for(uint32 i = 0; i < length; ++i) - { - globalBuilder.append((fchar)value[i]); - } - return globalBuilder.ToString(); - } -#else // UNICODE - fstring FUStringConversion::ToFString(const char* value) { return fstring(value); } -#endif // UNICODE - -// Convert a fstring string to a UTF-8 string -#ifdef UNICODE - string FUStringConversion::ToString(const fchar* value) - { - globalSBuilder.clear(); - uint32 length = (uint32) fstrlen(value); - globalSBuilder.reserve(length + 1); - for(uint32 i = 0; i < length; ++i) - { - if (value[i] < 0xFF || (value[i] & (~0xFF)) >= 32) globalSBuilder.append((char)value[i]); - else globalSBuilder.append('_'); // some generic enough character - } - return globalSBuilder.ToString(); - } -#else // UNICODE - string FUStringConversion::ToString(const fchar* value) { return string(value); } -#endif // UNICODE - -// Convert a fstring to a boolean value -#ifdef UNICODE -bool FUStringConversion::ToBoolean(const fchar* value) -{ - return value != NULL && *value != 0 && *value != '0' && *value != 'f' && *value != 'F'; -} -#endif // UNICODE -bool FUStringConversion::ToBoolean(const char* value) -{ - return value != NULL && *value != 0 && *value != '0' && *value != 'f' && *value != 'F'; -} - -// Convert a fstring to a int32 and advance the character pointer -#ifdef UNICODE -int32 FUStringConversion::ToInt32(const fchar** value) -{ - if (!*value) return 0; - - // Skip beginning white spaces - const fchar* s = *value; - fchar c; - while ((c = *s) != 0 && (c == ' ' || c == '\t' || c == '\r' || c == '\n')) { ++s; } - - int32 val = 0; - int32 sign = 1; - if (*s == '-') { ++s; sign = -1; } - - while ((c = *s) != 0) - { - if (c >= '0' && c <= '9') val = val * 10 + c - '0'; - else break; - ++s; - } - val *= sign; - while ((c = *s) != '\0' && (c != ' ' && c != '\t' && c != '\n')) s++; - while ((c = *s) != '\0' && (c == ' ' || c == '\t' || c == '\n')) s++; - *value = s; - return val; -} -#endif // UNICODE -int32 FUStringConversion::ToInt32(const char** value) -{ - if (!*value) return 0; - - // Skip beginning white spaces - const char* s = *value; - char c; - while ((c = *s) != 0 && (c == ' ' || c == '\t' || c == '\r' || c == '\n')) { ++s; } - - int32 val = 0; - int32 sign = 1; - if (*s == '-') { ++s; sign = -1; } - - while ((c = *s) != 0) - { - if (c >= '0' && c <= '9') val = val * 10 + c - '0'; - else break; - ++s; - } - val *= sign; - while ((c = *s) != '\0' && (c != ' ' && c != '\t' && c != '\n')) s++; - while ((c = *s) != '\0' && (c == ' ' || c == '\t' || c == '\n')) s++; - *value = s; - return val; -} - -// Convert a fstring to a float and advance the character pointer -#ifdef UNICODE -float FUStringConversion::ToFloat(const fchar** value) -{ - const fchar* s = *value; - if (s == NULL || *s == 0) return 0.0f; - - // Skip beginning white spaces - fchar c; - while ((c = *s) != 0 && (c == ' ' || c == '\t' || c == '\r' || c == '\n')) { ++s; } - - // Skip all the plausible numerical characters - double val = 0.0; - int sign = 1; - if (*s == '-') { ++s; sign = -1; } - int32 decimals = 0; - int32 exponent = 0; - bool infinity = false; - bool nonValidFound = false; - while ((c = *s) != 0 && !nonValidFound) - { - switch(c) - { - case '.': decimals = 1; break; - case '0': val *= 10.0; decimals *= 10; break; - case '1': val = val * 10.0 + 1; decimals *= 10; break; - case '2': val = val * 10.0 + 2; decimals *= 10; break; - case '3': val = val * 10.0 + 3; decimals *= 10; break; - case '4': val = val * 10.0 + 4; decimals *= 10; break; - case '5': val = val * 10.0 + 5; decimals *= 10; break; - case '6': val = val * 10.0 + 6; decimals *= 10; break; - case '7': val = val * 10.0 + 7; decimals *= 10; break; - case '8': val = val * 10.0 + 8; decimals *= 10; break; - case '9': val = val * 10.0 + 9; decimals *= 10; break; - case 'e': - case 'E': ++s; exponent = ToInt32(&s); --s; - case 'I': nonValidFound = true; infinity = true; --s; break; - default: nonValidFound = true; --s; break; - } - ++s; - } - - if(infinity) // test for infinity - { - infinity = false; - if(*s=='I') - if(*(++s)=='N') - if(*(++s)=='F') - { - infinity = true; - decimals=0; - val = std::numeric_limits::infinity() * (double)sign; - } - } - if(!infinity) - { - // Generate the value - if (decimals != 0) val /= (double)decimals; - val *= (double)sign; - if (exponent != 0) val *= pow(10.0, (double) exponent); - } - - // Find next whitespaces and Skip end whitespaces - while ((c = *s) != 0 && c != ' ' && c != '\t' && c != '\r' && c != '\n') { ++s; } - while ((c = *s) != 0 && (c == ' ' || c == '\t' || c == '\r' || c == '\n')) { ++s; } - - *value = s; - return (float)val; -} -#endif // UNICODE -float FUStringConversion::ToFloat(const char** value) -{ - const char* s = *value; - if (s == NULL || *s == 0) return 0.0f; - - // Skip beginning white spaces - char c; - while ((c = *s) != 0 && (c == ' ' || c == '\t' || c == '\r' || c == '\n')) { ++s; } - - // Skip all the plausible numerical characters - double val = 0.0; - int sign = 1; - if (*s == '-') { ++s; sign = -1; } - int32 decimals = 0; - int32 exponent = 0; - bool infinity = false; - bool nonValidFound = false; - while ((c = *s) != 0 && !nonValidFound) - { - switch(c) - { - case '.': decimals = 1; break; - case '0': val *= 10.0; decimals *= 10; break; - case '1': val = val * 10.0 + 1; decimals *= 10; break; - case '2': val = val * 10.0 + 2; decimals *= 10; break; - case '3': val = val * 10.0 + 3; decimals *= 10; break; - case '4': val = val * 10.0 + 4; decimals *= 10; break; - case '5': val = val * 10.0 + 5; decimals *= 10; break; - case '6': val = val * 10.0 + 6; decimals *= 10; break; - case '7': val = val * 10.0 + 7; decimals *= 10; break; - case '8': val = val * 10.0 + 8; decimals *= 10; break; - case '9': val = val * 10.0 + 9; decimals *= 10; break; - case 'e': - case 'E': ++s; exponent = ToInt32(&s); --s; - case 'I': nonValidFound = true; infinity = true; --s; break; - default: nonValidFound = true; --s; break; - } - ++s; - } - - if(infinity) // test for infinity - { - infinity = false; - if(*s=='I') - if(*(++s)=='N') - if(*(++s)=='F') - { - infinity = true; - decimals=0; - val = std::numeric_limits::infinity() * (double)sign; - } - } - if(!infinity) - { - // Generate the value - if (decimals != 0) val /= (double)decimals; - val *= (double)sign; - if (exponent != 0) val *= pow(10.0, (double) exponent); - } - - // Find next whitespaces and Skip end whitespaces - while ((c = *s) != 0 && c != ' ' && c != '\t' && c != '\r' && c != '\n') { ++s; } - while ((c = *s) != 0 && (c == ' ' || c == '\t' || c == '\r' || c == '\n')) { ++s; } - - *value = s; - return (float)val; -} - -// Convert a fstring to a uint32 and advance the character pointer -#ifdef UNICODE -uint32 FUStringConversion::ToUInt32(const fchar** value) -{ - if (value == NULL || *value == NULL || **value == 0) return 0; - - // Skip beginning white spaces - const fchar* s = *value; - fchar c; - while ((c = *s) != 0 && (c == ' ' || c == '\t' || c == '\r' || c == '\n')) { ++s; } - - uint32 val = 0; - while ((c = *s) != 0) - { - if (c >= '0' && c <= '9') val = val * 10 + c - '0'; - else break; - ++s; - } - - while ((c = *s) != '\0' && (c != ' ' && c != '\t' && c != '\n')) s++; - while ((c = *s) != '\0' && (c == ' ' || c == '\t' || c == '\n')) s++; - *value = s; - return val; -} -#endif // UNICODE -uint32 FUStringConversion::ToUInt32(const char** value) -{ - if (value == NULL || *value == NULL || **value == 0) return 0; - - // Skip beginning white spaces - const char* s = *value; - char c; - while ((c = *s) != 0 && (c == ' ' || c == '\t' || c == '\r' || c == '\n')) { ++s; } - - uint32 val = 0; - while ((c = *s) != 0) - { - if (c >= '0' && c <= '9') val = val * 10 + c - '0'; - else break; - ++s; - } - - while ((c = *s) != '\0' && (c != ' ' && c != '\t' && c != '\n')) s++; - while ((c = *s) != '\0' && (c == ' ' || c == '\t' || c == '\n')) s++; - *value = s; - return val; -} - -uint32 FUStringConversion::HexToUInt32(const char** value, uint32 count) -{ - if (value == NULL || *value == NULL || **value == 0) return 0; - - const char* s = *value; - char c; - - uint32 val = 0; - for (uint32 i = 0; i < count && (c = *s) != 0; ++i) - { - if (c >= '0' && c <= '9') val = val * 16 + c - '0'; - else if (c >= 'A' && c <= 'F') val = val * 16 + c + 10 - 'A'; - else if (c >= 'a' && c <= 'f') val = val * 16 + c + 10 - 'a'; - else break; - ++s; - } - - *value = s; - return val; -} -#ifdef UNICODE -uint32 FUStringConversion::HexToUInt32(const fchar** value, uint32 count) -{ - if (value == NULL || *value == NULL || **value == 0) return 0; - - const fchar* s = *value; - fchar c; - - uint32 val = 0; - for (uint32 i = 0; i < count && (c = *s) != 0; ++i) - { - if (c >= '0' && c <= '9') val = val * 16 + c - '0'; - else if (c >= 'A' && c <= 'Z') val = val * 16 + c + 10 - 'A'; - else if (c >= 'a' && c <= 'z') val = val * 16 + c + 10 - 'a'; - else break; - ++s; - } - - *value = s; - return val; -} -#endif // UNICODE - -#ifdef UNICODE -void FUStringConversion::ToMatrix(const fchar** s, FMMatrix44& mx, float lengthFactor) -{ - if (s != NULL && *s != NULL && **s != 0) - { - // COLLADA is Column major - mx[0][0] = ToFloat(s); mx[1][0] = ToFloat(s); mx[2][0] = ToFloat(s); mx[3][0] = ToFloat(s) * lengthFactor; - mx[0][1] = ToFloat(s); mx[1][1] = ToFloat(s); mx[2][1] = ToFloat(s); mx[3][1] = ToFloat(s) * lengthFactor; - mx[0][2] = ToFloat(s); mx[1][2] = ToFloat(s); mx[2][2] = ToFloat(s); mx[3][2] = ToFloat(s) * lengthFactor; - mx[0][3] = ToFloat(s); mx[1][3] = ToFloat(s); mx[2][3] = ToFloat(s); mx[3][3] = ToFloat(s); - } -} -#endif // UNICODE -void FUStringConversion::ToMatrix(const char** s, FMMatrix44& mx, float lengthFactor) -{ - if (s != NULL && *s != NULL && **s != 0) - { - // COLLADA is Column major - mx[0][0] = ToFloat(s); mx[1][0] = ToFloat(s); mx[2][0] = ToFloat(s); mx[3][0] = ToFloat(s) * lengthFactor; - mx[0][1] = ToFloat(s); mx[1][1] = ToFloat(s); mx[2][1] = ToFloat(s); mx[3][1] = ToFloat(s) * lengthFactor; - mx[0][2] = ToFloat(s); mx[1][2] = ToFloat(s); mx[2][2] = ToFloat(s); mx[3][2] = ToFloat(s) * lengthFactor; - mx[0][3] = ToFloat(s); mx[1][3] = ToFloat(s); mx[2][3] = ToFloat(s); mx[3][3] = ToFloat(s); - } -} - -// Convert a matrix to a string -void FUStringConversion::ToString(FUSStringBuilder& builder, const FMMatrix44& m, float lengthFactor) -{ - VAL(m[0][0]); SPACE; VAL(m[1][0]); SPACE; VAL(m[2][0]); SPACE; VAL(m[3][0] * lengthFactor); SPACE; - VAL(m[0][1]); SPACE; VAL(m[1][1]); SPACE; VAL(m[2][1]); SPACE; VAL(m[3][1] * lengthFactor); SPACE; - VAL(m[0][2]); SPACE; VAL(m[1][2]); SPACE; VAL(m[2][2]); SPACE; VAL(m[3][2] * lengthFactor); SPACE; - VAL(m[0][3]); SPACE; VAL(m[1][3]); SPACE; VAL(m[2][3]); SPACE; VAL(m[3][3]); -} - -string FUStringConversion::ToString(const FMMatrix44& m, float lengthFactor) -{ - globalSBuilder.clear(); - ToString(globalSBuilder, m, lengthFactor); - return globalSBuilder.ToString(); -} - - -string FUStringConversion::ToString(const FUDateTime& dateTime) -{ - char sz[21]; - snprintf(sz, 21, "%04d-%02d-%02dT%02d:%02d:%02dZ", dateTime.GetYear(), dateTime.GetMonth(), dateTime.GetDay(), dateTime.GetHour(), dateTime.GetMinutes(), dateTime.GetSeconds()); - sz[20] = 0; - return string(sz); -} - -// Convert a matrix to a fstring -void FUStringConversion::ToFString(FUStringBuilder& builder, const FMMatrix44& m, float lengthFactor) -{ - VAL(m[0][0]); SPACE; VAL(m[1][0]); SPACE; VAL(m[2][0]); SPACE; VAL(m[3][0] * lengthFactor); SPACE; - VAL(m[0][1]); SPACE; VAL(m[1][1]); SPACE; VAL(m[2][1]); SPACE; VAL(m[3][1] * lengthFactor); SPACE; - VAL(m[0][2]); SPACE; VAL(m[1][2]); SPACE; VAL(m[2][2]); SPACE; VAL(m[3][2] * lengthFactor); SPACE; - VAL(m[0][3]); SPACE; VAL(m[1][3]); SPACE; VAL(m[2][3]); SPACE; VAL(m[3][3]); -} - -fstring FUStringConversion::ToFString(const FMMatrix44& m, float lengthFactor) -{ - globalBuilder.clear(); - ToFString(globalBuilder, m, lengthFactor); - return globalBuilder.ToString(); -} - -fstring FUStringConversion::ToFString(const FUDateTime& dateTime) -{ - fchar sz[21]; - fsnprintf(sz, 21, FC("%04d-%02d-%02dT%02d:%02d:%02dZ"), dateTime.GetYear(), dateTime.GetMonth(), dateTime.GetDay(), dateTime.GetHour(), dateTime.GetMinutes(), dateTime.GetSeconds()); - sz[20] = 0; - return fstring(sz); -} - -void FUStringConversion::ToDateTime(const char* value, FUDateTime& dateTime) -{ - // We're not in the business of checking the string value for UTC correctness: assume "YYYY-MM-DDTHH:MM:SSZ". - if (strlen(value) == 20) - { - dateTime.SetYear(ToUInt32(value)); value += 5; - dateTime.SetMonth(ToUInt32(value)); value += 3; - dateTime.SetDay(ToUInt32(value)); value += 3; - dateTime.SetHour(ToUInt32(value)); value += 3; - dateTime.SetMinutes(ToUInt32(value)); value += 3; - dateTime.SetSeconds(ToUInt32(value)); value += 3; - } -} -#ifdef UNICODE -void FUStringConversion::ToDateTime(const fchar* value, FUDateTime& dateTime) -{ - if (fstrlen(value) == 20) - { - dateTime.SetYear(ToUInt32(value)); value += 5; - dateTime.SetMonth(ToUInt32(value)); value += 3; - dateTime.SetDay(ToUInt32(value)); value += 3; - dateTime.SetHour(ToUInt32(value)); value += 3; - dateTime.SetMinutes(ToUInt32(value)); value += 3; - dateTime.SetSeconds(ToUInt32(value)); value += 3; - } -} -#endif - -#ifdef HAS_VECTORTYPES - -// Split a fstring into multiple substrings -void FUStringConversion::ToFStringList(const fstring& value, FStringList& array) -{ - const fchar* s = value.c_str(); - - // Skip beginning white spaces - fchar c; - while ((c = *s) != 0 && (c == ' ' || c == '\t' || c == '\r' || c == '\n')) { ++s; } - - size_t index = 0; - while (*s != 0) - { - const fchar* word = s; - - // Find next white space - while ((c = *s) != 0 && c != ' ' && c != '\t' && c != '\r' && c != '\n') { ++s; } - - if (index < array.size()) array[index++].append(word, s - word); - else { array.push_back(fstring(word, s - word)); index++; } - - // Skip all white spaces - while ((c = *s) != 0 && (c == ' ' || c == '\t' || c == '\r' || c == '\n')) { ++s; } - } -} - -void FUStringConversion::ToStringList(const string& value, StringList& array) -{ - const char* s = value.c_str(); - - // Skip beginning white spaces - char c; - while ((c = *s) != 0 && (c == ' ' || c == '\t' || c == '\r' || c == '\n')) { ++s; } - - size_t index = 0; - while (*s != 0) - { - const char* word = s; - - // Find next white space - while ((c = *s) != 0 && c != ' ' && c != '\t' && c != '\r' && c != '\n') { ++s; } - - if (index < array.size()) array[index++].append(word, s - word); - else { array.push_back(string(word, s - word)); index++; } - - // Skip all white spaces - while ((c = *s) != 0 && (c == ' ' || c == '\t' || c == '\r' || c == '\n')) { ++s; } - } -} - -#ifdef UNICODE -void FUStringConversion::ToStringList(const fchar* value, StringList& array) -{ - // Performance could be improved... - ToStringList(ToString(value), array); -} -#endif - -// Convert a fstring to a 32-bit integer list -#ifdef UNICODE -void FUStringConversion::ToInt32List(const fchar* value, Int32List& array) -{ - if (value != NULL && *value != 0) - { - size_t length = array.size(); - for (size_t count = 0; count < length && *value != 0; ++count) array[count] = ToInt32(&value); - while (*value != 0) { int32 i = ToInt32(&value); array.push_back(i); } - } -} -#endif // UNICODE -void FUStringConversion::ToInt32List(const char* value, Int32List& array) -{ - if (value != NULL && *value != 0) - { - size_t length = array.size(); - for (size_t count = 0; count < length && *value != 0; ++count) array[count] = ToInt32(&value); - while (*value != 0) { int32 i = ToInt32(&value); array.push_back(i); } - } -} - -// Convert a fstring to a 32-bit unsigned integer list -#ifdef UNICODE -void FUStringConversion::ToUInt32List(const fchar* value, UInt32List& array) -{ - if (value != NULL && *value != 0) - { - size_t length = array.size(); - for (size_t count = 0; count < length && *value != 0; ++count) array[count] = ToUInt32(&value); - while (*value != 0) { int32 i = ToUInt32(&value); array.push_back(i); } - } -} -#endif // UNICODE -void FUStringConversion::ToUInt32List(const char* value, UInt32List& array) -{ - if (value != NULL && *value != 0) - { - size_t length = array.size(); - for (size_t count = 0; count < length && *value != 0; ++count) array[count] = ToUInt32(&value); - while (*value != 0) { int32 i = ToUInt32(&value); array.push_back(i); } - } -} - -// Convert a fstring to 32-bit floating point list -#ifdef UNICODE -void FUStringConversion::ToFloatList(const fchar* value, FloatList& array) -{ - if (value != NULL && *value != 0) - { - size_t length = array.size(); - for (size_t count = 0; count < length && *value != 0; ++count) array[count] = ToFloat(&value); - while (*value != 0) array.push_back(ToFloat(&value)); - } -} -#endif // UNICODE -void FUStringConversion::ToFloatList(const char* value, FloatList& array) -{ - if (value != NULL && *value != 0) - { - size_t length = array.size(); - for (size_t count = 0; count < length && *value != 0; ++count) array[count] = ToFloat(&value); - while (*value != 0) array.push_back(ToFloat(&value)); - } -} - -// Convert a fstring to a list of interleaved floating points -#ifdef UNICODE -void FUStringConversion::ToInterleavedFloatList(const fchar* value, const vector& arrays) -{ - size_t stride = arrays.size(); - if (value != NULL && *value != 0 && stride > 0) - { - size_t length = arrays[0]->size(); - for (size_t count = 0; count < length && *value != 0; ++count) - { - for (size_t i = 0; i < stride && *value != 0; ++i) - { - FloatList* array = arrays[i]; - if (array != NULL) array->at(count) = ToFloat(&value); - else ToFloat(&value); - } - } - - while (*value != 0) - { - for (size_t i = 0; i < stride && *value != 0; ++i) - { - FloatList* array = arrays[i]; - if (array != NULL) array->push_back(ToFloat(&value)); - else ToFloat(&value); - } - } - } -} -#endif // UNICODE -void FUStringConversion::ToInterleavedFloatList(const char* value, const vector& arrays) -{ - size_t stride = arrays.size(); - if (value != NULL && *value != 0 && stride > 0) - { - size_t length = arrays[0]->size(); - for (size_t count = 0; count < length && *value != 0; ++count) - { - for (size_t i = 0; i < stride && *value != 0; ++i) - { - FloatList* array = arrays[i]; - if (array != NULL) array->at(count) = ToFloat(&value); - else ToFloat(&value); - } - } - - while (*value != 0) - { - for (size_t i = 0; i < stride && *value != 0; ++i) - { - FloatList* array = arrays[i]; - if (array != NULL) array->push_back(ToFloat(&value)); - else ToFloat(&value); - } - } - } -} - -// Convert a fstring to a (X,Y,Z) Point object -#ifdef UNICODE -FMVector3 FUStringConversion::ToPoint(const fchar** value, float lengthFactor) -{ - FMVector3 p; - if (value != NULL && *value != NULL && **value != 0) - { - p.x = ToFloat(value) * lengthFactor; - p.y = ToFloat(value) * lengthFactor; - p.z = ToFloat(value) * lengthFactor; - } - return p; -} -#endif // UNICODE -FMVector3 FUStringConversion::ToPoint(const char** value, float lengthFactor) -{ - FMVector3 p; - if (value != NULL && *value != NULL && **value != 0) - { - p.x = ToFloat(value) * lengthFactor; - p.y = ToFloat(value) * lengthFactor; - p.z = ToFloat(value) * lengthFactor; - } - return p; -} - -// Convert a point to a string -void FUStringConversion::ToString(FUSStringBuilder& builder, const FMVector3& p, float lengthFactor) -{ - VAL(p.x * lengthFactor); SPACE; VAL(p.y * lengthFactor); SPACE; VAL(p.z * lengthFactor); -} - -string FUStringConversion::ToString(const FMVector3& p, float lengthFactor) -{ - globalSBuilder.clear(); - ToString(globalSBuilder, p, lengthFactor); - return globalSBuilder.ToString(); -} - -// Convert a vector4 to a string -void FUStringConversion::ToString(FUSStringBuilder& builder, const FMVector4& p, float lengthFactor) -{ - VAL(p.w * lengthFactor); SPACE; VAL(p.x * lengthFactor); SPACE; VAL(p.y * lengthFactor); SPACE; VAL(p.z * lengthFactor); -} - -string FUStringConversion::ToString(const FMVector4& p, float lengthFactor) -{ - globalSBuilder.clear(); - ToString(globalSBuilder, p, lengthFactor); - return globalSBuilder.ToString(); -} - - -// Convert a point to a fstring -void FUStringConversion::ToFString(FUStringBuilder& builder, const FMVector3& p, float lengthFactor) -{ - VAL(p.x * lengthFactor); SPACE; VAL(p.y * lengthFactor); SPACE; VAL(p.z * lengthFactor); -} - -fstring FUStringConversion::ToFString(const FMVector3& p, float lengthFactor) -{ - globalBuilder.clear(); - ToFString(globalBuilder, p, lengthFactor); - return globalBuilder.ToString(); -} - -#ifdef HAS_VECTORTYPES -void FUStringConversion::ToString(FUSStringBuilder& builder, const FloatList& values, float lengthFactor) -{ - if (values.empty()) return; - if (!builder.empty()) SPACE; - FloatList::const_iterator itV = values.begin(); - if (IsEquivalent(lengthFactor, 1.0f)) - { - builder.append(*itV); - for (++itV; itV != values.end(); ++itV) { SPACE; VAL(*itV); } - } - else - { - builder.append(*itV * lengthFactor); - for (++itV; itV != values.end(); ++itV) { SPACE; VAL(*itV * lengthFactor); } - } -} - -void FUStringConversion::ToString(FUSStringBuilder& builder, const Int32List& values) -{ - if (values.empty()) return; - if (!builder.empty()) SPACE; - Int32List::const_iterator itV = values.begin(); - builder.append(*itV); - for (; itV != values.end(); ++itV) { SPACE; VAL(*itV); } -} - -void FUStringConversion::ToString(FUSStringBuilder& builder, const UInt32List& values) -{ - if (values.empty()) return; - if (!builder.empty()) SPACE; - UInt32List::const_iterator itV = values.begin(); - builder.append(*itV); - for (; itV != values.end(); ++itV) { SPACE; VAL(*itV); } -} -#endif // HAS_VECTORTYPES - -// Convert a fstring to a list of matrices -#ifdef UNICODE -void FUStringConversion::ToMatrixList(const fchar* value, FMMatrix44List& array, float lengthFactor) -{ - if (value != NULL && *value != 0) - { - size_t length = array.size(); - for (size_t count = 0; count < length && *value != 0; ++count) - { - ToMatrix(&value, array[count], lengthFactor); - } - - while (*value != 0) - { - FMMatrix44List::iterator it = array.insert(array.end(), FMMatrix44::Identity); - ToMatrix(&value, *it, lengthFactor); - } - } -} -#endif // UNICODE -void FUStringConversion::ToMatrixList(const char* value, FMMatrix44List& array, float lengthFactor) -{ - if (value != NULL && *value != 0) - { - size_t length = array.size(); - for (size_t count = 0; count < length && *value != 0; ++count) - { - ToMatrix(&value, array[count], lengthFactor); - } - - while (*value != 0) - { - FMMatrix44List::iterator it = array.insert(array.end(), FMMatrix44::Identity); - ToMatrix(&value, *it, lengthFactor); - } - } -} - -#ifdef UNICODE -void FUStringConversion::ToPointList(const fchar* value, FMVector3List& array, float lengthFactor) -{ - if (value != NULL && *value != 0) - { - size_t length = array.size(); - for (size_t count = 0; count < length && *value != 0; ++count) - { - array[count] = ToPoint(&value, lengthFactor); - } - - while (*value != 0) array.push_back(ToPoint(&value, lengthFactor)); - } -} -#endif // UNICODE -void FUStringConversion::ToPointList(const char* value, FMVector3List& array, float lengthFactor) -{ - if (value != NULL && *value != 0) - { - size_t length = array.size(); - for (size_t count = 0; count < length && *value != 0; ++count) - { - array[count] = ToPoint(&value, lengthFactor); - } - - while (*value != 0) array.push_back(ToPoint(&value, lengthFactor)); - } -} - -#endif // HAS_VECTORTYPES - -// Parasitic: Common string operators -#ifdef UNICODE -fstring operator+(const fstring& sz1, int32 i) -{ - globalBuilder.set(sz1); - globalBuilder.append(i); - return globalBuilder.ToString(); -} -#endif // UNICODE - -string operator+(const string& sz1, int32 i) -{ - globalSBuilder.set(sz1); - globalSBuilder.append(i); - return globalSBuilder.ToString(); -} - -// Parasitic: empty string constants -const string emptyString(""); -const fstring emptyFString(FC("")); diff --git a/Extras/FCollada/FUtils/FUStringConversion.h b/Extras/FCollada/FUtils/FUStringConversion.h deleted file mode 100644 index 504098867..000000000 --- a/Extras/FCollada/FUtils/FUStringConversion.h +++ /dev/null @@ -1,318 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FUStringConversion.h - This file contains the FUStringConversion class. -*/ - -#ifndef _FCU_STRING_CONVERSION_ -#define _FCU_STRING_CONVERSION_ - -class FUDateTime; - -/** - Common string conversion. - - This static class contains the parsing function for Unicode and 8-bit/UTF-8 - strings into common data types: integers, booleans, floating-point values, - vectors, matrices, date-time, etc. and dynamically-sized array of these types. - - This class can also convert common data types into an 8-bit or a Unicode string and - it contains conversion functions to convert string between 8-bit and Unicode. - - @ingroup FUtils -*/ -class FCOLLADA_EXPORT FUStringConversion -{ -private: FUStringConversion() {} -public: - /** Converts a 8-bit string to a Unicode string. - @param value The 8-bit string. - @return The converted Unicode string. */ - static fstring ToFString(const char* value); - inline static fstring ToFString(const string& value) { return ToFString(value.c_str()); } /**< See above. */ - - /** Converts an Unicode string to a 8-bit string. - @param value The Unicode string. - @return The converted 8-bit string. */ - static string ToString(const fchar* value); - inline static string ToString(const fstring& value) { return ToString(value.c_str()); } /**< See above. */ - - /** Parses a string into a boolean value. - @param value The string. - @return The parsed boolean value. */ - static bool ToBoolean(const char* value); - inline static bool ToBoolean(const string& value) { return ToBoolean(value.c_str()); } /**< See above. */ -#ifdef UNICODE - static bool ToBoolean(const fchar* value); /**< See above. */ - inline static bool ToBoolean(const fstring& value) { return ToBoolean(value.c_str()); } /**< See above. */ -#endif - - /** Parses a string into a floating-point value. - @param value The string. For the string pointer versions of this function, - the pointer will point to the last processed characters after the parsing. - @return The parsed floating-point value. */ - static float ToFloat(const char** value); - inline static float ToFloat(const char* value) { return ToFloat(&value); } /**< See above. */ - inline static float ToFloat(const string& value) { return ToFloat(value.c_str()); } /**< See above. */ -#ifdef UNICODE - static float ToFloat(const fchar** value); /**< See above. */ - inline static float ToFloat(const fstring& value) { return ToFloat(value.c_str()); } /**< See above. */ - inline static float ToFloat(const fchar* value) { return ToFloat(&value); } /**< See above. */ -#endif - - /** Parses a string into a signed integer. - @param value The string. For the string pointer versions of this function, - the pointer will point to the last processed characters after the parsing. - @return The parsed signed integer. */ - static int32 ToInt32(const char** value); - inline static int32 ToInt32(const char* value) { return ToInt32(&value); } /**< See above. */ - inline static int32 ToInt32(const string& value) { return ToInt32(value.c_str()); } /**< See above. */ -#ifdef UNICODE - static int32 ToInt32(const fchar** value); /**< See above. */ - inline static int32 ToInt32(const fchar* value) { return ToInt32(&value); } /**< See above. */ - inline static int32 ToInt32(const fstring& value) { return ToInt32(value.c_str()); } /**< See above. */ -#endif - - /** Parses a string into an unsigned integer. - @param value The string. For the string pointer versions of this function, - the pointer will point to the last processed characters after the parsing. - @return The parsed unsigned integer. */ - static uint32 ToUInt32(const char** value); - inline static uint32 ToUInt32(const char* value) { return ToUInt32(&value); } /**< See above. */ - inline static uint32 ToUInt32(const string& value) { return ToUInt32(value.c_str()); } /**< See above. */ -#ifdef UNICODE - static uint32 ToUInt32(const fchar** value); /**< See above. */ - inline static uint32 ToUInt32(const fchar* value) { return ToUInt32(&value); } /**< See above. */ - inline static uint32 ToUInt32(const fstring& value) { return ToUInt32(value.c_str()); } /**< See above. */ -#endif - - /** Parses a string into an unsigned integer. The string is assumed to have - an unsigned integer in hexadecimal format. - @param value The string. For the string pointer versions of this function, - the pointer will point to the last processed characters after the parsing. - @param count The maxmimum number of characters to parse. - For example, a count of 2 will read in an 8-bit character. - @return The parsed unsigned integer. */ - static uint32 HexToUInt32(const char** value, uint32 count=UINT_MAX); - inline static uint32 HexToUInt32(const char* value, uint32 count=UINT_MAX) { return HexToUInt32(&value, count); } /**< See above. */ - inline static uint32 HexToUInt32(const string& value, uint32 count=UINT_MAX) { return HexToUInt32(value.c_str(), count); } /**< See above. */ -#ifdef UNICODE - static uint32 HexToUInt32(const fchar** value, uint32 count=UINT_MAX); /**< See above. */ - inline static uint32 HexToUInt32(const fchar* value, uint32 count=UINT_MAX) { return HexToUInt32(&value, count); } /**< See above. */ - inline static uint32 HexToUInt32(const fstring& value, uint32 count=UINT_MAX) { return HexToUInt32(value.c_str(), count); } /**< See above. */ -#endif - - /** Parses a string into a 3D vector. - @param value The string. For the string pointer versions of this function, - the pointer will point to the last processed characters after the parsing. - @param lengthFactor An optional factor that will scale the 3D vector. - @return The parsed 3D vector. */ - static FMVector3 ToPoint(const char** value, float lengthFactor=1.0f); - inline static FMVector3 ToPoint(const char* value, float lengthFactor=1.0f) { return ToPoint(&value, lengthFactor); } /**< See above. */ - inline static FMVector3 ToPoint(const string& value, float lengthFactor=1.0f) { return ToPoint(value.c_str(), lengthFactor); } /**< See above. */ -#ifdef UNICODE - static FMVector3 ToPoint(const fchar** value, float lengthFactor=1.0f); /**< See above. */ - inline static FMVector3 ToPoint(const fchar* value, float lengthFactor=1.0f) { return ToPoint(&value, lengthFactor); } /**< See above. */ - inline static FMVector3 ToPoint(const fstring& value, float lengthFactor=1.0f) { return ToPoint(value.c_str(), lengthFactor); } /**< See above. */ -#endif - - /** Parses a string into a 4x4 matrix. - @param value The string. For the string pointer versions of this function, - the pointer will point to the last processed characters after the parsing. - @param mx The matrix to be filled in. - @param lengthFactor An optional factor that will scale the translation column - of the matrix. */ - static void ToMatrix(const char** value, FMMatrix44& mx, float lengthFactor=1.0f); - inline static void ToMatrix(const char* value, FMMatrix44& mx, float lengthFactor=1.0f) { return ToMatrix(&value, mx, lengthFactor); } /**< See above. */ - inline static void ToMatrix(const string& value, FMMatrix44& mx, float lengthFactor=1.0f) { return ToMatrix(value.c_str(), mx, lengthFactor); } /**< See above. */ -#ifdef UNICODE - static void ToMatrix(const fchar** value, FMMatrix44& mx, float lengthFactor=1.0f); /**< See above. */ - inline static void ToMatrix(const fchar* value, FMMatrix44& mx, float lengthFactor=1.0f) { return ToMatrix(&value, mx, lengthFactor); } /**< See above. */ - inline static void ToMatrix(const fstring& value, FMMatrix44& mx, float lengthFactor=1.0f) { return ToMatrix(value.c_str(), mx, lengthFactor); } /**< See above. */ -#endif - - /** Parses a string into a datetime structure. - @param value The string. - @param dateTime The datetime structure to fill in. */ - static void ToDateTime(const char* value, FUDateTime& dateTime); - inline static void ToDateTime(const string& value, FUDateTime& dateTime) { return ToDateTime(value.c_str(), dateTime); } /**< See above. */ -#ifdef UNICODE - static void ToDateTime(const fchar* value, FUDateTime& dateTime); /**< See above. */ - inline static void ToDateTime(const fstring& value, FUDateTime& dateTime) { return ToDateTime(value.c_str(), dateTime); } /**< See above. */ -#endif - -#ifdef HAS_VECTORTYPES - - /** Splits a string into multiple substrings. - The separator used here are the white-spaces. - @param value The string. - @param array A list of strings that will be filled in. */ - static void ToFStringList(const fstring& value, FStringList& array); - static void ToStringList(const string& value, StringList& array); /**< See above. */ -#ifdef UNICODE - static void ToStringList(const fchar* value, StringList& array); /**< See above. */ - inline static void ToStringList(const fstring& value, StringList& array) { return ToStringList(value.c_str(), array); } /**< See above. */ -#endif - - /** Parses a string into a list of floating point values. - @param value The string. - @param array The list of floating point values to fill in. */ - static void ToFloatList(const char* value, FloatList& array); - inline static void ToFloatList(const string& value, FloatList& array) { return ToFloatList(value.c_str(), array); } /**< See above. */ -#ifdef UNICODE - static void ToFloatList(const fchar* value, FloatList& array); /**< See above. */ - inline static void ToFloatList(const fstring& value, FloatList& array) { return ToFloatList(value.c_str(), array); } /**< See above. */ -#endif - - /** Parses a string into a list of signed integers. - @param value The string. - @param array The list of signed integers to fill in. */ - static void ToInt32List(const char* value, Int32List& array); - inline static void ToInt32List(const string& value, Int32List& array) { return ToInt32List(value.c_str(), array); } /**< See above. */ -#ifdef UNICODE - static void ToInt32List(const fchar* value, Int32List& array); /**< See above. */ - inline static void ToInt32List(const fstring& value, Int32List& array) { return ToInt32List(value.c_str(), array); } /**< See above. */ -#endif - - /** Parses a string into a list of unsigned integers. - @param value The string. - @param array The list of unsigned integers to fill in. */ - static void ToUInt32List(const char* value, UInt32List& array); - inline static void ToUInt32List(const string& value, UInt32List& array) { return ToUInt32List(value.c_str(), array); } /**< See above. */ -#ifdef UNICODE - static void ToUInt32List(const fchar* value, UInt32List& array); /**< See above. */ - inline static void ToUInt32List(const fstring& value, UInt32List& array) { return ToUInt32List(value.c_str(), array); } /**< See above. */ -#endif - - /** Parses a string containing interleaved floating-point values. - The values will be stored in multiple, independent lists. - @param value The string containing interleaved floating-point values. - @param arrays The lists of floating-point values to fill in. */ - static void ToInterleavedFloatList(const char* value, const vector& arrays); - inline static void ToInterleavedFloatList(const string& value, const vector& arrays) { return ToInterleavedFloatList(value.c_str(), arrays); } /**< See above. */ -#ifdef UNICODE - static void ToInterleavedFloatList(const fchar* value, const vector& arrays); /**< See above. */ - inline static void ToInterleavedFloatList(const fstring& value, const vector& arrays) { return ToInterleavedFloatList(value.c_str(), arrays); } /**< See above. */ -#endif - - /** Parses a string into a list of matrices. - @param value The string. - @param array The list of matrices to fill in. - @param lengthFactor An optional factor that will scale the translation column - of the matrices. */ - static void ToMatrixList(const char* value, FMMatrix44List& array, float lengthFactor=1.0f); - inline static void ToMatrixList(const string& value, FMMatrix44List& array, float lengthFactor=1.0f) { return ToMatrixList(value.c_str(), array, lengthFactor); } /**< See above. */ -#ifdef UNICODE - static void ToMatrixList(const fchar* value, FMMatrix44List& array, float lengthFactor=1.0f); /**< See above. */ - inline static void ToMatrixList(const fstring& value, FMMatrix44List& array, float lengthFactor=1.0f) { return ToMatrixList(value.c_str(), array, lengthFactor); } /**< See above. */ -#endif - - /** Parses a string into a list of 3D points. - @param value The string. - @param array The list of 3D points to fill in. - @param lengthFactor An optional factor that will scale the points. */ - static void ToPointList(const char* value, FMVector3List& array, float lengthFactor=1.0f); - inline static void ToPointList(const string& value, FMVector3List& array, float lengthFactor=1.0f) { return ToPointList(value.c_str(), array, lengthFactor); } /**< See above. */ -#ifdef UNICODE - static void ToPointList(const fchar* value, FMVector3List& array, float lengthFactor=1.0f); /**< See above. */ - inline static void ToPointList(const fstring& value, FMVector3List& array, float lengthFactor=1.0f) { return ToPointList(value.c_str(), array, lengthFactor); } /**< See above. */ -#endif - - /** Converts a list of floating-point values into a string. - @param builder The string builder that will contain the list of values. - This string builder is not cleared of its contents and a space - character will be added if it is not empty. - @param values The list of floating-point values to convert. - @param lengthFactor An optional factor that will scale all the - floating-point values. */ - static void ToString(FUSStringBuilder& builder, const FloatList& values, float lengthFactor=1.0f); - - /** Converts a list of signed integers into a string. - @param builder The string builder that will contain the list of values. - This string builder is not cleared of its contents and a space - character will be added if it is not empty. - @param values The list of signed integers to convert. */ - static void ToString(FUSStringBuilder& builder, const Int32List& values); - - /** Converts a list of unsigned integers into a string. - @param builder The string builder that will contain the list of values. - This string builder is not cleared of its contents and a space - character will be added if it is not empty. - @param values The list of unsigned integers to convert. */ - static void ToString(FUSStringBuilder& builder, const UInt32List& values); - -#endif // HAS_VECTORTYPES - - /** Converts a 4D vector into a string. - @param p The 4D vector to convert. - @param lengthFactor An optional factor that will scale the vector. - @return The string containing the converted vector. */ - static string ToString(const FMVector4& p, float lengthFactor=1.0f); - - /** Converts a matrix into a string. - @param value The matrix to convert. - @param lengthFactor An optional factor that will scale the translation - column of the matrix. - @return The string containing the converted matrix. */ - static string ToString(const FMMatrix44& value, float lengthFactor=1.0f); - static fstring ToFString(const FMMatrix44& value, float lengthFactor=1.0f); /**< See above. */ - - /** Converts a 3D vector into a string. - @param value The 3D vector to convert. - @param lengthFactor An optional factor that will scale the vector. - @return The string containing the converted vector. */ - static string ToString(const FMVector3& value, float lengthFactor=1.0f); - static fstring ToFString(const FMVector3& value, float lengthFactor=1.0f); /**< See above. */ - - /** Converts a datetime structure into a string. - @param dateTime The datetime structure to convert. - @return The string containing the converted datetime structure. */ - static string ToString(const FUDateTime& dateTime); - static fstring ToFString(const FUDateTime& dateTime); /**< See above. */ - - /** Converts a primitive value into a string. - This function is templatized to use the global string builders to - convert most primitive value types, such as signed integers, - unsigned integers and single floating-point values, into strings. - @see FUStringBuilderT - @param value A primitive value. - @return The string containing the converted primitive value. */ - template static string ToString(const T& value) { globalSBuilder.set(value); return globalSBuilder.ToString(); } - template static fstring ToFString(const T& value) { globalBuilder.set(value); return globalBuilder.ToString(); } /**< See above. */ - - /** Converts a matrix into a string. - @param builder The string builder that will contain the matrix. - This string builder is not cleared of its contents. - @param value The matrix to convert. - @param lengthFactor An optional factor that will scale the translation - column of the matrix. */ - static void ToString(FUSStringBuilder& builder, const FMMatrix44& value, float lengthFactor=1.0f); - static void ToFString(FUStringBuilder& builder, const FMMatrix44& value, float lengthFactor=1.0f); /**< See above. */ - - /** Converts a 3D vector into a string. - @param builder The string builder that will contain the 3D vector. - This string builder is not cleared of its contents. - @param value The 3D vector to convert. - @param lengthFactor An optional factor that will scale the vector. */ - static void ToString(FUSStringBuilder& builder, const FMVector3& value, float lengthFactor=1.0f); - static void ToFString(FUStringBuilder& builder, const FMVector3& value, float lengthFactor=1.0f); /**< See above. */ - - /** Converts a 4D vector into a string. - @param builder The string builder that will contain the 4D vector. - This string builder is not cleared of its contents. - @param p The 4D vector to convert. - @param lengthFactor An optional factor that will scale the vector. */ - static void ToString(FUSStringBuilder& builder, const FMVector4& p, float lengthFactor=1.0f); -}; - -#endif // _FCU_STRING_CONVERSION_ diff --git a/Extras/FCollada/FUtils/FUUniqueStringMap.h b/Extras/FCollada/FUtils/FUUniqueStringMap.h deleted file mode 100644 index aafb31668..000000000 --- a/Extras/FCollada/FUtils/FUUniqueStringMap.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FUUniqueStringMap.h - This file contains the FUUniqueStringMapT template. -*/ - -#ifndef _FU_UNIQUE_ID_MAP_H_ -#define _FU_UNIQUE_ID_MAP_H_ - -/** - A set of unique strings. - This class adds three functions to the STL map in order to - keep the strings inside unique: AddUniqueString, Exists and Erase. - - @ingroup FUtils -*/ -template -class FUUniqueStringMapT : map -{ -private: - typedef map Super; - -public: - /** Adds a string to the map. - If the string isn't unique, it will be modified in order to make it unique. - @param wantedStr The string to add. This reference will be directly - modified to hold the actual unique string added to the map. */ - void AddUniqueString(typename STRING_BUILDER::String& wantedStr); - - /** Retrieves whether a given string is contained within the map. - @param str The string. */ - bool Exists(const typename STRING_BUILDER::String& str) const; - - /** Erases a string from the map. - @param str A string contained within the map. */ - void Erase(const typename STRING_BUILDER::String& str); -}; - -typedef FUUniqueStringMapT FUSUniqueStringMap; /**< A map of unique UTF-8 strings. */ -typedef FUUniqueStringMapT FUUniqueStringMap; /**< A map of unique Unicode strings. */ - -template -void FUUniqueStringMapT::AddUniqueString(typename Builder::String& wantedStr) -{ - if (Exists(wantedStr)) - { - // Attempt to generate a new string by appending an increasing counter. - uint32 counter = 2; - static const int maxCounter = 256; - Builder buffer; - buffer.reserve(wantedStr.length() + 5); - do - { - buffer.set(wantedStr); - buffer.append(counter); - } while (counter++ < maxCounter && Exists(buffer.ToString())); - - // Hopefully, this is now unique. - wantedStr = buffer.ToString(); - } - insert(Super::value_type(wantedStr, NULL)); -} - -template -bool FUUniqueStringMapT::Exists(const typename Builder::String& str) const -{ - const_iterator it = find(str); - return it != end(); -} - -template -void FUUniqueStringMapT::Erase(const typename Builder::String& str) -{ - iterator it = find(str); - if (it != end()) erase(it); -} - -#endif // _FU_UNIQUE_ID_MAP_H_ - diff --git a/Extras/FCollada/FUtils/FUUri.h b/Extras/FCollada/FUtils/FUUri.h deleted file mode 100644 index baaef460e..000000000 --- a/Extras/FCollada/FUtils/FUUri.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _FU_URI_H_ -#define _FU_URI_H_ - -class FUUri -{ -public: - fstring prefix; - string suffix; -}; - -#endif // _FU_URI_H_ - diff --git a/Extras/FCollada/FUtils/FUXmlNodeIdPair.h b/Extras/FCollada/FUtils/FUXmlNodeIdPair.h deleted file mode 100644 index b9e464fe4..000000000 --- a/Extras/FCollada/FUtils/FUXmlNodeIdPair.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _FU_XML_NODE_ID_PAIR_H_ -#define _FU_XML_NODE_ID_PAIR_H_ - -#ifdef HAS_LIBXML - -class FUXmlNodeIdPair -{ -public: - FUCrc32::crc32 id; - xmlNode* node; -}; - -typedef vector FUXmlNodeIdPairList; - -#endif // HAS_LIBXML - -#endif // _FU_XML_NODE_ID_PAIR_H_ - diff --git a/Extras/FCollada/FUtils/FUXmlParser.cpp b/Extras/FCollada/FUtils/FUXmlParser.cpp deleted file mode 100644 index ffd833ea6..000000000 --- a/Extras/FCollada/FUtils/FUXmlParser.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FUtils/FUXmlParser.h" - -#define xmlT(a) (const xmlChar*) (a) - -namespace FUXmlParser -{ - // Returns the first child node of a given type - xmlNode* FindChildByType(xmlNode* parent, const char* type) - { - if (parent != NULL) - { - for (xmlNode* child = parent->children; child != NULL; child = child->next) - { - if (child->type == XML_ELEMENT_NODE) - { - if (IsEquivalent(child->name, type)) return child; - } - } - } - return NULL; - } - - // return the first child node of a given name - xmlNode* FindChildByName(xmlNode* parent, const char* name) - { - if (parent != NULL) - { - for (xmlNode* child = parent->children; child != NULL; child = child->next) - { - if (child->type == XML_ELEMENT_NODE) - { - string str_name = ReadNodeProperty(child, "name"); - if (str_name == name) return child; - } - } - } - return NULL; - } - - - // return the first child node of a given property value - xmlNode* FindChildByProperty(xmlNode* parent, const char* prop, const char* val ) - { - if (parent != NULL) - { - for (xmlNode* child = parent->children; child != NULL; child = child->next) - { - string str_pop = ReadNodeProperty(child, prop); - if (str_pop == val) return child; - - } - } - return NULL; - } - - // return the first node in list of a given property - xmlNode* FindNodeInListByProperty(xmlNodeList list, const char* property, const char* prop) - { - for (xmlNodeList::iterator it = list.begin(); it != list.end(); ++it) - { - xmlNode* element = *it; - string str_prop = ReadNodeProperty(element, property); - if (str_prop == prop) return element; - - } - return NULL; - } - - // Retrieves all the child nodes of a given type - void FindChildrenByType(xmlNode* parent, const char* type, xmlNodeList& nodes) - { - if (parent != NULL) - { - for (xmlNode* child = parent->children; child != NULL; child = child->next) - { - if (child->type == XML_ELEMENT_NODE) - { - if (IsEquivalent(child->name, type)) nodes.push_back(child); - } - } - } - } - - // Returns whether the given node has the given property - bool HasNodeProperty(xmlNode* node, const char* property) - { - xmlAttr* attribute = xmlHasProp(node, xmlT(property)); - return attribute != NULL; - } - - // Returns the string value of a node's property - string ReadNodeProperty(xmlNode* node, const char* property) - { - string ret=""; - if (node != NULL && property != NULL) - { - xmlChar* data = xmlGetProp(node, xmlT(property)); - if (data != NULL) - { - ret = (const char*) data; - } - xmlFree(data); - } - - // Process the string for special characters - XmlToString(ret); - return ret; - } - - // Returns the CRC value of a node's property - FUCrc32::crc32 ReadNodePropertyCRC(xmlNode* node, const char* property) - { - FUCrc32::crc32 ret = 0; - if (node != NULL && property != NULL) - { - xmlChar* data = xmlGetProp(node, xmlT(property)); - if (data != NULL) ret = FUCrc32::CRC32((const char*) data); - xmlFree(data); - } - return ret; - } - - // Returns the text content directly attached to a node - const char* ReadNodeContentDirect(xmlNode* node) - { - if (node == NULL || node->children == NULL - || node->children->type != XML_TEXT_NODE || node->children->content == NULL) return ""; - return (const char*) node->children->content; - } - - // Returns the inner text content of a node - string ReadNodeContentFull(xmlNode* node) - { - string ret; - if (node != NULL) - { - xmlChar* content = xmlNodeGetContent(node); - ret = (const char*) content; - xmlFree(content); - } - return ret; - } - - // Convert a XML string to a text string: handles the '%' character - void XmlToString(string& s) - { - if (s.find('%') == string::npos) return; - - // Replace all the '%XX' characters by the equivalent hex value - const char* original = s.c_str(); - uint32 length = (uint32) s.length(); - char* copy = new char[length],* p = copy; - for (uint32 i = 0; i < length; ++i, ++p) - { - char c = original[i]; - if (c != '%' || i >= length - 2) *p = c; - else - { - char* dummy; - p[0] = original[i + 1]; p[1] = original[i + 2]; p[2] = 0; - uint32 v = strtoul(p, &dummy, 16); - *p = (char) v; - i += 2; - } - } - *p = 0; - s = copy; - } -}; diff --git a/Extras/FCollada/FUtils/FUXmlParser.h b/Extras/FCollada/FUtils/FUXmlParser.h deleted file mode 100644 index ee46b7d6b..000000000 --- a/Extras/FCollada/FUtils/FUXmlParser.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _FU_XML_PARSER_H_ -#define _FU_XML_PARSER_H_ - -#ifdef HAS_LIBXML - -namespace FUXmlParser -{ - // Retrieve specific child nodes - FCOLLADA_EXPORT xmlNode* FindChildByType(xmlNode* parent, const char* type); - FCOLLADA_EXPORT xmlNode* FindChildByName(xmlNode* parent, const char* name); - FCOLLADA_EXPORT void FindChildrenByType(xmlNode* parent, const char* type, xmlNodeList& nodes); - FCOLLADA_EXPORT xmlNode* FindChildByProperty(xmlNode* parent, const char* prop, const char* val ); - FCOLLADA_EXPORT xmlNode* FindNodeInListByProperty(xmlNodeList list, const char* property, const char* prop); - - // Retrieve node property and content - FCOLLADA_EXPORT bool HasNodeProperty(xmlNode* node, const char* property); - FCOLLADA_EXPORT string ReadNodeProperty(xmlNode* node, const char* property); - FCOLLADA_EXPORT FUCrc32::crc32 ReadNodePropertyCRC(xmlNode* node, const char* property); - FCOLLADA_EXPORT const char* ReadNodeContentDirect(xmlNode* node); - FCOLLADA_EXPORT string ReadNodeContentFull(xmlNode* node); - - // Process values - FCOLLADA_EXPORT void XmlToString(string& s); -}; - -inline bool IsEquivalent(const xmlChar* sz1, const char* sz2) { return IsEquivalent((const char*) sz1, sz2); } - -#endif // HAS_LIBXML - -#endif //_FU_XML_PARSER_H_ diff --git a/Extras/FCollada/FUtils/FUXmlWriter.cpp b/Extras/FCollada/FUtils/FUXmlWriter.cpp deleted file mode 100644 index f4dfbd463..000000000 --- a/Extras/FCollada/FUtils/FUXmlWriter.cpp +++ /dev/null @@ -1,137 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#include "StdAfx.h" -#include "FUtils/FUXmlWriter.h" -#include "FUtils/FUXmlParser.h" -#include "FUtils/FUStringConversion.h" - -#define xcT(text) (const xmlChar*) (text) - -namespace FUXmlWriter -{ - // Create a new xml tree node - xmlNode* CreateNode(const char* name) - { - return xmlNewNode(NULL, xcT(name)); - } - - // Create a new xml tree child node, parented to the given xml tree node - void AddChild(xmlNode* parent, xmlNode* child) - { - xmlAddChild(parent, child); - } - - xmlNode* AddChild(xmlNode* parent, const char* name) - { - return (parent != NULL) ? xmlNewChild(parent, NULL, xcT(name), NULL) : NULL; - } - - xmlNode* AddChild(xmlNode* parent, const char* name, const char* content) - { - if (content != NULL && *content == 0) content = NULL; - return (parent != NULL) ? xmlNewChild(parent, NULL, xcT(name), xcT(content)) : NULL; - } - -#ifdef UNICODE - xmlNode* AddChild(xmlNode* parent, const char* name, const fstring& content) - { - string s = FUStringConversion::ToString(content); - return AddChild(parent, name, !s.empty() ? s.c_str() : NULL); - } -#endif - - xmlNode* AddChildOnce(xmlNode* parent, const char* name, const char* content) - { - xmlNode* node = NULL; - if (parent != NULL) - { - node = FUXmlParser::FindChildByType(parent, name); - if (node == NULL) node = AddChild(parent, name, (content == NULL || *content == 0) ? NULL : content); - } - return node; - } - - // Create/Append a new xml tree node, as a sibling to a given xml tree node - void AddSibling(xmlNode* sibling, xmlNode* dangling) - { - xmlAddSibling(sibling, dangling); - } - - xmlNode* AddSibling(xmlNode* node, const char* name) - { - xmlNode* n = CreateNode(name); - AddSibling(node, n); - return n; - } - - void AddContent(xmlNode* node, const char* content) - { - if (node != NULL) - { - xmlNodeAddContent(node, xcT(content)); - } - } - -#ifdef UNICODE - void AddContent(xmlNode* node, const fstring& content) - { - string s = FUStringConversion::ToString(content); - AddContent(node, s.c_str()); - } -#endif - - void AddAttribute(xmlNode* node, const char* attributeName, const char* value) - { - if (node != NULL) - { - xmlNewProp(node, xcT(attributeName), xcT(value)); - } - } - -#ifdef UNICODE - void AddAttribute(xmlNode* node, const char* attributeName, const fstring& attributeValue) - { - string s = FUStringConversion::ToString(attributeValue); - AddAttribute(node, attributeName, s.c_str()); - } -#endif - - // Insert a child, respecting lexical ordering - void AddChildSorted(xmlNode* parent, xmlNode* child) - { - // Do an insertion sort in alphabetical order of the element names. - // Walk backward from the last child, to make sure that - // the chronological ordering of elements of the same type is respected. - // - for (xmlNode* p = xmlGetLastChild(parent); p != NULL; p = p->prev) - { - if (p->type != XML_ELEMENT_NODE) continue; - if (strcmp((const char*) p->name, (const char*) child->name) <= 0) - { - xmlAddNextSibling(p, child); - return; - } - } - - // Add to the top of the list. - if (parent->children && parent->children->type == XML_ELEMENT_NODE) - { - xmlAddPrevSibling(parent->children, child); - } - else - { - AddChild(parent, child); - } - } - - xmlNode* AddChildSorted(xmlNode* parent, const char* name, const char* content) - { - xmlNode* node = CreateNode(name); - if (content != NULL && *content != 0) xmlNodeAddContent(node, xcT(content)); - AddChildSorted(parent, node); - return node; - } -}; diff --git a/Extras/FCollada/FUtils/FUXmlWriter.h b/Extras/FCollada/FUtils/FUXmlWriter.h deleted file mode 100644 index 38e621265..000000000 --- a/Extras/FCollada/FUtils/FUXmlWriter.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FUXmlWriter.h - This file defines the FUXmlWriter namespace. -*/ - -#ifndef _FU_XML_WRITER_H_ -#define _FU_XML_WRITER_H_ - -#ifdef HAS_LIBXML - -/** - Common XML writing utility functions. - Based on top of the LibXML2 library. - This whole namespace is considered external and should only be used - by the FCollada library. - - @ingroup FUtils -*/ -namespace FUXmlWriter -{ - /** Creates a dangling XML tree node. - @param name The name of the new XML tree node. - @return The new XML tree node. This pointer should never be NULL. */ - FCOLLADA_EXPORT xmlNode* CreateNode(const char* name); - - /** Appends a dangling XML tree child node to a XML tree node. - The child XML tree node is added at the end of the parent XML tree node children list. - @param parent The parent XML tree node. - @param child The child XML tree node. */ - FCOLLADA_EXPORT void AddChild(xmlNode* parent, xmlNode* child); - - /** Creates a child XML tree node within a XML tree node. - The child XML tree node is added at the end of the parent XML tree node children list. - @param parent The parent XML tree node. - @param name The name of the new child node. - @return The new child XML tree node. */ - FCOLLADA_EXPORT xmlNode* AddChild(xmlNode* parent, const char* name); - - /** Creates a child XML tree node within a XML tree node. - The child XML tree node is added at the end of the parent XML tree node children list. - The given content string is added to the returned child XML tree node. - @param parent The parent XML tree node. - @param name The name of the new child XML tree node. - @param content The content to add to the new child XML tree node. - @return The new child XML tree node. */ - FCOLLADA_EXPORT xmlNode* AddChild(xmlNode* parent, const char* name, const char* content); -#ifdef UNICODE - FCOLLADA_EXPORT xmlNode* AddChild(xmlNode* parent, const char* name, const fstring& content); /**< See above. */ -#endif - inline xmlNode* AddChild(xmlNode* parent, const char* name, const string& content) { return AddChild(parent, name, content.c_str()); } /**< See above. */ - inline xmlNode* AddChild(xmlNode* parent, const char* name, FUSStringBuilder& content) { return AddChild(parent, name, content.ToCharPtr()); } /**< See above. */ - - /** Creates a child XML tree node within a XML tree node. - The child XML tree node is added at the end of the parent XML tree node children list. - The given content value is added, in string-form, to the returned child XML tree node. - @param parent The parent XML tree node. - @param name The name of the new child XML tree node. - @param value A primitive value. This value is stringified and added, as content, to the new child XML tree node. - @return The new child XML tree node. */ - template inline xmlNode* AddChild(xmlNode* parent, const char* name, const T& value) { globalSBuilder.set(value); return AddChild(parent, name, globalSBuilder); } - - /** Appends a dangling XML tree node as a sibling of a XML tree node. - Two sibling XML tree nodes have the same parent XML tree node. - The dangling XML tree node is added at the end of the parent XML tree node children list. - @param sibling The sibling XML tree node. It must have a valid parent XML tree node. - @param dangling The dangling XML tree node. */ - FCOLLADA_EXPORT void AddSibling(xmlNode* sibling, xmlNode* dangling); - - /** Creates a XML tree node as a sibling of a XML tree node. - Two sibling XML tree nodes have the same parent XML tree node. - The new XML tree node is added at the end of the parent XML tree node children list. - @param sibling The sibling XML tree node. It must have a valid parent XML tree node. - @param name The name of the new XML tree node. - @return The new sibling XML tree node. */ - FCOLLADA_EXPORT xmlNode* AddSibling(xmlNode* sibling, const char* name); - - /** Returns a child XML tree node within a XML tree node. - If the child XML tree node with the given name does not exists, it is created and - the given content is added to the new XML tree node. - @param parent The parent XML tree node. - @param name The name of the child XML tree node. - @param content The content to add to the child XML tree node, if it must be created. - @return The child XML tree node. */ - FCOLLADA_EXPORT xmlNode* AddChildOnce(xmlNode* parent, const char* name, const char* content=NULL); - inline xmlNode* AddChildOnce(xmlNode* parent, const char* name, const string& content) { return AddChildOnce(parent, name, content.c_str()); } /**< See above. */ - inline xmlNode* AddChildOnce(xmlNode* parent, const char* name, FUSStringBuilder& content) { return AddChildOnce(parent, name, content.ToCharPtr()); } /**< See above. */ - - /** Returns a child XML tree node within a XML tree node. - If the child XML tree node with the given name does not exists, it is created and - the given content is added to the new XML tree node. - @param parent The parent XML tree node. - @param name The name of the child XML tree node. - @param value A primitive value. If the child XML tree node must be created: this value is stringified and added as content. - @return The child XML tree node. */ - template inline xmlNode* AddChildOnce(xmlNode* parent, const char* name, const T& value) { globalSBuilder.set(value); return AddChildOnce(parent, name, globalSBuilder); } - - /** Appends a content string to a XML tree node. - The content string is added at the end of the XML tree node's content, with no special characters added. - @param node The XML tree node. - @param content The content to add to the XML tree node. */ - FCOLLADA_EXPORT void AddContent(xmlNode* node, const char* content); -#ifdef UNICODE - FCOLLADA_EXPORT void AddContent(xmlNode* node, const fstring& content); /**< See above. */ -#endif - inline void AddContent(xmlNode* node, const string& content) { AddContent(node, content.c_str()); } /**< See above. */ - inline void AddContent(xmlNode* node, FUSStringBuilder& content) { AddContent(node, content.ToCharPtr()); } /**< See above. */ - - /** Appends a primitive value to a XML tree node. - The primitive value is added at the end of the XML tree node's content, with no special characters added. - @param node The XML tree node. - @param value A primitive value. The value is stringified and added as content to the XML tree node. */ - template inline void AddContent(xmlNode* node, const T& value) { globalSBuilder.set(value); return AddContent(node, globalSBuilder); } - - /** Appends a XML attribute to a XML tree node. - A XML attribute appears in the form @. - @param node The XML tree node. - @param attributeName The name of the XML attribute. - @param attributeValue The value of the XML attribute. */ - FCOLLADA_EXPORT void AddAttribute(xmlNode* node, const char* attributeName, const char* attributeValue); -#ifdef UNICODE - FCOLLADA_EXPORT void AddAttribute(xmlNode* node, const char* attributeName, const fstring& attributeValue); /**< See above. */ -#endif - inline void AddAttribute(xmlNode* node, const char* attributeName, FUSStringBuilder& attributeValue) { AddAttribute(node, attributeName, attributeValue.ToCharPtr()); } /**< See above. */ - inline void AddAttribute(xmlNode* node, const char* attributeName, const string& attributeValue) { AddAttribute(node, attributeName, attributeValue.c_str()); } /**< See above. */ - - /** Appends a XML attribute to a XML tree node. - A XML attribute appears in the form @. - @param node The XML tree node. - @param attributeName The name of the XML attribute. - @param attributeValue A primitive value. The value is stringified and set as the value of the XML attribute. */ - template inline void AddAttribute(xmlNode* node, const char* attributeName, const T& attributeValue) { globalSBuilder.set(attributeValue); AddAttribute(node, attributeName, globalSBuilder.ToCharPtr()); } - - /** Appends a dangling XML tree node to a XML tree node - The dangling XML tree node is inserted in lexical order, - after all the sibling XML tree node with the same name. - @param parent The XML tree node onto which the dangling XML node tree is appended. - @param child The dangling XML tree node. */ - FCOLLADA_EXPORT void AddChildSorted(xmlNode* parent, xmlNode* child); - - /** Creates a new child XML tree node of a XML tree node - The new child XML tree node is inserted in lexical order, - after all the sibling XML tree node with the same name. - @param parent The XML tree node onto which the new XML node tree is created. - @param name The name of the new child XML tree node. - @param content A content string to be added to the child XML tree node. - @return The new child XML tree node. */ - FCOLLADA_EXPORT xmlNode* AddChildSorted(xmlNode* parent, const char* name, const char* content=NULL); -}; - -#endif // HAS_LIBXML - -#endif // _FU_XML_WRITER_H_ diff --git a/Extras/FCollada/FUtils/FUtils.h b/Extras/FCollada/FUtils/FUtils.h deleted file mode 100644 index 043e0a8fc..000000000 --- a/Extras/FCollada/FUtils/FUtils.h +++ /dev/null @@ -1,92 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -/** - @file FUtils.h - Includes the common utilities classes and macros. -*/ - -/** @defgroup FUtils Utility Classes. */ - -#ifndef _F_UTILS_H_ -#define _F_UTILS_H_ - -// STL -#ifdef _WIN32 -#pragma warning(disable:4702) -#endif -#include -#include -#include -#include -#include -#include -#ifdef _WIN32 -#pragma warning(default:4702) -#endif - -// Pre-include the platform-specific macros and definitions -#include "FUtils/Platforms.h" -#include "FUtils/FUAssert.h" - -// PLUG_CRT enforces CRT memory checks every 128 allocations -// and CRT memory leaks output -#if defined(_DEBUG) && defined(WIN32) && defined(MEMORY_DEBUG) -#define PLUG_CRT -#ifdef PLUG_CRT -#include -#define DEBUG_CLIENTBLOCK new( _CLIENT_BLOCK, __FILE__, __LINE__) -#define new DEBUG_CLIENTBLOCK -#endif // PLUG_CRT -#endif // _DEBUG & WIN32 & MEMORY_DEBUG - -// FMath -#define HAS_VECTORTYPES /**< Used by FCollada, this #define implies that we are including all the common dynamically-sized arrays. */ -#include "FMath/FMath.h" - -// LibXML -#ifndef NO_LIBXML -#define HAS_LIBXML /**< Used by FCollada, this #define implies that we are including LibXML functions in the library interface. */ -#define LIBXML_STATIC /**< Used by LibXML, this #define implies that we are statically-linking the LibXML. */ -#include -#else -typedef struct _xmlNode xmlNode; -#endif -typedef vector xmlNodeList; /**< A dynamically-sized array of XML nodes. */ - -// SAFE_DELETE Macro set. -#define SAFE_DELETE(ptr) if ((ptr) != NULL) { delete (ptr); (ptr) = NULL; } /**< This macro safely deletes a pointer and sets the given pointer to NULL. */ -#define SAFE_DELETE_ARRAY(ptr) if (ptr != NULL) { delete [] ptr; ptr = NULL; } /**< This macro safely deletes an heap array and sets the given pointer to NULL. */ -#define SAFE_FREE(ptr) if (ptr != NULL) { free(ptr); ptr = NULL; } /**< This macro safely frees a memory block and sets the given pointer to NULL. */ -#define SAFE_RELEASE(ptr) if ((ptr) != NULL) { (ptr)->Release(); (ptr) = NULL; } /**< This macro safely releases an interface and sets the given pointer to NULL. */ -#define CLEAR_POINTER_VECTOR(a) { size_t l = (a).size(); for (size_t i = 0; i < l; ++i) SAFE_DELETE((a)[i]); (a).clear(); } /**< This macro deletes all the object pointers contained within a vector and clears it. */ -#define CLEAR_POINTER_MAP(mapT, a) { for (mapT::iterator it = (a).begin(); it != (a).end(); ++it) SAFE_DELETE((*it).second); (a).clear(); } /**< This macro deletes all the object pointers contained within a map and clears it. */ - -// Conversion macros -#define UNUSED(a) /**< Removes a piece of code during the pre-process. This macro is useful for these pesky unused variable warnings. */ -#ifdef _DEBUG -#define UNUSED_NDEBUG(a) a -#else -#define UNUSED_NDEBUG(a) /**< Removes a piece of debug code during the pre-process. This macro is useful for these pesky unused variable warnings. */ -#endif // _DEBUG - -#undef min -#define min(a, b) std::min(a, b) /**< Retrieves the smallest of two values. */ -#undef max -#define max(a, b) std::max(a, b) /**< Retrieves the largest of two values. */ - -// More complex utility classes -#include "FUtils/FUString.h" -#include "FUtils/FUCrc32.h" -#include "FUtils/FUDebug.h" -#include "FUtils/FUStatus.h" - -#endif // _F_UTILS_H_ diff --git a/Extras/FCollada/FUtils/FUtils_vc7.vcproj b/Extras/FCollada/FUtils/FUtils_vc7.vcproj deleted file mode 100644 index 023aa727a..000000000 --- a/Extras/FCollada/FUtils/FUtils_vc7.vcproj +++ /dev/null @@ -1,964 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/FCollada/FUtils/FUtils_vc8.vcproj b/Extras/FCollada/FUtils/FUtils_vc8.vcproj deleted file mode 100644 index ef6a7a4bc..000000000 --- a/Extras/FCollada/FUtils/FUtils_vc8.vcproj +++ /dev/null @@ -1,964 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/Extras/FCollada/FUtils/Makefile b/Extras/FCollada/FUtils/Makefile deleted file mode 100644 index 1ff905ce0..000000000 --- a/Extras/FCollada/FUtils/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/make -# FUtils makefile for PS3 - -include ../../MakeDefs - -LIBNAME = libfutils - -prefix=.. - -INCPATH=$(prefix)/include -LIBPATH=$(prefix)/lib - -PPU_INCDIRS=-I$(INCPATH) -I.. -I../LibXML/include -PPU_OPTIMIZE_LV= -O3 -funroll-loops - -PPU_LIB_TARGET=$(LIBNAME).a -PPU_SRCS = \ - FUCrc32.cpp \ - FUDaeEnum.cpp \ - FUDaeParser.cpp \ - FUDaeWriter.cpp \ - FUDateTime.cpp \ - FUDebug.cpp \ - FUFile.cpp \ - FUFileManager.cpp \ - FULogFile.cpp \ - FUObject.cpp \ - FUStringConversion.cpp \ - FUXmlParser.cpp \ - FUXmlWriter.cpp \ - StdAfx.cpp - -include ../../MakeRules diff --git a/Extras/FCollada/FUtils/Makefile.am b/Extras/FCollada/FUtils/Makefile.am deleted file mode 100644 index 6aece0d36..000000000 --- a/Extras/FCollada/FUtils/Makefile.am +++ /dev/null @@ -1,6 +0,0 @@ -INCLUDES = -I$(top_srcdir)/. -I/usr/include/libxml2 -METASOURCES = AUTO -noinst_LIBRARIES = libFUtils.a -libFUtils_a_SOURCES = FUDaeParser.cpp FUStringConversion.cpp FUXmlParser.cpp \ - FUDebug.cpp -noinst_HEADERS = FUDebug.h diff --git a/Extras/FCollada/FUtils/Platforms.h b/Extras/FCollada/FUtils/Platforms.h deleted file mode 100644 index 78ca07268..000000000 --- a/Extras/FCollada/FUtils/Platforms.h +++ /dev/null @@ -1,181 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ -/* - Based on the FS Import classes: - Copyright (C) 2005-2006 Feeling Software Inc - Copyright (C) 2005-2006 Autodesk Media Entertainment - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _PLATFORMS_H_ -#define _PLATFORMS_H_ - -#ifdef FCOLLADA_DLL -// Disable the "private member not available for export" warning, -// because I don't feel like writing interfaces -#pragma warning(disable:4251) -#ifdef FCOLLADA_INTERNAL -#define FCOLLADA_EXPORT __declspec(dllexport) -#else -#define FCOLLADA_EXPORT __declspec(dllimport) -#endif -#else -#define FCOLLADA_EXPORT -#endif - -// Ensure that both UNICODE and _UNICODE are set. -#ifdef UNICODE -#ifndef _UNICODE -#define _UNICODE -#endif -#else -#ifdef _UNICODE -#define UNICODE -#endif -#endif - -#include - -#ifdef WIN32 -#pragma warning(disable:4702) -#include -#else -#ifdef MAC_TIGER -#include -#include -#else // MAC_TIGER -#if defined(LINUX) -#else // LINUX -#error "Unsupported platform." -#endif // LINUX -#endif // MAC_TIGER - -#endif // WIN32 - -// Cross-platform type definitions -#ifdef WIN32 - -#define int8 char -typedef short int16; -typedef long int32; -typedef __int64 int64; -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned long uint32; -typedef unsigned __int64 uint64; - -#else // For LINUX and MAC_TIGER - -#define int8 char -typedef short int16; -typedef long int32; -typedef long long int64; -typedef unsigned char uint8; -typedef unsigned short uint16; -typedef unsigned long uint32; -typedef unsigned long long uint64; -#endif - -// Important functions that some OSes have missing! -#ifdef MAC_TIGER -inline char* strlower(char* str) { char* it = str; while (*it != 0) { *it = tolower(*it); ++it; } return str; } -inline wchar_t* wcslwr(wchar_t* str) { wchar_t* it = str; while (*it != 0) { *it = towlower(*it); ++it; } return str; } -#ifndef isinf -#define isinf __isinff -#endif -#define stricmp strcasecmp - -#endif // MAC_TIGER - -// Cross-platform needed functions -#ifdef WIN32 - -#define vsnprintf _vsnprintf -#define snprintf _snprintf -#define vsnwprintf _vsnwprintf -#define snwprintf _snwprintf -#define strlower _strlwr - -#else // WIN32 - -#define vsnwprintf vswprintf -#define snwprintf swprintf - -#endif // WIN32 - -// For Doxygen purposes, we stopped using the "using namespace std;" statement and use shortcuts instead. - -/** A STL string. */ -typedef std::string string; - -/** A STL map. */ -template -class map : public std::map<_Kty, _Ty> {}; - -// fstring and character definition -#ifdef UNICODE -#ifdef WIN32 - -#include - typedef TCHAR fchar; - typedef std::basic_string fstring; - #define FC(a) __T(a) - - #define fstrlen _tcslen - #define fstrcmp _tcscmp - #define fstricmp _tcsicmp - #define fstrncpy _tcsncpy - #define fstrrchr _tcsrchr - #define fstrlower _tcslwr - #define fsnprintf _sntprintf - #define fvsnprintf _vsntprintf - - #define fchdir _tchdir - -#else // For MacOSX and Linux platforms - - #define fchar wchar_t - typedef std::wstring fstring; - #define FC(a) L ## a - - #define fstrlen wcslen - #define fstrcmp wcscmp - #define fstricmp wcsicmp - #define fstrncpy wcsncpy - #define fstrrchr wcsrchr - #define fstrlower wcslwr - #define fsnprintf swprintf - #define fvsnprintf vswprintf - - #define fchdir(a) chdir(FUStringConversion::ToString(a).c_str()) - -#endif // WIN32 - -#else // UNICODE - -typedef char fchar; -typedef std::basic_string fstring; -#define FC(a) a - -#define fstrlen strlen -#define fstrcmp strcmp -#define fstricmp stricmp -#define fstrncpy strncpy -#define fstrrchr strrchr -#define fstrlower strlower -#define fsnprintf snprintf -#define fvsnprintf vsnprintf - -#define fatol atol -#define fatof atof -#define fchdir chdir - -#endif // UNICODE - -#ifndef WIN32 -#define MAX_PATH 1024 -#endif // !WIN32 - -#endif // _PLATFORMS_H_ diff --git a/Extras/FCollada/FUtils/StdAfx.cpp b/Extras/FCollada/FUtils/StdAfx.cpp deleted file mode 100644 index 9b13c1ca1..000000000 --- a/Extras/FCollada/FUtils/StdAfx.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "StdAfx.h" diff --git a/Extras/FCollada/FUtils/StdAfx.h b/Extras/FCollada/FUtils/StdAfx.h deleted file mode 100644 index afce5a589..000000000 --- a/Extras/FCollada/FUtils/StdAfx.h +++ /dev/null @@ -1,11 +0,0 @@ -/* - Copyright (C) 2005-2006 Feeling Software Inc. - MIT License: http://www.opensource.org/licenses/mit-license.php -*/ - -#ifndef _STD_AFX_H_ -#define _STD_AFX_H_ - -#include "FUtils/FUtils.h" - -#endif // _STD_AFX_H_ diff --git a/Extras/FCollada/GenerateDoxygen.py b/Extras/FCollada/GenerateDoxygen.py deleted file mode 100644 index e98c0eaa2..000000000 --- a/Extras/FCollada/GenerateDoxygen.py +++ /dev/null @@ -1,15 +0,0 @@ -import os - -# Run the Doxygen application to generate the documentation. -os.system("rd /q/s \"Output/Doxygen\"") -os.system("mkdir \"Output/Doxygen\"") -os.system("doxygen.exe Doxyfile") - -# Generate a second index file which simply points to the inner one. -indexFile = open("Output/Doxygen/FCollada.html", "w") -indexFile.write("FCollada Documentation") -indexFile.write("") -indexFile.close() - -# Open the Doxygeon log file to users so they know what's missing. -os.system("write \"Output/Doxygen/log.txt\"") diff --git a/Extras/FCollada/LibXML/COPYING b/Extras/FCollada/LibXML/COPYING deleted file mode 100644 index 417e95531..000000000 --- a/Extras/FCollada/LibXML/COPYING +++ /dev/null @@ -1,27 +0,0 @@ -Except where otherwise noted in the source code (e.g. the files hash.c, -list.c and the trio files, which are covered by a similar licence but -with different Copyright notices) all the files are: - - Copyright (C) 1998-2003 Daniel Veillard. All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is fur- -nished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- -NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -DANIEL VEILLARD BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON- -NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of Daniel Veillard shall not -be used in advertising or otherwise to promote the sale, use or other deal- -ings in this Software without prior written authorization from him. - diff --git a/Extras/FCollada/LibXML/Compatibility.txt b/Extras/FCollada/LibXML/Compatibility.txt deleted file mode 100644 index 1b405ff48..000000000 --- a/Extras/FCollada/LibXML/Compatibility.txt +++ /dev/null @@ -1,2 +0,0 @@ -[Guillaume Laforte/Feeling Software] -Please note that this version of LibXML2 is meant to be used and compiled on Windows platforms only. For a version of LibXML2 specific to your platform, please check http://xmlsoft.org/. \ No newline at end of file diff --git a/Extras/FCollada/LibXML/Copyright b/Extras/FCollada/LibXML/Copyright deleted file mode 100644 index 417e95531..000000000 --- a/Extras/FCollada/LibXML/Copyright +++ /dev/null @@ -1,27 +0,0 @@ -Except where otherwise noted in the source code (e.g. the files hash.c, -list.c and the trio files, which are covered by a similar licence but -with different Copyright notices) all the files are: - - Copyright (C) 1998-2003 Daniel Veillard. All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is fur- -nished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FIT- -NESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -DANIEL VEILLARD BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER -IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CON- -NECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of Daniel Veillard shall not -be used in advertising or otherwise to promote the sale, use or other deal- -ings in this Software without prior written authorization from him. - diff --git a/Extras/FCollada/LibXML/DOCBparser.c b/Extras/FCollada/LibXML/DOCBparser.c deleted file mode 100644 index 357374335..000000000 --- a/Extras/FCollada/LibXML/DOCBparser.c +++ /dev/null @@ -1,305 +0,0 @@ -/* - * DOCBparser.c : an attempt to parse SGML Docbook documents - * - * This is deprecated !!! - * Code removed with release 2.6.0 it was broken. - * The doc are expect to be migrated to XML DocBook - * - * See Copyright for the status of this software. - * - * daniel@veillard.com - */ - -#define IN_LIBXML -#include "libxml.h" -#ifdef LIBXML_DOCB_ENABLED - -#include -#include - -/** - * docbEncodeEntities: - * @out: a pointer to an array of bytes to store the result - * @outlen: the length of @out - * @in: a pointer to an array of UTF-8 chars - * @inlen: the length of @in - * @quoteChar: the quote character to escape (' or ") or zero. - * - * Take a block of UTF-8 chars in and try to convert it to an ASCII - * plus SGML entities block of chars out. - * - * Returns 0 if success, -2 if the transcoding fails, or -1 otherwise - * The value of @inlen after return is the number of octets consumed - * as the return value is positive, else unpredictable. - * The value of @outlen after return is the number of octets consumed. - */ -int -docbEncodeEntities(unsigned char *out ATTRIBUTE_UNUSED, - int *outlen ATTRIBUTE_UNUSED, - const unsigned char *in ATTRIBUTE_UNUSED, - int *inlen ATTRIBUTE_UNUSED, - int quoteChar ATTRIBUTE_UNUSED) -{ - static int deprecated = 0; - - if (!deprecated) { - xmlGenericError(xmlGenericErrorContext, - "docbEncodeEntities() deprecated function reached\n"); - deprecated = 1; - } - return(-1); -} - -/** - * docbParseDocument: - * @ctxt: an SGML parser context - * - * parse an SGML document (and build a tree if using the standard SAX - * interface). - * - * Returns 0, -1 in case of error. the parser context is augmented - * as a result of the parsing. - */ - -int -docbParseDocument(docbParserCtxtPtr ctxt ATTRIBUTE_UNUSED) -{ - static int deprecated = 0; - - if (!deprecated) { - xmlGenericError(xmlGenericErrorContext, - "docbParseDocument() deprecated function reached\n"); - deprecated = 1; - } - return (xmlParseDocument(ctxt)); -} - -/** - * docbFreeParserCtxt: - * @ctxt: an SGML parser context - * - * Free all the memory used by a parser context. However the parsed - * document in ctxt->myDoc is not freed. - */ - -void -docbFreeParserCtxt(docbParserCtxtPtr ctxt ATTRIBUTE_UNUSED) -{ - static int deprecated = 0; - - if (!deprecated) { - xmlGenericError(xmlGenericErrorContext, - "docbFreeParserCtxt() deprecated function reached\n"); - deprecated = 1; - } - xmlFreeParserCtxt(ctxt); -} - -/** - * docbParseChunk: - * @ctxt: an XML parser context - * @chunk: an char array - * @size: the size in byte of the chunk - * @terminate: last chunk indicator - * - * Parse a Chunk of memory - * - * Returns zero if no error, the xmlParserErrors otherwise. - */ -int -docbParseChunk(docbParserCtxtPtr ctxt ATTRIBUTE_UNUSED, - const char *chunk ATTRIBUTE_UNUSED, - int size ATTRIBUTE_UNUSED, - int terminate ATTRIBUTE_UNUSED) -{ - static int deprecated = 0; - - if (!deprecated) { - xmlGenericError(xmlGenericErrorContext, - "docbParseChunk() deprecated function reached\n"); - deprecated = 1; - } - - return (xmlParseChunk(ctxt, chunk, size, terminate)); -} - -/** - * docbCreatePushParserCtxt: - * @sax: a SAX handler - * @user_data: The user data returned on SAX callbacks - * @chunk: a pointer to an array of chars - * @size: number of chars in the array - * @filename: an optional file name or URI - * @enc: an optional encoding - * - * Create a parser context for using the DocBook SGML parser in push mode - * To allow content encoding detection, @size should be >= 4 - * The value of @filename is used for fetching external entities - * and error/warning reports. - * - * Returns the new parser context or NULL - */ -docbParserCtxtPtr -docbCreatePushParserCtxt(docbSAXHandlerPtr sax ATTRIBUTE_UNUSED, - void *user_data ATTRIBUTE_UNUSED, - const char *chunk ATTRIBUTE_UNUSED, - int size ATTRIBUTE_UNUSED, - const char *filename ATTRIBUTE_UNUSED, - xmlCharEncoding enc ATTRIBUTE_UNUSED) -{ - static int deprecated = 0; - - if (!deprecated) { - xmlGenericError(xmlGenericErrorContext, - "docbParseChunk() deprecated function reached\n"); - deprecated = 1; - } - - return(xmlCreatePushParserCtxt(sax, user_data, chunk, size, filename)); -} - -/** - * docbSAXParseDoc: - * @cur: a pointer to an array of xmlChar - * @encoding: a free form C string describing the SGML document encoding, or NULL - * @sax: the SAX handler block - * @userData: if using SAX, this pointer will be provided on callbacks. - * - * parse an SGML in-memory document and build a tree. - * It use the given SAX function block to handle the parsing callback. - * If sax is NULL, fallback to the default DOM tree building routines. - * - * Returns the resulting document tree - */ - -docbDocPtr -docbSAXParseDoc(xmlChar * cur ATTRIBUTE_UNUSED, - const char *encoding ATTRIBUTE_UNUSED, - docbSAXHandlerPtr sax ATTRIBUTE_UNUSED, - void *userData ATTRIBUTE_UNUSED) -{ - static int deprecated = 0; - - if (!deprecated) { - xmlGenericError(xmlGenericErrorContext, - "docbParseChunk() deprecated function reached\n"); - deprecated = 1; - } - - return (xmlSAXParseMemoryWithData(sax, (const char *)cur, - xmlStrlen((const xmlChar *) cur), 0, userData)); -} - -/** - * docbParseDoc: - * @cur: a pointer to an array of xmlChar - * @encoding: a free form C string describing the SGML document encoding, or NULL - * - * parse an SGML in-memory document and build a tree. - * - * Returns the resulting document tree - */ - -docbDocPtr -docbParseDoc(xmlChar * cur ATTRIBUTE_UNUSED, - const char *encoding ATTRIBUTE_UNUSED) -{ - static int deprecated = 0; - - if (!deprecated) { - xmlGenericError(xmlGenericErrorContext, - "docbParseChunk() deprecated function reached\n"); - deprecated = 1; - } - - return (xmlParseDoc(cur)); -} - - -/** - * docbCreateFileParserCtxt: - * @filename: the filename - * @encoding: the SGML document encoding, or NULL - * - * Create a parser context for a file content. - * Automatic support for ZLIB/Compress compressed document is provided - * by default if found at compile-time. - * - * Returns the new parser context or NULL - */ -docbParserCtxtPtr -docbCreateFileParserCtxt(const char *filename ATTRIBUTE_UNUSED, - const char *encoding ATTRIBUTE_UNUSED) -{ - static int deprecated = 0; - - if (!deprecated) { - xmlGenericError(xmlGenericErrorContext, - "docbCreateFileParserCtxt() deprecated function reached\n"); - deprecated = 1; - } - - return (xmlCreateFileParserCtxt(filename)); -} - -/** - * docbSAXParseFile: - * @filename: the filename - * @encoding: a free form C string describing the SGML document encoding, or NULL - * @sax: the SAX handler block - * @userData: if using SAX, this pointer will be provided on callbacks. - * - * parse an SGML file and build a tree. Automatic support for ZLIB/Compress - * compressed document is provided by default if found at compile-time. - * It use the given SAX function block to handle the parsing callback. - * If sax is NULL, fallback to the default DOM tree building routines. - * - * Returns the resulting document tree - */ - -docbDocPtr -docbSAXParseFile(const char *filename ATTRIBUTE_UNUSED, - const char *encoding ATTRIBUTE_UNUSED, - docbSAXHandlerPtr sax ATTRIBUTE_UNUSED, - void *userData ATTRIBUTE_UNUSED) -{ - static int deprecated = 0; - - if (!deprecated) { - xmlGenericError(xmlGenericErrorContext, - "docbSAXParseFile() deprecated function reached\n"); - deprecated = 1; - } - - return (xmlSAXParseFileWithData(sax, filename, 0, userData)); -} - -/** - * docbParseFile: - * @filename: the filename - * @encoding: a free form C string describing document encoding, or NULL - * - * parse a Docbook SGML file and build a tree. Automatic support for - * ZLIB/Compress compressed document is provided by default if found - * at compile-time. - * - * Returns the resulting document tree - */ - -docbDocPtr -docbParseFile(const char *filename ATTRIBUTE_UNUSED, - const char *encoding ATTRIBUTE_UNUSED) -{ - static int deprecated = 0; - - if (!deprecated) { - xmlGenericError(xmlGenericErrorContext, - "docbParseFile() deprecated function reached\n"); - deprecated = 1; - } - - return (xmlParseFile(filename)); -} -#define bottom_DOCBparser -#include "elfgcchack.h" -#endif /* LIBXML_DOCB_ENABLED */ diff --git a/Extras/FCollada/LibXML/HTMLparser.c b/Extras/FCollada/LibXML/HTMLparser.c deleted file mode 100644 index 0c0c9232a..000000000 --- a/Extras/FCollada/LibXML/HTMLparser.c +++ /dev/null @@ -1,6178 +0,0 @@ -/* - * HTMLparser.c : an HTML 4.0 non-verifying parser - * - * See Copyright for the status of this software. - * - * daniel@veillard.com - */ - -#define IN_LIBXML -#include "libxml.h" -#ifdef LIBXML_HTML_ENABLED - -#include -#ifdef HAVE_CTYPE_H -#include -#endif -#ifdef HAVE_STDLIB_H -#include -#endif -#ifdef HAVE_SYS_STAT_H -#include -#endif -#ifdef HAVE_FCNTL_H -#include -#endif -#ifdef HAVE_UNISTD_H -#include -#endif -#ifdef HAVE_ZLIB_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define HTML_MAX_NAMELEN 1000 -#define HTML_PARSER_BIG_BUFFER_SIZE 1000 -#define HTML_PARSER_BUFFER_SIZE 100 - -/* #define DEBUG */ -/* #define DEBUG_PUSH */ - -static int htmlOmittedDefaultValue = 1; - -xmlChar * htmlDecodeEntities(htmlParserCtxtPtr ctxt, int len, - xmlChar end, xmlChar end2, xmlChar end3); -static void htmlParseComment(htmlParserCtxtPtr ctxt); - -/************************************************************************ - * * - * Some factorized error routines * - * * - ************************************************************************/ - -/** - * htmlErrMemory: - * @ctxt: an HTML parser context - * @extra: extra informations - * - * Handle a redefinition of attribute error - */ -static void -htmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra) -{ - if ((ctxt != NULL) && (ctxt->disableSAX != 0) && - (ctxt->instate == XML_PARSER_EOF)) - return; - if (ctxt != NULL) { - ctxt->errNo = XML_ERR_NO_MEMORY; - ctxt->instate = XML_PARSER_EOF; - ctxt->disableSAX = 1; - } - if (extra) - __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, - XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, extra, - NULL, NULL, 0, 0, - "Memory allocation failed : %s\n", extra); - else - __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, - XML_ERR_NO_MEMORY, XML_ERR_FATAL, NULL, 0, NULL, - NULL, NULL, 0, 0, "Memory allocation failed\n"); -} - -/** - * htmlParseErr: - * @ctxt: an HTML parser context - * @error: the error number - * @msg: the error message - * @str1: string infor - * @str2: string infor - * - * Handle a fatal parser error, i.e. violating Well-Formedness constraints - */ -static void -htmlParseErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, - const char *msg, const xmlChar *str1, const xmlChar *str2) -{ - if ((ctxt != NULL) && (ctxt->disableSAX != 0) && - (ctxt->instate == XML_PARSER_EOF)) - return; - if (ctxt != NULL) - ctxt->errNo = error; - __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_HTML, error, - XML_ERR_ERROR, NULL, 0, - (const char *) str1, (const char *) str2, - NULL, 0, 0, - msg, str1, str2); - if (ctxt != NULL) - ctxt->wellFormed = 0; -} - -/** - * htmlParseErrInt: - * @ctxt: an HTML parser context - * @error: the error number - * @msg: the error message - * @val: integer info - * - * Handle a fatal parser error, i.e. violating Well-Formedness constraints - */ -static void -htmlParseErrInt(xmlParserCtxtPtr ctxt, xmlParserErrors error, - const char *msg, int val) -{ - if ((ctxt != NULL) && (ctxt->disableSAX != 0) && - (ctxt->instate == XML_PARSER_EOF)) - return; - if (ctxt != NULL) - ctxt->errNo = error; - __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_HTML, error, - XML_ERR_ERROR, NULL, 0, NULL, NULL, - NULL, val, 0, msg, val); - if (ctxt != NULL) - ctxt->wellFormed = 0; -} - -/************************************************************************ - * * - * Parser stacks related functions and macros * - * * - ************************************************************************/ - -/** - * htmlnamePush: - * @ctxt: an HTML parser context - * @value: the element name - * - * Pushes a new element name on top of the name stack - * - * Returns 0 in case of error, the index in the stack otherwise - */ -static int -htmlnamePush(htmlParserCtxtPtr ctxt, const xmlChar * value) -{ - if (ctxt->nameNr >= ctxt->nameMax) { - ctxt->nameMax *= 2; - ctxt->nameTab = (const xmlChar * *) - xmlRealloc((xmlChar * *)ctxt->nameTab, - ctxt->nameMax * - sizeof(ctxt->nameTab[0])); - if (ctxt->nameTab == NULL) { - htmlErrMemory(ctxt, NULL); - return (0); - } - } - ctxt->nameTab[ctxt->nameNr] = value; - ctxt->name = value; - return (ctxt->nameNr++); -} -/** - * htmlnamePop: - * @ctxt: an HTML parser context - * - * Pops the top element name from the name stack - * - * Returns the name just removed - */ -static const xmlChar * -htmlnamePop(htmlParserCtxtPtr ctxt) -{ - const xmlChar *ret; - - if (ctxt->nameNr <= 0) - return (0); - ctxt->nameNr--; - if (ctxt->nameNr < 0) - return (0); - if (ctxt->nameNr > 0) - ctxt->name = ctxt->nameTab[ctxt->nameNr - 1]; - else - ctxt->name = NULL; - ret = ctxt->nameTab[ctxt->nameNr]; - ctxt->nameTab[ctxt->nameNr] = 0; - return (ret); -} - -/* - * Macros for accessing the content. Those should be used only by the parser, - * and not exported. - * - * Dirty macros, i.e. one need to make assumption on the context to use them - * - * CUR_PTR return the current pointer to the xmlChar to be parsed. - * CUR returns the current xmlChar value, i.e. a 8 bit value if compiled - * in ISO-Latin or UTF-8, and the current 16 bit value if compiled - * in UNICODE mode. This should be used internally by the parser - * only to compare to ASCII values otherwise it would break when - * running with UTF-8 encoding. - * NXT(n) returns the n'th next xmlChar. Same as CUR is should be used only - * to compare on ASCII based substring. - * UPP(n) returns the n'th next xmlChar converted to uppercase. Same as CUR - * it should be used only to compare on ASCII based substring. - * SKIP(n) Skip n xmlChar, and must also be used only to skip ASCII defined - * strings without newlines within the parser. - * - * Clean macros, not dependent of an ASCII context, expect UTF-8 encoding - * - * CURRENT Returns the current char value, with the full decoding of - * UTF-8 if we are using this mode. It returns an int. - * NEXT Skip to the next character, this does the proper decoding - * in UTF-8 mode. It also pop-up unfinished entities on the fly. - * NEXTL(l) Skip the current Unicode character of l xmlChars long. - * COPY(to) copy one char to *to, increment CUR_PTR and to accordingly - */ - -#define UPPER (toupper(*ctxt->input->cur)) - -#define SKIP(val) ctxt->nbChars += (val),ctxt->input->cur += (val),ctxt->input->col+=(val) - -#define NXT(val) ctxt->input->cur[(val)] - -#define UPP(val) (toupper(ctxt->input->cur[(val)])) - -#define CUR_PTR ctxt->input->cur - -#define SHRINK if ((ctxt->input->cur - ctxt->input->base > 2 * INPUT_CHUNK) && \ - (ctxt->input->end - ctxt->input->cur < 2 * INPUT_CHUNK)) \ - xmlParserInputShrink(ctxt->input) - -#define GROW if ((ctxt->progressive == 0) && \ - (ctxt->input->end - ctxt->input->cur < INPUT_CHUNK)) \ - xmlParserInputGrow(ctxt->input, INPUT_CHUNK) - -#define CURRENT ((int) (*ctxt->input->cur)) - -#define SKIP_BLANKS htmlSkipBlankChars(ctxt) - -/* Inported from XML */ - -/* #define CUR (ctxt->token ? ctxt->token : (int) (*ctxt->input->cur)) */ -#define CUR ((int) (*ctxt->input->cur)) -#define NEXT xmlNextChar(ctxt) - -#define RAW (ctxt->token ? -1 : (*ctxt->input->cur)) -#define NXT(val) ctxt->input->cur[(val)] -#define CUR_PTR ctxt->input->cur - - -#define NEXTL(l) do { \ - if (*(ctxt->input->cur) == '\n') { \ - ctxt->input->line++; ctxt->input->col = 1; \ - } else ctxt->input->col++; \ - ctxt->token = 0; ctxt->input->cur += l; ctxt->nbChars++; \ - } while (0) - -/************ - \ - if (*ctxt->input->cur == '%') xmlParserHandlePEReference(ctxt); \ - if (*ctxt->input->cur == '&') xmlParserHandleReference(ctxt); - ************/ - -#define CUR_CHAR(l) htmlCurrentChar(ctxt, &l) -#define CUR_SCHAR(s, l) xmlStringCurrentChar(ctxt, s, &l) - -#define COPY_BUF(l,b,i,v) \ - if (l == 1) b[i++] = (xmlChar) v; \ - else i += xmlCopyChar(l,&b[i],v) - -/** - * htmlCurrentChar: - * @ctxt: the HTML parser context - * @len: pointer to the length of the char read - * - * The current char value, if using UTF-8 this may actually span multiple - * bytes in the input buffer. Implement the end of line normalization: - * 2.11 End-of-Line Handling - * If the encoding is unspecified, in the case we find an ISO-Latin-1 - * char, then the encoding converter is plugged in automatically. - * - * Returns the current char value and its length - */ - -static int -htmlCurrentChar(xmlParserCtxtPtr ctxt, int *len) { - if (ctxt->instate == XML_PARSER_EOF) - return(0); - - if (ctxt->token != 0) { - *len = 0; - return(ctxt->token); - } - if (ctxt->charset == XML_CHAR_ENCODING_UTF8) { - /* - * We are supposed to handle UTF8, check it's valid - * From rfc2044: encoding of the Unicode values on UTF-8: - * - * UCS-4 range (hex.) UTF-8 octet sequence (binary) - * 0000 0000-0000 007F 0xxxxxxx - * 0000 0080-0000 07FF 110xxxxx 10xxxxxx - * 0000 0800-0000 FFFF 1110xxxx 10xxxxxx 10xxxxxx - * - * Check for the 0x110000 limit too - */ - const unsigned char *cur = ctxt->input->cur; - unsigned char c; - unsigned int val; - - c = *cur; - if (c & 0x80) { - if (cur[1] == 0) - xmlParserInputGrow(ctxt->input, INPUT_CHUNK); - if ((cur[1] & 0xc0) != 0x80) - goto encoding_error; - if ((c & 0xe0) == 0xe0) { - - if (cur[2] == 0) - xmlParserInputGrow(ctxt->input, INPUT_CHUNK); - if ((cur[2] & 0xc0) != 0x80) - goto encoding_error; - if ((c & 0xf0) == 0xf0) { - if (cur[3] == 0) - xmlParserInputGrow(ctxt->input, INPUT_CHUNK); - if (((c & 0xf8) != 0xf0) || - ((cur[3] & 0xc0) != 0x80)) - goto encoding_error; - /* 4-byte code */ - *len = 4; - val = (cur[0] & 0x7) << 18; - val |= (cur[1] & 0x3f) << 12; - val |= (cur[2] & 0x3f) << 6; - val |= cur[3] & 0x3f; - } else { - /* 3-byte code */ - *len = 3; - val = (cur[0] & 0xf) << 12; - val |= (cur[1] & 0x3f) << 6; - val |= cur[2] & 0x3f; - } - } else { - /* 2-byte code */ - *len = 2; - val = (cur[0] & 0x1f) << 6; - val |= cur[1] & 0x3f; - } - if (!IS_CHAR(val)) { - htmlParseErrInt(ctxt, XML_ERR_INVALID_CHAR, - "Char 0x%X out of allowed range\n", val); - } - return(val); - } else { - /* 1-byte code */ - *len = 1; - return((int) *ctxt->input->cur); - } - } - /* - * Assume it's a fixed length encoding (1) with - * a compatible encoding for the ASCII set, since - * XML constructs only use < 128 chars - */ - *len = 1; - if ((int) *ctxt->input->cur < 0x80) - return((int) *ctxt->input->cur); - - /* - * Humm this is bad, do an automatic flow conversion - */ - xmlSwitchEncoding(ctxt, XML_CHAR_ENCODING_8859_1); - ctxt->charset = XML_CHAR_ENCODING_UTF8; - return(xmlCurrentChar(ctxt, len)); - -encoding_error: - /* - * If we detect an UTF8 error that probably mean that the - * input encoding didn't get properly advertized in the - * declaration header. Report the error and switch the encoding - * to ISO-Latin-1 (if you don't like this policy, just declare the - * encoding !) - */ - { - char buffer[150]; - - snprintf(buffer, 149, "Bytes: 0x%02X 0x%02X 0x%02X 0x%02X\n", - ctxt->input->cur[0], ctxt->input->cur[1], - ctxt->input->cur[2], ctxt->input->cur[3]); - htmlParseErr(ctxt, XML_ERR_INVALID_ENCODING, - "Input is not proper UTF-8, indicate encoding !\n", - BAD_CAST buffer, NULL); - } - - ctxt->charset = XML_CHAR_ENCODING_8859_1; - *len = 1; - return((int) *ctxt->input->cur); -} - -/** - * htmlSkipBlankChars: - * @ctxt: the HTML parser context - * - * skip all blanks character found at that point in the input streams. - * - * Returns the number of space chars skipped - */ - -static int -htmlSkipBlankChars(xmlParserCtxtPtr ctxt) { - int res = 0; - - while (IS_BLANK_CH(*(ctxt->input->cur))) { - if ((*ctxt->input->cur == 0) && - (xmlParserInputGrow(ctxt->input, INPUT_CHUNK) <= 0)) { - xmlPopInput(ctxt); - } else { - if (*(ctxt->input->cur) == '\n') { - ctxt->input->line++; ctxt->input->col = 1; - } else ctxt->input->col++; - ctxt->input->cur++; - ctxt->nbChars++; - if (*ctxt->input->cur == 0) - xmlParserInputGrow(ctxt->input, INPUT_CHUNK); - } - res++; - } - return(res); -} - - - -/************************************************************************ - * * - * The list of HTML elements and their properties * - * * - ************************************************************************/ - -/* - * Start Tag: 1 means the start tag can be ommited - * End Tag: 1 means the end tag can be ommited - * 2 means it's forbidden (empty elements) - * 3 means the tag is stylistic and should be closed easily - * Depr: this element is deprecated - * DTD: 1 means that this element is valid only in the Loose DTD - * 2 means that this element is valid only in the Frameset DTD - * - * Name,Start Tag,End Tag,Save End,Empty,Deprecated,DTD,inline,Description - , subElements , impliedsubelt , Attributes, userdata - */ - -/* Definitions and a couple of vars for HTML Elements */ - -#define FONTSTYLE "tt", "i", "b", "u", "s", "strike", "big", "small" -#define NB_FONTSTYLE 8 -#define PHRASE "em", "strong", "dfn", "code", "samp", "kbd", "var", "cite", "abbr", "acronym" -#define NB_PHRASE 10 -#define SPECIAL "a", "img", "applet", "object", "font", "basefont", "br", "script", "map", "q", "sub", "sup", "span", "bdo", "iframe" -#define NB_SPECIAL 15 -#define INLINE PCDATA FONTSTYLE PHRASE SPECIAL FORMCTRL -#define NB_INLINE NB_PCDATA + NB_FONTSTYLE + NB_PHRASE + NB_SPECIAL + NB_FORMCTRL -#define BLOCK HEADING, LIST "pre", "p", "dl", "div", "center", "noscript", "noframes", "blockquote", "form", "isindex", "hr", "table", "fieldset", "address" -#define NB_BLOCK NB_HEADING + NB_LIST + 14 -#define FORMCTRL "input", "select", "textarea", "label", "button" -#define NB_FORMCTRL 5 -#define PCDATA -#define NB_PCDATA 0 -#define HEADING "h1", "h2", "h3", "h4", "h5", "h6" -#define NB_HEADING 6 -#define LIST "ul", "ol", "dir", "menu" -#define NB_LIST 4 -#define MODIFIER -#define NB_MODIFIER 0 -#define FLOW BLOCK,INLINE -#define NB_FLOW NB_BLOCK + NB_INLINE -#define EMPTY NULL - - -static const char* html_flow[] = { FLOW, NULL } ; -static const char* html_inline[] = { INLINE, NULL } ; - -/* placeholders: elts with content but no subelements */ -static const char* html_pcdata[] = { NULL } ; -#define html_cdata html_pcdata - - -/* ... and for HTML Attributes */ - -#define COREATTRS "id", "class", "style", "title" -#define NB_COREATTRS 4 -#define I18N "lang", "dir" -#define NB_I18N 2 -#define EVENTS "onclick", "ondblclick", "onmousedown", "onmouseup", "onmouseover", "onmouseout", "onkeypress", "onkeydown", "onkeyup" -#define NB_EVENTS 9 -#define ATTRS COREATTRS,I18N,EVENTS -#define NB_ATTRS NB_NB_COREATTRS + NB_I18N + NB_EVENTS -#define CELLHALIGN "align", "char", "charoff" -#define NB_CELLHALIGN 3 -#define CELLVALIGN "valign" -#define NB_CELLVALIGN 1 - -static const char* html_attrs[] = { ATTRS, NULL } ; -static const char* core_i18n_attrs[] = { COREATTRS, I18N, NULL } ; -static const char* core_attrs[] = { COREATTRS, NULL } ; -static const char* i18n_attrs[] = { I18N, NULL } ; - - -/* Other declarations that should go inline ... */ -static const char* a_attrs[] = { ATTRS, "charset", "type", "name", - "href", "hreflang", "rel", "rev", "accesskey", "shape", "coords", - "tabindex", "onfocus", "onblur", NULL } ; -static const char* target_attr[] = { "target", NULL } ; -static const char* rows_cols_attr[] = { "rows", "cols", NULL } ; -static const char* alt_attr[] = { "alt", NULL } ; -static const char* src_alt_attrs[] = { "src", "alt", NULL } ; -static const char* href_attrs[] = { "href", NULL } ; -static const char* clear_attrs[] = { "clear", NULL } ; -static const char* inline_p[] = { INLINE, "p", NULL } ; -static const char* flow_param[] = { FLOW, "param", NULL } ; -static const char* applet_attrs[] = { COREATTRS , "codebase", - "archive", "alt", "name", "height", "width", "align", - "hspace", "vspace", NULL } ; -static const char* area_attrs[] = { "shape", "coords", "href", "nohref", - "tabindex", "accesskey", "onfocus", "onblur", NULL } ; -static const char* basefont_attrs[] = - { "id", "size", "color", "face", NULL } ; -static const char* quote_attrs[] = { ATTRS, "cite", NULL } ; -static const char* body_contents[] = { FLOW, "ins", "del", NULL } ; -static const char* body_attrs[] = { ATTRS, "onload", "onunload", NULL } ; -static const char* body_depr[] = { "background", "bgcolor", "text", - "link", "vlink", "alink", NULL } ; -static const char* button_attrs[] = { ATTRS, "name", "value", "type", - "disabled", "tabindex", "accesskey", "onfocus", "onblur", NULL } ; - - -static const char* col_attrs[] = { ATTRS, "span", "width", CELLHALIGN, CELLVALIGN, NULL } ; -static const char* col_elt[] = { "col", NULL } ; -static const char* edit_attrs[] = { ATTRS, "datetime", "cite", NULL } ; -static const char* compact_attrs[] = { ATTRS, "compact", NULL } ; -static const char* dl_contents[] = { "dt", "dd", NULL } ; -static const char* compact_attr[] = { "compact", NULL } ; -static const char* label_attr[] = { "label", NULL } ; -static const char* fieldset_contents[] = { FLOW, "legend" } ; -static const char* font_attrs[] = { COREATTRS, I18N, "size", "color", "face" , NULL } ; -static const char* form_contents[] = { HEADING, LIST, INLINE, "pre", "p", "div", "center", "noscript", "noframes", "blockquote", "isindex", "hr", "table", "fieldset", "address", NULL } ; -static const char* form_attrs[] = { ATTRS, "method", "enctype", "accept", "name", "onsubmit", "onreset", "accept-charset", NULL } ; -static const char* frame_attrs[] = { COREATTRS, "longdesc", "name", "src", "frameborder", "marginwidth", "marginheight", "noresize", "scrolling" , NULL } ; -static const char* frameset_attrs[] = { COREATTRS, "rows", "cols", "onload", "onunload", NULL } ; -static const char* frameset_contents[] = { "frameset", "frame", "noframes", NULL } ; -static const char* head_attrs[] = { I18N, "profile", NULL } ; -static const char* head_contents[] = { "title", "isindex", "base", "script", "style", "meta", "link", "object", NULL } ; -static const char* hr_depr[] = { "align", "noshade", "size", "width", NULL } ; -static const char* version_attr[] = { "version", NULL } ; -static const char* html_content[] = { "head", "body", "frameset", NULL } ; -static const char* iframe_attrs[] = { COREATTRS, "longdesc", "name", "src", "frameborder", "marginwidth", "marginheight", "scrolling", "align", "height", "width", NULL } ; -static const char* img_attrs[] = { ATTRS, "longdesc", "name", "height", "width", "usemap", "ismap", NULL } ; -static const char* input_attrs[] = { ATTRS, "type", "name", "value", "checked", "disabled", "readonly", "size", "maxlength", "src", "alt", "usemap", "ismap", "tabindex", "accesskey", "onfocus", "onblur", "onselect", "onchange", "accept", NULL } ; -static const char* prompt_attrs[] = { COREATTRS, I18N, "prompt", NULL } ; -static const char* label_attrs[] = { ATTRS, "for", "accesskey", "onfocus", "onblur", NULL } ; -static const char* legend_attrs[] = { ATTRS, "accesskey", NULL } ; -static const char* align_attr[] = { "align", NULL } ; -static const char* link_attrs[] = { ATTRS, "charset", "href", "hreflang", "type", "rel", "rev", "media", NULL } ; -static const char* map_contents[] = { BLOCK, "area", NULL } ; -static const char* name_attr[] = { "name", NULL } ; -static const char* action_attr[] = { "action", NULL } ; -static const char* blockli_elt[] = { BLOCK, "li", NULL } ; -static const char* meta_attrs[] = { I18N, "http-equiv", "name", "scheme", NULL } ; -static const char* content_attr[] = { "content", NULL } ; -static const char* type_attr[] = { "type", NULL } ; -static const char* noframes_content[] = { "body", FLOW MODIFIER, NULL } ; -static const char* object_contents[] = { FLOW, "param", NULL } ; -static const char* object_attrs[] = { ATTRS, "declare", "classid", "codebase", "data", "type", "codetype", "archive", "standby", "height", "width", "usemap", "name", "tabindex", NULL } ; -static const char* object_depr[] = { "align", "border", "hspace", "vspace", NULL } ; -static const char* ol_attrs[] = { "type", "compact", "start", NULL} ; -static const char* option_elt[] = { "option", NULL } ; -static const char* optgroup_attrs[] = { ATTRS, "disabled", NULL } ; -static const char* option_attrs[] = { ATTRS, "disabled", "label", "selected", "value", NULL } ; -static const char* param_attrs[] = { "id", "value", "valuetype", "type", NULL } ; -static const char* width_attr[] = { "width", NULL } ; -static const char* pre_content[] = { PHRASE, "tt", "i", "b", "u", "s", "strike", "a", "br", "script", "map", "q", "span", "bdo", "iframe", NULL } ; -static const char* script_attrs[] = { "charset", "src", "defer", "event", "for", NULL } ; -static const char* language_attr[] = { "language", NULL } ; -static const char* select_content[] = { "optgroup", "option", NULL } ; -static const char* select_attrs[] = { ATTRS, "name", "size", "multiple", "disabled", "tabindex", "onfocus", "onblur", "onchange", NULL } ; -static const char* style_attrs[] = { I18N, "media", "title", NULL } ; -static const char* table_attrs[] = { ATTRS "summary", "width", "border", "frame", "rules", "cellspacing", "cellpadding", "datapagesize", NULL } ; -static const char* table_depr[] = { "align", "bgcolor", NULL } ; -static const char* table_contents[] = { "caption", "col", "colgroup", "thead", "tfoot", "tbody", "tr", NULL} ; -static const char* tr_elt[] = { "tr", NULL } ; -static const char* talign_attrs[] = { ATTRS, CELLHALIGN, CELLVALIGN, NULL} ; -static const char* th_td_depr[] = { "nowrap", "bgcolor", "width", "height", NULL } ; -static const char* th_td_attr[] = { ATTRS, "abbr", "axis", "headers", "scope", "rowspan", "colspan", CELLHALIGN, CELLVALIGN, NULL } ; -static const char* textarea_attrs[] = { ATTRS, "name", "disabled", "readonly", "tabindex", "accesskey", "onfocus", "onblur", "onselect", "onchange", NULL } ; -static const char* tr_contents[] = { "th", "td", NULL } ; -static const char* bgcolor_attr[] = { "bgcolor", NULL } ; -static const char* li_elt[] = { "li", NULL } ; -static const char* ul_depr[] = { "type", "compact", NULL} ; -static const char* dir_attr[] = { "dir", NULL} ; - -#define DECL (const char**) - -static const htmlElemDesc -html40ElementTable[] = { -{ "a", 0, 0, 0, 0, 0, 0, 1, "anchor ", - DECL html_inline , NULL , DECL a_attrs , DECL target_attr, NULL -}, -{ "abbr", 0, 0, 0, 0, 0, 0, 1, "abbreviated form", - DECL html_inline , NULL , DECL html_attrs, NULL, NULL -}, -{ "acronym", 0, 0, 0, 0, 0, 0, 1, "", - DECL html_inline , NULL , DECL html_attrs, NULL, NULL -}, -{ "address", 0, 0, 0, 0, 0, 0, 0, "information on author ", - DECL inline_p , NULL , DECL html_attrs, NULL, NULL -}, -{ "applet", 0, 0, 0, 0, 1, 1, 2, "java applet ", - DECL flow_param , NULL , NULL , DECL applet_attrs, NULL -}, -{ "area", 0, 2, 2, 1, 0, 0, 0, "client-side image map area ", - EMPTY , NULL , DECL area_attrs , DECL target_attr, DECL alt_attr -}, -{ "b", 0, 3, 0, 0, 0, 0, 1, "bold text style", - DECL html_inline , NULL , DECL html_attrs, NULL, NULL -}, -{ "base", 0, 2, 2, 1, 0, 0, 0, "document base uri ", - EMPTY , NULL , NULL , DECL target_attr, DECL href_attrs -}, -{ "basefont", 0, 2, 2, 1, 1, 1, 1, "base font size " , - EMPTY , NULL , NULL, DECL basefont_attrs, NULL -}, -{ "bdo", 0, 0, 0, 0, 0, 0, 1, "i18n bidi over-ride ", - DECL html_inline , NULL , DECL core_i18n_attrs, NULL, DECL dir_attr -}, -{ "big", 0, 3, 0, 0, 0, 0, 1, "large text style", - DECL html_inline , NULL , DECL html_attrs, NULL, NULL -}, -{ "blockquote", 0, 0, 0, 0, 0, 0, 0, "long quotation ", - DECL html_flow , NULL , DECL quote_attrs , NULL, NULL -}, -{ "body", 1, 1, 0, 0, 0, 0, 0, "document body ", - DECL body_contents , "div" , DECL body_attrs, DECL body_depr, NULL -}, -{ "br", 0, 2, 2, 1, 0, 0, 1, "forced line break ", - EMPTY , NULL , DECL core_attrs, DECL clear_attrs , NULL -}, -{ "button", 0, 0, 0, 0, 0, 0, 2, "push button ", - DECL html_flow MODIFIER , NULL , DECL button_attrs, NULL, NULL -}, -{ "caption", 0, 0, 0, 0, 0, 0, 0, "table caption ", - DECL html_inline , NULL , DECL html_attrs, NULL, NULL -}, -{ "center", 0, 3, 0, 0, 1, 1, 0, "shorthand for div align=center ", - DECL html_flow , NULL , NULL, DECL html_attrs, NULL -}, -{ "cite", 0, 0, 0, 0, 0, 0, 1, "citation", - DECL html_inline , NULL , DECL html_attrs, NULL, NULL -}, -{ "code", 0, 0, 0, 0, 0, 0, 1, "computer code fragment", - DECL html_inline , NULL , DECL html_attrs, NULL, NULL -}, -{ "col", 0, 2, 2, 1, 0, 0, 0, "table column ", - EMPTY , NULL , DECL col_attrs , NULL, NULL -}, -{ "colgroup", 0, 1, 0, 0, 0, 0, 0, "table column group ", - DECL col_elt , "col" , DECL col_attrs , NULL, NULL -}, -{ "dd", 0, 1, 0, 0, 0, 0, 0, "definition description ", - DECL html_flow , NULL , DECL html_attrs, NULL, NULL -}, -{ "del", 0, 0, 0, 0, 0, 0, 2, "deleted text ", - DECL html_flow , NULL , DECL edit_attrs , NULL, NULL -}, -{ "dfn", 0, 0, 0, 0, 0, 0, 1, "instance definition", - DECL html_inline , NULL , DECL html_attrs, NULL, NULL -}, -{ "dir", 0, 0, 0, 0, 1, 1, 0, "directory list", - DECL blockli_elt, "li" , NULL, DECL compact_attrs, NULL -}, -{ "div", 0, 0, 0, 0, 0, 0, 0, "generic language/style container", - DECL html_flow, NULL, DECL html_attrs, DECL align_attr, NULL -}, -{ "dl", 0, 0, 0, 0, 0, 0, 0, "definition list ", - DECL dl_contents , "dd" , html_attrs, DECL compact_attr, NULL -}, -{ "dt", 0, 1, 0, 0, 0, 0, 0, "definition term ", - DECL html_inline, NULL, DECL html_attrs, NULL, NULL -}, -{ "em", 0, 3, 0, 0, 0, 0, 1, "emphasis", - DECL html_inline, NULL, DECL html_attrs, NULL, NULL -}, -{ "fieldset", 0, 0, 0, 0, 0, 0, 0, "form control group ", - DECL fieldset_contents , NULL, DECL html_attrs, NULL, NULL -}, -{ "font", 0, 3, 0, 0, 1, 1, 1, "local change to font ", - DECL html_inline, NULL, NULL, DECL font_attrs, NULL -}, -{ "form", 0, 0, 0, 0, 0, 0, 0, "interactive form ", - DECL form_contents, "fieldset", DECL form_attrs , DECL target_attr, DECL action_attr -}, -{ "frame", 0, 2, 2, 1, 0, 2, 0, "subwindow " , - EMPTY, NULL, NULL, DECL frame_attrs, NULL -}, -{ "frameset", 0, 0, 0, 0, 0, 2, 0, "window subdivision" , - DECL frameset_contents, "noframes" , NULL , DECL frameset_attrs, NULL -}, -{ "h1", 0, 0, 0, 0, 0, 0, 0, "heading ", - DECL html_inline, NULL, DECL html_attrs, DECL align_attr, NULL -}, -{ "h2", 0, 0, 0, 0, 0, 0, 0, "heading ", - DECL html_inline, NULL, DECL html_attrs, DECL align_attr, NULL -}, -{ "h3", 0, 0, 0, 0, 0, 0, 0, "heading ", - DECL html_inline, NULL, DECL html_attrs, DECL align_attr, NULL -}, -{ "h4", 0, 0, 0, 0, 0, 0, 0, "heading ", - DECL html_inline, NULL, DECL html_attrs, DECL align_attr, NULL -}, -{ "h5", 0, 0, 0, 0, 0, 0, 0, "heading ", - DECL html_inline, NULL, DECL html_attrs, DECL align_attr, NULL -}, -{ "h6", 0, 0, 0, 0, 0, 0, 0, "heading ", - DECL html_inline, NULL, DECL html_attrs, DECL align_attr, NULL -}, -{ "head", 1, 1, 0, 0, 0, 0, 0, "document head ", - DECL head_contents, NULL, DECL head_attrs, NULL, NULL -}, -{ "hr", 0, 2, 2, 1, 0, 0, 0, "horizontal rule " , - EMPTY, NULL, DECL html_attrs, DECL hr_depr, NULL -}, -{ "html", 1, 1, 0, 0, 0, 0, 0, "document root element ", - DECL html_content , NULL , DECL i18n_attrs, DECL version_attr, NULL -}, -{ "i", 0, 3, 0, 0, 0, 0, 1, "italic text style", - DECL html_inline, NULL, DECL html_attrs, NULL, NULL -}, -{ "iframe", 0, 0, 0, 0, 0, 1, 2, "inline subwindow ", - DECL html_flow, NULL, NULL, DECL iframe_attrs, NULL -}, -{ "img", 0, 2, 2, 1, 0, 0, 1, "embedded image ", - EMPTY, NULL, DECL img_attrs, DECL align_attr, src_alt_attrs -}, -{ "input", 0, 2, 2, 1, 0, 0, 1, "form control ", - EMPTY, NULL, DECL input_attrs , DECL align_attr, NULL -}, -{ "ins", 0, 0, 0, 0, 0, 0, 2, "inserted text", - DECL html_flow, NULL, DECL edit_attrs, NULL, NULL -}, -{ "isindex", 0, 2, 2, 1, 1, 1, 0, "single line prompt ", - EMPTY, NULL, NULL, DECL prompt_attrs, NULL -}, -{ "kbd", 0, 0, 0, 0, 0, 0, 1, "text to be entered by the user", - DECL html_inline, NULL, DECL html_attrs, NULL, NULL -}, -{ "label", 0, 0, 0, 0, 0, 0, 1, "form field label text ", - DECL html_inline MODIFIER, NULL, DECL label_attrs , NULL, NULL -}, -{ "legend", 0, 0, 0, 0, 0, 0, 0, "fieldset legend ", - DECL html_inline, NULL, DECL legend_attrs , DECL align_attr, NULL -}, -{ "li", 0, 1, 1, 0, 0, 0, 0, "list item ", - DECL html_flow, NULL, DECL html_attrs, NULL, NULL -}, -{ "link", 0, 2, 2, 1, 0, 0, 0, "a media-independent link ", - EMPTY, NULL, DECL link_attrs, DECL target_attr, NULL -}, -{ "map", 0, 0, 0, 0, 0, 0, 2, "client-side image map ", - DECL map_contents , NULL, DECL html_attrs , NULL, name_attr -}, -{ "menu", 0, 0, 0, 0, 1, 1, 0, "menu list ", - DECL blockli_elt , NULL, NULL, DECL compact_attrs, NULL -}, -{ "meta", 0, 2, 2, 1, 0, 0, 0, "generic metainformation ", - EMPTY, NULL, DECL meta_attrs , NULL , DECL content_attr -}, -{ "noframes", 0, 0, 0, 0, 0, 2, 0, "alternate content container for non frame-based rendering ", - DECL noframes_content, "body" , DECL html_attrs, NULL, NULL -}, -{ "noscript", 0, 0, 0, 0, 0, 0, 0, "alternate content container for non script-based rendering ", - DECL html_flow, "div", DECL html_attrs, NULL, NULL -}, -{ "object", 0, 0, 0, 0, 0, 0, 2, "generic embedded object ", - DECL object_contents , "div" , DECL object_attrs, DECL object_depr, NULL -}, -{ "ol", 0, 0, 0, 0, 0, 0, 0, "ordered list ", - DECL li_elt , "li" , DECL html_attrs, DECL ol_attrs, NULL -}, -{ "optgroup", 0, 0, 0, 0, 0, 0, 0, "option group ", - option_elt , "option", DECL optgroup_attrs, NULL, DECL label_attr -}, -{ "option", 0, 1, 0, 0, 0, 0, 0, "selectable choice " , - DECL html_pcdata, NULL, DECL option_attrs, NULL, NULL -}, -{ "p", 0, 1, 0, 0, 0, 0, 0, "paragraph ", - DECL html_inline, NULL, DECL html_attrs, DECL align_attr, NULL -}, -{ "param", 0, 2, 2, 1, 0, 0, 0, "named property value ", - EMPTY, NULL, DECL param_attrs, NULL, name_attr -}, -{ "pre", 0, 0, 0, 0, 0, 0, 0, "preformatted text ", - DECL pre_content, NULL, DECL html_attrs, DECL width_attr, NULL -}, -{ "q", 0, 0, 0, 0, 0, 0, 1, "short inline quotation ", - DECL html_inline, NULL, DECL quote_attrs, NULL, NULL -}, -{ "s", 0, 3, 0, 0, 1, 1, 1, "strike-through text style", - DECL html_inline, NULL, NULL, DECL html_attrs, NULL -}, -{ "samp", 0, 0, 0, 0, 0, 0, 1, "sample program output, scripts, etc.", - DECL html_inline, NULL, DECL html_attrs, NULL, NULL -}, -{ "script", 0, 0, 0, 0, 0, 0, 2, "script statements ", - DECL html_cdata, NULL, DECL script_attrs, DECL language_attr, DECL type_attr -}, -{ "select", 0, 0, 0, 0, 0, 0, 1, "option selector ", - DECL select_content, NULL, DECL select_attrs, NULL, NULL -}, -{ "small", 0, 3, 0, 0, 0, 0, 1, "small text style", - DECL html_inline, NULL, DECL html_attrs, NULL, NULL -}, -{ "span", 0, 0, 0, 0, 0, 0, 1, "generic language/style container ", - DECL html_inline, NULL, DECL html_attrs, NULL, NULL -}, -{ "strike", 0, 3, 0, 0, 1, 1, 1, "strike-through text", - DECL html_inline, NULL, NULL, DECL html_attrs, NULL -}, -{ "strong", 0, 3, 0, 0, 0, 0, 1, "strong emphasis", - DECL html_inline, NULL, DECL html_attrs, NULL, NULL -}, -{ "style", 0, 0, 0, 0, 0, 0, 0, "style info ", - DECL html_cdata, NULL, DECL style_attrs, NULL, DECL type_attr -}, -{ "sub", 0, 3, 0, 0, 0, 0, 1, "subscript", - DECL html_inline, NULL, DECL html_attrs, NULL, NULL -}, -{ "sup", 0, 3, 0, 0, 0, 0, 1, "superscript ", - DECL html_inline, NULL, DECL html_attrs, NULL, NULL -}, -{ "table", 0, 0, 0, 0, 0, 0, 0, "", - DECL table_contents , "tr" , DECL table_attrs , DECL table_depr, NULL -}, -{ "tbody", 1, 0, 0, 0, 0, 0, 0, "table body ", - DECL tr_elt , "tr" , DECL talign_attrs, NULL, NULL -}, -{ "td", 0, 0, 0, 0, 0, 0, 0, "table data cell", - DECL html_flow, NULL, DECL th_td_attr, DECL th_td_depr, NULL -}, -{ "textarea", 0, 0, 0, 0, 0, 0, 1, "multi-line text field ", - DECL html_pcdata, NULL, DECL textarea_attrs, NULL, DECL rows_cols_attr -}, -{ "tfoot", 0, 1, 0, 0, 0, 0, 0, "table footer ", - DECL tr_elt , "tr" , DECL talign_attrs, NULL, NULL -}, -{ "th", 0, 1, 0, 0, 0, 0, 0, "table header cell", - DECL html_flow, NULL, DECL th_td_attr, DECL th_td_depr, NULL -}, -{ "thead", 0, 1, 0, 0, 0, 0, 0, "table header ", - DECL tr_elt , "tr" , DECL talign_attrs, NULL, NULL -}, -{ "title", 0, 0, 0, 0, 0, 0, 0, "document title ", - DECL html_pcdata, NULL, DECL i18n_attrs, NULL, NULL -}, -{ "tr", 0, 0, 0, 0, 0, 0, 0, "table row ", - DECL tr_contents , "td" , DECL talign_attrs, DECL bgcolor_attr, NULL -}, -{ "tt", 0, 3, 0, 0, 0, 0, 1, "teletype or monospaced text style", - DECL html_inline, NULL, DECL html_attrs, NULL, NULL -}, -{ "u", 0, 3, 0, 0, 1, 1, 1, "underlined text style", - DECL html_inline, NULL, NULL, DECL html_attrs, NULL -}, -{ "ul", 0, 0, 0, 0, 0, 0, 0, "unordered list ", - DECL li_elt , "li" , DECL html_attrs, DECL ul_depr, NULL -}, -{ "var", 0, 0, 0, 0, 0, 0, 1, "instance of a variable or program argument", - DECL html_inline, NULL, DECL html_attrs, NULL, NULL -} -}; - -/* - * start tags that imply the end of current element - */ -static const char *htmlStartClose[] = { -"form", "form", "p", "hr", "h1", "h2", "h3", "h4", "h5", "h6", - "dl", "ul", "ol", "menu", "dir", "address", "pre", - "listing", "xmp", "head", NULL, -"head", "p", NULL, -"title", "p", NULL, -"body", "head", "style", "link", "title", "p", NULL, -"frameset", "head", "style", "link", "title", "p", NULL, -"li", "p", "h1", "h2", "h3", "h4", "h5", "h6", "dl", "address", - "pre", "listing", "xmp", "head", "li", NULL, -"hr", "p", "head", NULL, -"h1", "p", "head", NULL, -"h2", "p", "head", NULL, -"h3", "p", "head", NULL, -"h4", "p", "head", NULL, -"h5", "p", "head", NULL, -"h6", "p", "head", NULL, -"dir", "p", "head", NULL, -"address", "p", "head", "ul", NULL, -"pre", "p", "head", "ul", NULL, -"listing", "p", "head", NULL, -"xmp", "p", "head", NULL, -"blockquote", "p", "head", NULL, -"dl", "p", "dt", "menu", "dir", "address", "pre", "listing", - "xmp", "head", NULL, -"dt", "p", "menu", "dir", "address", "pre", "listing", "xmp", - "head", "dd", NULL, -"dd", "p", "menu", "dir", "address", "pre", "listing", "xmp", - "head", "dt", NULL, -"ul", "p", "head", "ol", "menu", "dir", "address", "pre", - "listing", "xmp", NULL, -"ol", "p", "head", "ul", NULL, -"menu", "p", "head", "ul", NULL, -"p", "p", "head", "h1", "h2", "h3", "h4", "h5", "h6", NULL, -"div", "p", "head", NULL, -"noscript", "p", "head", NULL, -"center", "font", "b", "i", "p", "head", NULL, -"a", "a", NULL, -"caption", "p", NULL, -"colgroup", "caption", "colgroup", "col", "p", NULL, -"col", "caption", "col", "p", NULL, -"table", "p", "head", "h1", "h2", "h3", "h4", "h5", "h6", "pre", - "listing", "xmp", "a", NULL, -"th", "th", "td", "p", "span", "font", "a", "b", "i", "u", NULL, -"td", "th", "td", "p", "span", "font", "a", "b", "i", "u", NULL, -"tr", "th", "td", "tr", "caption", "col", "colgroup", "p", NULL, -"thead", "caption", "col", "colgroup", NULL, -"tfoot", "th", "td", "tr", "caption", "col", "colgroup", "thead", - "tbody", "p", NULL, -"tbody", "th", "td", "tr", "caption", "col", "colgroup", "thead", - "tfoot", "tbody", "p", NULL, -"optgroup", "option", NULL, -"option", "option", NULL, -"fieldset", "legend", "p", "head", "h1", "h2", "h3", "h4", "h5", "h6", - "pre", "listing", "xmp", "a", NULL, -NULL -}; - -/* - * The list of HTML elements which are supposed not to have - * CDATA content and where a p element will be implied - * - * TODO: extend that list by reading the HTML SGML DTD on - * implied paragraph - */ -static const char *htmlNoContentElements[] = { - "html", - "head", - "body", - NULL -}; - -/* - * The list of HTML attributes which are of content %Script; - * NOTE: when adding ones, check htmlIsScriptAttribute() since - * it assumes the name starts with 'on' - */ -static const char *htmlScriptAttributes[] = { - "onclick", - "ondblclick", - "onmousedown", - "onmouseup", - "onmouseover", - "onmousemove", - "onmouseout", - "onkeypress", - "onkeydown", - "onkeyup", - "onload", - "onunload", - "onfocus", - "onblur", - "onsubmit", - "onrest", - "onchange", - "onselect" -}; - -/* - * This table is used by the htmlparser to know what to do with - * broken html pages. By assigning different priorities to different - * elements the parser can decide how to handle extra endtags. - * Endtags are only allowed to close elements with lower or equal - * priority. - */ - -typedef struct { - const char *name; - int priority; -} elementPriority; - -static const elementPriority htmlEndPriority[] = { - {"div", 150}, - {"td", 160}, - {"th", 160}, - {"tr", 170}, - {"thead", 180}, - {"tbody", 180}, - {"tfoot", 180}, - {"table", 190}, - {"head", 200}, - {"body", 200}, - {"html", 220}, - {NULL, 100} /* Default priority */ -}; - -static const char** htmlStartCloseIndex[100]; -static int htmlStartCloseIndexinitialized = 0; - -/************************************************************************ - * * - * functions to handle HTML specific data * - * * - ************************************************************************/ - -/** - * htmlInitAutoClose: - * - * Initialize the htmlStartCloseIndex for fast lookup of closing tags names. - * This is not reentrant. Call xmlInitParser() once before processing in - * case of use in multithreaded programs. - */ -void -htmlInitAutoClose(void) { - int indx, i = 0; - - if (htmlStartCloseIndexinitialized) return; - - for (indx = 0;indx < 100;indx ++) htmlStartCloseIndex[indx] = NULL; - indx = 0; - while ((htmlStartClose[i] != NULL) && (indx < 100 - 1)) { - htmlStartCloseIndex[indx++] = &htmlStartClose[i]; - while (htmlStartClose[i] != NULL) i++; - i++; - } - htmlStartCloseIndexinitialized = 1; -} - -/** - * htmlTagLookup: - * @tag: The tag name in lowercase - * - * Lookup the HTML tag in the ElementTable - * - * Returns the related htmlElemDescPtr or NULL if not found. - */ -const htmlElemDesc * -htmlTagLookup(const xmlChar *tag) { - unsigned int i; - - for (i = 0; i < (sizeof(html40ElementTable) / - sizeof(html40ElementTable[0]));i++) { - if (!xmlStrcasecmp(tag, BAD_CAST html40ElementTable[i].name)) - return((htmlElemDescPtr) &html40ElementTable[i]); - } - return(NULL); -} - -/** - * htmlGetEndPriority: - * @name: The name of the element to look up the priority for. - * - * Return value: The "endtag" priority. - **/ -static int -htmlGetEndPriority (const xmlChar *name) { - int i = 0; - - while ((htmlEndPriority[i].name != NULL) && - (!xmlStrEqual((const xmlChar *)htmlEndPriority[i].name, name))) - i++; - - return(htmlEndPriority[i].priority); -} - - -/** - * htmlCheckAutoClose: - * @newtag: The new tag name - * @oldtag: The old tag name - * - * Checks whether the new tag is one of the registered valid tags for - * closing old. - * Initialize the htmlStartCloseIndex for fast lookup of closing tags names. - * - * Returns 0 if no, 1 if yes. - */ -static int -htmlCheckAutoClose(const xmlChar * newtag, const xmlChar * oldtag) -{ - int i, indx; - const char **closed = NULL; - - if (htmlStartCloseIndexinitialized == 0) - htmlInitAutoClose(); - - /* inefficient, but not a big deal */ - for (indx = 0; indx < 100; indx++) { - closed = htmlStartCloseIndex[indx]; - if (closed == NULL) - return (0); - if (xmlStrEqual(BAD_CAST * closed, newtag)) - break; - } - - i = closed - htmlStartClose; - i++; - while (htmlStartClose[i] != NULL) { - if (xmlStrEqual(BAD_CAST htmlStartClose[i], oldtag)) { - return (1); - } - i++; - } - return (0); -} - -/** - * htmlAutoCloseOnClose: - * @ctxt: an HTML parser context - * @newtag: The new tag name - * @force: force the tag closure - * - * The HTML DTD allows an ending tag to implicitly close other tags. - */ -static void -htmlAutoCloseOnClose(htmlParserCtxtPtr ctxt, const xmlChar * newtag) -{ - const htmlElemDesc *info; - int i, priority; - - priority = htmlGetEndPriority(newtag); - - for (i = (ctxt->nameNr - 1); i >= 0; i--) { - - if (xmlStrEqual(newtag, ctxt->nameTab[i])) - break; - /* - * A missplaced endtag can only close elements with lower - * or equal priority, so if we find an element with higher - * priority before we find an element with - * matching name, we just ignore this endtag - */ - if (htmlGetEndPriority(ctxt->nameTab[i]) > priority) - return; - } - if (i < 0) - return; - - while (!xmlStrEqual(newtag, ctxt->name)) { - info = htmlTagLookup(ctxt->name); - if ((info != NULL) && (info->endTag == 3)) { - htmlParseErr(ctxt, XML_ERR_TAG_NAME_MISMATCH, - "Opening and ending tag mismatch: %s and %s\n", - newtag, ctxt->name); - } - if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL)) - ctxt->sax->endElement(ctxt->userData, ctxt->name); - htmlnamePop(ctxt); - } -} - -/** - * htmlAutoCloseOnEnd: - * @ctxt: an HTML parser context - * - * Close all remaining tags at the end of the stream - */ -static void -htmlAutoCloseOnEnd(htmlParserCtxtPtr ctxt) -{ - int i; - - if (ctxt->nameNr == 0) - return; - for (i = (ctxt->nameNr - 1); i >= 0; i--) { - if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL)) - ctxt->sax->endElement(ctxt->userData, ctxt->name); - htmlnamePop(ctxt); - } -} - -/** - * htmlAutoClose: - * @ctxt: an HTML parser context - * @newtag: The new tag name or NULL - * - * The HTML DTD allows a tag to implicitly close other tags. - * The list is kept in htmlStartClose array. This function is - * called when a new tag has been detected and generates the - * appropriates closes if possible/needed. - * If newtag is NULL this mean we are at the end of the resource - * and we should check - */ -static void -htmlAutoClose(htmlParserCtxtPtr ctxt, const xmlChar * newtag) -{ - while ((newtag != NULL) && (ctxt->name != NULL) && - (htmlCheckAutoClose(newtag, ctxt->name))) { - if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL)) - ctxt->sax->endElement(ctxt->userData, ctxt->name); - htmlnamePop(ctxt); - } - if (newtag == NULL) { - htmlAutoCloseOnEnd(ctxt); - return; - } - while ((newtag == NULL) && (ctxt->name != NULL) && - ((xmlStrEqual(ctxt->name, BAD_CAST "head")) || - (xmlStrEqual(ctxt->name, BAD_CAST "body")) || - (xmlStrEqual(ctxt->name, BAD_CAST "html")))) { - if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL)) - ctxt->sax->endElement(ctxt->userData, ctxt->name); - htmlnamePop(ctxt); - } -} - -/** - * htmlAutoCloseTag: - * @doc: the HTML document - * @name: The tag name - * @elem: the HTML element - * - * The HTML DTD allows a tag to implicitly close other tags. - * The list is kept in htmlStartClose array. This function checks - * if the element or one of it's children would autoclose the - * given tag. - * - * Returns 1 if autoclose, 0 otherwise - */ -int -htmlAutoCloseTag(htmlDocPtr doc, const xmlChar *name, htmlNodePtr elem) { - htmlNodePtr child; - - if (elem == NULL) return(1); - if (xmlStrEqual(name, elem->name)) return(0); - if (htmlCheckAutoClose(elem->name, name)) return(1); - child = elem->children; - while (child != NULL) { - if (htmlAutoCloseTag(doc, name, child)) return(1); - child = child->next; - } - return(0); -} - -/** - * htmlIsAutoClosed: - * @doc: the HTML document - * @elem: the HTML element - * - * The HTML DTD allows a tag to implicitly close other tags. - * The list is kept in htmlStartClose array. This function checks - * if a tag is autoclosed by one of it's child - * - * Returns 1 if autoclosed, 0 otherwise - */ -int -htmlIsAutoClosed(htmlDocPtr doc, htmlNodePtr elem) { - htmlNodePtr child; - - if (elem == NULL) return(1); - child = elem->children; - while (child != NULL) { - if (htmlAutoCloseTag(doc, elem->name, child)) return(1); - child = child->next; - } - return(0); -} - -/** - * htmlCheckImplied: - * @ctxt: an HTML parser context - * @newtag: The new tag name - * - * The HTML DTD allows a tag to exists only implicitly - * called when a new tag has been detected and generates the - * appropriates implicit tags if missing - */ -static void -htmlCheckImplied(htmlParserCtxtPtr ctxt, const xmlChar *newtag) { - if (!htmlOmittedDefaultValue) - return; - if (xmlStrEqual(newtag, BAD_CAST"html")) - return; - if (ctxt->nameNr <= 0) { - htmlnamePush(ctxt, BAD_CAST"html"); - if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL)) - ctxt->sax->startElement(ctxt->userData, BAD_CAST"html", NULL); - } - if ((xmlStrEqual(newtag, BAD_CAST"body")) || (xmlStrEqual(newtag, BAD_CAST"head"))) - return; - if ((ctxt->nameNr <= 1) && - ((xmlStrEqual(newtag, BAD_CAST"script")) || - (xmlStrEqual(newtag, BAD_CAST"style")) || - (xmlStrEqual(newtag, BAD_CAST"meta")) || - (xmlStrEqual(newtag, BAD_CAST"link")) || - (xmlStrEqual(newtag, BAD_CAST"title")) || - (xmlStrEqual(newtag, BAD_CAST"base")))) { - /* - * dropped OBJECT ... i you put it first BODY will be - * assumed ! - */ - htmlnamePush(ctxt, BAD_CAST"head"); - if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL)) - ctxt->sax->startElement(ctxt->userData, BAD_CAST"head", NULL); - } else if ((!xmlStrEqual(newtag, BAD_CAST"noframes")) && - (!xmlStrEqual(newtag, BAD_CAST"frame")) && - (!xmlStrEqual(newtag, BAD_CAST"frameset"))) { - int i; - for (i = 0;i < ctxt->nameNr;i++) { - if (xmlStrEqual(ctxt->nameTab[i], BAD_CAST"body")) { - return; - } - if (xmlStrEqual(ctxt->nameTab[i], BAD_CAST"head")) { - return; - } - } - - htmlnamePush(ctxt, BAD_CAST"body"); - if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL)) - ctxt->sax->startElement(ctxt->userData, BAD_CAST"body", NULL); - } -} - -/** - * htmlCheckParagraph - * @ctxt: an HTML parser context - * - * Check whether a p element need to be implied before inserting - * characters in the current element. - * - * Returns 1 if a paragraph has been inserted, 0 if not and -1 - * in case of error. - */ - -static int -htmlCheckParagraph(htmlParserCtxtPtr ctxt) { - const xmlChar *tag; - int i; - - if (ctxt == NULL) - return(-1); - tag = ctxt->name; - if (tag == NULL) { - htmlAutoClose(ctxt, BAD_CAST"p"); - htmlCheckImplied(ctxt, BAD_CAST"p"); - htmlnamePush(ctxt, BAD_CAST"p"); - if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL)) - ctxt->sax->startElement(ctxt->userData, BAD_CAST"p", NULL); - return(1); - } - if (!htmlOmittedDefaultValue) - return(0); - for (i = 0; htmlNoContentElements[i] != NULL; i++) { - if (xmlStrEqual(tag, BAD_CAST htmlNoContentElements[i])) { - htmlAutoClose(ctxt, BAD_CAST"p"); - htmlCheckImplied(ctxt, BAD_CAST"p"); - htmlnamePush(ctxt, BAD_CAST"p"); - if ((ctxt->sax != NULL) && (ctxt->sax->startElement != NULL)) - ctxt->sax->startElement(ctxt->userData, BAD_CAST"p", NULL); - return(1); - } - } - return(0); -} - -/** - * htmlIsScriptAttribute: - * @name: an attribute name - * - * Check if an attribute is of content type Script - * - * Returns 1 is the attribute is a script 0 otherwise - */ -int -htmlIsScriptAttribute(const xmlChar *name) { - unsigned int i; - - if (name == NULL) - return(0); - /* - * all script attributes start with 'on' - */ - if ((name[0] != 'o') || (name[1] != 'n')) - return(0); - for (i = 0; - i < sizeof(htmlScriptAttributes)/sizeof(htmlScriptAttributes[0]); - i++) { - if (xmlStrEqual(name, (const xmlChar *) htmlScriptAttributes[i])) - return(1); - } - return(0); -} - -/************************************************************************ - * * - * The list of HTML predefined entities * - * * - ************************************************************************/ - - -static const htmlEntityDesc html40EntitiesTable[] = { -/* - * the 4 absolute ones, plus apostrophe. - */ -{ 34, "quot", "quotation mark = APL quote, U+0022 ISOnum" }, -{ 38, "amp", "ampersand, U+0026 ISOnum" }, -{ 39, "apos", "single quote" }, -{ 60, "lt", "less-than sign, U+003C ISOnum" }, -{ 62, "gt", "greater-than sign, U+003E ISOnum" }, - -/* - * A bunch still in the 128-255 range - * Replacing them depend really on the charset used. - */ -{ 160, "nbsp", "no-break space = non-breaking space, U+00A0 ISOnum" }, -{ 161, "iexcl","inverted exclamation mark, U+00A1 ISOnum" }, -{ 162, "cent", "cent sign, U+00A2 ISOnum" }, -{ 163, "pound","pound sign, U+00A3 ISOnum" }, -{ 164, "curren","currency sign, U+00A4 ISOnum" }, -{ 165, "yen", "yen sign = yuan sign, U+00A5 ISOnum" }, -{ 166, "brvbar","broken bar = broken vertical bar, U+00A6 ISOnum" }, -{ 167, "sect", "section sign, U+00A7 ISOnum" }, -{ 168, "uml", "diaeresis = spacing diaeresis, U+00A8 ISOdia" }, -{ 169, "copy", "copyright sign, U+00A9 ISOnum" }, -{ 170, "ordf", "feminine ordinal indicator, U+00AA ISOnum" }, -{ 171, "laquo","left-pointing double angle quotation mark = left pointing guillemet, U+00AB ISOnum" }, -{ 172, "not", "not sign, U+00AC ISOnum" }, -{ 173, "shy", "soft hyphen = discretionary hyphen, U+00AD ISOnum" }, -{ 174, "reg", "registered sign = registered trade mark sign, U+00AE ISOnum" }, -{ 175, "macr", "macron = spacing macron = overline = APL overbar, U+00AF ISOdia" }, -{ 176, "deg", "degree sign, U+00B0 ISOnum" }, -{ 177, "plusmn","plus-minus sign = plus-or-minus sign, U+00B1 ISOnum" }, -{ 178, "sup2", "superscript two = superscript digit two = squared, U+00B2 ISOnum" }, -{ 179, "sup3", "superscript three = superscript digit three = cubed, U+00B3 ISOnum" }, -{ 180, "acute","acute accent = spacing acute, U+00B4 ISOdia" }, -{ 181, "micro","micro sign, U+00B5 ISOnum" }, -{ 182, "para", "pilcrow sign = paragraph sign, U+00B6 ISOnum" }, -{ 183, "middot","middle dot = Georgian comma Greek middle dot, U+00B7 ISOnum" }, -{ 184, "cedil","cedilla = spacing cedilla, U+00B8 ISOdia" }, -{ 185, "sup1", "superscript one = superscript digit one, U+00B9 ISOnum" }, -{ 186, "ordm", "masculine ordinal indicator, U+00BA ISOnum" }, -{ 187, "raquo","right-pointing double angle quotation mark right pointing guillemet, U+00BB ISOnum" }, -{ 188, "frac14","vulgar fraction one quarter = fraction one quarter, U+00BC ISOnum" }, -{ 189, "frac12","vulgar fraction one half = fraction one half, U+00BD ISOnum" }, -{ 190, "frac34","vulgar fraction three quarters = fraction three quarters, U+00BE ISOnum" }, -{ 191, "iquest","inverted question mark = turned question mark, U+00BF ISOnum" }, -{ 192, "Agrave","latin capital letter A with grave = latin capital letter A grave, U+00C0 ISOlat1" }, -{ 193, "Aacute","latin capital letter A with acute, U+00C1 ISOlat1" }, -{ 194, "Acirc","latin capital letter A with circumflex, U+00C2 ISOlat1" }, -{ 195, "Atilde","latin capital letter A with tilde, U+00C3 ISOlat1" }, -{ 196, "Auml", "latin capital letter A with diaeresis, U+00C4 ISOlat1" }, -{ 197, "Aring","latin capital letter A with ring above = latin capital letter A ring, U+00C5 ISOlat1" }, -{ 198, "AElig","latin capital letter AE = latin capital ligature AE, U+00C6 ISOlat1" }, -{ 199, "Ccedil","latin capital letter C with cedilla, U+00C7 ISOlat1" }, -{ 200, "Egrave","latin capital letter E with grave, U+00C8 ISOlat1" }, -{ 201, "Eacute","latin capital letter E with acute, U+00C9 ISOlat1" }, -{ 202, "Ecirc","latin capital letter E with circumflex, U+00CA ISOlat1" }, -{ 203, "Euml", "latin capital letter E with diaeresis, U+00CB ISOlat1" }, -{ 204, "Igrave","latin capital letter I with grave, U+00CC ISOlat1" }, -{ 205, "Iacute","latin capital letter I with acute, U+00CD ISOlat1" }, -{ 206, "Icirc","latin capital letter I with circumflex, U+00CE ISOlat1" }, -{ 207, "Iuml", "latin capital letter I with diaeresis, U+00CF ISOlat1" }, -{ 208, "ETH", "latin capital letter ETH, U+00D0 ISOlat1" }, -{ 209, "Ntilde","latin capital letter N with tilde, U+00D1 ISOlat1" }, -{ 210, "Ograve","latin capital letter O with grave, U+00D2 ISOlat1" }, -{ 211, "Oacute","latin capital letter O with acute, U+00D3 ISOlat1" }, -{ 212, "Ocirc","latin capital letter O with circumflex, U+00D4 ISOlat1" }, -{ 213, "Otilde","latin capital letter O with tilde, U+00D5 ISOlat1" }, -{ 214, "Ouml", "latin capital letter O with diaeresis, U+00D6 ISOlat1" }, -{ 215, "times","multiplication sign, U+00D7 ISOnum" }, -{ 216, "Oslash","latin capital letter O with stroke latin capital letter O slash, U+00D8 ISOlat1" }, -{ 217, "Ugrave","latin capital letter U with grave, U+00D9 ISOlat1" }, -{ 218, "Uacute","latin capital letter U with acute, U+00DA ISOlat1" }, -{ 219, "Ucirc","latin capital letter U with circumflex, U+00DB ISOlat1" }, -{ 220, "Uuml", "latin capital letter U with diaeresis, U+00DC ISOlat1" }, -{ 221, "Yacute","latin capital letter Y with acute, U+00DD ISOlat1" }, -{ 222, "THORN","latin capital letter THORN, U+00DE ISOlat1" }, -{ 223, "szlig","latin small letter sharp s = ess-zed, U+00DF ISOlat1" }, -{ 224, "agrave","latin small letter a with grave = latin small letter a grave, U+00E0 ISOlat1" }, -{ 225, "aacute","latin small letter a with acute, U+00E1 ISOlat1" }, -{ 226, "acirc","latin small letter a with circumflex, U+00E2 ISOlat1" }, -{ 227, "atilde","latin small letter a with tilde, U+00E3 ISOlat1" }, -{ 228, "auml", "latin small letter a with diaeresis, U+00E4 ISOlat1" }, -{ 229, "aring","latin small letter a with ring above = latin small letter a ring, U+00E5 ISOlat1" }, -{ 230, "aelig","latin small letter ae = latin small ligature ae, U+00E6 ISOlat1" }, -{ 231, "ccedil","latin small letter c with cedilla, U+00E7 ISOlat1" }, -{ 232, "egrave","latin small letter e with grave, U+00E8 ISOlat1" }, -{ 233, "eacute","latin small letter e with acute, U+00E9 ISOlat1" }, -{ 234, "ecirc","latin small letter e with circumflex, U+00EA ISOlat1" }, -{ 235, "euml", "latin small letter e with diaeresis, U+00EB ISOlat1" }, -{ 236, "igrave","latin small letter i with grave, U+00EC ISOlat1" }, -{ 237, "iacute","latin small letter i with acute, U+00ED ISOlat1" }, -{ 238, "icirc","latin small letter i with circumflex, U+00EE ISOlat1" }, -{ 239, "iuml", "latin small letter i with diaeresis, U+00EF ISOlat1" }, -{ 240, "eth", "latin small letter eth, U+00F0 ISOlat1" }, -{ 241, "ntilde","latin small letter n with tilde, U+00F1 ISOlat1" }, -{ 242, "ograve","latin small letter o with grave, U+00F2 ISOlat1" }, -{ 243, "oacute","latin small letter o with acute, U+00F3 ISOlat1" }, -{ 244, "ocirc","latin small letter o with circumflex, U+00F4 ISOlat1" }, -{ 245, "otilde","latin small letter o with tilde, U+00F5 ISOlat1" }, -{ 246, "ouml", "latin small letter o with diaeresis, U+00F6 ISOlat1" }, -{ 247, "divide","division sign, U+00F7 ISOnum" }, -{ 248, "oslash","latin small letter o with stroke, = latin small letter o slash, U+00F8 ISOlat1" }, -{ 249, "ugrave","latin small letter u with grave, U+00F9 ISOlat1" }, -{ 250, "uacute","latin small letter u with acute, U+00FA ISOlat1" }, -{ 251, "ucirc","latin small letter u with circumflex, U+00FB ISOlat1" }, -{ 252, "uuml", "latin small letter u with diaeresis, U+00FC ISOlat1" }, -{ 253, "yacute","latin small letter y with acute, U+00FD ISOlat1" }, -{ 254, "thorn","latin small letter thorn with, U+00FE ISOlat1" }, -{ 255, "yuml", "latin small letter y with diaeresis, U+00FF ISOlat1" }, - -{ 338, "OElig","latin capital ligature OE, U+0152 ISOlat2" }, -{ 339, "oelig","latin small ligature oe, U+0153 ISOlat2" }, -{ 352, "Scaron","latin capital letter S with caron, U+0160 ISOlat2" }, -{ 353, "scaron","latin small letter s with caron, U+0161 ISOlat2" }, -{ 376, "Yuml", "latin capital letter Y with diaeresis, U+0178 ISOlat2" }, - -/* - * Anything below should really be kept as entities references - */ -{ 402, "fnof", "latin small f with hook = function = florin, U+0192 ISOtech" }, - -{ 710, "circ", "modifier letter circumflex accent, U+02C6 ISOpub" }, -{ 732, "tilde","small tilde, U+02DC ISOdia" }, - -{ 913, "Alpha","greek capital letter alpha, U+0391" }, -{ 914, "Beta", "greek capital letter beta, U+0392" }, -{ 915, "Gamma","greek capital letter gamma, U+0393 ISOgrk3" }, -{ 916, "Delta","greek capital letter delta, U+0394 ISOgrk3" }, -{ 917, "Epsilon","greek capital letter epsilon, U+0395" }, -{ 918, "Zeta", "greek capital letter zeta, U+0396" }, -{ 919, "Eta", "greek capital letter eta, U+0397" }, -{ 920, "Theta","greek capital letter theta, U+0398 ISOgrk3" }, -{ 921, "Iota", "greek capital letter iota, U+0399" }, -{ 922, "Kappa","greek capital letter kappa, U+039A" }, -{ 923, "Lambda", "greek capital letter lambda, U+039B ISOgrk3" }, -{ 924, "Mu", "greek capital letter mu, U+039C" }, -{ 925, "Nu", "greek capital letter nu, U+039D" }, -{ 926, "Xi", "greek capital letter xi, U+039E ISOgrk3" }, -{ 927, "Omicron","greek capital letter omicron, U+039F" }, -{ 928, "Pi", "greek capital letter pi, U+03A0 ISOgrk3" }, -{ 929, "Rho", "greek capital letter rho, U+03A1" }, -{ 931, "Sigma","greek capital letter sigma, U+03A3 ISOgrk3" }, -{ 932, "Tau", "greek capital letter tau, U+03A4" }, -{ 933, "Upsilon","greek capital letter upsilon, U+03A5 ISOgrk3" }, -{ 934, "Phi", "greek capital letter phi, U+03A6 ISOgrk3" }, -{ 935, "Chi", "greek capital letter chi, U+03A7" }, -{ 936, "Psi", "greek capital letter psi, U+03A8 ISOgrk3" }, -{ 937, "Omega","greek capital letter omega, U+03A9 ISOgrk3" }, - -{ 945, "alpha","greek small letter alpha, U+03B1 ISOgrk3" }, -{ 946, "beta", "greek small letter beta, U+03B2 ISOgrk3" }, -{ 947, "gamma","greek small letter gamma, U+03B3 ISOgrk3" }, -{ 948, "delta","greek small letter delta, U+03B4 ISOgrk3" }, -{ 949, "epsilon","greek small letter epsilon, U+03B5 ISOgrk3" }, -{ 950, "zeta", "greek small letter zeta, U+03B6 ISOgrk3" }, -{ 951, "eta", "greek small letter eta, U+03B7 ISOgrk3" }, -{ 952, "theta","greek small letter theta, U+03B8 ISOgrk3" }, -{ 953, "iota", "greek small letter iota, U+03B9 ISOgrk3" }, -{ 954, "kappa","greek small letter kappa, U+03BA ISOgrk3" }, -{ 955, "lambda","greek small letter lambda, U+03BB ISOgrk3" }, -{ 956, "mu", "greek small letter mu, U+03BC ISOgrk3" }, -{ 957, "nu", "greek small letter nu, U+03BD ISOgrk3" }, -{ 958, "xi", "greek small letter xi, U+03BE ISOgrk3" }, -{ 959, "omicron","greek small letter omicron, U+03BF NEW" }, -{ 960, "pi", "greek small letter pi, U+03C0 ISOgrk3" }, -{ 961, "rho", "greek small letter rho, U+03C1 ISOgrk3" }, -{ 962, "sigmaf","greek small letter final sigma, U+03C2 ISOgrk3" }, -{ 963, "sigma","greek small letter sigma, U+03C3 ISOgrk3" }, -{ 964, "tau", "greek small letter tau, U+03C4 ISOgrk3" }, -{ 965, "upsilon","greek small letter upsilon, U+03C5 ISOgrk3" }, -{ 966, "phi", "greek small letter phi, U+03C6 ISOgrk3" }, -{ 967, "chi", "greek small letter chi, U+03C7 ISOgrk3" }, -{ 968, "psi", "greek small letter psi, U+03C8 ISOgrk3" }, -{ 969, "omega","greek small letter omega, U+03C9 ISOgrk3" }, -{ 977, "thetasym","greek small letter theta symbol, U+03D1 NEW" }, -{ 978, "upsih","greek upsilon with hook symbol, U+03D2 NEW" }, -{ 982, "piv", "greek pi symbol, U+03D6 ISOgrk3" }, - -{ 8194, "ensp", "en space, U+2002 ISOpub" }, -{ 8195, "emsp", "em space, U+2003 ISOpub" }, -{ 8201, "thinsp","thin space, U+2009 ISOpub" }, -{ 8204, "zwnj", "zero width non-joiner, U+200C NEW RFC 2070" }, -{ 8205, "zwj", "zero width joiner, U+200D NEW RFC 2070" }, -{ 8206, "lrm", "left-to-right mark, U+200E NEW RFC 2070" }, -{ 8207, "rlm", "right-to-left mark, U+200F NEW RFC 2070" }, -{ 8211, "ndash","en dash, U+2013 ISOpub" }, -{ 8212, "mdash","em dash, U+2014 ISOpub" }, -{ 8216, "lsquo","left single quotation mark, U+2018 ISOnum" }, -{ 8217, "rsquo","right single quotation mark, U+2019 ISOnum" }, -{ 8218, "sbquo","single low-9 quotation mark, U+201A NEW" }, -{ 8220, "ldquo","left double quotation mark, U+201C ISOnum" }, -{ 8221, "rdquo","right double quotation mark, U+201D ISOnum" }, -{ 8222, "bdquo","double low-9 quotation mark, U+201E NEW" }, -{ 8224, "dagger","dagger, U+2020 ISOpub" }, -{ 8225, "Dagger","double dagger, U+2021 ISOpub" }, - -{ 8226, "bull", "bullet = black small circle, U+2022 ISOpub" }, -{ 8230, "hellip","horizontal ellipsis = three dot leader, U+2026 ISOpub" }, - -{ 8240, "permil","per mille sign, U+2030 ISOtech" }, - -{ 8242, "prime","prime = minutes = feet, U+2032 ISOtech" }, -{ 8243, "Prime","double prime = seconds = inches, U+2033 ISOtech" }, - -{ 8249, "lsaquo","single left-pointing angle quotation mark, U+2039 ISO proposed" }, -{ 8250, "rsaquo","single right-pointing angle quotation mark, U+203A ISO proposed" }, - -{ 8254, "oline","overline = spacing overscore, U+203E NEW" }, -{ 8260, "frasl","fraction slash, U+2044 NEW" }, - -{ 8364, "euro", "euro sign, U+20AC NEW" }, - -{ 8465, "image","blackletter capital I = imaginary part, U+2111 ISOamso" }, -{ 8472, "weierp","script capital P = power set = Weierstrass p, U+2118 ISOamso" }, -{ 8476, "real", "blackletter capital R = real part symbol, U+211C ISOamso" }, -{ 8482, "trade","trade mark sign, U+2122 ISOnum" }, -{ 8501, "alefsym","alef symbol = first transfinite cardinal, U+2135 NEW" }, -{ 8592, "larr", "leftwards arrow, U+2190 ISOnum" }, -{ 8593, "uarr", "upwards arrow, U+2191 ISOnum" }, -{ 8594, "rarr", "rightwards arrow, U+2192 ISOnum" }, -{ 8595, "darr", "downwards arrow, U+2193 ISOnum" }, -{ 8596, "harr", "left right arrow, U+2194 ISOamsa" }, -{ 8629, "crarr","downwards arrow with corner leftwards = carriage return, U+21B5 NEW" }, -{ 8656, "lArr", "leftwards double arrow, U+21D0 ISOtech" }, -{ 8657, "uArr", "upwards double arrow, U+21D1 ISOamsa" }, -{ 8658, "rArr", "rightwards double arrow, U+21D2 ISOtech" }, -{ 8659, "dArr", "downwards double arrow, U+21D3 ISOamsa" }, -{ 8660, "hArr", "left right double arrow, U+21D4 ISOamsa" }, - -{ 8704, "forall","for all, U+2200 ISOtech" }, -{ 8706, "part", "partial differential, U+2202 ISOtech" }, -{ 8707, "exist","there exists, U+2203 ISOtech" }, -{ 8709, "empty","empty set = null set = diameter, U+2205 ISOamso" }, -{ 8711, "nabla","nabla = backward difference, U+2207 ISOtech" }, -{ 8712, "isin", "element of, U+2208 ISOtech" }, -{ 8713, "notin","not an element of, U+2209 ISOtech" }, -{ 8715, "ni", "contains as member, U+220B ISOtech" }, -{ 8719, "prod", "n-ary product = product sign, U+220F ISOamsb" }, -{ 8721, "sum", "n-ary summation, U+2211 ISOamsb" }, -{ 8722, "minus","minus sign, U+2212 ISOtech" }, -{ 8727, "lowast","asterisk operator, U+2217 ISOtech" }, -{ 8730, "radic","square root = radical sign, U+221A ISOtech" }, -{ 8733, "prop", "proportional to, U+221D ISOtech" }, -{ 8734, "infin","infinity, U+221E ISOtech" }, -{ 8736, "ang", "angle, U+2220 ISOamso" }, -{ 8743, "and", "logical and = wedge, U+2227 ISOtech" }, -{ 8744, "or", "logical or = vee, U+2228 ISOtech" }, -{ 8745, "cap", "intersection = cap, U+2229 ISOtech" }, -{ 8746, "cup", "union = cup, U+222A ISOtech" }, -{ 8747, "int", "integral, U+222B ISOtech" }, -{ 8756, "there4","therefore, U+2234 ISOtech" }, -{ 8764, "sim", "tilde operator = varies with = similar to, U+223C ISOtech" }, -{ 8773, "cong", "approximately equal to, U+2245 ISOtech" }, -{ 8776, "asymp","almost equal to = asymptotic to, U+2248 ISOamsr" }, -{ 8800, "ne", "not equal to, U+2260 ISOtech" }, -{ 8801, "equiv","identical to, U+2261 ISOtech" }, -{ 8804, "le", "less-than or equal to, U+2264 ISOtech" }, -{ 8805, "ge", "greater-than or equal to, U+2265 ISOtech" }, -{ 8834, "sub", "subset of, U+2282 ISOtech" }, -{ 8835, "sup", "superset of, U+2283 ISOtech" }, -{ 8836, "nsub", "not a subset of, U+2284 ISOamsn" }, -{ 8838, "sube", "subset of or equal to, U+2286 ISOtech" }, -{ 8839, "supe", "superset of or equal to, U+2287 ISOtech" }, -{ 8853, "oplus","circled plus = direct sum, U+2295 ISOamsb" }, -{ 8855, "otimes","circled times = vector product, U+2297 ISOamsb" }, -{ 8869, "perp", "up tack = orthogonal to = perpendicular, U+22A5 ISOtech" }, -{ 8901, "sdot", "dot operator, U+22C5 ISOamsb" }, -{ 8968, "lceil","left ceiling = apl upstile, U+2308 ISOamsc" }, -{ 8969, "rceil","right ceiling, U+2309 ISOamsc" }, -{ 8970, "lfloor","left floor = apl downstile, U+230A ISOamsc" }, -{ 8971, "rfloor","right floor, U+230B ISOamsc" }, -{ 9001, "lang", "left-pointing angle bracket = bra, U+2329 ISOtech" }, -{ 9002, "rang", "right-pointing angle bracket = ket, U+232A ISOtech" }, -{ 9674, "loz", "lozenge, U+25CA ISOpub" }, - -{ 9824, "spades","black spade suit, U+2660 ISOpub" }, -{ 9827, "clubs","black club suit = shamrock, U+2663 ISOpub" }, -{ 9829, "hearts","black heart suit = valentine, U+2665 ISOpub" }, -{ 9830, "diams","black diamond suit, U+2666 ISOpub" }, - -}; - -/************************************************************************ - * * - * Commodity functions to handle entities * - * * - ************************************************************************/ - -/* - * Macro used to grow the current buffer. - */ -#define growBuffer(buffer) { \ - xmlChar *tmp; \ - buffer##_size *= 2; \ - tmp = (xmlChar *) xmlRealloc(buffer, buffer##_size * sizeof(xmlChar)); \ - if (tmp == NULL) { \ - htmlErrMemory(ctxt, "growing buffer\n"); \ - xmlFree(buffer); \ - return(NULL); \ - } \ - buffer = tmp; \ -} - -/** - * htmlEntityLookup: - * @name: the entity name - * - * Lookup the given entity in EntitiesTable - * - * TODO: the linear scan is really ugly, an hash table is really needed. - * - * Returns the associated htmlEntityDescPtr if found, NULL otherwise. - */ -const htmlEntityDesc * -htmlEntityLookup(const xmlChar *name) { - unsigned int i; - - for (i = 0;i < (sizeof(html40EntitiesTable)/ - sizeof(html40EntitiesTable[0]));i++) { - if (xmlStrEqual(name, BAD_CAST html40EntitiesTable[i].name)) { - return((htmlEntityDescPtr) &html40EntitiesTable[i]); - } - } - return(NULL); -} - -/** - * htmlEntityValueLookup: - * @value: the entity's Unicode value - * - * Lookup the given entity in EntitiesTable - * - * TODO: the linear scan is really ugly, an hash table is really needed. - * - * Returns the associated htmlEntityDescPtr if found, NULL otherwise. - */ -const htmlEntityDesc * -htmlEntityValueLookup(unsigned int value) { - unsigned int i; - - for (i = 0;i < (sizeof(html40EntitiesTable)/ - sizeof(html40EntitiesTable[0]));i++) { - if (html40EntitiesTable[i].value >= value) { - if (html40EntitiesTable[i].value > value) - break; - return((htmlEntityDescPtr) &html40EntitiesTable[i]); - } - } - return(NULL); -} - -/** - * UTF8ToHtml: - * @out: a pointer to an array of bytes to store the result - * @outlen: the length of @out - * @in: a pointer to an array of UTF-8 chars - * @inlen: the length of @in - * - * Take a block of UTF-8 chars in and try to convert it to an ASCII - * plus HTML entities block of chars out. - * - * Returns 0 if success, -2 if the transcoding fails, or -1 otherwise - * The value of @inlen after return is the number of octets consumed - * as the return value is positive, else unpredictable. - * The value of @outlen after return is the number of octets consumed. - */ -int -UTF8ToHtml(unsigned char* out, int *outlen, - const unsigned char* in, int *inlen) { - const unsigned char* processed = in; - const unsigned char* outend; - const unsigned char* outstart = out; - const unsigned char* instart = in; - const unsigned char* inend; - unsigned int c, d; - int trailing; - - if ((out == NULL) || (outlen == NULL) || (inlen == NULL)) return(-1); - if (in == NULL) { - /* - * initialization nothing to do - */ - *outlen = 0; - *inlen = 0; - return(0); - } - inend = in + (*inlen); - outend = out + (*outlen); - while (in < inend) { - d = *in++; - if (d < 0x80) { c= d; trailing= 0; } - else if (d < 0xC0) { - /* trailing byte in leading position */ - *outlen = out - outstart; - *inlen = processed - instart; - return(-2); - } else if (d < 0xE0) { c= d & 0x1F; trailing= 1; } - else if (d < 0xF0) { c= d & 0x0F; trailing= 2; } - else if (d < 0xF8) { c= d & 0x07; trailing= 3; } - else { - /* no chance for this in Ascii */ - *outlen = out - outstart; - *inlen = processed - instart; - return(-2); - } - - if (inend - in < trailing) { - break; - } - - for ( ; trailing; trailing--) { - if ((in >= inend) || (((d= *in++) & 0xC0) != 0x80)) - break; - c <<= 6; - c |= d & 0x3F; - } - - /* assertion: c is a single UTF-4 value */ - if (c < 0x80) { - if (out + 1 >= outend) - break; - *out++ = c; - } else { - int len; - const htmlEntityDesc * ent; - - /* - * Try to lookup a predefined HTML entity for it - */ - - ent = htmlEntityValueLookup(c); - if (ent == NULL) { - /* no chance for this in Ascii */ - *outlen = out - outstart; - *inlen = processed - instart; - return(-2); - } - len = strlen(ent->name); - if (out + 2 + len >= outend) - break; - *out++ = '&'; - memcpy(out, ent->name, len); - out += len; - *out++ = ';'; - } - processed = in; - } - *outlen = out - outstart; - *inlen = processed - instart; - return(0); -} - -/** - * htmlEncodeEntities: - * @out: a pointer to an array of bytes to store the result - * @outlen: the length of @out - * @in: a pointer to an array of UTF-8 chars - * @inlen: the length of @in - * @quoteChar: the quote character to escape (' or ") or zero. - * - * Take a block of UTF-8 chars in and try to convert it to an ASCII - * plus HTML entities block of chars out. - * - * Returns 0 if success, -2 if the transcoding fails, or -1 otherwise - * The value of @inlen after return is the number of octets consumed - * as the return value is positive, else unpredictable. - * The value of @outlen after return is the number of octets consumed. - */ -int -htmlEncodeEntities(unsigned char* out, int *outlen, - const unsigned char* in, int *inlen, int quoteChar) { - const unsigned char* processed = in; - const unsigned char* outend; - const unsigned char* outstart = out; - const unsigned char* instart = in; - const unsigned char* inend; - unsigned int c, d; - int trailing; - - if ((out == NULL) || (outlen == NULL) || (inlen == NULL) || (in == NULL)) - return(-1); - outend = out + (*outlen); - inend = in + (*inlen); - while (in < inend) { - d = *in++; - if (d < 0x80) { c= d; trailing= 0; } - else if (d < 0xC0) { - /* trailing byte in leading position */ - *outlen = out - outstart; - *inlen = processed - instart; - return(-2); - } else if (d < 0xE0) { c= d & 0x1F; trailing= 1; } - else if (d < 0xF0) { c= d & 0x0F; trailing= 2; } - else if (d < 0xF8) { c= d & 0x07; trailing= 3; } - else { - /* no chance for this in Ascii */ - *outlen = out - outstart; - *inlen = processed - instart; - return(-2); - } - - if (inend - in < trailing) - break; - - while (trailing--) { - if (((d= *in++) & 0xC0) != 0x80) { - *outlen = out - outstart; - *inlen = processed - instart; - return(-2); - } - c <<= 6; - c |= d & 0x3F; - } - - /* assertion: c is a single UTF-4 value */ - if ((c < 0x80) && (c != (unsigned int) quoteChar) && - (c != '&') && (c != '<') && (c != '>')) { - if (out >= outend) - break; - *out++ = c; - } else { - const htmlEntityDesc * ent; - const char *cp; - char nbuf[16]; - int len; - - /* - * Try to lookup a predefined HTML entity for it - */ - ent = htmlEntityValueLookup(c); - if (ent == NULL) { - snprintf(nbuf, sizeof(nbuf), "#%u", c); - cp = nbuf; - } - else - cp = ent->name; - len = strlen(cp); - if (out + 2 + len > outend) - break; - *out++ = '&'; - memcpy(out, cp, len); - out += len; - *out++ = ';'; - } - processed = in; - } - *outlen = out - outstart; - *inlen = processed - instart; - return(0); -} - -/************************************************************************ - * * - * Commodity functions to handle streams * - * * - ************************************************************************/ - -/** - * htmlNewInputStream: - * @ctxt: an HTML parser context - * - * Create a new input stream structure - * Returns the new input stream or NULL - */ -static htmlParserInputPtr -htmlNewInputStream(htmlParserCtxtPtr ctxt) { - htmlParserInputPtr input; - - input = (xmlParserInputPtr) xmlMalloc(sizeof(htmlParserInput)); - if (input == NULL) { - htmlErrMemory(ctxt, "couldn't allocate a new input stream\n"); - return(NULL); - } - memset(input, 0, sizeof(htmlParserInput)); - input->filename = NULL; - input->directory = NULL; - input->base = NULL; - input->cur = NULL; - input->buf = NULL; - input->line = 1; - input->col = 1; - input->buf = NULL; - input->free = NULL; - input->version = NULL; - input->consumed = 0; - input->length = 0; - return(input); -} - - -/************************************************************************ - * * - * Commodity functions, cleanup needed ? * - * * - ************************************************************************/ -/* - * all tags allowing pc data from the html 4.01 loose dtd - * NOTE: it might be more apropriate to integrate this information - * into the html40ElementTable array but I don't want to risk any - * binary incomptibility - */ -static const char *allowPCData[] = { - "a", "abbr", "acronym", "address", "applet", "b", "bdo", "big", - "blockquote", "body", "button", "caption", "center", "cite", "code", - "dd", "del", "dfn", "div", "dt", "em", "font", "form", "h1", "h2", - "h3", "h4", "h5", "h6", "i", "iframe", "ins", "kbd", "label", "legend", - "li", "noframes", "noscript", "object", "p", "pre", "q", "s", "samp", - "small", "span", "strike", "strong", "td", "th", "tt", "u", "var" -}; - -/** - * areBlanks: - * @ctxt: an HTML parser context - * @str: a xmlChar * - * @len: the size of @str - * - * Is this a sequence of blank chars that one can ignore ? - * - * Returns 1 if ignorable 0 otherwise. - */ - -static int areBlanks(htmlParserCtxtPtr ctxt, const xmlChar *str, int len) { - unsigned int i; - int j; - xmlNodePtr lastChild; - - for (j = 0;j < len;j++) - if (!(IS_BLANK_CH(str[j]))) return(0); - - if (CUR == 0) return(1); - if (CUR != '<') return(0); - if (ctxt->name == NULL) - return(1); - if (xmlStrEqual(ctxt->name, BAD_CAST"html")) - return(1); - if (xmlStrEqual(ctxt->name, BAD_CAST"head")) - return(1); - if (xmlStrEqual(ctxt->name, BAD_CAST"body")) - return(1); - if (ctxt->node == NULL) return(0); - lastChild = xmlGetLastChild(ctxt->node); - while ((lastChild) && (lastChild->type == XML_COMMENT_NODE)) - lastChild = lastChild->prev; - if (lastChild == NULL) { - if ((ctxt->node->type != XML_ELEMENT_NODE) && - (ctxt->node->content != NULL)) return(0); - /* keep ws in constructs like ... ... - for all tags "b" allowing PCDATA */ - for ( i = 0; i < sizeof(allowPCData)/sizeof(allowPCData[0]); i++ ) { - if ( xmlStrEqual(ctxt->name, BAD_CAST allowPCData[i]) ) { - return(0); - } - } - } else if (xmlNodeIsText(lastChild)) { - return(0); - } else { - /* keep ws in constructs like

xy z

- for all tags "p" allowing PCDATA */ - for ( i = 0; i < sizeof(allowPCData)/sizeof(allowPCData[0]); i++ ) { - if ( xmlStrEqual(lastChild->name, BAD_CAST allowPCData[i]) ) { - return(0); - } - } - } - return(1); -} - -/** - * htmlNewDocNoDtD: - * @URI: URI for the dtd, or NULL - * @ExternalID: the external ID of the DTD, or NULL - * - * Creates a new HTML document without a DTD node if @URI and @ExternalID - * are NULL - * - * Returns a new document, do not initialize the DTD if not provided - */ -htmlDocPtr -htmlNewDocNoDtD(const xmlChar *URI, const xmlChar *ExternalID) { - xmlDocPtr cur; - - /* - * Allocate a new document and fill the fields. - */ - cur = (xmlDocPtr) xmlMalloc(sizeof(xmlDoc)); - if (cur == NULL) { - htmlErrMemory(NULL, "HTML document creation failed\n"); - return(NULL); - } - memset(cur, 0, sizeof(xmlDoc)); - - cur->type = XML_HTML_DOCUMENT_NODE; - cur->version = NULL; - cur->intSubset = NULL; - cur->doc = cur; - cur->name = NULL; - cur->children = NULL; - cur->extSubset = NULL; - cur->oldNs = NULL; - cur->encoding = NULL; - cur->standalone = 1; - cur->compression = 0; - cur->ids = NULL; - cur->refs = NULL; - cur->_private = NULL; - cur->charset = XML_CHAR_ENCODING_UTF8; - if ((ExternalID != NULL) || - (URI != NULL)) - xmlCreateIntSubset(cur, BAD_CAST "html", ExternalID, URI); - return(cur); -} - -/** - * htmlNewDoc: - * @URI: URI for the dtd, or NULL - * @ExternalID: the external ID of the DTD, or NULL - * - * Creates a new HTML document - * - * Returns a new document - */ -htmlDocPtr -htmlNewDoc(const xmlChar *URI, const xmlChar *ExternalID) { - if ((URI == NULL) && (ExternalID == NULL)) - return(htmlNewDocNoDtD( - BAD_CAST "http://www.w3.org/TR/REC-html40/loose.dtd", - BAD_CAST "-//W3C//DTD HTML 4.0 Transitional//EN")); - - return(htmlNewDocNoDtD(URI, ExternalID)); -} - - -/************************************************************************ - * * - * The parser itself * - * Relates to http://www.w3.org/TR/html40 * - * * - ************************************************************************/ - -/************************************************************************ - * * - * The parser itself * - * * - ************************************************************************/ - -static const xmlChar * htmlParseNameComplex(xmlParserCtxtPtr ctxt); - -/** - * htmlParseHTMLName: - * @ctxt: an HTML parser context - * - * parse an HTML tag or attribute name, note that we convert it to lowercase - * since HTML names are not case-sensitive. - * - * Returns the Tag Name parsed or NULL - */ - -static const xmlChar * -htmlParseHTMLName(htmlParserCtxtPtr ctxt) { - int i = 0; - xmlChar loc[HTML_PARSER_BUFFER_SIZE]; - - if (!IS_ASCII_LETTER(CUR) && (CUR != '_') && - (CUR != ':')) return(NULL); - - while ((i < HTML_PARSER_BUFFER_SIZE) && - ((IS_ASCII_LETTER(CUR)) || (IS_ASCII_DIGIT(CUR)) || - (CUR == ':') || (CUR == '-') || (CUR == '_'))) { - if ((CUR >= 'A') && (CUR <= 'Z')) loc[i] = CUR + 0x20; - else loc[i] = CUR; - i++; - - NEXT; - } - - return(xmlDictLookup(ctxt->dict, loc, i)); -} - -/** - * htmlParseName: - * @ctxt: an HTML parser context - * - * parse an HTML name, this routine is case sensitive. - * - * Returns the Name parsed or NULL - */ - -static const xmlChar * -htmlParseName(htmlParserCtxtPtr ctxt) { - const xmlChar *in; - const xmlChar *ret; - int count = 0; - - GROW; - - /* - * Accelerator for simple ASCII names - */ - in = ctxt->input->cur; - if (((*in >= 0x61) && (*in <= 0x7A)) || - ((*in >= 0x41) && (*in <= 0x5A)) || - (*in == '_') || (*in == ':')) { - in++; - while (((*in >= 0x61) && (*in <= 0x7A)) || - ((*in >= 0x41) && (*in <= 0x5A)) || - ((*in >= 0x30) && (*in <= 0x39)) || - (*in == '_') || (*in == '-') || - (*in == ':') || (*in == '.')) - in++; - if ((*in > 0) && (*in < 0x80)) { - count = in - ctxt->input->cur; - ret = xmlDictLookup(ctxt->dict, ctxt->input->cur, count); - ctxt->input->cur = in; - ctxt->nbChars += count; - ctxt->input->col += count; - return(ret); - } - } - return(htmlParseNameComplex(ctxt)); -} - -static const xmlChar * -htmlParseNameComplex(xmlParserCtxtPtr ctxt) { - int len = 0, l; - int c; - int count = 0; - - /* - * Handler for more complex cases - */ - GROW; - c = CUR_CHAR(l); - if ((c == ' ') || (c == '>') || (c == '/') || /* accelerators */ - (!IS_LETTER(c) && (c != '_') && - (c != ':'))) { - return(NULL); - } - - while ((c != ' ') && (c != '>') && (c != '/') && /* test bigname.xml */ - ((IS_LETTER(c)) || (IS_DIGIT(c)) || - (c == '.') || (c == '-') || - (c == '_') || (c == ':') || - (IS_COMBINING(c)) || - (IS_EXTENDER(c)))) { - if (count++ > 100) { - count = 0; - GROW; - } - len += l; - NEXTL(l); - c = CUR_CHAR(l); - } - return(xmlDictLookup(ctxt->dict, ctxt->input->cur - len, len)); -} - - -/** - * htmlParseHTMLAttribute: - * @ctxt: an HTML parser context - * @stop: a char stop value - * - * parse an HTML attribute value till the stop (quote), if - * stop is 0 then it stops at the first space - * - * Returns the attribute parsed or NULL - */ - -static xmlChar * -htmlParseHTMLAttribute(htmlParserCtxtPtr ctxt, const xmlChar stop) { - xmlChar *buffer = NULL; - int buffer_size = 0; - xmlChar *out = NULL; - const xmlChar *name = NULL; - const xmlChar *cur = NULL; - const htmlEntityDesc * ent; - - /* - * allocate a translation buffer. - */ - buffer_size = HTML_PARSER_BUFFER_SIZE; - buffer = (xmlChar *) xmlMallocAtomic(buffer_size * sizeof(xmlChar)); - if (buffer == NULL) { - htmlErrMemory(ctxt, "buffer allocation failed\n"); - return(NULL); - } - out = buffer; - - /* - * Ok loop until we reach one of the ending chars - */ - while ((CUR != 0) && (CUR != stop)) { - if ((stop == 0) && (CUR == '>')) break; - if ((stop == 0) && (IS_BLANK_CH(CUR))) break; - if (CUR == '&') { - if (NXT(1) == '#') { - unsigned int c; - int bits; - - c = htmlParseCharRef(ctxt); - if (c < 0x80) - { *out++ = c; bits= -6; } - else if (c < 0x800) - { *out++ =((c >> 6) & 0x1F) | 0xC0; bits= 0; } - else if (c < 0x10000) - { *out++ =((c >> 12) & 0x0F) | 0xE0; bits= 6; } - else - { *out++ =((c >> 18) & 0x07) | 0xF0; bits= 12; } - - for ( ; bits >= 0; bits-= 6) { - *out++ = ((c >> bits) & 0x3F) | 0x80; - } - - if (out - buffer > buffer_size - 100) { - int indx = out - buffer; - - growBuffer(buffer); - out = &buffer[indx]; - } - } else { - ent = htmlParseEntityRef(ctxt, &name); - if (name == NULL) { - *out++ = '&'; - if (out - buffer > buffer_size - 100) { - int indx = out - buffer; - - growBuffer(buffer); - out = &buffer[indx]; - } - } else if (ent == NULL) { - *out++ = '&'; - cur = name; - while (*cur != 0) { - if (out - buffer > buffer_size - 100) { - int indx = out - buffer; - - growBuffer(buffer); - out = &buffer[indx]; - } - *out++ = *cur++; - } - } else { - unsigned int c; - int bits; - - if (out - buffer > buffer_size - 100) { - int indx = out - buffer; - - growBuffer(buffer); - out = &buffer[indx]; - } - c = (xmlChar)ent->value; - if (c < 0x80) - { *out++ = c; bits= -6; } - else if (c < 0x800) - { *out++ =((c >> 6) & 0x1F) | 0xC0; bits= 0; } - else if (c < 0x10000) - { *out++ =((c >> 12) & 0x0F) | 0xE0; bits= 6; } - else - { *out++ =((c >> 18) & 0x07) | 0xF0; bits= 12; } - - for ( ; bits >= 0; bits-= 6) { - *out++ = ((c >> bits) & 0x3F) | 0x80; - } - } - } - } else { - unsigned int c; - int bits, l; - - if (out - buffer > buffer_size - 100) { - int indx = out - buffer; - - growBuffer(buffer); - out = &buffer[indx]; - } - c = CUR_CHAR(l); - if (c < 0x80) - { *out++ = c; bits= -6; } - else if (c < 0x800) - { *out++ =((c >> 6) & 0x1F) | 0xC0; bits= 0; } - else if (c < 0x10000) - { *out++ =((c >> 12) & 0x0F) | 0xE0; bits= 6; } - else - { *out++ =((c >> 18) & 0x07) | 0xF0; bits= 12; } - - for ( ; bits >= 0; bits-= 6) { - *out++ = ((c >> bits) & 0x3F) | 0x80; - } - NEXT; - } - } - *out++ = 0; - return(buffer); -} - -/** - * htmlParseEntityRef: - * @ctxt: an HTML parser context - * @str: location to store the entity name - * - * parse an HTML ENTITY references - * - * [68] EntityRef ::= '&' Name ';' - * - * Returns the associated htmlEntityDescPtr if found, or NULL otherwise, - * if non-NULL *str will have to be freed by the caller. - */ -const htmlEntityDesc * -htmlParseEntityRef(htmlParserCtxtPtr ctxt, const xmlChar **str) { - const xmlChar *name; - const htmlEntityDesc * ent = NULL; - - if (str != NULL) *str = NULL; - if ((ctxt == NULL) || (ctxt->input == NULL)) return(NULL); - - if (CUR == '&') { - NEXT; - name = htmlParseName(ctxt); - if (name == NULL) { - htmlParseErr(ctxt, XML_ERR_NAME_REQUIRED, - "htmlParseEntityRef: no name\n", NULL, NULL); - } else { - GROW; - if (CUR == ';') { - if (str != NULL) - *str = name; - - /* - * Lookup the entity in the table. - */ - ent = htmlEntityLookup(name); - if (ent != NULL) /* OK that's ugly !!! */ - NEXT; - } else { - htmlParseErr(ctxt, XML_ERR_ENTITYREF_SEMICOL_MISSING, - "htmlParseEntityRef: expecting ';'\n", - NULL, NULL); - if (str != NULL) - *str = name; - } - } - } - return(ent); -} - -/** - * htmlParseAttValue: - * @ctxt: an HTML parser context - * - * parse a value for an attribute - * Note: the parser won't do substitution of entities here, this - * will be handled later in xmlStringGetNodeList, unless it was - * asked for ctxt->replaceEntities != 0 - * - * Returns the AttValue parsed or NULL. - */ - -static xmlChar * -htmlParseAttValue(htmlParserCtxtPtr ctxt) { - xmlChar *ret = NULL; - - if (CUR == '"') { - NEXT; - ret = htmlParseHTMLAttribute(ctxt, '"'); - if (CUR != '"') { - htmlParseErr(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED, - "AttValue: \" expected\n", NULL, NULL); - } else - NEXT; - } else if (CUR == '\'') { - NEXT; - ret = htmlParseHTMLAttribute(ctxt, '\''); - if (CUR != '\'') { - htmlParseErr(ctxt, XML_ERR_ATTRIBUTE_NOT_FINISHED, - "AttValue: ' expected\n", NULL, NULL); - } else - NEXT; - } else { - /* - * That's an HTMLism, the attribute value may not be quoted - */ - ret = htmlParseHTMLAttribute(ctxt, 0); - if (ret == NULL) { - htmlParseErr(ctxt, XML_ERR_ATTRIBUTE_WITHOUT_VALUE, - "AttValue: no value found\n", NULL, NULL); - } - } - return(ret); -} - -/** - * htmlParseSystemLiteral: - * @ctxt: an HTML parser context - * - * parse an HTML Literal - * - * [11] SystemLiteral ::= ('"' [^"]* '"') | ("'" [^']* "'") - * - * Returns the SystemLiteral parsed or NULL - */ - -static xmlChar * -htmlParseSystemLiteral(htmlParserCtxtPtr ctxt) { - const xmlChar *q; - xmlChar *ret = NULL; - - if (CUR == '"') { - NEXT; - q = CUR_PTR; - while ((IS_CHAR_CH(CUR)) && (CUR != '"')) - NEXT; - if (!IS_CHAR_CH(CUR)) { - htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_FINISHED, - "Unfinished SystemLiteral\n", NULL, NULL); - } else { - ret = xmlStrndup(q, CUR_PTR - q); - NEXT; - } - } else if (CUR == '\'') { - NEXT; - q = CUR_PTR; - while ((IS_CHAR_CH(CUR)) && (CUR != '\'')) - NEXT; - if (!IS_CHAR_CH(CUR)) { - htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_FINISHED, - "Unfinished SystemLiteral\n", NULL, NULL); - } else { - ret = xmlStrndup(q, CUR_PTR - q); - NEXT; - } - } else { - htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_STARTED, - " or ' expected\n", NULL, NULL); - } - - return(ret); -} - -/** - * htmlParsePubidLiteral: - * @ctxt: an HTML parser context - * - * parse an HTML public literal - * - * [12] PubidLiteral ::= '"' PubidChar* '"' | "'" (PubidChar - "'")* "'" - * - * Returns the PubidLiteral parsed or NULL. - */ - -static xmlChar * -htmlParsePubidLiteral(htmlParserCtxtPtr ctxt) { - const xmlChar *q; - xmlChar *ret = NULL; - /* - * Name ::= (Letter | '_') (NameChar)* - */ - if (CUR == '"') { - NEXT; - q = CUR_PTR; - while (IS_PUBIDCHAR_CH(CUR)) NEXT; - if (CUR != '"') { - htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_FINISHED, - "Unfinished PubidLiteral\n", NULL, NULL); - } else { - ret = xmlStrndup(q, CUR_PTR - q); - NEXT; - } - } else if (CUR == '\'') { - NEXT; - q = CUR_PTR; - while ((IS_PUBIDCHAR_CH(CUR)) && (CUR != '\'')) - NEXT; - if (CUR != '\'') { - htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_FINISHED, - "Unfinished PubidLiteral\n", NULL, NULL); - } else { - ret = xmlStrndup(q, CUR_PTR - q); - NEXT; - } - } else { - htmlParseErr(ctxt, XML_ERR_LITERAL_NOT_STARTED, - "PubidLiteral \" or ' expected\n", NULL, NULL); - } - - return(ret); -} - -/** - * htmlParseScript: - * @ctxt: an HTML parser context - * - * parse the content of an HTML SCRIPT or STYLE element - * http://www.w3.org/TR/html4/sgml/dtd.html#Script - * http://www.w3.org/TR/html4/sgml/dtd.html#StyleSheet - * http://www.w3.org/TR/html4/types.html#type-script - * http://www.w3.org/TR/html4/types.html#h-6.15 - * http://www.w3.org/TR/html4/appendix/notes.html#h-B.3.2.1 - * - * Script data ( %Script; in the DTD) can be the content of the SCRIPT - * element and the value of intrinsic event attributes. User agents must - * not evaluate script data as HTML markup but instead must pass it on as - * data to a script engine. - * NOTES: - * - The content is passed like CDATA - * - the attributes for style and scripting "onXXX" are also described - * as CDATA but SGML allows entities references in attributes so their - * processing is identical as other attributes - */ -static void -htmlParseScript(htmlParserCtxtPtr ctxt) { - xmlChar buf[HTML_PARSER_BIG_BUFFER_SIZE + 1]; - int nbchar = 0; - xmlChar cur; - - SHRINK; - cur = CUR; - while (IS_CHAR_CH(cur)) { - if ((cur == '<') && (NXT(1) == '!') && (NXT(2) == '-') && - (NXT(3) == '-')) { - if ((nbchar != 0) && (ctxt->sax != NULL) && (!ctxt->disableSAX)) { - if (ctxt->sax->cdataBlock!= NULL) { - /* - * Insert as CDATA, which is the same as HTML_PRESERVE_NODE - */ - ctxt->sax->cdataBlock(ctxt->userData, buf, nbchar); - } else if (ctxt->sax->characters != NULL) { - ctxt->sax->characters(ctxt->userData, buf, nbchar); - } - } - nbchar = 0; - htmlParseComment(ctxt); - cur = CUR; - continue; - } else if ((cur == '<') && (NXT(1) == '/')) { - /* - * One should break here, the specification is clear: - * Authors should therefore escape "= 'A') && (NXT(2) <= 'Z')) || - ((NXT(2) >= 'a') && (NXT(2) <= 'z'))) - break; /* while */ - } - buf[nbchar++] = cur; - if (nbchar >= HTML_PARSER_BIG_BUFFER_SIZE) { - if (ctxt->sax->cdataBlock!= NULL) { - /* - * Insert as CDATA, which is the same as HTML_PRESERVE_NODE - */ - ctxt->sax->cdataBlock(ctxt->userData, buf, nbchar); - } else if (ctxt->sax->characters != NULL) { - ctxt->sax->characters(ctxt->userData, buf, nbchar); - } - nbchar = 0; - } - NEXT; - cur = CUR; - } - if (!(IS_CHAR_CH(cur))) { - htmlParseErrInt(ctxt, XML_ERR_INVALID_CHAR, - "Invalid char in CDATA 0x%X\n", cur); - NEXT; - } - - if ((nbchar != 0) && (ctxt->sax != NULL) && (!ctxt->disableSAX)) { - if (ctxt->sax->cdataBlock!= NULL) { - /* - * Insert as CDATA, which is the same as HTML_PRESERVE_NODE - */ - ctxt->sax->cdataBlock(ctxt->userData, buf, nbchar); - } else if (ctxt->sax->characters != NULL) { - ctxt->sax->characters(ctxt->userData, buf, nbchar); - } - } -} - - -/** - * htmlParseCharData: - * @ctxt: an HTML parser context - * - * parse a CharData section. - * if we are within a CDATA section ']]>' marks an end of section. - * - * [14] CharData ::= [^<&]* - ([^<&]* ']]>' [^<&]*) - */ - -static void -htmlParseCharData(htmlParserCtxtPtr ctxt) { - xmlChar buf[HTML_PARSER_BIG_BUFFER_SIZE + 5]; - int nbchar = 0; - int cur, l; - - SHRINK; - cur = CUR_CHAR(l); - while (((cur != '<') || (ctxt->token == '<')) && - ((cur != '&') || (ctxt->token == '&')) && - (IS_CHAR(cur))) { - COPY_BUF(l,buf,nbchar,cur); - if (nbchar >= HTML_PARSER_BIG_BUFFER_SIZE) { - /* - * Ok the segment is to be consumed as chars. - */ - if ((ctxt->sax != NULL) && (!ctxt->disableSAX)) { - if (areBlanks(ctxt, buf, nbchar)) { - if (ctxt->sax->ignorableWhitespace != NULL) - ctxt->sax->ignorableWhitespace(ctxt->userData, - buf, nbchar); - } else { - htmlCheckParagraph(ctxt); - if (ctxt->sax->characters != NULL) - ctxt->sax->characters(ctxt->userData, buf, nbchar); - } - } - nbchar = 0; - } - NEXTL(l); - cur = CUR_CHAR(l); - if (cur == 0) { - SHRINK; - GROW; - cur = CUR_CHAR(l); - } - } - if (nbchar != 0) { - /* - * Ok the segment is to be consumed as chars. - */ - if ((ctxt->sax != NULL) && (!ctxt->disableSAX)) { - if (areBlanks(ctxt, buf, nbchar)) { - if (ctxt->sax->ignorableWhitespace != NULL) - ctxt->sax->ignorableWhitespace(ctxt->userData, buf, nbchar); - } else { - htmlCheckParagraph(ctxt); - if (ctxt->sax->characters != NULL) - ctxt->sax->characters(ctxt->userData, buf, nbchar); - } - } - } else { - /* - * Loop detection - */ - if (cur == 0) - ctxt->instate = XML_PARSER_EOF; - } -} - -/** - * htmlParseExternalID: - * @ctxt: an HTML parser context - * @publicID: a xmlChar** receiving PubidLiteral - * - * Parse an External ID or a Public ID - * - * [75] ExternalID ::= 'SYSTEM' S SystemLiteral - * | 'PUBLIC' S PubidLiteral S SystemLiteral - * - * [83] PublicID ::= 'PUBLIC' S PubidLiteral - * - * Returns the function returns SystemLiteral and in the second - * case publicID receives PubidLiteral, is strict is off - * it is possible to return NULL and have publicID set. - */ - -static xmlChar * -htmlParseExternalID(htmlParserCtxtPtr ctxt, xmlChar **publicID) { - xmlChar *URI = NULL; - - if ((UPPER == 'S') && (UPP(1) == 'Y') && - (UPP(2) == 'S') && (UPP(3) == 'T') && - (UPP(4) == 'E') && (UPP(5) == 'M')) { - SKIP(6); - if (!IS_BLANK_CH(CUR)) { - htmlParseErr(ctxt, XML_ERR_SPACE_REQUIRED, - "Space required after 'SYSTEM'\n", NULL, NULL); - } - SKIP_BLANKS; - URI = htmlParseSystemLiteral(ctxt); - if (URI == NULL) { - htmlParseErr(ctxt, XML_ERR_URI_REQUIRED, - "htmlParseExternalID: SYSTEM, no URI\n", NULL, NULL); - } - } else if ((UPPER == 'P') && (UPP(1) == 'U') && - (UPP(2) == 'B') && (UPP(3) == 'L') && - (UPP(4) == 'I') && (UPP(5) == 'C')) { - SKIP(6); - if (!IS_BLANK_CH(CUR)) { - htmlParseErr(ctxt, XML_ERR_SPACE_REQUIRED, - "Space required after 'PUBLIC'\n", NULL, NULL); - } - SKIP_BLANKS; - *publicID = htmlParsePubidLiteral(ctxt); - if (*publicID == NULL) { - htmlParseErr(ctxt, XML_ERR_PUBID_REQUIRED, - "htmlParseExternalID: PUBLIC, no Public Identifier\n", - NULL, NULL); - } - SKIP_BLANKS; - if ((CUR == '"') || (CUR == '\'')) { - URI = htmlParseSystemLiteral(ctxt); - } - } - return(URI); -} - -/** - * xmlParsePI: - * @ctxt: an XML parser context - * - * parse an XML Processing Instruction. - * - * [16] PI ::= '' Char*)))? '?>' - */ -static void -htmlParsePI(htmlParserCtxtPtr ctxt) { - xmlChar *buf = NULL; - int len = 0; - int size = HTML_PARSER_BUFFER_SIZE; - int cur, l; - const xmlChar *target; - xmlParserInputState state; - int count = 0; - - if ((RAW == '<') && (NXT(1) == '?')) { - state = ctxt->instate; - ctxt->instate = XML_PARSER_PI; - /* - * this is a Processing Instruction. - */ - SKIP(2); - SHRINK; - - /* - * Parse the target name and check for special support like - * namespace. - */ - target = htmlParseName(ctxt); - if (target != NULL) { - if (RAW == '>') { - SKIP(1); - - /* - * SAX: PI detected. - */ - if ((ctxt->sax) && (!ctxt->disableSAX) && - (ctxt->sax->processingInstruction != NULL)) - ctxt->sax->processingInstruction(ctxt->userData, - target, NULL); - ctxt->instate = state; - return; - } - buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); - if (buf == NULL) { - htmlErrMemory(ctxt, NULL); - ctxt->instate = state; - return; - } - cur = CUR; - if (!IS_BLANK(cur)) { - htmlParseErr(ctxt, XML_ERR_SPACE_REQUIRED, - "ParsePI: PI %s space expected\n", target, NULL); - } - SKIP_BLANKS; - cur = CUR_CHAR(l); - while (IS_CHAR(cur) && (cur != '>')) { - if (len + 5 >= size) { - xmlChar *tmp; - - size *= 2; - tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); - if (tmp == NULL) { - htmlErrMemory(ctxt, NULL); - xmlFree(buf); - ctxt->instate = state; - return; - } - buf = tmp; - } - count++; - if (count > 50) { - GROW; - count = 0; - } - COPY_BUF(l,buf,len,cur); - NEXTL(l); - cur = CUR_CHAR(l); - if (cur == 0) { - SHRINK; - GROW; - cur = CUR_CHAR(l); - } - } - buf[len] = 0; - if (cur != '>') { - htmlParseErr(ctxt, XML_ERR_PI_NOT_FINISHED, - "ParsePI: PI %s never end ...\n", target, NULL); - } else { - SKIP(1); - - /* - * SAX: PI detected. - */ - if ((ctxt->sax) && (!ctxt->disableSAX) && - (ctxt->sax->processingInstruction != NULL)) - ctxt->sax->processingInstruction(ctxt->userData, - target, buf); - } - xmlFree(buf); - } else { - htmlParseErr(ctxt, XML_ERR_PI_NOT_STARTED, - "PI is not started correctly", NULL, NULL); - } - ctxt->instate = state; - } -} - -/** - * htmlParseComment: - * @ctxt: an HTML parser context - * - * Parse an XML (SGML) comment - * - * [15] Comment ::= '' - */ -static void -htmlParseComment(htmlParserCtxtPtr ctxt) { - xmlChar *buf = NULL; - int len; - int size = HTML_PARSER_BUFFER_SIZE; - int q, ql; - int r, rl; - int cur, l; - xmlParserInputState state; - - /* - * Check that there is a comment right here. - */ - if ((RAW != '<') || (NXT(1) != '!') || - (NXT(2) != '-') || (NXT(3) != '-')) return; - - state = ctxt->instate; - ctxt->instate = XML_PARSER_COMMENT; - SHRINK; - SKIP(4); - buf = (xmlChar *) xmlMallocAtomic(size * sizeof(xmlChar)); - if (buf == NULL) { - htmlErrMemory(ctxt, "buffer allocation failed\n"); - ctxt->instate = state; - return; - } - q = CUR_CHAR(ql); - NEXTL(ql); - r = CUR_CHAR(rl); - NEXTL(rl); - cur = CUR_CHAR(l); - len = 0; - while (IS_CHAR(cur) && - ((cur != '>') || - (r != '-') || (q != '-'))) { - if (len + 5 >= size) { - xmlChar *tmp; - - size *= 2; - tmp = (xmlChar *) xmlRealloc(buf, size * sizeof(xmlChar)); - if (tmp == NULL) { - xmlFree(buf); - htmlErrMemory(ctxt, "growing buffer failed\n"); - ctxt->instate = state; - return; - } - buf = tmp; - } - COPY_BUF(ql,buf,len,q); - q = r; - ql = rl; - r = cur; - rl = l; - NEXTL(l); - cur = CUR_CHAR(l); - if (cur == 0) { - SHRINK; - GROW; - cur = CUR_CHAR(l); - } - } - buf[len] = 0; - if (!IS_CHAR(cur)) { - htmlParseErr(ctxt, XML_ERR_COMMENT_NOT_FINISHED, - "Comment not terminated \n */ - base += 2; - } - } - if (incomment) { - if (base + 3 > len) - return(-1); - if ((buf[base] == '-') && (buf[base + 1] == '-') && - (buf[base + 2] == '>')) { - incomment = 0; - base += 2; - } - continue; - } - if (buf[base] == first) { - if (third != 0) { - if ((buf[base + 1] != next) || - (buf[base + 2] != third)) continue; - } else if (next != 0) { - if (buf[base + 1] != next) continue; - } - ctxt->checkIndex = 0; -#ifdef DEBUG_PUSH - if (next == 0) - xmlGenericError(xmlGenericErrorContext, - "HPP: lookup '%c' found at %d\n", - first, base); - else if (third == 0) - xmlGenericError(xmlGenericErrorContext, - "HPP: lookup '%c%c' found at %d\n", - first, next, base); - else - xmlGenericError(xmlGenericErrorContext, - "HPP: lookup '%c%c%c' found at %d\n", - first, next, third, base); -#endif - return(base - (in->cur - in->base)); - } - } - ctxt->checkIndex = base; -#ifdef DEBUG_PUSH - if (next == 0) - xmlGenericError(xmlGenericErrorContext, - "HPP: lookup '%c' failed\n", first); - else if (third == 0) - xmlGenericError(xmlGenericErrorContext, - "HPP: lookup '%c%c' failed\n", first, next); - else - xmlGenericError(xmlGenericErrorContext, - "HPP: lookup '%c%c%c' failed\n", first, next, third); -#endif - return(-1); -} - -/** - * htmlParseTryOrFinish: - * @ctxt: an HTML parser context - * @terminate: last chunk indicator - * - * Try to progress on parsing - * - * Returns zero if no parsing was possible - */ -static int -htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) { - int ret = 0; - htmlParserInputPtr in; - int avail = 0; - xmlChar cur, next; - -#ifdef DEBUG_PUSH - switch (ctxt->instate) { - case XML_PARSER_EOF: - xmlGenericError(xmlGenericErrorContext, - "HPP: try EOF\n"); break; - case XML_PARSER_START: - xmlGenericError(xmlGenericErrorContext, - "HPP: try START\n"); break; - case XML_PARSER_MISC: - xmlGenericError(xmlGenericErrorContext, - "HPP: try MISC\n");break; - case XML_PARSER_COMMENT: - xmlGenericError(xmlGenericErrorContext, - "HPP: try COMMENT\n");break; - case XML_PARSER_PROLOG: - xmlGenericError(xmlGenericErrorContext, - "HPP: try PROLOG\n");break; - case XML_PARSER_START_TAG: - xmlGenericError(xmlGenericErrorContext, - "HPP: try START_TAG\n");break; - case XML_PARSER_CONTENT: - xmlGenericError(xmlGenericErrorContext, - "HPP: try CONTENT\n");break; - case XML_PARSER_CDATA_SECTION: - xmlGenericError(xmlGenericErrorContext, - "HPP: try CDATA_SECTION\n");break; - case XML_PARSER_END_TAG: - xmlGenericError(xmlGenericErrorContext, - "HPP: try END_TAG\n");break; - case XML_PARSER_ENTITY_DECL: - xmlGenericError(xmlGenericErrorContext, - "HPP: try ENTITY_DECL\n");break; - case XML_PARSER_ENTITY_VALUE: - xmlGenericError(xmlGenericErrorContext, - "HPP: try ENTITY_VALUE\n");break; - case XML_PARSER_ATTRIBUTE_VALUE: - xmlGenericError(xmlGenericErrorContext, - "HPP: try ATTRIBUTE_VALUE\n");break; - case XML_PARSER_DTD: - xmlGenericError(xmlGenericErrorContext, - "HPP: try DTD\n");break; - case XML_PARSER_EPILOG: - xmlGenericError(xmlGenericErrorContext, - "HPP: try EPILOG\n");break; - case XML_PARSER_PI: - xmlGenericError(xmlGenericErrorContext, - "HPP: try PI\n");break; - case XML_PARSER_SYSTEM_LITERAL: - xmlGenericError(xmlGenericErrorContext, - "HPP: try SYSTEM_LITERAL\n");break; - } -#endif - - while (1) { - - in = ctxt->input; - if (in == NULL) break; - if (in->buf == NULL) - avail = in->length - (in->cur - in->base); - else - avail = in->buf->buffer->use - (in->cur - in->base); - if ((avail == 0) && (terminate)) { - htmlAutoCloseOnEnd(ctxt); - if ((ctxt->nameNr == 0) && (ctxt->instate != XML_PARSER_EOF)) { - /* - * SAX: end of the document processing. - */ - ctxt->instate = XML_PARSER_EOF; - if ((ctxt->sax) && (ctxt->sax->endDocument != NULL)) - ctxt->sax->endDocument(ctxt->userData); - } - } - if (avail < 1) - goto done; - cur = in->cur[0]; - if (cur == 0) { - SKIP(1); - continue; - } - - switch (ctxt->instate) { - case XML_PARSER_EOF: - /* - * Document parsing is done ! - */ - goto done; - case XML_PARSER_START: - /* - * Very first chars read from the document flow. - */ - cur = in->cur[0]; - if (IS_BLANK_CH(cur)) { - SKIP_BLANKS; - if (in->buf == NULL) - avail = in->length - (in->cur - in->base); - else - avail = in->buf->buffer->use - (in->cur - in->base); - } - if ((ctxt->sax) && (ctxt->sax->setDocumentLocator)) - ctxt->sax->setDocumentLocator(ctxt->userData, - &xmlDefaultSAXLocator); - if ((ctxt->sax) && (ctxt->sax->startDocument) && - (!ctxt->disableSAX)) - ctxt->sax->startDocument(ctxt->userData); - - cur = in->cur[0]; - next = in->cur[1]; - if ((cur == '<') && (next == '!') && - (UPP(2) == 'D') && (UPP(3) == 'O') && - (UPP(4) == 'C') && (UPP(5) == 'T') && - (UPP(6) == 'Y') && (UPP(7) == 'P') && - (UPP(8) == 'E')) { - if ((!terminate) && - (htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0)) - goto done; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: Parsing internal subset\n"); -#endif - htmlParseDocTypeDecl(ctxt); - ctxt->instate = XML_PARSER_PROLOG; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: entering PROLOG\n"); -#endif - } else { - ctxt->instate = XML_PARSER_MISC; - } -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: entering MISC\n"); -#endif - break; - case XML_PARSER_MISC: - SKIP_BLANKS; - if (in->buf == NULL) - avail = in->length - (in->cur - in->base); - else - avail = in->buf->buffer->use - (in->cur - in->base); - if (avail < 2) - goto done; - cur = in->cur[0]; - next = in->cur[1]; - if ((cur == '<') && (next == '!') && - (in->cur[2] == '-') && (in->cur[3] == '-')) { - if ((!terminate) && - (htmlParseLookupSequence(ctxt, '-', '-', '>', 1) < 0)) - goto done; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: Parsing Comment\n"); -#endif - htmlParseComment(ctxt); - ctxt->instate = XML_PARSER_MISC; - } else if ((cur == '<') && (next == '?')) { - if ((!terminate) && - (htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0)) - goto done; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: Parsing PI\n"); -#endif - htmlParsePI(ctxt); - ctxt->instate = XML_PARSER_MISC; - } else if ((cur == '<') && (next == '!') && - (UPP(2) == 'D') && (UPP(3) == 'O') && - (UPP(4) == 'C') && (UPP(5) == 'T') && - (UPP(6) == 'Y') && (UPP(7) == 'P') && - (UPP(8) == 'E')) { - if ((!terminate) && - (htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0)) - goto done; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: Parsing internal subset\n"); -#endif - htmlParseDocTypeDecl(ctxt); - ctxt->instate = XML_PARSER_PROLOG; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: entering PROLOG\n"); -#endif - } else if ((cur == '<') && (next == '!') && - (avail < 9)) { - goto done; - } else { - ctxt->instate = XML_PARSER_START_TAG; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: entering START_TAG\n"); -#endif - } - break; - case XML_PARSER_PROLOG: - SKIP_BLANKS; - if (in->buf == NULL) - avail = in->length - (in->cur - in->base); - else - avail = in->buf->buffer->use - (in->cur - in->base); - if (avail < 2) - goto done; - cur = in->cur[0]; - next = in->cur[1]; - if ((cur == '<') && (next == '!') && - (in->cur[2] == '-') && (in->cur[3] == '-')) { - if ((!terminate) && - (htmlParseLookupSequence(ctxt, '-', '-', '>', 1) < 0)) - goto done; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: Parsing Comment\n"); -#endif - htmlParseComment(ctxt); - ctxt->instate = XML_PARSER_PROLOG; - } else if ((cur == '<') && (next == '?')) { - if ((!terminate) && - (htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0)) - goto done; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: Parsing PI\n"); -#endif - htmlParsePI(ctxt); - ctxt->instate = XML_PARSER_PROLOG; - } else if ((cur == '<') && (next == '!') && - (avail < 4)) { - goto done; - } else { - ctxt->instate = XML_PARSER_START_TAG; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: entering START_TAG\n"); -#endif - } - break; - case XML_PARSER_EPILOG: - if (in->buf == NULL) - avail = in->length - (in->cur - in->base); - else - avail = in->buf->buffer->use - (in->cur - in->base); - if (avail < 1) - goto done; - cur = in->cur[0]; - if (IS_BLANK_CH(cur)) { - htmlParseCharData(ctxt); - goto done; - } - if (avail < 2) - goto done; - next = in->cur[1]; - if ((cur == '<') && (next == '!') && - (in->cur[2] == '-') && (in->cur[3] == '-')) { - if ((!terminate) && - (htmlParseLookupSequence(ctxt, '-', '-', '>', 1) < 0)) - goto done; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: Parsing Comment\n"); -#endif - htmlParseComment(ctxt); - ctxt->instate = XML_PARSER_EPILOG; - } else if ((cur == '<') && (next == '?')) { - if ((!terminate) && - (htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0)) - goto done; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: Parsing PI\n"); -#endif - htmlParsePI(ctxt); - ctxt->instate = XML_PARSER_EPILOG; - } else if ((cur == '<') && (next == '!') && - (avail < 4)) { - goto done; - } else { - ctxt->errNo = XML_ERR_DOCUMENT_END; - ctxt->wellFormed = 0; - ctxt->instate = XML_PARSER_EOF; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: entering EOF\n"); -#endif - if ((ctxt->sax) && (ctxt->sax->endDocument != NULL)) - ctxt->sax->endDocument(ctxt->userData); - goto done; - } - break; - case XML_PARSER_START_TAG: { - const xmlChar *name, *oldname; - int depth = ctxt->nameNr; - const htmlElemDesc * info; - - if (avail < 2) - goto done; - cur = in->cur[0]; - if (cur != '<') { - ctxt->instate = XML_PARSER_CONTENT; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: entering CONTENT\n"); -#endif - break; - } - if (in->cur[1] == '/') { - ctxt->instate = XML_PARSER_END_TAG; - ctxt->checkIndex = 0; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: entering END_TAG\n"); -#endif - break; - } - if ((!terminate) && - (htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0)) - goto done; - - oldname = ctxt->name; - htmlParseStartTag(ctxt); - name = ctxt->name; - if (((depth == ctxt->nameNr) && - (xmlStrEqual(oldname, ctxt->name))) || - (name == NULL)) { - if (CUR == '>') - NEXT; - break; - } - - /* - * Lookup the info for that element. - */ - info = htmlTagLookup(name); - if (info == NULL) { - htmlParseErr(ctxt, XML_HTML_UNKNOWN_TAG, - "Tag %s invalid\n", name, NULL); - } - - /* - * Check for an Empty Element labeled the XML/SGML way - */ - if ((CUR == '/') && (NXT(1) == '>')) { - SKIP(2); - if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL)) - ctxt->sax->endElement(ctxt->userData, name); - oldname = htmlnamePop(ctxt); - ctxt->instate = XML_PARSER_CONTENT; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: entering CONTENT\n"); -#endif - break; - } - - if (CUR == '>') { - NEXT; - } else { - htmlParseErr(ctxt, XML_ERR_GT_REQUIRED, - "Couldn't find end of Start Tag %s\n", - name, NULL); - - /* - * end of parsing of this node. - */ - if (xmlStrEqual(name, ctxt->name)) { - nodePop(ctxt); - oldname = htmlnamePop(ctxt); - } - - ctxt->instate = XML_PARSER_CONTENT; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: entering CONTENT\n"); -#endif - break; - } - - /* - * Check for an Empty Element from DTD definition - */ - if ((info != NULL) && (info->empty)) { - if ((ctxt->sax != NULL) && (ctxt->sax->endElement != NULL)) - ctxt->sax->endElement(ctxt->userData, name); - oldname = htmlnamePop(ctxt); - } - ctxt->instate = XML_PARSER_CONTENT; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: entering CONTENT\n"); -#endif - break; - } - case XML_PARSER_CONTENT: { - long cons; - /* - * Handle preparsed entities and charRef - */ - if (ctxt->token != 0) { - xmlChar chr[2] = { 0 , 0 } ; - - chr[0] = (xmlChar) ctxt->token; - htmlCheckParagraph(ctxt); - if ((ctxt->sax != NULL) && (ctxt->sax->characters != NULL)) - ctxt->sax->characters(ctxt->userData, chr, 1); - ctxt->token = 0; - ctxt->checkIndex = 0; - } - if ((avail == 1) && (terminate)) { - cur = in->cur[0]; - if ((cur != '<') && (cur != '&')) { - if (ctxt->sax != NULL) { - if (IS_BLANK_CH(cur)) { - if (ctxt->sax->ignorableWhitespace != NULL) - ctxt->sax->ignorableWhitespace( - ctxt->userData, &cur, 1); - } else { - htmlCheckParagraph(ctxt); - if (ctxt->sax->characters != NULL) - ctxt->sax->characters( - ctxt->userData, &cur, 1); - } - } - ctxt->token = 0; - ctxt->checkIndex = 0; - in->cur++; - break; - } - } - if (avail < 2) - goto done; - cur = in->cur[0]; - next = in->cur[1]; - cons = ctxt->nbChars; - if ((xmlStrEqual(ctxt->name, BAD_CAST"script")) || - (xmlStrEqual(ctxt->name, BAD_CAST"style"))) { - /* - * Handle SCRIPT/STYLE separately - */ - if ((!terminate) && - (htmlParseLookupSequence(ctxt, '<', '/', 0, 0) < 0)) - goto done; - htmlParseScript(ctxt); - if ((cur == '<') && (next == '/')) { - ctxt->instate = XML_PARSER_END_TAG; - ctxt->checkIndex = 0; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: entering END_TAG\n"); -#endif - break; - } - } else { - /* - * Sometimes DOCTYPE arrives in the middle of the document - */ - if ((cur == '<') && (next == '!') && - (UPP(2) == 'D') && (UPP(3) == 'O') && - (UPP(4) == 'C') && (UPP(5) == 'T') && - (UPP(6) == 'Y') && (UPP(7) == 'P') && - (UPP(8) == 'E')) { - if ((!terminate) && - (htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0)) - goto done; - htmlParseErr(ctxt, XML_HTML_STRUCURE_ERROR, - "Misplaced DOCTYPE declaration\n", - BAD_CAST "DOCTYPE" , NULL); - htmlParseDocTypeDecl(ctxt); - } else if ((cur == '<') && (next == '!') && - (in->cur[2] == '-') && (in->cur[3] == '-')) { - if ((!terminate) && - (htmlParseLookupSequence( - ctxt, '-', '-', '>', 1) < 0)) - goto done; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: Parsing Comment\n"); -#endif - htmlParseComment(ctxt); - ctxt->instate = XML_PARSER_CONTENT; - } else if ((cur == '<') && (next == '?')) { - if ((!terminate) && - (htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0)) - goto done; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: Parsing PI\n"); -#endif - htmlParsePI(ctxt); - ctxt->instate = XML_PARSER_CONTENT; - } else if ((cur == '<') && (next == '!') && (avail < 4)) { - goto done; - } else if ((cur == '<') && (next == '/')) { - ctxt->instate = XML_PARSER_END_TAG; - ctxt->checkIndex = 0; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: entering END_TAG\n"); -#endif - break; - } else if (cur == '<') { - ctxt->instate = XML_PARSER_START_TAG; - ctxt->checkIndex = 0; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: entering START_TAG\n"); -#endif - break; - } else if (cur == '&') { - if ((!terminate) && - (htmlParseLookupSequence(ctxt, ';', 0, 0, 0) < 0)) - goto done; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: Parsing Reference\n"); -#endif - /* TODO: check generation of subtrees if noent !!! */ - htmlParseReference(ctxt); - } else { - /* - * check that the text sequence is complete - * before handing out the data to the parser - * to avoid problems with erroneous end of - * data detection. - */ - if ((!terminate) && - (htmlParseLookupSequence(ctxt, '<', 0, 0, 0) < 0)) - goto done; - ctxt->checkIndex = 0; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: Parsing char data\n"); -#endif - htmlParseCharData(ctxt); - } - } - if (cons == ctxt->nbChars) { - if (ctxt->node != NULL) { - htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR, - "detected an error in element content\n", - NULL, NULL); - } - NEXT; - break; - } - - break; - } - case XML_PARSER_END_TAG: - if (avail < 2) - goto done; - if ((!terminate) && - (htmlParseLookupSequence(ctxt, '>', 0, 0, 0) < 0)) - goto done; - htmlParseEndTag(ctxt); - if (ctxt->nameNr == 0) { - ctxt->instate = XML_PARSER_EPILOG; - } else { - ctxt->instate = XML_PARSER_CONTENT; - } - ctxt->checkIndex = 0; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: entering CONTENT\n"); -#endif - break; - case XML_PARSER_CDATA_SECTION: - htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR, - "HPP: internal error, state == CDATA\n", - NULL, NULL); - ctxt->instate = XML_PARSER_CONTENT; - ctxt->checkIndex = 0; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: entering CONTENT\n"); -#endif - break; - case XML_PARSER_DTD: - htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR, - "HPP: internal error, state == DTD\n", - NULL, NULL); - ctxt->instate = XML_PARSER_CONTENT; - ctxt->checkIndex = 0; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: entering CONTENT\n"); -#endif - break; - case XML_PARSER_COMMENT: - htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR, - "HPP: internal error, state == COMMENT\n", - NULL, NULL); - ctxt->instate = XML_PARSER_CONTENT; - ctxt->checkIndex = 0; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: entering CONTENT\n"); -#endif - break; - case XML_PARSER_PI: - htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR, - "HPP: internal error, state == PI\n", - NULL, NULL); - ctxt->instate = XML_PARSER_CONTENT; - ctxt->checkIndex = 0; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: entering CONTENT\n"); -#endif - break; - case XML_PARSER_ENTITY_DECL: - htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR, - "HPP: internal error, state == ENTITY_DECL\n", - NULL, NULL); - ctxt->instate = XML_PARSER_CONTENT; - ctxt->checkIndex = 0; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: entering CONTENT\n"); -#endif - break; - case XML_PARSER_ENTITY_VALUE: - htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR, - "HPP: internal error, state == ENTITY_VALUE\n", - NULL, NULL); - ctxt->instate = XML_PARSER_CONTENT; - ctxt->checkIndex = 0; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: entering DTD\n"); -#endif - break; - case XML_PARSER_ATTRIBUTE_VALUE: - htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR, - "HPP: internal error, state == ATTRIBUTE_VALUE\n", - NULL, NULL); - ctxt->instate = XML_PARSER_START_TAG; - ctxt->checkIndex = 0; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: entering START_TAG\n"); -#endif - break; - case XML_PARSER_SYSTEM_LITERAL: - htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR, - "HPP: internal error, state == XML_PARSER_SYSTEM_LITERAL\n", - NULL, NULL); - ctxt->instate = XML_PARSER_CONTENT; - ctxt->checkIndex = 0; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: entering CONTENT\n"); -#endif - break; - case XML_PARSER_IGNORE: - htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR, - "HPP: internal error, state == XML_PARSER_IGNORE\n", - NULL, NULL); - ctxt->instate = XML_PARSER_CONTENT; - ctxt->checkIndex = 0; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: entering CONTENT\n"); -#endif - break; - case XML_PARSER_PUBLIC_LITERAL: - htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR, - "HPP: internal error, state == XML_PARSER_LITERAL\n", - NULL, NULL); - ctxt->instate = XML_PARSER_CONTENT; - ctxt->checkIndex = 0; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, - "HPP: entering CONTENT\n"); -#endif - break; - - } - } -done: - if ((avail == 0) && (terminate)) { - htmlAutoCloseOnEnd(ctxt); - if ((ctxt->nameNr == 0) && (ctxt->instate != XML_PARSER_EOF)) { - /* - * SAX: end of the document processing. - */ - ctxt->instate = XML_PARSER_EOF; - if ((ctxt->sax) && (ctxt->sax->endDocument != NULL)) - ctxt->sax->endDocument(ctxt->userData); - } - } - if ((ctxt->myDoc != NULL) && - ((terminate) || (ctxt->instate == XML_PARSER_EOF) || - (ctxt->instate == XML_PARSER_EPILOG))) { - xmlDtdPtr dtd; - dtd = xmlGetIntSubset(ctxt->myDoc); - if (dtd == NULL) - ctxt->myDoc->intSubset = - xmlCreateIntSubset(ctxt->myDoc, BAD_CAST "html", - BAD_CAST "-//W3C//DTD HTML 4.0 Transitional//EN", - BAD_CAST "http://www.w3.org/TR/REC-html40/loose.dtd"); - } -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, "HPP: done %d\n", ret); -#endif - return(ret); -} - -/** - * htmlParseChunk: - * @ctxt: an HTML parser context - * @chunk: an char array - * @size: the size in byte of the chunk - * @terminate: last chunk indicator - * - * Parse a Chunk of memory - * - * Returns zero if no error, the xmlParserErrors otherwise. - */ -int -htmlParseChunk(htmlParserCtxtPtr ctxt, const char *chunk, int size, - int terminate) { - if ((ctxt == NULL) || (ctxt->input == NULL)) { - htmlParseErr(ctxt, XML_ERR_INTERNAL_ERROR, - "htmlParseChunk: context error\n", NULL, NULL); - return(XML_ERR_INTERNAL_ERROR); - } - if ((size > 0) && (chunk != NULL) && (ctxt->input != NULL) && - (ctxt->input->buf != NULL) && (ctxt->instate != XML_PARSER_EOF)) { - int base = ctxt->input->base - ctxt->input->buf->buffer->content; - int cur = ctxt->input->cur - ctxt->input->base; - - xmlParserInputBufferPush(ctxt->input->buf, size, chunk); - ctxt->input->base = ctxt->input->buf->buffer->content + base; - ctxt->input->cur = ctxt->input->base + cur; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, "HPP: pushed %d\n", size); -#endif - -#if 0 - if ((terminate) || (ctxt->input->buf->buffer->use > 80)) - htmlParseTryOrFinish(ctxt, terminate); -#endif - } else if (ctxt->instate != XML_PARSER_EOF) { - if ((ctxt->input != NULL) && ctxt->input->buf != NULL) { - xmlParserInputBufferPtr in = ctxt->input->buf; - if ((in->encoder != NULL) && (in->buffer != NULL) && - (in->raw != NULL)) { - int nbchars; - - nbchars = xmlCharEncInFunc(in->encoder, in->buffer, in->raw); - if (nbchars < 0) { - htmlParseErr(ctxt, XML_ERR_INVALID_ENCODING, - "encoder error\n", NULL, NULL); - return(XML_ERR_INVALID_ENCODING); - } - } - } - } - htmlParseTryOrFinish(ctxt, terminate); - if (terminate) { - if ((ctxt->instate != XML_PARSER_EOF) && - (ctxt->instate != XML_PARSER_EPILOG) && - (ctxt->instate != XML_PARSER_MISC)) { - ctxt->errNo = XML_ERR_DOCUMENT_END; - ctxt->wellFormed = 0; - } - if (ctxt->instate != XML_PARSER_EOF) { - if ((ctxt->sax) && (ctxt->sax->endDocument != NULL)) - ctxt->sax->endDocument(ctxt->userData); - } - ctxt->instate = XML_PARSER_EOF; - } - return((xmlParserErrors) ctxt->errNo); -} - -/************************************************************************ - * * - * User entry points * - * * - ************************************************************************/ - -/** - * htmlCreatePushParserCtxt: - * @sax: a SAX handler - * @user_data: The user data returned on SAX callbacks - * @chunk: a pointer to an array of chars - * @size: number of chars in the array - * @filename: an optional file name or URI - * @enc: an optional encoding - * - * Create a parser context for using the HTML parser in push mode - * The value of @filename is used for fetching external entities - * and error/warning reports. - * - * Returns the new parser context or NULL - */ -htmlParserCtxtPtr -htmlCreatePushParserCtxt(htmlSAXHandlerPtr sax, void *user_data, - const char *chunk, int size, const char *filename, - xmlCharEncoding enc) { - htmlParserCtxtPtr ctxt; - htmlParserInputPtr inputStream; - xmlParserInputBufferPtr buf; - - xmlInitParser(); - - buf = xmlAllocParserInputBuffer(enc); - if (buf == NULL) return(NULL); - - ctxt = htmlNewParserCtxt(); - if (ctxt == NULL) { - xmlFreeParserInputBuffer(buf); - return(NULL); - } - if(enc==XML_CHAR_ENCODING_UTF8 || buf->encoder) - ctxt->charset=XML_CHAR_ENCODING_UTF8; - if (sax != NULL) { - if (ctxt->sax != (xmlSAXHandlerPtr) &htmlDefaultSAXHandler) - xmlFree(ctxt->sax); - ctxt->sax = (htmlSAXHandlerPtr) xmlMalloc(sizeof(htmlSAXHandler)); - if (ctxt->sax == NULL) { - xmlFree(buf); - xmlFree(ctxt); - return(NULL); - } - memcpy(ctxt->sax, sax, sizeof(htmlSAXHandler)); - if (user_data != NULL) - ctxt->userData = user_data; - } - if (filename == NULL) { - ctxt->directory = NULL; - } else { - ctxt->directory = xmlParserGetDirectory(filename); - } - - inputStream = htmlNewInputStream(ctxt); - if (inputStream == NULL) { - xmlFreeParserCtxt(ctxt); - xmlFree(buf); - return(NULL); - } - - if (filename == NULL) - inputStream->filename = NULL; - else - inputStream->filename = (char *) - xmlCanonicPath((const xmlChar *) filename); - inputStream->buf = buf; - inputStream->base = inputStream->buf->buffer->content; - inputStream->cur = inputStream->buf->buffer->content; - inputStream->end = - &inputStream->buf->buffer->content[inputStream->buf->buffer->use]; - - inputPush(ctxt, inputStream); - - if ((size > 0) && (chunk != NULL) && (ctxt->input != NULL) && - (ctxt->input->buf != NULL)) { - int base = ctxt->input->base - ctxt->input->buf->buffer->content; - int cur = ctxt->input->cur - ctxt->input->base; - - xmlParserInputBufferPush(ctxt->input->buf, size, chunk); - - ctxt->input->base = ctxt->input->buf->buffer->content + base; - ctxt->input->cur = ctxt->input->base + cur; - ctxt->input->end = - &ctxt->input->buf->buffer->content[ctxt->input->buf->buffer->use]; -#ifdef DEBUG_PUSH - xmlGenericError(xmlGenericErrorContext, "HPP: pushed %d\n", size); -#endif - } - - return(ctxt); -} -#endif /* LIBXML_PUSH_ENABLED */ - -/** - * htmlSAXParseDoc: - * @cur: a pointer to an array of xmlChar - * @encoding: a free form C string describing the HTML document encoding, or NULL - * @sax: the SAX handler block - * @userData: if using SAX, this pointer will be provided on callbacks. - * - * Parse an HTML in-memory document. If sax is not NULL, use the SAX callbacks - * to handle parse events. If sax is NULL, fallback to the default DOM - * behavior and return a tree. - * - * Returns the resulting document tree unless SAX is NULL or the document is - * not well formed. - */ - -htmlDocPtr -htmlSAXParseDoc(xmlChar *cur, const char *encoding, htmlSAXHandlerPtr sax, void *userData) { - htmlDocPtr ret; - htmlParserCtxtPtr ctxt; - - xmlInitParser(); - - if (cur == NULL) return(NULL); - - - ctxt = htmlCreateDocParserCtxt(cur, encoding); - if (ctxt == NULL) return(NULL); - if (sax != NULL) { - if (ctxt->sax != NULL) xmlFree (ctxt->sax); - ctxt->sax = sax; - ctxt->userData = userData; - } - - htmlParseDocument(ctxt); - ret = ctxt->myDoc; - if (sax != NULL) { - ctxt->sax = NULL; - ctxt->userData = NULL; - } - htmlFreeParserCtxt(ctxt); - - return(ret); -} - -/** - * htmlParseDoc: - * @cur: a pointer to an array of xmlChar - * @encoding: a free form C string describing the HTML document encoding, or NULL - * - * parse an HTML in-memory document and build a tree. - * - * Returns the resulting document tree - */ - -htmlDocPtr -htmlParseDoc(xmlChar *cur, const char *encoding) { - return(htmlSAXParseDoc(cur, encoding, NULL, NULL)); -} - - -/** - * htmlCreateFileParserCtxt: - * @filename: the filename - * @encoding: a free form C string describing the HTML document encoding, or NULL - * - * Create a parser context for a file content. - * Automatic support for ZLIB/Compress compressed document is provided - * by default if found at compile-time. - * - * Returns the new parser context or NULL - */ -htmlParserCtxtPtr -htmlCreateFileParserCtxt(const char *filename, const char *encoding) -{ - htmlParserCtxtPtr ctxt; - htmlParserInputPtr inputStream; - char *canonicFilename; - /* htmlCharEncoding enc; */ - xmlChar *content, *content_line = (xmlChar *) "charset="; - - if (filename == NULL) - return(NULL); - - ctxt = htmlNewParserCtxt(); - if (ctxt == NULL) { - return(NULL); - } - canonicFilename = (char *) xmlCanonicPath((const xmlChar *) filename); - if (canonicFilename == NULL) { -#ifdef LIBXML_SAX1_ENABLED - if (xmlDefaultSAXHandler.error != NULL) { - xmlDefaultSAXHandler.error(NULL, "out of memory\n"); - } -#endif - xmlFreeParserCtxt(ctxt); - return(NULL); - } - - inputStream = xmlLoadExternalEntity(canonicFilename, NULL, ctxt); - xmlFree(canonicFilename); - if (inputStream == NULL) { - xmlFreeParserCtxt(ctxt); - return(NULL); - } - - inputPush(ctxt, inputStream); - - /* set encoding */ - if (encoding) { - content = xmlMallocAtomic (xmlStrlen(content_line) + strlen(encoding) + 1); - if (content) { - strcpy ((char *)content, (char *)content_line); - strcat ((char *)content, (char *)encoding); - htmlCheckEncoding (ctxt, content); - xmlFree (content); - } - } - - return(ctxt); -} - -/** - * htmlSAXParseFile: - * @filename: the filename - * @encoding: a free form C string describing the HTML document encoding, or NULL - * @sax: the SAX handler block - * @userData: if using SAX, this pointer will be provided on callbacks. - * - * parse an HTML file and build a tree. Automatic support for ZLIB/Compress - * compressed document is provided by default if found at compile-time. - * It use the given SAX function block to handle the parsing callback. - * If sax is NULL, fallback to the default DOM tree building routines. - * - * Returns the resulting document tree unless SAX is NULL or the document is - * not well formed. - */ - -htmlDocPtr -htmlSAXParseFile(const char *filename, const char *encoding, htmlSAXHandlerPtr sax, - void *userData) { - htmlDocPtr ret; - htmlParserCtxtPtr ctxt; - htmlSAXHandlerPtr oldsax = NULL; - - xmlInitParser(); - - ctxt = htmlCreateFileParserCtxt(filename, encoding); - if (ctxt == NULL) return(NULL); - if (sax != NULL) { - oldsax = ctxt->sax; - ctxt->sax = sax; - ctxt->userData = userData; - } - - htmlParseDocument(ctxt); - - ret = ctxt->myDoc; - if (sax != NULL) { - ctxt->sax = oldsax; - ctxt->userData = NULL; - } - htmlFreeParserCtxt(ctxt); - - return(ret); -} - -/** - * htmlParseFile: - * @filename: the filename - * @encoding: a free form C string describing the HTML document encoding, or NULL - * - * parse an HTML file and build a tree. Automatic support for ZLIB/Compress - * compressed document is provided by default if found at compile-time. - * - * Returns the resulting document tree - */ - -htmlDocPtr -htmlParseFile(const char *filename, const char *encoding) { - return(htmlSAXParseFile(filename, encoding, NULL, NULL)); -} - -/** - * htmlHandleOmittedElem: - * @val: int 0 or 1 - * - * Set and return the previous value for handling HTML omitted tags. - * - * Returns the last value for 0 for no handling, 1 for auto insertion. - */ - -int -htmlHandleOmittedElem(int val) { - int old = htmlOmittedDefaultValue; - - htmlOmittedDefaultValue = val; - return(old); -} - -/** - * htmlElementAllowedHere: - * @parent: HTML parent element - * @elt: HTML element - * - * Checks whether an HTML element may be a direct child of a parent element. - * Note - doesn't check for deprecated elements - * - * Returns 1 if allowed; 0 otherwise. - */ -int -htmlElementAllowedHere(const htmlElemDesc* parent, const xmlChar* elt) { - const char** p ; - - if ( ! elt || ! parent || ! parent->subelts ) - return 0 ; - - for ( p = parent->subelts; *p; ++p ) - if ( !xmlStrcmp((const xmlChar *)*p, elt) ) - return 1 ; - - return 0 ; -} -/** - * htmlElementStatusHere: - * @parent: HTML parent element - * @elt: HTML element - * - * Checks whether an HTML element may be a direct child of a parent element. - * and if so whether it is valid or deprecated. - * - * Returns one of HTML_VALID, HTML_DEPRECATED, HTML_INVALID - */ -htmlStatus -htmlElementStatusHere(const htmlElemDesc* parent, const htmlElemDesc* elt) { - if ( ! parent || ! elt ) - return HTML_INVALID ; - if ( ! htmlElementAllowedHere(parent, (const xmlChar*) elt->name ) ) - return HTML_INVALID ; - - return ( elt->dtd == 0 ) ? HTML_VALID : HTML_DEPRECATED ; -} -/** - * htmlAttrAllowed: - * @elt: HTML element - * @attr: HTML attribute - * @legacy: whether to allow deprecated attributes - * - * Checks whether an attribute is valid for an element - * Has full knowledge of Required and Deprecated attributes - * - * Returns one of HTML_REQUIRED, HTML_VALID, HTML_DEPRECATED, HTML_INVALID - */ -htmlStatus -htmlAttrAllowed(const htmlElemDesc* elt, const xmlChar* attr, int legacy) { - const char** p ; - - if ( !elt || ! attr ) - return HTML_INVALID ; - - if ( elt->attrs_req ) - for ( p = elt->attrs_req; *p; ++p) - if ( !xmlStrcmp((const xmlChar*)*p, attr) ) - return HTML_REQUIRED ; - - if ( elt->attrs_opt ) - for ( p = elt->attrs_opt; *p; ++p) - if ( !xmlStrcmp((const xmlChar*)*p, attr) ) - return HTML_VALID ; - - if ( legacy && elt->attrs_depr ) - for ( p = elt->attrs_depr; *p; ++p) - if ( !xmlStrcmp((const xmlChar*)*p, attr) ) - return HTML_DEPRECATED ; - - return HTML_INVALID ; -} -/** - * htmlNodeStatus: - * @node: an htmlNodePtr in a tree - * @legacy: whether to allow deprecated elements (YES is faster here - * for Element nodes) - * - * Checks whether the tree node is valid. Experimental (the author - * only uses the HTML enhancements in a SAX parser) - * - * Return: for Element nodes, a return from htmlElementAllowedHere (if - * legacy allowed) or htmlElementStatusHere (otherwise). - * for Attribute nodes, a return from htmlAttrAllowed - * for other nodes, HTML_NA (no checks performed) - */ -htmlStatus -htmlNodeStatus(const htmlNodePtr node, int legacy) { - if ( ! node ) - return HTML_INVALID ; - - switch ( node->type ) { - case XML_ELEMENT_NODE: - return legacy - ? ( htmlElementAllowedHere ( - htmlTagLookup(node->parent->name) , node->name - ) ? HTML_VALID : HTML_INVALID ) - : htmlElementStatusHere( - htmlTagLookup(node->parent->name) , - htmlTagLookup(node->name) ) - ; - case XML_ATTRIBUTE_NODE: - return htmlAttrAllowed( - htmlTagLookup(node->parent->name) , node->name, legacy) ; - default: return HTML_NA ; - } -} -/************************************************************************ - * * - * New set (2.6.0) of simpler and more flexible APIs * - * * - ************************************************************************/ -/** - * DICT_FREE: - * @str: a string - * - * Free a string if it is not owned by the "dict" dictionnary in the - * current scope - */ -#define DICT_FREE(str) \ - if ((str) && ((!dict) || \ - (xmlDictOwns(dict, (const xmlChar *)(str)) == 0))) \ - xmlFree((char *)(str)); - -/** - * htmlCtxtReset: - * @ctxt: an HTML parser context - * - * Reset a parser context - */ -void -htmlCtxtReset(htmlParserCtxtPtr ctxt) -{ - xmlParserInputPtr input; - xmlDictPtr dict; - - if (ctxt == NULL) - return; - - dict = ctxt->dict; - - while ((input = inputPop(ctxt)) != NULL) { /* Non consuming */ - xmlFreeInputStream(input); - } - ctxt->inputNr = 0; - ctxt->input = NULL; - - ctxt->spaceNr = 0; - if (ctxt->spaceTab != NULL) { - ctxt->spaceTab[0] = -1; - ctxt->space = &ctxt->spaceTab[0]; - } else { - ctxt->space = NULL; - } - - - ctxt->nodeNr = 0; - ctxt->node = NULL; - - ctxt->nameNr = 0; - ctxt->name = NULL; - - DICT_FREE(ctxt->version); - ctxt->version = NULL; - DICT_FREE(ctxt->encoding); - ctxt->encoding = NULL; - DICT_FREE(ctxt->directory); - ctxt->directory = NULL; - DICT_FREE(ctxt->extSubURI); - ctxt->extSubURI = NULL; - DICT_FREE(ctxt->extSubSystem); - ctxt->extSubSystem = NULL; - if (ctxt->myDoc != NULL) - xmlFreeDoc(ctxt->myDoc); - ctxt->myDoc = NULL; - - ctxt->standalone = -1; - ctxt->hasExternalSubset = 0; - ctxt->hasPErefs = 0; - ctxt->html = 1; - ctxt->external = 0; - ctxt->instate = XML_PARSER_START; - ctxt->token = 0; - - ctxt->wellFormed = 1; - ctxt->nsWellFormed = 1; - ctxt->valid = 1; - ctxt->vctxt.userData = ctxt; - ctxt->vctxt.error = xmlParserValidityError; - ctxt->vctxt.warning = xmlParserValidityWarning; - ctxt->record_info = 0; - ctxt->nbChars = 0; - ctxt->checkIndex = 0; - ctxt->inSubset = 0; - ctxt->errNo = XML_ERR_OK; - ctxt->depth = 0; - ctxt->charset = XML_CHAR_ENCODING_UTF8; - ctxt->catalogs = NULL; - xmlInitNodeInfoSeq(&ctxt->node_seq); - - if (ctxt->attsDefault != NULL) { - xmlHashFree(ctxt->attsDefault, (xmlHashDeallocator) xmlFree); - ctxt->attsDefault = NULL; - } - if (ctxt->attsSpecial != NULL) { - xmlHashFree(ctxt->attsSpecial, NULL); - ctxt->attsSpecial = NULL; - } -} - -/** - * htmlCtxtUseOptions: - * @ctxt: an HTML parser context - * @options: a combination of htmlParserOption(s) - * - * Applies the options to the parser context - * - * Returns 0 in case of success, the set of unknown or unimplemented options - * in case of error. - */ -int -htmlCtxtUseOptions(htmlParserCtxtPtr ctxt, int options) -{ - if (ctxt == NULL) - return(-1); - - if (options & HTML_PARSE_NOWARNING) { - ctxt->sax->warning = NULL; - ctxt->vctxt.warning = NULL; - options -= XML_PARSE_NOWARNING; - ctxt->options |= XML_PARSE_NOWARNING; - } - if (options & HTML_PARSE_NOERROR) { - ctxt->sax->error = NULL; - ctxt->vctxt.error = NULL; - ctxt->sax->fatalError = NULL; - options -= XML_PARSE_NOERROR; - ctxt->options |= XML_PARSE_NOERROR; - } - if (options & HTML_PARSE_PEDANTIC) { - ctxt->pedantic = 1; - options -= XML_PARSE_PEDANTIC; - ctxt->options |= XML_PARSE_PEDANTIC; - } else - ctxt->pedantic = 0; - if (options & XML_PARSE_NOBLANKS) { - ctxt->keepBlanks = 0; - ctxt->sax->ignorableWhitespace = xmlSAX2IgnorableWhitespace; - options -= XML_PARSE_NOBLANKS; - ctxt->options |= XML_PARSE_NOBLANKS; - } else - ctxt->keepBlanks = 1; - ctxt->dictNames = 0; - return (options); -} - -/** - * htmlDoRead: - * @ctxt: an HTML parser context - * @URL: the base URL to use for the document - * @encoding: the document encoding, or NULL - * @options: a combination of htmlParserOption(s) - * @reuse: keep the context for reuse - * - * Common front-end for the htmlRead functions - * - * Returns the resulting document tree or NULL - */ -static htmlDocPtr -htmlDoRead(htmlParserCtxtPtr ctxt, const char *URL, const char *encoding, - int options, int reuse) -{ - htmlDocPtr ret; - - htmlCtxtUseOptions(ctxt, options); - ctxt->html = 1; - if (encoding != NULL) { - xmlCharEncodingHandlerPtr hdlr; - - hdlr = xmlFindCharEncodingHandler(encoding); - if (hdlr != NULL) - xmlSwitchToEncoding(ctxt, hdlr); - } - if ((URL != NULL) && (ctxt->input != NULL) && - (ctxt->input->filename == NULL)) - ctxt->input->filename = (char *) xmlStrdup((const xmlChar *) URL); - htmlParseDocument(ctxt); - ret = ctxt->myDoc; - ctxt->myDoc = NULL; - if (!reuse) { - if ((ctxt->dictNames) && - (ret != NULL) && - (ret->dict == ctxt->dict)) - ctxt->dict = NULL; - xmlFreeParserCtxt(ctxt); - } - return (ret); -} - -/** - * htmlReadDoc: - * @cur: a pointer to a zero terminated string - * @URL: the base URL to use for the document - * @encoding: the document encoding, or NULL - * @options: a combination of htmlParserOption(s) - * - * parse an XML in-memory document and build a tree. - * - * Returns the resulting document tree - */ -htmlDocPtr -htmlReadDoc(const xmlChar * cur, const char *URL, const char *encoding, int options) -{ - htmlParserCtxtPtr ctxt; - - if (cur == NULL) - return (NULL); - - ctxt = xmlCreateDocParserCtxt(cur); - if (ctxt == NULL) - return (NULL); - return (htmlDoRead(ctxt, URL, encoding, options, 0)); -} - -/** - * htmlReadFile: - * @filename: a file or URL - * @encoding: the document encoding, or NULL - * @options: a combination of htmlParserOption(s) - * - * parse an XML file from the filesystem or the network. - * - * Returns the resulting document tree - */ -htmlDocPtr -htmlReadFile(const char *filename, const char *encoding, int options) -{ - htmlParserCtxtPtr ctxt; - - ctxt = htmlCreateFileParserCtxt(filename, encoding); - if (ctxt == NULL) - return (NULL); - return (htmlDoRead(ctxt, NULL, NULL, options, 0)); -} - -/** - * htmlReadMemory: - * @buffer: a pointer to a char array - * @size: the size of the array - * @URL: the base URL to use for the document - * @encoding: the document encoding, or NULL - * @options: a combination of htmlParserOption(s) - * - * parse an XML in-memory document and build a tree. - * - * Returns the resulting document tree - */ -htmlDocPtr -htmlReadMemory(const char *buffer, int size, const char *URL, const char *encoding, int options) -{ - htmlParserCtxtPtr ctxt; - - ctxt = xmlCreateMemoryParserCtxt(buffer, size); - if (ctxt == NULL) - return (NULL); - if (ctxt->sax != NULL) - memcpy(ctxt->sax, &htmlDefaultSAXHandler, sizeof(xmlSAXHandlerV1)); - return (htmlDoRead(ctxt, URL, encoding, options, 0)); -} - -/** - * htmlReadFd: - * @fd: an open file descriptor - * @URL: the base URL to use for the document - * @encoding: the document encoding, or NULL - * @options: a combination of htmlParserOption(s) - * - * parse an XML from a file descriptor and build a tree. - * - * Returns the resulting document tree - */ -htmlDocPtr -htmlReadFd(int fd, const char *URL, const char *encoding, int options) -{ - htmlParserCtxtPtr ctxt; - xmlParserInputBufferPtr input; - xmlParserInputPtr stream; - - if (fd < 0) - return (NULL); - - input = xmlParserInputBufferCreateFd(fd, XML_CHAR_ENCODING_NONE); - if (input == NULL) - return (NULL); - ctxt = xmlNewParserCtxt(); - if (ctxt == NULL) { - xmlFreeParserInputBuffer(input); - return (NULL); - } - stream = xmlNewIOInputStream(ctxt, input, XML_CHAR_ENCODING_NONE); - if (stream == NULL) { - xmlFreeParserInputBuffer(input); - xmlFreeParserCtxt(ctxt); - return (NULL); - } - inputPush(ctxt, stream); - return (htmlDoRead(ctxt, URL, encoding, options, 0)); -} - -/** - * htmlReadIO: - * @ioread: an I/O read function - * @ioclose: an I/O close function - * @ioctx: an I/O handler - * @URL: the base URL to use for the document - * @encoding: the document encoding, or NULL - * @options: a combination of htmlParserOption(s) - * - * parse an HTML document from I/O functions and source and build a tree. - * - * Returns the resulting document tree - */ -htmlDocPtr -htmlReadIO(xmlInputReadCallback ioread, xmlInputCloseCallback ioclose, - void *ioctx, const char *URL, const char *encoding, int options) -{ - htmlParserCtxtPtr ctxt; - xmlParserInputBufferPtr input; - xmlParserInputPtr stream; - - if (ioread == NULL) - return (NULL); - - input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx, - XML_CHAR_ENCODING_NONE); - if (input == NULL) - return (NULL); - ctxt = xmlNewParserCtxt(); - if (ctxt == NULL) { - xmlFreeParserInputBuffer(input); - return (NULL); - } - stream = xmlNewIOInputStream(ctxt, input, XML_CHAR_ENCODING_NONE); - if (stream == NULL) { - xmlFreeParserInputBuffer(input); - xmlFreeParserCtxt(ctxt); - return (NULL); - } - inputPush(ctxt, stream); - return (htmlDoRead(ctxt, URL, encoding, options, 0)); -} - -/** - * htmlCtxtReadDoc: - * @ctxt: an HTML parser context - * @cur: a pointer to a zero terminated string - * @URL: the base URL to use for the document - * @encoding: the document encoding, or NULL - * @options: a combination of htmlParserOption(s) - * - * parse an XML in-memory document and build a tree. - * This reuses the existing @ctxt parser context - * - * Returns the resulting document tree - */ -htmlDocPtr -htmlCtxtReadDoc(htmlParserCtxtPtr ctxt, const xmlChar * cur, - const char *URL, const char *encoding, int options) -{ - xmlParserInputPtr stream; - - if (cur == NULL) - return (NULL); - if (ctxt == NULL) - return (NULL); - - htmlCtxtReset(ctxt); - - stream = xmlNewStringInputStream(ctxt, cur); - if (stream == NULL) { - return (NULL); - } - inputPush(ctxt, stream); - return (htmlDoRead(ctxt, URL, encoding, options, 1)); -} - -/** - * htmlCtxtReadFile: - * @ctxt: an HTML parser context - * @filename: a file or URL - * @encoding: the document encoding, or NULL - * @options: a combination of htmlParserOption(s) - * - * parse an XML file from the filesystem or the network. - * This reuses the existing @ctxt parser context - * - * Returns the resulting document tree - */ -htmlDocPtr -htmlCtxtReadFile(htmlParserCtxtPtr ctxt, const char *filename, - const char *encoding, int options) -{ - xmlParserInputPtr stream; - - if (filename == NULL) - return (NULL); - if (ctxt == NULL) - return (NULL); - - htmlCtxtReset(ctxt); - - stream = xmlLoadExternalEntity(filename, NULL, ctxt); - if (stream == NULL) { - return (NULL); - } - inputPush(ctxt, stream); - return (htmlDoRead(ctxt, NULL, encoding, options, 1)); -} - -/** - * htmlCtxtReadMemory: - * @ctxt: an HTML parser context - * @buffer: a pointer to a char array - * @size: the size of the array - * @URL: the base URL to use for the document - * @encoding: the document encoding, or NULL - * @options: a combination of htmlParserOption(s) - * - * parse an XML in-memory document and build a tree. - * This reuses the existing @ctxt parser context - * - * Returns the resulting document tree - */ -htmlDocPtr -htmlCtxtReadMemory(htmlParserCtxtPtr ctxt, const char *buffer, int size, - const char *URL, const char *encoding, int options) -{ - xmlParserInputBufferPtr input; - xmlParserInputPtr stream; - - if (ctxt == NULL) - return (NULL); - if (buffer == NULL) - return (NULL); - - htmlCtxtReset(ctxt); - - input = xmlParserInputBufferCreateMem(buffer, size, XML_CHAR_ENCODING_NONE); - if (input == NULL) { - return(NULL); - } - - stream = xmlNewIOInputStream(ctxt, input, XML_CHAR_ENCODING_NONE); - if (stream == NULL) { - xmlFreeParserInputBuffer(input); - return(NULL); - } - - inputPush(ctxt, stream); - return (htmlDoRead(ctxt, URL, encoding, options, 1)); -} - -/** - * htmlCtxtReadFd: - * @ctxt: an HTML parser context - * @fd: an open file descriptor - * @URL: the base URL to use for the document - * @encoding: the document encoding, or NULL - * @options: a combination of htmlParserOption(s) - * - * parse an XML from a file descriptor and build a tree. - * This reuses the existing @ctxt parser context - * - * Returns the resulting document tree - */ -htmlDocPtr -htmlCtxtReadFd(htmlParserCtxtPtr ctxt, int fd, - const char *URL, const char *encoding, int options) -{ - xmlParserInputBufferPtr input; - xmlParserInputPtr stream; - - if (fd < 0) - return (NULL); - if (ctxt == NULL) - return (NULL); - - htmlCtxtReset(ctxt); - - - input = xmlParserInputBufferCreateFd(fd, XML_CHAR_ENCODING_NONE); - if (input == NULL) - return (NULL); - stream = xmlNewIOInputStream(ctxt, input, XML_CHAR_ENCODING_NONE); - if (stream == NULL) { - xmlFreeParserInputBuffer(input); - return (NULL); - } - inputPush(ctxt, stream); - return (htmlDoRead(ctxt, URL, encoding, options, 1)); -} - -/** - * htmlCtxtReadIO: - * @ctxt: an HTML parser context - * @ioread: an I/O read function - * @ioclose: an I/O close function - * @ioctx: an I/O handler - * @URL: the base URL to use for the document - * @encoding: the document encoding, or NULL - * @options: a combination of htmlParserOption(s) - * - * parse an HTML document from I/O functions and source and build a tree. - * This reuses the existing @ctxt parser context - * - * Returns the resulting document tree - */ -htmlDocPtr -htmlCtxtReadIO(htmlParserCtxtPtr ctxt, xmlInputReadCallback ioread, - xmlInputCloseCallback ioclose, void *ioctx, - const char *URL, - const char *encoding, int options) -{ - xmlParserInputBufferPtr input; - xmlParserInputPtr stream; - - if (ioread == NULL) - return (NULL); - if (ctxt == NULL) - return (NULL); - - htmlCtxtReset(ctxt); - - input = xmlParserInputBufferCreateIO(ioread, ioclose, ioctx, - XML_CHAR_ENCODING_NONE); - if (input == NULL) - return (NULL); - stream = xmlNewIOInputStream(ctxt, input, XML_CHAR_ENCODING_NONE); - if (stream == NULL) { - xmlFreeParserInputBuffer(input); - return (NULL); - } - inputPush(ctxt, stream); - return (htmlDoRead(ctxt, URL, encoding, options, 1)); -} - -#define bottom_HTMLparser -#include "elfgcchack.h" -#endif /* LIBXML_HTML_ENABLED */ diff --git a/Extras/FCollada/LibXML/HTMLtree.c b/Extras/FCollada/LibXML/HTMLtree.c deleted file mode 100644 index de086db46..000000000 --- a/Extras/FCollada/LibXML/HTMLtree.c +++ /dev/null @@ -1,1193 +0,0 @@ -/* - * HTMLtree.c : implementation of access function for an HTML tree. - * - * See Copyright for the status of this software. - * - * daniel@veillard.com - */ - - -#define IN_LIBXML -#include "libxml.h" -#ifdef LIBXML_HTML_ENABLED - -#include /* for memset() only ! */ - -#ifdef HAVE_CTYPE_H -#include -#endif -#ifdef HAVE_STDLIB_H -#include -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/************************************************************************ - * * - * Getting/Setting encoding meta tags * - * * - ************************************************************************/ - -/** - * htmlGetMetaEncoding: - * @doc: the document - * - * Encoding definition lookup in the Meta tags - * - * Returns the current encoding as flagged in the HTML source - */ -const xmlChar * -htmlGetMetaEncoding(htmlDocPtr doc) { - htmlNodePtr cur; - const xmlChar *content; - const xmlChar *encoding; - - if (doc == NULL) - return(NULL); - cur = doc->children; - - /* - * Search the html - */ - while (cur != NULL) { - if ((cur->type == XML_ELEMENT_NODE) && (cur->name != NULL)) { - if (xmlStrEqual(cur->name, BAD_CAST"html")) - break; - if (xmlStrEqual(cur->name, BAD_CAST"head")) - goto found_head; - if (xmlStrEqual(cur->name, BAD_CAST"meta")) - goto found_meta; - } - cur = cur->next; - } - if (cur == NULL) - return(NULL); - cur = cur->children; - - /* - * Search the head - */ - while (cur != NULL) { - if ((cur->type == XML_ELEMENT_NODE) && (cur->name != NULL)) { - if (xmlStrEqual(cur->name, BAD_CAST"head")) - break; - if (xmlStrEqual(cur->name, BAD_CAST"meta")) - goto found_meta; - } - cur = cur->next; - } - if (cur == NULL) - return(NULL); -found_head: - cur = cur->children; - - /* - * Search the meta elements - */ -found_meta: - while (cur != NULL) { - if ((cur->type == XML_ELEMENT_NODE) && (cur->name != NULL)) { - if (xmlStrEqual(cur->name, BAD_CAST"meta")) { - xmlAttrPtr attr = cur->properties; - int http; - const xmlChar *value; - - content = NULL; - http = 0; - while (attr != NULL) { - if ((attr->children != NULL) && - (attr->children->type == XML_TEXT_NODE) && - (attr->children->next == NULL)) { - value = attr->children->content; - if ((!xmlStrcasecmp(attr->name, BAD_CAST"http-equiv")) - && (!xmlStrcasecmp(value, BAD_CAST"Content-Type"))) - http = 1; - else if ((value != NULL) - && (!xmlStrcasecmp(attr->name, BAD_CAST"content"))) - content = value; - if ((http != 0) && (content != NULL)) - goto found_content; - } - attr = attr->next; - } - } - } - cur = cur->next; - } - return(NULL); - -found_content: - encoding = xmlStrstr(content, BAD_CAST"charset="); - if (encoding == NULL) - encoding = xmlStrstr(content, BAD_CAST"Charset="); - if (encoding == NULL) - encoding = xmlStrstr(content, BAD_CAST"CHARSET="); - if (encoding != NULL) { - encoding += 8; - } else { - encoding = xmlStrstr(content, BAD_CAST"charset ="); - if (encoding == NULL) - encoding = xmlStrstr(content, BAD_CAST"Charset ="); - if (encoding == NULL) - encoding = xmlStrstr(content, BAD_CAST"CHARSET ="); - if (encoding != NULL) - encoding += 9; - } - if (encoding != NULL) { - while ((*encoding == ' ') || (*encoding == '\t')) encoding++; - } - return(encoding); -} - -/** - * htmlSetMetaEncoding: - * @doc: the document - * @encoding: the encoding string - * - * Sets the current encoding in the Meta tags - * NOTE: this will not change the document content encoding, just - * the META flag associated. - * - * Returns 0 in case of success and -1 in case of error - */ -int -htmlSetMetaEncoding(htmlDocPtr doc, const xmlChar *encoding) { - htmlNodePtr cur, meta; - const xmlChar *content; - char newcontent[100]; - - - if (doc == NULL) - return(-1); - - if (encoding != NULL) { - snprintf(newcontent, sizeof(newcontent), "text/html; charset=%s", - (char *)encoding); - newcontent[sizeof(newcontent) - 1] = 0; - } - - cur = doc->children; - - /* - * Search the html - */ - while (cur != NULL) { - if ((cur->type == XML_ELEMENT_NODE) && (cur->name != NULL)) { - if (xmlStrcasecmp(cur->name, BAD_CAST"html") == 0) - break; - if (xmlStrcasecmp(cur->name, BAD_CAST"head") == 0) - goto found_head; - if (xmlStrcasecmp(cur->name, BAD_CAST"meta") == 0) - goto found_meta; - } - cur = cur->next; - } - if (cur == NULL) - return(-1); - cur = cur->children; - - /* - * Search the head - */ - while (cur != NULL) { - if ((cur->type == XML_ELEMENT_NODE) && (cur->name != NULL)) { - if (xmlStrcasecmp(cur->name, BAD_CAST"head") == 0) - break; - if (xmlStrcasecmp(cur->name, BAD_CAST"meta") == 0) - goto found_meta; - } - cur = cur->next; - } - if (cur == NULL) - return(-1); -found_head: - if (cur->children == NULL) { - if (encoding == NULL) - return(0); - meta = xmlNewDocNode(doc, NULL, BAD_CAST"meta", NULL); - xmlAddChild(cur, meta); - xmlNewProp(meta, BAD_CAST"http-equiv", BAD_CAST"Content-Type"); - xmlNewProp(meta, BAD_CAST"content", BAD_CAST newcontent); - return(0); - } - cur = cur->children; - -found_meta: - if (encoding != NULL) { - /* - * Create a new Meta element with the right attributes - */ - - meta = xmlNewDocNode(doc, NULL, BAD_CAST"meta", NULL); - xmlAddPrevSibling(cur, meta); - xmlNewProp(meta, BAD_CAST"http-equiv", BAD_CAST"Content-Type"); - xmlNewProp(meta, BAD_CAST"content", BAD_CAST newcontent); - } - - /* - * Search and destroy all the remaining the meta elements carrying - * encoding informations - */ - while (cur != NULL) { - if ((cur->type == XML_ELEMENT_NODE) && (cur->name != NULL)) { - if (xmlStrcasecmp(cur->name, BAD_CAST"meta") == 0) { - xmlAttrPtr attr = cur->properties; - int http; - const xmlChar *value; - - content = NULL; - http = 0; - while (attr != NULL) { - if ((attr->children != NULL) && - (attr->children->type == XML_TEXT_NODE) && - (attr->children->next == NULL)) { - value = attr->children->content; - if ((!xmlStrcasecmp(attr->name, BAD_CAST"http-equiv")) - && (!xmlStrcasecmp(value, BAD_CAST"Content-Type"))) - http = 1; - else - { - if ((value != NULL) && - (!xmlStrcasecmp(attr->name, BAD_CAST"content"))) - content = value; - } - if ((http != 0) && (content != NULL)) - break; - } - attr = attr->next; - } - if ((http != 0) && (content != NULL)) { - meta = cur; - cur = cur->next; - xmlUnlinkNode(meta); - xmlFreeNode(meta); - continue; - } - - } - } - cur = cur->next; - } - return(0); -} - -/** - * booleanHTMLAttrs: - * - * These are the HTML attributes which will be output - * in minimized form, i.e.