All pastes #224536 Raw Edit

Someone

public text v1 · immutable
#224536 ·published 2006-10-27 13:07 UTC
rendered paste body
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!");
	
	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") ;
		
}