Exemple #1
0
HRESULT Li_lstBtnSprite::fn_drawButton(LPD3DXSPRITE dxSpriteInterface)
{
	// Build our matrix to rotate, scale and position our sprite
	D3DXMATRIX mat;
	RECT srcRect;
	
	srcRect.left	= 0;
	srcRect.right	= m_Width;

	switch (m_direction)
	{
	case 0: // Down
		{
			// draw the selected button in the list
			srcRect.top		= m_Height / m_lstSize * m_curSelect;
			srcRect.bottom	= m_Height / m_lstSize * (m_curSelect + 1);
		} break;
	default: break;
	}

	D3DXVECTOR3 translation;
	translation.x = m_pos.x;
	translation.y = m_pos.y;
	translation.z = 0;

	// out, scaling centre, scaling rotation, scaling, rotation centre, rotation, translation
	D3DXMatrixTransformation(&mat, NULL, NULL, NULL, NULL, NULL, &translation);
	dxSpriteInterface->SetTransform(&mat);

	return dxSpriteInterface->Draw(m_dxTexture,&srcRect,NULL,NULL,0xFFFFFFFF);
}
Exemple #2
0
//--------------------------------------------------------
 void TSprite::RenderEx(	const RECT *pSrc, const D3DXVECTOR3 &inPos,
							const D3DXVECTOR3 &inScale, const D3DXVECTOR3 &inRotation,
							D3DXVECTOR3 *pCenter , const FLOAT inAlpha, const D3DCOLOR inColor)
 {
	// set color

	const D3DCOLOR COLOR = ((DWORD)(inAlpha*255.f) << 24) | 0x00FFFFFF;
	//const D3DCOLOR COLOR = ((DWORD)(inAlpha * 255.f) << 24 )| (inColor & 0x00FFFFFF);

	// rotation vector change to quaternion
	D3DXQUATERNION qt;
	
	D3DXQuaternionRotationYawPitchRoll(	&qt,
										D3DXToRadian(inRotation.y),
										D3DXToRadian(inRotation.x),
										D3DXToRadian(inRotation.z));
	
	// set matrix
	D3DXMATRIX mat;
	D3DXMatrixTransformation(&mat, NULL, NULL, &inScale, NULL, &qt, &inPos);
	FpD3DXSprite->SetTransform(&mat);

	// draw
	FpD3DXSprite->Draw( FpTexture9, pSrc, pCenter, NULL, COLOR);
 }
