Jump to content
  • Advertisement

Shamino

Member
  • Content Count

    751
  • Joined

  • Last visited

Community Reputation

100 Neutral

About Shamino

  • Rank
    Banned
  1. Yes, blame me for not muddling through (45?) posts about some screenshots :) You should edit your origional post, :)
  2. Shamino

    Oblivion

    When you sit in the throne of the goblin king only to fall prey to a deadly ball and spike trap smashing you in the face when you sit after you killed him... You know you got a great game..
  3. that guy definately has bloom AND/OR hdr turned off in some of those shots.. Don't post stuff unless you crank up the graphics :D
  4. Starting from ghost in the shell to inuyasha, it is a pretty sweet lineup..
  5. Ahh, I see.. Who would have though switching from the ms3d file def to my own would be such a hassle, I gotta like, completely rewrite the loader.. NeHe should really cover this topic :d
  6. Thanks alot, so just doing this: int nVertices = *( word* )pPtr; NumVertices = nVertices; Vertices = new Vertex[nVertices]; pPtr += sizeof( word ); int i; for ( i = 0; i < nVertices; i++ ) { MS3DVertex * pVertex = ( MS3DVertex* )pPtr; // Vertices.BoneID = pVertex->m_boneID; memcpy( Vertices.vx, pVertex->m_vertex[0], sizeof(float)); memcpy( Vertices.vy, pVertex->m_vertex[1], sizeof(float)); memcpy( Vertices.vz, pVertex->m_vertex[2], sizeof(float)); pPtr += sizeof( MS3DVertex ); } Isn't creating enough vertices to draw the model? Never woulda guessed...
  7. Oh I see, when we unshare vertices, we're creating an array of vertices (as well as creating more vertices we need to draw the models with the VA).. Then we create an index for every group.. After that, in our rendering function... for every group drawelements (group index)
  8. Sweet, so in that code you're creating a straight up array of vertex information? Not worrying about breaking them down into triangles in the MS3D structure right? Maybe I'm missing something.. What kind of index to I need to give my vertex array? the MS3D Loading code looks like this in the beginning... bool MS3DModel::Load(const std::string & name) { const char *ptr1 = 0; ptr1= name.data ( ); ifstream inputFile( ptr1, ios::in | ios::binary); if ( inputFile.fail()) { MessageBox(NULL,"Model file not found.","Model Error",MB_OK); return false; // "Couldn't open the model file." } inputFile.seekg( 0, ios::end ); long fileSize = inputFile.tellg(); inputFile.seekg( 0, ios::beg ); byte *pBuffer = new byte[fileSize]; inputFile.read((char *)pBuffer, fileSize ); inputFile.close(); const byte *pPtr = pBuffer; MS3DHeader *pHeader = ( MS3DHeader* )pPtr; pPtr += sizeof( MS3DHeader ); if ( strncmp( pHeader->m_ID, "MS3D000000", 10 ) != 0 ) { MessageBox(NULL,"Not a valid Milkshape3D model file.", "Model Error",MB_OK); return false; // "Not a valid Milkshape3D model file." } if ( pHeader->m_version < 3 || pHeader->m_version > 7 ) { MessageBox(NULL,"Not a valid Milkshape3D file version.","Model Error",MB_OK); return false; // "Unhandled file version. Milkshape3D Version 1.3 through 1.7 is supported." :) } int nVertices = *( word* )pPtr; NumVertices = nVertices; Vertices = new Vertex[nVertices]; pPtr += sizeof( word ); int i; for ( i = 0; i < nVertices; i++ ) { MS3DVertex *pVertex = ( MS3DVertex* )pPtr; Vertices.BoneID = pVertex->m_boneID; memcpy( Vertices.Location, pVertex->m_vertex, sizeof( float )*3 ); pPtr += sizeof( MS3DVertex ); } int nTriangles = *( word* )pPtr; NumTriangles = nTriangles; Triangles = new Triangle[nTriangles]; pPtr += sizeof( word ); for ( i = 0; i < nTriangles; i++ ) { MS3DTriangle *pTriangle = ( MS3DTriangle* )pPtr; int vertexIndices[3] = { pTriangle->m_vertexIndices[0], pTriangle->m_vertexIndices[1], pTriangle->m_vertexIndices[2] }; float t[3] = { 1.0f-pTriangle->m_t[0], 1.0f-pTriangle->m_t[1], 1.0f-pTriangle->m_t[2] }; memcpy( Triangles.VertexNormals, pTriangle->m_vertexNormals, sizeof( float )*3*3 ); memcpy( Triangles.Textures1, pTriangle->m_s, sizeof( float )*3 ); memcpy( Triangles.Textures2, t, sizeof( float )*3 ); memcpy( Triangles.VertexIndices, vertexIndices, sizeof( int )*3 ); pPtr += sizeof( MS3DTriangle ); } int nGroups = *( word* )pPtr; NumMeshes = nGroups; Meshes = new Mesh[nGroups]; pPtr += sizeof( word ); for ( i = 0; i < nGroups; i++ ) { pPtr += sizeof( byte ); // flags pPtr += 32; // name word nTriangles = *( word* )pPtr; pPtr += sizeof( word ); int *pTriangleIndices = new int[nTriangles]; for ( int j = 0; j < nTriangles; j++ ) { pTriangleIndices[j] = *( word* )pPtr; pPtr += sizeof( word ); } char materialIndex = *( char* )pPtr; pPtr += sizeof( char ); Meshes.MaterialIndex = materialIndex; Meshes.NumTriangles = nTriangles; Meshes.TriangleIndices = pTriangleIndices; } int nMaterials = *( word* )pPtr; NumMaterials = nMaterials; Materials = new Material[nMaterials]; pPtr += sizeof( word ); for ( i = 0; i < nMaterials; i++ ) { MS3DMaterial *pMaterial = ( MS3DMaterial* )pPtr; memcpy( Materials.Ambient, pMaterial->m_ambient, sizeof( float )*4 ); memcpy( Materials.Diffuse, pMaterial->m_diffuse, sizeof( float )*4 ); memcpy( Materials.Specular, pMaterial->m_specular, sizeof( float )*4 ); memcpy( Materials.Emissive, pMaterial->m_emissive, sizeof( float )*4 ); Materials.Shininess = pMaterial->m_shininess; Materials.TextureFilename = new char[strlen( pMaterial->m_texture )+1]; strcpy( Materials.TextureFilename, pMaterial->m_texture ); pPtr += sizeof( MS3DMaterial ); } I'm under the impression that you have to arrange everything in that way, but I know this can't be the case.. I don't care about defining triangles, the vertex array can pick out triangles with an index right? This is so weird, I'm not sure how to convert the normals (which are created for every triangle), as well as tex coords, to be created per vertex?? Am I thinking wrong, missing something?
  9. Thats really cool Arsenal, I'll try that code out, there are a few things I want to change though, and I'd like to know if they're possible.. I'd like to change it so normals/vertex/texcoords come out of one struct, I want to make the final rendering function centralized, I want to pass a Vertex array to the render function, and do all the stuff you said, only working out of one super vertex struct, would this be possible?
  10. I thought the Index would handle for all the vertices that aren't re used, I didn't think I would have to actually duplicate all the skipped vertices to put them in a vertex array..
  11. That is what I'm doing right now, and I'm asking for help.
  12. Okay, so lately I've been rewriting my MS3D class to fit itself nicely for vertex arrays, I'm having a few issues in doing this, let me post some code.. struct Vertex { float vx; float vy; float vz; float nx; float ny; float nz; float s; float t; unsigned char r,g,b,a; int BoneID; }; int NumVertices; Vertex * Vertices; This is the structure I will be holding the vertex information, I want to hold the xyz vertices, the xyz normals, the st tex coords, the rgba colors, and the BoneID for skeletal animation... The MS3D file structure is setup like this // File header struct MS3DHeader { char m_ID[10]; int m_version; } PACK_STRUCT; // Vertex information struct MS3DVertex { byte m_flags; float m_vertex[3]; char m_boneID; byte m_refCount; } PACK_STRUCT; // Triangle information struct MS3DTriangle { word m_flags; word m_vertexIndices[3]; float m_vertexNormals[3][3]; float m_s[3], m_t[3]; byte m_smoothingGroup; byte m_groupIndex; } PACK_STRUCT; // Material information struct MS3DMaterial { char m_name[32]; float m_ambient[4]; float m_diffuse[4]; float m_specular[4]; float m_emissive[4]; float m_shininess; // 0.0f - 128.0f float m_transparency; // 0.0f - 1.0f byte m_mode; // 0, 1, 2 is unused now char m_texture[128]; char m_alphamap[128]; } PACK_STRUCT; // Joint information struct MS3DJoint { byte m_flags; char m_name[32]; char m_parentName[32]; float m_rotation[3]; float m_translation[3]; word m_numRotationKeyframes; word m_numTranslationKeyframes; } PACK_STRUCT; // Keyframe data struct MS3DKeyframe { float m_time; float m_parameter[3]; } PACK_STRUCT; Right now I'm just worried about getting vertex info, normal info, and tex coord info.. I've managed to copy the vertex information successfully.. int nVertices = *( word* )pPtr; NumVertices = nVertices; Vertices = new Vertex[nVertices]; pPtr += sizeof( word ); int i; for ( i = 0; i < nVertices; i++ ) { MS3DVertex * pVertex = ( MS3DVertex* )pPtr; MS3DTriangle *pTriangle = ( MS3DTriangle* )pPtr; Vertices.BoneID = pVertex->m_boneID; Vertices.vx = pVertex->m_vertex[0]; Vertices.vy = pVertex->m_vertex[1]; Vertices.vz = pVertex->m_vertex[2]; pPtr += sizeof( MS3DVertex ); } The normals and texture coordinates are a little more iffy, they are set up per triangle, not per vertex, I've thought of how I could throw everything into that one vertex loop, but somehow I'm not sure if that will be able to happen, here is how ms3d converts the information, (using identical structures).. int nTriangles = *( word* )pPtr; NumTriangles = nTriangles; Triangles = new Triangle[nTriangles]; pPtr += sizeof( word ); for ( i = 0; i < nTriangles; i++ ) { MS3DTriangle *pTriangle = ( MS3DTriangle* )pPtr; int vertexIndices[3] = { pTriangle->m_vertexIndices[0], pTriangle->m_vertexIndices[1], pTriangle->m_vertexIndices[2] }; float t[3] = { 1.0f-pTriangle->m_t[0], 1.0f-pTriangle->m_t[1], 1.0f-pTriangle->m_t[2] }; memcpy( Triangles.Textures1, pTriangle->m_s, sizeof( float )*3 ); memcpy( Triangles.Textures2, t, sizeof( float )*3 ); memcpy( Triangles.VertexIndices, vertexIndices, sizeof( int )*3 ); pPtr += sizeof( MS3DTriangle ); } How am I supposed to break these things down to being copied per vertex instead of copying them per triangle? Can anyone gimme a push in the right direction?
  13. I've gotten this much done so far, I'll put this structure in the MS3DModel class and cut out all the other structural information, and in the loading code I'll copy everything to this structure instead of to all the other ones... struct Vertex { float vx; float vy; float vz; float nx; float ny; float nz; float s; float t; unsigned char r,g,b,a; int BoneID; }; int NumVertices; Vertex * Vertices; I changed the loading code to fill out the vertex information correctly.. int nVertices = *( word* )pPtr; NumVertices = nVertices; Vertices = new Vertex[nVertices]; pPtr += sizeof( word ); int i; for ( i = 0; i < nVertices; i++ ) { MS3DVertex * pVertex = ( MS3DVertex* )pPtr; MS3DTriangle *pTriangle = ( MS3DTriangle* )pPtr; Vertices.BoneID = pVertex->m_boneID; Vertices.vx = pVertex->m_vertex[0]; Vertices.vy = pVertex->m_vertex[1]; Vertices.vz = pVertex->m_vertex[2]; pPtr += sizeof( MS3DVertex ); } My question is, how do I convert things that are structured in the file as triangles to being structured in my code as vertices? This is what I have to work on next.. int nTriangles = *( word* )pPtr; m_numTriangles = nTriangles; m_pTriangles = new Triangle[nTriangles]; pPtr += sizeof( word ); for ( i = 0; i < nTriangles; i++ ) { MS3DTriangle *pTriangle = ( MS3DTriangle* )pPtr; int vertexIndices[3] = { pTriangle->m_vertexIndices[0], pTriangle->m_vertexIndices[1], pTriangle->m_vertexIndices[2] }; float t[3] = { 1.0f-pTriangle->m_t[0], 1.0f-pTriangle->m_t[1], 1.0f-pTriangle->m_t[2] }; memcpy( m_pTriangles.m_vertexNormals, pTriangle->m_vertexNormals, sizeof( float )*3*3 ); memcpy( m_pTriangles.m_s, pTriangle->m_s, sizeof( float )*3 ); memcpy( m_pTriangles.m_t, t, sizeof( float )*3 ); memcpy( m_pTriangles.m_vertexIndices, vertexIndices, sizeof( int )*3 ); pPtr += sizeof( MS3DTriangle ); } I need all this information to be in my one vertex struct, this is going to be iffy.. Can anyone give me a push in the right direction? It seems like converting the normals and such is going to be the trickiest..
  14. Thanks, I was switching it from copying an entire array of values, in one line, and I didn't realize there was no difference between that and an assignment operator..
  15. I'll just start off with the code.. int nVertices = *( word* )pPtr; NumVertices = nVertices; Vertices = new Vertex[nVertices]; pPtr += sizeof( word ); int i; for ( i = 0; i < nVertices; i++ ) { MS3DVertex * pVertex = ( MS3DVertex* )pPtr; // Vertices.BoneID = pVertex->m_boneID; memcpy( Vertices.vx, pVertex->m_vertex[0], sizeof(float)); memcpy( Vertices.vy, pVertex->m_vertex[1], sizeof(float)); memcpy( Vertices.vz, pVertex->m_vertex[2], sizeof(float)); pPtr += sizeof( MS3DVertex ); } Okay, so I'm copying pVertex->m_vertex elements to each element in my structure in code, I'll show you the definitions of each of these structs.. I'm copying from this one // Vertex information struct MS3DVertex { byte m_flags; float m_vertex[3]; char m_boneID; byte m_refCount; } PACK_STRUCT; To this one struct Vertex { float vx; float vy; float vz; float nx; float ny; float nz; float s; float t; unsigned char r,g,b,a; }; int NumVertices; Vertex * Vertices; That is all I'm doing, maybe I'm not using memcpy right? Here are the errors.. --------------------Configuration: NeHeGL - Win32 Debug-------------------- Compiling... MS3D.CPP \\student\courses\cedar_cliff\computer\senior project\auditorium\engine source\ms3d.cpp(192) : error C2664: 'memcpy' : cannot convert parameter 1 from 'float' to 'void *' There is no context in which this conversion is possible \\student\courses\cedar_cliff\computer\senior project\auditorium\engine source\ms3d.cpp(193) : error C2664: 'memcpy' : cannot convert parameter 1 from 'float' to 'void *' There is no context in which this conversion is possible \\student\courses\cedar_cliff\computer\senior project\auditorium\engine source\ms3d.cpp(194) : error C2664: 'memcpy' : cannot convert parameter 1 from 'float' to 'void *' There is no context in which this conversion is possible Any ideas? [Edited by - Shamino on March 24, 2006 8:46:21 AM]
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!