Пример #1
0
void CMyObject::setRotAngels(D3DXVECTOR3 rotAngels)
{
	D3DXMATRIX mtxRotX;
	D3DXMATRIX mtxRotY;
	D3DXMATRIX mtxRotZ;

	m_rotAngles = rotAngels;
	D3DXMatrixRotationX(&mtxRotX,m_rotAngles.x);
	D3DXMatrixRotationY(&mtxRotY,m_rotAngles.y);
	D3DXMatrixRotationZ(&mtxRotZ,m_rotAngles.z);
	m_mtxRot = mtxRotX * mtxRotY * mtxRotZ;
}
Пример #2
0
void AmjuGLDX9::RotateX(float degs)
{
  AMJU_CALL_STACK;

  Assert(s_matrixMode == AmjuGL::AMJU_MODELVIEW_MATRIX);

  D3DXMATRIX m;
  D3DXMatrixIdentity(&m);
  D3DXMatrixRotationX(&m, D3DXToRadian(degs)); 
  g_matrixStack->MultMatrixLocal( &m);
  dd->SetTransform(D3DTS_WORLD, g_matrixStack->GetTop());
}
Пример #3
0
	Node::Node()
	{
		D3DXMatrixTranslation( &this->matTranslate,0,0,0 );
		D3DXMatrixTranslation( &this->matTranslate_Relative,0,0,0 );
		D3DXMatrixRotationX( &this->matRotateX, 0 );        // Pitch
		D3DXMatrixRotationY( &this->matRotateY, 0 );        // Yaw
		D3DXMatrixRotationZ( &this->matRotateZ, 0 );        // Roll
		D3DXMatrixScaling( &this->matScale,1,1,1 );
		
		this->hasParent = false;
		this->hasChildren = false;
	}
