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

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

Reply
 
Thread Tools Display Modes
  #1  
Old 11-21-2004, 11:40 AM
daeken_bb
Discordant
 
Join Date: Mar 2003
Location: Chambersburg, PA
Posts: 469
Default Placeable object help please.

I need a bit of help with the .zon file format. I have placeable objects rendering perfectly, but the scaling is way off. I'm currently using the scaling variable as a float and scaling x and y by this. Is that not the proper way to do it? If not, please tell me how to scale the objects

Happy Hacking,
Lord Daeken M. BlackBlade
(Cody Brocious)
__________________
Keep me unemployed and working on OpenEQ, PM me about donating

Check out my deviantART page at http://daeken.deviantart.com/
Reply With Quote
  #2  
Old 11-26-2004, 02:31 AM
jbb
Hill Giant
 
Join Date: Mar 2003
Location: UK
Posts: 242
Default

I'll look what I did in my renderer where it seemed about right.
But it's on my other computer which is currently in pieces... When I put it back together I'll have a look. In an hour or two maybe.
Reply With Quote
  #3  
Old 11-26-2004, 02:38 AM
daeken_bb
Discordant
 
Join Date: Mar 2003
Location: Chambersburg, PA
Posts: 469
Default

Quote:
Originally Posted by jbb
I'll look what I did in my renderer where it seemed about right.
But it's on my other computer which is currently in pieces... When I put it back together I'll have a look. In an hour or two maybe.
Great, thanks
__________________
Keep me unemployed and working on OpenEQ, PM me about donating

Check out my deviantART page at http://daeken.deviantart.com/
Reply With Quote
  #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
  #5  
Old 11-26-2004, 03:51 AM
jbb
Hill Giant
 
Join Date: Mar 2003
Location: UK
Posts: 242
Default

The full source is here:
http://eqengine.fx2100.com/eqengine_src.zip

It's windows, c++ and direct3d 9 but hopefull it will make some sense.

I don't know if this version even builds at all but hopefully it's not too far from the one that did.
Reply With Quote
  #6  
Old 11-26-2004, 04:36 AM
daeken_bb
Discordant
 
Join Date: Mar 2003
Location: Chambersburg, PA
Posts: 469
Default

This is really starting to bug the hell out of me now lol.

It seems that I'm not only doing the scaling properly, but also the rotation seems waaaaay off. I tried converting radians into degrees, but that just made the problem worse heh.

I'm about ready to call sony up and ask for a bit of help on this

Here's the code for the placeable object draw routine, in case this is where the problem is:
Code:
  for(j = 0; j < this->model_data->plac_count; ++j) {
    plac = this->model_data->placeable[j];
    glPushMatrix();
    glLoadIdentity();
    
    glRotatef(270, 1.0, 0.0, 0.0);
    glRotatef(rot[1], 1.0, 0.0, 0.0);
    glRotatef(rot[0], 0.0, 0.0, 1.0);

    glScalef(plac->scale, plac->scale, plac->scale);
    
    glTranslatef(trans[0], trans[1], trans[2]);

    glTranslatef(plac->x, plac->y, plac->z);
    
    glRotatef(plac->rx, 1.0f, 0.0f, 0.0f);
    glRotatef(plac->ry, 0.0f, 1.0f, 0.0f);
    glRotatef(plac->rz, 0.0f, 0.0f, 1.0f);
    
    glCallList(this->model_lists[plac->model]);
    
    glPopMatrix();
  }
And here's the code for the placeable object placement/rotation loader from zon.cpp:
Code:
  for(i = 0; i < hdr->obj_count; ++i) {
    plac = (zon_placeable *) buffer;

    this->model_data.placeable[i] = new Placeable;

    this->model_data.placeable[i]->x = plac->x;
    this->model_data.placeable[i]->y = plac->y;
    this->model_data.placeable[i]->z = plac->z;

    this->model_data.placeable[i]->rx = plac->rx;
    this->model_data.placeable[i]->ry = plac->ry;
    this->model_data.placeable[i]->rz = plac->rz;

    this->model_data.placeable[i]->scale = plac->scale;
    this->model_data.placeable[i]->model = 0;

    zon_tmp = zon_orig + plac->loc;
    while(zon_tmp[strlen((char *) zon_tmp) - 4] != '.')
      zon_tmp += strlen((char *) zon_tmp) + 1;
    for(j = 0; j < this->model_data.model_count; ++j) {
      if(!strcmp(model_names[j], (char *) zon_tmp)) {
        this->model_data.placeable[i]->model = j;
        break;
      }
    }

    buffer += sizeof(zon_placeable);
  }
If you see anything obviously wrong, please let me know hehe.

Happy Hacking,
Lord Daeken M. BlackBlade
(Cody Brocious)
__________________
Keep me unemployed and working on OpenEQ, PM me about donating

