ChainStrikeClientSkillEffect::ChainStrikeClientSkillEffect(unsigned int _lastTarget, unsigned int _target, FLOAT3 _position)
{
	m_superPos = _position;
	m_lifetime = 0.0f;

	this->m_lastTarget = _lastTarget;
	this->m_target = _target;
	this->m_percentToTarget = 0;

	pe[0] = g_graphicsEngine->createParticleEngine("test", D3DXVECTOR4(0, 0, 0, 1), D3DXQUATERNION(0, 0, 0, 1), D3DXVECTOR2(1, 1));
	pe[1] = g_graphicsEngine->createParticleEngine("test2", D3DXVECTOR4(0, 0, 0, 1), D3DXQUATERNION(0, 0, 0, 1), D3DXVECTOR2(1, 1));
	pe[2] = g_graphicsEngine->createParticleEngine("test3", D3DXVECTOR4(0, 0, 0, 1), D3DXQUATERNION(0, 0, 0, 1), D3DXVECTOR2(1, 1));

	int sound = createSoundHandle("skills/chain_strike.wav", false, true, _position, 0.5f);
	playSound(sound);
	deactivateSound(sound);

	Entity *e = ClientEntityHandler::getEntity(_lastTarget);
	if(e != NULL && e->m_type == ServerEntity::HeroType)
	{
		e->m_model->getAnimation()->Play("ChainLight");
	}
	m_orig = D3DXVECTOR3(0, 0, 0);
	m_eOrig = NULL;
	m_eOrig = ClientEntityHandler::getEntity(m_lastTarget);
	if(m_eOrig)
		m_orig = D3DXVECTOR3(m_eOrig->m_model->getPosition().x, m_eOrig->m_model->getPosition().y, m_eOrig->m_model->getPosition().z);
}
Example #2
0
CBody::CBody(void) :
	m_position(D3DXVECTOR3(0,0,0)),
	m_velocity(D3DXVECTOR3(0,0,0)),

	m_orientation(D3DXQUATERNION(0,0,0,1)),
	m_angularVelocity(D3DXQUATERNION(0,0,0,1)),

	m_lastUpdate(0)
{
}
Example #3
0
 D3DXVECTOR3 rotateVec3ByQuat(const D3DXVECTOR3 *vec, const D3DXQUATERNION *quat)
 {
     D3DXQUATERNION conj, res;
     D3DXQuaternionConjugate(&conj,quat);
     res = conj*D3DXQUATERNION(vec->x, vec->y, vec->z,1.f)*(*quat);
     return D3DXVECTOR3(res.x,res.y,res.z);
 }
