irrlicht/source/Irrlicht/CSceneNodeAnimatorFlyCircle...

101 lines
2.8 KiB
C++
Raw Normal View History

// Copyright (C) 2002-2009 Nikolaus Gebhardt
// This file is part of the "Irrlicht Engine".
// For conditions of distribution and use, see copyright notice in irrlicht.h
#include "CSceneNodeAnimatorFlyCircle.h"
namespace irr
{
namespace scene
{
//! constructor
CSceneNodeAnimatorFlyCircle::CSceneNodeAnimatorFlyCircle(u32 time,
const core::vector3df& center, f32 radius, f32 speed,
const core::vector3df& direction, f32 radiusEllipsoid)
: Center(center), Direction(direction), Radius(radius),
RadiusEllipsoid(radiusEllipsoid), Speed(speed), StartTime(time)
{
#ifdef _DEBUG
setDebugName("CSceneNodeAnimatorFlyCircle");
#endif
init();
}
void CSceneNodeAnimatorFlyCircle::init()
{
Direction.normalize();
if (Direction.Y != 0)
VecV = core::vector3df(50,0,0).crossProduct(Direction).normalize();
else
VecV = core::vector3df(0,50,0).crossProduct(Direction).normalize();
VecU = VecV.crossProduct(Direction).normalize();
}
//! animates a scene node
void CSceneNodeAnimatorFlyCircle::animateNode(ISceneNode* node, u32 timeMs)
{
if ( 0 == node )
return;
f32 time;
// Check for the condition where the StartTime is in the future.
if(StartTime > timeMs)
time = ((s32)timeMs - (s32)StartTime) * Speed;
else
time = (timeMs-StartTime) * Speed;
Changes in 1.6 TA - fixed createMeshWith2TCoords normals were missing during copy. - addded //! Creates a copy of the mesh, which will only consist of S3DVertex vertices. IMesh* CMeshManipulator::createMeshWith1TCoords(IMesh* mesh) const - added io::IFileSystem* CSceneManager::getFileSystem() for preparing to remove the (mostly) unnecessary double member variables in many loaders - added virtual const c8* ISceneManager::getAnimatorTypeName(ESCENE_NODE_ANIMATOR_TYPE type); to the SceneManger Interface. just like getTypeName is public - added CSceneNodeAnimatorFlyCircle::radiusEllipsoid. if radiusEllipsoid == 0 the default circle animation is done else radiusEllipsoid forms the b-axe of the ellipsoid. -> gummiball bouncing - added ISceneManager::createFlyStraightAnimator variable bool ping-pong used in loop mode to device if start from beginning ( default ) or make ping-pong -> straight bouncing - changed IFileSystem::registerFileArchive remove the index of the hiarchy and added a new interface method //! move the hirarchy of the filesystem. moves sourceIndex relative up or down virtual bool moveFileArchive( u32 sourceIndex, s32 relative ) = 0; - bugfix and changes in SViewFrustum::SViewFrustum wrong size of Matrices copy. This bug must be ages old... (typo) detected during resizing the Matrices. removed obsolute Matrices renamed E_TRANSFORMATION_STATE_2 to E_TRANSFORMATION_STATE_FRUSTUM therefore also changed SViewFrustum::setTransformState to not tap in the pitfall again of wrong memory... and renamed it to getTransform, like in the driver and Matrices private - OpenGL: Specular - moved //! EMT_ONETEXTURE_BLEND: has BlendFactor Alphablending inline bool textureBlendFunc_hasAlpha ( E_BLEND_FACTOR factor ) const from the material renderes ( 3x declared ) to SMaterial.h - updated managed light example to use standard driver selection - BurningsVideo - LightModel reworked. Point Light & Direction Light works for Diffuse Color as aspected Specular and Fog still have problems ( needs new pixel shader ) pushed burningsvideo to 0.42 for this major step - removed obsolete matrix transformations renamed E_TRANSFORMATION_STATE_2 to E_TRANSFORMATION_STATE_BURNING - cleaned line3d.h vector3d.h template behavior. many mixed f32/f64 implementations are here. i'm not sure if this should be the default behavior to use f64 for example for 1.0/x value, because they benefit from more precisions, but in my point of view the user is responsible of choosing a vector3d<f32> or vector3d<f64>. - added core::squareroot to irrmath.h -> for having candidates for faster math in the same file - added AllowZWriteOnTransparent from SceneManager to burningsvideo Following SceneManger guideline -added hasAlpha() to ITexture This info can be used for e.q to downgrade a transparent alpha channel blit to add if the texture has no alpha channel. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2199 dfc29bdd-3216-0410-991c-e03cc46cb475
2009-02-05 07:33:55 -08:00
// node->setPosition(Center + Radius * ((VecU*cosf(time)) + (VecV*sinf(time))));
f32 r2 = RadiusEllipsoid == 0.f ? Radius : RadiusEllipsoid;
node->setPosition(Center + (Radius*cosf(time)*VecU) + (r2*sinf(time)*VecV ) );
}
//! Writes attributes of the scene node animator.
void CSceneNodeAnimatorFlyCircle::serializeAttributes(io::IAttributes* out, io::SAttributeReadWriteOptions* options) const
{
out->addVector3d("Center", Center);
out->addFloat("Radius", Radius);
out->addFloat("Speed", Speed);
out->addVector3d("Direction", Direction);
Changes in 1.6 TA - fixed createMeshWith2TCoords normals were missing during copy. - addded //! Creates a copy of the mesh, which will only consist of S3DVertex vertices. IMesh* CMeshManipulator::createMeshWith1TCoords(IMesh* mesh) const - added io::IFileSystem* CSceneManager::getFileSystem() for preparing to remove the (mostly) unnecessary double member variables in many loaders - added virtual const c8* ISceneManager::getAnimatorTypeName(ESCENE_NODE_ANIMATOR_TYPE type); to the SceneManger Interface. just like getTypeName is public - added CSceneNodeAnimatorFlyCircle::radiusEllipsoid. if radiusEllipsoid == 0 the default circle animation is done else radiusEllipsoid forms the b-axe of the ellipsoid. -> gummiball bouncing - added ISceneManager::createFlyStraightAnimator variable bool ping-pong used in loop mode to device if start from beginning ( default ) or make ping-pong -> straight bouncing - changed IFileSystem::registerFileArchive remove the index of the hiarchy and added a new interface method //! move the hirarchy of the filesystem. moves sourceIndex relative up or down virtual bool moveFileArchive( u32 sourceIndex, s32 relative ) = 0; - bugfix and changes in SViewFrustum::SViewFrustum wrong size of Matrices copy. This bug must be ages old... (typo) detected during resizing the Matrices. removed obsolute Matrices renamed E_TRANSFORMATION_STATE_2 to E_TRANSFORMATION_STATE_FRUSTUM therefore also changed SViewFrustum::setTransformState to not tap in the pitfall again of wrong memory... and renamed it to getTransform, like in the driver and Matrices private - OpenGL: Specular - moved //! EMT_ONETEXTURE_BLEND: has BlendFactor Alphablending inline bool textureBlendFunc_hasAlpha ( E_BLEND_FACTOR factor ) const from the material renderes ( 3x declared ) to SMaterial.h - updated managed light example to use standard driver selection - BurningsVideo - LightModel reworked. Point Light & Direction Light works for Diffuse Color as aspected Specular and Fog still have problems ( needs new pixel shader ) pushed burningsvideo to 0.42 for this major step - removed obsolete matrix transformations renamed E_TRANSFORMATION_STATE_2 to E_TRANSFORMATION_STATE_BURNING - cleaned line3d.h vector3d.h template behavior. many mixed f32/f64 implementations are here. i'm not sure if this should be the default behavior to use f64 for example for 1.0/x value, because they benefit from more precisions, but in my point of view the user is responsible of choosing a vector3d<f32> or vector3d<f64>. - added core::squareroot to irrmath.h -> for having candidates for faster math in the same file - added AllowZWriteOnTransparent from SceneManager to burningsvideo Following SceneManger guideline -added hasAlpha() to ITexture This info can be used for e.q to downgrade a transparent alpha channel blit to add if the texture has no alpha channel. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2199 dfc29bdd-3216-0410-991c-e03cc46cb475
2009-02-05 07:33:55 -08:00
out->addFloat("RadiusEllipsoid", Radius);
}
//! Reads attributes of the scene node animator.
void CSceneNodeAnimatorFlyCircle::deserializeAttributes(io::IAttributes* in, io::SAttributeReadWriteOptions* options)
{
Center = in->getAttributeAsVector3d("Center");
Radius = in->getAttributeAsFloat("Radius");
Speed = in->getAttributeAsFloat("Speed");
Direction = in->getAttributeAsVector3d("Direction");
StartTime = 0;
if (Direction.equals(core::vector3df(0,0,0)))
Direction.set(0,1,0); // irrlicht 1.1 backwards compatibility
else
Direction.normalize();
Changes in 1.6 TA - fixed createMeshWith2TCoords normals were missing during copy. - addded //! Creates a copy of the mesh, which will only consist of S3DVertex vertices. IMesh* CMeshManipulator::createMeshWith1TCoords(IMesh* mesh) const - added io::IFileSystem* CSceneManager::getFileSystem() for preparing to remove the (mostly) unnecessary double member variables in many loaders - added virtual const c8* ISceneManager::getAnimatorTypeName(ESCENE_NODE_ANIMATOR_TYPE type); to the SceneManger Interface. just like getTypeName is public - added CSceneNodeAnimatorFlyCircle::radiusEllipsoid. if radiusEllipsoid == 0 the default circle animation is done else radiusEllipsoid forms the b-axe of the ellipsoid. -> gummiball bouncing - added ISceneManager::createFlyStraightAnimator variable bool ping-pong used in loop mode to device if start from beginning ( default ) or make ping-pong -> straight bouncing - changed IFileSystem::registerFileArchive remove the index of the hiarchy and added a new interface method //! move the hirarchy of the filesystem. moves sourceIndex relative up or down virtual bool moveFileArchive( u32 sourceIndex, s32 relative ) = 0; - bugfix and changes in SViewFrustum::SViewFrustum wrong size of Matrices copy. This bug must be ages old... (typo) detected during resizing the Matrices. removed obsolute Matrices renamed E_TRANSFORMATION_STATE_2 to E_TRANSFORMATION_STATE_FRUSTUM therefore also changed SViewFrustum::setTransformState to not tap in the pitfall again of wrong memory... and renamed it to getTransform, like in the driver and Matrices private - OpenGL: Specular - moved //! EMT_ONETEXTURE_BLEND: has BlendFactor Alphablending inline bool textureBlendFunc_hasAlpha ( E_BLEND_FACTOR factor ) const from the material renderes ( 3x declared ) to SMaterial.h - updated managed light example to use standard driver selection - BurningsVideo - LightModel reworked. Point Light & Direction Light works for Diffuse Color as aspected Specular and Fog still have problems ( needs new pixel shader ) pushed burningsvideo to 0.42 for this major step - removed obsolete matrix transformations renamed E_TRANSFORMATION_STATE_2 to E_TRANSFORMATION_STATE_BURNING - cleaned line3d.h vector3d.h template behavior. many mixed f32/f64 implementations are here. i'm not sure if this should be the default behavior to use f64 for example for 1.0/x value, because they benefit from more precisions, but in my point of view the user is responsible of choosing a vector3d<f32> or vector3d<f64>. - added core::squareroot to irrmath.h -> for having candidates for faster math in the same file - added AllowZWriteOnTransparent from SceneManager to burningsvideo Following SceneManger guideline -added hasAlpha() to ITexture This info can be used for e.q to downgrade a transparent alpha channel blit to add if the texture has no alpha channel. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2199 dfc29bdd-3216-0410-991c-e03cc46cb475
2009-02-05 07:33:55 -08:00
RadiusEllipsoid = in->getAttributeAsFloat("RadiusEllipsoid");
init();
}
ISceneNodeAnimator* CSceneNodeAnimatorFlyCircle::createClone(ISceneNode* node, ISceneManager* newManager)
{
CSceneNodeAnimatorFlyCircle * newAnimator =
Changes in 1.6 TA - fixed createMeshWith2TCoords normals were missing during copy. - addded //! Creates a copy of the mesh, which will only consist of S3DVertex vertices. IMesh* CMeshManipulator::createMeshWith1TCoords(IMesh* mesh) const - added io::IFileSystem* CSceneManager::getFileSystem() for preparing to remove the (mostly) unnecessary double member variables in many loaders - added virtual const c8* ISceneManager::getAnimatorTypeName(ESCENE_NODE_ANIMATOR_TYPE type); to the SceneManger Interface. just like getTypeName is public - added CSceneNodeAnimatorFlyCircle::radiusEllipsoid. if radiusEllipsoid == 0 the default circle animation is done else radiusEllipsoid forms the b-axe of the ellipsoid. -> gummiball bouncing - added ISceneManager::createFlyStraightAnimator variable bool ping-pong used in loop mode to device if start from beginning ( default ) or make ping-pong -> straight bouncing - changed IFileSystem::registerFileArchive remove the index of the hiarchy and added a new interface method //! move the hirarchy of the filesystem. moves sourceIndex relative up or down virtual bool moveFileArchive( u32 sourceIndex, s32 relative ) = 0; - bugfix and changes in SViewFrustum::SViewFrustum wrong size of Matrices copy. This bug must be ages old... (typo) detected during resizing the Matrices. removed obsolute Matrices renamed E_TRANSFORMATION_STATE_2 to E_TRANSFORMATION_STATE_FRUSTUM therefore also changed SViewFrustum::setTransformState to not tap in the pitfall again of wrong memory... and renamed it to getTransform, like in the driver and Matrices private - OpenGL: Specular - moved //! EMT_ONETEXTURE_BLEND: has BlendFactor Alphablending inline bool textureBlendFunc_hasAlpha ( E_BLEND_FACTOR factor ) const from the material renderes ( 3x declared ) to SMaterial.h - updated managed light example to use standard driver selection - BurningsVideo - LightModel reworked. Point Light & Direction Light works for Diffuse Color as aspected Specular and Fog still have problems ( needs new pixel shader ) pushed burningsvideo to 0.42 for this major step - removed obsolete matrix transformations renamed E_TRANSFORMATION_STATE_2 to E_TRANSFORMATION_STATE_BURNING - cleaned line3d.h vector3d.h template behavior. many mixed f32/f64 implementations are here. i'm not sure if this should be the default behavior to use f64 for example for 1.0/x value, because they benefit from more precisions, but in my point of view the user is responsible of choosing a vector3d<f32> or vector3d<f64>. - added core::squareroot to irrmath.h -> for having candidates for faster math in the same file - added AllowZWriteOnTransparent from SceneManager to burningsvideo Following SceneManger guideline -added hasAlpha() to ITexture This info can be used for e.q to downgrade a transparent alpha channel blit to add if the texture has no alpha channel. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@2199 dfc29bdd-3216-0410-991c-e03cc46cb475
2009-02-05 07:33:55 -08:00
new CSceneNodeAnimatorFlyCircle(StartTime, Center, Radius, Speed, Direction, RadiusEllipsoid);
return newAnimator;
}
} // end namespace scene
} // end namespace irr