File: daeWSceneObjects.cpp

package info (click to toggle)
openscenegraph-3.4 3.4.1+dfsg1-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 36,912 kB
  • sloc: cpp: 392,492; ansic: 23,625; java: 1,020; yacc: 548; makefile: 449; objc: 288; xml: 155; lex: 151
file content (544 lines) | stat: -rw-r--r-- 20,607 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
/*
 * Copyright 2006 Sony Computer Entertainment Inc.
 *
 * Licensed under the SCEA Shared Source License, Version 1.0 (the "License"); you may not use this
 * file except in compliance with the License. You may obtain a copy of the License at:
 * http://research.scea.com/scea_shared_source_license.html
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License
 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 * implied. See the License for the specific language governing permissions and limitations under the
 * License.
 */

#include "daeWriter.h"

#include <dom/domCOLLADA.h>

#include <dom/domNode.h>
#include <dom/domConstants.h>
#include <dom/domLibrary_cameras.h>
#include <dom/domLibrary_lights.h>
#include <dae/domAny.h>
//#include <dom/domVisual_scene.h>
//#include <dom/domLibrary_visual_scenes.h>

#include <osgSim/MultiSwitch>
#include <osg/Sequence>
#include <osg/Billboard>
#include <osg/CameraView>

#ifdef COLLADA_DOM_2_4_OR_LATER
#include <dom/domAny.h>
using namespace ColladaDOM141;
#endif

using namespace osgDAE;

// Write non-standard node data as extra of type "Node" with "OpenSceneGraph" technique
void daeWriter::writeNodeExtra(osg::Node &node)
{
    unsigned int numDesc = node.getDescriptions().size();
    // Only create extra if descriptions are filled in
    if (_pluginOptions.writeExtras && (numDesc > 0))
    {
        // Adds the following to a node

        //<extra type="Node">
        //    <technique profile="OpenSceneGraph">
        //        <Descriptions>
        //            <Description>Some info</Description>
        //        </Descriptions>
        //    </technique>
        //</extra>

        domExtra *extra = daeSafeCast<domExtra>(currentNode->add( COLLADA_ELEMENT_EXTRA ));
        extra->setType("Node");
        domTechnique *teq = daeSafeCast<domTechnique>(extra->add( COLLADA_ELEMENT_TECHNIQUE ) );
        teq->setProfile( "OpenSceneGraph" );
        domAny *descriptions = (domAny*)teq->add( "Descriptions" );

        for (unsigned int currDesc = 0; currDesc < numDesc; currDesc++)
        {
            std::string value = node.getDescription(currDesc);
            if (!value.empty())
            {
                domAny *description = (domAny*)descriptions->add( "Description" );
                description->setValue(value.c_str());
            }
        }
    }
}