Example #4
0
Mesh::Mesh(D3DXVECTOR3 pos, string filePath, string billboardFilePath, float distanceToSwapToBillboard)
{
	this->filePath = filePath;
	this->specialColor = NULL_COLOR;
	this->usingInvisibilityEffect = false;
	//this->transparency = 0.0f;

	this->meshStripsResource = NULL;
	this->isStripCulled = NULL;
	this->isStripShadowCulled = NULL;

	this->dontRender = false;

	this->height = -1.0f;
	this->billboardFilePath = billboardFilePath;
	if(billboardFilePath != "")
	{
		this->hasBillboard = true;
	}
	else
	{
		this->hasBillboard = false;
	}
	this->billboard = NULL;
	this->distanceToSwapToBillboard = distanceToSwapToBillboard;

	this->topology = D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
	this->pos = pos;

	this->rotQuat = D3DXQUATERNION(0, 0, 0, 1);
	this->scale = D3DXVECTOR3(1, 1, 1);
	this->RecreateWorldMatrix();
}
Example #5
0
void CWindmill::Initialize()
{
	m_SkinModel.Initialize("XFile\\windmill.x");
	m_data.rotation = D3DXQUATERNION(0, 0, 0, 1.0f);
	m_data.scale = D3DXVECTOR3(0, 0, 0);
	m_aabbMin += m_data.position;
	m_aabbMax += m_data.position;
}
Example #6
0
D3DXMATRIX CCamera::GetMatrixCamera()
{
	D3DXMatrixIdentity(&m_matrixCamera);
	D3DXMatrixAffineTransformation(&m_matrixCamera , 1, &D3DXVECTOR3(0,0,0), &D3DXQUATERNION(0,0,0,0), &D3DXVECTOR3((float)-m_pos.x, (float) m_pos.y, 0));
	m_matrixCamera._22 = -1;

	return m_matrixCamera;
}
Example #7
0
D3DXQUATERNION ArcBall::QuatFromBallPoints(const D3DXVECTOR3 &vFrom, const D3DXVECTOR3 &vTo)
{
	D3DXVECTOR3 vPart;
	float fDot = D3DXVec3Dot( &vFrom, &vTo );	// rotation angle
	D3DXVec3Cross( &vPart, &vFrom, &vTo );		// rotation axis

	return D3DXQUATERNION( vPart.x, vPart.y, vPart.z, fDot );
}
Example #8
0
void Mesh::RotateAxis(D3DXVECTOR3 around, float angle)
{
	D3DXQUATERNION quaternion = D3DXQUATERNION(0, 0, 0, 1);
	D3DXQuaternionRotationAxis(&quaternion, &around, angle);
	
	D3DXQuaternionMultiply(&this->rotQuat, &this->rotQuat, &quaternion);
	this->RecreateWorldMatrix();
}
Example #9
0
//--------------------------------------------------------------------------------------
D3DXQUATERNION CD3DArcBall::QuatFromBallPoints( const D3DXVECTOR3& vFrom, const D3DXVECTOR3& vTo )
{
    D3DXVECTOR3 vPart;
    float fDot = D3DXVec3Dot( &vFrom, &vTo );
    D3DXVec3Cross( &vPart, &vFrom, &vTo );

    return D3DXQUATERNION( vPart.x, vPart.y, vPart.z, fDot );
}
Example #10
0
// Putting this here until I find a better place for it!
D3DXVECTOR3 *D3DXVec3Rotate( D3DXVECTOR3 *pOut, const D3DXVECTOR3 *pV, const D3DXQUATERNION *pQ )
{
    D3DXQUATERNION q1, q2;
    D3DXQuaternionConjugate( &q1, pQ );
    q2 = q1 * D3DXQUATERNION( pV->x, pV->y, pV->z, 1.0f ) * (*pQ);

	*pOut = D3DXVECTOR3( q2.x, q2.y, q2.z );
    return pOut;
}
Example #11
0
//=============================================================================
// コンストラクタ
//=============================================================================
SceneModel::SceneModel(char * pFileName, const D3DXVECTOR3 & Pos, SceneModel * pParentint, PRIORITY Priority, OBJTYPE Type)
    :Scene(Priority, Type), m_pParent(pParentint)
{
    m_pD3DDevice = Manager::GetRenderer()->GetDevice();
    m_Pos = Pos;
    m_Rot = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
    m_Scl = D3DXVECTOR3(1.0f, 1.0f, 1.0f);
    m_Quaternion = D3DXQUATERNION(0.0f, 0.0f, 0.0f, 1.0f);
    m_pModelManager = Model::Load(pFileName, m_pMeshBuff, m_pMatBuff, &m_pMaterial, m_NumMat, &m_pTextureBuff, m_PosLocalOrigin, m_Size);
}
Example #12
0
void IK::init()
{
	//initializing here just means setting quaternions to initial values
	if (_info.NumberOfLinks)
	{
		for (int i=0;i<(int)_info.NumberOfLinks;i++)
		{
			_info.BoneLinkList[i].IKQuat = D3DXQUATERNION(0,0,0,1);
		}
	}
}
Example #13
0
ArcBall::ArcBall(void)
    : is_dragged_(false),
      radius_(1.0f),
      previous_point_(D3DXVECTOR3(0, 0, 0)),
      current_point_(D3DXVECTOR3(0, 0, 0)),
      old_point_(D3DXVECTOR3(0, 0, 0)),
      previous_quaternion_(D3DXQUATERNION(0, 0, 0, 1)),
      current_quaternion_(D3DXQUATERNION(0, 0, 0, 1)),
      rotation_increament_(D3DXQUATERNION(0, 0, 0, 1))
{
    D3DXMatrixIdentity(&rotate_matrix_);

    RECT rc ;
    GetClientRect(GetForegroundWindow(), &rc) ;

    int window_width  = rc.right - rc.left;
    int window_height = rc.bottom - rc.top;

    SetWindow(window_width, window_height) ;
}
Example #14
0
    void Camera::lookAt(const D3DXVECTOR3& eye, const D3DXVECTOR3& at, const D3DXVECTOR3& up)
    {
        D3DXVECTOR3 axisUp = up;
        D3DXVECTOR3 axisTo = (at-eye);
        //check if up and  at - eye is perpendicular. If not, make them.
        if( D3DXVec3Dot(&axisUp,&axisTo) != 0)
        {
            D3DXVECTOR3 temp;
            D3DXVec3Cross(&temp, &axisUp, &axisTo);
            D3DXVec3Cross(&axisUp, &axisTo, &temp);
        }
        D3DXVec3Normalize(&axisUp, &axisUp);
        D3DXVec3Normalize(&axisTo, &axisTo);

        D3DXMatrixIdentity(&m_viewMatrix);
        D3DXMatrixLookAtLH(&m_viewMatrix,&eye,&at,&axisUp);

        //calculate transforms
        m_translation = -eye;
        D3DXVECTOR3 ref = D3DXVECTOR3(0,0,1);
        D3DXVECTOR3 rotAxis;
        D3DXVec3Cross(&rotAxis,&axisTo,&ref);
        D3DXVec3Normalize(&rotAxis, &rotAxis);
        float angle;
        

        angle = acos(D3DXVec3Dot( &ref, &axisTo ))*0.5f;

        m_orientation = D3DXQUATERNION(sin(angle)*rotAxis.x, sin(angle)*rotAxis.y, sin(angle)*rotAxis.z, cos(angle));

        //check if up vector is still "up"
        
        D3DXVECTOR3 rotatedUp = MathUtil::rotateVec3ByQuat(&axisUp, &m_orientation);
        if(D3DXVec3Dot(&rotatedUp,&up)<0)
        {
            m_orientation = D3DXQUATERNION(axisTo.x*sin(MathUtil::PI*0.5f),axisTo.y*sin(MathUtil::PI*0.5f), axisTo.z*sin(MathUtil::PI*0.5f), cos(MathUtil::PI*0.5f)) * m_orientation;
        }


        m_viewCacheValid = true;
    }
