Author Topic: How pof files work  (Read 1810 times)

0 Members and 1 Guest are viewing this topic.

Offline RandomTiger

  • Senior Member
  • 211
How pof files work
Is there any documentation on how the pof model files store the vertex data?

 

Offline IceFire

  • GTVI Section 3
  • 212
    • http://www.3dap.com/hlp/hosted/ce
I'm not really a programmer so I can't tell an array from a string...but here's what DNet has on the POF specs.  May or may not be useful to you...but I think its all that we have.

http://www.freespace-2.com/ddn/specs/pof/
- IceFire
BlackWater Ops, Cold Element
"Burn the land, boil the sea, you can't take the sky from me..."

 

Offline Bobboau

  • Just a MODern kinda guy
    Just MODerately cool
    And MODest too
  • 213
it is the first chunk in the bsp data held in each SOBJ chunk, for each def point there are a number of normals (used for each point in every polygon this defpoint is used in)
here is an example of some code that I used to load the defpoints

Code: [Select]
void OBJ2::parse_defpoint(int offset){
//CString debug_string;
int oldoffset = offset;
offset += 8;
//MessageBox(NULL, "into defpoint", "!", MB_OK);
int OFFSET;
render_data.normcount = &bsp_data[oldoffset + 20];

//MessageBox(NULL, "past normcount", "!", MB_OK);
parseI(render_data.n_defpoints, bsp_data, offset);
parseI(render_data.n_norms, bsp_data, offset);
parseI(OFFSET, bsp_data, offset);

/* for(int i = 0; idebug_string.Format("point %d has %d norms",i, (int)normcount[i]);
MessageBox(NULL, debug_string, "!", MB_OK);
}
*/
offset = oldoffset +OFFSET;
render_data.defpoint = new vector[render_data.n_defpoints];
render_data.normal = new vector[render_data.n_norms];

//debug_string.Format("about to enter the defpoint/normal parseing thingy, with %d points",render_data.n_defpoints);
//MessageBox(NULL, debug_string, "!", MB_OK);
int k = 0;
for(int i = 0; i memcpy(&render_data.defpoint[i].x, &bsp_data[offset], sizeof(float));
memcpy(&render_data.defpoint[i].y, &bsp_data[offset += sizeof(float)], sizeof(float));
memcpy(&render_data.defpoint[i].z, &bsp_data[offset += sizeof(float)], sizeof(float));
offset += sizeof(float);
// parseV(render_data.defpoint, bsp_data, off_set);

// offset += sizeof(vector)*normcount[i];

//debug_string.Format("iteration %d, defpoint x %0.2f y %0.2f z %0.2f",i, render_data.defpoint[i].x, render_data.defpoint[i].y, render_data.defpoint[i].z);
//MessageBox(NULL, debug_string, "!", MB_OK);

for(int z = 0; z memcpy(&render_data.normal[k].x, &bsp_data[offset], sizeof(float));
memcpy(&render_data.normal[k].y, &bsp_data[offset += sizeof(float)], sizeof(float));
memcpy(&render_data.normal[k++].z, &bsp_data[offset += sizeof(float)], sizeof(float));
offset += sizeof(float);

// parseV(render_data.normal[i][k], bsp_data, off_set);

//debug_string.Format("normal %d, x %0.2f y %0.2f z %0.2f",k ,render_data.normal[(i*render_data.normcount[i])+k].x ,render_data.normal[(i*render_data.normcount[i])+k].y ,render_data.normal[(i*render_data.normcount[i])+k].z);
//MessageBox(NULL, debug_string, "!", MB_OK);

}
}

//debug_string.Format("defpoints, n_defpoints %d, n_norms %d,\n first defpoint x %0.2f y %0.2f z %0.2f\nlast x %0.2f y %0.2f z %0.2f", render_data.n_defpoints, render_data.n_norms, render_data.defpoint[0].x, render_data.defpoint[0].y, render_data.defpoint[0].z, render_data.defpoint[render_data.n_defpoints-1].x, render_data.defpoint[render_data.n_defpoints-1].y, render_data.defpoint[render_data.n_defpoints-1].z);
//MessageBox(NULL, debug_string, "!", MB_OK);

}
Bobboau, bringing you products that work... in theory
learn to use PCS
creator of the ProXimus Procedural Texture and Effect Generator
My latest build of PCS2, get it while it's hot!
PCS 2.0.3


DEUTERONOMY 22:11
Thou shalt not wear a garment of diverse sorts, [as] of woollen and linen together

 

Offline RandomTiger

  • Senior Member
  • 211
Thanks guys :) That will keep me going for a bit.

 

Offline Kazan

  • PCS2 Wizard
  • 212
  • Soul lives in the Mountains
    • http://alliance.sourceforge.net
it may be easier to make sense out of the POF Constructor Suite code  -  POFHandler and POF Renderer are what you would be concerned with, if you're interested in how to generate the model data see COBConversion
PCS2 2.0.3 | POF CS2 wiki page | Important PCS2 Threads | PCS2 Mantis

"The Mountains are calling, and I must go" - John Muir

 

Offline aldo_14

  • Gunnery Control
  • 213
Ah, so the normals are stored per point?  I was  a mite curious about that RE: the goraud shading.  (wonder what the impact of Phong would be... )

Incidentally, I don;t suppose anyone can tell me how the shading is modulated on the ships - i.e. most of the V ships have 45 degree, PCS / cob2pof smoothed tend to be 180... I'm guessing that it's something to do with only applying the colour algorithm between faces with a certain angle between their normals?

  

Offline Kazan

  • PCS2 Wizard
  • 212
  • Soul lives in the Mountains
    • http://alliance.sourceforge.net
in the BSP Points chunk there is an array of single-byte integers called "Num Norms" (Number of Normals), then another array of points and their (multiple) point normals

Code: [Select]

struct pnt
{
   vector3d point; // vector3d = struct { float x,y,z; }
   vector3d *normals; //this is an array
}

struct BSP_DefPointChunk
{
   [i][b]...[/i][/b]
   int numpoints;
   char *num_norms; // allocated to numpoints elements
   pnt *points; // allocated to numpoints elements
}


num_norms[n] correspondes to the number of normals in the "*normals" array in points[n]
PCS2 2.0.3 | POF CS2 wiki page | Important PCS2 Threads | PCS2 Mantis

"The Mountains are calling, and I must go" - John Muir