void CMovement::Update(void)
{
	CRotation*			pcRotation;
	CPosition*			pcPosition;
	SFloat3*			psPosition;
	SQuaternion*		psRotation;
	CTransformNode*		pcMatrix;

	if (miType == MT_PRS)
	{
		psRotation = NULL;
		if (mpcRotationAnimation)
		{
			pcRotation = (CRotation*)mpcRotationAnimation->Update();
			psRotation = pcRotation->GetRotation();
		}
		psPosition = NULL;
		if (mpcPositionAnimation)
		{
			pcPosition = (CPosition*)mpcPositionAnimation->Update();
			psPosition = pcPosition->GetPosition();
		}
		D3DXMatrixTransformation((D3DXMATRIX*)&mpsOutput->sD3DMatrix, NULL, NULL, NULL, NULL, (D3DXQUATERNION*)psRotation, (D3DXVECTOR3*)psPosition);
	}
	else if (miType = MT_Matrix)
	{
		pcMatrix = (CTransformNode*)mpcMatrixAnimation->Update();
		mpsOutput->sD3DMatrix = *pcMatrix->GetMatrix();
	}

	if (mpsOffset)
	{
		Float4x4Multiply(&mpsOutput->sD3DMatrix, &mpsOutput->sD3DMatrix, &mpsOffset->sD3DMatrix);
	}
}
Exemple #4
0
void AnimationNode::set_pos_rot_scale(const D3DXVECTOR3& pos, const D3DXQUATERNION& rot, const D3DXVECTOR3& scale)
{
  pos_ = pos;
  rot_ = rot;
  scale_ = scale;
  D3DXMatrixTransformation(&transform_, &kVec3Zero, &kQuatId, &scale, &kVec3Zero, &rot, &pos);
}
Exemple #5
0
void GESprite::render()
{
    sSprite->Begin(D3DXSPRITE_ALPHABLEND);

    D3DXVECTOR3 vSpriteCenter(vPosition.x + vCenter.x, vPosition.y + vCenter.y, vPosition.z + vCenter.z);
    D3DXMatrixTransformation(&mTransform, &vSpriteCenter, NULL, &vScale, &vSpriteCenter, &qRotation, NULL);

    sSprite->SetTransform(&mTransform);
    sSprite->Draw(sTexture, NULL, &vCenter, &vPosition, D3DCOLOR_ARGB(iOpacity, 0xFF, 0xFF, 0xFF));
    sSprite->End();
}
Exemple #6
0
void KG3DTransformation::UpdateTransformation()
{
	D3DXMatrixTransformation(&m_Matrix,
		&m_ScalingCenter,
		&m_ScalingRotation,
		&m_Scaling,
		&m_RotationCenter,
		&m_Rotation,
		&m_Translation);
    ASSERT_FLOAT_IS_VALIED(m_Matrix._11);
}
void cPlayerGauge::Update()
{
	D3DXMATRIXA16 matHpWorld, matManaWorld;

	D3DXMatrixTransformation(&matHpWorld, &D3DXVECTOR3(53, 12, 0), NULL, &D3DXVECTOR3(m_fEnergyWidth, 1.f, 1.f),
		NULL, NULL, &D3DXVECTOR3(53, 12, 0));

	D3DXMatrixTransformation(&matManaWorld, &D3DXVECTOR3(720, 630, 0), NULL, &D3DXVECTOR3(m_fManaWidth, 1.f, 1.f),
		NULL, NULL, &D3DXVECTOR3(720, 630, 0));

	m_pHpFrame->GetChild()[0]->SetWorld(&matHpWorld);
	m_pManaFrame->GetChild()[0]->SetWorld(&matManaWorld);

	if (m_pHpFrame)
	{
		m_pHpFrame->Update();
	}

	if (m_pManaFrame)
	{
		m_pManaFrame->Update();
	}
}
//----------------------------------------------------------------------------//
void Direct3D8GeometryBuffer::updateMatrix() const
{
    const D3DXVECTOR3 p(d_pivot.d_x, d_pivot.d_y, d_pivot.d_z);
    const D3DXVECTOR3 t(d_translation.d_x, d_translation.d_y, d_translation.d_z);

    D3DXQUATERNION r;
    D3DXQuaternionRotationYawPitchRoll(&r,
        D3DXToRadian(d_rotation.d_y),
        D3DXToRadian(d_rotation.d_x),
        D3DXToRadian(d_rotation.d_z));

    D3DXMatrixTransformation(&d_matrix, 0, 0, 0, &p, &r, &t);
    d_matrixValid = true;
}
void 
CCamera::SetViewQuaternion(const D3DXVECTOR3& _krvec3Position, const D3DXQUATERNION& _krquatRotation)
{
	m_vec3Position = _krvec3Position;

	D3DXMATRIX mat;
	D3DXMatrixRotationQuaternion(&mat, &_krquatRotation);

	D3DXVec3TransformCoord(&m_vec3Look, &g_atUpRightDirectionVecs[FACE_TOP].vec3Direction, &mat);
	D3DXVec3TransformCoord(&m_vec3Up, &g_atUpRightDirectionVecs[FACE_TOP].vec3Up, &mat);
	D3DXVec3TransformCoord(&m_vec3Right, &g_atUpRightDirectionVecs[FACE_TOP].vec3Right, &mat);

	D3DXMatrixTransformation(&m_matView, 0, 0, 0, 0, &_krquatRotation, &_krvec3Position);
	D3DXMatrixInverse(&m_matView, 0, &m_matView);
}
void GameObject::Move( float x, float y, float z )
{
	m_Position.x += x;
	m_Position.y += y;
	m_Position.z += z;

	D3DXMatrixTransformation( &m_Matrix, NULL, NULL, NULL, NULL, NULL, &m_Position );

	updateAABBBox();

	// update obb :: 회전이 없을땐 편하다
	m_OBBBox.m_CenterPos.x += x;
	m_OBBBox.m_CenterPos.y += y;
	m_OBBBox.m_CenterPos.z += z;
}
D3DXVECTOR3 PlayerCharacter::GetViewDirection()
{
	D3DXQUATERNION	qRotation;
	D3DXMATRIXA16 tempMatrix;

	D3DXMatrixIdentity( &tempMatrix );

	// rotation에서 쿼터니언 생성, yaw ptich roll 은 y, x, z 순서임
	D3DXQuaternionRotationYawPitchRoll( &qRotation, D3DXToRadian( m_Rotation.y ), D3DXToRadian( m_Rotation.x ), D3DXToRadian( m_Rotation.z ) );

	// matrix를 affine변환이 적용된 형태로 변환 - 생략 가능?
	D3DXMatrixTransformation( &tempMatrix, NULL, NULL, &m_Scale, NULL, &qRotation, &m_Position );

	return D3DXVECTOR3( tempMatrix._31, tempMatrix._32, tempMatrix._33 );
}
D3DXMATRIXA16 Transform::MatrixTransform()
{
	D3DXQUATERNION	qRotation;
	D3DXMATRIXA16	tempMatrix;

	D3DXMatrixIdentity( &tempMatrix );

	// rotation에서 쿼터니언 생성, yaw ptich roll 은 y, x, z 순서임
	D3DXQuaternionRotationYawPitchRoll( &qRotation, D3DXToRadian( m_Rotation.y ), D3DXToRadian( m_Rotation.x ), D3DXToRadian( m_Rotation.z ) );

	// matrix를 affine변환이 적용된 형태로 변환	
	D3DXMatrixTransformation( &tempMatrix, NULL, NULL, &m_Scale, NULL, &qRotation, &m_Position );

	return tempMatrix;
}
Exemple #13
0
//----------------------------------------------------------------------------//
void Direct3D9GeometryBuffer::updateMatrix() const
{
    const D3DXVECTOR3 p(d_pivot.d_x, d_pivot.d_y, d_pivot.d_z);
    const D3DXVECTOR3 t(d_translation.d_x, d_translation.d_y, d_translation.d_z);

    D3DXQUATERNION r;
    r.x = d_rotation.d_x;
    r.y = d_rotation.d_y;
    r.z = d_rotation.d_z;
    r.w = d_rotation.d_w;

    D3DXMatrixTransformation(&d_matrix, 0, 0, 0, &p, &r, &t);

    d_matrixValid = true;
}
Exemple #14
0
void Explosion::Activate(D3DXVECTOR3 &position, D3DCOLOR &colour)
{
	
	m_v3Position = position;
	m_d3cColour = colour;

	D3DXMatrixTransformation(&m_mWorld, NULL ,NULL, NULL, NULL, NULL, &m_v3Position);
	D3DXMatrixInverse(&m_mInvWorld,NULL, &m_mWorld);
	
	for(int i = 0; i < m_iMaxNumParticles; ++i)
	{

		m_vDeadParticles.push_back(&m_vParticles[i]);
		addParticle();
	}

	m_bActive = true;
}
Exemple #15
0
HRESULT Li_lstBtnSprite::fn_drawButtonList(LPD3DXSPRITE dxSpriteInterface)
{
	// Build our matrix to rotate, scale and position our sprite
	D3DXMATRIX mat;
	RECT srcRect;
	D3DXVECTOR3 translation;
	D3DCOLOR col;

	switch (m_direction)
	{
	case 0: // Down
		{
			// draw the list button separately
			for (int i = 0; i < m_lstSize; i++)
			{
				// draw the list at the different position
				srcRect.left	= 0;
				srcRect.right	= m_Width;
				srcRect.top		= m_Height / m_lstSize * i;
				srcRect.bottom	= m_Height / m_lstSize * (i + 1);

				translation.x	= m_pos.x;
				translation.y	= m_pos.y + m_Height / m_lstSize * (i + 1);
				translation.z = 0;

				if (i == m_curSelect)
					col = 0xFFFFFFFF;
				else
					col = 0x78787878;

				// out, scaling centre, scaling rotation, scaling, rotation centre, rotation, translation
				D3DXMatrixTransformation(&mat, NULL, NULL, NULL, NULL, NULL, &translation);
				dxSpriteInterface->SetTransform(&mat);
				dxSpriteInterface->Draw(m_dxTexture,&srcRect,NULL,NULL,col);
			}
		} break;
	default: break;
	}

	return S_OK;
}
D3DXMATRIX to_matrix(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);

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

  D3DXVECTOR3 d3d_pos((float)translation.x, (float)translation.y, (float)-translation.z);
  D3DXVECTOR3 d3d_scale((float)scale[0], (float)scale[1], (float)-scale[2]);
  D3DXQUATERNION d3d_rot((float)q_x, (float)q_y, (float)-q_z, (float)q_w);
  D3DXVECTOR3 kvtxZero(0,0,0);
  D3DXQUATERNION qtId;
  D3DXQuaternionIdentity(&qtId);

  D3DXMATRIX d3d_mtx;
  D3DXMatrixTransformation(&d3d_mtx, &kvtxZero, &qtId, &d3d_scale, &kvtxZero, &d3d_rot, &d3d_pos);
  return d3d_mtx;
}
Exemple #17
0
  ///////////////////
 // Button Sprite //
