Hard Light Productions Forums
		Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Topic started by: RandomTiger on May 28, 2003, 06:40:55 am
		
			
			- 
				Is there any documentation on how the pof model files store the vertex data?
			
 
			
			- 
				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/
			 
			
			- 
				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
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);
}
			 
			
			- 
				Thanks guys :) That will keep me going for a bit.
			
 
			
			- 
				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
			
 
			
			- 
				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?
			 
			
			- 
				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
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]