peterigz
Forum Replies Created
-
AuthorPosts
-
peterigzKeymasterUnfortunately the Area effect type doesn’t have the option to only spawn at the edges. I guess one work around might be to create a line effect and then use effect angle and line length to position them around the edge that you want to create the rectangle that way.
peterigzKeymasterHi, sorry for the delay, I finally managed to get Blitzmax working again! I loaded the effect in the sample program that comes with the documentation and it seems to play ok. Is there anything in your code that might be causing the effect to play with less particles? Are you using “MyParticleManager.SetGlobalAmountScale(1)” anywhere perhaps with a lower number? If is the code I am using to test: (sorry about lack of formatting, the code box wasn’t working properly for some reason!
SuperStrict
Framework brl.max2d
Import rigz.timelinefx
Import rigz.tweener
Import brl.glmax2dSetGraphicsDriver GLMax2DDriver()
‘Load the effects library
Local MyEffectsLib:tlEffectsLibrary = LoadEffects(“effects/main_lib2.eff”, False)
‘Create an effect and assign it an effect from the library
Local MyEffect:tlEffect = MyEffectsLib.GetEffect(“slow_smoke”)
‘Create the particle manager to manage the particles
Local MyParticleManager:tlParticleManager = CreateParticleManager()Graphics (800, 600, 0)
‘These commands are important to set the origin of the particle manager. For this example we’re setting the origin so that
‘effects will be placed at screen coordinates. If you leave out the setorigin command then an effect created at 0,0 would
‘be placed at the center of the screen.
myparticlemanager.SetScreenSize(GraphicsWidth(), GraphicsHeight())
myparticlemanager.SetOrigin(GraphicsWidth() / 2, GraphicsHeight() / 2)
‘You can use the following command to control the number of particles spawned globally by the particle manager.
‘This is handy for slower PCs where you want to reduce the number of particles that are drawn overal. A setting of 0.5 would halve the
‘number spawned for example. 1 is the default value.
‘MyParticleManager.SetGlobalAmountScale(1)MyParticleManager.SetUpdateMode(tlUPDATE_MODE_INTERPOLATED)
‘This will make one frame equal 33 millisecs long – or 30 updates per second.
SetUpdateFrequency(30)‘Create a tweener using the tweener mod. Make sure its frequency matches that above
Local Tweener:tTweener = New tTweener.Create(30)‘Our main loop
While Not KeyDown(KEY_ESCAPE) Or AppTerminate()Cls
If MouseHit(1)
‘to create an effect you need to use the copyeffect command, and copy the MyEffect you created earlier.
‘You shouldn’t use MyEffect as it is the template
‘for which is used to create effects you draw on screen.
Local tempeffect:tlEffect = CopyEffect(myeffect, MyParticleManager)
‘Set the temp effect to the mouse coords
tempeffect.SetX(MouseX())
tempeffect.SetY(MouseY())
‘give it a random zoom level which will affect the overal size of the effect
tempeffect.SetZ(Rnd(0.5, 1.5))
‘add the effect to the particle manager. Important, otherwise the particle manager would have nothing to update
MyParticleManager.addeffect(tempeffect)
End If‘here is the timing code, update the tweener to get the number of ticks for this loop
Tweener.Update()For Local Ticks:Int = 1 To Tweener.FrameTicks
‘Update the execution time for the tweener
Tweener.UpdateExecutionTime()
‘Update the particle manager
MyParticleManager.Update()
Next‘and finally draw the particles.
MyParticleManager.DrawParticles(Tweener.Tween)SetRotation 0
SetScale 1, 1
SetAlpha 1
DrawText MyParticleManager.GetParticlesInUse(), 10, 10Flip 0
Wend
peterigzKeymasterHi, I’ll try and look at this, currently my Blitzmax doesn’t seem to be compiling so once I’ve sorted that I’ll take a look at it.
peterigzKeymasterGreat glad you got it working. Yes come to think it it that extra code I had might have been to do the pre-multiply alpha I had set up but it’s been quite a few years since I looked at the code!
peterigzKeymasterThat looks better!
Regarding the smoke emitter, it looks like it’s not spawning enough particles, maybe you can check how many particle it’s spawning compared to the editor?
peterigzKeymasterWell, in blitzmax you simply do SetBlend LightBlend. But looking into the directx module that handles it all for you the setblend function looks like this: (bear in mind that this is DX9)
Method SetBlend( blend ) If blend=_active_blend Return Select blend Case SOLIDBLEND _d3dDev.SetRenderState D3DRS_ALPHATESTENABLE,False _d3dDev.SetRenderState D3DRS_ALPHABLENDENABLE,False Case MASKBLEND _d3dDev.SetRenderState D3DRS_ALPHATESTENABLE,True _d3dDev.SetRenderState D3DRS_ALPHABLENDENABLE,False Case ALPHABLEND _d3dDev.SetRenderState D3DRS_ALPHATESTENABLE,False _d3dDev.SetRenderState D3DRS_ALPHABLENDENABLE,True _d3dDev.SetRenderState D3DRS_SRCBLEND,D3DBLEND_SRCALPHA _d3dDev.SetRenderState D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA Case LIGHTBLEND _d3dDev.SetRenderState D3DRS_ALPHATESTENABLE,False _d3dDev.SetRenderState D3DRS_ALPHABLENDENABLE,True _d3dDev.SetRenderState D3DRS_SRCBLEND,D3DBLEND_SRCALPHA _d3dDev.SetRenderState D3DRS_DESTBLEND,D3DBLEND_ONE Case SHADEBLEND _d3dDev.SetRenderState D3DRS_ALPHATESTENABLE,False _d3dDev.SetRenderState D3DRS_ALPHABLENDENABLE,True _d3dDev.SetRenderState D3DRS_SRCBLEND,D3DBLEND_ZERO _d3dDev.SetRenderState D3DRS_DESTBLEND,D3DBLEND_SRCCOLOR End Select _active_blend=blend End MethodYou can find the source code for the DX9 module for blitzmax here: https://github.com/blitz-research/blitzmax/blob/master/mod/brl.mod/d3d9max2d.mod/d3d9max2d.bmx
peterigzKeymasterHmm, unfortunately I just don’t know enough about dx11 to know why it might be doing that. You might have to ask around on more DX oriented forums. Let me know how you get on.
peterigzKeymasterCan you try the following for additive blend, see if it makes any difference:
SrcBlend = D3D11_BLEND_ONE; DestBlend = D3D11_BLEND_ONE; BlendOp = D3D11_BLEND_OP_ADD; SrcBlendAlpha = D3D11_BLEND_ONE; DestBlendAlpha = D3D11_BLEND_ONE; BlendOpAlpha = D3D11_BLEND_OP_ADD;
peterigzKeymasterFrom your image it does look light additive blend is working as it should, but the image is wrong – like the whole image is just a white square. Is there somehow you can verify that the image is correct? The additive code you have does look correct to me so maybe it’s something with the image, that’s the only thing that I can think of at the moment.
peterigzKeymasterOpps sorry missed this thread! You could do either effect.Softkill() or effect.Hardkill() depending on whether or not you want the effect to finish playing out the effect or just end straight away. If you want to start it again just add the effect back to the particle manager. If you don’t want to remove the effect you could also do effect.SetAmount(0) to stop particles spawning and then effect.SetAmount(1) to start them again, but it depends what type of effect you are using.
peterigzKeymasterI think that my load script just measured the width and height of the image and then determined how to load the animation based on the size of each frame and the number of frame. Most images are square and laid out as per your example though. Yes frames start from 0 I believe.
As for the blend mode, I’m not really sure about how blend modes work in DX11, it looks correct how you’re doing it as both source and destination need to be ONE but maybe there’s something else that needs to be done else where in the code?
peterigzKeymasterIt looks like it’s not respecting the alpha values in the image, so maybe it’s an issue with the way image is being loaded rather then the actual blend mode? Looks like all alpha values in the image are 1. Maybe it’s being loaded with RGB rather then RGBA or something along those lines.
I think in the data.xml file in the eff file the animated images have the details about the width and height of each frame and the number of each frame so you should be able to use that to load the sprite sheets correctly.
peterigzKeymasterHi, the blending in the editor is either Alpha blending where the colours are just mixed together based on the alpha values, or additive blending where colours are added together. It looks like you are only using alpha blending? It might be called Lightblend in DX but not sure.
The animated particles are just sprite sheets. These are drawn based on the start frame and the frames per second as set on the Frame Rate graph. You can see on the Particle tab in the editor that you can also set the animation to play in reverse. The frame number is what’s passed in – it’s passed in as a float because you can change the frame rate that it’s played so it’s just converted to an int to draw the nearest available frame.
peterigzKeymasterThanks, I’ll take a look at that, I think it’s just a minor bug but I never noticed the error before.
peterigzKeymasterHi George, I’ve resent it to that address, let me know if you get it ok.
-
AuthorPosts