From 7028cbe09c688437910a25623098762bf0fa592d Mon Sep 17 00:00:00 2001 From: David Walter Seikel Date: Mon, 28 Mar 2016 22:28:34 +1000 Subject: Move Irrlicht to src/others. --- .../Irrlicht/CDefaultSceneNodeAnimatorFactory.cpp | 162 +++++++++++++++++++++ 1 file changed, 162 insertions(+) create mode 100644 src/others/irrlicht-1.8.1/source/Irrlicht/CDefaultSceneNodeAnimatorFactory.cpp (limited to 'src/others/irrlicht-1.8.1/source/Irrlicht/CDefaultSceneNodeAnimatorFactory.cpp') diff --git a/src/others/irrlicht-1.8.1/source/Irrlicht/CDefaultSceneNodeAnimatorFactory.cpp b/src/others/irrlicht-1.8.1/source/Irrlicht/CDefaultSceneNodeAnimatorFactory.cpp new file mode 100644 index 0000000..ec52d25 --- /dev/null +++ b/src/others/irrlicht-1.8.1/source/Irrlicht/CDefaultSceneNodeAnimatorFactory.cpp @@ -0,0 +1,162 @@ +// Copyright (C) 2002-2012 Nikolaus Gebhardt +// This file is part of the "Irrlicht Engine". +// For conditions of distribution and use, see copyright notice in irrlicht.h + +#include "CDefaultSceneNodeAnimatorFactory.h" +#include "CSceneNodeAnimatorCameraFPS.h" +#include "CSceneNodeAnimatorCameraMaya.h" +#include "ICursorControl.h" +#include "ISceneNodeAnimatorCollisionResponse.h" +#include "ISceneManager.h" + +namespace irr +{ +namespace scene +{ + +//! Names for scene node types +const c8* const SceneNodeAnimatorTypeNames[] = +{ + "flyCircle", + "flyStraight", + "followSpline", + "rotation", + "texture", + "deletion", + "collisionResponse", + "cameraFPS", + "cameraMaya", + 0 +}; + + +CDefaultSceneNodeAnimatorFactory::CDefaultSceneNodeAnimatorFactory(ISceneManager* mgr, gui::ICursorControl* crs) +: Manager(mgr), CursorControl(crs) +{ + #ifdef _DEBUG + setDebugName("CDefaultSceneNodeAnimatorFactory"); + #endif + + // don't grab the scene manager here to prevent cyclic references + if (CursorControl) + CursorControl->grab(); +} + + +CDefaultSceneNodeAnimatorFactory::~CDefaultSceneNodeAnimatorFactory() +{ + if (CursorControl) + CursorControl->drop(); +} + + +//! creates a scene node animator based on its type id +ISceneNodeAnimator* CDefaultSceneNodeAnimatorFactory::createSceneNodeAnimator(ESCENE_NODE_ANIMATOR_TYPE type, ISceneNode* target) +{ + scene::ISceneNodeAnimator* anim = 0; + + switch(type) + { + case ESNAT_FLY_CIRCLE: + anim = Manager->createFlyCircleAnimator(core::vector3df(0,0,0), 10); + break; + case ESNAT_FLY_STRAIGHT: + anim = Manager->createFlyStraightAnimator(core::vector3df(0,0,0), core::vector3df(100,100,100), 10000, true ); + break; + case ESNAT_FOLLOW_SPLINE: + { + core::array points; + points.push_back(core::vector3df(0,0,0)); + points.push_back(core::vector3df(10,5,10)); + anim = Manager->createFollowSplineAnimator(0, points); + } + break; + case ESNAT_ROTATION: + anim = Manager->createRotationAnimator(core::vector3df(0.3f,0,0)); + break; + case ESNAT_TEXTURE: + { + core::array textures; + anim = Manager->createTextureAnimator(textures, 250); + } + break; + case ESNAT_DELETION: + anim = Manager->createDeleteAnimator(5000); + break; + case ESNAT_COLLISION_RESPONSE: + anim = Manager->createCollisionResponseAnimator(0, target); + break; + case ESNAT_CAMERA_FPS: + anim = new CSceneNodeAnimatorCameraFPS(CursorControl); + break; + case ESNAT_CAMERA_MAYA: + anim = new CSceneNodeAnimatorCameraMaya(CursorControl); + break; + default: + break; + } + + if (anim && target) + target->addAnimator(anim); + + return anim; +} + + +//! creates a scene node animator based on its type name +ISceneNodeAnimator* CDefaultSceneNodeAnimatorFactory::createSceneNodeAnimator(const c8* typeName, ISceneNode* target) +{ + return createSceneNodeAnimator( getTypeFromName(typeName), target ); +} + + +//! returns amount of scene node animator types this factory is able to create +u32 CDefaultSceneNodeAnimatorFactory::getCreatableSceneNodeAnimatorTypeCount() const +{ + return ESNAT_COUNT; +} + + +//! returns type of a createable scene node animator type +ESCENE_NODE_ANIMATOR_TYPE CDefaultSceneNodeAnimatorFactory::getCreateableSceneNodeAnimatorType(u32 idx) const +{ + if (idx