MD2Lib troubles

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Rangu2057
Posts: 87
Joined: Mon Jul 23, 2007 8:37 am
Location: wilmington, NC

MD2Lib troubles

Post by Rangu2057 »

im trying to code a MD2Library for the psp using this page here http://en.wikipedia.org/wiki/MD2_%28file_format%29

and here is my code so far

EDIT: i already know i havent added the other headers

Code: Select all


#include "stdio.h"

#ifdef __cplusplus__
extern "C" {
#endif /* __cplusplus */


typedef struct MD2_Header{
int ident;
int version
int skinwidth;
int skinheight;
int framesize;
int num_skins;
int num_xyz;
int num_st;
int num_tris;
int num_glcmds;
int num_frames;
int ofs_skins;
int ofs_st;
int ofs_tris;
int ofs_frames;
int ofs_glcmds;
int ofs_end;
}MD2_Header;

/* at offset ofs_st its num_st * this struct */
typedef struct MD2_ofs1{
short s;
short t;
}MD2_ofs1

/* 
typedef struct MD2_


int Load_MD2(char *target){

MD2_Header *header;

if(Load_MD2(char *target)
	{
	printf("file %d loaded sucessfully!\n\n", char *target);
	printf("verifying struct...\n");
	printf("%d"

	}

/* this function decompresses a single frame and displays it
 *
 */
int Decompress_Frame(int frame)
{




}


int MD2GetMagic(void)
{
return ident;
}


int MD2GetVersion(void)
{
return version;
}


int MD2GetSkinWidth(void)
{
return skinwidth;
}


int MD2GetSkinHeight(void)
{
return skinheight;
}


int MD2GetFrameSize(void)
{
return framesize;
}


int MD2GetNumSkins(void)
{
return num_skins;
}


int MD2GetNumXYZ(void)
{
return num_xyz
}


int MD2GetNumST(void)
{
return num_st;
}


int MD2GetNumTri(void)
{
return num_tris;
}


int MD2GetNumGL(void)
{
return num_glcmds;
}


int MD2GetNumFrames(void)
{
return num_frames;
}


int MD2GetSkinOffs(void)
{
return ofs_skins;

if&#40;ofs_skins << unsigned char&#91;64&#93;&#41;
	&#123;
	printf&#40;"error at %d", ofs_skins&#41;;
	&#125;

else if&#40;ofs_skins == unsigned char&#91;64&#93;&#41;
	&#123;
	printf&#40;"%d", ofs_skins&#41;;
	&#125;
return ofs_skins;
&#125;


int MD2GetSTOffs&#40;void&#41;
&#123;
ofs_st = &#40;num_st * &#40;MD2_ofs1 *header&#41;&#41;;

return ofs_st;
&#125;


int MD2GetTrigOffs&#40;void&#41;
&#123;
return ofs_tris;
&#125;


int MD2GetFrameOffs&#40;void&#41;
&#123;
return ofs_frames;
&#125;


int MD2GetGLOffs&#40;void&#41;
&#123;
return ofs_glcmds;
&#125;


int MD2GetEndOffs&#40;void&#41;
&#123;
return ofs_end;
&#125;
im still only a noob right now when it comes to 3D graphics, but i decided to give it a try and now im so freaking confused now and asking some advice if im doing something right or wrong...
the questions of today are awnswered by the blood and bullets of tomorrow! ---EagleEye--- (Socom FTB2)
Smong
Posts: 82
Joined: Tue Sep 04, 2007 4:44 am

Re: MD2Lib troubles

Post by Smong »

You didn't say where you were going wrong. This also doesn't look like a PSP specific question.

I noticed this part has strange commenting:
Rangu2057 wrote:

Code: Select all

/* 
typedef struct MD2_


int Load_MD2&#40;char *target&#41;&#123;

MD2_Header *header;

if&#40;Load_MD2&#40;char *target&#41;
	&#123;
	printf&#40;"file %d loaded sucessfully!\n\n", char *target&#41;;
	printf&#40;"verifying struct...\n"&#41;;
	printf&#40;"%d"

	&#125;

/* this function decompresses a single frame and displays it
 *
 */
int Decompress_Frame&#40;int frame&#41;
&#123;




&#125;
There is a MD2 in Open GL sample at Cone3D:
http://cone3d.gamedev.net/cgi-bin/index ... gladv/tut2
You'll need to remove the PCX loader and convert the glVertex/glNormal to instead generate a list of vertices that can be passed to sceGumDrawArray.

pspdev\psp\sdk\samples\gu\common\geometry.h has a bunch of structs you may find useful for storing the vertices in on PSP.
(+[__]%)
Rangu2057
Posts: 87
Joined: Mon Jul 23, 2007 8:37 am
Location: wilmington, NC

Post by Rangu2057 »

ok, thanks for the help :)
the questions of today are awnswered by the blood and bullets of tomorrow! ---EagleEye--- (Socom FTB2)
Post Reply