4 Replies - 1173 Views - Last Post: 10 March 2012 - 08:48 AM Rate Topic: -----

#1 Justei  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 2
  • Joined: 04-March 12

Moving a mesh in directx problem, does not move.

Posted 04 March 2012 - 07:49 AM

Hello!
I have a problem with some code I have made, I have made a d3d hook that basically changes some stuff up for me.
(NOW, so people don't think I'm creating a cheat, I am not, actually it's a hook for a private server for a MMO).

What I am trying to accomplish is to load a model at specific coordinates in the game.

My code is the following:

LPD3DXMESH mesh;
LPD3DXBUFFER materialBuffer;
DWORD numMaterials;
D3DXMATERIAL* d3dxMaterials;
D3DMATERIAL9 *meshMaterials;
LPDIRECT3DTEXTURE9 *meshTextures;

HRESULT hr=D3DXLoadMeshFromXA("arrow.x", D3DXMESH_DONOTCLIP,
		pDevice, NULL,
		&materialBuffer,NULL, &numMaterials,
		&mesh );

	d3dxMaterials = (D3DXMATERIAL*)materialBuffer->GetBufferPointer();
	meshMaterials = new D3DMATERIAL9[numMaterials];
	meshTextures  = new LPDIRECT3DTEXTURE9[numMaterials];


	for (DWORD i=0; i<numMaterials; i++)
	{

		// Copy the material
		meshMaterials[i] = d3dxMaterials[i].MatD3D;

		// Set the ambient color for the material (D3DX does not do this)
		meshMaterials[i].Ambient = meshMaterials[i].Diffuse;

		// Create the texture if it exists - it may not
		meshTextures[i] = NULL;
		if (d3dxMaterials[i].pTextureFilename)
			D3DXCreateTextureFromFileA(pDevice, d3dxMaterials[i].pTextureFilename,     &meshTextures[i]);

	}


	for (DWORD i=0; i<numMaterials; i++)
	{
		// Set the material and texture for this subset
		pDevice->SetMaterial(&meshMaterials[i]);
		pDevice->SetTexture(0,meshTextures[i]);

		// Draw the mesh subset
		mesh->DrawSubset( i );
	}



         D3DXMATRIX  matIdt,RotY,Mov;
	 D3DXMatrixTranslation(&Mov,5000.0f, 0.0f, 20.5f);
	 D3DXMatrixRotationY(&RotY,350);
	 D3DXMatrixMultiply(&matIdt,&RotY,&Mov);
 
	 pDevice->SetTransform(D3DTS_WORLD,&matIdt);



Now, the result looks like this:
Posted Image

As you can tell, it gets attached to the arm of the character, and no matter what coordinates I put in Mov, it doesn't change a bit.

Now, I havent worked with matrixes in this way before, so I am not sure if I am doing this correct, only been working with graphics engines directly that had functions that let you set the coordinates of a specific model.

It seems as it's attaching the model to the joint of the characters arm for some reason, even though I did not specify that. Any ideas?

Is This A Good Question/Topic? 1
  • +

Replies To: Moving a mesh in directx problem, does not move.

#2 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Moving a mesh in directx problem, does not move.

Posted 04 March 2012 - 04:31 PM

Have you used your debugger to ensure the relevant values are being updated?
Was This Post Helpful? 0
  • +
  • -

#3 Justei  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 2
  • Joined: 04-March 12

Re: Moving a mesh in directx problem, does not move.

Posted 05 March 2012 - 09:29 AM

View PostButchDean, on 04 March 2012 - 04:31 PM, said:

Have you used your debugger to ensure the relevant values are being updated?

Yes, it seems like everything that (from what I can tell) is set correctly :S..
Was This Post Helpful? 0
  • +
  • -

#4 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 0
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: Moving a mesh in directx problem, does not move.

Posted 05 March 2012 - 02:19 PM

So now you need to find out where those successfully updated variables are referenced. This is all standard debugging procedure, give it a little thought! ;)
Was This Post Helpful? 0
  • +
  • -

#5 RUAg4mer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 47
  • Joined: 30-July 11

Re: Moving a mesh in directx problem, does not move.

Posted 10 March 2012 - 08:48 AM

I think you should be calling your world matrix inside your matrixTranslation. then multiply it in the transform. I think but it's worth a shot.

you have D3DXMatrixTranslation(&Mov,5000.0f, 0.0f, 20.5f);

i think it should be something like

D3DXMatrixTranslation(&matIdt,5000.0f, 0.0f, 20.5f);

maybe.

This post has been edited by RUAg4mer: 10 March 2012 - 08:48 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1