Пример #4
0
//-----------------------------------------------------------------------------
// Desc: 设置世界矩阵
//-----------------------------------------------------------------------------
VOID SetupWorldMatrice()
{
	//建立一个绕X轴动态旋转的世界矩阵
	D3DXMATRIX matWorld;
	UINT  iTime  = timeGetTime() % 1000;
	FLOAT fAngle = iTime * (2.0f * D3DX_PI) / 1000.0f;
	D3DXMatrixIdentity( &matWorld );
	D3DXMatrixRotationX( &matWorld, fAngle );

	//设置世界矩阵
	g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
}
Пример #5
0
void cPart::Update(float delta, D3DXMATRIXA16* pmatParentWorld){
	
	
	if (m_eState == E_STATE_WALK){
		if (m_epart != PT_fist){
			m_fAngle += m_fAngleSpeed * delta;
			D3DXMatrixRotationX(&m_matRot, m_fAngle);
		}
	}
	else if (m_eState == E_STATE_ATTACK && m_epart == PT_arm_right){
		m_fXAngle -= D3DXToRadian(-360) * delta;
		D3DXMatrixRotationX(&m_matRot, m_fXAngle);
	}
	else {
		D3DXMatrixRotationX(&m_matRot, m_fAngle);
	}

	if (m_fAngle < -D3DX_PI / 4.0f)
	{
		m_fAngle = (-D3DX_PI / 4.0f);
		m_fAngleSpeed *= -1;
	}

	if (m_fAngle > D3DX_PI / 4.0f)
	{
		m_fAngle = (D3DX_PI / 4.0f);
		m_fAngleSpeed *= -1;
	}
	

	m_matWorldTM = m_matPrevT * m_matRot * m_matPostT;
	if (pmatParentWorld)
	{
		m_matWorldTM = m_matWorldTM * (*pmatParentWorld);
	}

	for each (auto p in m_vecChildren)
	{
		p->Update(delta, &m_matWorldTM);
	}
Пример #6
0
// Sets the object's rotation.
void SceneObject::SetRotation( float x, float y, float z )
{
	m_rotation.x = x;
	m_rotation.y = y;
	m_rotation.z = z;

	D3DXMATRIX rotationX, rotationY;
	D3DXMatrixRotationX( &rotationX, m_rotation.x );
	D3DXMatrixRotationY( &rotationY, m_rotation.y );
	D3DXMatrixRotationZ( &m_rotationMatrix, m_rotation.z );
	D3DXMatrixMultiply( &m_rotationMatrix, &m_rotationMatrix, &rotationX );
	D3DXMatrixMultiply( &m_rotationMatrix, &m_rotationMatrix, &rotationY );
}
/**-----------------------------------------------------------------------------
 * 애니메이션 설정
 *------------------------------------------------------------------------------
 */
VOID Animate()
{
	D3DXMATRIXA16	matX;
	D3DXMATRIXA16	matY;

	D3DXMatrixRotationX( &matX, g_xRot );
	D3DXMatrixRotationY( &matY, g_yRot );
	g_matWorld = matX * matY;
	g_pd3dDevice->SetTransform( D3DTS_WORLD, &g_matWorld ); /// 디바이스에 월드행렬 설정
	SetupLights();
	SetupPS();
	LogFPS();						// 로깅
}
Пример #8
0
void SetupRotation()
{
	D3DXMATRIX matWorld, matWorldX, matWorldY, matWorldZ;

	D3DXMatrixRotationX(&matWorldX, timeGetTime()/400.0f);
	D3DXMatrixRotationY(&matWorldY, timeGetTime()/400.0f);
	D3DXMatrixRotationZ(&matWorldZ, timeGetTime()/400.0f);

	D3DXMatrixMultiply(&matWorld, &matWorldX, &matWorldY);
	D3DXMatrixMultiply(&matWorld, &matWorld, &matWorldZ);

	g_pD3DDevice->SetTransform(D3DTS_WORLD, &matWorld);
}
Пример #9
0
//----------------------------------------------------------------
void Renderer::rotateX (float fAngle)
{
	D3DXMATRIX kTempMatrix;

	// generate translation matrix
	D3DXMatrixRotationX(&kTempMatrix, fAngle);

	// convert from MatrixMode to D3DTRANSFORMSTATETYPE
	D3DTRANSFORMSTATETYPE eMatMode = static_cast<D3DTRANSFORMSTATETYPE>(m_eCurrentMatMode);

	// set the matrix
	m_pkDevice->MultiplyTransform(eMatMode, &kTempMatrix);
}
Пример #10
0
/// Draws a sphere of a given radius at a given place.
/// Very good for bounding spheres
void QDrawSphere(IDirect3DDevice9* pDev,const D3DXVECTOR3& pos,float radius,D3DCOLOR col)
{
	const int STEPS=32;
	D3DXVECTOR3 points[STEPS+1];
	pDev->SetMaterial(&InitMtrl(BLACK_COL,BLACK_COL,BLACK_COL,col,0));	// set colour
	pDev->SetTexture(0,NULL);	// no texture
	pDev->SetFVF(D3DFVF_XYZ);

	// xz loop
	for(int i=0;i<STEPS+1;i++)
	{
		float ang=D3DX_PI*2*i/STEPS;
		points[i].x=sin(ang);
		points[i].y=0;
		points[i].z=cos(ang);
	}
	D3DXMATRIX trans,rot,scale;
	D3DXMatrixTranslation(&trans,pos.x,pos.y,pos.z);
	D3DXMatrixScaling(&scale,radius,radius,radius);
	D3DXMatrixRotationX(&rot,D2R(0));
	pDev->SetTransform(D3DTS_WORLD,&(scale*rot*trans));	
	pDev->DrawPrimitiveUP(D3DPT_LINESTRIP,         //PrimitiveType
							 STEPS,              //PrimitiveCount
							 points,            //pVertexStreamZeroData
							 sizeof(D3DXVECTOR3));   //VertexStreamZeroStride
	D3DXMatrixRotationX(&rot,D2R(90));
	pDev->SetTransform(D3DTS_WORLD,&(scale*rot*trans));	
	pDev->DrawPrimitiveUP(D3DPT_LINESTRIP,         //PrimitiveType
							 STEPS,              //PrimitiveCount
							 points,            //pVertexStreamZeroData
							 sizeof(D3DXVECTOR3));   //VertexStreamZeroStride
	D3DXMatrixRotationZ(&rot,D2R(90));
	pDev->SetTransform(D3DTS_WORLD,&(scale*rot*trans));	
	pDev->DrawPrimitiveUP(D3DPT_LINESTRIP,         //PrimitiveType
							 STEPS,              //PrimitiveCount
							 points,            //pVertexStreamZeroData
							 sizeof(D3DXVECTOR3));   //VertexStreamZeroStride
}
Пример #11
0
//--------------------------------------------------------------------------------------
// Handle updates to the scene.  This is called regardless of which D3D API is used
//--------------------------------------------------------------------------------------
void CALLBACK OnFrameMove( double fTime, float fElapsedTime, void* pUserContext )
{
    // Update the camera's position based on user input 
    g_Camera.FrameMove( fElapsedTime );

    if( g_bSpinning )
        D3DXMatrixRotationY( &g_World, 60.0f * DEG2RAD((float)fTime) );
    else
        D3DXMatrixRotationY( &g_World, DEG2RAD( 180.0f ) );

    D3DXMATRIX mRot;
    D3DXMatrixRotationX( &mRot, DEG2RAD( -90.0f ) );
    g_World = mRot * g_World;
}
Пример #12
0
void PRTHierarchy::UpdateTransformationMatrices() {
	D3DXMATRIX rotX, rotY, rotYInverse;
	D3DXMatrixRotationY(&rotY, mRotationY);
	D3DXMatrixRotationX(&rotX, mRotationX);
	
	D3DXMatrixIdentity(&mWorldTransform);

	D3DXMATRIX rot = rotX * rotY;
	mWorldTransform = mScaleMatrix * rot;
	mRenderMesh->SetWorldTransformation(mWorldTransform);
	mApproxMesh->SetWorldTransformation(mWorldTransform);
	mRenderMesh->SetRotationMatrix(rot);
	mApproxMesh->SetRotationMatrix(rot);
}
Пример #13
0
void xForm::SetCameraPosition(const xVec3& origin, const xMat3& axis)
{
  xMat4 m(axis, origin); // camera to world space
  m.InverseSelf(); // world to camera space
  D3DXMATRIX mat = dxMat(m), out, out2;

  D3DXMatrixRotationZ(&out, DEG2RAD(90));
  D3DXMatrixMultiply(&out2, &mat, &out); // result in out2

  D3DXMatrixRotationX(&out, DEG2RAD(-90));
  D3DXMatrixMultiply(&mat, &out2, &out); // result in mat

  m_pd3dDevice->SetTransform(D3DTS_VIEW, &mat);
}
Пример #14
0
void Chunk::Render(Camera* p_pCamera)
{
	D3DXMATRIX _Mat = p_pCamera->GetViewMatrix() * p_pCamera->GetProjMatrix();

	D3D11_MAPPED_SUBRESOURCE _CBMSR;

	m_pDevCon->Map(m_pConstantBufferMatrix, 0, D3D11_MAP::D3D11_MAP_WRITE_DISCARD, 0, &_CBMSR);
	memcpy(_CBMSR.pData, &_Mat, sizeof(D3DXMATRIX));
	m_pDevCon->Unmap(m_pConstantBufferMatrix, 0);

	D3DXMATRIX _SunRotation;
	D3DXMatrixRotationX(&_SunRotation, TimeSinceStart);

	ChunkConstantBuffer _CCB;

	D3DXVECTOR3 _LightDir(2, -3, 1);
	D3DXVec3Normalize(&_LightDir, &_LightDir);

	_CCB.LightDir = D3DXVECTOR4(_LightDir.x, _LightDir.y, _LightDir.z, 0);

	D3DXVec4Transform(&_CCB.LightDir, &_CCB.LightDir, &_SunRotation);

	float Intensity = 1;
	_CCB.RGBLightColor_ALightIntensity = D3DXVECTOR4(1 * Intensity, 1 * Intensity, 0.7f * Intensity, 0);

	m_pDevCon->Map(m_pConstantBufferLight, 0, D3D11_MAP::D3D11_MAP_WRITE_DISCARD, 0, &_CBMSR);
	memcpy(_CBMSR.pData, &_CCB, sizeof(ChunkConstantBuffer));
	m_pDevCon->Unmap(m_pConstantBufferLight, 0);



	UINT stride = sizeof(ChunkVertexStruct);
	UINT offset = 0;

	m_pDevCon->IASetIndexBuffer(m_pIndexBuffer, DXGI_FORMAT::DXGI_FORMAT_R32_UINT, 0);
	m_pDevCon->IASetVertexBuffers(0, 1, &m_pVertexBuffer, &stride, &offset);
	m_pDevCon->IASetInputLayout(m_pInputLayout);
	m_pDevCon->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY::D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);

	m_pDevCon->VSSetShader(m_pVertexShader, nullptr, 0);
	m_pDevCon->VSSetConstantBuffers(0, 1, &m_pConstantBufferMatrix);

	m_pDevCon->PSSetShader(m_pPixelShader, nullptr, 0);
	m_pDevCon->PSSetShaderResources(0, 1, &m_pDirtTexture);
	m_pDevCon->PSSetConstantBuffers(0, 1, &m_pConstantBufferLight);


	m_pDevCon->DrawIndexed(FaceCount * 2 * 3, 0, 0);

}
Пример #15
0
bool Sample::Frame() {
	D3DXMATRIX matRotation, matScale;
	D3DXMatrixScaling(&matScale, 100, 100, 100);
	D3DXMatrixRotationX(&matRotation, D3DXToRadian(90.0f));
	m_matWorld[2] = matScale * matRotation;

	if (I_Input.m_DIMouseState.rgbButtons[0])
	{
		m_vDir.y += m_fSpeed * g_fSecPerFrame * I_Input.m_DIMouseState.lX;
		m_vDir.x += m_fSpeed * g_fSecPerFrame * I_Input.m_DIMouseState.lY;
	}
	if (I_Input.KeyCheck(DIK_SPACE))
	{
		m_fSpeed += g_fSecPerFrame * 20.0f;
		if (m_fSpeed >= 50.0f) m_fSpeed = 50.0f;
	}
	else
	{
		m_fSpeed -= g_fSecPerFrame * 10.0f;
		if (m_fSpeed <= 5.0f) m_fSpeed = 5.0f;
	}
	if (I_Input.KeyCheck(DIK_W))
	{
		m_Camera.MoveLook(g_fSecPerFrame* m_fSpeed);
	}
	if (I_Input.KeyCheck(DIK_S))
	{
		m_Camera.MoveLook(-g_fSecPerFrame* m_fSpeed);
	}
	m_vDir.w = 0.0f;
	if (I_Input.m_DIMouseState.lZ != 0)
	{
		m_vDir.w = m_fSpeed * g_fSecPerFrame * I_Input.m_DIMouseState.lZ;
	}


	if (I_Input.KeyCheck(DIK_F4))
	{
		m_bCameraType = !m_bCameraType;
	}
	if (m_bCameraType)
	{
		m_Camera.Update(m_vDir);
	}
	else
	{
		m_Camera.Frame(m_vDir);
	}
	return true;
};
Пример #16
0
void CAnimationView::Update(void)
{
	_matrix			matScale, matRotX, matRotY, matRotZ, matTrans;

	D3DXMatrixScaling(&matScale, m_vScale.x, m_vScale.y, m_vScale.z);
	D3DXMatrixRotationX(&matRotX, m_fAngle[ANGLE_X]);
	D3DXMatrixRotationY(&matRotY, m_fAngle[ANGLE_Y]);
	D3DXMatrixRotationZ(&matRotZ, m_fAngle[ANGLE_Z]);

	D3DXMatrixTranslation(&matTrans, m_vPosition.x, m_vPosition.y, m_vPosition.z);

	m_matWorld = matScale * matRotX * matRotY * matRotZ * matTrans;
	Engine::GetGraphicDev() ->SetTransform(D3DTS_WORLD , &m_matWorld);
}
Пример #17
0
int CInfo::Update(void)
{
	D3DXMATRIX	matScale, matRotX, matRotY, matRotZ, matTrans;

	//½÷����°ר
	D3DXMatrixScaling(&matScale, m_vScale.x, m_vScale.y, m_vScale.z);
	D3DXMatrixRotationX(&matRotX, m_fAngle[ANGLE_X]);
	D3DXMatrixRotationY(&matRotY, m_fAngle[ANGLE_Y]);
	D3DXMatrixRotationZ(&matRotZ, m_fAngle[ANGLE_Z]);
	D3DXMatrixTranslation(&matTrans, m_vPos.x, m_vPos.y, m_vPos.z);

	m_matWorld = matScale * matRotX * matRotY * matRotZ * matTrans;
	return 0;
}
Пример #18
0
void CTourist::UpdateWorldMatrix()
{	
	D3DXMATRIX mRot, mRotX, mRotZ, mRotY, mTrans, mat;
	D3DXMatrixRotationX(&mRotX, m_vAngle.x);
	D3DXMatrixRotationY(&mRotY, m_vAngle.y);
	D3DXMatrixRotationZ(&mRotZ, m_vAngle.z);
	D3DXMatrixMultiply(&mRot, &mRotY, &mRotX);
	D3DXMatrixMultiply(&mRot, &mRotZ, &mRot);
	D3DXMatrixIdentity(&mat);
	D3DXMatrixMultiply(&m_mOrientation, &mat, &mRot);
	D3DXMatrixTranslation(&mTrans, m_vPos.x, m_vPos.y, m_vPos.z);	
	D3DXMatrixMultiply(&m_mOrientation, &m_mOrientation, &mTrans);

}
Пример #19
0
/////////////////////////////////////
// Name:	
// Purpose:	
// Output:	
// Return:	
/////////////////////////////////////
PUBLIC void OBJRotX(hOBJ obj, float radian)
{
	obj->wrldRot[eX] += radian;

	D3DXMATRIX mtxR;

	//set the rotation matrix
	D3DXMatrixRotationX(&mtxR, radian);
	D3DXMatrixMultiply(&obj->wrldMtx.mtxRot,&obj->wrldMtx.mtxRot,&mtxR);

	//set the world matrix
	D3DXMatrixMultiply(&obj->wrldMtx.mtxWrld,&obj->wrldMtx.mtxScale,&obj->wrldMtx.mtxRot);
	D3DXMatrixMultiply(&obj->wrldMtx.mtxWrld,&obj->wrldMtx.mtxWrld,&obj->wrldMtx.mtxTrans);
}
Пример #20
0
	void Node::Rotate(float x, float y, float z)
	{
		D3DXMATRIX rotationX;
		D3DXMATRIX rotationY;
		D3DXMATRIX rotationZ;

		D3DXMatrixRotationX( &rotationX, x );        // Pitch
		D3DXMatrixRotationY( &rotationY, y );        // Yaw
		D3DXMatrixRotationZ( &rotationZ, z );        // Roll

		this->matRotateX *= rotationX;
		this->matRotateY *= rotationY;
		this->matRotateZ *= rotationZ;
	}
