Using the face normal to place a projectile effect
by Bryce · in Technical Issues · 12/28/2007 (6:33 am) · 3 replies
Hello,
I was playing Call of Duty 1 (I know it's old, it's still fun) a while ago and I noticed that if you shoot at a wall, instead of a single particle effect like you'd get in torque, there was a 3d shape that was supposed to resemble a puff of dust that would protrude outwards from the wall. I am trying to implement something like that in Torque, and I'm trying to figure out how to do something like that. I have a shape modeled for the effect, but my main obstacle is figuring out how to adjust the shape's transform to match the normal of the wall (the normal is given to us in the projectile's ::onCollision(...) function, so don't worry about showing how to get that). Hope I've been clear on this, help is appreciated.
I was playing Call of Duty 1 (I know it's old, it's still fun) a while ago and I noticed that if you shoot at a wall, instead of a single particle effect like you'd get in torque, there was a 3d shape that was supposed to resemble a puff of dust that would protrude outwards from the wall. I am trying to implement something like that in Torque, and I'm trying to figure out how to do something like that. I have a shape modeled for the effect, but my main obstacle is figuring out how to adjust the shape's transform to match the normal of the wall (the normal is given to us in the projectile's ::onCollision(...) function, so don't worry about showing how to get that). Hope I've been clear on this, help is appreciated.
#2
12/28/2007 (8:16 am)
That isn't exactly what I mean. In the fx pack, for example, you can see that large explosions have a particle effect and a 3d shape that fades in and out again if you look closely. That 3d shape isn't always straight up; if the normal of the face isn't flat (say you fire at the side of a hill), then the shape is rotated so that it aligns with the surface. Follow me?
#3
I'm sure there are plenty of ways to do this but lets explore an option that I am familiar with (in all my limited knowledge).
Lets say your puff object is modeled so that it faced "forward" along the y axis like players.
Then our Normal (N) becomes our Forward Vector (F) Which can then be crossed (Cross Product) with an Up Vector (U) to compute our Right Vector (R) which can then build built into a matrix by settings columns 1, 2 and 0 respectively.
However! Yes there is a however and this is where I suspect there might be an easier way. Almost anytime you need to use special cases to compute something there is a more efficient way without casing, but I don't know what that is so here it goes.
Just performing the method above might fail for surfaces that are perfectly flat (horizontally). If you want to use the above method you should check to see if your normal is either straight up or straight down and in that case use a different vector for up. Normally I use world right '1 0 0' but you could use the collision vector or something instead.
12/28/2007 (10:11 am)
This question is asked so many times in SO many forms...I'm sure there are plenty of ways to do this but lets explore an option that I am familiar with (in all my limited knowledge).
Lets say your puff object is modeled so that it faced "forward" along the y axis like players.
Then our Normal (N) becomes our Forward Vector (F) Which can then be crossed (Cross Product) with an Up Vector (U) to compute our Right Vector (R) which can then build built into a matrix by settings columns 1, 2 and 0 respectively.
However! Yes there is a however and this is where I suspect there might be an easier way. Almost anytime you need to use special cases to compute something there is a more efficient way without casing, but I don't know what that is so here it goes.
Just performing the method above might fail for surfaces that are perfectly flat (horizontally). If you want to use the above method you should check to see if your normal is either straight up or straight down and in that case use a different vector for up. Normally I use world right '1 0 0' but you could use the collision vector or something instead.
Torque 3D Owner Sean H.