genesis-3d_engine/Engine/players/DemoUI/gyrostat.h
zhongdaohuan 6e8fbca745 genesis-3d engine version 1.3.
match the genesis editor version 1.3.0.653.
2014-05-05 14:50:33 +08:00

98 lines
2.0 KiB
C++

/** \file gyrostat.h
* Copyright (c) 2011,ChangYou.Webjet
* All rights reserved.
* Date Ver author Comment
* 2011:10:26 1.0 Àî±ó
*/
#ifndef __GYROSTAT_H__
#define __GYROSTAT_H__
#include "foundation/math/float3.h"
#include "resource/meshres.h"
namespace Sample
{
using namespace Math;
class Gyrostat
{
public:
enum OPSTATE
{
OSTrans = 0,
OSRotate = 1,
OSScale = 2,
};
enum OPMODE
{
OMGLOBAL = 0,
OMLOCAL = 1,
OMSCREEN = 2,
};
struct GyrostatProp
{
Ptr<App::Actor> _actor;
Math::float3 _axis;
Math::float3 _oriVec;
Math::float4 _color;
};
public:
Gyrostat();
virtual ~Gyrostat();
void SetParent(const Ptr<App::Actor>& actor);
void SetSelectActor(const Ptr<App::Actor>& actor);
void UpdateActors();
int IsSelected();
void MouseChanged(const float2& oldPos, const float2& nowPos);
void SetOpState(OPSTATE op);
void SetOpMode(OPMODE op);
static void CreateCircleActor(GyrostatProp* gp, const Util::String& actName ,Resources::PositionData& position);
static Ptr<App::Actor> CreateGyrostatActor(OPSTATE os, const Util::String& actName, Math::float3 vec, uint layerId, GyrostatProp* gp = NULL);
private:
void Create();
Math::float3 GetScaleParent(const Ptr<App::Actor>& parentAct, Math::scalar& scale) const;
void UpdateSelectActor(const int i);
bool CalAxisWithQuat( const Math::quaternion& qut,Math::float4& out );
private:
Util::Array< GyrostatProp > mGyrostatActors;
Ptr<App::Actor> mParentActor;
int mSelectIndex;
OPSTATE mOpState;
OPMODE mOpMode;
};
//---------------------------------------------------------------------------
inline void
Gyrostat::SetParent(const Ptr<App::Actor>& actor)
{
mParentActor = actor;
if(!mParentActor.isvalid())
mSelectIndex = -1;
}
//----------------------------------------------------------------------------
inline int
Gyrostat::IsSelected()
{
return (mSelectIndex>=0);
}
}
#endif