Пример #21
0
//-----------------------------------------------------------------------------
// Name: SetupMatrices()
// Desc: Sets up the world, view, and projection transform matrices.
//-----------------------------------------------------------------------------
VOID SetupMatrices()
{
    HRESULT hr;

    if( 0 == g_StartTime )
    {
        srand( timeGetTime());
        g_StartTime = (DWORD)(timeGetTime()/2000.0f);
    }

    // For our world matrix, we will just leave it as the identity
    D3DXMATRIX matWorld;
    D3DXMatrixIdentity( &matWorld );
    D3DXMatrixRotationX( &matWorld, (FLOAT)(timeGetTime()/2000.0f - g_StartTime + D3DX_PI/2.0));

    hr = g_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
    if (FAILED(hr))                                      
    {
        Msg(TEXT("Could not set D3DTS_WORLD transform!  hr=0x%x"), hr);
    }

    // Set up our view matrix. A view matrix can be defined given an eye point,
    // a point to look at, and a direction for which way is up. Here, we set the
    // eye five units back along the z-axis and up three units, look at the
    // origin, and define "up" to be in the y-direction.
    D3DXMATRIX matView;
    D3DXMatrixLookAtLH( &matView, &D3DXVECTOR3( 0.0f, 3.0f,-3.0f ),
                                  &D3DXVECTOR3( 0.0f, 0.0f, 0.0f ),
                                  &D3DXVECTOR3( 0.0f, 1.0f, 0.0f ) );
    hr = g_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
    if (FAILED(hr))                                      
    {
        Msg(TEXT("Could not set D3DTS_VIEW transform!  hr=0x%x"), hr);
    }

    // For the projection matrix, we set up a perspective transform (which
    // transforms geometry from 3D view space to 2D viewport space, with
    // a perspective divide making objects smaller in the distance). To build
    // a perpsective transform, we need the field of view (1/4 pi is common),
    // the aspect ratio, and the near and far clipping planes (which define at
    // what distances geometry should be no longer be rendered).
    D3DXMATRIX matProj;
    D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 100.0f );

    hr = g_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
    if (FAILED(hr))                                      
    {
        Msg(TEXT("Could not set D3DTS_PROJECTION transform!  hr=0x%x"), hr);
    }
}
void Cube_Textured::Update()
{	
	float tick = (float)GameManager::GetTick();
	jumpTime += tick;

	if ((GetAsyncKeyState('A') & 0x8000) != 0)
	{
		rotationAxisY -= (rotationSpeed * tick);
	}
	else if ((GetAsyncKeyState('D') & 0x8000) != 0)
	{
		rotationAxisY += (rotationSpeed * tick);
	}
	if ((GetAsyncKeyState('W') & 0x8000) != 0)
	{
		position += (direction * moveSpeed * tick);
	}
	else if ((GetAsyncKeyState('S') & 0x8000) != 0)
	{
		position -= (direction * moveSpeed * tick);
	}
	if ((GetAsyncKeyState(VK_SPACE) & 0x8000) != 0 && isJumping == false )
	{
		isJumping = true;
		jumpTime = 0.0f;
	}

	D3DXMATRIX rotX, rotY, move;
	D3DXMatrixRotationX(&rotX, rotationAxisX);
	D3DXMatrixRotationY(&rotY, rotationAxisY);
		
	world = rotX * rotY;

	D3DXVECTOR3 baseDirection(0, 0, 1);
	D3DXVec3TransformCoord(&direction, &baseDirection, &world);

	if (isJumping)
	{
		position.y = jumpPower * jumpTime - 4.9f/*0.5f * ( 9.8f ) */* jumpTime * jumpTime;
		if (position.y < 0.0)
		{
			isJumping = false;
			position.y = 0.0f;
		}
	}

	D3DXMatrixTranslation(&move, position.x, position.y, position.z);
	world *= move;
}
Пример #23
0
bool graphics::RenderSceneToTexTure2()
{
    D3DXMATRIX worldMatrix, lightViewMatrix, lightProjectionMatrix, translateMatrix,tempA,tempB,tempC;
    float posX, posY, posZ;


    // Set the render target to be the render to texture.
    _renderTexture2->SetRenderTarget(_D3D->GetDevice());

    // Clear the render to texture.
    _renderTexture2->ClearRenderTarget(_D3D->GetDevice(), 0.0f, 0.0f, 0.0f, 1.0f);

    // Generate the light view matrix based on the light's position.
    _light2->GenerateViewMatrix();

    // Get the world matrix from the d3d object.
    _D3D->GetWorldMatrix(worldMatrix);

    // Get the view and orthographic matrices from the light object.
    _light2->GetViewMatrix(lightViewMatrix);
    _light2->GetProjectionMatrix(lightProjectionMatrix);
    D3DXMatrixRotationY(&worldMatrix,_rotation1);
    // Setup the translation matrix for the cube model.
    _model2->RenderToGraphics(_D3D->GetDevice());
    _depthShader->Render(_D3D->GetDevice(), _model2->GetIndexCount(), worldMatrix, lightViewMatrix, lightProjectionMatrix);

    _D3D->GetWorldMatrix(worldMatrix);

    D3DXMatrixTranslation(&tempA,0.0f,1.0f,0.5f);
    D3DXMatrixRotationX(&tempB, 90.0f);

    D3DXMatrixMultiply(&worldMatrix,&tempA,&tempB);
    D3DXMatrixScaling(&tempC,2.0f,2.0f,2.0f);

    D3DXMatrixMultiply(&worldMatrix,&worldMatrix,&tempC);
    _model->RenderToGraphics(_D3D->GetDevice());
    _depthShader->Render(_D3D->GetDevice(), _model->GetIndexCount(), worldMatrix, lightViewMatrix, lightProjectionMatrix);

    // Render the cube model with the depth shader.


    // Reset the render target back to the original back buffer and not the render to texture anymore.
    _D3D->SetBackBufferRenderTarget();

    // Reset the viewport back to the original.
    _D3D->ResetViewport();

    return true;
}
Пример #24
0
//-------------------------------------------------------------
// Name: FrameMove()
// Desc: �� �����Ӹ��� ȣ���. �ִϸ��̼� ó���� ���
//-------------------------------------------------------------
HRESULT CMyD3DApplication::FrameMove()
{
	// UFO�� �����δ�
	m_pos.x = 1.5f*(FLOAT)cos(1.0f*this->m_fTime)+1.0f;
	m_pos.z = 1.5f*(FLOAT)sin(1.0f*this->m_fTime);
	m_pos.y = 1.3f;

	UpdateInput( &m_UserInput ); // �Էµ����� ����

	//---------------------------------------------------------
	// �Է¿� ���� ��ǥ�踦 �����Ѵ�
	//---------------------------------------------------------
	// ȸ��
    D3DXMATRIX matRotY;
    D3DXMATRIX matRotX;

    if( m_UserInput.bRotateLeft && !m_UserInput.bRotateRight )
        m_fWorldRotY += m_fElapsedTime;
    else
    if( m_UserInput.bRotateRight && !m_UserInput.bRotateLeft )
        m_fWorldRotY -= m_fElapsedTime;

    if( m_UserInput.bRotateUp && !m_UserInput.bRotateDown )
        m_fWorldRotX += m_fElapsedTime;
    else
    if( m_UserInput.bRotateDown && !m_UserInput.bRotateUp )
        m_fWorldRotX -= m_fElapsedTime;

    D3DXMatrixRotationX( &matRotX, m_fWorldRotX );
    D3DXMatrixRotationY( &matRotY, m_fWorldRotY );

    D3DXMatrixMultiply( &m_mWorld, &matRotY, &matRotX );
	
	//---------------------------------------------------------
	// ����� ����
	//---------------------------------------------------------
	// ��
    if( m_UserInput.bZoomIn && !m_UserInput.bZoomOut )
        m_fViewZoom += m_fElapsedTime;
    else if( m_UserInput.bZoomOut && !m_UserInput.bZoomIn )
        m_fViewZoom -= m_fElapsedTime;

    D3DXVECTOR3 vFromPt   = D3DXVECTOR3( 0.0f, 0.0f, -m_fViewZoom );
    D3DXVECTOR3 vLookatPt = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
    D3DXVECTOR3 vUpVec    = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
    D3DXMatrixLookAtLH( &m_mView, &vFromPt, &vLookatPt, &vUpVec );

	return S_OK;
}
Пример #25
0
void CAXModel::UpdateMatrix(void)
{
	D3DXMATRIX matPosition;
	D3DXMATRIX matSize;
	D3DXMATRIX matRotate;
	D3DXMATRIX matAnchorPoint;
	D3DXMATRIX matComplate;
	
	D3DXMATRIX mT;
	{
		AVector3 vLeft(1.0f, 0.0f, 0.0f);
		AVector3 vUp(0.0f, 1.0f, 0.0f);
		AVector3 vLook(0.0f, 0.0f, 1.0f);
		AVector3 vUpNew, vLeftNew, vLookNew;
		D3DXMATRIX mX, mY, mZ;

		D3DXMatrixRotationX(&mX, m_fRotX);
		D3DXMatrixRotationY(&mY, m_fRotY);
		D3DXMatrixRotationZ(&mZ, -m_fRotZ);

		D3DXMatrixTranslation(&mT, vUp.x, vUp.y, vUp.z);
		mT *= mX; D3DXMatrixTranslation(&mT, mT._41, mT._42, mT._43);
		mT *= mY; D3DXMatrixTranslation(&mT, mT._41, mT._42, mT._43);
		mT *= mZ; vUpNew = AVector3(mT._41, mT._42, mT._43);

		D3DXMatrixTranslation(&mT, vLeft.x, vLeft.y, vLeft.z);
		mT *= mX; D3DXMatrixTranslation(&mT, mT._41, mT._42, mT._43);
		mT *= mY; D3DXMatrixTranslation(&mT, mT._41, mT._42, mT._43);
		mT *= mZ; vLeftNew = AVector3(mT._41, mT._42, mT._43);

		D3DXMatrixTranslation(&mT, vLook.x, vLook.y, vLook.z);
		mT *= mX; D3DXMatrixTranslation(&mT, mT._41, mT._42, mT._43);
		mT *= mY; D3DXMatrixTranslation(&mT, mT._41, mT._42, mT._43);
		mT *= mZ; vLookNew = AVector3(mT._41, mT._42, mT._43);

		mT._11 = vLeftNew.x;   mT._12 = vLeftNew.y;   mT._13 = vLeftNew.z;   mT._14 = 0.0f;		// Left Vector
		mT._21 = vUpNew.x;     mT._22 = vUpNew.y;     mT._23 = vUpNew.z;     mT._24 = 0.0f;		// Up Vector
		mT._31 = vLookNew.x;   mT._32 = vLookNew.y;   mT._33 = vLookNew.z;   mT._34 = 0.0f;		// Front Vector
		mT._41 = 0.0f;         mT._42 = 0.0f;         mT._43 = 0.0f;         mT._44 = 1.0f;		// Translation
	}

	D3DXMatrixTranslation(&matAnchorPoint, m_vAnchorPoint.x, m_vAnchorPoint.y, m_vAnchorPoint.z);
	D3DXMatrixScaling(&matSize, m_vSize.x, m_vSize.y, m_vSize.z);
	D3DXMatrixTranslation(&matPosition, m_vPosition.x, m_vPosition.y, m_vPosition.z);

	m_matComplate = matAnchorPoint * matSize * mT * matPosition;
	
	m_bUpdateMatrix = false;
}
Пример #26
0
void CMyObject::Rotate(float x, float y, float z)
{
	D3DXMATRIX mtxRotX;
	D3DXMATRIX mtxRotY;
	D3DXMATRIX mtxRotZ;

	m_rotAngles.x += x;
	m_rotAngles.y += y;
	m_rotAngles.z += z;

	D3DXMatrixRotationX(&mtxRotX,m_rotAngles.x);
	D3DXMatrixRotationY(&mtxRotY,m_rotAngles.y);
	D3DXMatrixRotationZ(&mtxRotZ,m_rotAngles.z);
	m_mtxRot = mtxRotX * mtxRotY * mtxRotZ;
}
Пример #27
0
void
CGameObject::setupRotation()
{
	D3DXMATRIX matWorldX, matWorldY, matWorldZ;

    // Rotate to global orientation
	D3DXMatrixRotationX(&matWorldX, m_Rotation.x);
	D3DXMatrixRotationY(&matWorldY, m_Rotation.y);
	D3DXMatrixRotationZ(&matWorldZ, m_Rotation.z);

	// Combine the transformations by multiplying them together
	D3DXMatrixMultiply(&m_MatWorld, &matWorld, &matWorldX);
	D3DXMatrixMultiply(&m_MatWorld, &m_MatWorld, &matWorldY);
	D3DXMatrixMultiply(&m_MatWorld, &m_MatWorld, &matWorldZ);
}
Пример #28
0
Vector3 Vector::RotateX(Vector3 * v, float fAngle)
{
	Vector3 rV = *v;
	D3DXVec3Normalize(&rV, &rV);
	Matrix4x4 matRotX, matRotY;
	// x축으로 먼저 회전 시킨다음, y축으로 회전
	D3DXMatrixRotationX(&matRotX, D3DXToRadian(fAngle));
	
	// x가 양수면 z축 방향을 바라봄, x가 음수면 -z축 방향을 바라봄
	Vector3 vAxisZ(0, 0, 1);
	D3DXMatrixRotationY(&matRotY, GetAngleY(&rV));
	D3DXVec3TransformNormal(&rV, &vAxisZ, &(matRotX * matRotY));
	
	return rV;
}
Пример #29
0
void OrbitX::draw(int m){

  D3DXMATRIX  Rotate, Rotate2;

  D3DXMatrixRotationX(&Rotate, yaw);
  D3DXMatrixRotationY(&Rotate2, initPos+(Tools::g->CurrentTime - Networks::timediff)*(speeds));

  World = Rotate*Rotate2;


  if(rotateSelf) World = Rotate2*World;
  Tools::m4_inverse(WorldInverse, World);

  PaintableX::draw(m);
}
Пример #30
0
bool Display(float timeDelta)
{
	if( Device )
	{
		//
		// Update: Rotate the cube.
		//

		D3DXMATRIX xRot;
		D3DXMatrixRotationX(&xRot, D3DX_PI * 0.2f);

		static float y = 0.0f;
		D3DXMATRIX yRot;
		D3DXMatrixRotationY(&yRot, y);
		y += timeDelta;

		if( y >= 6.28f )
			y = 0.0f;

		CubeWorldMatrix = xRot * yRot;  // 合并旋转

		//
		// Render
		//

		Device->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0);
		Device->BeginScene();

		// draw back drop
		D3DXMATRIX I;
		D3DXMatrixIdentity(&I);
		Device->SetStreamSource(0, BackDropVB, 0, sizeof(Vertex));
		Device->SetFVF(FVF_VERTEX);
		Device->SetTexture(0, BackDropTex);
		Device->SetTransform(D3DTS_WORLD, &I);
		Device->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 2);

		// draw cube
		Device->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
		if(Box)
			Box->draw(&CubeWorldMatrix, 0, CrateTex);
		Device->SetRenderState(D3DRS_ALPHABLENDENABLE, false);

		Device->EndScene();
		Device->Present(0, 0, 0, 0);
	}
	return true;
}