///////////////////
HRESULT Li_btnSprite::fn_drawButton(LPD3DXSPRITE dxSpriteInterface)
{
	// Build our matrix to rotate, scale and position our sprite
	D3DXMATRIX mat;
	RECT srcRect;

	srcRect.left	= 0;
	srcRect.right	= m_Width;

	switch (m_btnState)
	{
	case IDLE:
		{
			srcRect.top		= 0;
			srcRect.bottom	= m_Height / 3;
		} break;
	case PUSH:
		{
			srcRect.top		= m_Height / 3;
			srcRect.bottom	= m_Height / 3 * 2;
		} break;
	case PASS:
		{
			srcRect.top		= m_Height / 3 * 2;
			srcRect.bottom	= m_Height;
		} break;
	}

	D3DXVECTOR3 translation;
	translation.x = m_pos.x;
	translation.y = m_pos.y;
	translation.z = 0;

	// out, scaling centre, scaling rotation, scaling, rotation centre, rotation, translation
	D3DXMatrixTransformation(&mat, NULL, NULL, NULL, NULL, NULL, &translation);
	dxSpriteInterface->SetTransform(&mat);

	return dxSpriteInterface->Draw(m_dxTexture,&srcRect,NULL,NULL,0xFFFFFFFF);
}
Exemple #18
0
void CMatrix::SetTransformationMatrix(_In_ const CVector3& scale,
									  _In_ const CQuaternion& orientation,
									  _In_ const CVector3& translation)
{
	D3DXMatrixTransformation(&m_DXMatrix,NULL,NULL,&scale.GetD3DXVECTOR3(),NULL,&orientation.GetD3DXQUATERNION(),&translation.GetD3DXVECTOR3());
}
Exemple #19
0
/*************************************************************************
 * D3DXMatrixTransformation2D
 */
