WoW Memory EditingWoW Memory Editing for learning purposes only.
This section is more advanced than others on MMOwnedRead the section specific rules, infractions will be given out if u break them!That is including the expectations! - If you don't meet them then don't post
I'm trying to render custom objects (so far only a simple triangle) in wow's game world, but I can't get anything to show up. I suspect it's because either my view or projection matrices are messed up, but I can't figure out how all the matrix math works. And I'm not skilled enough to reverse wow to find out how blizzard does it. All my d3d code is derived from msdn documentation and guesswork.
Here's the relevant parts of what I'm doing currently, which doesn't work. Nothing gets rendered at all.
Code:
struct CUSTOMVERTEX
{
float x, y, z;
DWORD color;
};
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ | D3DFVF_DIFFUSE)
D3DXVECTOR3 pos(targetPos); // location in the game world where object should appear
D3DXMATRIX world, view, proj;
D3DXMatrixTranslation(&world, pos.x, pos.y, pos.z);
D3DXMatrixLookAtLH(&view, &D3DXVECTOR3(cameraPos), // eye position, read from [CGWorldFrame::GetActiveCamera() + 8] (cameraPos = pointer to an array of 3 floats)
&D3DXVECTOR3(playerPos), // look-at point (should this be the player's position?) (playerPos = pointer to an array of 3 floats)
&D3DXVECTOR3(0.0f, 1.0f, 0.0f)); // up vector (should this always be 0,1,0?)
D3DXMatrixPerspectiveFovLH(&proj, fov, 1.333f, 0.1f, 1000000.0f); // fov is read from [active camera + 0x40], aspect ratio is 1024/768
pDevice->SetTransform(D3DTS_WORLD, &world);
pDevice->SetTransform(D3DTS_VIEW, &view);
pDevice->SetTransform(D3DTS_PROJECTION, &proj);
pDevice->SetFVF(D3DFVF_CUSTOMVERTEX);
pDevice->SetRenderState(D3DRS_ZENABLE, FALSE);
pDevice->SetRenderState(D3DRS_LIGHTING, FALSE);
pDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
pDevice->SetStreamSource(0, vb, 0, sizeof(CUSTOMVERTEX)); // vertex buffer vb contains 3 vertices for a simple triangle
pDevice->DrawPrimitive(D3DPT_TRIANGLELIST, 0, 1);
Looking at the debug output from the directx debug runtime doesn't show any errors.
What am I doing wrong? I 'm not asking for any copy-and-paste code, just some pointers on what I should be doing instead.
Thanks,
Mike
Donate to remove ads, get your "DONATOR title, and get access to the MMOwned community's elite Shoutbawx.
I can't help you out all the way, however I can steer you in the direction you should be going.
First of all, WoW's renderer is Direct3D 9 (if you use D3D9 instead of OpenGL). Now Direct3D 9 isn't thread safe persé so I suggest you do all your own rendering calls on the WoW's main thread, the same thread where WoW does all the rendering.
The thing you need to do is hooking the IDirect3DDevice9::EndScene. Prior executing the original EndScene code, you should batch your own render calls.
For the rest I would like to point out one another what you did so far:
There is no reason to call these members again, since these variables usually don't change during a frame. Its only the World matrix you are interested in, because that defines the position where you are going to draw your own geometry.
Also take a note that WoW uses effects (custom Vertex and Pixel shading) for some stages in the render process, make sure to call the
Well I have said this before and I got my ass kicked then, but i say this again. Wow's game world is a right hand coordinate system. Positive X is "North", Positive Y is "West" and Positive Z is "up". (This might not be true for M2 and WO model coord system though)
I use D3DXMatrixLookAtRH(&view, &eye, &lookAt, &up);
Used it for both terrain mapping and In game rendering.
Thanks for your help guys, got rendering partially working now
Quote:
Originally Posted by Maeco
Hello Mike,
First of all, WoW's renderer is Direct3D 9 (if you use D3D9 instead of OpenGL). Now Direct3D 9 isn't thread safe persé so I suggest you do all your own rendering calls on the WoW's main thread, the same thread where WoW does all the rendering.
The thing you need to do is hooking the IDirect3DDevice9::EndScene. Prior executing the original EndScene code, you should batch your own render calls.
Yes, I forgot to write I am doing this from an EndScene hook, sorry
Quote:
There is no reason to call these members again, since these variables usually don't change during a frame. Its only the World matrix you are interested in, because that defines the position where you are going to draw your own geometry.
If I don't set the view and projection matrices then nothing gets rendered.
Quote:
Also take a note that WoW uses effects (custom Vertex and Pixel shading) for some stages in the render process, make sure to call the
members passing along a NULL argument. That way you will be using the fixed function pipeline again.
This was my main issue, I feel so stupid for overlooking shaders. Thanks
Quote:
Originally Posted by ggg898
Well I have said this before and I got my ass kicked then, but i say this again. Wow's game world is a right hand coordinate system. Positive X is "North", Positive Y is "West" and Positive Z is "up". (This might not be true for M2 and WO model coord system though)
I use D3DXMatrixLookAtRH(&view, &eye, &lookAt, &up);
Used it for both terrain mapping and In game rendering.
Yes I noticed this when things started to move in the wrong directions when I rotated the camera. With a right handed system everything moves like it should relative to camera movements.
But my matrices must still be wrong because my objects appear in the wrong position.
When I'm standing on the target location (ie target is in the center of the screen) it gets rendered correctly, but if I move away my objects gets rendered exactly halfway between my position and the target position.
I'm trying to learn some more 3d projection math now, and I'll post back here if I make any progress. Problem is, I hate math :P
Thanks for your help guys, got rendering partially working now
Yes, I forgot to write I am doing this from an EndScene hook, sorry
If I don't set the view and projection matrices then nothing gets rendered.
This was my main issue, I feel so stupid for overlooking shaders. Thanks
Yes I noticed this when things started to move in the wrong directions when I rotated the camera. With a right handed system everything moves like it should relative to camera movements.
But my matrices must still be wrong because my objects appear in the wrong position.
When I'm standing on the target location (ie target is in the center of the screen) it gets rendered correctly, but if I move away my objects gets rendered exactly halfway between my position and the target position.
I'm trying to learn some more 3d projection math now, and I'll post back here if I make any progress. Problem is, I hate math :P
Your FoV is wrong, as well as your 'eye' matrix.
__________________
[Only registered and activated users can see links. ]
Are you sure it's wrong? The value at camera+40h converted to degrees is 90, which seems like a reasonable value for the FoV.
I took the offset from kynox's info in [Only registered and activated users can see links. ]
Is that outdated info?
Mike, you could also hook those method calls the same way you did with EndScene. That way you can see what values are passed, same goes for the View and Projection matrices.
Mike, you could also hook those method calls the same way you did with EndScene. That way you can see what values are passed, same goes for the View and Projection matrices.
WoW does not use the transforms for anything but the radar. Everything is done through vertex shading, and hence his creation of his own matrixes is the proper way.
Like Apoc said, Up should be 0, 1, 0 and your Fov is wrong. Look into the Camera functions and you'll see how they use the fov in their call. Tip: it's not 90 or 45.
__________________
[Only registered and activated users can see links. ]
WoW does not use the transforms for anything but the radar. Everything is done through vertex shading, and hence his creation of his own matrixes is the proper way.
Ok good to know, I was oblivious to this and kinda assumed WoW was using them.
Like Apoc said, Up should be 0, 1, 0 and your Fov is wrong. Look into the Camera functions and you'll see how they use the fov in their call. Tip: it's not 90 or 45.
Thanks for the hint about the camera functions. I couldn't find the place where they actually use the FoV for matrix construction, but I did find a function where they multiply camera+0x40 by 0.6. I don't know if it's the proper way to do it, but it works and everything gets rendered in the right place.
Thanks for the hint about the camera functions. I couldn't find the place where they actually use the FoV for matrix construction, but I did find a function where they multiply camera+0x40 by 0.6. I don't know if it's the proper way to do it, but it works and everything gets rendered in the right place.
There you go
__________________
[Only registered and activated users can see links. ]