MCPcopy Create free account
hub / github.com/KhronosGroup/OpenCOLLADA / createCamera

Method createCamera

dae2ma/src/DAE2MACameraImporter.cpp:101–169  ·  view source on GitHub ↗

------------------------------

Source from the content-addressed store, hash-verified

99
100 //------------------------------
101 void CameraImporter::createCamera (
102 const COLLADAFW::Camera* camera,
103 MayaNode* mayaTransformNode )
104 {
105 // Get the unique id.
106 const COLLADAFW::UniqueId& cameraId = camera->getUniqueId ();
107
108 // Make the maya name unique and manage it in all necessary lists.
109 String cameraName = camera->getName ();
110 if ( cameraName.empty () ) cameraName = CAMERA_NAME;
111 cameraName = DocumentImporter::frameworkNameToMayaName ( cameraName );
112 const ExtraDataCallbackHandler& callbackHandler = getDocumentImporter ()->getMayaIdCallbackHandler ();
113 String originalMayaId = getOriginalMayaId ( callbackHandler, cameraId, COLLADASaxFWL15::HASH_ELEMENT_CAMERA );
114 if ( !originalMayaId.empty () ) cameraName = originalMayaId;
115 cameraName = generateUniqueDagNodeName ( cameraName, mayaTransformNode );
116
117 // Create a maya node object of the current node and push it into the map.
118 MayaNode* mayaCameraNode = new MayaNode ( cameraId, cameraName, mayaTransformNode );
119 mMayaCameraNodesMap [ cameraId ] = mayaCameraNode;
120
121 // Check if we want to write a shared default camera.
122 bool isSharedCamera = false;
123 if ( COLLADABU::Utils::equals ( camera->getName (), CAMERA_PERSP_SHAPE )
124 || COLLADABU::Utils::equals ( camera->getName (), CAMERA_TOP_SHAPE )
125 || COLLADABU::Utils::equals ( camera->getName (), CAMERA_FRONT_SHAPE )
126 || COLLADABU::Utils::equals ( camera->getName (), CAMERA_SIDE_SHAPE ) )
127 {
128 isSharedCamera = true;
129 }
130
131 // Create the maya camera object and write it into the maya ascii file.
132 FILE* file = getDocumentImporter ()->getFile ();
133 MayaDM::Camera mayaCamera ( file, cameraName, mayaTransformNode->getNodePath (), isSharedCamera );
134
135 // Add the original id attribute.
136 String colladaId = camera->getOriginalId ();
137 if ( !colladaId.empty () )
138 {
139 MayaDM::addAttr ( file, COLLADA_ID_ATTRIBUTE_NAME, ATTRIBUTE_DATA_TYPE, ATTRIBUTE_TYPE_STRING );
140 MayaDM::setAttr ( file, COLLADA_ID_ATTRIBUTE_NAME, ATTRIBUTE_TYPE, ATTRIBUTE_TYPE_STRING, colladaId );
141 }
142// // TODO Add the attributes for all the extra tags.
143// setExtraData ( camera->getExtraDataArray () );
144
145 // Have a look, if there is a center of interest set by the transform's lookat matrix.
146 VisualSceneImporter* visualSceneImporter = getDocumentImporter ()->getVisualSceneImporter ();
147 double centerOfInterestDistance;
148 bool found = visualSceneImporter->findCenterOfInterestDistance ( mayaTransformNode->getUniqueId (), centerOfInterestDistance );
149 if ( found )
150 {
151 mayaCamera.setCenterOfInterest ( centerOfInterestDistance );
152 }
153
154 // Write the data in depend on the camera type.
155 const COLLADAFW::Camera::CameraType& cameraType = camera->getCameraType ();
156 switch ( cameraType )
157 {
158 case COLLADAFW::Camera::ORTHOGRAPHIC:

Callers

nothing calls this directly

Calls 11

addAttrFunction · 0.85
setAttrFunction · 0.85
getUniqueIdMethod · 0.80
getNodePathMethod · 0.80
getCameraTypeMethod · 0.80
getNameMethod · 0.45
emptyMethod · 0.45
getFileMethod · 0.45
setCenterOfInterestMethod · 0.45

Tested by

no test coverage detected