Thread: oi please help

  1. #1
    Registered User
    Join Date
    May 2005
    Posts
    4

    oi please help

    Code:
    k here is my code
    
    
    void CEnemy::Load()
    {
    	// load model
    	CMD2Model::Load("models\\head.md2", "models\\head.pcx");
    	CMD2Model::Load("models\\body.md2", "models\\body.pcx");
    	CMD2Model::Load("models\\legs.md2", "models\\legs.pcx");
    }
    
    compiles nice  but when i start the game it only shows the legs

  2. #2
    Toaster Zach L.'s Avatar
    Join Date
    Aug 2001
    Posts
    2,686
    You're gonna have to give a lot more info than that.
    There's not enough context there for anyone to figure out what might be wrong.

    Cheers
    The word rap as it applies to music is the result of a peculiar phonological rule which has stripped the word of its initial voiceless velar stop.

  3. #3
    Registered User
    Join Date
    May 2005
    Posts
    4
    do u want my md2.cpp

  4. #4
    Registered User
    Join Date
    May 2005
    Posts
    4
    here is the piece of my md2.cpp

    Code:
    // CMD2Model::LoadModel()
    // access: public
    // desc: loads model from file
    int CMD2Model::LoadModel(char *modelFile)
    {
         FILE *filePtr;                          // file pointer
         int fileLen;                            // length of model file
         char *buffer;                           // file buffer
         
         modelHeader_t *modelHeader;             // model header
         
         stIndex_t *stPtr;                       // texture data
         frame_t *frame;                              // frame data
         vector_t *vertexListPtr;                // index variable
         mesh_t *triIndex, *bufIndexPtr;         // index variables
         int i, j;                               // index variables
         
         // open the model file
         filePtr = fopen(modelFile, "rb");
         if (filePtr == NULL)
              return FALSE;
         
         // find length of file
         fseek(filePtr, 0, SEEK_END);
         fileLen = ftell(filePtr);
         fseek(filePtr, 0, SEEK_SET);
         
         // read entire file into buffer
         buffer = new char [fileLen+1];
         fread(buffer, sizeof(char), fileLen, filePtr);
         
         // extract model file header from buffer
         modelHeader = (modelHeader_t*)buffer;
         
         // allocate vertex list
         vertexList = new vector_t [modelHeader->numXYZ * modelHeader->numFrames];
         
         numVertices = modelHeader->numXYZ;
         numFrames = modelHeader->numFrames;
         frameSize = modelHeader->framesize;
         
         for (j = 0; j < numFrames; j++)
         {
              frame = (frame_t*)&buffer[modelHeader->offsetFrames + frameSize * j];
              
              vertexListPtr = (vector_t*)&vertexList[numVertices * j];
              for (i = 0; i < numVertices; i++)
              {
                   vertexListPtr[i].point[0] = frame->scale[0] * frame->fp[i].v[0] + frame->translate[0];
                   vertexListPtr[i].point[1] = frame->scale[1] * frame->fp[i].v[1] + frame->translate[1];
                   vertexListPtr[i].point[2] = frame->scale[2] * frame->fp[i].v[2] + frame->translate[2];
              }
         }
         
         numST = modelHeader->numST;
         
         st = new texCoord_t [numST];
         
         stPtr = (stIndex_t*)&buffer[modelHeader->offsetST];
         for (i = 0; i < numST; i++)
         {
              st[i].s = 0.0;
              st[i].t = 0.0;
         }
         
         numTriangles = modelHeader->numTris;
         triIndex = new mesh_t [numTriangles];
         
         // point to triangle indexes in buffer
         bufIndexPtr = (mesh_t*)&buffer[modelHeader->offsetTris];
         
         // create a mesh (triangle) list
         for (j = 0; j < numFrames; j++)         
         {
              // for all triangles in each frame
              for(i = 0; i < numTriangles; i++)
              {
                   triIndex[i].meshIndex[0] = bufIndexPtr[i].meshIndex[0];
                   triIndex[i].meshIndex[1] = bufIndexPtr[i].meshIndex[1];
                   triIndex[i].meshIndex[2] = bufIndexPtr[i].meshIndex[2];
                   triIndex[i].stIndex[0] = bufIndexPtr[i].stIndex[0];
                   triIndex[i].stIndex[1] = bufIndexPtr[i].stIndex[1];
                   triIndex[i].stIndex[2] = bufIndexPtr[i].stIndex[2];
              }
         }
         
         // close file and free memory
         fclose(filePtr);
    	delete buffer;
         
         modelTex = NULL;
         currentFrame = 0;
         nextFrame = 1;
         interpol = 0.0;
         
         return 0;
    }

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,660
    > oi please help
    Next time, try not to sound so important or desperate for attention.
    It doesn't work.

    CMD2Model::Load("models\\head.md2", "models\\head.pcx");
    CMD2Model::Load("models\\body.md2", "models\\body.pcx");
    CMD2Model::Load("models\\legs.md2", "models\\legs.pcx");
    Lemme guess, successive loads to the same object instance trash previous loads.
    The result, last one wins (ie, the legs).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    Registered User
    Join Date
    May 2005
    Posts
    4
    ok well the oi was just me sayin dangit and yes the last 1 won

    i hava rewrite the md2.cpp right
    or at least part of it
    Last edited by sleepwalker; 05-07-2005 at 12:28 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. your "horrorscope"......
    By imbecile in C in forum C Programming
    Replies: 24
    Last Post: 08-18-2003, 09:47 AM
  2. Source Code for Print a "Box"
    By imbecile in C in forum C Programming
    Replies: 2
    Last Post: 07-27-2003, 11:49 PM
  3. pyramiding asterisks " * "
    By imbecile in C in forum C Programming
    Replies: 10
    Last Post: 07-24-2003, 03:28 PM
  4. display 10 consecutive lines...........
    By imbecile in C in forum C Programming
    Replies: 6
    Last Post: 07-09-2003, 07:37 PM
  5. MVC++ Cstring question
    By rmullen3 in forum C++ Programming
    Replies: 5
    Last Post: 12-18-2001, 07:21 PM