Network: WoW Gold | WoW Accounts | MPS Games | FPSowned
MMOwned - World of Warcraft Exploits, Hacks, Bots and Guides
Homepage »      Register »      Hall of Fame »      Ranks And Awards »      Advertise »      Marketplace »
 
Sign up



Do you like this excellent information? Then Donate HERE to remove ads and support the MMOwned community.


Go Back   MMOwned - World of Warcraft Exploits, Hacks, Bots and Guides > World of Warcraft > Bots and Programs > WoW Memory Editing

WoW Memory Editing WoW Memory Editing for learning purposes only.
This section is more advanced than others on MMOwned Read 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

Reply
 
LinkBack Thread Tools
  #1  
Old 10-10-2009
_Mike is offline.
New User
  
 
Join Date: Apr 2008
Posts: 13
Reputation: 1
Points: 357, Level: 1
Points: 357, Level: 1 Points: 357, Level: 1 Points: 357, Level: 1
Level up: 90%, 43 Points needed
Level up: 90% Level up: 90% Level up: 90%
Activity: 1.8%
Activity: 1.8% Activity: 1.8% Activity: 1.8%

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
Reply With Quote


Donate to remove ads, get your "DONATOR title, and get access to the MMOwned community's elite Shoutbawx.

  #2  
Old 10-10-2009
Maeco is offline.
New User
  
 
Join Date: May 2009
Posts: 14
Reputation: 2
Points: 101, Level: 1
Points: 101, Level: 1 Points: 101, Level: 1 Points: 101, Level: 1
Level up: 26%, 299 Points needed
Level up: 26% Level up: 26% Level up: 26%
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
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:
Quote:
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
Reply With Quote
  #3  
Old 10-10-2009
ggg898 is offline.
Corporal
  
 
Join Date: Jan 2009
Posts: 33
Reputation: 10
Points: 348, Level: 1
Points: 348, Level: 1 Points: 348, Level: 1 Points: 348, Level: 1
Level up: 87%, 52 Points needed
Level up: 87% Level up: 87% Level up: 87%
Activity: 1.1%
Activity: 1.1% Activity: 1.1% Activity: 1.1%

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.
Reply With Quote
  #4  
Old 10-10-2009
_Mike is offline.
New User
  
 
Join Date: Apr 2008
Posts: 13
Reputation: 1
Points: 357, Level: 1
Points: 357, Level: 1 Points: 357, Level: 1 Points: 357, Level: 1
Level up: 90%, 43 Points needed
Level up: 90% Level up: 90% Level up: 90%
Activity: 1.8%
Activity: 1.8% Activity: 1.8% Activity: 1.8%

Thanks for your help guys, got rendering partially working now

Quote:
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

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
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

Quote:
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
Reply With Quote
  #5  
Old 10-10-2009
Apoc's Avatar
Apoc is offline.
MMOwned WebDev
Legendary User
  
 
Join Date: Jan 2008
Posts: 1,909
Nominated 5 Times in 1 Post
Reputation: 1029
Points: 22,671, Level: 21
Points: 22,671, Level: 21 Points: 22,671, Level: 21 Points: 22,671, Level: 21
Level up: 17%, 1,329 Points needed
Level up: 17% Level up: 17% Level up: 17%
Activity: 35.7%
Activity: 35.7% Activity: 35.7% Activity: 35.7%

Quote:
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.
__________________
[Only registered and activated users can see links. ]
Reply With Quote
  #6  
Old 10-12-2009
_Mike is offline.
New User
  
 
Join Date: Apr 2008
Posts: 13
Reputation: 1
Points: 357, Level: 1
Points: 357, Level: 1 Points: 357, Level: 1 Points: 357, Level: 1
Level up: 90%, 43 Points needed
Level up: 90% Level up: 90% Level up: 90%
Activity: 1.8%
Activity: 1.8% Activity: 1.8% Activity: 1.8%

Quote:
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 [Only registered and activated users can see links. ]
Is that outdated info?
Quote:
Originally Posted by Apoc View Post
as well as your 'eye' matrix.
Any more hints on what's wrong with it please?
Reply With Quote
  #7  
Old 10-12-2009
Maeco is offline.
New User
  
 
Join Date: May 2009
Posts: 14
Reputation: 2
Points: 101, Level: 1
Points: 101, Level: 1 Points: 101, Level: 1 Points: 101, Level: 1
Level up: 26%, 299 Points needed
Level up: 26% Level up: 26% Level up: 26%
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
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.
Reply With Quote
  #8  
Old 10-12-2009
kynox's Avatar
kynox is offline.
Warden's Mediator
Legendary User
  
 
Join Date: Dec 2006
Location: Raping your Stack
Posts: 774
Nominated 2 Times in 1 Post
Reputation: 797
Points: 28,091, Level: 24
Points: 28,091, Level: 24 Points: 28,091, Level: 24 Points: 28,091, Level: 24
Level up: 53%, 809 Points needed
Level up: 53% Level up: 53% Level up: 53%
Activity: 5.2%
Activity: 5.2% Activity: 5.2% Activity: 5.2%

Quote:
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.
__________________
[Only registered and activated users can see links. ]
Reply With Quote
  #9  
Old 10-13-2009
Maeco is offline.
New User
  
 
Join Date: May 2009
Posts: 14
Reputation: 2
Points: 101, Level: 1
Points: 101, Level: 1 Points: 101, Level: 1 Points: 101, Level: 1
Level up: 26%, 299 Points needed
Level up: 26% Level up: 26% Level up: 26%
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Quote:
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.
Reply With Quote
  #10  
Old 10-13-2009
_Mike is offline.
New User
  
 
Join Date: Apr 2008
Posts: 13
Reputation: 1
Points: 357, Level: 1
Points: 357, Level: 1 Points: 357, Level: 1 Points: 357, Level: 1
Level up: 90%, 43 Points needed
Level up: 90% Level up: 90% Level up: 90%
Activity: 1.8%
Activity: 1.8% Activity: 1.8% Activity: 1.8%

Quote:
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.
Reply With Quote
  #11  
Old 10-13-2009
kynox's Avatar
kynox is offline.
Warden's Mediator
Legendary User
  
 
Join Date: Dec 2006
Location: Raping your Stack
Posts: 774
Nominated 2 Times in 1 Post
Reputation: 797
Points: 28,091, Level: 24
Points: 28,091, Level: 24 Points: 28,091, Level: 24 Points: 28,091, Level: 24
Level up: 53%, 809 Points needed
Level up: 53% Level up: 53% Level up: 53%
Activity: 5.2%
Activity: 5.2% Activity: 5.2% Activity: 5.2%

Quote:
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
__________________
[Only registered and activated users can see links. ]
Reply With Quote
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On



All times are GMT -4. The time now is 12:44 PM.




Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.1

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493