Go Back   EQEmulator Home > EQEmulator Forums > Archives > OpenEQ > OpenEQ::Development

OpenEQ::Development Development discussion for OpenEQ. Do not post for support.

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 11-26-2004, 03:08 AM
jbb
Hill Giant
 
Join Date: Mar 2003
Location: UK
Posts: 242
Default

Ok, my other PC isn't connected to the network at the moment so I'll have to retype some of this here... If you can't get it to work I'll be able to post my code later on probably.

I have this structure for placable objects

struct Object
{
long id;
long offset;
float x, y, z;
float rx, ry, rz;
float scale;
}

You're probably loading this already.
x, y, z are the locations in the world of the object and rx, ry, and rz are the rotations (In radians I guess, not sure) and scale is the scaling factor on the size of the object.

To draw it I have this code (which is using D3D vector objects and the vector math library)

D3DMATRIX tMat, rxMat, ryMat, rzMat;


D3DXMatrixTranslation(&tMat, mesh->x, mesh->y, mesh-z);

// Hmm, wierd swapping of coordinates below, can't remember why
D3DXMatrixRotationX(&rxMat, mesh->rz);
D3DXMatrixRotationY(&rxMat, mesh->ry);
D3DXMatrixRotationZ(&rxMat, mesh->rx);

// These are vector multiplies that the direct 3d library provides in their c++ classes
matWorld = mesh->scale * rzMat * ryMat * rxMat;
matWorld = matWorld * tMat;

m_pD3DDevice->SetTransform(D3DTS_WORLD, &matWorld);

So yes, basically I scale the object (in x y and z), then rotate it and then move it to it's place in the world. (I think the order of the matrix multiplies means I do it in this order)

Maybe you've got the order of these operations wrong so you're trying to scale an object which isn't at the coordinate system origin or something.

Also, the main terrain object has x, y, z coordinates and the placable objects are all positioned relative to the world object.... So you either need to add the x, y, z coordinates of the objects to those of the landscape model or do what I did and zero out the x, y, z coordinates of the terrain model before drawing it so that the placeable objects are in the same system.

Well, I'll post the actual code when I'm able to but this did seem to work for me.
Reply With Quote
 


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

Forum Jump

   

All times are GMT -4. The time now is 02:06 PM.


 

Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
       
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3