void daeWriter::apply( osg::Group &node )
{
    debugPrint( node );
    updateCurrentDaeNode();
    currentNode = daeSafeCast< domNode >(currentNode->add( COLLADA_ELEMENT_NODE ) );

    // If a multiswitch node, store it's data as extra "MultiSwitch" data in the "OpenSceneGraph" technique
    osgSim::MultiSwitch* multiswitch = dynamic_cast<osgSim::MultiSwitch*>(&node);
    if (_pluginOptions.writeExtras && multiswitch)
    {
        // Adds the following to a node

        //<extra type="MultiSwitch">
        //    <technique profile="OpenSceneGraph">
        //        <ActiveSwitchSet>0</ActiveSwitchSet>
        //        <ValueLists>
        //            <ValueList>1 0</ValueList>
        //            <ValueList>0 1</ValueList>
        //        </ValueLists>
        //    </technique>
        //</extra>

        domExtra *extra = daeSafeCast<domExtra>(currentNode->add( COLLADA_ELEMENT_EXTRA ));
        extra->setType("MultiSwitch");
        domTechnique *teq = daeSafeCast<domTechnique>(extra->add( COLLADA_ELEMENT_TECHNIQUE ) );
        teq->setProfile( "OpenSceneGraph" );

        domAny *activeSwitchSet = (domAny*)teq->add("ActiveSwitchSet" );
        activeSwitchSet->setValue(toString<unsigned int>(multiswitch->getActiveSwitchSet()).c_str());

        domAny *valueLists = (domAny*)teq->add( "ValueLists" );

        unsigned int pos = 0;
        const osgSim::MultiSwitch::SwitchSetList& switchset = multiswitch->getSwitchSetList();
        for(osgSim::MultiSwitch::SwitchSetList::const_iterator sitr=switchset.begin();
            sitr!=switchset.end();
            ++sitr,++pos)
        {
            domAny *valueList = (domAny*)valueLists->add( "ValueList" );
            std::stringstream fw;
            const osgSim::MultiSwitch::ValueList& values = *sitr;
            for(osgSim::MultiSwitch::ValueList::const_iterator itr=values.begin();
                itr!=values.end();
                ++itr)
            {
                if (itr != values.begin())
                {
                    fw << " ";
                }
                fw << *itr;
            }
            valueList->setValue(fw.str().c_str());
        }
        currentNode->setId(getNodeName(node,"multiswitch").c_str());
    }
    else
    {
        writeAnimations(node);

        currentNode->setId(getNodeName(node,"group").c_str());
    }

    writeNodeExtra(node);

    lastDepth = _nodePath.size();

    traverse( node );
}


void daeWriter::apply( osg::Switch &node )
{
    debugPrint( node );
    updateCurrentDaeNode();
    currentNode = daeSafeCast< domNode >(currentNode->add( COLLADA_ELEMENT_NODE ) );
    currentNode->setId(getNodeName(node,"switch").c_str());

    if (_pluginOptions.writeExtras)
    {
        // Adds the following to a node

        //<extra type="Switch">
        //    <technique profile="OpenSceneGraph">
        //        <ValueList>1 0</ValueList>
        //    </technique>
        //</extra>

        domExtra *extra = daeSafeCast<domExtra>(currentNode->add( COLLADA_ELEMENT_EXTRA ));
        extra->setType("Switch");
        domTechnique *teq = daeSafeCast<domTechnique>(extra->add( COLLADA_ELEMENT_TECHNIQUE ) );
        teq->setProfile( "OpenSceneGraph" );

        domAny *valueList = (domAny*)teq->add( "ValueList" );

        std::stringstream fw;
        const osg::Switch::ValueList& values = node.getValueList();
        for(osg::Switch::ValueList::const_iterator itr=values.begin();
            itr!=values.end();
            ++itr)
        {
            if (itr != values.begin())
            {
                fw << " ";
            }
            fw << *itr;
        }
        valueList->setValue(fw.str().c_str());
    }

    writeNodeExtra(node);

    lastDepth = _nodePath.size();

    // Process all children
    traverse( node );
}

