@@ -206,6 +206,8 @@ void DotSceneLoader::processScene(pugi::xml_node& XMLRoot)
206
206
207
207
void DotSceneLoader::processNodes (pugi::xml_node& XMLNode)
208
208
{
209
+ LogManager::getSingleton ().logMessage (" [DotSceneLoader] Processing Nodes..." , LML_TRIVIAL);
210
+
209
211
// Process node (*)
210
212
for (auto pElement : XMLNode.children (" node" ))
211
213
{
@@ -241,6 +243,8 @@ void DotSceneLoader::processExternals(pugi::xml_node& XMLNode)
241
243
242
244
void DotSceneLoader::processEnvironment (pugi::xml_node& XMLNode)
243
245
{
246
+ LogManager::getSingleton ().logMessage (" [DotSceneLoader] Processing Environment..." , LML_TRIVIAL);
247
+
244
248
// Process camera (?)
245
249
if (auto pElement = XMLNode.child (" camera" ))
246
250
processCamera (pElement);
@@ -273,6 +277,8 @@ void DotSceneLoader::processEnvironment(pugi::xml_node& XMLNode)
273
277
void DotSceneLoader::processTerrainGroup (pugi::xml_node& XMLNode)
274
278
{
275
279
#ifdef OGRE_BUILD_COMPONENT_TERRAIN
280
+ LogManager::getSingleton ().logMessage (" [DotSceneLoader] Processing Terrain Group..." , LML_TRIVIAL);
281
+
276
282
Real worldSize = getAttribReal (XMLNode, " worldSize" );
277
283
int mapSize = StringConverter::parseInt (XMLNode.attribute (" size" ).value ());
278
284
int compositeMapDistance = StringConverter::parseInt (XMLNode.attribute (" tuningCompositeMapDistance" ).value ());
@@ -311,6 +317,8 @@ void DotSceneLoader::processLight(pugi::xml_node& XMLNode, SceneNode* pParent)
311
317
// Process attributes
312
318
String name = getAttrib (XMLNode, " name" );
313
319
320
+ LogManager::getSingleton ().logMessage (" [DotSceneLoader] Processing Light: " + name, LML_TRIVIAL);
321
+
314
322
// Create the light
315
323
Light* pLight = mSceneMgr ->createLight (name);
316
324
if (pParent)
@@ -357,6 +365,9 @@ void DotSceneLoader::processCamera(pugi::xml_node& XMLNode, SceneNode* pParent)
357
365
{
358
366
// Process attributes
359
367
String name = getAttrib (XMLNode, " name" );
368
+
369
+ LogManager::getSingleton ().logMessage (" [DotSceneLoader] Processing Camera: " + name, LML_TRIVIAL);
370
+
360
371
// Real fov = getAttribReal(XMLNode, "fov", 45);
361
372
Real aspectRatio = getAttribReal (XMLNode, " aspectRatio" , 1.3333 );
362
373
String projectionType = getAttrib (XMLNode, " projectionType" , " perspective" );
@@ -403,6 +414,8 @@ void DotSceneLoader::processNode(pugi::xml_node& XMLNode, SceneNode* pParent)
403
414
// Construct the node's name
404
415
String name = getAttrib (XMLNode, " name" );
405
416
417
+ LogManager::getSingleton ().logMessage (" [DotSceneLoader] Processing Node: " + name, LML_TRIVIAL);
418
+
406
419
// Create the scene node
407
420
SceneNode* pNode;
408
421
if (name.empty ())
@@ -498,6 +511,10 @@ void DotSceneLoader::processNode(pugi::xml_node& XMLNode, SceneNode* pParent)
498
511
// Process userDataReference (?)
499
512
if (auto pElement = XMLNode.child (" userData" ))
500
513
processUserData (pElement, pNode->getUserObjectBindings ());
514
+
515
+ // Process node animations (?)
516
+ if (auto pElement = XMLNode.child (" animations" ))
517
+ processNodeAnimations (pElement, pNode);
501
518
}
502
519
503
520
void DotSceneLoader::processLookTarget (pugi::xml_node& XMLNode, SceneNode* pParent)
@@ -507,6 +524,8 @@ void DotSceneLoader::processLookTarget(pugi::xml_node& XMLNode, SceneNode* pPare
507
524
// Process attributes
508
525
String nodeName = getAttrib (XMLNode, " nodeName" );
509
526
527
+ LogManager::getSingleton ().logMessage (" [DotSceneLoader] Processing Look Target, nodeName: " + nodeName, LML_TRIVIAL);
528
+
510
529
Node::TransformSpace relativeTo = Node::TS_PARENT;
511
530
String sValue = getAttrib (XMLNode, " relativeTo" );
512
531
if (sValue == " local" )
@@ -548,6 +567,8 @@ void DotSceneLoader::processTrackTarget(pugi::xml_node& XMLNode, SceneNode* pPar
548
567
// Process attributes
549
568
String nodeName = getAttrib (XMLNode, " nodeName" );
550
569
570
+ LogManager::getSingleton ().logMessage (" [DotSceneLoader] Processing Track Target, nodeName: " + nodeName, LML_TRIVIAL);
571
+
551
572
// Process localDirection (?)
552
573
Vector3 localDirection = Vector3::NEGATIVE_UNIT_Z;
553
574
if (auto pElement = XMLNode.child (" localDirection" ))
@@ -574,6 +595,9 @@ void DotSceneLoader::processEntity(pugi::xml_node& XMLNode, SceneNode* pParent)
574
595
{
575
596
// Process attributes
576
597
String name = getAttrib (XMLNode, " name" );
598
+
599
+ LogManager::getSingleton ().logMessage (" [DotSceneLoader] Processing Entity: " + name, LML_TRIVIAL);
600
+
577
601
String meshFile = getAttrib (XMLNode, " meshFile" );
578
602
bool castShadows = getAttribBool (XMLNode, " castShadows" , true );
579
603
@@ -603,6 +627,9 @@ void DotSceneLoader::processParticleSystem(pugi::xml_node& XMLNode, SceneNode* p
603
627
{
604
628
// Process attributes
605
629
String name = getAttrib (XMLNode, " name" );
630
+
631
+ LogManager::getSingleton ().logMessage (" [DotSceneLoader] Processing Particle System: " + name, LML_TRIVIAL);
632
+
606
633
String templateName = getAttrib (XMLNode, " template" );
607
634
608
635
if (templateName.empty ())
@@ -628,6 +655,9 @@ void DotSceneLoader::processBillboardSet(pugi::xml_node& XMLNode, SceneNode* pPa
628
655
void DotSceneLoader::processPlane (pugi::xml_node& XMLNode, SceneNode* pParent)
629
656
{
630
657
String name = getAttrib (XMLNode, " name" );
658
+
659
+ LogManager::getSingleton ().logMessage (" [DotSceneLoader] Processing Plane: " + name, LML_TRIVIAL);
660
+
631
661
Real distance = getAttribReal (XMLNode, " distance" );
632
662
Real width = getAttribReal (XMLNode, " width" );
633
663
Real height = getAttribReal (XMLNode, " height" );
@@ -654,6 +684,8 @@ void DotSceneLoader::processPlane(pugi::xml_node& XMLNode, SceneNode* pParent)
654
684
655
685
void DotSceneLoader::processFog (pugi::xml_node& XMLNode)
656
686
{
687
+ LogManager::getSingleton ().logMessage (" [DotSceneLoader] Processing Fog..." , LML_TRIVIAL);
688
+
657
689
// Process attributes
658
690
Real expDensity = getAttribReal (XMLNode, " density" , 0.001 );
659
691
Real linearStart = getAttribReal (XMLNode, " start" , 0.0 );
@@ -684,6 +716,8 @@ void DotSceneLoader::processFog(pugi::xml_node& XMLNode)
684
716
685
717
void DotSceneLoader::processSkyBox (pugi::xml_node& XMLNode)
686
718
{
719
+ LogManager::getSingleton ().logMessage (" [DotSceneLoader] Processing SkyBox..." , LML_TRIVIAL);
720
+
687
721
// Process attributes
688
722
String material = getAttrib (XMLNode, " material" , " BaseWhite" );
689
723
Real distance = getAttribReal (XMLNode, " distance" , 5000 );
@@ -704,6 +738,8 @@ void DotSceneLoader::processSkyBox(pugi::xml_node& XMLNode)
704
738
705
739
void DotSceneLoader::processSkyDome (pugi::xml_node& XMLNode)
706
740
{
741
+ LogManager::getSingleton ().logMessage (" [DotSceneLoader] Processing SkyDome..." , LML_TRIVIAL);
742
+
707
743
// Process attributes
708
744
String material = XMLNode.attribute (" material" ).value ();
709
745
Real curvature = getAttribReal (XMLNode, " curvature" , 10 );
@@ -725,6 +761,8 @@ void DotSceneLoader::processSkyDome(pugi::xml_node& XMLNode)
725
761
726
762
void DotSceneLoader::processSkyPlane (pugi::xml_node& XMLNode)
727
763
{
764
+ LogManager::getSingleton ().logMessage (" [DotSceneLoader] Processing SkyPlane..." , LML_TRIVIAL);
765
+
728
766
// Process attributes
729
767
String material = getAttrib (XMLNode, " material" );
730
768
Real planeX = getAttribReal (XMLNode, " planeX" , 0 );
@@ -789,6 +827,96 @@ void DotSceneLoader::processUserData(pugi::xml_node& XMLNode, UserObjectBindings
789
827
}
790
828
}
791
829
830
+ void DotSceneLoader::processNodeAnimations (pugi::xml_node& XMLNode, SceneNode* pParent)
831
+ {
832
+ LogManager::getSingleton ().logMessage (" [DotSceneLoader] Processing Node Animations for SceneNode: " + pParent->getName (), LML_TRIVIAL);
833
+
834
+ // Process node animations (*)
835
+ for (auto pElement : XMLNode.children (" animation" ))
836
+ {
837
+ processNodeAnimation (pElement, pParent);
838
+ }
839
+ }
840
+
841
+ void DotSceneLoader::processNodeAnimation (pugi::xml_node& XMLNode, SceneNode* pParent)
842
+ {
843
+ // Process node animation (*)
844
+
845
+ // Construct the animation name
846
+ String name = getAttrib (XMLNode, " name" );
847
+
848
+ LogManager::getSingleton ().logMessage (" [DotSceneLoader] Processing Node Animation: " + name, LML_TRIVIAL);
849
+
850
+ Real length = getAttribReal (XMLNode, " length" );
851
+
852
+ Animation* anim = mSceneMgr ->createAnimation (name, length);
853
+
854
+ bool enable = getAttribBool (XMLNode, " enable" , false );
855
+ bool loop = getAttribBool (XMLNode, " loop" , false );
856
+
857
+ String interpolationMode = getAttrib (XMLNode, " interpolationMode" );
858
+
859
+ if (interpolationMode == " linear" )
860
+ anim->setInterpolationMode (Animation::IM_LINEAR);
861
+ else if (interpolationMode == " spline" )
862
+ anim->setInterpolationMode (Animation::IM_SPLINE);
863
+ else
864
+ LogManager::getSingleton ().logError (" DotSceneLoader - Invalid interpolationMode: " + interpolationMode);
865
+
866
+ String rotationInterpolationMode = getAttrib (XMLNode, " rotationInterpolationMode" );
867
+
868
+ if (rotationInterpolationMode == " linear" )
869
+ anim->setRotationInterpolationMode (Animation::RIM_LINEAR);
870
+ else if (rotationInterpolationMode == " spherical" )
871
+ anim->setRotationInterpolationMode (Animation::RIM_SPHERICAL);
872
+ else
873
+ LogManager::getSingleton ().logError (" DotSceneLoader - Invalid rotationInterpolationMode: " + rotationInterpolationMode);
874
+
875
+ // create a track to animate the camera's node
876
+ NodeAnimationTrack* track = anim->createNodeTrack (0 , pParent);
877
+
878
+ // Process keyframes (*)
879
+ for (auto pElement : XMLNode.children (" keyframe" ))
880
+ {
881
+ processKeyframe (pElement, track);
882
+ }
883
+
884
+ // create a new animation state to track this
885
+ auto animState = mSceneMgr ->createAnimationState (name);
886
+ animState->setEnabled (enable);
887
+ animState->setLoop (loop);
888
+ }
889
+
890
+ void DotSceneLoader::processKeyframe (pugi::xml_node& XMLNode, NodeAnimationTrack* pTrack)
891
+ {
892
+ // Process node animation keyframe (*)
893
+ Real time = getAttribReal (XMLNode, " time" );
894
+
895
+ LogManager::getSingleton ().logMessage (" [DotSceneLoader] Processing Keyframe: " + StringConverter::toString (time), LML_TRIVIAL);
896
+
897
+ auto keyframe = pTrack->createNodeKeyFrame (time);
898
+
899
+ // Process translation (?)
900
+ if (auto pElement = XMLNode.child (" position" )) {
901
+ Vector3 translation = parseVector3 (pElement);
902
+ keyframe->setTranslate (translation);
903
+ }
904
+
905
+ // Process rotation (?)
906
+ // Quaternion rotation = Quaternion::IDENTITY;
907
+ if (auto pElement = XMLNode.child (" rotation" )) {
908
+ Quaternion rotation = parseQuaternion (pElement);
909
+ keyframe->setRotation (rotation);
910
+ }
911
+
912
+ // Process scale (?)
913
+ // Vector3 scale = parseVector3(XMLNode.child("scale"));
914
+ if (auto pElement = XMLNode.child (" scale" )) {
915
+ Vector3 scale = parseVector3 (pElement);
916
+ keyframe->setScale (scale);
917
+ }
918
+ }
919
+
792
920
const Ogre::String& DotScenePlugin::getName () const {
793
921
static Ogre::String name = " DotScene Loader" ;
794
922
return name;
0 commit comments