View Single Post
  #5  
Old 11-24-2010, 02:55 PM
Derision
Developer
 
Join Date: Feb 2004
Location: UK
Posts: 1,540
Default

The code in azone2 might help you out.

The placeable object locations are defined in Type 0x15 fragments in the .wld. The relevant code that processes them is in utils\azone2\wld.cpp ...
Code:
FRAG_CONSTRUCTOR(Data15) {
  struct_Data15 *hdr = (struct_Data15 *) buf;
  Placeable *plac = new Placeable;
  Placeable **pl;

  plac->x = hdr->trans[0];
  plac->y = hdr->trans[1];
  plac->z = hdr->trans[2];

  plac->rx = hdr->rot[2] / 512.f * 360.f;
  plac->ry = hdr->rot[1] / 512.f * 360.f;
  plac->rz = hdr->rot[0] / 512.f * 360.f;

  plac->scale[0] = hdr->scale[2];
  plac->scale[1] = hdr->scale[1];
  plac->scale[2] = hdr->scale[1];

  plac->model = (int) &wld->sHash[-(int)hdr->ref]; // Object name, e.g. LADDER20_ACTORDEF

  pl = new Placeable *[wld->model_data.plac_count + 1];
  memcpy(pl, wld->model_data.placeable, sizeof(Placeable *) * wld->model_data.plac_count);
  if(wld->model_data.plac_count)
    delete[] wld->model_data.placeable;
  pl[wld->model_data.plac_count] = plac;
  wld->model_data.placeable = pl;
  ++wld->model_data.plac_count;
}
As you can see, the type 0x15 fragment contains the location, rotation, scale and also the name of the object model.

The actual mesh for the object is defined in a type 0x36 fragment, so if you look in wld.cpp, under the code for FRAG_CONSTRUCTOR(Data36), you will see that the mesh is also
assigned a name:
Code:
model->name = (char *) &wld->sHash[-frag_name];
So to draw the placeable objects, you need to iterate through the list of 0x15 fragments, use the model name in the 0x15 fragment to find the mesh/polygons for that object
in the list of 0x36 fragments, and then apply the translation/rotation/scale values in the 0x15 fragment to each polygon.

void QTBuilder::AddPlaceable(... in utils\azone2\azone.cpp has the code to apply the transformations in the correct order.

The ladder and gate models that you highlight in your video are these two (output from azone2):
Code:
Processing azone.ini for placeable models.
azone.ini entry found for this zone. Including 2 models.
Including Placeable Object   17 using model   15 (MISTGATE_DMSPRITEDEF).
Including Placeable Object   18 using model   15 (MISTGATE_DMSPRITEDEF).
Including Placeable Object   77 using model   13 (LADDER20_DMSPRITEDEF).
Including Placeable Object   78 using model   13 (LADDER20_DMSPRITEDEF).
Reply With Quote