void daeWriter::apply( osg::Sequence &node )
{
    debugPrint( node );
    updateCurrentDaeNode();
    currentNode = daeSafeCast< domNode >(currentNode->add( COLLADA_ELEMENT_NODE ) );
    currentNode->setId(getNodeName(node,"sequence").c_str());

    // If a sequence node, store it's data as extra "Sequence" data in the "OpenSceneGraph" technique
    if (_pluginOptions.writeExtras)
    {
        // Adds the following to a node

        //<extra type="Sequence">
        //    <technique profile="OpenSceneGraph">
        //        <FrameTime>0 0</FrameTime>
        //        <LastFrameTime>0</LastFrameTime>
        //        <LoopMode>0</LoopMode>
        //        <IntervalBegin>0</IntervalBegin>
        //        <IntervalEnd>-1</IntervalEnd>
        //        <DurationSpeed>1</DurationSpeed>
        //        <DurationNReps>-1</DurationNReps>
        //        <SequenceMode>0</SequenceMode>
        //    </technique>
        //</extra>

        domExtra *extra = daeSafeCast<domExtra>(currentNode->add( COLLADA_ELEMENT_EXTRA ));
        extra->setType("Sequence");
        domTechnique *teq = daeSafeCast<domTechnique>(extra->add( COLLADA_ELEMENT_TECHNIQUE ) );
        teq->setProfile( "OpenSceneGraph" );

        domAny *frameTime = (domAny*)teq->add("FrameTime");
        std::stringstream fw;
        for (unsigned int i = 0; i < node.getNumChildren(); i++)
        {
            if (i > 0)
            {
                fw << " ";
            }
            fw << node.getTime(i);
        }
        frameTime->setValue(fw.str().c_str());

        domAny *lastFrameTime = (domAny*)teq->add("LastFrameTime");
        lastFrameTime->setValue(toString<double>(node.getLastFrameTime()).c_str());

        // loop mode & interval
        osg::Sequence::LoopMode mode;
        int begin, end;
        node.getInterval(mode, begin, end);
        domAny *loopMode = (domAny*)teq->add("LoopMode");
        loopMode->setValue(toString<osg::Sequence::LoopMode>(mode).c_str());
        domAny *intervalBegin = (domAny*)teq->add("IntervalBegin");
        intervalBegin->setValue(toString<int>(begin).c_str());
        domAny *intervalEnd = (domAny*)teq->add("IntervalEnd");
        intervalEnd->setValue(toString<int>(end).c_str());

        // duration
        float speed;
        int nreps;
        node.getDuration(speed, nreps);
        domAny *durationSpeed = (domAny*)teq->add("DurationSpeed");
        durationSpeed->setValue(toString<float>(speed).c_str());
        domAny *durationNReps = (domAny*)teq->add("DurationNReps");
        durationNReps->setValue(toString<int>(nreps).c_str());

        // sequence mode
        domAny *sequenceMode = (domAny*)teq->add("SequenceMode");
        sequenceMode->setValue(toString<osg::Sequence::SequenceMode>(node.getMode()).c_str());
    }

    writeNodeExtra(node);

    lastDepth = _nodePath.size();

    traverse( node );
}

void daeWriter::apply( osg::LOD &node )
{
    debugPrint( node );
    updateCurrentDaeNode();
    lastDepth = _nodePath.size();
    currentNode = daeSafeCast< domNode >(currentNode->add( COLLADA_ELEMENT_NODE ) );
    currentNode->setId(getNodeName(node,"LOD").c_str());

    if (_pluginOptions.writeExtras)
    {
        // Store LOD data as extra "LOD" data in the "OpenSceneGraph" technique
        // Adds the following to a node

        //<extra type="LOD">
        //    <technique profile="OpenSceneGraph">
        //        <Center>1 2 3</Center> (optional )
        //        <Radius>-1</Radius> (required if Center is available)
        //        <RangeMode>0</RangeMode>
        //        <RangeList>
        //            <MinMax>0 300</MinMax>
        //            <MinMax>300 600</MinMax>
        //        </RangeList>
        //    </technique>
        //</extra>

        domExtra *extra = daeSafeCast<domExtra>(currentNode->add( COLLADA_ELEMENT_EXTRA ));
        extra->setType("LOD");
        domTechnique *teq = daeSafeCast<domTechnique>(extra->add( COLLADA_ELEMENT_TECHNIQUE ) );
        teq->setProfile( "OpenSceneGraph" );

        if ((node.getCenterMode()==osg::LOD::USER_DEFINED_CENTER)||(node.getCenterMode()==osg::LOD::UNION_OF_BOUNDING_SPHERE_AND_USER_DEFINED))
        {
            domAny *center = (domAny*)teq->add("Center");
            center->setValue(toString(node.getCenter()).c_str());

            domAny *radius = (domAny*)teq->add("Radius");
            radius->setValue(toString<osg::LOD::value_type>(node.getRadius()).c_str());
        }

        domAny *rangeMode = (domAny*)teq->add("RangeMode");
        rangeMode->setValue(toString<osg::LOD::RangeMode>(node.getRangeMode()).c_str());

        domAny *valueLists = (domAny*)teq->add("RangeList");

        unsigned int pos = 0;
        const osg::LOD::RangeList& rangelist = node.getRangeList();
        for(osg::LOD::RangeList::const_iterator sitr=rangelist.begin();
            sitr!=rangelist.end();
            ++sitr,++pos)
        {
            domAny *valueList = (domAny*)valueLists->add("MinMax");
            std::stringstream fw;
            fw << sitr->first << " " << sitr->second;
            valueList->setValue(fw.str().c_str());
        }
    }

    writeNodeExtra(node);

    // Process all children
    traverse( node );
}

