From: <rob...@us...> - 2009-02-11 15:30:49
|
Revision: 354 http://colladamaya.svn.sourceforge.net/colladamaya/?rev=354&view=rev Author: robertwuerfel Date: 2009-02-11 15:30:41 +0000 (Wed, 11 Feb 2009) Log Message: ----------- complete import of camera into frame work (untested) Modified Paths: -------------- branches/nextgen/COLLADAFramework/include/COLLADAFWNode.h branches/nextgen/COLLADAFramework/scripts/COLLADAFramework.vcproj branches/nextgen/COLLADAMax/include/COLLADAMaxNodeImporter.h branches/nextgen/COLLADAMax/src/COLLADAMaxNodeImporter.cpp branches/nextgen/COLLADASaxFrameworkLoader/include/COLLADASaxFWLLibraryCamerasLoader.h branches/nextgen/COLLADASaxFrameworkLoader/include/COLLADASaxFWLNodeLoader.h branches/nextgen/COLLADASaxFrameworkLoader/src/COLLADASaxFWLLibraryCamerasLoader.cpp branches/nextgen/COLLADASaxFrameworkLoader/src/COLLADASaxFWLNodeLoader.cpp Added Paths: ----------- branches/nextgen/COLLADAFramework/include/COLLADAFWInstanceCamera.h Added: branches/nextgen/COLLADAFramework/include/COLLADAFWInstanceCamera.h =================================================================== --- branches/nextgen/COLLADAFramework/include/COLLADAFWInstanceCamera.h (rev 0) +++ branches/nextgen/COLLADAFramework/include/COLLADAFWInstanceCamera.h 2009-02-11 15:30:41 UTC (rev 354) @@ -0,0 +1,30 @@ +/* + Copyright (c) 2008 NetAllied Systems GmbH + + This file is part of COLLADAFramework. + + 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 __COLLADAFW_INSTANCECAMERA_H__ +#define __COLLADAFW_INSTANCECAMERA_H__ + +#include "COLLADAFWPrerequisites.h" +#include "COLLADAFWSceneGraphInstance.h" +#include "COLLADAFWPointerArray.h" + + +namespace COLLADAFW +{ + + /** Instantiates a node within a scene graph.*/ + typedef SceneGraphInstance InstanceCamera; + + typedef ArrayPrimitiveType<InstanceNode*> InstanceCameraArray; + typedef PointerArray<InstanceNode> InstanceCameraPointerArray; + +} // namespace COLLADAFW + +#endif // __COLLADAFW_INSTANCECAMERA_H__ Modified: branches/nextgen/COLLADAFramework/include/COLLADAFWNode.h =================================================================== --- branches/nextgen/COLLADAFramework/include/COLLADAFWNode.h 2009-02-11 13:19:06 UTC (rev 353) +++ branches/nextgen/COLLADAFramework/include/COLLADAFWNode.h 2009-02-11 15:30:41 UTC (rev 354) @@ -16,6 +16,7 @@ #include "COLLADAFWTransformation.h" #include "COLLADAFWInstanceGeometry.h" #include "COLLADAFWInstanceNode.h" +#include "COLLADAFWInstanceCamera.h" #include "COLLADAFWArrayPrimitiveType.h" #include "COLLADAFWPointerArray.h" @@ -70,6 +71,9 @@ /** List of all instance nodes of this node. Array and contents will be delete in destructor.*/ InstanceNodePointerArray mInstanceNodes; + /** List of all instance cameras of this node. Array and contents will be delete in destructor.*/ + InstanceCameraPointerArray mInstanceCameras; + /** List of all child nodes. Array and contents will be delete in destructor.*/ NodePointerArray mChildNodes; @@ -111,6 +115,12 @@ /** List of all instance nodes of this node.*/ const InstanceNodePointerArray& getInstanceNodes() const { return mInstanceNodes; } + /** List of all instance cameras of this camera.*/ + InstanceCameraPointerArray& getInstanceCameras() { return mInstanceCameras; } + + /** List of all instance cameras of this camera.*/ + const InstanceCameraPointerArray& getInstanceCameras() const { return mInstanceCameras; } + /** Get list of all child nodes.*/ NodePointerArray& getChildNodes() { return mChildNodes; } Modified: branches/nextgen/COLLADAFramework/scripts/COLLADAFramework.vcproj =================================================================== --- branches/nextgen/COLLADAFramework/scripts/COLLADAFramework.vcproj 2009-02-11 13:19:06 UTC (rev 353) +++ branches/nextgen/COLLADAFramework/scripts/COLLADAFramework.vcproj 2009-02-11 15:30:41 UTC (rev 354) @@ -510,6 +510,10 @@ > </File> <File + RelativePath="..\include\COLLADAFWInstanceCamera.h" + > + </File> + <File RelativePath="..\include\COLLADAFWInstanceEffect.h" > </File> Modified: branches/nextgen/COLLADAMax/include/COLLADAMaxNodeImporter.h =================================================================== --- branches/nextgen/COLLADAMax/include/COLLADAMaxNodeImporter.h 2009-02-11 13:19:06 UTC (rev 353) +++ branches/nextgen/COLLADAMax/include/COLLADAMaxNodeImporter.h 2009-02-11 15:30:41 UTC (rev 354) @@ -63,7 +63,7 @@ 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* importInstanceGeometrie( const COLLADAFW::Node* node, ImpNode* parentImportNode ); + ImpNode* importInstanceGeometry( 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/src/COLLADAMaxNodeImporter.cpp =================================================================== --- branches/nextgen/COLLADAMax/src/COLLADAMaxNodeImporter.cpp 2009-02-11 13:19:06 UTC (rev 353) +++ branches/nextgen/COLLADAMax/src/COLLADAMaxNodeImporter.cpp 2009-02-11 15:30:41 UTC (rev 354) @@ -93,7 +93,7 @@ } else { - newImportNode = importInstanceGeometrie( node, parentImportNode ); + newImportNode = importInstanceGeometry( node, parentImportNode ); importNodes(node->getChildNodes(), newImportNode); } @@ -168,7 +168,7 @@ } //------------------------------ - ImpNode* NodeImporter::importInstanceGeometrie( const COLLADAFW::Node* node, ImpNode* parentImportNode ) + ImpNode* NodeImporter::importInstanceGeometry( const COLLADAFW::Node* node, ImpNode* parentImportNode ) { ImpNode* newImportNode = getMaxImportInterface()->CreateNode(); setNodeProperties(node, newImportNode); Modified: branches/nextgen/COLLADASaxFrameworkLoader/include/COLLADASaxFWLLibraryCamerasLoader.h =================================================================== --- branches/nextgen/COLLADASaxFrameworkLoader/include/COLLADASaxFWLLibraryCamerasLoader.h 2009-02-11 13:19:06 UTC (rev 353) +++ branches/nextgen/COLLADASaxFrameworkLoader/include/COLLADASaxFWLLibraryCamerasLoader.h 2009-02-11 15:30:41 UTC (rev 354) @@ -73,18 +73,22 @@ /** We don't need to do anything here.*/ virtual bool end__optics__technique_common(){return true;} - /** Create an orthographic camera. Not yet implemented.*/ - virtual bool begin__orthographic(){return true;} - virtual bool end__orthographic(){return true;} - /** Create an orthographic camera.*/ + /** Set camera type to perspective.*/ virtual bool begin__perspective(); /** We don't need to do anything here.*/ virtual bool end__perspective(){return true;} + /** Set camera type to orthographic.*/ + virtual bool begin__orthographic(); + /** We don't need to do anything here.*/ + virtual bool end__orthographic(){return true;} + + + /** We don't need to do anything here.*/ virtual bool begin__xfov( const xfov__AttributeData& attributeData ){return true;} /** We don't need to do anything here.*/ @@ -105,6 +109,26 @@ /** We don't need to do anything here.*/ + virtual bool begin__xmag( const xmag__AttributeData& attributeData ){return true;} + + /** We don't need to do anything here.*/ + virtual bool end__xmag(){return true;} + + /** Stores the xmag of the current camera.*/ + virtual bool data__xmag( double value ); + + + /** We don't need to do anything here.*/ + virtual bool begin__ymag( const ymag__AttributeData& attributeData ){return true;} + + /** We don't need to do anything here.*/ + virtual bool end__ymag(){return true;} + + /** Stores the ymag of the current camera.*/ + virtual bool data__ymag( double value ); + + + /** We don't need to do anything here.*/ virtual bool begin__perspective__aspect_ratio( const aspect_ratio__AttributeData& attributeData ){return true;} /** We don't need to do anything here.*/ @@ -135,6 +159,36 @@ /** We don't need to do anything here.*/ + virtual bool begin__orthographic__aspect_ratio( const aspect_ratio__AttributeData& attributeData ){return true;} + + /** We don't need to do anything here.*/ + virtual bool end__orthographic__aspect_ratio(){return true;} + + /** Stores the aspect ratio of the current camera.*/ + virtual bool data__orthographic__aspect_ratio( double value ); + + + /** We don't need to do anything here.*/ + virtual bool begin__orthographic__znear( const znear__AttributeData& attributeData ){return true;} + + /** We don't need to do anything here.*/ + virtual bool end__orthographic__znear(){return true;} + + /** Stores the near clipping plane of the current camera.*/ + virtual bool data__orthographic__znear( double value ); + + + /** We don't need to do anything here.*/ + virtual bool begin__orthographic__zfar( const zfar__AttributeData& attributeData ){return true;} + + /** We don't need to do anything here.*/ + virtual bool end__orthographic__zfar(){return true;} + + /** Stores the far clipping plane of the current camera.*/ + virtual bool data__orthographic__zfar( double value ); + + + /** We don't need to do anything here.*/ virtual bool begin__imager(){return true;} /** We don't need to do anything here.*/ Modified: branches/nextgen/COLLADASaxFrameworkLoader/include/COLLADASaxFWLNodeLoader.h =================================================================== --- branches/nextgen/COLLADASaxFrameworkLoader/include/COLLADASaxFWLNodeLoader.h 2009-02-11 13:19:06 UTC (rev 353) +++ branches/nextgen/COLLADASaxFrameworkLoader/include/COLLADASaxFWLNodeLoader.h 2009-02-11 15:30:41 UTC (rev 354) @@ -176,10 +176,16 @@ /** Sax callback function for the beginning of an instance node element.*/ virtual bool begin__instance_node( const instance_node__AttributeData& attributeData ); - /** Sax callback function for the ending of an instance node element.*/ - virtual bool end__instance_node(); + /** We don't need to do anything here.*/ + virtual bool end__instance_node(){return true;} + /** Appends the instance camera to the current node.*/ + virtual bool begin__instance_camera( const instance_camera__AttributeData& attributeData ); + + /** We don't need to do anything here.*/ + virtual bool end__instance_camera(){return true;} + }; } // namespace COLLADASAXFWL Modified: branches/nextgen/COLLADASaxFrameworkLoader/src/COLLADASaxFWLLibraryCamerasLoader.cpp =================================================================== --- branches/nextgen/COLLADASaxFrameworkLoader/src/COLLADASaxFWLLibraryCamerasLoader.cpp 2009-02-11 13:19:06 UTC (rev 353) +++ branches/nextgen/COLLADASaxFrameworkLoader/src/COLLADASaxFWLLibraryCamerasLoader.cpp 2009-02-11 15:30:41 UTC (rev 354) @@ -64,6 +64,32 @@ //------------------------------ bool LibraryCamerasLoader::end__camera() { + // we need to determine the description type + // X = 1, Y = 2, aspect ratio = 4 + int descriptionType = (mCurrentCameraHasX ? 1 : 0) + + (mCurrentCameraHasY ? 2 : 0) + + (mCurrentCameraHasAspectRatio ? 4 : 0); + switch ( descriptionType ) + { + case 1: + mCurrentCamera->setDescriptionType(COLLADAFW::Camera::SINGLE_X); + break; + case 2: + mCurrentCamera->setDescriptionType(COLLADAFW::Camera::SINGLE_Y); + break; + case 3: + mCurrentCamera->setDescriptionType(COLLADAFW::Camera::X_AND_Y); + break; + case 5: + mCurrentCamera->setDescriptionType(COLLADAFW::Camera::ASPECTRATIO_AND_X); + break; + case 6: + mCurrentCamera->setDescriptionType(COLLADAFW::Camera::ASPECTRATIO_AND_Y); + break; + default: + mCurrentCamera->setDescriptionType(COLLADAFW::Camera::UNDEFINED); + } + bool success = writer()->writeCamera(mCurrentCamera); FW_DELETE mCurrentCamera; resetCurrentValues(); @@ -78,9 +104,17 @@ } //------------------------------ + bool LibraryCamerasLoader::begin__orthographic() + { + mCurrentCamera->setCameraType(COLLADAFW::Camera::ORTHOGRAPHIC); + return true; + } + + //------------------------------ bool LibraryCamerasLoader::data__xfov( double value ) { mCurrentCamera->setXFovOrXMag( value ); + mCurrentCameraHasX = true; return true; } @@ -88,27 +122,71 @@ bool LibraryCamerasLoader::data__yfov( double value ) { mCurrentCamera->setYFovOrYMag( value ); + mCurrentCameraHasX = true; return true; } + //------------------------------ + bool LibraryCamerasLoader::data__xmag( double value ) + { + mCurrentCamera->setXFovOrXMag( value ); + mCurrentCameraHasX = true; + return true; + } + + //------------------------------ + bool LibraryCamerasLoader::data__ymag( double value ) + { + mCurrentCamera->setYFovOrYMag( value ); + mCurrentCameraHasX = true; + return true; + } + + //------------------------------ bool LibraryCamerasLoader::data__perspective__aspect_ratio( double value ) { mCurrentCamera->setAspectRatio(value); + mCurrentCameraHasAspectRatio = true; return true; } + //------------------------------ bool LibraryCamerasLoader::data__perspective__znear( double value ) { mCurrentCamera->setNearClippingPlane(value); return true; } + //------------------------------ bool LibraryCamerasLoader::data__perspective__zfar( double value ) { mCurrentCamera->setFarClippingPlane(value); return true; } + //------------------------------ + bool LibraryCamerasLoader::data__orthographic__aspect_ratio( double value ) + { + mCurrentCamera->setAspectRatio(value); + mCurrentCameraHasAspectRatio = true; + return true; + } + //------------------------------ + bool LibraryCamerasLoader::data__orthographic__znear( double value ) + { + mCurrentCamera->setNearClippingPlane(value); + return true; + } + + //------------------------------ + bool LibraryCamerasLoader::data__orthographic__zfar( double value ) + { + mCurrentCamera->setFarClippingPlane(value); + return true; + } + + + } // namespace COLLADASaxFWL Modified: branches/nextgen/COLLADASaxFrameworkLoader/src/COLLADASaxFWLNodeLoader.cpp =================================================================== --- branches/nextgen/COLLADASaxFrameworkLoader/src/COLLADASaxFWLNodeLoader.cpp 2009-02-11 13:19:06 UTC (rev 353) +++ branches/nextgen/COLLADASaxFrameworkLoader/src/COLLADASaxFWLNodeLoader.cpp 2009-02-11 15:30:41 UTC (rev 354) @@ -21,6 +21,7 @@ #include "COLLADAFWMatrix.h" #include "COLLADAFWGeometry.h" #include "COLLADAFWMaterial.h" +#include "COLLADAFWCamera.h" namespace COLLADASaxFWL @@ -388,17 +389,23 @@ COLLADAFW::Node* currentNode = mNodeStack.top(); COLLADAFW::UniqueId instantiatedNodeUniqueId = getUniqueIdFromUrl( attributeData.url, COLLADAFW::Node::ID() ); - COLLADAFW::InstanceNode* instanceNode = new COLLADAFW::InstanceNode(instantiatedNodeUniqueId); + COLLADAFW::InstanceNode* instanceNode = FW_NEW COLLADAFW::InstanceNode(instantiatedNodeUniqueId); currentNode->getInstanceNodes().append(instanceNode); return true; } + //------------------------------ - bool NodeLoader::end__instance_node() + bool NodeLoader::begin__instance_camera( const instance_camera__AttributeData& attributeData ) { + COLLADAFW::Node* currentNode = mNodeStack.top(); + COLLADAFW::UniqueId instantiatedCameraUniqueId = getUniqueIdFromUrl( attributeData.url, COLLADAFW::Camera::ID() ); + + COLLADAFW::InstanceCamera* instanceCamera = FW_NEW COLLADAFW::InstanceCamera(instantiatedCameraUniqueId); + currentNode->getInstanceNodes().append(instanceCamera); + return true; } - } // namespace COLLADASaxFWL This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |