Control Of Bone

Started by
37 comments, last by VitaliBR 13 years, 3 months ago
[font=arial, sans-serif]Thanks guy, Now it works biggrin.gif
[font=arial, sans-serif]

[font=arial, sans-serif]just something weird is happening unsure.gif


[font=arial, sans-serif]when the cursor approaches the player, the arm moves strangely, see:
[font=arial, sans-serif][media]
[/media]
http://mateusvitali.wordpress.com/
Advertisement
Whew! Glad you have it at least partially working. But it's obviously not working correctly. I'm guessing that:

1. You're not calculating the angle between the bone location and mouse location correctly.
or
2. The mouse or bone location coordinates haven't been correctly converted to client coordinates.

Are you sure you're converting the mouse point to client coordinates correctly?

Are you using exactly the same world matrix in the D3DXVec3Project call that you use to render the object?

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.


Whew! Glad you have it at least partially working

rolleyes.gif


Are you sure you're converting the mouse point to client coordinates correctly?

[font="arial, sans-serif"]I think so,
GetCursorPos(&absCursor);
ScreenToClient(wndHandle,&absCursor);
D3DXVECTOR3 mouseLocation((float)absCursor.x,(float)absCursor.y,0);
player->mouselocal(mouseLocation, WIDTH, pm, vm,vp);

void mouselocal(D3DXVECTOR3 pos_of_Mouse, int Width, D3DXMATRIX pm, D3DXMATRIX vm, D3DVIEWPORT9 vp);



Are you using exactly the same world matrix in the D3DXVec3Project call that you use to render the object?

Yes,
[font="arial, sans-serif"]I'm using the matrix matWorld [font="arial, sans-serif"]used to render the mesh
[font="arial, sans-serif"]look:
[font="arial, sans-serif"][font="arial, sans-serif"]class SKINNEDMESH
{
public:
SKINNEDMESH();
~SKINNEDMESH();
//...
//...

private:
//...
//...

// Setup world matrix
D3DXMATRIXA16 matWorld,matWorld2;

//...
//...
};

[font="arial, sans-serif"] //...
//...
D3DXMatrixTranslation( &matWorld2, vPos.x, vPos.y,vPos.z );

D3DXMatrixMultiply(&matWorld,&matWorld,&matWorld2);

m_pDevice->SetTransform( D3DTS_WORLD, &matWorld );

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


[font="arial, sans-serif"] D3DXMATRIX final = bone->TransformationMatrix*(*parentMatrix);
D3DXVECTOR3 boneLocation(final._41,final._42,final._43);
D3DXVec3Project(&boneLocation,&boneLocation,&m_vp,&m_pm,&m_vm,&matWorld);

http://mateusvitali.wordpress.com/

player->mouselocal(mouseLocation, WIDTH, pm, vm, vp);

I don't know what that function does, but you don't need to do anything with mouseLocation after you convert it to client coordinates!

Comment out that line and try it.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.



player->mouselocal(mouseLocation, WIDTH, pm, vm, vp);

I don't know what that function does, but you don't need to do anything with mouseLocation after you convert it to client coordinates!

Comment out that line and try it.


[font="arial, sans-serif"]This line just gets the parameters and saves the class variables
[font="arial, sans-serif"]void SKINNEDMESH::mouselocal(D3DXVECTOR3 pos, int Width, D3DXMATRIX pm, D3DXMATRIX vm, D3DVIEWPORT9 vp)
{
mouseLocation = pos;
m_Width = Width;
m_pm = pm;
m_vm = vm;
m_vp = vp;
}

http://mateusvitali.wordpress.com/
Ah! Okay. It appears it shouldn't be commented out!

Reviewing some of the logged data you posted above, you might try logging the same information when the mouse pointer is directly on top (or very close to) the bone location. The intent of using D3DXVec3Project is to get the bone location and the mouse location both in client coordinates.

When the mouse pointer is very close to the bone location, the bone location X and Y coordinates should be almost the same as the mouse location - within a few pixels. I think you logged that data before you changed D3DXVec3Project to use the correct world matrix.


Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

[font=arial, sans-serif]I solved the problem just by commenting out the line ScreenToClient (wndHandle, &absCursor); biggrin.gif


[font=arial, sans-serif]This working 100% now, thanks for the help buckeye
http://mateusvitali.wordpress.com/
Curious. Nevertheless, good job of keeping at it.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

[media]
[/media]

biggrin.gif
http://mateusvitali.wordpress.com/

This topic is closed to new replies.

Advertisement