Commits

Anonymous committed 650f19c

added a light, added computed normals

Comments (0)

Files changed (3)

Release/Plugins.cfg

 
 # Define plugins
 Plugin=RenderSystem_Direct3D9
-Plugin=RenderSystem_GL
 Plugin=Plugin_ParticleFX
 Plugin=Plugin_CgProgramManager
 Plugin=Plugin_OctreeSceneManager

ogre-lib3ds/Test3DSViewerApp.cpp

     mCamera->lookAt(Vector3::ZERO);
 
     _build3dsModel();
+
+
+    mBBset = mSceneMgr->createBillboardSet("Light BB");
+    mBBset->setMaterialName("Objects/Flare");
+    mLightFlare = mBBset->createBillboard(Vector3::ZERO);
+
+    mLight = mSceneMgr->createLight("main light");
+    mLight->setType(Light::LT_POINT);
+    mLight->setDiffuseColour(ColourValue::White);
+    mLight->setSpecularColour(ColourValue::White);
+
+    mLightNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("light node");
+    mLightNode->attachObject(mLight);
+    mLightNode->attachObject(mBBset);
 }
 //------------------------------------------------------------------------------
 void Test3DSViewerApp::_createGrid(int _units)
 {
     int result;
     //mFile = fopen("cube.3ds", "rb");
-    mFile = fopen("Modern-home-interior1.3DS", "rb");
+    //mFile = fopen("../media/3ds/Modern-home-interior1.3DS", "rb");
+    mFile = fopen("../media/3ds/indochine.3DS", "rb");
 
     m3dsFile = lib3ds_file_new();
 
 
     mObjectBuilder = mSceneMgr->createManualObject("3ds cube");
 
+
+    
     for(int j=0 ; j<m3dsFile->nmeshes ; ++j)
     {
         Lib3dsMesh *mesh = m3dsFile->meshes[j];
-        
-        mObjectBuilder->begin("", RenderOperation::OT_TRIANGLE_LIST);
+    
+        float (*normals)[3] = (float(*)[3])malloc(sizeof(float) * 9 * mesh->nfaces);
+        lib3ds_mesh_calculate_vertex_normals(mesh, normals);
+
+
+        mObjectBuilder->begin("Gray", RenderOperation::OT_TRIANGLE_LIST);
         float p[3], t[2];
         for (int i = 0; i < mesh->nvertices; ++i) {
             lib3ds_vector_copy(p, mesh->vertices[i]);
                 mObjectBuilder->textureCoord(mesh->texcos[i][0], mesh->texcos[i][1]);
                 
             }
+            
+            mObjectBuilder->normal(normals[i][0], normals[i][1], normals[i][2]);
+            
 
         }
         for(int i=0 ; i<mesh->nfaces ; i++)

ogre-lib3ds/Test3DSViewerApp.h

     Lib3dsIo m3dsIo;
 
     ManualObject *mObjectBuilder;
+
+    BillboardSet *mBBset;
+    Billboard *mLightFlare;
+    Light *mLight;
+    SceneNode *mLightNode;
 };