1
0
forked from metin2/client
client/GameLib/PhysicsObject.h

100 lines
2.0 KiB
C
Raw Normal View History

#pragma once
#include "MapUtil.h"
class IPhysicsWorld
{
public:
IPhysicsWorld()
{
assert(ms_pWorld == NULL);
ms_pWorld = this;
}
virtual ~IPhysicsWorld()
{
if (this == ms_pWorld)
ms_pWorld = NULL;
}
static IPhysicsWorld* GetPhysicsWorld()
{
return ms_pWorld;
}
virtual bool isPhysicalCollision(const D3DXVECTOR3 & c_rvCheckPosition) = 0;
private:
static IPhysicsWorld* ms_pWorld;
};
class CActorInstance;
//NOTE : <20><><EFBFBD><EFBFBD> <20>ȵ<EFBFBD><C8B5><EFBFBD><EFBFBD><EFBFBD> Dependency Inversion<6F><6E> <20><><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> interface<63><65> <20><><EFBFBD><EFBFBD><EFBFBD>ϱ<EFBFBD> <20><><EFBFBD>ؼ<EFBFBD> <20>̹<EFBFBD><CCB9>Ĵ<EFBFBD><C4B4><EFBFBD> <20><><EFBFBD><EFBFBD>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><20>Ѵٸ<D1B4> world<6C><64> live object<63><74><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD>ݴ<EFBFBD> base project<63><74><EFBFBD><EFBFBD> (gamelib<69>̳<EFBFBD> <20><> base project<63><74><EFBFBD><EFBFBD> <20>ؾ<EFBFBD> <20>Ѵ<EFBFBD> )
class IObjectManager
{
public:
IObjectManager()
{
assert(ms_ObjManager == NULL);
ms_ObjManager = this;
}
virtual ~IObjectManager()
{
if (this == ms_ObjManager)
ms_ObjManager = NULL;
}
static IObjectManager* GetObjectManager()
{
return ms_ObjManager;
}
virtual void AdjustCollisionWithOtherObjects(CActorInstance* pInst ) = 0;
private:
static IObjectManager* ms_ObjManager;
};
class CPhysicsObject
{
public:
CPhysicsObject();
virtual ~CPhysicsObject();
void Initialize();
void Update(float fElapsedTime);
bool isBlending();
void SetDirection(const D3DXVECTOR3 & c_rv3Direction);
void IncreaseExternalForce(const D3DXVECTOR3 & c_rvBasePosition, float fForce);
void SetLastPosition(const TPixelPosition & c_rPosition, float fBlendingTime);
void GetLastPosition(TPixelPosition * pPosition);
float GetXMovement();
float GetYMovement();
void ClearSavingMovement();
void SetActorInstance( CActorInstance* pInst ) { m_pActorInstance = pInst; }
CActorInstance* GetActorInstance() { return m_pActorInstance; }
protected:
void Accumulate(D3DXVECTOR3 * pv3Position);
protected:
float m_fMass;
float m_fFriction;
D3DXVECTOR3 m_v3Direction;
D3DXVECTOR3 m_v3Acceleration;
D3DXVECTOR3 m_v3Velocity;
D3DXVECTOR3 m_v3LastPosition;
CEaseOutInterpolation m_xPushingPosition;
CEaseOutInterpolation m_yPushingPosition;
CActorInstance* m_pActorInstance;
};