D3DXMATRIX* WINAPI D3DXMatrixTransformation2D(
    D3DXMATRIX *pout, CONST D3DXVECTOR2 *pscalingcenter,
    FLOAT scalingrotation, CONST D3DXVECTOR2 *pscaling,
    CONST D3DXVECTOR2 *protationcenter, FLOAT rotation,
    CONST D3DXVECTOR2 *ptranslation)
{
    D3DXQUATERNION rot, sca_rot;
    D3DXVECTOR3 rot_center, sca, sca_center, trans;

    if ( pscalingcenter )
    {
        sca_center.x=pscalingcenter->x;
        sca_center.y=pscalingcenter->y;
        sca_center.z=0.0f;
    }
    else
    {
        sca_center.x=0.0f;
        sca_center.y=0.0f;
        sca_center.z=0.0f;
    }

    if ( pscaling )
    {
        sca.x=pscaling->x;
        sca.y=pscaling->y;
        sca.z=0.0f;
    }
    else
    {
        sca.x=0.0f;
        sca.y=0.0f;
        sca.z=0.0f;
    }

    if ( protationcenter )
    {
        rot_center.x=protationcenter->x;
        rot_center.y=protationcenter->y;
        rot_center.z=0.0f;
    }
    else
    {
        rot_center.x=0.0f;
        rot_center.y=0.0f;
        rot_center.z=0.0f;
    }

    if ( ptranslation )
    {
        trans.x=ptranslation->x;
        trans.y=ptranslation->y;
        trans.z=0.0f;
    }
    else
    {
        trans.x=0.0f;
        trans.y=0.0f;
        trans.z=0.0f;
    }

    rot.w=cos(rotation/2.0f);
    rot.x=0.0f;
    rot.y=0.0f;
    rot.z=sin(rotation/2.0f);

    sca_rot.w=cos(scalingrotation/2.0f);
    sca_rot.x=0.0f;
    sca_rot.y=0.0f;
    sca_rot.z=sin(scalingrotation/2.0f);

    D3DXMatrixTransformation(pout, &sca_center, &sca_rot, &sca, &rot_center, &rot, &trans);

    return pout;
}
HRESULT InitScene()
{
	HRESULT hr;

	SetWindowText(hwnd, TITLE);

	MYVALID(D3DXLoadMeshFromX("../media/meshes/sky.X", D3DXMESH_MANAGED, device, NULL, NULL, NULL, NULL, &skymesh));
	MYVALID(D3DXLoadMeshFromX("../media/meshes/box.X", D3DXMESH_MANAGED, device, NULL, NULL, NULL, NULL, &mesh));
	MYVALID(D3DXCreateTextureFromFileA(device, "../media/textures/fire.png", &texture1));
	MYVALID(D3DXCreateTextureFromFileA(device, "../media/textures/stones.jpg", &texture2));
	MYVALID(D3DXCreateCubeTextureFromFileA(device, "../media/textures/sky4.dds", &skytex));
	MYVALID(device->CreateTexture(512, 512, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &text, NULL));

	MYVALID(DXCreateEffect("../media/shaders/skinning.fx", device, &effect));
	MYVALID(DXCreateEffect("../media/shaders/sky.fx", device, &skyeffect));

	system1.Initialize(device, 500);
	system1.ParticleTexture = texture1;

	// load dwarfs
	dwarfs[0].Effect = effect;
	dwarfs[0].Method = SM_Shader;
	dwarfs[0].Path = "../media/meshes/dwarf/";
	
	MYVALID(dwarfs[0].Load(device, "../media/meshes/dwarf/dwarf.X"));

	dwarfs[0].Clone(dwarfs[1]);
	dwarfs[0].Clone(dwarfs[2]);
	dwarfs[0].Clone(dwarfs[3]);
	dwarfs[0].Clone(dwarfs[4]);
	dwarfs[0].Clone(dwarfs[5]);

	D3DXVECTOR3 scale(0.1f, 0.1f, 0.1f);
	D3DXVECTOR3 trans;
	D3DXQUATERNION rot;

	// dwarf 0
	trans = D3DXVECTOR3(-1, 0, 1);

	D3DXQuaternionRotationYawPitchRoll(&rot, -0.785f, 0, 0);
	D3DXMatrixTransformation(&dwarfmatrices[0], NULL, NULL, &scale, NULL, &rot, &trans);

	// dwarf 1
	trans = D3DXVECTOR3(-1, 0, -1);

	D3DXQuaternionRotationYawPitchRoll(&rot, -2.356f, 0, 0);
	D3DXMatrixTransformation(&dwarfmatrices[1], NULL, NULL, &scale, NULL, &rot, &trans);

	// dwarf 2
	trans = D3DXVECTOR3(1, 0, -1);

	D3DXQuaternionRotationYawPitchRoll(&rot, 2.356f, 0, 0);
	D3DXMatrixTransformation(&dwarfmatrices[2], NULL, NULL, &scale, NULL, &rot, &trans);

	// dwarf 3
	trans = D3DXVECTOR3(1, 0, 1);

	D3DXQuaternionRotationYawPitchRoll(&rot, 0.785f, 0, 0);
	D3DXMatrixTransformation(&dwarfmatrices[3], NULL, NULL, &scale, NULL, &rot, &trans);

	// dwarf 4
	trans = D3DXVECTOR3(-0.2f, 0, -0.2f);

	D3DXQuaternionRotationYawPitchRoll(&rot, -1.57f, 0, 0);
	D3DXMatrixTransformation(&dwarfmatrices[4], NULL, NULL, &scale, NULL, &rot, &trans);

	// dwarf 5
	trans = D3DXVECTOR3(0.2f, 0, 0);

	D3DXQuaternionRotationYawPitchRoll(&rot, -1.57f, 0, 0);
	D3DXMatrixTransformation(&dwarfmatrices[5], NULL, NULL, &scale, NULL, &rot, &trans);

	// skins
	DwarfSkin(0, 1, 1, 3, 1, 1, 3, 0);
	DwarfSkin(1, 2, 0, 1, 3, 3, 1, 1);
	DwarfSkin(2, 3, 2, 2, 2, 1, 2, 3);
	DwarfSkin(3, 1, 3, 2, 1, 3, 0, 2);
	DwarfSkin(4, 1, 1, 3, 3, 2, 2, 1);
	DwarfSkin(5, 0, 0, 1, 2, 3, 0, 1);

	// 0, 1, 2 - dead
	// 3, 5 - stand
	// 4 - jump
	// 6 - cheer with weapon
	// 7 - cheer with one hand
	// 8 - cheer with both hands
	dwarfs[0].SetAnimation(6);
	dwarfs[1].SetAnimation(8);
	dwarfs[2].SetAnimation(7);
	dwarfs[3].SetAnimation(4);
	dwarfs[4].SetAnimation(2);
	dwarfs[5].SetAnimation(1);

	// other
	device->SetRenderState(D3DRS_LIGHTING, false);
	device->SetSamplerState(0, D3DSAMP_MINFILTER, D3DTEXF_LINEAR);
	device->SetSamplerState(0, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR);

	DXRenderText(HELP_TEXT, text, 512, 512);
	cameraangle = D3DXVECTOR2(0.785f, 0.785f);

	// sound
	if( SUCCEEDED(InitXAudio2()) )
	{
		firesound = streamer.LoadSound(xaudio2, "../media/sound/fire.ogg");

		// create streaming thread and load music
		worker.Attach<AudioStreamer>(&streamer, &AudioStreamer::Update);
		worker.Start();

		music = streamer.LoadSoundStream(xaudio2, "../media/sound/painkiller.ogg");
	}

	if( music )
	{
		music->GetVoice()->SetVolume(4);
		music->Play();
	}

	if( firesound )
	{
		firesound->GetVoice()->SetVolume(0.7f);
		firesound->Play();
	}

	return S_OK;
}