Check out my deviantART page at http://daeken.deviantart.com/
Reply With Quote
  #7  
Old 11-26-2004, 04:45 AM
jbb
Hill Giant
 
Join Date: Mar 2003
Location: UK
Posts: 242
Default

I don't see anything immediatly wrong. The only thing I can think of immediately is are you locating the start of the array of objects in the zone file properly?

Is it drawing the objects in what look like the right places?
Even if they are the wrong size & orientation?

You can usually spot things like likes of torches down corridors in some of the zones.
Reply With Quote
  #8  
Old 11-26-2004, 04:47 AM
daeken_bb
Discordant
 
Join Date: Mar 2003
Location: Chambersburg, PA
Posts: 469
Default

Quote:
Originally Posted by jbb
I don't see anything immediatly wrong. The only thing I can think of immediately is are you locating the start of the array of objects in the zone file properly?

Is it drawing the objects in what look like the right places?
Even if they are the wrong size & orientation?

You can usually spot things like likes of torches down corridors in some of the zones.
Yea, they objects are definitely where they're supposed to be, it's just that the scaling and rotation is waaay off it seems.
__________________
Keep me unemployed and working on OpenEQ, PM me about donating

Check out my deviantART page at http://daeken.deviantart.com/
Reply With Quote
  #9  
Old 11-26-2004, 04:54 AM
jbb
Hill Giant
 
Join Date: Mar 2003
Location: UK
Posts: 242
Default

Hmm,
maybe if you print out the scaling, location and rotation vectors of some of the objects inside the drawing loop then I could compare them with what I get.

Then at least you might be able to establish if the problem is in the loading or the drawing code.

Probably not going to be able to do that with my code until tomorrow though.
Reply With Quote
  #10  
Old 11-26-2004, 05:12 AM
daeken_bb
Discordant
 
Join Date: Mar 2003
Location: Chambersburg, PA
Posts: 469
Default

Oh bloody 'ell... I just realized some stuff...

1) I've been drawing 2 zone meshes (yes, i feel stupid)
2) I've never offset the transformations (which is ok because I haven't been following the transformation for the zone mesh, i guess)

So, now that I feel like a total asshat...
http://home.archshadow.com/~daeken/draniksscar.txt
http://home.archshadow.com/~daeken/anguish.txt
http://home.archshadow.com/~daeken/wallofslaughter.txt
http://home.archshadow.com/~daeken/riftseekers.txt
__________________
Keep me unemployed and working on OpenEQ, PM me about donating

Check out my deviantART page at http://daeken.deviantart.com/
Reply With Quote
  #11  
Old 11-26-2004, 06:31 AM
jbb
Hill Giant
 
Join Date: Mar 2003
Location: UK
Posts: 242
Default

Sorry I'm not going to have time to look at this tonight, but i'll see what mine is outputting tomorrow morning. Yours looks like it is probably right though.
Reply With Quote
  #12  
Old 11-26-2004, 06:34 AM
jbb
Hill Giant
 
Join Date: Mar 2003
Location: UK
Posts: 242
Default

You don't have any additional rotations and scaling in the display list do you?
Reply With Quote
  #13  
Old 11-26-2004, 06:38 AM
daeken_bb
Discordant
 
Join Date: Mar 2003
Location: Chambersburg, PA
Posts: 469
Default

Quote:
Originally Posted by jbb
Sorry I'm not going to have time to look at this tonight, but i'll see what mine is outputting tomorrow morning. Yours looks like it is probably right though.

You don't have any additional rotations and scaling in the display list do you?
Thanks... whenever you have time that's fine

No, the display list doesn't have anything aside from the triangle drawing and tex coords.
__________________
Keep me unemployed and working on OpenEQ, PM me about donating

Check out my deviantART page at http://daeken.deviantart.com/
Reply With Quote
  #14  
Old 11-26-2004, 09:14 AM
daeken_bb
Discordant
 
Join Date: Mar 2003
Location: Chambersburg, PA
Posts: 469
Default

Well, I have the doors in anguish placed properly, but they're the only objects showing up in the right place with the right rotation lol:





I'm making some progress, but it's still not quite right.
__________________
Keep me unemployed and working on OpenEQ, PM me about donating

Check out my deviantART page at http://daeken.deviantart.com/
Reply With Quote
  #15  
Old 11-27-2004, 12:02 AM
jbb
Hill Giant
 
Join Date: Mar 2003
Location: UK
Posts: 242
Default

Good morning!
I've put my dump for dranksscar at
http://eqengine.fx2100.com/output.txt

The position data looks the same as yours.

However my renderer seems to be rather wrong in that zone too.
I need to do some more checking.

Edit: I rewrote this post as first of all I though mine was working but it's not. Perhaps we've misinterpreted the data structure in some way. It looks right, but maybe those aren't just x, y, z rotations,
Reply With Quote
Reply


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 12:28 AM.


 

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 - 2024, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3