Jump to content
  • Advertisement


  • 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....

    OBJ parsing and texture mapping

    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)); } try this: for(int i=0; i < 2; i++) { vt.add(Float.valueOf(tokens)); }
  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.

    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.

    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)

    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

    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();

    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; }

    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 :(

    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.

    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); } }
  • 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!