• Advertisement
Sign in to follow this  

Bump Mapping and Tokamak Physics[SOLVED]

This topic is 4048 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok, I'm having a goofy problem. I'm using tokamak physics sdk, and when I use D3DDECLUSAGE_TEXCOORD in my vertexelement array, the torque on the z axis just stops working. I debugged the code and it does not affect the rotation transform on the neRigidBody. If I take it out and replace with texcoord, it works fine, but my bump map doesn't work??? any ideas? code that clones the mesh
D3DVERTEXELEMENT9 decl[]=
{
   {0, 0,  D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0},
   {0, 12, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0},
   {0, 24, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0},
   {0, 32, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BINORMAL, 0},
   {0, 44, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT, 0},
   D3DDECL_END()
};

HRESULT hr = m_pMesh->CloneMesh(D3DXMESH_SYSTEMMEM, decl, dvc.Device(), &pMeshTemp);
if( FAILED(hr) )
{
	::MessageBox(NULL, L"Failed to clone mesh", L"", MB_OK );
	return;
}



vertex shader:
struct VS_OUTPUT
{
	float4 pos		: POSITION;
	float2 tex		: TEXCOORD0;
	float3 view		: TEXCOORD1;
	float3 light	: TEXCOORD2;
	
};

VS_OUTPUT VS( vector inPos: POSITION, 
	      float3 inNormal : NORMAL,
	      float2 inTex : TEXCOORD0,
	      float3 inBinormal : BINORMAL,
	      float3 inTangent   : TANGENT
			   )
{
	VS_OUTPUT Out = (VS_OUTPUT)0;
	Out.pos	      = mul ( inPos, matWVP );
	
        float3x3 worldToTangentSpace;
        worldToTangentSpace[0] = mul(inTangent, matWorld);
        worldToTangentSpace[1] = mul(cross(inTangent, inNormal), matWorld);
        worldToTangentSpace[2] = mul(inNormal, matWorld);
  
	float4 Pos	= mul ( inPos, matWorld );
	
	Out.tex		= inTex.xy;
	Out.view	= mul( worldToTangentSpace, vecEye - Pos );
	Out.light	= mul( worldToTangentSpace, vLightDir );
	
	return Out;
}



[Edited by - vetroXL on January 25, 2007 8:09:14 PM]

Share this post


Link to post
Share on other sites
Advertisement
Ended up being this line of code right here:


D3DXComputeBoundingBox( reinterpret_cast<D3DXVECTOR3*>( v ),
m_pMesh->GetNumVertices(),
D3DXGetFVFVertexSize( m_pMesh->GetFVF() ),
&m_AABB.m_min,
&m_AABB.m_max );




changed to:

D3DXComputeBoundingBox( reinterpret_cast<D3DXVECTOR3*>( v ),
m_pMesh->GetNumVertices(),
D3DXGetDeclVertexSize( Declaration,0 ),
&m_AABB.m_min,
&m_AABB.m_max );

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement