3D Position to Screen Position



  • I'm wanting to spawn a 2D explosion in my 3D world.
    I didn't see any animated 3D explosions in the gallery, as that would have been my first option.

    How do I figure out where to draw a 2D graphic at a 3D world position (eg. where the enemy model is)?
    I need a '3D point to 2D position' conversion function.

    I could make and spawn my own 3D particle system (using cubes?), but that's seems like too much work.

    Right now, I just delete the enemy from the screen instantly when shot, so is barely noticeable.
    Or what other technique could I use?


  • F

    I have seen formulas for this online, but have not tried them myself.

    I once made a very simple ’explosion’ out of a sphere. Set it to orange, semi-transparent. Experiment with size changes and colour fades, I’m sure you’ll come up with something :)


  • F

    The terrain function also has transparencies now, you could wangle something explosion looking out of one of those, maybe.



  • I was thinking about the sphere idea, and may give that a go.

    BUT, I'm loving the terrain idea! I could spawn a small terrain tile at the enemy's position, with a circular (or rectangular) shape, with heights and color matching the enemy, and reduce the heights over time to appear like the enemy 'melts' into the ground. maybe changing colors and alpha along the way. Maybe combine that with a red sphere expanding and fading.

    It at least looks good in my head. Will get on that! Thanks for the idea!


  • F

    @Slydog I did a bunch of digging into this-- you need use "matrix math" to calculate the projection. There's a whole Wikipedia article about it. One article had a painting of a guy from the 18th century or some crazy thing (wish I could find it), drawing a string through a wooden frame, explaining to someone how to do that math-- it was fascinating to me that this concept predates computers by hundreds of years!

    https://en.wikipedia.org/wiki/3D_projection


Log in to reply