Questions about workings of fireball in techdemo

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Domarius
Posts: 178
Joined: Thu Mar 11, 2004 9:51 am
Location: Brisbane, QLD, Australia

Questions about workings of fireball in techdemo

Post by Domarius »

I didn't have any luck in the Beginner's Forum with this post, so I'm trying here.

In the tech demo, in CDemo.cpp, there is a 'struct' called SParticleImpact. I worked out that this is what is instantiated to make a "shoot" bullet, that fires when you press Space.

These variables are created inside it.
core::vector3df pos;
core::vector3df outVector;
I'm assuming they are to help make the ball travel.

What I want to know is; how are they used?

Also, where is the fireball destroyed?? I can see where it is added to the array; Impacts.push_back(imp); but when is it removed??

Lastly, I got this version of "shoot" working perfectly in my project - a Faerie shoots the bullet billboards from her body when you press space.
But because the bullets use the collision animator to go between 2 points, there's nothing in there for testing collision with a moving object.
So if I want to be able to shoot moving objects, what's the best way to go about doing that?

I was going to iterate through the array of bullets, and test for overlap between all the moving objects.
But 2 things stopped me.
First, I don't really understand where all the bullets are being stored. The only thing I could see is Impacts.push_back(imp); but I wasn't sure if it contains the entire bullet, since there's nothing there about the node variable.
Also, in http://irrlicht.sourceforge.net/phpBB2/ ... php?t=1972
Electron said;
I think it would probably be easier to use Newton with projectiles, because one can set a callback for when the bullets collide, rather than having to constantly test them yourself.
It sounds really cool, and I probably wouldn't need to manage them in an array that way - just deal with them in the callback event they create.
Does anyone else agree?
Gorgon Zola
Posts: 118
Joined: Thu Sep 18, 2003 10:05 pm
Location: switzerland

Post by Gorgon Zola »

Hi Domarius
In the tech demo, in CDemo.cpp, there is a 'struct' called SParticleImpact. I worked out that this is what is instantiated to make a "shoot" bullet, that fires when you press Space.
no quiet. the structure SParticleImpact only stores when and where an impact particle system should be created. -> see CDemo::createParticleImpacts()
These variables are created inside it.
core::vector3df pos;
core::vector3df outVector;
I'm assuming they are to help make the ball travel.
no, these have only to do with the impacts.
pos : the position of the impact particles
outVector : direction of the particle emmission
-> see CDemo::createParticleImpacts()

Lastly, I got this version of "shoot" working perfectly in my project - a Faerie shoots the bullet billboards from her body when you press space.
But because the bullets use the collision animator to go between 2 points, there's nothing in there for testing collision with a moving object.
So if I want to be able to shoot moving objects, what's the best way to go about doing that?
As you have no doubt guest, the method of shooting in the techdemo is only good if you have nonmoving objects or very fast bullets.
if you have slow bullets and moving objects you'll have to test for collisions or proximity.
the techdemo doesn't hold an array of the moving bullets only the impacts are stored, so you'll have to build this bullet array yourself.

I'd do a simple bounding sphere intersection test against all moving objects

About using an other collision library:
if you have physics in your game then newton would shurely be an option, if not then there are "simpler" ways like 'coldet' or 'opcode', or just do proximity test as mentioned before

cheers
tom
Domarius
Posts: 178
Joined: Thu Mar 11, 2004 9:51 am
Location: Brisbane, QLD, Australia

Post by Domarius »

Thanks for taking the time to answer each and every one of my questionsGorgon Zola, that's pretty much all the information I could have hoped for. :D

I get it now - SParticleImpacts is just information on where and what angle to create those white smoke things that come from the wall when the bullet hits - the code makes a bit more sense now. So I have references to SParticleImpact in my project for nothing. Heh.

What I'm confused about now is - where is the information for the bullet and its direction etc. stored? Is it possible that once it's instantiated, it doesn't need any variables associated with it, and Irrlicht looks after it from then on? How does Irrlicht know when to destroy it?

Also, if I wanted to make an array of the bullets, am I right in assuming I would have to store the 'node' variable from the 'shoot()' function, in an index in the array?

Lastly, I have no idea what 'coldet' and 'opcode' are, where can I learn about them?
Gorgon Zola
Posts: 118
Joined: Thu Sep 18, 2003 10:05 pm
Location: switzerland

Post by Gorgon Zola »

Domarius wrote: What I'm confused about now is - where is the information for the bullet and its direction etc. stored? Is it possible that once it's instantiated, it doesn't need any variables associated with it, and Irrlicht looks after it from then on? How does Irrlicht know when to destroy it?
check the 'shoot' function of the techdemo!
a billboard node is created for the fireball and two animators are attached.
one fly forward animator and one delete animator.
Domarius wrote: Also, if I wanted to make an array of the bullets, am I right in assuming I would have to store the 'node' variable from the 'shoot()' function, in an index in the array?
yes.
Domarius wrote: Lastly, I have no idea what 'coldet' and 'opcode' are, where can I learn about them?
I'm not so shure that you'll have very much fun with these collision libraries :? http://www.codercorner.com/Opcode.htm http://photoneffect.com/coldet/
Domarius
Posts: 178
Joined: Thu Mar 11, 2004 9:51 am
Location: Brisbane, QLD, Australia

Post by Domarius »

Gorgon Zola wrote: check the 'shoot' function of the techdemo!
a billboard node is created for the fireball and two animators are attached.
one fly forward animator and one delete animator.
Geez - well no wonder I missed that, I never thought it would be done that way! That is very cool. Letting the engine handle it. Just set it and forget it.
Gorgon Zola wrote: I'm not so shure that you'll have very much fun with these collision libraries :? http://www.codercorner.com/Opcode.htm http://photoneffect.com/coldet/
Okay - well I will stick with what I know then :)

Thanks again - I can continue with my project now :)
Post Reply