From: <rob...@us...> - 2009-02-12 14:19:03
|
Revision: 355 http://colladamaya.svn.sourceforge.net/colladamaya/?rev=355&view=rev Author: robertwuerfel Date: 2009-02-12 14:18:55 +0000 (Thu, 12 Feb 2009) Log Message: ----------- complete FREE non animated camera Modified Paths: -------------- branches/nextgen/COLLADAFramework/include/COLLADAFWCamera.h branches/nextgen/COLLADAFramework/include/COLLADAFWLookat.h branches/nextgen/COLLADAFramework/include/COLLADAFWSceneGraphInstance.h branches/nextgen/COLLADAMax/include/COLLADAMaxColladaPlugin.h branches/nextgen/COLLADAMax/include/COLLADAMaxDocumentImporter.h branches/nextgen/COLLADAMax/include/COLLADAMaxGeometryImporter.h branches/nextgen/COLLADAMax/include/COLLADAMaxImporterBase.h branches/nextgen/COLLADAMax/include/COLLADAMaxNodeImporter.h branches/nextgen/COLLADAMax/scripts/COLLADAMax.vcproj branches/nextgen/COLLADAMax/src/COLLADAMaxCameraExporter.cpp branches/nextgen/COLLADAMax/src/COLLADAMaxColladaPlugin.cpp branches/nextgen/COLLADAMax/src/COLLADAMaxDllEntry.cpp branches/nextgen/COLLADAMax/src/COLLADAMaxDocumentExporter.cpp branches/nextgen/COLLADAMax/src/COLLADAMaxDocumentImporter.cpp branches/nextgen/COLLADAMax/src/COLLADAMaxGeometryImporter.cpp branches/nextgen/COLLADAMax/src/COLLADAMaxImporterBase.cpp branches/nextgen/COLLADAMax/src/COLLADAMaxNodeImporter.cpp branches/nextgen/COLLADAMaya/src/COLLADAMayaVisualSceneImporter.cpp branches/nextgen/COLLADASaxFrameworkLoader/src/COLLADASaxFWLLibraryCamerasLoader.cpp branches/nextgen/COLLADASaxFrameworkLoader/src/COLLADASaxFWLMeshLoader.cpp branches/nextgen/COLLADASaxFrameworkLoader/src/COLLADASaxFWLNodeLoader.cpp Added Paths: ----------- branches/nextgen/COLLADAMax/include/COLLADAMaxCameraImporter.h branches/nextgen/COLLADAMax/src/COLLADAMaxCameraImporter.cpp Modified: branches/nextgen/COLLADAFramework/include/COLLADAFWCamera.h =================================================================== --- branches/nextgen/COLLADAFramework/include/COLLADAFWCamera.h 2009-02-11 15:30:41 UTC (rev 354) +++ branches/nextgen/COLLADAFramework/include/COLLADAFWCamera.h 2009-02-12 14:18:55 UTC (rev 355) @@ -21,7 +21,7 @@ /** Camera class. The camera is either a perspective or an orthographic camera. The CameraType indicates of which type the camera is which. For perspective cameras mXFovOrXMag and mYFovOrYMag store the horizontal or vertical field of view, - for perspective cameras mXFovOrXMag and mYFovOrYMag store the horizontal or vertical magnification of the view.*/ + for orthographic cameras mXFovOrXMag and mYFovOrYMag store the horizontal or vertical magnification of the view.*/ class Camera : public ObjectTemplate < COLLADA_TYPE::CAMERA > { public: @@ -33,7 +33,7 @@ PERSPECTIVE }; - /** Defines which values are used to describe the perspective camera.*/ + /** Defines which values are used to describe the camera.*/ enum DescriptionType { UNDEFINED, //!< The perspective camera object is invalid @@ -97,18 +97,30 @@ /** sets the type of description used to define the perspective camera.*/ void setDescriptionType(DescriptionType descriptionType) { mDescriptionType = descriptionType; } - /** Returns the horizontal field of view or magnification of the view.*/ - double getXFovOrXMag() const { return mXFovOrXMag; } + /** Returns the horizontal field of view. Use only for perspective cameras.*/ + double getXFov() const { return mXFovOrXMag; } - /** Sets the horizontal field of view or magnification of the view.*/ - void setXFovOrXMag(double xFov) { mXFovOrXMag = xFov; } + /** Sets the horizontal field of view. Use only for perspective cameras.*/ + void setXFov(double xFov) { mXFovOrXMag = xFov; } - /** Returns the vertical field of view or magnification of the view.*/ - double getYFovOrYMag() const { return mYFovOrYMag; } + /** Returns the horizontal magnification of the view. Use only for orthographic cameras.*/ + double getXMag() const { return mXFovOrXMag; } - /** Sets the vertical field of view or magnification of the view.*/ - void setYFovOrYMag(double yFov) { mYFovOrYMag = yFov; } + /** Sets the horizontal magnification of the view. Use only for orthographic cameras.*/ + void setXMag(double xMag) { mXFovOrXMag = xMag; } + /** Returns the vertical field of view. Use only for perspective cameras.*/ + double getYFov() const { return mYFovOrYMag; } + + /** Sets the vertical field of view. Use only for perspective cameras.*/ + void setYFov(double yFov) { mYFovOrYMag = yFov; } + + /** Returns the vertical magnification of the view. Use only for orthographic cameras.*/ + double getYMag() const { return mYFovOrYMag; } + + /** Sets the vertical magnification of the view. Use only for orthographic cameras.*/ + void setYMag(double yMag) { mYFovOrYMag = yMag; } + /** Returns the aspect ratio.*/ double getAspectRatio() const { return mAspectRatio; } Modified: branches/nextgen/COLLADAFramework/include/COLLADAFWLookat.h =================================================================== --- branches/nextgen/COLLADAFramework/include/COLLADAFWLookat.h 2009-02-11 15:30:41 UTC (rev 354) +++ branches/nextgen/COLLADAFramework/include/COLLADAFWLookat.h 2009-02-12 14:18:55 UTC (rev 355) @@ -36,10 +36,10 @@ COLLADABU::Math::Vector3 mEyePosition; /** The target of the viewer. Defines the pitch and the yaw of the transform. */ - COLLADABU::Math::Vector3 mInterestPosition; + COLLADABU::Math::Vector3 mInterestPointPosition; /** The up-axis of the viewer. Defines the roll of the transform. */ - COLLADABU::Math::Vector3 mUpPosition; + COLLADABU::Math::Vector3 mUpAxisDirection; public: @@ -57,14 +57,14 @@ void setEyePosition ( COLLADABU::Math::Vector3& val ) { mEyePosition = val; } /** The target of the viewer. Defines the pitch and the yaw of the transform. */ - COLLADABU::Math::Vector3& getInterestPosition () { return mInterestPosition; } - const COLLADABU::Math::Vector3& getInterestPosition () const { return mInterestPosition; } - void setInterestPosition ( COLLADABU::Math::Vector3& val ) { mInterestPosition = val; } + COLLADABU::Math::Vector3& getInterestPointPosition () { return mInterestPointPosition; } + const COLLADABU::Math::Vector3& getInterestPointPosition () const { return mInterestPointPosition; } + void setInterestPointPosition ( COLLADABU::Math::Vector3& val ) { mInterestPointPosition = val; } /** The up-axis of the viewer. Defines the roll of the transform. */ - COLLADABU::Math::Vector3& getUpPosition () { return mUpPosition; } - const COLLADABU::Math::Vector3& getUpPosition () const { return mUpPosition; } - void setUpPosition ( COLLADABU::Math::Vector3& val ) { mUpPosition = val; } + COLLADABU::Math::Vector3& getUpAxisDirection () { return mUpAxisDirection; } + const COLLADABU::Math::Vector3& getUpAxisDirection () const { return mUpAxisDirection; } + void setUpAxisDirection ( COLLADABU::Math::Vector3& val ) { mUpAxisDirection = val; } /** Clones the lookat.*/ virtual Lookat* clone() const { return new Lookat(*this); } Modified: branches/nextgen/COLLADAFramework/include/COLLADAFWSceneGraphInstance.h =================================================================== --- branches/nextgen/COLLADAFramework/include/COLLADAFWSceneGraphInstance.h 2009-02-11 15:30:41 UTC (rev 354) +++ branches/nextgen/COLLADAFramework/include/COLLADAFWSceneGraphInstance.h 2009-02-12 14:18:55 UTC (rev 355) @@ -13,6 +13,7 @@ #include "COLLADAFWPrerequisites.h" #include "COLLADAFWUniqueId.h" +#include "COLLADAFWPointerArray.h" namespace COLLADAFW @@ -50,15 +51,11 @@ virtual SceneGraphInstance* clone() const { return new SceneGraphInstance(*this); } - private: - /** Disable default copy ctor. */ -// SceneGraphInstance( const SceneGraphInstance& pre ); - /** Disable default assignment operator. */ -// const SceneGraphInstance& operator= ( const SceneGraphInstance& pre ); - }; + typedef PointerArray<SceneGraphInstance> SceneGraphInstancePointerArray; + } // namespace COLLADAFW #endif // __COLLADAFW_SCENEGRAPHINSTANCE_H__ Added: branches/nextgen/COLLADAMax/include/COLLADAMaxCameraImporter.h =================================================================== --- branches/nextgen/COLLADAMax/include/COLLADAMaxCameraImporter.h (rev 0) +++ branches/nextgen/COLLADAMax/include/COLLADAMaxCameraImporter.h 2009-02-12 14:18:55 UTC (rev 355) @@ -0,0 +1,71 @@ +/* +Copyright (c) 2008 NetAllied Systems GmbH + +This file is part of COLLADAMax. + +Portions of the code are: +Copyright (c) 2005-2007 Feeling Software Inc. +Copyright (c) 2005-2007 Sony Computer Entertainment America + +Based on the 3dsMax COLLADASW Tools: +Copyright (c) 2005-2006 Autodesk Media Entertainment + +Licensed under the MIT Open Source License, +for details please see LICENSE file or the website +http://www.opensource.org/licenses/mit-license.php +*/ + +#ifndef __COLLADAMAX_CAMERAIMPORTER_H__ +#define __COLLADAMAX_CAMERAIMPORTER_H__ + +#include "COLLADAMaxPrerequisites.h" +#include "COLLADAMaxImporterBase.h" + + +class GenCamera; + +namespace COLLADAFW +{ + class Camera; +}; + + +namespace COLLADAMax +{ + + /** Imports a camera into the max scene */ + class CameraImporter : public ImporterBase + { + private: + /** The camera to import.*/ + const COLLADAFW::Camera* mCamera; + + public: + + /** Constructor. */ + CameraImporter( DocumentImporter* documentImporter, const COLLADAFW::Camera* camera ); + + /** Destructor. */ + virtual ~CameraImporter(); + + /** Performs the import of the camera. + @return True on success, false otherwise.*/ + bool import(); + + /** Creates a new GenCamera from @a camera and returns a pointer to it. */ + GenCamera* createCamera( const COLLADAFW::Camera* camera ); + + + private: + + /** Disable default copy ctor. */ + CameraImporter( const CameraImporter& pre ); + + /** Disable default assignment operator. */ + const CameraImporter& operator= ( const CameraImporter& pre ); + + }; + +} // namespace COLLADAMAX + +#endif // __COLLADAMAX_CAMERAIMPORTER_H__ Modified: branches/nextgen/COLLADAMax/include/COLLADAMaxColladaPlugin.h =================================================================== --- branches/nextgen/COLLADAMax/include/COLLADAMaxColladaPlugin.h 2009-02-11 15:30:41 UTC (rev 354) +++ branches/nextgen/COLLADAMax/include/COLLADAMaxColladaPlugin.h 2009-02-12 14:18:55 UTC (rev 355) @@ -18,6 +18,11 @@ static const String OTHERMESSAGE1; static const String OTHERMESSAGE2; + static const String REVISION_STRING; + static const String PLATFORM_STRING; + static const String CONFIGURATION_STRING; + + static const String FATALERROR; Modified: branches/nextgen/COLLADAMax/include/COLLADAMaxDocumentImporter.h =================================================================== --- branches/nextgen/COLLADAMax/include/COLLADAMaxDocumentImporter.h 2009-02-11 15:30:41 UTC (rev 354) +++ branches/nextgen/COLLADAMax/include/COLLADAMaxDocumentImporter.h 2009-02-12 14:18:55 UTC (rev 355) @@ -97,7 +97,10 @@ /** List of inode inode pairs.*/ typedef std::vector<std::pair<INode*, INode*>> INodeINodePairList; + /** Maps an object to its name.*/ + typedef std::map<Object*, String > ObjectObjectNameMap; + private: /** Max interface.*/ Interface* mMaxInterface; @@ -158,6 +161,9 @@ an inode is cloned, the cloned one and itself should be added to that list.*/ INodeINodePairList mClonedINodeOriginalINodePairList; + /** Maps an object to its name. Whenever an object is created, add it with its name to this map.*/ + ObjectObjectNameMap mObjectObjectNameMap; + public: /** Constructor . @param maxInterface The max interface. @@ -266,6 +272,10 @@ When ever an inode is cloned, the cloned one and itself should be added to that list.*/ INodeINodePairList& getClonedINodeOriginalINodePairList() { return mClonedINodeOriginalINodePairList; } + /** Returns the map, that maps an object to its name. Whenever an object is created, add it with + its name to this map.*/ + ObjectObjectNameMap& getObjectObjectNameMap() { return mObjectObjectNameMap; } + friend class ImporterBase; }; Modified: branches/nextgen/COLLADAMax/include/COLLADAMaxGeometryImporter.h =================================================================== --- branches/nextgen/COLLADAMax/include/COLLADAMaxGeometryImporter.h 2009-02-11 15:30:41 UTC (rev 354) +++ branches/nextgen/COLLADAMax/include/COLLADAMaxGeometryImporter.h 2009-02-12 14:18:55 UTC (rev 355) @@ -99,10 +99,6 @@ - /** Performs all operations to ensure that the geometry is referenced by the all nodes - that need to reference it.*/ - bool handleReferences(COLLADAFW::Geometry* geometry, Object* object); - /** Fills the map with pair of frame work material ids of the used by primitives in @a primitiveArray and material ids used in Max. The max material ids start with 1 and are increased for each new framework material id.*/ Modified: branches/nextgen/COLLADAMax/include/COLLADAMaxImporterBase.h =================================================================== --- branches/nextgen/COLLADAMax/include/COLLADAMaxImporterBase.h 2009-02-11 15:30:41 UTC (rev 354) +++ branches/nextgen/COLLADAMax/include/COLLADAMaxImporterBase.h 2009-02-12 14:18:55 UTC (rev 355) @@ -45,6 +45,9 @@ /** The base class of all importer classes. It provides methods used by all importer classes.*/ class ImporterBase { + public: + static const String EMPTY_STRING; + private: /** The collada importer the importer belongs to.*/ DocumentImporter* mDocumentImporter; @@ -71,6 +74,12 @@ /** Returns collada importer the importer belongs to.*/ DocumentImporter* getColladaImporter() { return mDocumentImporter; } + /** Performs all operations to ensure that the object is referenced by the all nodes + that need to reference it. + @tparam FWObject The framework object class of the framework object that became object */ + template<class FWObject> + bool handleObjectReferences( FWObject* fWobject, Object* object ); + /** Adds an UniqueId-Object INode pair to the UniqueIdObjectINodeMap. An Object INode is an INode that references an object. For nodes that reference an object that has not already been loaded this method should be called.*/ @@ -130,6 +139,10 @@ /** Adds the @pair clonedNode and @a originalNode to the list of cloned and original inodes.*/ void addClonedINodeOriginalINodePair(INode* clonedNode, INode* originalNode); + /** Adds an object object-name pair to the ObejctObjectNameMap. Whenever an object is created, + add it using this method.*/ + void addObjectObjectNamePair( Object* object, const String& name); + /** Returns the object that was created from the imported object with UniqueId @a uniqueId. If @a uniqueId has not been added using addUniqueIdObjectPair, null is returned.*/ Object* getObjectByUniqueId( const COLLADAFW::UniqueId& uniqueId); @@ -165,6 +178,9 @@ When ever an inode is cloned, the cloned one and itself should be added to that list.*/ const DocumentImporter::INodeINodePairList& getClonedINodeOriginalINodePairList(); + /** Returns the name of @a object.*/ + const String& getObjectNameByObject( Object* object ) const; + private: /** Disable default copy ctor. */ @@ -175,6 +191,36 @@ }; + + + //------------------------------ + template<class FWObject> + bool ImporterBase::handleObjectReferences( FWObject* fWobject, Object* object ) + { + const COLLADAFW::UniqueId& uniqueID = fWobject->getUniqueId(); + + const String& objectName = fWobject->getName(); + addUniqueIdObjectPair(uniqueID, object); + if ( !objectName.empty() ) + addObjectObjectNamePair(object, objectName); + + INodeList objectNodeList; + getObjectINodesByUniqueId(uniqueID, objectNodeList); + for ( size_t i = 0, count = objectNodeList.size(); i<count; ++i) + { + INode* maxNode = objectNodeList[i]; + TCHAR* name = maxNode->GetName(); + if ( !name || !(*name) ) + maxNode->SetName( (char *)objectName.c_str()); + maxNode->SetObjectRef(object); + } + + return true; + } + + + + } // namespace COLLADAMAX #endif // __COLLADAMAX_IMPORTERBASE_H__ Modified: branches/nextgen/COLLADAMax/include/COLLADAMaxNodeImporter.h =================================================================== --- branches/nextgen/COLLADAMax/include/COLLADAMaxNodeImporter.h 2009-02-11 15:30:41 UTC (rev 354) +++ branches/nextgen/COLLADAMax/include/COLLADAMaxNodeImporter.h 2009-02-12 14:18:55 UTC (rev 355) @@ -24,6 +24,8 @@ #include "COLLADAFWNode.h" #include "Math/COLLADABUMathMatrix4.h" + +class INode; namespace COLLADAFW { }; @@ -56,15 +58,39 @@ /** Imports all nodes in @a nodeArray and attaches them to @a parentImportNode.*/ bool importNodes(const COLLADAFW::NodePointerArray& nodeArray, ImpNode* parentImportNode); + /** Imports all the instances in @a instanceArray and attaches them to @a parentImportNode.*/ + template<class Instance, + void (NodeImporter::*postProcess)( INode*, Instance* )> + bool importInstances( const COLLADAFW::PointerArray<Instance>& instanceArray, ImpNode* parentImportNode ); + /** Imports all the instance geometries in @a instanceGeometryArray and attaches them to @a parentImportNode.*/ bool importInstanceGeometries( const COLLADAFW::InstanceGeometryPointerArray& instanceGeometryArray, ImpNode* parentImportNode ); + /** Imports all the instance cameras in @a instanceGeometryArray and attaches them to @a parentImportNode.*/ + bool importInstanceCameras( const COLLADAFW::InstanceCameraPointerArray& instanceCameraArray, ImpNode* parentImportNode ); + + + /** Imports the first instance of type Instance in @a node. A new INode is created, that references + the instantiated geometry and has the properties of @a node (name, transformation). The new INode + is attached to @a parentImportNode. Use this member, if a node has exactly one instance.*/ + template<class Instance, + const COLLADAFW::PointerArray<Instance>& (COLLADAFW::Node::*getInstances)()const, + void (NodeImporter::*postProcess)( INode*, Instance* )> + ImpNode* importInstance( const COLLADAFW::Node* node, ImpNode* parentImportNode ); + /** Imports the first instance geometry in @a node. It is assumed that @a node has at least one instance geometry. A new INode is created, that references the instantiated geometry and has the properties of @a node (name, transformation). The new INode is attached to @a parentImportNode. Use this member, if a node has exactly one instance geometry.*/ ImpNode* importInstanceGeometry( const COLLADAFW::Node* node, ImpNode* parentImportNode ); + + /** Imports the first instance camera in @a node. It is assumed that @a node has at least one + instance camera. A new INode is created, that references the instantiated camera and has the + properties of @a node (name, transformation). The new INode is attached to @a parentImportNode. + Use this member, if a node has exactly one instance camera.*/ + ImpNode* importInstanceCamera( const COLLADAFW::Node* node, ImpNode* parentImportNode ); + /** Imports all the instance nodes in @a instanceNodeArray and attaches them to @a parentImportNode.*/ bool importInstanceNodes( const COLLADAFW::InstanceNodePointerArray& instanceNodeArray, ImpNode* parentImportNode ); Modified: branches/nextgen/COLLADAMax/scripts/COLLADAMax.vcproj =================================================================== --- branches/nextgen/COLLADAMax/scripts/COLLADAMax.vcproj 2009-02-11 15:30:41 UTC (rev 354) +++ branches/nextgen/COLLADAMax/scripts/COLLADAMax.vcproj 2009-02-12 14:18:55 UTC (rev 355) @@ -2075,6 +2075,10 @@ Name="importer" > <File + RelativePath="..\src\COLLADAMaxCameraImporter.cpp" + > + </File> + <File RelativePath="..\src\COLLADAMaxColladaImporter.cpp" > </File> @@ -2257,6 +2261,10 @@ Name="importer" > <File + RelativePath="..\include\COLLADAMaxCameraImporter.h" + > + </File> + <File RelativePath="..\include\COLLADAMaxColladaImporter.h" > </File> Modified: branches/nextgen/COLLADAMax/src/COLLADAMaxCameraExporter.cpp =================================================================== --- branches/nextgen/COLLADAMax/src/COLLADAMaxCameraExporter.cpp 2009-02-11 15:30:41 UTC (rev 354) +++ branches/nextgen/COLLADAMax/src/COLLADAMaxCameraExporter.cpp 2009-02-12 14:18:55 UTC (rev 355) @@ -134,7 +134,6 @@ if ( camera ) { - if ( mDocumentExporter->isExportedObject(ObjectIdentifier(camera)) ) return; Added: branches/nextgen/COLLADAMax/src/COLLADAMaxCameraImporter.cpp =================================================================== --- branches/nextgen/COLLADAMax/src/COLLADAMaxCameraImporter.cpp (rev 0) +++ branches/nextgen/COLLADAMax/src/COLLADAMaxCameraImporter.cpp 2009-02-12 14:18:55 UTC (rev 355) @@ -0,0 +1,125 @@ +/* +Copyright (c) 2008 NetAllied Systems GmbH + +This file is part of COLLADAMax. + +Portions of the code are: +Copyright (c) 2005-2007 Feeling Software Inc. +Copyright (c) 2005-2007 Sony Computer Entertainment America + +Based on the 3dsMax COLLADASW Tools: +Copyright (c) 2005-2006 Autodesk Media Entertainment + +Licensed under the MIT Open Source License, +for details please see LICENSE file or the website +http://www.opensource.org/licenses/mit-license.php +*/ + +#include "COLLADAMaxStableHeaders.h" +#include "COLLADAMaxCameraImporter.h" + +#include "COLLADAFWCamera.h" + +#include <max.h> + +namespace COLLADAMax +{ + + //------------------------------ + CameraImporter::CameraImporter( DocumentImporter* documentImporter, const COLLADAFW::Camera* camera ) + : ImporterBase(documentImporter) + , mCamera(camera) + { + } + + //------------------------------ + CameraImporter::~CameraImporter() + { + } + + //------------------------------ + bool CameraImporter::import() + { + GenCamera* maxCamera = createCamera(mCamera); + + handleObjectReferences(mCamera, maxCamera); + + return true; + } + + //------------------------------ + GenCamera* CameraImporter::createCamera( const COLLADAFW::Camera* camera ) + { + // TODO TARGETED_CAMERA + GenCamera* maxCamera = getMaxImportInterface()->CreateCameraObject( FREE_CAMERA ); + + float targetDistance = 100; // we don't have a target, therefore we need to set anything + maxCamera->SetTDist(0, targetDistance); + + if (camera->getCameraType() == COLLADAFW::Camera::PERSPECTIVE) + { + // Perspective camera + maxCamera->SetOrtho(FALSE); + switch ( camera->getDescriptionType() ) + { + case COLLADAFW::Camera::SINGLE_X: + case COLLADAFW::Camera::X_AND_Y: + case COLLADAFW::Camera::ASPECTRATIO_AND_X: + maxCamera->SetFOVType(0); + maxCamera->SetFOV(0, COLLADABU::Math::Utils::degToRadF( (float)camera->getXFov())); + break; + case COLLADAFW::Camera::SINGLE_Y: + case COLLADAFW::Camera::ASPECTRATIO_AND_Y: + { + float aspectRatio = getMaxInterface()->GetRendImageAspect(); + maxCamera->SetFOVType(1); + float yfov = COLLADABU::Math::Utils::degToRadF( (float)camera->getYFov()); + float xfov = 2 * atan( aspectRatio * tan(yfov/2)); + maxCamera->SetFOV(0, xfov); + break; + } + } + } + else + { + // Orthographic camera + maxCamera->SetOrtho(TRUE); + + // Consider only the correct magnification and the target distance, + // which is kept constant, to calculate the FOV. + switch ( camera->getDescriptionType() ) + { + case COLLADAFW::Camera::SINGLE_X: + case COLLADAFW::Camera::X_AND_Y: + case COLLADAFW::Camera::ASPECTRATIO_AND_X: + { + maxCamera->SetFOVType(0); + float fov = 2 * (float)atan( camera->getXMag()/targetDistance ); + maxCamera->SetFOV(0, fov); + break; + } + case COLLADAFW::Camera::SINGLE_Y: + case COLLADAFW::Camera::ASPECTRATIO_AND_Y: + { + float aspectRatio = getMaxInterface()->GetRendImageAspect(); + maxCamera->SetFOVType(1); + float yfov = 2 * (float)atan( camera->getYMag()/targetDistance ); + float xfov = 2 * atan( aspectRatio * tan(yfov/2)); + maxCamera->SetFOV(0, xfov ); + break; + } + } + } + + // Common camera parameters: nearZ, farZ + // The "Far Clip " animatable parameter intentionally has an extra space in the definition. + maxCamera->SetClipDist(0, CAM_HITHER_CLIP, (float)camera->getNearClippingPlane()); + maxCamera->SetClipDist(0, CAM_YON_CLIP, (float)camera->getFarClippingPlane()); + maxCamera->SetManualClip(TRUE); + maxCamera->Enable(TRUE); + + return maxCamera; + } + + +} // namespace COLLADAMax Modified: branches/nextgen/COLLADAMax/src/COLLADAMaxColladaPlugin.cpp =================================================================== --- branches/nextgen/COLLADAMax/src/COLLADAMaxColladaPlugin.cpp 2009-02-11 15:30:41 UTC (rev 354) +++ branches/nextgen/COLLADAMax/src/COLLADAMaxColladaPlugin.cpp 2009-02-12 14:18:55 UTC (rev 355) @@ -1,6 +1,8 @@ #include "COLLADAMaxStableHeaders.h" #include "COLLADAMaxCOLLADAPlugin.h" +#include "COLLADAMaxVersionInfo.h" + namespace COLLADAMax { @@ -12,7 +14,11 @@ const String COLLADAPlugin::OTHERMESSAGE1 = ""; const String COLLADAPlugin::OTHERMESSAGE2 = ""; + const String COLLADAPlugin::REVISION_STRING = (CURRENT_REVISION.empty() ? "" : String("Revision: ") + CURRENT_REVISION); + const String COLLADAPlugin::PLATFORM_STRING = String("Platform: ") + CURRENT_PLATFORM; + const String COLLADAPlugin::CONFIGURATION_STRING = String("Configuration: ") + CURRENT_CONFIGURATION; + const String COLLADAPlugin::FATALERROR = "Fatal Error: exception caught."; const unsigned int COLLADAPlugin::PLUGINVERSION = 400; Modified: branches/nextgen/COLLADAMax/src/COLLADAMaxDllEntry.cpp =================================================================== --- branches/nextgen/COLLADAMax/src/COLLADAMaxDllEntry.cpp 2009-02-11 15:30:41 UTC (rev 354) +++ branches/nextgen/COLLADAMax/src/COLLADAMaxDllEntry.cpp 2009-02-12 14:18:55 UTC (rev 355) @@ -22,10 +22,15 @@ #include "COLLADAMaxColladaExporter.h" #include "COLLADAMaxColladaImporter.h" +#include "COLLADAMaxColladaPlugin.h" + +#include "COLLADAMaxVersionInfo.h" + HINSTANCE hInstance; int controlsInit = FALSE; -static const COLLADAMax::String LIBDESCRIPTION = "COLLADAMax NextGen"; +static const COLLADAMax::String LIBDESCRIPTION = "COLLADAMax NextGen" + + (COLLADAMax::COLLADAPlugin::REVISION_STRING.empty() ? "" : (COLLADAMax::String(" ") + COLLADAMax::COLLADAPlugin::REVISION_STRING)); BOOL WINAPI DllMain ( HINSTANCE hinstDLL, ULONG fdwReason, LPVOID UNUSED ( lpvReserved ) ) { Modified: branches/nextgen/COLLADAMax/src/COLLADAMaxDocumentExporter.cpp =================================================================== --- branches/nextgen/COLLADAMax/src/COLLADAMaxDocumentExporter.cpp 2009-02-11 15:30:41 UTC (rev 354) +++ branches/nextgen/COLLADAMax/src/COLLADAMaxDocumentExporter.cpp 2009-02-12 14:18:55 UTC (rev 355) @@ -28,8 +28,9 @@ #include "COLLADAMaxImageExporter.h" #include "COLLADAMaxCameraExporter.h" #include "COLLADAMaxLightExporter.h" -#include "COLLADAMaxVersionInfo.h" +#include "COLLADAMaxColladaPlugin.h" + #include "COLLADASWAsset.h" #include "COLLADASWScene.h" #include "COLLADASWConstants.h" @@ -41,10 +42,10 @@ const String DocumentExporter::SCENE_ID = "MaxScene"; - const String DocumentExporter::AUTHORING_TOOL = String("COLLADAMax Next Gen") + - (CURRENT_REVISION.empty() ? "" : String("; Revision: ") + CURRENT_REVISION) + - String("; Platform: ") + CURRENT_PLATFORM + - String("; Configuration: ") + CURRENT_CONFIGURATION; + const String DocumentExporter::AUTHORING_TOOL = String("COLLADAMax NextGen") + + (COLLADAPlugin::REVISION_STRING.empty() ? "" : String("; ") + COLLADAPlugin::REVISION_STRING) + + String("; ") + COLLADAPlugin::PLATFORM_STRING + + String("; ") + COLLADAPlugin::CONFIGURATION_STRING; //--------------------------------------------------------------- Modified: branches/nextgen/COLLADAMax/src/COLLADAMaxDocumentImporter.cpp =================================================================== --- branches/nextgen/COLLADAMax/src/COLLADAMaxDocumentImporter.cpp 2009-02-11 15:30:41 UTC (rev 354) +++ branches/nextgen/COLLADAMax/src/COLLADAMaxDocumentImporter.cpp 2009-02-12 14:18:55 UTC (rev 355) @@ -23,6 +23,7 @@ #include "COLLADAMaxMaterialImporter.h" #include "COLLADAMaxMaterialCreator.h" #include "COLLADAMaxEffectImporter.h" +#include "COLLADAMaxCameraImporter.h" #include "COLLADAMaxFWLErrorHandler.h" #include "COLLADAFWLibraryNodes.h" @@ -111,7 +112,8 @@ //--------------------------------------------------------------- bool DocumentImporter::writeCamera( const COLLADAFW::Camera* camera ) { - return true; + CameraImporter cameraImporter(this, camera); + return cameraImporter.import(); } } // namespace COLLADAMax Modified: branches/nextgen/COLLADAMax/src/COLLADAMaxGeometryImporter.cpp =================================================================== --- branches/nextgen/COLLADAMax/src/COLLADAMaxGeometryImporter.cpp 2009-02-11 15:30:41 UTC (rev 354) +++ branches/nextgen/COLLADAMax/src/COLLADAMaxGeometryImporter.cpp 2009-02-12 14:18:55 UTC (rev 355) @@ -95,7 +95,7 @@ triangleMesh.InvalidateGeomCache(); triangleMesh.InvalidateTopologyCache(); - handleReferences(mesh, triangleObject); + handleObjectReferences(mesh, triangleObject); return true; } @@ -390,7 +390,7 @@ //polygonMesh.InvalidateGeomCache(); - handleReferences(mesh, polygonObject); + handleObjectReferences(mesh, polygonObject); return true; } @@ -707,21 +707,7 @@ return true; } - //------------------------------ - bool GeometryImporter::handleReferences( COLLADAFW::Geometry* geometry, Object* object ) - { - const COLLADAFW::UniqueId& uniqueID = geometry->getUniqueId(); - addUniqueIdObjectPair(uniqueID, object); - - INodeList objectNodeList; - getObjectINodesByUniqueId(uniqueID, objectNodeList); - for ( size_t i = 0, count = objectNodeList.size(); i<count; ++i) - objectNodeList[i]->SetObjectRef(object); - - return true; - } - //------------------------------ void GeometryImporter::createFWMaterialIdMaxMtlIdMap( const COLLADAFW::MeshPrimitiveArray& primitiveArray, DocumentImporter::FWMaterialIdMaxMtlIdMap& materialMap ) { Modified: branches/nextgen/COLLADAMax/src/COLLADAMaxImporterBase.cpp =================================================================== --- branches/nextgen/COLLADAMax/src/COLLADAMaxImporterBase.cpp 2009-02-11 15:30:41 UTC (rev 354) +++ branches/nextgen/COLLADAMax/src/COLLADAMaxImporterBase.cpp 2009-02-12 14:18:55 UTC (rev 355) @@ -24,6 +24,8 @@ namespace COLLADAMax { + const String ImporterBase::EMPTY_STRING = ""; + ImporterBase::ImporterBase( DocumentImporter* documentImporter) : mDocumentImporter(documentImporter) { @@ -52,6 +54,7 @@ return mDocumentImporter->getDummyObject(); } + //------------------------------ void ImporterBase::addUniqueIdObjectINodePair( const COLLADAFW::UniqueId& uniqueId, INode* node ) { @@ -168,6 +171,13 @@ } //------------------------------ + void ImporterBase::addObjectObjectNamePair( Object* object, const String& name ) + { + DocumentImporter::ObjectObjectNameMap& objectObjectNameMap = mDocumentImporter->getObjectObjectNameMap(); + objectObjectNameMap.insert(std::pair<Object*, String>(object, name)); + } + + //------------------------------ Object* ImporterBase::getObjectByUniqueId( const COLLADAFW::UniqueId& uniqueId ) { const DocumentImporter::UniqueIdObjectMap& uniqueIdObjectMap = mDocumentImporter->getUniqueIdObjectMap(); @@ -246,8 +256,21 @@ return mDocumentImporter->getGeometryMaterialIdMapMap()[uniqueId]; } + //------------------------------ const DocumentImporter::INodeINodePairList& ImporterBase::getClonedINodeOriginalINodePairList() { return mDocumentImporter->getClonedINodeOriginalINodePairList(); } + + //------------------------------ + const String& ImporterBase::getObjectNameByObject( Object* object ) const + { + const DocumentImporter::ObjectObjectNameMap& objectObjectNameMap = mDocumentImporter->getObjectObjectNameMap(); + DocumentImporter::ObjectObjectNameMap::const_iterator it = objectObjectNameMap.find(object); + if ( it == objectObjectNameMap.end() ) + return EMPTY_STRING; + else + return it->second; + } + } // namespace COLLADAMax Modified: branches/nextgen/COLLADAMax/src/COLLADAMaxNodeImporter.cpp =================================================================== --- branches/nextgen/COLLADAMax/src/COLLADAMaxNodeImporter.cpp 2009-02-11 15:30:41 UTC (rev 354) +++ branches/nextgen/COLLADAMax/src/COLLADAMaxNodeImporter.cpp 2009-02-12 14:18:55 UTC (rev 355) @@ -59,7 +59,7 @@ //------------------------------ void NodeImporter::setNodeProperties( const COLLADAFW::Node* node, ImpNode* importNode) { - String newNodeName = node->getName(); + const String& newNodeName = node->getName(); if ( !newNodeName.empty() ) importNode->SetName(newNodeName.c_str()); @@ -69,17 +69,17 @@ Matrix3 maxTransformationMatrix; Matrix4ToMaxMatrix3(maxTransformationMatrix, transformationMatrix); importNode->SetTransform(0, maxTransformationMatrix); - } //------------------------------ ImpNode* NodeImporter::importNode( const COLLADAFW::Node* node, ImpNode* parentImportNode ) { - bool singleGeometryInstance = node->getInstanceGeometries().getCount() == 1; + bool singleInstance = (node->getInstanceGeometries().getCount() + + node->getInstanceCameras().getCount() ) == 1; ImpNode* newImportNode = 0; const COLLADAFW::UniqueId& nodeUniqueId = node->getUniqueId(); - if ( !singleGeometryInstance ) + if ( !singleInstance ) { newImportNode = getMaxImportInterface()->CreateNode(); @@ -89,11 +89,16 @@ RefResult res = newImportNode->Reference(getDummyObject()); importInstanceGeometries(node->getInstanceGeometries(), newImportNode); + importInstanceCameras(node->getInstanceCameras(), newImportNode); importNodes(node->getChildNodes(), newImportNode); } else { newImportNode = importInstanceGeometry( node, parentImportNode ); + if ( !newImportNode ) + newImportNode = importInstanceCamera( node, parentImportNode ); + + assert(newImportNode); importNodes(node->getChildNodes(), newImportNode); } @@ -131,15 +136,17 @@ } //------------------------------ - bool NodeImporter::importInstanceGeometries( const COLLADAFW::InstanceGeometryPointerArray& instanceGeometryArray, ImpNode* parentImportNode ) + template<class Instance, + void (NodeImporter::*postProcess)( INode*, Instance* )> + bool NodeImporter::importInstances( const COLLADAFW::PointerArray<Instance>& instanceArray, ImpNode* parentImportNode ) { - for ( size_t i = 0, count = instanceGeometryArray.getCount(); i < count; ++i) + for ( size_t i = 0, count = instanceArray.getCount(); i < count; ++i) { - COLLADAFW::InstanceGeometry* instanceGeometry = instanceGeometryArray[i]; + Instance* instance = instanceArray[i]; ImpNode* newImportNode = getMaxImportInterface()->CreateNode(); INode* newNode = newImportNode->GetINode(); - const COLLADAFW::UniqueId& uniqueId = instanceGeometry->getInstanciatedObjectId(); + const COLLADAFW::UniqueId& uniqueId = instance->getInstanciatedObjectId(); Object* object = getObjectByUniqueId(uniqueId); if ( object ) @@ -150,37 +157,63 @@ { newImportNode->Reference( getDummyObject() ); } - const COLLADAFW::UniqueId& instanceGeometryUniqueId = instanceGeometry->getInstanciatedObjectId(); + const COLLADAFW::UniqueId& instanceUniqueId = instance->getInstanciatedObjectId(); // Store mapping between unique ids and nodes referencing the corresponding object. // Used to clone nodes - addObjectINodeUniqueIdPair(newNode, instanceGeometryUniqueId); + addObjectINodeUniqueIdPair(newNode, instanceUniqueId); // Used to resolve instancing of objects - addUniqueIdObjectINodePair(instanceGeometryUniqueId, newNode); + addUniqueIdObjectINodePair(instanceUniqueId, newNode); INode* parentNode = parentImportNode->GetINode(); parentNode->AttachChild(newNode, FALSE); - // Store the information about material bindings - storeMaterialBindings(newNode, instanceGeometry); + // post process the creation + if ( postProcess ) + (this->*postProcess)(newNode, instance); } return true; } + //------------------------------ - ImpNode* NodeImporter::importInstanceGeometry( const COLLADAFW::Node* node, ImpNode* parentImportNode ) + bool NodeImporter::importInstanceGeometries( const COLLADAFW::InstanceGeometryPointerArray& instanceGeometryArray, ImpNode* parentImportNode ) { + return importInstances<COLLADAFW::InstanceGeometry, &NodeImporter::storeMaterialBindings>(instanceGeometryArray, parentImportNode); + } + + + //------------------------------ + bool NodeImporter::importInstanceCameras( const COLLADAFW::InstanceCameraPointerArray& instanceCameraArray, ImpNode* parentImportNode ) + { + return importInstances<COLLADAFW::InstanceCamera, 0>(instanceCameraArray, parentImportNode); + } + + //------------------------------ + template<class Instance, + const COLLADAFW::PointerArray<Instance>& (COLLADAFW::Node::*getInstances)()const, + void (NodeImporter::*postProcess)( INode*, Instance* )> + ImpNode* NodeImporter::importInstance( const COLLADAFW::Node* node, ImpNode* parentImportNode ) + { + const COLLADAFW::PointerArray<Instance>& instances = (node->*getInstances)(); + if ( instances.getCount() != 1 ) + return 0; + ImpNode* newImportNode = getMaxImportInterface()->CreateNode(); setNodeProperties(node, newImportNode); INode* newNode = newImportNode->GetINode(); - COLLADAFW::InstanceGeometry* instanceGeometry = node->getInstanceGeometries()[0]; + Instance* instanceGeometry = instances[0]; const COLLADAFW::UniqueId& uniqueId = instanceGeometry->getInstanciatedObjectId(); Object* object = getObjectByUniqueId(uniqueId); if ( object ) { newImportNode->Reference(object); + const String& objectName = getObjectNameByObject(object); + + if ( node->getName().empty() && !objectName.empty() ) + newImportNode->SetName( objectName.c_str() ); } else { @@ -196,14 +229,27 @@ INode* parentNode = parentImportNode->GetINode(); parentNode->AttachChild(newNode, FALSE); - // Store the information about material bindings - storeMaterialBindings(newNode, instanceGeometry); + // post process the creation + if ( postProcess ) + (this->*postProcess)(newNode, instanceGeometry); return newImportNode; } + //------------------------------ + ImpNode* NodeImporter::importInstanceGeometry( const COLLADAFW::Node* node, ImpNode* parentImportNode ) + { + return importInstance<COLLADAFW::InstanceGeometry, &COLLADAFW::Node::getInstanceGeometries, &NodeImporter::storeMaterialBindings>(node, parentImportNode); + } + //------------------------------ + ImpNode* NodeImporter::importInstanceCamera( const COLLADAFW::Node* node, ImpNode* parentImportNode ) + { + return importInstance<COLLADAFW::InstanceCamera, &COLLADAFW::Node::getInstanceCameras, 0>(node, parentImportNode); + } + + //------------------------------ bool NodeImporter::importInstanceNodes( const COLLADAFW::InstanceNodePointerArray& instanceNodeArray, ImpNode* parentImportNode ) { for ( size_t i = 0, count = instanceNodeArray.getCount(); i < count; ++i) Modified: branches/nextgen/COLLADAMaya/src/COLLADAMayaVisualSceneImporter.cpp =================================================================== --- branches/nextgen/COLLADAMaya/src/COLLADAMayaVisualSceneImporter.cpp 2009-02-11 15:30:41 UTC (rev 354) +++ branches/nextgen/COLLADAMaya/src/COLLADAMayaVisualSceneImporter.cpp 2009-02-12 14:18:55 UTC (rev 355) @@ -365,9 +365,9 @@ /** The position of the object. */ COLLADABU::Math::Vector3& eyePosition = lookat->getEyePosition (); /** The position of the interest point. */ - COLLADABU::Math::Vector3& interestPosition = lookat->getInterestPosition (); + COLLADABU::Math::Vector3& interestPosition = lookat->getInterestPointPosition(); /** The direction that points up. */ - COLLADABU::Math::Vector3& upPosition = lookat->getUpPosition (); + COLLADABU::Math::Vector3& upPosition = lookat->getUpAxisDirection(); // TODO Do anything with this values! Modified: branches/nextgen/COLLADASaxFrameworkLoader/src/COLLADASaxFWLLibraryCamerasLoader.cpp =================================================================== --- branches/nextgen/COLLADASaxFrameworkLoader/src/COLLADASaxFWLLibraryCamerasLoader.cpp 2009-02-11 15:30:41 UTC (rev 354) +++ branches/nextgen/COLLADASaxFrameworkLoader/src/COLLADASaxFWLLibraryCamerasLoader.cpp 2009-02-12 14:18:55 UTC (rev 355) @@ -113,7 +113,7 @@ //------------------------------ bool LibraryCamerasLoader::data__xfov( double value ) { - mCurrentCamera->setXFovOrXMag( value ); + mCurrentCamera->setXFov( value ); mCurrentCameraHasX = true; return true; } @@ -121,8 +121,8 @@ //------------------------------ bool LibraryCamerasLoader::data__yfov( double value ) { - mCurrentCamera->setYFovOrYMag( value ); - mCurrentCameraHasX = true; + mCurrentCamera->setYFov( value ); + mCurrentCameraHasY = true; return true; } @@ -130,7 +130,7 @@ //------------------------------ bool LibraryCamerasLoader::data__xmag( double value ) { - mCurrentCamera->setXFovOrXMag( value ); + mCurrentCamera->setXMag( value ); mCurrentCameraHasX = true; return true; } @@ -138,8 +138,8 @@ //------------------------------ bool LibraryCamerasLoader::data__ymag( double value ) { - mCurrentCamera->setYFovOrYMag( value ); - mCurrentCameraHasX = true; + mCurrentCamera->setYMag( value ); + mCurrentCameraHasY = true; return true; } Modified: branches/nextgen/COLLADASaxFrameworkLoader/src/COLLADASaxFWLMeshLoader.cpp =================================================================== --- branches/nextgen/COLLADASaxFrameworkLoader/src/COLLADASaxFWLMeshLoader.cpp 2009-02-11 15:30:41 UTC (rev 354) +++ branches/nextgen/COLLADASaxFrameworkLoader/src/COLLADASaxFWLMeshLoader.cpp 2009-02-12 14:18:55 UTC (rev 355) @@ -50,7 +50,10 @@ , mTexCoordList (0) , mColorList (0) { - mMesh->setName ( geometryName ); + if ( !geometryName.empty() ) + mMesh->setName ( geometryName ); + else if ( !geometryId.empty() ) + mMesh->setName ( geometryId ); } Modified: branches/nextgen/COLLADASaxFrameworkLoader/src/COLLADASaxFWLNodeLoader.cpp =================================================================== --- branches/nextgen/COLLADASaxFrameworkLoader/src/COLLADASaxFWLNodeLoader.cpp 2009-02-11 15:30:41 UTC (rev 354) +++ branches/nextgen/COLLADASaxFrameworkLoader/src/COLLADASaxFWLNodeLoader.cpp 2009-02-12 14:18:55 UTC (rev 355) @@ -299,8 +299,8 @@ assert(lookat); COLLADABU::Math::Vector3& eyePosition = lookat->getEyePosition (); - COLLADABU::Math::Vector3& interestPosition = lookat->getInterestPosition (); - COLLADABU::Math::Vector3& upPosition = lookat->getUpPosition (); + COLLADABU::Math::Vector3& interestPointPosition = lookat->getInterestPointPosition (); + COLLADABU::Math::Vector3& upAxisDirection = lookat->getUpAxisDirection (); size_t i = 0; if ( i < length && mTransformationNumbersReceived < 3 ) @@ -315,7 +315,7 @@ { for ( size_t j=0; j<3 && i<length; ++j, ++i ) { - interestPosition[j] = data[i]; + interestPointPosition[j] = data[i]; mTransformationNumbersReceived++; } } @@ -323,7 +323,7 @@ { for ( size_t j=0; j<3 && i<length; ++j, ++i ) { - upPosition[j] = data[i]; + upAxisDirection[j] = data[i]; mTransformationNumbersReceived++; } } @@ -403,7 +403,7 @@ COLLADAFW::UniqueId instantiatedCameraUniqueId = getUniqueIdFromUrl( attributeData.url, COLLADAFW::Camera::ID() ); COLLADAFW::InstanceCamera* instanceCamera = FW_NEW COLLADAFW::InstanceCamera(instantiatedCameraUniqueId); - currentNode->getInstanceNodes().append(instanceCamera); + currentNode->getInstanceCameras().append(instanceCamera); return true; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |