Page 1 of 1

ParticleColorRange

Posted: Sat Dec 08, 2012 1:39 am
by Samuel
According to the help files this command is supposed to give every emitted particle a random value, within the 'StartColor' and 'EndColor' range.
In this example though the particles stay the original color of the texture. The ParticleColorRange seems to have no effect on them.
Not sure if this is a bug or if I'm just using this incorrectly. Any help is appreciated.

Code: Select all


;################PRESS ESCAPE TO QUIT##################

#CameraSpeed = 1
Define.f MouseX, MouseY
  ExamineDesktops()
  InitEngine3D()
  InitSprite()
  InitKeyboard()
  InitMouse()

W=DesktopWidth(0)
H=DesktopHeight(0)
If OpenWindow(0, 0, 0, W, H, "Particles", #PB_Window_MinimizeGadget | #PB_Window_ScreenCentered)
  OpenWindowedScreen(WindowID(0), 0, 0, W, H, 0, 0, 0)

   CreateTexture(2, 32, 32)
    StartDrawing(TextureOutput(2))
      Circle(16,16,16,RGB(255,255,255))
    StopDrawing()
    
   CreateMaterial(0, TextureID(2))
   MaterialBlendingMode(0, #PB_Material_Add)
   CreateLight(1, RGB(155,155, 155), 0, 500 , 0)
            
   CreateParticleEmitter(0, 1000, 1000, 100, #PB_Particle_Box, 0, 700, -200)
   ParticleMaterial(0, MaterialID(0))
   ParticleEmitterDirection(0, 0, -1, 0)
   ParticleTimeToLive(0, 6, 7)
   ParticleEmissionRate(0, 100)
   ParticleSize(0, 10, 10)
   
  ;################
   ParticleColorRange(0, RGB(50,0,0), RGB(255,0,0))
   
   
    CreateCamera(0, 0, 0, 100, 100)
    CameraLocate(0, 0, 200, 150)
    CameraBackColor(0,RGB(0,0,0))
    
    Repeat

      If ExamineMouse()
        MouseX = -MouseDeltaX() * #CameraSpeed * 0.05
        MouseY = -MouseDeltaY() * #CameraSpeed * 0.05
      EndIf
      If ExamineKeyboard()
      EndIf
      RotateCamera(0, MouseY, MouseX, 0, #PB_Relative)
      
      RenderWorld()
      FlipBuffers()
    Until KeyboardPushed(#PB_Key_Escape)

Else
  MessageRequester("Error", "The 3D Engine can't be initialized",0)
EndIf

End

Re: ParticleColorRange

Posted: Sat Dec 08, 2012 2:54 am
by idle
think the problem is with your textures creation
if you try the particles.pb demo in examples it works with the flare.png loaded as a texture
so maybe try creating an image with transparency first then draw that into the texture

Re: ParticleColorRange

Posted: Sat Dec 08, 2012 3:17 am
by Samuel
I took a look at the particles example and I noticed that it had DisableMaterialLighting on the texture. So I gave that a try and it seems to work perfect now.
I guess it was just the light disabling the ParticleColorRange. Thanks for the help though.