Jump to content
  • Advertisement
  • entries
  • comments
  • views

Cool trails

Sign in to follow this  


Ship now has a cool fire-trail thingy while accelerating. Looks quite nice in motion.

Actually, the main bulk of tonights work has been implementing texture atlasing for all the non-map-block images. I wasn't comfortable with loading a seperate texture for every object, particle and so on, so now have a system for dynamically atlasing bitmaps onto a big texture at runtime.

I've sussed out the problem I had with large texture atlases and rotation when writing Udo.

Trick seems to be to add 0.5f to both the generated texture co-ordinates AND the vertex co-ordinates of the quad. This appears to make the sampling pixel perfect at any rotation.

So when I generate and store texture co-ordinates for each loaded image, I add 0.5f to them, and when I generate the vector of vertices that stores each object's basic image information, I again just add 0.5f.

When an object is created, a vector of six vertices defining a quad is defined, relative to the object's centre.

When rendering, this vector is first copied to a temporary vector, then the temporary vector has its Us and Vs assigned based on the image index (to allow for per-frame animation). At this point the vertices are still relative to the object's centre, so it is trivial to rotate them by the object's angle, before just translating them by the object's position.

There is then a global translate-rotate based on the player ship's position handled by my GraphicsDevice's RenderTriangle* methods, and finally a translate to move the origin to the centre of the screen.

The next major issue is to start to tidy up the code, since a lot of the current code is very temporary, just to make sure everything was going to work out how I wanted.
Sign in to follow this  


Recommended Comments

There are no comments to display.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!