Crystal Space
Welcome, Guest. Please login or register.
July 24, 2014, 07:30:24 am

Login with username, password and session length
Search:     Advanced search
9005 Posts in 2043 Topics by 8224 Members
Latest Member: Valeriehiga
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Support
| | |-+  particle texture problem
« previous next »
Pages: [1] Print
Author Topic: particle texture problem  (Read 1591 times)
koocake
Jr. Member
**
Posts: 54


View Profile
« on: May 09, 2006, 02:01:06 am »

Hi there,

I have a problem which is that when I create an explosion, whatever texture I use just shows as black.

I am using the following code (using the explo texture from walktest)
There are no errors about the texture not being found, so I know its not that thats the problem :

Code:
  //Setup missile explosion ready for use
  csRef<iGeneralFactoryState> fstate;
  csRef<iEngine> engine = app->GetEngine();
  csRef<iLoader> loader = app->GetLoader();
 
  missile_explo_factory = engine->CreateMeshFactory ("crystalspace.mesh.object.explosion", "explosion");
  if (!missile_explo_factory)
  {
    app->ReportError("Failed to load explosion mesh factory!");
  }
 
  if (!loader->LoadTexture ("explosion_texture", "img/explo.jpg"))
  {
    app->ReportError("Error loading 'explo' texture!");
  }

  //Create it
  csRef<iMeshWrapper> explosion = app->GetEngine()->CreateMeshWrapper(missile_explo_factory, "explosion", sector, pos);
  if (!explosion)
  {
    app->ReportError("Error creating explosion mesh!");
    return;
  }
  explosion->SetZBufMode(CS_ZBUF_TEST);
  explosion->SetRenderPriority (app->GetEngine()->GetAlphaRenderPriority ());
   
csRef<iParticleState> partstate= scfQueryInterface<iParticleState>(explosion->GetMeshObject());

  csRef<iMaterialWrapper> mat = app->GetEngine()->GetMaterialList()->FindByName("explosion_texture");
  partstate->SetMaterialWrapper (mat);
  partstate->SetColor (csColor (1, 1, 0));
  partstate->SetChangeSize (1.25);
  partstate->SetSelfDestruct (3000);
  partstate->SetChangeRotation (5.0f);
  partstate->SetAlpha(0.5);

   csRef<iExplosionState> expstate (
  SCF_QUERY_INTERFACE (explosion->GetMeshObject (), iExplosionState));
  expstate->SetParticleCount (100);
  expstate->SetCenter (csVector3 (0, 0, 0));
  expstate->SetPush (csVector3 (0, 0, 0));
  expstate->SetNrSides (6);
  expstate->SetPartRadius (0.15f);
  expstate->SetLighting (false);
  expstate->SetSpreadPos (0.6f);
  expstate->SetSpreadSpeed (2.0f);
  expstate->SetSpreadAcceleration (2.0f);
  expstate->SetFadeSprites (500);
  explosion->PlaceMesh ();

regards,
Kate
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1706


View Profile
« Reply #1 on: May 09, 2006, 05:37:53 am »

You are not registering your texture. See the iTextureWrapper api for a method to register the texture. Or else move this code before the engine->Prepare() call.

Greetings,
Logged
koocake
Jr. Member
**
Posts: 54


View Profile
« Reply #2 on: May 09, 2006, 09:54:25 pm »

thanks, that solved the problem Smiley

regards,

Kate
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 6.242 seconds with 16 queries.