About Store Forum Documentation Contact



Post Reply 
Yellow scene with hpRt(true)?
Author Message
Esenthel Offline
Administrator

Post: #16
Re: Yellow scene with hpRt(true)?
Hi,

you need to draw in RM_PRT_BLN - alpha blending mode (not palette mode, because in palette the color is taken from the color palette)

please check this code

Code:
/******************************************************************************/
#include "stdafx.h"
/******************************************************************************/
Mesh      mbox;
Particles part; // particles
/******************************************************************************/
void InitPre()
{
   App.name="Particles";
   App.flag=APP_FULL_TOGGLE|APP_MS_EXCLUSIVE;
   PakAdd("../data/engine.pak");

   D.full(true);
   Cam.dist=2;
}
/******************************************************************************/
Bool Init()
{
   // create mesh box
   mbox.create(1).B(0).create(Box(4),VTX_TX0|VTX_NRM|VTX_TNG).reverse();
   mbox.setMaterial(Materials("../data/mtrl/brick/0.mtrl")).setRender().setBox();

   // create particles
   {
      Gfx  *gfx  =Gfxs("../data/gfx/particle/fire.gfx"); // image
      UInt  col  =WHITE;                                 // color
      Int   num  =30;                                    // number
      Flt   r    =0.1,                                   // radius
            life =0;                                     // life
      Vec   accel(0);                                    // acceleration
      Vec   point(0);                                    // position

      part.createCustom(*gfx,col,num,r,life,accel,point);
      part.func=PARTICLE_FULL;
      REPA(part)
      {
         part.p(i).radius=1;
         part.p(i).pos=Rnd(Ball(1));
      }
   }
   return true;
}
/******************************************************************************/
void Shut()
{
}
/******************************************************************************/
Bool Main()
{
   if(Kb.bp(KB_ESC))return false;
   CamHandle(0.01,100,CAMH_ZOOM|(Ms.b(1)?CAMH_MOVE:CAMH_ROT));

   // update particles
   part.update();

   return true;
}
/******************************************************************************/
void Render()
{
   switch(Renderer())
   {
      case RM_SOLID:
         mbox.draw(MatrixIdentity);
      break;

      case RM_LIGHT:
         LightPoint(30,Vec(0,3,0)).add();
      break;
      
      case RM_PRT_BLN: // alpha blending
         part.draw();
      break;
   }
}
void Draw()
{
   Renderer(Render);
}
/******************************************************************************/

I have a question, why don't you want to embed stars on the sky-box ? It would be faster.

Do you want to have animated stars?
02-10-2009 03:16 PM
Find all posts by this user Quote this message in a reply
SONB Offline
Member

Post: #17
Re: Yellow scene with hpRt(true)?
Thanx, Esenthel! Your code works grin

Yes, I want animated stars. If I paint them on my skybox, they look too static to me. I know, the real stars don't blink, but the star field looks so much better when the stars fade out and fade in again.
Now here comes another problem: the particles generated with your code don't blink. If I set life to a positive value, they die simultaneously. Ok, I think I could set for each particle a random life value. But more important question is: how can I reborn them again?
I'll try to figure it out myself but if you find a minute for me, it would be great!

Thanx again for your code, at least I can see my goddamn stars again lol
02-10-2009 05:24 PM
Find all posts by this user Quote this message in a reply
Esenthel Offline
Administrator

Post: #18
Re: Yellow scene with hpRt(true)?
for blinking I advise to use
func=PARTICLE_LIFE_MAX;

and then manually set Particle::life_max to values 0..1
02-10-2009 05:31 PM
Find all posts by this user Quote this message in a reply
SONB Offline
Member

Post: #19
Re: Yellow scene with hpRt(true)?
Works perfectly, Esenthel grin

Thanx a lot for your help!
02-10-2009 08:23 PM
Find all posts by this user Quote this message in a reply
Post Reply