A question for someone familiar with TimelineFX

BlitzMax Forums/BlitzMax Beginners Area/A question for someone familiar with TimelineFX

Galdy(Posted 2014) [#1]
I'm trying out thier "A simple program in Blitzmax with TimelineFX" found here : http://www.rigzsoft.co.uk/a-simple-program-in-blitzmax-with-timelinefx/


When it gets to this line,

 Local tempeffect:tlEffect = CopyEffect(MyEffect, MyParticleManager) 


i’m getting a “Attempt to access field or method of Null object”

The only changes i made to thier example program are the path and the effect.

 Local MyEffectsLib:tlEffectsLibrary = LoadEffects(“C:\Users\Tim Knapp\Downloads\TimelineFX\FireandSmoke.eff”) 


and

 Local MyEffect:tlEffect = MyEffectsLib.GetEffect(“Torch”)



Pete Rigz(Posted 2014) [#2]
In the mod folder in timelinefx.mod/doc you'll find tlParticleManager.bmx which is an example program you can run as is. Try that and see if it works ok to verify the module is all installed ok.


Galdy(Posted 2014) [#3]
Yes the tlParticleManager.bmx worked. I noticed a couple of different lines at the start of it.

The tlParticleManager.bmx has

Framework brl.max2d
Import rigz.timelinefx
Import rigz.tweener
Import brl.glmax2d 

SetGraphicsDriver GLMax2DDriver()


This is not in your example on the website.

where as i have this prior to loading the effects library.
Import koriolis.bufferedstream
Import koriolis.zipstream
Import bah.libxml
Import gman.zipengine
Import rigz.timelinefx
Import rigz.Tweener 


I added the ones I was missing from your tlParticleManager.bmx example and it still isn't working. Your website says that these modules are needed.

Import koriolis.bufferedstream
Import koriolis.zipstream
Import bah.libxml
Import gman.zipengine


Galdy(Posted 2014) [#4]
Ok i took the tlParticleManager.bmx example and I pasted over my path and effect name "Torch" and it did not work. Must be a problem with my path?

 Local MyEffectsLib:tlEffectsLibrary = LoadEffects("C:\Users\Tim Knapp\Downloads\TimelineFX\FireandSmoke.eff", False)



Still getting null object.


Galdy(Posted 2014) [#5]
So now I tried not even changing that path, but putting FireandSmoke.eff in the same folder as examples.eff which works. I get an "Error loading effects file". It will load example.eff and work, but not FireandSmoke.eff.

 MyEffectsLib:tlEffectsLibrary = LoadEffects("effects/FireandSmoke.eff", False)
'Create an effect and assign it an effect from the library
Local MyEffect:tlEffect = MyEffectsLib.GetEffect("Torch")



Pete Rigz(Posted 2014) [#6]
Does the fireandsmoke.eff file load into the editor ok?


Floyd(Posted 2014) [#7]
Maybe it's a file permissions problem.

Program tlParticleManager.bmx can load effects.eff successfully, but your test program fails on FireandSmoke.eff.

Try putting your program in the same place as tlParticleManager.bmx and put FireandSmoke.eff in the same location as effects.eff.


Galdy(Posted 2014) [#8]
Pete Rigz,The file loads into the editor no problem. I tried aurasandhalos.eff and they wont load into tlParticleManager.bmx either. Baffling, when the examples.eff will load in tlParticleManager.bmx.

Floyd, That is what i did. I put the Fireandsmoke.eff in the same folder as the "Example.eff." "Effects/" is the folder containing the example.eff not the effect itself. Man i'd really like to try these particles out for my game if possible, but i can't even get out of the batters box. lol.


Galdy(Posted 2014) [#9]
It is interesting when I put my own path C:\Users\Tim Knapp\Downloads\TimelineFX\FireandSmoke.eff in tlParticleManager.bmx, it appears to load, but i get a null object error when it get to the copy function.


Pete Rigz(Posted 2014) [#10]
Floyd may have the answer there if your Blitzmax is installed in the program files folder. On windows any programs run from there access a virtual store in your users folder instead of use files that are actually in the installation folder, so it might be something to do with that. I would try moving the example into your documents folder and running it from there.

I wouldn't have thought it'd affect something you're compiling and running from Blitmax though...


Galdy(Posted 2014) [#11]
Blitzmax is not stored in the programs folder. C:\BlitzMax


Galdy(Posted 2014) [#12]
Update. it appears to load the FireandSmoke.eff from the same folder as example.eff or my own path. So the path is not the issue. I must not have actually pasted fireandsmoke.eff to the effects/" folder. I must have been dingy late last night.
Never the less, i still have the very original problem then. I get a null object in the copy effect function.


Galdy(Posted 2014) [#13]
I Don't know if this will help, but regarding the null object error, Blide debug mode directs the problem to the copy effect function and specifically highlights the line "eff.amount = CopyAttributeNodes(e.amount)"

Function CopyEffect:tlEffect(e:tlEffect, ParticleManager:tlParticleManager, copydirectory:Int = False)
	Local eff:tlEffect = New tlEffect
	Local ec:tlEmitter
	eff.amount = CopyAttributeNodes(e.amount)
	eff.life = CopyAttributeNodes(e.life)
	eff.sizex = CopyAttributeNodes(e.sizex)
	eff.sizey = CopyAttributeNodes(e.sizey)
	eff.velocity = CopyAttributeNodes(e.velocity)
	eff.weight = CopyAttributeNodes(e.weight)



Pete Rigz(Posted 2014) [#14]
ooooh, sorry I should have looked at your code more closely, I just loaded the fire and smoke library and knew straight away what it was :)

You need to specify the path to the effect as it is in the editor. So for example torch is in Torch and candles folder so you need to do:

Local MyEffect:tlEffect = MyEffectsLib.GetEffect("torch and candles/Torch")



Galdy(Posted 2014) [#15]
Didn't work at first, but is now. Apparently the path for the effects library MUST BE in bloody C:\BlitzMax\mod\rigz.mod\timelinefx.mod\doc\Effects\ I take it.

Plus it appears that the tlParticleManager.bmx MUST Be in C:\BlitzMax\mod\rigz.mod\timelinefx.mod\doc\

So any .bmx I wish to call these effects from better be in there uh?


Pete Rigz(Posted 2014) [#16]
No, you can load them from wherever you want, the path should be relative to where the .bmx file is stored, for example here is the code from my test that loads the effects from the same folder as the code sits in:

'Load the effects library
Local MyEffectsLib:tlEffectsLibrary = LoadEffects("fireandsmoke.eff", False)
'Create an effect and assign it an effect from the library
Local MyEffect:tlEffect = MyEffectsLib.GetEffect("Torch and candles/candle")


The important thing was that you specify the "Torch and Candle" folder when you get the effect.


Galdy(Posted 2014) [#17]
Rigz, thanks for answering all these newb questions Sir. I might have a couple more before I get the full jist of your module commands, but I should be able to play with it now and try integrating it into my game. Thanks.


Galdy(Posted 2014) [#18]
If I create 40 Torch's, will they all be rendering if I use
 Myeffect.setvisible(True/False)
to make only the ones I want visible? I don't want to over tax the system if i don't have to.

Also, is there a way to draw the "torch" effect so that it is in full bloom? Reason i ask is if I create a new effect every time i need a torch drawn somewhere, it's going to draw it like it's being lit up for the first time. Starting at zero particles. I need the flame already blazing away. Hence the question above about having them already created and making them visible or not.


Pete Rigz(Posted 2014) [#19]
I think SetVisible will work as you need, but any particles not within the screen view won't be drawn either.

You can start an effect a few frames into the simulation by using:

AddPreLoadedEffect(e:tlEffect, frames:Int, Layer:Int = 0)


Use that instead of AddEffect, and specify the number frames into the effect you want to start from. Most most effects 30 should be enough but it depends on the effect, you can experiment :)


Galdy(Posted 2014) [#20]
Thanks for the reply Pete. I was able to accomplish what I needed with multiple particle managers with one torch effect in each. I had to do this because when I add multiple effects into one particle manager, it wants to draw them all at once when the ParticleManager.DrawParticles(Tweener.Tween) is called. So I made an array of particle managers loaded with a Torch and it's related (x,y ,z) values. So there is a particle manger for each Torch location. This is the only way I differentiate each one. Also, this way no more particles are being drawn than what is necessary at a time. I'm not sure this is the best way to do it, but it is what i'm trying right now and seems to work. Except for the following problem.....


When I run my game without the drawing any Torch effects everything is normal. See pic.






However, as soon as I invoke ParticleManager.DrawParticles(Tweener.Tween) in my code I get this weird effect.

You can see a Torch particle effect in operation on the left most torch. Looks great except for this weird issue.I should add that I shouldn't able to see that torch in operation though.



I adapted your example code inside my own Torch function that draws the torch& sconce and lit wall, then draws the torch particle effect.

 For Local Ticks:Int = 1 To Tweener.FrameTicks
                 Tweener.UpdateExecutionTime()					
	    TorchParticleManagerNS[D_Pointer].Update()
          Next
     TorchParticleManagerNS[D_Pointer].DrawParticles(Tweener.Tween) 




Any thoughts what I could be doing wrong Pete?


Pete Rigz(Posted 2014) [#21]
My initial guess would be that for some reason the alpha isn't being set back to what it should be. When the particles are drawn by the particle manager, before it starts it makes a note of the current SetAlpha, SetColor, SetRotation etc. values, so that once it's finished drawing the particles it sets them back to what they were before it started drawing them.

I just looked at the code however and it doesn't seem to restore the value of the current Blendmode. Not sure why, maybe it's not possible to get the current blendmode so I left it out... So I would try setting the blendmode that you want before you start drawing your own graphics and see if that helps.


Galdy(Posted 2014) [#22]
I had to put
 SetBlend SOLIDBLEND
       SetBlend ALPHABLEND
       SetAlpha 1  


After each call of
 TorchParticleManagerNS[D_Pointer].DrawParticles(Tweener.Tween)


Thanks for pointing me in the right direction. I still got some lingering glitches with implementing the torches. Close though. lol.


Galdy(Posted 2014) [#23]
Pete, I have multiple particle managers with one effect in each. I can't figure out how to get the z,y handle of an "effect" that's in a particle manager. I'm trying to track down why some of the torches are getting drawn at 0,0 instead of the coordinates I assigned them at the start of the program.


Pete Rigz(Posted 2014) [#24]
If you need to track an effect the best this is to just store that effect somewhere so you can get to it again, and use effect.GetX(), GetY() or effect.SetPosition() to position it.


Galdy(Posted 2014) [#25]
I seem to be having a problem with the timing now. I use the function below to update my particle managers that are visible, but the timing is only allowing me to properly draw the first torch it encounters in the loop. If I remove
 
Tweener.UpdateExecutionTime()


it will draw all the torches that are visible, but of course way to fast. I tried to adapt your example code to what I'm doing, but I guess I don't fully understand how to use the tweener mod. Perhaps you/someone can identify what I'm doing wrong.



Function Torch_Update()
Tweener.Update()
For Local Ticks:Int = 1 To Tweener.FrameTicks
    Tweener.UpdateExecutionTime()
  	Select D.Layer4
		Case 9  'North facing Torch 
		    Select Player.Heading
			    Case 1 'looking north
			    Case 2 'looking east
				    Select D_Pointer 'Right side
				      	Case 3, 5, 7, 10, 12, 14, 19, 21, 24, 26, 31, 34
							TorchParticleManagerEW[D_Pointer].Update
		             End Select
				Case 3 'Looking South  Straight ahead						 	
					Select D_Pointer
					Case 4, 5, 6, 7, 8, 11, 12, 13, 14, 15, 20, 21, 22, 25, 26, 27, 32, 35
						TorchParticleManagerNS[D_Pointer].Update
					End Select
				Case 4 'Looking west
				    Select D_Pointer 'Left side				
						Case 2, 4, 6, 9, 11, 13, 18, 20, 23, 25, 30, 33
							TorchParticleManagerEW[D_Pointer].Update
					End Select
			EndSelect		
		Case 10 'East facing Torch	
		 	Select Player.Heading
			    Case 1 'looking north
				    Select D_Pointer 'Left side
						Case 2, 4, 6, 9, 11, 13, 18, 20, 23, 25, 30, 33
							TorchParticleManagerEW[D_Pointer].Update
					End Select
				Case 2 'Looking east
							
				Case 3
				    Select D_Pointer 'Right side
				      	Case 3, 5, 7, 10, 12, 14, 19, 21, 24, 26, 29, 31, 34
							TorchParticleManagerEW[D_Pointer].Update
		            End Select
				Case 4 'looking west								 	
					Select D_Pointer
						Case 4, 5, 6, 7, 8, 11, 12, 13, 14, 15, 20, 21, 22, 25, 26, 27, 32, 35
					    	TorchParticleManagerNS[D_Pointer].Update
					End Select
			End Select
			
		Case 11 'South facing torch
			Select Player.Heading
				Case 1
					Select D_Pointer
						Case 4, 5, 6, 7, 8, 11, 12, 13, 14, 15, 20, 21, 22, 25, 26, 27, 32, 35
							TorchParticleManagerNS[D_Pointer].Update
					Default
					
					End Select
				Case 2
					Select D_Pointer 'Left side
						Case 2, 4, 6, 9, 11, 13, 18, 20, 23, 25, 30, 33
							TorchParticleManagerEW[D_Pointer].Update
					End Select
				Case 3
				Case 4
				 	Select D_Pointer 'Right side
				      	Case 3, 5, 7, 10, 12, 14, 19, 21, 24, 26, 29, 31, 34
							TorchParticleManagerEW[D_Pointer].Update
		            End Select
			End Select
		Case 12 'West Facing Torch
		   	Select Player.Heading
		    	Case 1 'Looking north
				 	Select D_Pointer 'Right side
				      	Case 3, 5, 7, 10, 12, 14, 19, 21, 24, 26, 29, 31, 34
							TorchParticleManagerEW[D_Pointer].Update
		            End Select
				Case 2 'Looking east		    
					Select D_Pointer
						Case 4, 5, 6, 7, 8, 11, 12, 13, 14, 15, 20, 21, 22, 25, 26, 27, 32, 35
							TorchParticleManagerNS[D_Pointer].Update
					End Select
																	
				Case 3 'looking east
					Select D_Pointer 'Left side
						Case 2, 4, 6, 9, 11, 13, 18, 20, 23, 25, 30, 33
							TorchParticleManagerEW[D_Pointer].Update
					End Select
				Case 4
			End Select
	End Select
Next
End Function 



Pete Rigz(Posted 2014) [#26]
hi Galdy,

Hmm it's hard to say, I'm not sure I'd structure it like that by putting the timer loop inside the torch update function, rather I'd do something in your main loop along the lines of:

Tweener.Update()
For Local Ticks:Int = 1 To Tweener.FrameTicks
    Tweener.UpdateExecutionTime()
    Torch_Update()
    ...all your other updates
Next

ParticleManager.DrawParticles(Tweener.Tween)


Let me know how you get on.


Galdy(Posted 2014) [#27]
Ok, figured it out. I had to change the function above to select the "viewable" particle managers, a.k.a torches, and put them in a list. Then in the main loop cycle through and update them (code below). WEW. Took some hours to struggle through and figure it out. Looks quite cool.

 
Local Number_of_Torches:tlParticleManager
Tweener.Update()
For Local Ticks:Int = 1 To Tweener.FrameTicks
Tweener.UpdateExecutionTime()
For Number_of_Torches = EachIn TorchList	  	
	Number_of_Torches.update		
	   	  
Next
Next 



Pete Rigz(Posted 2014) [#28]
Great, glad you figured it out :)


Galdy(Posted 2014) [#29]
Thanks for the help Pete. For the heck of it, here's a test vid of the torch in action. :)

https://www.youtube.com/watch?v=JT38Ne2sbaI&feature=em-upload_owner


Pete Rigz(Posted 2014) [#30]
Looks great. I love those old style dungeon crawlers, I played many hours on the likes of dungeon master, eye of the beholder, black crypt, Bane of the cosmic forge and god knows what else! Looking forward to seeing your game progress :)