Example #15
0
Mesh::Mesh(D3DXVECTOR3 pos)
{
	this->specialColor = NULL_COLOR;
	this->usingInvisibilityEffect = false;
	//this->transparency = 0.0f;

	this->strips = new MaloW::Array<MeshStrip*>();

	this->topology = D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
	this->pos = pos;

	this->rotQuat = D3DXQUATERNION(0, 0, 0, 1);
	this->scale = D3DXVECTOR3(1, 1, 1);
}
Example #16
0
void decompose_matrix(D3DXVECTOR3& d3d_pos, D3DXQUATERNION& d3d_rot, D3DXVECTOR3& d3d_scale, const MMatrix& mtx)
{
  MTransformationMatrix trans_mtx(mtx);
  MVector translation = trans_mtx.getTranslation(MSpace::kPostTransform);

  double q_x, q_y, q_z, q_w;
  trans_mtx.getRotationQuaternion(q_x, q_y, q_z, q_w, MSpace::kPostTransform);

  double scale[3];
  trans_mtx.getScale(scale, MSpace::kPostTransform);

  d3d_pos = D3DXVECTOR3((float)translation.x, (float)translation.y, (float)-translation.z);
  d3d_rot = D3DXQUATERNION ((float)q_x, (float)q_y, (float)-q_z, (float)q_w);
  d3d_scale = D3DXVECTOR3((float)scale[0], (float)scale[1], (float)scale[2]);
}
Example #17
0
//==============================================================================
// Brief  : クラス内の初期化処理
// Return : void								: なし
// Arg    : void								: なし
//==============================================================================
void Object::InitializeSelf( void )
{
	// メンバ変数の初期化
	idUpdate_ = -1;
	pParent_ = nullptr;
	pGraphic_ = nullptr;
	position_ = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
	typeRotation_ = ROTATION_VECTOR;
	rotation_ = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
	quaternionRotation_ = D3DXQUATERNION( 0.0f, 0.0f, 0.0f, 1.0f );
	matrixRotation_ = D3DXMATRIX( 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f );
	scale_ = D3DXVECTOR3( 1.0f, 1.0f, 1.0f );
	matrixWorld_ = D3DXMATRIX( 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f );
	needsUpdate_ = true;
	isEnable_ = true;
}
CXFrameNode::CXFrameNode(CBGame* inGame) : CBNamedObject(inGame)
{
	D3DXMatrixIdentity(&m_TransformationMatrix);
	D3DXMatrixIdentity(&m_OriginalMatrix);
	D3DXMatrixIdentity(&m_CombinedMatrix);

	for(int i=0; i<2; i++)
	{
		m_TransPos[i]   = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
		m_TransScale[i] = D3DXVECTOR3(1.0f, 1.0f, 1.0f);
		m_TransRot[i]   = D3DXQUATERNION(0.0f, 0.0f, 0.0f, 1.0f);
		m_LerpValue[i]  = 0.0f;

		m_TransUsed[i]  = false;
	}
}
Example #19
0
//-----------------------------------------------------------------------------
// Name: D3DUtil_GetRotationFromCursor()
// Desc: Returns a quaternion for the rotation implied by the window's cursor
//       position.
//-----------------------------------------------------------------------------
D3DXQUATERNION D3DUtil_GetRotationFromCursor( HWND hWnd,
                                              FLOAT fTrackBallRadius )
{
    POINT pt;
    RECT  rc;
    GetCursorPos( &pt );
    GetClientRect( hWnd, &rc );
    ScreenToClient( hWnd, &pt );
    FLOAT sx = ( ( ( 2.0f * pt.x ) / (rc.right-rc.left) ) - 1 );
    FLOAT sy = ( ( ( 2.0f * pt.y ) / (rc.bottom-rc.top) ) - 1 );
    FLOAT sz;

    if( sx == 0.0f && sy == 0.0f )
        return D3DXQUATERNION( 0.0f, 0.0f, 0.0f, 1.0f );

    FLOAT d2 = sqrtf( sx*sx + sy*sy );

    if( d2 < fTrackBallRadius * 0.70710678118654752440 ) // Inside sphere
        sz = sqrtf( fTrackBallRadius*fTrackBallRadius - d2*d2 );
    else                                                 // On hyperbola
        sz = (fTrackBallRadius*fTrackBallRadius) / (2.0f*d2);

    // Get two points on trackball's sphere
    D3DXVECTOR3 p1( sx, sy, sz );
    D3DXVECTOR3 p2( 0.0f, 0.0f, fTrackBallRadius );

    // Get axis of rotation, which is cross product of p1 and p2
    D3DXVECTOR3 vAxis;
    D3DXVec3Cross( &vAxis, &p1, &p2);

    // Calculate angle for the rotation about that axis
    D3DXVECTOR3 vecDiff = p2-p1;
    FLOAT t = D3DXVec3Length( &vecDiff ) / ( 2.0f*fTrackBallRadius );
    if( t > +1.0f) t = +1.0f;
    if( t < -1.0f) t = -1.0f;
    FLOAT fAngle = 2.0f * asinf( t );

    // Convert axis to quaternion
    D3DXQUATERNION quat;
    D3DXQuaternionRotationAxis( &quat, &vAxis, fAngle );
    return quat;
}
Example #20
0
void* Tractor::getVehiclePose()
{
	if(m_poseGiven)
		return (void*)m_vehiclePose;
	m_poseGiven = true;
	/*CHASSIS*/
	Mat rot;
	worldMat(&m_vehiclePose->matChassis, Vec3(m_actor->getGlobalPosition().x, m_actor->getGlobalPosition().y, m_actor->getGlobalPosition().z), Vec3(0, 0, 0));
	D3DXMatrixRotationQuaternion(&rot, &D3DXQUATERNION(m_actor->getGlobalOrientationQuat().x, m_actor->getGlobalOrientationQuat().y, m_actor->getGlobalOrientationQuat().z, m_actor->getGlobalOrientationQuat().w));
	m_vehiclePose->matChassis = m_vehicleDimms->matChassisRotation * rot * m_vehiclePose->matChassis;
	D3DXVec3TransformNormal(&m_forward, &Vec3(1, 0, 0), &rot);

	ShapeUserData* sud;
	//Wheels

	//Front Left wheel

	sud = (ShapeUserData*)(m_wheelFrontLeft->userData);
	sud->wheelShapePose.getColumnMajor44((NxF32*)&m_vehiclePose->matFrontLeftWheel);
	m_vehiclePose->matFrontLeftWheel = m_vehicleDimms->matFrontLeftWheelRotation * m_vehiclePose->matFrontLeftWheel;

	//Front Right wheel

	sud = (ShapeUserData*)(m_wheelFrontRight->userData);
	sud->wheelShapePose.getColumnMajor44((NxF32*)&m_vehiclePose->matFrontRightWheel);
	m_vehiclePose->matFrontRightWheel = m_vehicleDimms->matFrontRightWheelRotation * m_vehiclePose->matFrontRightWheel;

	//Rear Left wheel
	
	sud = (ShapeUserData*)(m_wheelRearLeft->userData);
	sud->wheelShapePose.getColumnMajor44((NxF32*)&m_vehiclePose->matRearLeftWheel);
	m_vehiclePose->matRearLeftWheel = m_vehicleDimms->matRearLeftWheelRotation * m_vehiclePose->matRearLeftWheel;

	//Rear Right wheel
	
	sud = (ShapeUserData*)(m_wheelRearRight->userData);
	sud->wheelShapePose.getColumnMajor44((NxF32*)&m_vehiclePose->matRearRightWheel);
	m_vehiclePose->matRearRightWheel = m_vehicleDimms->matRearRightWheelRotation * m_vehiclePose->matRearRightWheel;

	return (void*)m_vehiclePose;
}
ArrowClientSkillEffect::ArrowClientSkillEffect(FLOAT3 _position, unsigned int _targetId, unsigned int _masterId)
{
	m_active = true;
	m_targetId = _targetId;
	m_graphicalEffect = g_graphicsEngine->createModel("Arrow", _position);
	m_graphicalEffect->setAlpha(0.999f);

	Entity* master = ClientEntityHandler::getEntity(_masterId);
	if(master != NULL)
	{
		master->m_model->getAnimation()->PlayLoop("RangeAttack");
	}
	
	D3DXVECTOR3 newPos = D3DXVECTOR3(_position.x, _position.y, _position.z);
	this->m_particleSystem = g_graphicsEngine->createParticleEngine(D3DXVECTOR4(newPos, 1), D3DXQUATERNION(0, 0, 0, 1), D3DXVECTOR2(1.0f, 1.0f));

	// Play sound
	int sound;
	switch(random(0, 2))
	{
	case 0:
		sound = createSoundHandle("attacks/rangeAttack_0", false, true, _position);
		break;
	case 1:
		sound = createSoundHandle("attacks/rangeAttack_1", false, true, _position);
		break;
	case 2:
		sound = createSoundHandle("attacks/rangeAttack_2", false, true, _position);
		break;
	}
	playSound(sound);
	deactivateSound(sound);
}
Example #22
0
void		CBody::StopRotation(void)
{
	m_angularVelocity = D3DXQUATERNION(0.0f, 0.0f, 0.0f, 1.0f);
}
Example #23
0
	//---------------------------------------------------------------------
	D3DXQUATERNION MappingsD3D9::makeD3DXQuat(const vmQuat& q)
	{
		return D3DXQUATERNION(q.getX(), q.getY(), q.getZ(), q.getW());
	}
