Rendering in wow's game world. menu

User Tag List

Results 1 to 11 of 11
  1. #1
    _Mike's Avatar Contributor
    Reputation
    310
    Join Date
    Apr 2008
    Posts
    531
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Rendering in wow's game world.

    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

    Rendering in wow's game world.
  2. #2
    Maeco's Avatar Member
    Reputation
    2
    Join Date
    May 2009
    Posts
    14
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    RE: Rendering in wow's game world.

    Hello Mike,

    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:
    Code:
    pDevice->SetTransform(D3DTS_VIEW, &view);
    pDevice->SetTransform(D3DTS_PROJECTION, &proj);
    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
    Code:
    IDirect3DDevice9::SetVertexShader 
    IDirect3DDevice9::SetPixelShader
    members passing along a NULL argument. That way you will be using the fixed function pipeline again.


    I hope I helped you somewhat, its not very easy what you are trying to do if you don't know much about Rev. Engineering just like me , so good luck!

    Regards,

    Maeco

  3. #3
    ggg898's Avatar Member
    Reputation
    10
    Join Date
    Jan 2009
    Posts
    39
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  4. #4
    _Mike's Avatar Contributor
    Reputation
    310
    Join Date
    Apr 2008
    Posts
    531
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for your help guys, got rendering partially working now

    Originally Posted by Maeco View Post
    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

    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.

    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
    Code:
    IDirect3DDevice9::SetVertexShader 
    IDirect3DDevice9::SetPixelShader
    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

    Originally Posted by ggg898 View Post
    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

  5. #5
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by _Mike View Post
    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.

  6. #6
    _Mike's Avatar Contributor
    Reputation
    310
    Join Date
    Apr 2008
    Posts
    531
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Apoc View Post
    Your FoV is wrong
    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 Camera - WoW.Dev Wiki
    Is that outdated info?
    Originally Posted by Apoc View Post
    as well as your 'eye' matrix.
    Any more hints on what's wrong with it please?

  7. #7
    Maeco's Avatar Member
    Reputation
    2
    Join Date
    May 2009
    Posts
    14
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  8. #8
    kynox's Avatar Member
    Reputation
    830
    Join Date
    Dec 2006
    Posts
    888
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Maeco View Post
    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.

  9. #9
    Maeco's Avatar Member
    Reputation
    2
    Join Date
    May 2009
    Posts
    14
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by kynox View Post
    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.

  10. #10
    _Mike's Avatar Contributor
    Reputation
    310
    Join Date
    Apr 2008
    Posts
    531
    Thanks G/R
    0/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by kynox View Post
    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.

  11. #11
    kynox's Avatar Member
    Reputation
    830
    Join Date
    Dec 2006
    Posts
    888
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by _Mike View Post
    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

Similar Threads

  1. Replies: 6
    Last Post: 08-20-2015, 02:04 AM
  2. [Selling] col******* WoW GTC ★★★ [US] World of Warcraft 30/90/180 Days Game Time Codes [US] ★★★
    By coldrainer in forum World of Warcraft Buy Sell Trade
    Replies: 1
    Last Post: 10-26-2014, 11:34 AM
  3. WoW In-game Font?
    By Dark34 in forum Community Chat
    Replies: 3
    Last Post: 02-04-2007, 07:43 AM
  4. free 15 days trial not 10!!! ... WoW card/game for 20 dollars!!!
    By ragingazn628 in forum World of Warcraft Guides
    Replies: 9
    Last Post: 12-06-2006, 07:46 AM
All times are GMT -5. The time now is 01:07 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search