All pastes #224952 Raw Edit

Unnamed

public text v1 · immutable
#224952 ·published 2006-10-27 17:37 UTC
rendered paste body
it says 

crystalspace.maploader.parse.image:
  Could not open image file '<unknown>' on VFS!

at run time and the sphere still has no mesh!


// 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<iEngine> engine = app->GetEngine();
	if (!engine) printf("Star::Load_Texture: Failed to locate iEngine renderer!\n");

	csRef<iGraphics3D> g3d = app->Get_g3d();
	if (!g3d) printf("Body::Load_Image: Failed to locate 3D renderer!\n");

	csRef<iLoader> loader = app->Get_Loader();
	if (!loader) printf("Body::Load_Image: Failed to locate 3D renderer!\n");

	csRef<iTextureManager> 	texture_manager = g3d->GetTextureManager();
	if (!texture_manager) printf("Body::Load_Image: Failed to load Texture Manager!\n");

	printf("before new File:%s\n", filename.c_str() );

	csRef<csPhysicalFile> file = new csPhysicalFile( filename.c_str() ,"rb");
	if (!file) printf("Body::Load_Image: Failed to open image file: %s!\n" , filename.c_str() );

	csRef<iDataBuffer> buf = file->GetAllData();
	
	csRef<iTextureWrapper> texturewapper = loader->LoadTexture ( mat_name.c_str() ,
					buf, CS_TEXTURE_3D, 	texture_manager , true, true, true );

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