Example #24
0
 void  Camera::addOrientation(FLOAT x, FLOAT y, FLOAT z, FLOAT angle)
 {
     m_viewCacheValid = false;
     angle = -angle*0.5f;
     m_orientation *= D3DXQUATERNION(sin(angle)*x, sin(angle)*y, sin(angle)*z, cos(angle));
 }
void CObjCHAR_Collision2NPC::CollisionDetectionAvatar2Mob(CObjCHAR * pObjAvater)
{
	m_iObjTYPE = pObjAvater->Get_TYPE();

	if((m_iObjTYPE != OBJ_AVATAR) && (m_iObjTYPE != OBJ_USER) && (m_iObjTYPE != OBJ_CART) && (m_iObjTYPE != OBJ_CGEAR) && (m_iObjTYPE != OBJ_NRIDE))
		return;

	if (pObjAvater->GetPetMode() >= 0) { // if is on the PET, then ignore UpdateHeight
		return;
	}

	CObjCHAR *pObjectChar;
	HNODE hNPCBoneNode;
    	
	float fAvaterPositionXYZ[3];
	float fAvaterFrontPositionXYZ[3];
	float fPreAvaterRotaitonWXYZ[4];
	float fPreAvaterPositionXYZ[3];
	float fPreAvaterFrontPositionXYZ[3];

	float fBoneRotationWXYZ[4];
	float fBonePositionXYZ[3];
	float fPreBoneRotaitonWXYZ[4];
	float fPreBonePositionXYZ[3];

    D3DXVECTOR4 vlocalPos, vWorldPos;
    D3DXMATRIX boneModelM, bonePreModelM, invBonePreModelM;
	D3DXMATRIX boneModelRotationM; 
	
	Initialize(pObjAvater);
	
	::getPosition(m_hNodeModel, fAvaterPositionXYZ);
	fAvaterFrontPositionXYZ[0] = fAvaterPositionXYZ[0] + m_vLocalCollisionPoint.x;
	fAvaterFrontPositionXYZ[1] = fAvaterPositionXYZ[1] + m_vLocalCollisionPoint.y;
	fAvaterFrontPositionXYZ[2] = fAvaterPositionXYZ[2] + m_vLocalCollisionPoint.z;

	classDLLNODE< int > *pNode;
	pNode = g_pObjMGR->m_CharLIST.GetHeadNode ();
	
	while( pNode ) 
	{
		if ( g_pObjMGR->m_pOBJECTS[ pNode->DATA ] ) 
		{			
			if (g_pObjMGR->m_pOBJECTS[ pNode->DATA ]) {

				if(g_pObjMGR->m_pOBJECTS[ pNode->DATA ]->IsNPC())
				{
					pObjectChar = (CObjCHAR*)g_pObjMGR->m_pOBJECTS[ pNode->DATA ];
					if(pObjectChar->m_bCollisionOnOff)
					{
						hNPCBoneNode = ::getBone(pObjectChar->GetZMODEL(), pObjectChar->m_iCollisionBoneIndex);
						getRotationQuad(hNPCBoneNode, fBoneRotationWXYZ);
						getPosition(hNPCBoneNode, fBonePositionXYZ);
						
						D3DXMatrixRotationQuaternion(&boneModelM, &D3DXQUATERNION(fBoneRotationWXYZ[1], fBoneRotationWXYZ[2], fBoneRotationWXYZ[3], fBoneRotationWXYZ[0]));
						boneModelM._41 = fBonePositionXYZ[0];	boneModelM._42 = fBonePositionXYZ[1];	boneModelM._43 = fBonePositionXYZ[2];

//						::InputSceneOBB2(fBonePositionXYZ, fBoneRotationWXYZ, pObjectChar->m_fCollisionBoxLength[0], pObjectChar->m_fCollisionBoxLength[1], pObjectChar->m_fCollisionBoxLength[2]);
//						::InputSceneSphere(fAvaterFrontPositionXYZ[0], fAvaterFrontPositionXYZ[1], fAvaterFrontPositionXYZ[2], 50.0f);
   										
						if(CollisionPosition2OBBOnOff(&boneModelM, pObjectChar->m_fCollisionBoxLength[0], pObjectChar->m_fCollisionBoxLength[1], pObjectChar->m_fCollisionBoxLength[2], &D3DXVECTOR3(fAvaterFrontPositionXYZ[0], fAvaterFrontPositionXYZ[1], fAvaterFrontPositionXYZ[2])))
						{
							::getPrevPosition (hNPCBoneNode, fPreBonePositionXYZ);
							::getPrevRotation (hNPCBoneNode, fPreBoneRotaitonWXYZ);

							::getPrevPosition (m_hNodeModel, fPreAvaterPositionXYZ);
							::getPrevRotation (m_hNodeModel, fPreAvaterRotaitonWXYZ);
							
							fAvaterFrontPositionXYZ[0] = fPreAvaterPositionXYZ[0] + m_vLocalCollisionPoint.x;
							fAvaterFrontPositionXYZ[1] = fPreAvaterPositionXYZ[1] + m_vLocalCollisionPoint.y;
							fAvaterFrontPositionXYZ[2] = fPreAvaterPositionXYZ[2] + m_vLocalCollisionPoint.z;
							
							
							if(CollisionPosition2OBBOnOff(&boneModelM, pObjectChar->m_fCollisionBoxLength[0], pObjectChar->m_fCollisionBoxLength[1], pObjectChar->m_fCollisionBoxLength[2], &D3DXVECTOR3(fAvaterFrontPositionXYZ[0], fAvaterFrontPositionXYZ[1], fAvaterFrontPositionXYZ[2])))
							{
								D3DXVECTOR3 vContactPositon;
								CollisionPosition2OBBResponse(&boneModelM, pObjectChar->m_fCollisionBoxLength[0], pObjectChar->m_fCollisionBoxLength[1], pObjectChar->m_fCollisionBoxLength[2], &D3DXVECTOR3(fAvaterFrontPositionXYZ[0], fAvaterFrontPositionXYZ[1], fAvaterFrontPositionXYZ[2]), &vContactPositon);

								fPreAvaterPositionXYZ[0] = vContactPositon.x - m_vLocalCollisionPoint.x;
								fPreAvaterPositionXYZ[1] = vContactPositon.y - m_vLocalCollisionPoint.y;
								fPreAvaterPositionXYZ[2] = vContactPositon.z - m_vLocalCollisionPoint.z;
										
							}
						
							
/*							fPreAvaterFrontPositionXYZ[0] = fPreAvaterPositionXYZ[0] + m_vLocalCollisionPoint.x;
                            fPreAvaterFrontPositionXYZ[1] = fPreAvaterPositionXYZ[1] + m_vLocalCollisionPoint.y;
							fPreAvaterFrontPositionXYZ[2] = fPreAvaterPositionXYZ[2] + m_vLocalCollisionPoint.z;
			
							
							D3DXMatrixRotationQuaternion(&bonePreModelM, &D3DXQUATERNION(fPreBoneRotaitonWXYZ[1], fPreBoneRotaitonWXYZ[2], fPreBoneRotaitonWXYZ[3], fPreBoneRotaitonWXYZ[0]));
						    bonePreModelM._41 = fPreBonePositionXYZ[0];	bonePreModelM._42 = fPreBonePositionXYZ[1];	bonePreModelM._43 = fPreBonePositionXYZ[2];
							
							::InputSceneSphere(m_vLocalCollisionPoint.x + fPreAvaterPositionXYZ[0], m_vLocalCollisionPoint.y + fPreAvaterPositionXYZ[1], m_vLocalCollisionPoint.z + fPreAvaterPositionXYZ[2], 50.0f);
   							
							D3DXVECTOR3 vContactPoint;							
							if(CollisionPosition2OBBOnOff(&bonePreModelM, pObjectChar->m_fCollisionBoxLength[0], pObjectChar->m_fCollisionBoxLength[1], pObjectChar->m_fCollisionBoxLength[2], &D3DXVECTOR3(fPreAvaterFrontPositionXYZ[0], fPreAvaterFrontPositionXYZ[1], fPreAvaterFrontPositionXYZ[2])))
							{
								if(ContactRay2OBBIn(&bonePreModelM, pObjectChar->m_fCollisionBoxLength[0], pObjectChar->m_fCollisionBoxLength[1], pObjectChar->m_fCollisionBoxLength[2], &vContactPoint))
								{
									fPreAvaterPositionXYZ[0] = vContactPoint.x;
									fPreAvaterPositionXYZ[1] = vContactPoint.y;
									fPreAvaterPositionXYZ[2] = vContactPoint.z;
								}
								else
								{
									assert(true);

								}
							}
												
							D3DXMatrixInverse(&invBonePreModelM, NULL, &bonePreModelM);
								
							boneModelRotationM = invBonePreModelM * boneModelM;
                                
							D3DXVec4Transform(&vWorldPos, &D3DXVECTOR4(fPreAvaterPositionXYZ[0], fPreAvaterPositionXYZ[1], fPreAvaterPositionXYZ[2], 1.0f), &boneModelRotationM);
						
							fPreAvaterPositionXYZ[0] = vWorldPos.x - m_vLocalCollisionPoint.x;
							fPreAvaterPositionXYZ[1] = vWorldPos.y - m_vLocalCollisionPoint.y;
							fPreAvaterPositionXYZ[2] = vWorldPos.z - m_vLocalCollisionPoint.z;

*/							
							if(true)
							{
								m_pObjAvater->Set_CurPOS(D3DXVECTOR3(fPreAvaterPositionXYZ[0], fPreAvaterPositionXYZ[1], fPreAvaterPositionXYZ[2]));
							
								if(m_iObjTYPE == OBJ_USER)
									g_pNet->Send_cli_CANTMOVE();
								else
								{
									if(m_iObjTYPE == OBJ_CGEAR||m_iObjTYPE ==OBJ_NRIDE)
									{
										CObjCastleGear* pCgear = (CObjCastleGear*)pObjAvater;
										CObjCHAR* pParent = pCgear->GetParent();
										
										if(pParent)
										{
											if( pParent->Get_TYPE() == OBJ_USER)
												g_pNet->Send_cli_CANTMOVE();
										}
									}
									else if(m_iObjTYPE == OBJ_CART)
									{
										CObjCART* pCart = (CObjCART*)pObjAvater;
										CObjCHAR* pParent = pCart->GetParent();
										if( pParent )
										{
											if( pParent->Get_TYPE() == OBJ_USER)
												g_pNet->Send_cli_CANTMOVE();
										}
									}

								}
								
								m_pObjAvater->SetCMD_STOP();
								setPositionVec3( m_hNodeModel, fPreAvaterPositionXYZ );
							}

							::setRotationQuat(m_hNodeModel, fPreAvaterRotaitonWXYZ); 
							::stopModelRotation(m_hNodeModel);

							if(m_iObjTYPE == OBJ_CGEAR||m_iObjTYPE == OBJ_NRIDE)
							{
								CObjCastleGear* pCgear = (CObjCastleGear*)pObjAvater;
								CObjCHAR* pParent = pCgear->GetParent();
								if( pParent )
								{
									pParent->Set_CurPOS( pObjAvater->Get_CurPOS() );
								}
							}
							else if(m_iObjTYPE == OBJ_CART)
							{
								CObjCART* pCart = (CObjCART*)pObjAvater;
								CObjCHAR* pParent = pCart->GetParent();
								if( pParent )
								{
									pParent->Set_CurPOS( pObjAvater->Get_CurPOS() );
								}

							}


						}
						
					}
                 
				}
			}			
		}

		pNode = g_pObjMGR->m_CharLIST.GetNextNode( pNode );
	} 
}
Example #26
0
void Mesh::ResetRotationAndScale()
{
	this->rotQuat = D3DXQUATERNION(0, 0, 0, 1);
	this->scale = D3DXVECTOR3(1, 1, 1);
	this->RecreateWorldMatrix();
}
void TargetAcquiredClientSkillEffect::update(float _dt)
{
	this->m_lifetime = this->m_lifetime - _dt;
	float speed = 4;

	if(this->m_lifetime <= 5 && !m_fire)
	{
		m_firePos.x += 0.5f;
		m_fire = g_graphicsEngine->createParticleEngine("HellFireTail", D3DXVECTOR4(m_firePos.toD3DXVector(), 1), D3DXQUATERNION(0, 0, 0, 1), D3DXVECTOR2(1, 1));
	}
	if(this->m_lifetime <= 3.0f && !m_fireTwo)
	{
		m_fireTwo = g_graphicsEngine->createParticleEngine("HellFireTail", D3DXVECTOR4(m_fireTwoPos.toD3DXVector(), 1), D3DXQUATERNION(0, 0, 0, 1), D3DXVECTOR2(1, 1));
	}
	if(this->m_lifetime <= 4.2f && !m_ice)
	{
		m_icePos.x -= 0.5f;
		m_ice = g_graphicsEngine->createParticleEngine("FrostTail", D3DXVECTOR4(m_icePos.toD3DXVector(), 1), D3DXQUATERNION(0, 0, 0, 1), D3DXVECTOR2(2, 2));
	}
	if(this->m_lifetime <= 2.3f && !m_lightning)
	{
		m_lightningPos.x += 0.5f;
		m_lightning = g_graphicsEngine->createParticleEngine("test3", D3DXVECTOR4(m_lightningPos.toD3DXVector(), 1), D3DXQUATERNION(0, 0, 0, 1), D3DXVECTOR2(1, 1));
	}


	if(m_fire)
	{
		m_firePos.y -= _dt*speed;
		m_fire->setPosition(m_firePos.toD3DXVector());
	}
	if(m_fireTwo)
	{
		m_fireTwoPos.y -= _dt*speed;
		m_fireTwo->setPosition(m_fireTwoPos.toD3DXVector());
	}
	if(m_ice)
	{
		m_icePos.y -= _dt*speed*2;
		m_ice->setPosition(m_icePos.toD3DXVector());
	}
	if(m_lightning)
	{
		m_lightningPos.y -= _dt*speed*2;
		m_lightning->setPosition(m_lightningPos.toD3DXVector());
	}
}
Example #28
0
VehiclePose* VehicleController::getVehiclePose()
{
	if(m_poseGiven)
		return m_vehiclePose;
	m_poseGiven = true;
	Mat backup;
	Vec3 wheelPos;
	NxWheelContactData dest;
	NxShape* cont;
	float contactPos;
	Vec3 suspensionTravel;
	/*CHASSIS*/
	Mat rot;
	worldMat(&m_vehiclePose->matChassis, Vec3(m_actor->getGlobalPosition().x, m_actor->getGlobalPosition().y, m_actor->getGlobalPosition().z), Vec3(0, 0, 0));
	D3DXMatrixRotationQuaternion(&rot, &D3DXQUATERNION(m_actor->getGlobalOrientationQuat().x, m_actor->getGlobalOrientationQuat().y, m_actor->getGlobalOrientationQuat().z, m_actor->getGlobalOrientationQuat().w));

	Vec3 cross;
	Mat chassisRot;
	D3DXVec3Cross(&cross, &Vec3(1, 0, 0), &m_vehicleParams->vecChassisForward);

	D3DXMatrixRotationAxis(&chassisRot, &cross, acos(D3DXVec3Dot(&Vec3(1, 0, 0), &m_vehicleParams->vecChassisForward)));
	m_vehiclePose->matChassis = chassisRot * rot * m_vehiclePose->matChassis;
	D3DXVec3TransformCoord(&m_forward, &Vec3(1, 0, 0), &rot);
	D3DXVec3TransformCoord(&m_left, &Vec3(0, 0, -1), &rot);
	D3DXVec3Normalize(&m_forward, &m_forward);
	D3DXVec3Normalize(&m_left, &m_left);


	ShapeUserData* sud;
	//Wheels

	//Front Left wheel

	
	Mat wheelRot;
	D3DXMatrixRotationYawPitchRoll(&wheelRot, m_vehicleParams->vecFrontLeftWheelRotation.y, m_vehicleParams->vecFrontLeftWheelRotation.x, m_vehicleParams->vecFrontLeftWheelRotation.z);
	sud = (ShapeUserData*)(m_wheelFrontLeft->userData);
	sud->wheelShapePose.getColumnMajor44((NxF32*)&m_vehiclePose->matFrontLeftWheel);
	m_vehiclePose->matFrontLeftWheel = wheelRot * m_vehiclePose->matFrontLeftWheel;

	wheelPos = getVehicleParams()->posFrontLeftWheel;
	D3DXVec3TransformCoord(&wheelPos, &wheelPos, &m_vehiclePose->matChassis);
	cont = m_wheelFrontLeft->getContact(dest);
	backup = m_vehiclePose->matChassis;
	backup._41 = 0;
	backup._42 = 0;
	backup._43 = 0;
	contactPos = dest.contactPosition;
	if(!cont)
		contactPos = m_wheelFrontLeft->getSuspensionTravel();
	else
		contactPos -= m_wheelFrontLeft->getRadius();
	suspensionTravel = Vec3(0, contactPos, 0);
	D3DXVec3TransformCoord(&suspensionTravel, &suspensionTravel, &backup);
	//if(dest.contactForce)
		wheelPos -= suspensionTravel;

	m_vehiclePose->matFrontLeftWheel._41 = wheelPos.x;
	m_vehiclePose->matFrontLeftWheel._42 = wheelPos.y;
	m_vehiclePose->matFrontLeftWheel._43 = wheelPos.z;

	//Front Right wheel

	D3DXMatrixRotationYawPitchRoll(&wheelRot, m_vehicleParams->vecFrontRightWheelRotation.y, m_vehicleParams->vecFrontRightWheelRotation.x, m_vehicleParams->vecFrontRightWheelRotation.z);
	sud = (ShapeUserData*)(m_wheelFrontRight->userData);
	sud->wheelShapePose.getColumnMajor44((NxF32*)&m_vehiclePose->matFrontRightWheel);
	m_vehiclePose->matFrontRightWheel = wheelRot * m_vehiclePose->matFrontRightWheel;

	wheelPos = getVehicleParams()->posFrontRightWheel;
	D3DXVec3TransformCoord(&wheelPos, &wheelPos, &m_vehiclePose->matChassis);
	cont = m_wheelFrontRight->getContact(dest);
	backup = m_vehiclePose->matChassis;
	backup._41 = 0;
	backup._42 = 0;
	backup._43 = 0;
	contactPos = dest.contactPosition;
	if(!cont)
		contactPos = m_wheelFrontRight->getSuspensionTravel();
	else
		contactPos -= m_wheelFrontRight->getRadius();
	suspensionTravel = Vec3(0, contactPos, 0);
	D3DXVec3TransformCoord(&suspensionTravel, &suspensionTravel, &backup);
	//if(dest.contactForce)
		wheelPos -= suspensionTravel;

	m_vehiclePose->matFrontRightWheel._41 = wheelPos.x;
	m_vehiclePose->matFrontRightWheel._42 = wheelPos.y;
	m_vehiclePose->matFrontRightWheel._43 = wheelPos.z;

	//Rear Left wheel
	
	D3DXMatrixRotationYawPitchRoll(&wheelRot, m_vehicleParams->vecRearLeftWheelRotation.y, m_vehicleParams->vecRearLeftWheelRotation.x, m_vehicleParams->vecRearLeftWheelRotation.z);
	sud = (ShapeUserData*)(m_wheelRearLeft->userData);
	sud->wheelShapePose.getColumnMajor44((NxF32*)&m_vehiclePose->matRearLeftWheel);
	m_vehiclePose->matRearLeftWheel = wheelRot * m_vehiclePose->matRearLeftWheel;

	wheelPos = getVehicleParams()->posRearLeftWheel;
	D3DXVec3TransformCoord(&wheelPos, &wheelPos, &m_vehiclePose->matChassis);
	cont = m_wheelRearLeft->getContact(dest);
	backup = m_vehiclePose->matChassis;
	backup._41 = 0;
	backup._42 = 0;
	backup._43 = 0;
	contactPos = dest.contactPosition;
	if(!cont)
		contactPos = m_wheelRearLeft->getSuspensionTravel();
	else
		contactPos -= m_wheelRearLeft->getRadius();
	suspensionTravel = Vec3(0, contactPos, 0);
	D3DXVec3TransformCoord(&suspensionTravel, &suspensionTravel, &backup);
	//if(dest.contactForce)
		wheelPos -= suspensionTravel;

	m_vehiclePose->matRearLeftWheel._41 = wheelPos.x;
	m_vehiclePose->matRearLeftWheel._42 = wheelPos.y;
	m_vehiclePose->matRearLeftWheel._43 = wheelPos.z;

	//Rear Right wheel
	
	D3DXMatrixRotationYawPitchRoll(&wheelRot, m_vehicleParams->vecRearRightWheelRotation.y, m_vehicleParams->vecRearRightWheelRotation.x, m_vehicleParams->vecRearRightWheelRotation.z);
	sud = (ShapeUserData*)(m_wheelRearRight->userData);
	sud->wheelShapePose.getColumnMajor44((NxF32*)&m_vehiclePose->matRearRightWheel);
	m_vehiclePose->matRearRightWheel = wheelRot * m_vehiclePose->matRearRightWheel;

	wheelPos = getVehicleParams()->posRearRightWheel;
	D3DXVec3TransformCoord(&wheelPos, &wheelPos, &m_vehiclePose->matChassis);
	cont = m_wheelRearRight->getContact(dest);
	backup = m_vehiclePose->matChassis;
	backup._41 = 0;
	backup._42 = 0;
	backup._43 = 0;
	contactPos = dest.contactPosition;
	if(!cont)
		contactPos = m_wheelRearRight->getSuspensionTravel();
	else
		contactPos -= m_wheelRearRight->getRadius();
	suspensionTravel = Vec3(0, contactPos, 0);
	D3DXVec3TransformCoord(&suspensionTravel, &suspensionTravel, &backup);
	//if(dest.contactForce)
		wheelPos -= suspensionTravel;

	m_vehiclePose->matRearRightWheel._41 = wheelPos.x;
	m_vehiclePose->matRearRightWheel._42 = wheelPos.y;
	m_vehiclePose->matRearRightWheel._43 = wheelPos.z;

	return m_vehiclePose;
}
SimonsEvilClientSkillEffect::SimonsEvilClientSkillEffect(unsigned int _masterId)
{
	m_masterId = _masterId;
	Entity* master = ClientEntityHandler::getEntity(_masterId);
	if(master)
	{
		m_timer = 0.0f;

		D3DXVECTOR3 newPos = D3DXVECTOR3(master->m_startPos.x, master->m_startPos.y, master->m_startPos.z);
		this->m_particleSystem = g_graphicsEngine->createParticleEngine("HealingAura", D3DXVECTOR4(newPos, 1), D3DXQUATERNION(0, 0, 0, 1), D3DXVECTOR2(1.0f, 1.0f));

		// Play sound
		int sound = createSoundHandle("skills/healing_aura.wav", false, true, master->m_startPos);
		playSound(sound);
		deactivateSound(sound);
	}
	else
	{
		m_timer = SimonsEvilEffect::LIFETIME;
		m_particleSystem = NULL;
	}
}
Example #30
0
void Tank::Update(Input* input, float time, QuadTree *m_QuadTree){
	int deltaX, deltaY;
	input->GetMouseDelta(deltaX, deltaY);
	
	m_tankState->SetTime(time);
	
	m_tankState->ApplyForce(D3DXVECTOR3(0.0f, 0.0f, forward));
	forward = 0;

	m_tankState->SetYaw(turn * time);
	yaw -= turn * time;	
	turn    = 0;

	
	D3DXVECTOR3 position = *getTankState()->GetPosition(), vgarbage, normal5;
	float height;	

	m_QuadTree->GetHeightAtPosition(position.x, position.z, height, normal5);
	float netforce = -0.00098f;
	float y = m_tankState->GetPosition()->y;
	if (y-(height+17) < 0) {
		netforce -= (y-(height+17)) * 0.000065f;
	}

	m_tankState->ApplyForce(D3DXVECTOR3(0,netforce,0));

	//m_turretState->SetPitch(deltaY*0.01f);*/

	//m_turretState->SetYaw(rotation);

	D3DXQUATERNION quat = *m_tankState->GetRotation();
	D3DXQUATERNION inverse;
	D3DXQuaternionInverse(&inverse, &quat);
	D3DXQUATERNION temp;
	D3DXVECTOR3 output;
	
	float garbage;

	temp = quat * D3DXQUATERNION(FRONTRIGHT.x, FRONTRIGHT.y, FRONTRIGHT.z, 0.0f) * inverse;
	D3DXQuaternionToAxisAngle(&temp, &output, &garbage);
	m_frontRight = *m_tankState->GetPosition() + output;

	temp = quat * D3DXQUATERNION(FRONTLEFT.x, FRONTLEFT.y, FRONTLEFT.z, 0.0f) * inverse;
	D3DXQuaternionToAxisAngle(&temp, &output, &garbage);
	m_frontLeft = *m_tankState->GetPosition() + output;

	temp = quat * D3DXQUATERNION(REARLEFT.x, REARLEFT.y, REARLEFT.z, 0.0f) * inverse;
	D3DXQuaternionToAxisAngle(&temp, &output, &garbage);
	m_rearLeft = *m_tankState->GetPosition() + output;

	temp = quat * D3DXQUATERNION(REARRIGHT.x, REARRIGHT.y, REARRIGHT.z, 0.0f) * inverse;
	D3DXQuaternionToAxisAngle(&temp, &output, &garbage);
	m_rearRight = *m_tankState->GetPosition() + output;

	temp = quat * D3DXQUATERNION(CENTER.x, CENTER.y, CENTER.z, 0.0f) * inverse;
	D3DXQuaternionToAxisAngle(&temp, &output, &garbage);
	m_center = *m_tankState->GetPosition() + output;

	// Get the height of the triangle that is directly underneath the given tank position.
	//result = m_QuadTree->GetHeightAtPosition(position.x, position.z, height, vgarbage);
	//if(result) {
		// If there was a triangle under the tank then position the tank just above it by one unit.
	//	getTankState()->SetPosition(D3DXVECTOR3(position.x,m_tankState->GetPosition()->y, position.z));
	//}

	int count = 5;
	//D3DXVECTOR3 normal1, normal2, normal3, normal4, normal5;
	//result = m_QuadTree->GetHeightAtPosition(m_frontRight.x, m_frontRight.z, height, normal1);
	//if(!result) {
	//	normal1 = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
	//	count--;
	//}

	//result = m_QuadTree->GetHeightAtPosition(m_frontLeft.x, m_frontLeft.z, height, normal2);
	//if(!result) {
	//	normal2 = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
	//	count--;
	//}

	//result = m_QuadTree->GetHeightAtPosition(m_rearRight.x, m_rearRight.z, height, normal3);
	//if(!result) {
	//	normal3 = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
	//	count--;
	//}

	//result = m_QuadTree->GetHeightAtPosition(m_rearLeft.x, m_rearLeft.z, height, normal4);
	//if(!result) {
	//	normal4 = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
	//	count--;
	//}

	//result = m_QuadTree->GetHeightAtPosition(m_center.x, m_center.z, height, normal5);
	//if(!result) {
	//	normal5 = D3DXVECTOR3(0.0f, 0.0f, 0.0f);
	//	count--;
	//}
		
	D3DXVECTOR3 line3;
	if (count > 0)
		line3 = normal5;
		//line3 = (normal1+normal2+normal3+normal4+normal5)/float(count);
	else
		line3 = *m_tankState->GetUp();

	float angle = acos(D3DXVec3Dot(&line3, m_tankState->GetUp()));// assume normalized vectors /(D3DXVec3Length(&line3)*D3DXVec3Length(m_tankState->getUp())));
	angle /= 15.0f;// * time;

	//if (angle > 0.015f)
	//{
		D3DXVECTOR3 cross;
		D3DXVec3Cross(&cross, &line3, m_tankState->GetUp());

		D3DXVec3Normalize(&cross, &cross);

		D3DXQUATERNION quaternion;
		D3DXQuaternionRotationAxis(&quaternion, &cross, -angle);
		m_tankState->multiplyOrientation(&quaternion);
	//}
	m_tankState->Update();




	D3DXQUATERNION orien;

	D3DXVECTOR3 slope, forward, turretProj;
	D3DXVec3Cross(&slope, m_tankState->GetUp(), &D3DXVECTOR3(0, 1, 0));
	D3DXVec3Normalize(&slope, &slope);
	D3DXVec3Cross(&forward, m_tankState->GetUp(), &slope);
	D3DXVec3Normalize(&forward, &forward);
	D3DXVec3Cross(&turretProj, m_tankState->GetUp(), m_turretState->GetForward());
	D3DXVec3Normalize(&turretProj, &turretProj);
	D3DXVec3Cross(&turretProj, m_tankState->GetUp(), &turretProj);
	D3DXVec3Normalize(&turretProj, &turretProj);

	float projangle = acos(abs(D3DXVec3Dot(&turretProj, &forward)));
	if (D3DXVec3Dot(&turretProj, &forward) < 0) projangle = float(D3DX_PI - projangle);

	float slopeangle = acos(abs(D3DXVec3Dot(&D3DXVECTOR3(0, 1, 0), &forward)));
	slopeangle = float(D3DX_PI/2 - slopeangle);

	float pitchOffset = (1 - cos(projangle)) * slopeangle;

	D3DXQuaternionRotationYawPitchRoll(&orien, yaw, pitch - pitchOffset, 0);
	orien = orien * *m_tankState->GetRotation();
	m_turretState->SetOrientation(&orien);
	m_turretState->Update();

	m_Bullet->Update(time);
}