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

Method createLight

dae2ma/src/DAE2MALightImporter.cpp:141–210  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

139
140 // --------------------------------------------
141 void LightImporter::createLight (
142 const COLLADAFW::Light* light,
143 MayaNode* mayaTransformNode )
144 {
145 // Check if the camera is already imported.
146 const COLLADAFW::UniqueId& lightId = light->getUniqueId ();
147
148 // Make the maya name unique and manage it in all necessary lists.
149 String lightName = light->getName ();
150 if ( lightName.empty () ) lightName = LIGHT_NAME;
151 lightName = DocumentImporter::frameworkNameToMayaName ( lightName );
152 const ExtraDataCallbackHandler& callbackHandler = getDocumentImporter ()->getMayaIdCallbackHandler ();
153 String originalMayaId = getOriginalMayaId ( callbackHandler, lightId, COLLADASaxFWL15::HASH_ELEMENT_LIGHT );
154 if ( !originalMayaId.empty () ) lightName = originalMayaId;
155 lightName = generateUniqueDagNodeName ( lightName, mayaTransformNode );
156
157 // Create a maya node object of the current node and push it into the map.
158 MayaNode* mayaLightNode = new MayaNode ( lightId, lightName, mayaTransformNode );
159 mMayaLightNodesMap [ lightId ] = mayaLightNode;
160
161 FILE* file = getDocumentImporter ()->getFile ();
162
163 MayaDM::Light* mayaLight = 0;
164 COLLADAFW::Light::LightType lightType = light->getLightType ();
165 switch ( lightType )
166 {
167 case COLLADAFW::Light::AMBIENT_LIGHT:
168 {
169 mayaLight = new MayaDM::AmbientLight ( file, lightName, mayaTransformNode->getNodePath () );
170 }
171 break;
172 case COLLADAFW::Light::DIRECTIONAL_LIGHT:
173 {
174 mayaLight = new MayaDM::DirectionalLight ( file, lightName, mayaTransformNode->getNodePath () );
175 }
176 break;
177 case COLLADAFW::Light::POINT_LIGHT:
178 {
179 mayaLight = new MayaDM::PointLight ( file, lightName, mayaTransformNode->getNodePath () );
180 setPointLightAttributes ( light, mayaLight );
181 }
182 break;
183 case COLLADAFW::Light::SPOT_LIGHT:
184 {
185 mayaLight = new MayaDM::SpotLight ( file, lightName, mayaTransformNode->getNodePath () );
186 setSpotLightAttributes ( light, mayaLight );
187 }
188 break;
189 default:
190 std::cerr << "Unknown light type!" << std::endl;
191 return;
192 }
193
194 // Add the original id attribute.
195 String colladaId = light->getOriginalId ();
196 if ( !colladaId.empty () )
197 {
198 MayaDM::addAttr ( file, COLLADA_ID_ATTRIBUTE_NAME, ATTRIBUTE_DATA_TYPE, ATTRIBUTE_TYPE_STRING );

Callers

nothing calls this directly

Calls 14

addAttrFunction · 0.85
setAttrFunction · 0.85
float3Class · 0.85
getUniqueIdMethod · 0.80
getLightTypeMethod · 0.80
getNodePathMethod · 0.80
getNameMethod · 0.45
emptyMethod · 0.45
getFileMethod · 0.45
getColorMethod · 0.45
setColorMethod · 0.45
getRedMethod · 0.45

Tested by

no test coverage detected