• Content count

  • Joined

  • Last visited

Community Reputation

147 Neutral


  • Rank
  1. i'm sorry I don't have the source anymore. I have searched all my files but cant find it. Try pm'ing thefoofighter, he was searching to at that time. Could you pass me the link if you have found the source? Thanks.
    I will also search the net and if i find anything i will let you know.
    Best Regards,
  2. Hi Boy
    I downloaded OpenGL GameDevelopment by Chris Seddon in pdf format but unfortunately both link of source code do not work.
    can you send entire source codes to my mail ?
    if you do this you help me very much....
  3. OBJ parsing and texture mapping

    [quote name='afkboard' timestamp='1294750318' post='4757236'] going backwards: yes it is one image. the texture parsing code is in Java, here is the code: [code] private void processVTLine(String line){ String [] tokens=line.split("[ ]+"); //split the line at the spaces int c=tokens.length; for(int i=1; i<c; i++){ //add the vertex to the vertex array vt.add(Float.valueOf(tokens[i])); } } [/code] The coordinates are: [code] 0.983644, 0.001656, 0.992169, 0.001997, 0.99218, 0.009859, 0.983658, 0.009516, 0.975123, 0.001323, 0.975142, 0.009179, 0.992199, 0.017727, 0.983679, 0.017383, 0.975166, 0.017043, 0.96661, 0.001007, 0.966635, 0.008855, 0.958109, 7.17E-4, 0.958139, 0.008554, 0.966664, 0.016713, 0.958173, 0.0164, 0.992227, 0.025603, 0.983709, 0.025261, 0.9752, 0.024921, 0.992266, 0.033489, 0.983751, 0.033155, 0.975247, 0.03282, 0.966701, 0.024586, 0.958214, 0.024263, 0.966752, 0.032484, 0.958268, 0.032152, 0.949626, 4.66E-4, 0.949661, 0.008287, 0.941164, 2.62E-4, 0.941203, 0.008065, 0.949699, 0.016117, 0.941243, 0.015874, 0.932726, 1.14E-4, 0.932765, 0.007896, 0.924312, 2.6E-5, 0.924345, 0.007784, 0.932802, 0.015681, 0.924375, 0.015542, 0.949742, 0.023961, 0.941287, 0.023694, 0.949797, 0.031832, 0.941342, 0.03154, 0.932844, 0.023474, 0.924407, 0.023306, 0.932897, 0.03129, 0.924451, 0.031089, 0.992318, 0.041386, 0.983809, 0.041068, 0.975311, 0.040746, .... [/code] etc. (long list) And one more thing I forgot to mention: the binding of the texture goes like this: [code] glTexCoordPointer(2, GL10.GL_FLOAT, 0, textureBuffer); glEnable(GL10.GL_TEXTURE_2D); glBindTexture(GL10.GL_TEXTURE_2D, tex); glEnableClientState(GL10.GL_TEXTURE_COORD_ARRAY); [/code] Where textureBuffer is made of the coordinates above. Thanks. [/quote] You have more than 3 vt's per vertex. u v and w is optional. what are the other 5 coords? I think you just need the first 2 vt's for(int i=1; i<c; i++) // why are you starting at 1? { //add the vertex to the vertex array vt.add(Float.valueOf(tokens[i])); } try this: for(int i=0; i < 2; i++) { vt.add(Float.valueOf(tokens[i])); }
  4. you should look into C/C++ script librarries. ie Angelscript, Lua etc. I use Angelscript. It's easy, fast and has support for class binding.
  5. Object handle on class members

    Many thanks, it works now. I'm sure i have tested this before though. guess there was something else incorrect at the time.
  6. Object handle on class members

    I need to get the handle (@) to a class member but can't find how to do so. NormalMapMaterialDesc looks like this [source=cpp] class NormalMapMaterialDesc { public: NormalMapMaterialDesc(); virtual ~NormalMapMaterialDesc(); BitmapData* DiffuseMap; BitmapData* NormalMap; BitmapData* SpecularMap; float Shininess; }; NormalMapMaterialDesc is registered as a value type. The object properties are registered like: [source=cpp] int r; r = engine->RegisterObjectProperty("NormalMapMaterialDesc", "BitmapData@ DiffuseMap", offsetof(NormalMapMaterialDesc, DiffuseMap)); assert( r >= 0 ); r = engine->RegisterObjectProperty("NormalMapMaterialDesc", "BitmapData@ NormalMap", offsetof(NormalMapMaterialDesc, NormalMap)); assert( r >= 0 ); r = engine->RegisterObjectProperty("NormalMapMaterialDesc", "BitmapData@ SpecularMap", offsetof(NormalMapMaterialDesc, SpecularMap)); assert( r >= 0 ); r = engine->RegisterObjectProperty("NormalMapMaterialDesc", "float Shininess", offsetof(NormalMapMaterialDesc, Shininess)); assert( r >= 0 ); level.bitmapManager().Load() returns a BitmapData* (BitmapData@) // I need to get the handle of materialDesc.DiffuseMap. I want to set it with the return value of level.bitmapManager().Load(). Now I get an exception saying "Null pointer access" I have tried putting the @ at various places but all my effords have failed. [source=cpp] NormalMapMaterialDesc materialDesc; materialDesc.DiffuseMap = level.bitmapManager().Load("Images/Stone_D.png"); materialDesc.NormalMap = level.bitmapManager().Load("Images/Stone_N.png"); materialDesc.SpecularMap = level.bitmapManager().Load("Images/Stone_S.png"); materialDesc.Shininess = 66.0f;
  7. When you are unpacking, the vertices are placed in order into the new array. the 1st triangle has vertex indices 0, 1, 2 the 2nd triangle 3, 4, 5, the 3rd triangle 6, 7, 8 etc. when you do this in a loop the code below will create the correct indexbuffer for the new unpacked buffer. // unpacking #faces section // added v1, v2, v3 // added vt1, vt2, vt3 // added vn1, vn2, vn3 indicesUnpacked.Add(indicesUnpacked.size()); // the size of indicesUnpacked here is 0 indicesUnpacked.Add(indicesUnpacked.size()); // the size of indicesUnpacked here is 1 indicesUnpacked.Add(indicesUnpacked.size()); // the size of indicesUnpacked here is 2 // next loop/face // added v1, v2, v3 // added vt1, vt2, vt3 // added vn1, vn2, vn3 indicesUnpacked.Add(indicesUnpacked.size()); // the size of indicesUnpacked here is 3 indicesUnpacked.Add(indicesUnpacked.size()); // the size of indicesUnpacked here is 4 indicesUnpacked.Add(indicesUnpacked.size()); // the size of indicesUnpacked here is 5 etc or you can use: int size = indicesUnpacked.size(); indicesUnpacked.Add(size); // the size here is 0 indicesUnpacked.Add(size+1); // the size here is 1 indicesUnpacked.Add(size+2); // the size here is 2
  8. check out this page: http://en.wikipedia.org/wiki/Obj I assume that for every vertex the position, texcoord and the normal is stored in your obj file. your data will look something like this: # faces f 6/4/1 3/5/3 7/6/5 f 8/3/7 4/7/0 6/9/2 f 4/5/3 6/6/1 4/6/1 ... f v1/vt1/vn1 v2/vt2/vn2 v3/vt3/vn3 so basicly you have 3 indices for every vertex in order to use this data for rendering you need to unpack it. Array<Vector3> vertices; Array<Vector3> texcoords; Array<Vector3> normals; // read obj - read all vertices from obj and stored in vertices - read all texcoords from obj and store in texcoords - read all normals from obj and sotre in normals // Now read the # faces section and get the correct v, vt, vn according to the indices. for every face you read add the data to a new list Array<Vector3> verticesUnpacked; Array<Vector3> texcoordsUnpacked; Array<Vector3> normalsUnpacked; Array<int> indicesUnpacked; f v1/vt1/vn1 v2/vt2/vn2 v3/vt3/vn3 // Vertices for this face Vector3 vertex1 = vertices[v1]; verticesUnpacked.Add(vertex1); Vector3 vertex2 = vertices[v2]; verticesUnpacked.Add(vertex2); Vector3 vertex3 = vertices[v3]; verticesUnpacked.Add(vertex3); // Texcoords for this face Vector3 tex1 = texcoords[vt1]; texcoordsUnpacked.Add(tex1); Vector3 tex2 = texcoords[vt2]; texcoordsUnpacked.Add(tex2); Vector3 tex3 = texcoords[vt3]; texcoordsUnpacked.Add(tex3); // Normalsfor this face Vector3 normal1 = texcoords[vn1]; normalsUnpacked.Add(normal1 ); Vector3 normal2 = texcoords[vn2]; normalsUnpacked.Add(normal2 );' Vector3 normal3 = texcoords[vn3]; normalsUnpacked.Add(normal3 ); // Create new indices (this will automaticly build the new indices because the faces are now unpacked and in order. indicesUnpacked.Add(indicesUnpacked.size()); indicesUnpacked.Add(indicesUnpacked.size()); indicesUnpacked.Add(indicesUnpacked.size()); Now your indexbuffer corresponds with the vertexbuffer, texcoordbuffer and normalbuffer. the index start with 1 meaning that you need to -1 the index to get the correct vertex/texcoord/normal in your array (C/C++ arrays start with 0)
  9. C++: Creating a graphical user interface

    If you using VS you can create a Windows Forms Application with Managed C++ and .NET that can be combined with normal (unmanaged) C++ dll/code
  10. How can I move my camera

    if your going to use gluLookAt you dont need to use glTranslatef eyeX, eyeY, eyeZ Specifies the position of the eye point. centerX, centerY, centerZ Specifies the position of the reference point. upX, upY, upZ Specifies the direction of the up vector. eye is position (translation) center is camera lookat point up is up (usually x=0, y=1, z=0) try something like this: // Setup camera glMatrixMode( GL_PROJECTION ); glLoadIdentity(); // build projection matrix gluPerspective(mFieldOfView, mAspectRatio, mNearPlane, mFarPlane); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(mPosition.x,mPosition.y, mPosition.z, mLookAt.x, mLookAt.y, mLookAt.z, mUp.x, mUp.y, mUp.z); // Draw stuff glPushMatrix(); // Translate/Rotate by the object position etc // Draw object glCallList(m_cameraDisplist); glPopMatrix();
  11. Memory Management in AngelScript

    Ah oke things are more clear now thanks. Well what I meant was that I would like to delete objects myself. Is there some way to declare a "delete" behaviour, just like the "new" behaviour. // New r = engine->RegisterObjectBehaviour("Sound@ f()", asBEHAVE_FACTORY, declaration, asFUNCTION(New<T>), asCALL_GENERIC); assert( r >= 0 ); // Delete? r = engine->RegisterObjectBehaviour("void delete(Sound@)", asBEHAVE_FACTORY, declaration, asFUNCTION(Delete<T>), asCALL_GENERIC); assert( r >= 0 ); If so, how would the Delete<T> look like? something like this? template <class T> void Delete(asIScriptGeneric* gen) { T* a = (T*)gen->GetArgAddress(0); delete a; }
  12. Memory Management in AngelScript

    Hi, I have two questions that are related to each other. Question 1: Is there a delete operator in AngelScript? ie: Sound@ sound = LoadSound("bla1.wav"); // Do something, ie loading level data delete sound; @sound = LoadSound("bla2.wav"); // finished delete sound; Question 2: I'm currently using AngelScript to setup and load a level. The objects are created in AngelScript and the pointers are passed to the Level class. Both Entity and Level are registered with AngelScipt as a reference type. The problem is that when the script finishes the pointers are deleted by the Release behavior. But i don't want the objects to be deleted (yet) because they are used by Level. So i circumvented the problem by commenting the delete line. (see below) void ReferenceType::Release() { // Decrease ref count and delete if it reaches 0 if( --mRefCount == 0 ) { //delete this; } } The objects are deleted in the destructor of Level. // Below is a generic function to register a reference type with AngelScript. The New is used for objects with a default constructor. template <class T> void New(asIScriptGeneric* gen) { *(T**)gen->GetAddressOfReturnLocation() = new T(); } template <class T> void Assign(asIScriptGeneric* gen) { T* a = (T*)gen->GetArgAddress(0); T* thisPointer = (T*)gen->GetObject(); *thisPointer = *a; gen->SetReturnAddress(thisPointer); } template <class T> void RegisterReferenceType(asIScriptEngine* engine, const char* type) { int r; // Register the reference type r = engine->RegisterObjectType (type, 0, asOBJ_REF); assert( r >= 0 ); // register reference type behaviours r = engine->RegisterObjectBehaviour(type, asBEHAVE_ADDREF, "void f()", asMETHOD(T,AddReference), asCALL_THISCALL); assert( r >= 0 ); r = engine->RegisterObjectBehaviour(type, asBEHAVE_RELEASE, "void f()", asMETHOD(T,Release), asCALL_THISCALL); assert( r >= 0 ); } // Below is a generic function to register the Entity type with AngelScript template <class T> void RegisterEntity(asIScriptEngine* engine, const char* type) { int r; // Register the reference type RegisterReferenceType<T>(engine, type); char declaration[512]; sprintf(declaration, "%s@ f()", type); // Constructor r = engine->RegisterObjectBehaviour(type, asBEHAVE_FACTORY, declaration, asFUNCTION(NewEntity<T>), asCALL_GENERIC); assert( r >= 0 ); // Register = operator sprintf(declaration , "%s& opAssign(const %s& in)", type, type); r = engine->RegisterObjectMethod(type, declaration, asFUNCTION(Assign<T>), asCALL_GENERIC); assert( r >= 0 ); } I call: RegisterEntity<Entity>(scriptEngine, "Entity"); to register the Entity class. Level is registered in the same way.
  13. Looks good, when available i will definitly give it a try. One question though on your polly site you say: ".. Polly will always remain open source and free within the boundaries of GPL Licensing..." In the download section there is no download :(
  14. cg shader

    float mMatrix[16] CGparameter mParameter; cgSetMatrixParameterfc(mParameter, &mMatrix[0]); But make sure you calculate and send in the correct matrices to the shader.
  15. cg shader

    I think you need to pass the parameters in: mainVS - Proj - View - ViewI - ViewIT - LightPos mainPS - Texture declaring these parames as globals instead of function params technique technique0 { pass p0 { CullFaceEnable = false; VertexProgram = compile vp40 mainVS(Proj, View, ViewI, ViewIT, LightPos); FragmentProgram = compile fp40 mainPS(Texture); } }