void daeWriter::apply( osg::ProxyNode &node )
{
    OSG_WARN << "ProxyNode. Missing " << node.getNumChildren() << " children" << std::endl;
}

void daeWriter::apply( osg::LightSource &node )
{
    debugPrint( node );
    updateCurrentDaeNode();

    domInstance_light *il = daeSafeCast< domInstance_light >( currentNode->add( COLLADA_ELEMENT_INSTANCE_LIGHT ) );
    std::string name = node.getName();
    if ( name.empty() )
    {
        name = uniquify( "light" );
    }
    std::string url = "#" + name;
    il->setUrl( url.c_str() );

    if ( lib_lights == NULL )
    {
        lib_lights = daeSafeCast< domLibrary_lights >( dom->add( COLLADA_ELEMENT_LIBRARY_LIGHTS ) );
    }
    domLight *light = daeSafeCast< domLight >( lib_lights->add( COLLADA_ELEMENT_LIGHT ) );
    light->setId( name.c_str() );

    osg::Light* pOsgLight = node.getLight();

    domLight *pDomLight = daeSafeCast< domLight >( lib_lights->add( COLLADA_ELEMENT_LIGHT ) );
    pDomLight->setId( name.c_str() );

    domLight::domTechnique_common *domTechniqueCommon = daeSafeCast<domLight::domTechnique_common>(pDomLight->add(COLLADA_ELEMENT_TECHNIQUE_COMMON));

    osg::Vec4 position = pOsgLight->getPosition();
    osg::Vec3 direction = pOsgLight->getDirection();
    osg::Vec4 ambientColor = pOsgLight->getAmbient();
    osg::Vec4 diffuseColor = pOsgLight->getDiffuse();
    //osg::Vec4 specularColor = pOsgLight->getSpecular();

    if (position.w() == 0)
    {
        // Directional light
        domLight::domTechnique_common::domDirectional *domDirectional = daeSafeCast<domLight::domTechnique_common::domDirectional>(domTechniqueCommon->add(COLLADA_ELEMENT_DIRECTIONAL));

        if ((position.x() != 0) || (position.y() != 0) || (position.z() != 0))
        {
            osg::Vec3 dir(-position.x(), -position.y(), -position.z());
            // TODO wrap instance_light in a rotating node to translate default light [0,0,-1] into proper direction
        }

        domFloat3 color;
        color.append3(diffuseColor.r(), diffuseColor.g(), diffuseColor.b());
        domDirectional->add(COLLADA_ELEMENT_COLOR);
        domDirectional->getColor()->setValue(color);
    }
    else if (direction.length() == 0)
    {
        // Omni/point light
        domLight::domTechnique_common::domPoint *domPoint = daeSafeCast<domLight::domTechnique_common::domPoint>(domTechniqueCommon->add(COLLADA_ELEMENT_POINT));
        domPoint->add(COLLADA_ELEMENT_CONSTANT_ATTENUATION);
        domPoint->getConstant_attenuation()->setValue(pOsgLight->getConstantAttenuation());
        domPoint->add(COLLADA_ELEMENT_LINEAR_ATTENUATION);
        domPoint->getLinear_attenuation()->setValue(pOsgLight->getLinearAttenuation());
        domPoint->add(COLLADA_ELEMENT_QUADRATIC_ATTENUATION);
        domPoint->getQuadratic_attenuation()->setValue(pOsgLight->getQuadraticAttenuation());

        if ((position.x() != 0) || (position.y() != 0) || (position.z() != 0))
        {
            // TODO wrap instance_light in a transforming node to translate default light [0,0,0] into proper position
        }

        domFloat3 color;
        color.append3(diffuseColor.r(), diffuseColor.g(), diffuseColor.b());
        domPoint->add(COLLADA_ELEMENT_COLOR);
        domPoint->getColor()->setValue(color);
    }
    else
    {
        // Spot light
        domLight::domTechnique_common::domSpot *domSpot = daeSafeCast<domLight::domTechnique_common::domSpot>(domTechniqueCommon->add(COLLADA_ELEMENT_SPOT));
        domSpot->add(COLLADA_ELEMENT_CONSTANT_ATTENUATION);
        domSpot->getConstant_attenuation()->setValue(pOsgLight->getConstantAttenuation());
        domSpot->add(COLLADA_ELEMENT_LINEAR_ATTENUATION);
        domSpot->getLinear_attenuation()->setValue(pOsgLight->getLinearAttenuation());
        domSpot->add(COLLADA_ELEMENT_QUADRATIC_ATTENUATION);
        domSpot->getQuadratic_attenuation()->setValue(pOsgLight->getQuadraticAttenuation());

        if ((position.x() != 0) || (position.y() != 0) || (position.z() != 0))
        {
            // TODO wrap instance_light in a transforming node to translate default light [0,0,0] into proper position
            // and rotate default direction [0,0,-1] into proper dir
        }

        domFloat3 color;
        color.append3(diffuseColor.r(), diffuseColor.g(), diffuseColor.b());
        domSpot->add(COLLADA_ELEMENT_COLOR);
        domSpot->getColor()->setValue(color);

        domSpot->add(COLLADA_ELEMENT_FALLOFF_ANGLE);
        domSpot->getFalloff_angle()->setValue(pOsgLight->getSpotCutoff());

        domSpot->add(COLLADA_ELEMENT_FALLOFF_EXPONENT);
        domSpot->getFalloff_exponent()->setValue(pOsgLight->getSpotExponent());
    }

    // Write ambient as a separate Collada <ambient> light
    if ((ambientColor.r() != 0) || (ambientColor.g() != 0) || (ambientColor.b() != 0))
    {
        domInstance_light *ambientDomInstanceLight = daeSafeCast< domInstance_light >(currentNode->add( COLLADA_ELEMENT_INSTANCE_LIGHT ));
        name = node.getName();
        if (name.empty())
        {
            name = uniquify( "light-ambient" );
        }
        else
        {
            name += "-ambient";
        }
        url = "#" + name;
        ambientDomInstanceLight->setUrl( url.c_str() );

        domLight *ambientDomLight = daeSafeCast< domLight >( lib_lights->add( COLLADA_ELEMENT_LIGHT ) );
        ambientDomLight->setId(name.c_str());

        domLight::domTechnique_common *ambientDomTechniqueCommon = daeSafeCast<domLight::domTechnique_common>(ambientDomLight->add(COLLADA_ELEMENT_TECHNIQUE_COMMON));

        // Ambient light
        domLight::domTechnique_common::domAmbient *domAmbient = daeSafeCast<domLight::domTechnique_common::domAmbient>(ambientDomTechniqueCommon->add(COLLADA_ELEMENT_AMBIENT));

        domFloat3 color;
        color.append3(ambientColor.r(), ambientColor.g(), ambientColor.b());
        domAmbient->add(COLLADA_ELEMENT_COLOR);
        domAmbient->getColor()->setValue(color);
    }

    traverse( node );
}

