void Body::Create_Sphere_Mesh (AppTest* app, std::string new_sector ) { // Draw this star at 0,0,0 csVector3 radius = 1; csVector3 center (0,0,0); iMovable* movable; iSector* sector; // Set the bodys sector sector_name = new_sector ; csRef engine = app->GetEngine(); if (!engine) printf("Star::Create_Meshs: Failed to locate iEngine renderer!"); printf ("Star::Create_Meshs Got pointers to g3d & engine \n"); // Create the ball mesh factory. csRef ballFact = engine->CreateMeshFactory( "crystalspace.mesh.object.genmesh", "ballFact"); if (ballFact == 0) { printf ("solarsys.cpp Star::Create_Meshs\n Error ballFact mesh object factory!"); } csRef gmstate = scfQueryInterface ( ballFact->GetMeshObjectFactory ()); csEllipsoid ellips (center, radius); gmstate->GenerateSphere (ellips, 64); // Create the mesh. sector = engine->FindSector( sector_name.c_str() , 0 ); mesh = engine->CreateMeshWrapper (ballFact, name.c_str() , sector ) ; // Position the mesh // movable = mesh->GetMovable(); // movable->SetPosition ( pos ); if (mesh == 0) { printf ("Star::Create_Meshs. Error creating mesh object factory!\n"); } } // load a texture file from disk // note filename is a VFS File name of texture void Body::Load_Texture(AppTest* app, std::string filename, std::string mat_name ) { csColor* transp; iTextureList* texturelist; csRef engine = app->GetEngine(); if (!engine) printf("Star::Load_Texture: Failed to locate iEngine renderer!"); transp = new csColor; transp->Set(1,0,1); // Create a Texture from a image file on VFS if ( !engine->CreateTexture ( mat_name.c_str() , filename.c_str() , transp , CS_TEXTURE_3D ) ) { printf("Star::Load_Texture: Failed loading Texture %s\n" , filename.c_str() ); } // Use the texture to create a Material texturelist = engine->GetTextureList(); engine->CreateMaterial ( mat_name.c_str() , texturelist->FindByName(mat_name.c_str()) ); iMaterialWrapper* mat = engine->GetMaterialList ()->FindByName (mat_name.c_str() ); if ( !mat ) { printf(" Star::Load_Texture: Material %s not found!\n",mat_name.c_str() ); } // Now add the texture to the mesh if (!mesh->GetMeshObject ()->SetMaterialWrapper (mat)) printf ("Body::Load_Texture: Error SetMaterialWrapper failed\n") ; } void Body::Add_Light(AppTest* app ) { iSector* sector; csRef engine = app->GetEngine(); if (!engine) printf("Body::Add_Light: Failed to locate iEngine renderer!"); sector = engine->FindSector( sector_name.c_str() , 0 ); if (!sector) printf("Body::Add_Light: Failed to locate sector !"); printf ("Sector:%s\n" ,sector_name.c_str() ); // Now we need light to see something. csRef light; iLightList* ll = sector->GetLights (); // csRef sectorlist = engine->GetSectors(); // int sector_count = sectorlist->GetCount (); // printf ("sector count:%i\n" , sector_count ); light = engine->CreateLight(0, csVector3( 5, 5, 5), 10000, csColor(1, 1, 1)); ll->Add (light); }