Beispiel #1
0
void CCamera::YRotate ( int iID, float fY )
{
	// rotate the camera on it's y axis

	// update internal pointer
	if ( !this->UpdatePtr ( iID ) )
		return;

	D3DXMatrixLookAtLH 
						( 
							&m_ptr->matView,
							&D3DXVECTOR3 ( m_ptr->fX,   m_ptr->fY,    m_ptr->fZ ),
							&D3DXVECTOR3 ( 0.0f, 0.0f,  0.0f ),
							&D3DXVECTOR3 ( 0.0f, 1.0f,  0.0f )
						);

	D3DXMatrixRotationY ( &m_ptr->matRotateY, fY );
	D3DXMatrixMultiply  ( &m_ptr->matView, &m_ptr->matView, &m_ptr->matRotateY );

	m_pD3D->SetTransform ( D3DTS_VIEW, &m_ptr->matView );
}
Beispiel #2
0
//-----------------------------------------------------------------------------
// Name:
// Desc:
//-----------------------------------------------------------------------------
HRESULT CD3DFrame::Render( LPDIRECT3DDEVICE8 pd3dDevice, BOOL bDrawOpaqueSubsets,
                           BOOL bDrawAlphaSubsets )
{
    D3DXMATRIX matSavedWorld, matWorld;
    pd3dDevice->GetTransform( D3DTS_WORLD, &matSavedWorld );
    D3DXMatrixMultiply( &matWorld, &m_mat, &matSavedWorld );
    pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );

    if( m_pMesh )
        m_pMesh->Render( pd3dDevice, bDrawOpaqueSubsets, bDrawAlphaSubsets );

    if( m_pChild )
        m_pChild->Render( pd3dDevice, bDrawOpaqueSubsets, bDrawAlphaSubsets );

    pd3dDevice->SetTransform( D3DTS_WORLD, &matSavedWorld );

    if( m_pNext )
        m_pNext->Render( pd3dDevice, bDrawOpaqueSubsets, bDrawAlphaSubsets );

    return S_OK;
}
Beispiel #3
0
static void renderchain_set_mvp(
      cg_renderchain_t *chain,
      void *vertex_program,
      unsigned vp_width, unsigned vp_height,
      unsigned rotation)
{
   D3DXMATRIX proj, ortho, rot, tmp;
   CGprogram     vPrg   = (CGprogram)vertex_program;

   if (!chain)
      return;

   D3DXMatrixOrthoOffCenterLH(&ortho, 0, vp_width, 0, vp_height, 0, 1);
   D3DXMatrixIdentity(&rot);
   D3DXMatrixRotationZ(&rot, rotation * (M_PI / 2.0));

   D3DXMatrixMultiply(&proj, &ortho, &rot);
   D3DXMatrixTranspose(&tmp, &proj);

   renderchain_set_shader_mvp(chain, &vPrg, &tmp);
}
void DisplayObject::MoveMesh(){
	//D3DXMATRIX matRotateX;
	//D3DXMATRIX matRotateY;
	D3DXMATRIX matRotate;
	D3DXMATRIX matTrans;
	D3DXMATRIX matFinal;
	
	D3DXQuaternionNormalize(&_m_rotation, &_m_rotation);
	D3DXMatrixRotationQuaternion(&matRotate, &_m_rotation);

	//D3DXMatrixRotationX(&matRotateX, rotation.x);	
	//D3DXMatrixRotationY(&matRotateY, rotation.y);
	//D3DXMatrixRotationZ(&matRotateZ, rotation.z);
	D3DXMatrixTranslation(&matTrans, _m_pos.x, _m_pos.y, _m_pos.z);

	D3DXMatrixMultiply(&matFinal, &matRotate, &matTrans);
	//matFinal = matRotate * matTrans;
	//matRotate = matRotateZ * matRotateY * matRotateX * matTrans;
	m_world = matFinal;
	//DXUTGetD3D9Device()->SetTransform(m_world, &(matRotate));
}
void  CUtilities::ComputeVQSSkeleton( LPD3DXFRAME pRootFrame, LPD3DXFRAME pParentFrame, std::vector<D3DXVECTOR3>& rSkeletonList )
{
	//This is going to be recursive
	if( pRootFrame == NULL )
	{
		return;
	}

	if( !pRootFrame->pFrameFirstChild && !pRootFrame->pFrameSibling )
	{
		return;
	}


	if( pParentFrame != NULL )
	{
		Extra_Frame* parent = (Extra_Frame*)pParentFrame;
		Extra_Frame* current = (Extra_Frame*)pRootFrame;

		D3DXMATRIX	mat_parent	= pParentFrame->TransformationMatrix;
		D3DXMatrixMultiply( &pRootFrame->TransformationMatrix, &current->m_vqsTransform.toMatrix(), &pParentFrame->TransformationMatrix );
		D3DXMATRIX	mat_current = pRootFrame->TransformationMatrix;

		rSkeletonList.push_back( D3DXVECTOR3( mat_parent._41, mat_parent._42, mat_parent._43 ) );
		rSkeletonList.push_back( D3DXVECTOR3( mat_current._41, mat_current._42, mat_current._43 ) );

		parent->m_vqsTransformToRoot.SetVQS( mat_parent );
		current->m_vqsTransformToRoot.SetVQS( mat_current );
	}

	if( pRootFrame->pFrameFirstChild )
	{
		ComputeVQSSkeleton( pRootFrame->pFrameFirstChild, pRootFrame, rSkeletonList );
	}

	if( pRootFrame->pFrameSibling )
	{
		ComputeVQSSkeleton( pRootFrame->pFrameSibling, pParentFrame, rSkeletonList );
	}
}
Beispiel #6
0
//-------------------------------------------------------------
// Name: FrameMove()
// Desc: �� �����Ӹ��� ȣ���. �ִϸ��̼� ó���� ���
//-------------------------------------------------------------
HRESULT CMyD3DApplication::FrameMove()
{
    UpdateInput( &m_UserInput );// ���̓f�[�^�̍X�V

	//---------------------------------------------------------
	// �Է¿� ���� ��ǥ�踦 �����Ѵ�
	//---------------------------------------------------------
	// ȸ��
    D3DXMATRIX m;
    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, &matRotX, &matRotY );

    // �����
    D3DXVECTOR3 vFromPt   = D3DXVECTOR3( 0.0f, 2.73f, -8.0f );
    D3DXVECTOR3 vLookatPt = D3DXVECTOR3( 0.0f, 2.73f, 0.0f );
    D3DXVECTOR3 vUpVec    = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
    D3DXMatrixLookAtLH( &m_mView, &vFromPt, &vLookatPt, &vUpVec );
	m_mView = m * m_mView;
    m_pd3dDevice->SetTransform( D3DTS_VIEW, &m_mView );

	return S_OK;
}
VOID Render()
{
	g_pD3DDevice->Clear( 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB( 0, 0, 255 ), 1.0f, 0 );

	if ( SUCCEEDED( g_pD3DDevice->BeginScene() ) )
	{
		SetupLights();

		SetupMatrices();

		g_pD3DDevice->SetTextureStageState( 0, D3DTSS_COLOROP, D3DTOP_MODULATE );
		g_pD3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
		g_pD3DDevice->SetTextureStageState( 0, D3DTSS_COLORARG2, D3DTA_DIFFUSE );
		g_pD3DDevice->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_DISABLE );

		//soldier
		D3DXMATRIXA16 matFirstTiger, matTrans, matRotate;
		//D3DXMatrixIdentity(&matFirstTiger);

		//g_pD3DDevice->GetTransform(D3DTS_WORLD, &matFirstTiger);
		D3DXMatrixTranslation( &matTrans, 0.f, -2.f, 0.f );
		D3DXMatrixRotationY( &matRotate, timeGetTime() / 1000.0f );
		D3DXMatrixMultiply( &matFirstTiger, &matRotate, &matTrans );
		g_pD3DDevice->SetTransform( D3DTS_WORLD, &matFirstTiger );


		for ( DWORD i = 0; i < g_dwNumMaterials; ++i )
		{
			g_pD3DDevice->SetMaterial( &g_pMeshMaterials0[i] );
			g_pD3DDevice->SetTexture( 0, g_pMeshTextures0[i] );

			g_pMesh0->DrawSubset( i );
		}

		g_pD3DDevice->EndScene();
	}

	g_pD3DDevice->Present( NULL, NULL, NULL, NULL );
	g_tick++;
}
BoundingCone::BoundingCone(const BoundingBox& box, const D3DXMATRIX& projection, const D3DXVECTOR3& apex, const D3DXVECTOR3& direction )
{
	m_direction = direction;

	const D3DXVECTOR3 yAxis(0.f, 1.f, 0.f);
    const D3DXVECTOR3 zAxis(0.f, 0.f, 1.f);
    D3DXVec3Normalize(&m_direction, &m_direction);
    
    D3DXVECTOR3 axis = yAxis;

    if ( fabsf(D3DXVec3Dot(&yAxis, &m_direction))>0.99f )
	{
        axis = zAxis;
	}
    
    D3DXMatrixLookAtLH( &m_lookAt, &apex, &(apex+m_direction), &axis );
    
    float maxx = 0.f, maxy = 0.f;
    m_near = 1e32f;
    m_far =  0.f;

    D3DXMATRIX concatMatrix;
    D3DXMatrixMultiply( &concatMatrix, &projection, &m_lookAt );

	D3DXVECTOR3 ppPts[ box.CornerCount ];
	box.GetCorners( ppPts );

	for(int index=0; index<box.CornerCount; index++)
    {
		D3DXVECTOR3 vec = ppPts[index];
        D3DXVec3TransformCoord(&vec, &vec, &concatMatrix);
        maxx = max(maxx, fabsf(vec.x / vec.z));
        maxy = max(maxy, fabsf(vec.y / vec.z));
        m_near = min(m_near, vec.z);
        m_far  = max(m_far, vec.z);
    }

    m_fovx = atanf(maxx);
    m_fovy = atanf(maxy);
}
Beispiel #9
0
void drawCursor()
{
    double pos[3];
    gHaptics.synchFromServo();
    gHaptics.getPosition(pos);
    pos[2] *= -1;   // Reverse Z for DirectX

    // Check button state
    if (gHaptics.isButtonDown())
    {
        // Red when button is down
        gCursorMaterial.MatD3D.Diffuse.r = 1.0f;
        gCursorMaterial.MatD3D.Diffuse.g = 0.0f;
        gCursorMaterial.MatD3D.Diffuse.b = 0.0f;
        gCursorMaterial.MatD3D.Ambient.r = 1.0f;
        gCursorMaterial.MatD3D.Ambient.g = 0.0f;
        gCursorMaterial.MatD3D.Ambient.b = 0.0f;
    }
    else
    {
        // Teal when button is up
        gCursorMaterial.MatD3D.Diffuse.r = 0.0f;
        gCursorMaterial.MatD3D.Diffuse.g = 0.5f;
        gCursorMaterial.MatD3D.Diffuse.b = 0.5f;
        gCursorMaterial.MatD3D.Ambient.r = 0.0f;
        gCursorMaterial.MatD3D.Ambient.g = 0.5f;
        gCursorMaterial.MatD3D.Ambient.b = 0.5f;
    }

    //Now position cursor
	D3DXMATRIX matXlt;
	D3DXMatrixTranslation(&matXlt, (float)pos[0], (float)pos[1], (float)pos[2]);
	
	D3DXMATRIX matWorld;
	D3DXMatrixMultiply(&matWorld, &matXlt, &gMatView);	
    pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );

    drawMesh(gCursor, gCursorMaterial);
}
bool RainParticleSystem::Render(ID3D11DeviceContext* deviceContext, D3DXMATRIX worldMatrix, 
									  D3DXMATRIX viewMatrix, D3DXMATRIX projectionMatrix,
									  float frameTime, float gameTime, XMFLOAT3 camEyePos )
{
	HRESULT result;
	D3DXMATRIX* ViewProj = new D3DXMATRIX;
	cout<< "FireParticle:" << frameTime << "||" << gameTime << "||\n";

	//D3DXMatrixTranspose(&worldMatrix, &worldMatrix);
	//D3DXMatrixTranspose(&viewMatrix, &viewMatrix);
	//D3DXMatrixTranspose(&projectionMatrix, &projectionMatrix);


	D3DXMatrixMultiply(ViewProj, &viewMatrix, &projectionMatrix);

	D3DXMatrixTranspose(ViewProj, ViewProj);

	setEmit_Position(camEyePos);
		///////// STREAM_OUT/////////
	// Set the shader parameters that it will use for rendering.
	result = SetShaderParameters_StreamOut(deviceContext, frameTime,gameTime,camEyePos,ViewProj);
	if(!result)
	{
		//return false;
	}

	// Now render the prepared buffers with the shader.
	RenderShader_StreamOut(deviceContext);


	result = SetShaderParameters_Draw(deviceContext, frameTime,gameTime,camEyePos,ViewProj);
	if(!result)
	{
		return false;
	}

	//RenderShader_Draw(deviceContext);
	return  true;
}
// @brief  : 行列の作成
//--------------------------------------------------------------------
void TransLookCameraDx9::CreateMatrix(void)
{
    const D3DXVECTOR3 pos = Vector3(Position);
    const Camera *cam = Cam();

    D3DXMATRIX mtx_rot;
    {
        D3DXVECTOR3 eye = -Vector3(cam->Eye);
        D3DXVECTOR3 at  = -Vector3(cam->At);
        D3DXVECTOR3 up  = -Vector3(cam->Up);

        D3DXMatrixLookAtLH(&mtx_rot,&eye,&at,&up);
        D3DXMatrixInverse(&mtx_rot,NULL,&mtx_rot);
        mtx_rot._14 = mtx_rot._24 = mtx_rot._34 =
            mtx_rot._41 = mtx_rot._42 = mtx_rot._43 = 0.0f;
        mtx_rot._44 = 1.0f;
    }

    D3DXMATRIX mtx_pos;
    D3DXMatrixTranslation(&mtx_pos,pos.x,pos.y,pos.z);
    D3DXMatrixMultiply(&m_Matrix,&mtx_rot,&mtx_pos);
}
bool SpecmapShaderClass::Render(ID3D11DeviceContext* context, int indexCount, D3DXMATRIX world, D3DXMATRIX view, D3DXMATRIX proj, ID3D11ShaderResourceView** texarr, D3DXVECTOR3 lightdir, D3DXVECTOR4 difcolor,D3DXVECTOR3 camerapos, D3DXVECTOR4 speccolor,float specpow)
{
	bool result;
	D3DXMATRIX rolworld = world;
	D3DXMATRIX transworld = world;

	D3DXMatrixRotationYawPitchRoll(&rolworld, yaw, pitch, roll);

	D3DXMatrixTranslation(&transworld, posx, posy, posz);

	D3DXMatrixMultiply(&world, &rolworld, &transworld);

	result = SetShaderParameters(context, world, view, proj, texarr, lightdir, difcolor,camerapos,speccolor,specpow);
	if (!result)
	{
		return false;
	}

	RenderShader(context, indexCount);

	return true;
}
Beispiel #13
0
void SkinnedMesh::Render(Bone *bone) {
    if (bone == NULL) bone = (Bone*) m_pRootBone;

    //If there is a mesh to render...
    if (bone->pMeshContainer != NULL) {
        BoneMesh *boneMesh = (BoneMesh*) bone->pMeshContainer;

        if (boneMesh->pSkinInfo != NULL) {
            // set up bone transforms
            int numBones = boneMesh->pSkinInfo->GetNumBones();
            for (int i=0; i < numBones; i++)
                D3DXMatrixMultiply(&boneMesh->currentBoneMatrices[i],
                                   &boneMesh->boneOffsetMatrices[i],
                                   boneMesh->boneMatrixPtrs[i]);

            //Update the skinned mesh
            BYTE *src = NULL, *dest = NULL;
            boneMesh->OriginalMesh->LockVertexBuffer(D3DLOCK_READONLY, (VOID**)&src);
            boneMesh->MeshData.pMesh->LockVertexBuffer(0, (VOID**)&dest);

            boneMesh->pSkinInfo->UpdateSkinnedMesh(boneMesh->currentBoneMatrices, NULL, src, dest);

            boneMesh->MeshData.pMesh->UnlockVertexBuffer();
            boneMesh->OriginalMesh->UnlockVertexBuffer();

            //Render the mesh
            for (int i = 0; i < (int) boneMesh->NumAttributeGroups; i++) {
                int mtrlIndex = boneMesh->attributeTable[i].AttribId;
                g_pDevice->SetMaterial(&(boneMesh->materials[mtrlIndex]));
                g_pDevice->SetTexture(0, boneMesh->textures[mtrlIndex]);
                boneMesh->MeshData.pMesh->DrawSubset(mtrlIndex);
            }
        }
    }

    if (bone->pFrameSibling != NULL) Render((Bone*) bone->pFrameSibling);
    if (bone->pFrameFirstChild != NULL) Render((Bone*) bone->pFrameFirstChild);
}
//----------------------------------------------------------------------------//
void Direct3D10RenderTarget::updateMatrix() const
{
    const float fov = 0.523598776f;
    const float w = d_area.getWidth();
    const float h = d_area.getHeight();
    const float aspect = w / h;
    const float midx = w * 0.5f;
    const float midy = h * 0.5f;
    d_viewDistance = midx / (aspect * 0.267949192431123f);

    D3DXVECTOR3 eye(midx, midy, -d_viewDistance);
    D3DXVECTOR3 at(midx, midy, 1);
    D3DXVECTOR3 up(0, -1, 0);

    D3DXMATRIX tmp;
    D3DXMatrixMultiply(&d_matrix,
        D3DXMatrixLookAtRH(&d_matrix, &eye, &at, &up),
        D3DXMatrixPerspectiveFovRH(&tmp, fov, aspect,
                                   d_viewDistance * 0.5f,
                                   d_viewDistance * 2.0f));

    d_matrixValid = false;
}
Beispiel #15
0
void SkinnedMeshNode::UpdateMatrixPallete()
{
	D3DXMATRIX* pDst=NULL;
	DWORD offset_bytes = 0;
	DWORD offset_line = 0;
	DWORD bytesMatrix = sizeof(D3DXMATRIX);
	
	D3DLOCKED_RECT lock;	
	m_pMatrixPalleteTexture->GetD3DTexture()->LockRect(0,&lock,NULL,D3DLOCK_DISCARD);

	DWORD boneSize = m_vecBoneRef.size();
	for (DWORD boneIndex=0;boneIndex<boneSize;boneIndex++)
	{			
		pDst = (D3DXMATRIX*)((LPBYTE)lock.pBits + offset_line*lock.Pitch + offset_bytes);						
		BONEREFINFO& refItem=m_vecBoneRef[boneIndex];
		// = refItem.SkinOffset * refItem.pNode->GetWorldTM();	// WorldTM = LocalTM * Parent.WorldTM
		D3DXMatrixMultiply(pDst,&refItem.SkinOffset,&refItem.pNode->m_matWorld);	
		offset_bytes += bytesMatrix;		
	}	

	m_pMatrixPalleteTexture->GetD3DTexture()->UnlockRect(0);
	m_updateMatrixPallete = true;
}
Beispiel #16
0
void	CAnimationModel::UpdateFrameMatrices(LPD3DXFRAME pFrame, const LPD3DXMATRIX pParentMatrix)
{
	CFrame			*pFrame_Derived		= (CFrame*) pFrame;

	if( NULL != pParentMatrix )
	{
		D3DXMatrixMultiply( &pFrame_Derived->m_CombinedTransformationMatrix, &pFrame_Derived->TransformationMatrix, pParentMatrix );
	}
	else
	{
		pFrame_Derived->m_CombinedTransformationMatrix	= pFrame_Derived->TransformationMatrix;
	}

	if( NULL != pFrame_Derived->pFrameSibling )
	{
		UpdateFrameMatrices( pFrame_Derived->pFrameSibling, pParentMatrix );
	}

	if( NULL != pFrame_Derived->pFrameFirstChild )
	{
		UpdateFrameMatrices( pFrame_Derived->pFrameFirstChild, &pFrame_Derived->m_CombinedTransformationMatrix );
	}
}
Beispiel #17
0
void CMover::SetDestPos( CShip *pIAObj, const D3DXVECTOR3 &vDestPos )
{
	m_pIADestPos = pIAObj;
	
	D3DXMATRIX mTrans, mInvIA, mLocal;
	D3DXMatrixTranslation( &mTrans, vDestPos.x, vDestPos.y, vDestPos.z );		// 월드좌표를 매트릭스로 변환
	D3DXMatrixInverse( &mInvIA, NULL, pIAObj->GetMatrixWorldPtr() );			// IAObj의 역행렬.
	D3DXMatrixMultiply( &mLocal, &mTrans, GetIAObjLink()->GetInvTM() );	// IA오브젝트로부터의 로컬 행렬.

	D3DXVECTOR3 vLocal;
	vLocal.x = mLocal._41;
	vLocal.y = mLocal._42;
	vLocal.z = mLocal._43;
	
	SetDestPos( vLocal, true, FALSE );	// do not transfer

#ifdef __CLIENT
	if( IsActiveMover() )
	{
		g_DPlay.PutPlayerDestPos( vLocal, true, 0, pIAObj->GetId() );
	}
#endif	// __CLIENT
}
Beispiel #18
0
void Dio::init(TextureStruc stuff[])
{
	//speaker position and color
	speaker[0].rec.bottom=0;
	speaker[0].rec.left=0;
	speaker[0].rec.right=100;
	speaker[0].rec.top=400;
	speaker[0].textColor=D3DCOLOR_ARGB(255,255,255,255);
	//text position and color
	speaker[1].rec.bottom=0;
	speaker[1].rec.left=440;
	speaker[1].rec.right=400;
	speaker[1].rec.top=450;
	speaker[1].textColor=D3DCOLOR_ARGB(255,255,255,255);

	D3DXMATRIX matrixlove;
	D3DXMATRIX matrixlove1;
	D3DXMATRIX matrixlove2;
	D3DXMatrixIdentity(&matrixlove);
	D3DXMatrixIdentity(&matrixlove1);
	D3DXMatrixIdentity(&matrixlove2);
	D3DXMatrixScaling(&matrixlove,0.5f,0.5f,0.5f);
	D3DXMatrixTranslation(&matrixlove1,20,150,0);
	D3DXMatrixMultiply(&matrixlove2,&matrixlove1,&matrixlove);

	for (int i=0;i<=maxpics;i++)
	{
		pics[i].tex=stuff[i+9].objTex;
		pics[i].texinfo=stuff[i+9].texInfo;
		pics[i].matrix= matrixlove2;

	}
	salami.tex=0;
	readname=true;
	readtext=true;
	infile.open("Dialogue.txt");
}
Beispiel #19
0
void SkinnedMeshNode::UpdateMatrixInstancing( std::list<cMeshNode*>& list )
{
	auto it = list.begin();
	auto it_end = list.end();
	int size = list.size();
	SkinnedMeshNode* pMeshNode = NULL;
	D3DXMATRIX* pDst=NULL;
	DWORD offset_bytes = 0;
	DWORD offset_line = 0;
	DWORD bytesMatrix = sizeof(D3DXMATRIX);
	DWORD bytesPerLine= bytesMatrix * (m_pMatrixInstancingTexture->GetSize()/4); // 1mat= 4pixel

	D3DLOCKED_RECT lock;	
	m_pMatrixInstancingTexture->GetD3DTexture()->LockRect(0,&lock,NULL,D3DLOCK_DISCARD);

	for ( ; it!=it_end ; it++)
	{		
		pMeshNode =  static_cast<SkinnedMeshNode*>(*it);	
		auto& refArrBone = pMeshNode->GetArrayBoneRef();
		DWORD boneSize = refArrBone.size();
		for (DWORD boneIndex=0;boneIndex<boneSize;boneIndex++)
		{			
			pDst = (D3DXMATRIX*)((LPBYTE)lock.pBits + offset_line*lock.Pitch + offset_bytes);						
			BONEREFINFO& refItem=refArrBone[boneIndex];
			// = refItem.SkinOffset * refItem.pNode->GetWorldTM();	// WorldTM = LocalTM * Parent.WorldTM
			D3DXMatrixMultiply(pDst,&refItem.SkinOffset,&refItem.pNode->m_matWorld);		
			
			offset_bytes += bytesMatrix;		
			if (offset_bytes >= bytesPerLine)
			{
				offset_line++;			
				offset_bytes=0;
			}	
		}	
	}
	m_pMatrixInstancingTexture->GetD3DTexture()->UnlockRect(0);
}
Beispiel #20
0
VOID CCharactor::RecvBreakList( INT a_iCount, WORD* a_pList, D3DXVECTOR3& a_vDir )
{
	for( INT QLoop = 0; QLoop < a_iCount; ++QLoop )
	{
		if( m_vectorCube[ a_pList[QLoop] ] == NULL )
		{
			continue;
		}

		m_vectorCube[ a_pList[QLoop] ]->Set_Visible( EnumCharFrame::BASE, 3 );

		INT iFriendCubeVecIndex = -1;

		// 이웃 노드 큐브 보이기
		for(INT LoopFriend=0; LoopFriend<6; ++LoopFriend)
		{
			iFriendCubeVecIndex = m_vectorCube[ a_pList[QLoop] ]->Get_FriendCubeVecIndex( m_iSelectedFrameNum, LoopFriend );
			if ( iFriendCubeVecIndex != -1 )
			{
				if( m_vectorCube[ iFriendCubeVecIndex ] != NULL && m_vectorCube[ iFriendCubeVecIndex ]->Get_Visible( EnumCharFrame::BASE ) == FALSE )
				{
					m_vectorCube[ iFriendCubeVecIndex ]->Set_Visible( EnumCharFrame::BASE, TRUE );
				}
			}
		}

		if( m_bMonster )
		{
			D3DXMatrixMultiply( &m_matMultWorld, &Get_MatWorld(), &m_matMonster);
			m_pModel->CreateRandom( m_vectorCube[ a_pList[QLoop] ], m_iSelectedFrameNum, m_matMultWorld, a_vDir );
		}
		else
		{
			m_pModel->CreateRandom( m_vectorCube[ a_pList[QLoop] ], m_iSelectedFrameNum, Get_MatWorld(), a_vDir );
		}
	}	
}
Beispiel #21
0
VOID CCharactor::BreakListMake( INT Loop, D3DXVECTOR3& vDir )
{
	INT iFriendCubeVecIndex = -1;

	//전 프레임을 돌면서 체크
	for( INT LoopFrame = 0; LoopFrame<EnumCharFrame::MAXFRAME; ++LoopFrame )
	{
		m_vectorCube[Loop]->Set_Visible( LoopFrame, 3 );

		// 이웃 노드 큐브 보이기
		for(INT LoopFriend=0; LoopFriend<6; ++LoopFriend)
		{
			iFriendCubeVecIndex = m_vectorCube[Loop]->Get_FriendCubeVecIndex( m_iSelectedFrameNum, LoopFriend );
			if ( iFriendCubeVecIndex != -1 )
			{
				iFriendCubeVecIndex = m_vectorCube[Loop]->Get_FriendCubeVecIndex( LoopFrame, LoopFriend );
				if ( iFriendCubeVecIndex != -1 )
				{
					if( m_vectorCube[ iFriendCubeVecIndex ] != NULL && m_vectorCube[ iFriendCubeVecIndex ]->Get_Visible( LoopFrame ) == FALSE )
					{
						m_vectorCube[ iFriendCubeVecIndex ]->Set_Visible( LoopFrame, TRUE );
					}
				}
			}
		}
	}

	if( m_bMonster )
	{
		D3DXMatrixMultiply( &m_matMultWorld, &Get_MatWorld(), &m_matMonster);
		m_pModel->CreateRandom( m_vectorCube[Loop], m_iSelectedFrameNum, m_matMultWorld, vDir, 0.5f);
	}
	else
	{
		m_pModel->CreateRandom( m_vectorCube[Loop], m_iSelectedFrameNum, Get_MatWorld(), vDir );
	}
}
Beispiel #22
0
//-----------------------------------------------------------------------------
HRESULT CDXUTMeshFile::Render( LPDIRECT3DDEVICE9 pd3dDevice, D3DXMATRIX* pmatWorldMatrix )
{

    // For pure devices, specify the world transform. If the world transform is not
    // specified on pure devices, this function will fail.

    // Set up the world transformation
    D3DXMATRIX matSavedWorld, matWorld;

    if ( NULL == pmatWorldMatrix )
        pd3dDevice->GetTransform( D3DTS_WORLD, &matSavedWorld );
    else
        matSavedWorld = *pmatWorldMatrix;

    D3DXMatrixMultiply( &matWorld, &matSavedWorld, &m_mat );
    pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );

    // Render opaque subsets in the meshes
    if( m_pChild )
        m_pChild->Render( pd3dDevice, TRUE, FALSE, &matWorld );

    // Enable alpha blending
    pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, TRUE );
    pd3dDevice->SetRenderState( D3DRS_SRCBLEND,  D3DBLEND_SRCALPHA );
    pd3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );

    // Render alpha subsets in the meshes
    if( m_pChild )
        m_pChild->Render( pd3dDevice, FALSE, TRUE, &matWorld );

    // Restore state
    pd3dDevice->SetRenderState( D3DRS_ALPHABLENDENABLE, FALSE );
    pd3dDevice->SetTransform( D3DTS_WORLD, &matSavedWorld );

    return S_OK;
}
Beispiel #23
0
Matrix3& Matrix3::Multiply( const Matrix3& a, const Matrix3& b )
{
#ifdef __USE_D3DX__
	D3DXMatrixMultiply( (D3DXMATRIX*)this, (D3DXMATRIX*)&a, (D3DXMATRIX*)&b );
#else
	e[0] = b.e[0] * a.e[0] + b.e[4] * a.e[1] + b.e[8] * a.e[2] + b.e[12] * a.e[3];
	e[1] = b.e[1] * a.e[0] + b.e[5] * a.e[1] + b.e[9] * a.e[2] + b.e[13] * a.e[3];
	e[2] = b.e[2] * a.e[0] + b.e[6] * a.e[1] + b.e[10] * a.e[2] + b.e[14] * a.e[3];
	e[3] = b.e[3] * a.e[0] + b.e[7] * a.e[1] + b.e[11] * a.e[2] + b.e[15] * a.e[3];
	e[4] = b.e[0] * a.e[4] + b.e[4] * a.e[5] + b.e[8] * a.e[6] + b.e[12] * a.e[7];
	e[5] = b.e[1] * a.e[4] + b.e[5] * a.e[5] + b.e[9] * a.e[6] + b.e[13] * a.e[7];
	e[6] = b.e[2] * a.e[4] + b.e[6] * a.e[5] + b.e[10] * a.e[6] + b.e[14] * a.e[7];
	e[7] = b.e[3] * a.e[4] + b.e[7] * a.e[5] + b.e[11] * a.e[6] + b.e[15] * a.e[7];
	e[8] = b.e[0] * a.e[8] + b.e[4] * a.e[9] + b.e[8] * a.e[10] + b.e[12] * a.e[11];
	e[9] = b.e[1] * a.e[8] + b.e[5] * a.e[9] + b.e[9] * a.e[10] + b.e[13] * a.e[11];
	e[10] = b.e[2] * a.e[8] + b.e[6] * a.e[9] + b.e[10] * a.e[10] + b.e[14] * a.e[11];
	e[11] = b.e[3] * a.e[8] + b.e[7] * a.e[9] + b.e[11] * a.e[10] + b.e[15] * a.e[11];
	e[12] = b.e[0] * a.e[12] + b.e[4] * a.e[13] + b.e[8] * a.e[14] + b.e[12] * a.e[15];
	e[13] = b.e[1] * a.e[12] + b.e[5] * a.e[13] + b.e[9] * a.e[14] + b.e[13] * a.e[15];
	e[14] = b.e[2] * a.e[12] + b.e[6] * a.e[13] + b.e[10] * a.e[14] + b.e[14] * a.e[15];
	e[15] = b.e[3] * a.e[12] + b.e[7] * a.e[13] + b.e[11] * a.e[14] + b.e[15] * a.e[15];
#endif
	return *this;
}
bool RefractionShaderClass::Render(ID3D11DeviceContext* context, int indexCnt, D3DXMATRIX world, D3DXMATRIX view, D3DXMATRIX proj, ID3D11ShaderResourceView* tex, D3DXVECTOR3 lightdir, D3DXVECTOR4 ambient, D3DXVECTOR4 diffuse, D3DXVECTOR4 clipplane)
{
    bool result;

    D3DXMATRIX rolworld = world;
    D3DXMATRIX transworld = world;

    D3DXMatrixRotationYawPitchRoll(&rolworld, yaw, pitch, roll);

    D3DXMatrixTranslation(&transworld, posx, posy, posz);

    D3DXMatrixMultiply(&world, &rolworld, &transworld);

    result = SetShaderParameters(context, world, view, proj, tex, lightdir, ambient, diffuse,clipplane);


    if (!result)
    {
        return false;
    }
    RenderShader(context, indexCnt);

    return true;
}
Beispiel #25
0
void CRouter::MoveOn(D3DXVECTOR3 *vCurPos, float *angle, const float fSpeed, float fTime)
{
	if (m_pCurDest != NULL)
	{
		D3DXMATRIX mat;
		D3DXMATRIX mTrans;
		D3DXMatrixRotationY(&mat, *angle);
		D3DXMatrixTranslation(&mTrans, vCurPos->x, vCurPos->y, vCurPos->z);
		D3DXMatrixMultiply(&mat,&mat,&mTrans);

		if (m_pCurDest->pPrev->mode2Next == linear_mode)
		{
			MoveLinearly(vCurPos, &mat, fSpeed, fTime);
			if (IsPassBeyondPt(m_pCurDest->pPos, &mat))
			{
				m_pCurDest = m_pCurDest->pNext;
				PreparePath(TRUE, &mat, fSpeed);
			}

		}
		else
		{
			MoveCurvely(vCurPos, &mat, fSpeed, fTime);
			if(fabs(m_fAgl2Ajust) < 1e-4)
			{
				m_pCurDest = m_pCurDest->pNext;
				PreparePath(FALSE, &mat, fSpeed);
			}
		}

		D3DXVECTOR3 vLook(0,0,1);
		D3DXVec3TransformNormal(&vLook, &vLook, &mat);
		*angle = CaculateYaw(&vLook);
	}

}
Beispiel #26
0
HRESULT CRacorX::Render()
{
	D3DXMATRIX mat;
	//mat = m_mtWorld * m_mtView * m_mtProj;
	D3DXMatrixMultiply(&mat, &m_mtView, &m_mtProj);
	D3DXMatrixTranspose(&mat, &mat);
	HRESULT hr;
	m_spDevice->Clear(0, 0, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0, 1.0f, 0);

	if (SUCCEEDED(m_spDevice->BeginScene())) 
	{
		m_spDevice->SetStreamSource(0, m_spVB.get(), (sizeof Vertex));
		m_spDevice->SetIndices(m_spIB.get(), 0);
		hr = m_spDevice->SetVertexShader(m_dwVertexShader);
		hr = m_spDevice->SetVertexShaderConstant(0, &mat, 4);
		hr = m_spDevice->SetVertexShaderConstant(4, &m_fMaterial, 1);
		m_spDevice->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, 0, 4, 0, 2);
		m_spDevice->EndScene();
	}

	m_spDevice->Present(0, 0, 0, 0);

	return S_OK;
}
Beispiel #27
0
// Defines the volume corner with the lowest coordinate on each axis
void fp_RenderRaytrace::SetVolumeStartPos(D3DXVECTOR3* VolumeStartPos) {
    HRESULT hr;

    m_BBox.SetStart(VolumeStartPos);

    if(m_Effect != NULL) {
        // Set bounding box start pos
        V(m_EffectVarBBoxStart->SetFloatVector((float*)&VolumeStartPos));

        // Set WorldToNDS matrix

        D3DXMATRIX worldToNDS, tmpMatrix;    
        D3DXVECTOR3 volumeSize = m_BBox.GetSize();
        D3DXVECTOR3 volumeCenter = m_BBox.GetCenter();
        // Volume center becomes new origin
        D3DXMatrixTranslation(&worldToNDS, -volumeCenter.x, -volumeCenter.y,
                -volumeCenter.z);
        // Scale all coords inside volume to [-1,1] range    
        D3DXMatrixScaling(&tmpMatrix, 2.0f / volumeSize.x, 2.0f / volumeSize.y, 2.0f
                / volumeSize.z);
        D3DXMatrixMultiply(&worldToNDS, &worldToNDS, &tmpMatrix);
        V(m_EffectVarWorldToNDS->SetMatrix((float*)&worldToNDS));
    }
}
Beispiel #28
0
//-------------------------------------------------------------------------------------
void BillBoard::draw2(D3DXMATRIXA16* Bview){

	 D3DXMATRIXA16 matWorld;
	 D3DXMATRIXA16 matTrans;
	 D3DXMATRIXA16 matScale;
	 D3DXMatrixIdentity(&matWorld);
	 D3DXMatrixIdentity(&matTrans);
	 D3DXMatrixIdentity(&matScale);
	 //D3DXMatrixTranslation(&matTrans,3.0f,6.0f,5.0f);
	 //스케일링 설정
	 D3DXMatrixScaling(&matScale,0.02f,-0.02f,0.02f);
	 D3DXMatrixMultiply(&matWorld,&matTrans,&matScale);
	 //받아온 뷰매트릭스를 기준으로 WorldViewLH 설정
	 m_pd3dSprite->SetWorldViewLH(&matWorld,Bview);

	 //D3DXSPRITE_BILLBOARD|
	 //빌보드 모드 Begin
	 m_pd3dSprite->Begin(  D3DXSPRITE_SORT_DEPTH_BACKTOFRONT | 
		 D3DXSPRITE_SORT_DEPTH_FRONTTOBACK | D3DXSPRITE_ALPHABLEND | D3DXSPRITE_OBJECTSPACE);

		 //스케일등이 적용된 월드매트릭스 설정
 		 m_pd3dSprite->SetTransform(&matWorld);
		 //	D3DXVECTOR2 pos=D3DXVECTOR2(120,20);
		 //  Scale the texture 4 times in each dimension
		 //  D3DXVECTOR2 scaling(1.0f,1.0f);

		 //  out, scaling centre, scaling rotation, scaling, rotation centre, rotation, translation
		 //	D3DXMATRIX mat;
		 //	D3DXMatrixTransformation2D(&mat,NULL,0.0,&scaling,NULL,0,&pos);

		 //  Tell the sprite about the matrix
		 //  m_pd3dSprite->SetTransform(&mat);

		m_pd3dSprite->Draw(m_pTex,NULL,NULL,NULL,0xFFFFFFFF);
	 m_pd3dSprite->End();
}
Beispiel #29
0
bool GObject::ObjectFrame()
{
	for (int iModel = 0; iModel < m_pModelList.size(); iModel++)
	{
		TObjWM* pUnit = m_pModelList[iModel].get();
		pUnit->m_fElapseTime += g_fSecPerFrame * pUnit->m_Scene.iFrameSpeed * pUnit->m_Scene.iTickPerFrame;
		if (pUnit->m_fElapseTime >= pUnit->m_Scene.iLastFrame* pUnit->m_Scene.iTickPerFrame)
		{
			pUnit->m_fElapseTime = pUnit->m_Scene.iFirstFrame * pUnit->m_Scene.iTickPerFrame;
		}

		for (int iMesh = 0; iMesh < pUnit->m_Scene.iNumMesh; iMesh++)
		{
			D3DXMatrixIdentity(&pUnit->m_matAnim[iMesh]);
			D3DXMatrixIdentity(&pUnit->m_matCalculation[iMesh]);
			int iParent = pUnit->m_iParent[iMesh];
			D3DXMATRIX mat;
			if (iParent >= 0)
			{
				pUnit->m_matAnim[iMesh] = m_Animation.Update(pUnit->m_fElapseTime,
					pUnit->m_pModel->m_pMesh[iMesh].get(),
					pUnit->m_matAnim[iParent],
					pUnit->m_Scene);
			}
			else
			{
				pUnit->m_matAnim[iMesh] = m_Animation.Update(pUnit->m_fElapseTime,
					pUnit->m_pModel->m_pMesh[iMesh].get(),
					mat,
					pUnit->m_Scene);
			}
			D3DXMatrixMultiply(&pUnit->m_matCalculation[iMesh], &pUnit->m_matAnim[iMesh], &m_matWorld);
		}
	}	
	return true;
}
Beispiel #30
0
void XEnitity::UpdateSkinnedMesh(const D3DXFRAME *pFrameBase)
{
	CUSTOM_FRAME* pFrame = (CUSTOM_FRAME*) pFrameBase;
	CUSTOM_MESHCONTAINER* pMeshContainer = (CUSTOM_MESHCONTAINER*) pFrame->pMeshContainer;

	while(pMeshContainer && pMeshContainer->pSkinInfo){
		
		unsigned int NumBones = pMeshContainer->pSkinInfo->GetNumBones();

		for(unsigned int i = 0; i < NumBones; ++i){
			D3DXMatrixMultiply(&m_pBoneMatrices[i],&pMeshContainer->pExBoneOffsets[i], pMeshContainer->pExFrameCombinedMatrixPointer[i]);
		}

		void* pSrc = 0;
		HRESULT hr = pMeshContainer->MeshData.pMesh->LockVertexBuffer(D3DLOCK_READONLY, (void**)&pSrc);
		if(FAILED(hr))return;

		void* pDest = 0;
		hr = pMeshContainer->pExSkinMesh->LockVertexBuffer(0, (void**)&pDest);

		hr = pMeshContainer->pSkinInfo->UpdateSkinnedMesh(m_pBoneMatrices, NULL, pSrc, pDest);

		pMeshContainer->MeshData.pMesh->UnlockVertexBuffer();
		pMeshContainer->pExSkinMesh->UnlockVertexBuffer();

		pMeshContainer = (CUSTOM_MESHCONTAINER*) pMeshContainer->pNextMeshContainer;
	}//end while

	if (pFrame->pFrameSibling)
		UpdateSkinnedMesh(pFrame->pFrameSibling);

	if(pFrame->pFrameFirstChild)
		UpdateSkinnedMesh(pFrame->pFrameFirstChild);

	return;
}