void daeWriter::apply( osg::Camera &node )
{
    debugPrint( node );
    updateCurrentDaeNode();

    domInstance_camera *ic = daeSafeCast< domInstance_camera >( currentNode->add( COLLADA_ELEMENT_INSTANCE_CAMERA ) );
    std::string name = node.getName();
    if ( name.empty() )
    {
        name = uniquify( "camera" );
    }
    std::string url = "#" + name;
    ic->setUrl( url.c_str() );

    if ( lib_cameras == NULL )
    {
        lib_cameras = daeSafeCast< domLibrary_cameras >( dom->add( COLLADA_ELEMENT_LIBRARY_CAMERAS ) );
    }
    domCamera *cam = daeSafeCast< domCamera >( lib_cameras->add( COLLADA_ELEMENT_CAMERA ) );
    cam->setId( name.c_str() );

    traverse( node );
}

void daeWriter::apply( osg::CameraView &node)
{
    debugPrint( node );
    updateCurrentDaeNode();

    domInstance_camera *ic = daeSafeCast< domInstance_camera >( currentNode->add(COLLADA_ELEMENT_INSTANCE_CAMERA));
    std::string name = node.getName();
    if ( name.empty() )
    {
        name = uniquify( "camera" );
    }
    std::string url = "#" + name;
    ic->setUrl( url.c_str() );

    if ( lib_cameras == NULL )
    {
        lib_cameras = daeSafeCast< domLibrary_cameras >( dom->add( COLLADA_ELEMENT_LIBRARY_CAMERAS ) );
    }
    domCamera *cam = daeSafeCast< domCamera >( lib_cameras->add( COLLADA_ELEMENT_CAMERA ) );
    cam->setId( name.c_str() );

    domCamera::domOptics *optics = daeSafeCast< domCamera::domOptics >( cam->add( COLLADA_ELEMENT_OPTICS ) );
    domCamera::domOptics::domTechnique_common *techniqueCommon = daeSafeCast< domCamera::domOptics::domTechnique_common >( optics->add( COLLADA_ELEMENT_TECHNIQUE_COMMON ) );
    domCamera::domOptics::domTechnique_common::domPerspective *pDomPerspective = daeSafeCast< domCamera::domOptics::domTechnique_common::domPerspective >( techniqueCommon->add( COLLADA_ELEMENT_PERSPECTIVE ) );

    domTargetableFloat *pXfov = NULL;
    domTargetableFloat *pYfov = NULL;
    switch(node.getFieldOfViewMode())
    {
        case(osg::CameraView::UNCONSTRAINED):
            pXfov = daeSafeCast< domTargetableFloat >( pDomPerspective->add( COLLADA_ELEMENT_XFOV ) );
            pXfov->setValue(node.getFieldOfView());
            break;
        case(osg::CameraView::HORIZONTAL):
            pXfov = daeSafeCast< domTargetableFloat >( pDomPerspective->add( COLLADA_ELEMENT_XFOV ) );
            pXfov->setValue(node.getFieldOfView());
            break;
        case(osg::CameraView::VERTICAL):
            pYfov = daeSafeCast< domTargetableFloat >( pDomPerspective->add( COLLADA_ELEMENT_YFOV ) );
            pYfov->setValue(node.getFieldOfView());
            break;
    }

    // Using hardcoded values for <aspect_ratio>, <znear> and <zfar>
    domTargetableFloat *pAspectRatio = daeSafeCast< domTargetableFloat >( pDomPerspective->add( COLLADA_ELEMENT_ASPECT_RATIO ) );
    pAspectRatio->setValue(1.0);

    domTargetableFloat *pNear = daeSafeCast< domTargetableFloat >( pDomPerspective->add( COLLADA_ELEMENT_ZNEAR ) );
    pNear->setValue(1);

    domTargetableFloat *pFar = daeSafeCast< domTargetableFloat >( pDomPerspective->add( COLLADA_ELEMENT_ZFAR ) );
    pFar->setValue(1000);
}