• entries
743
1924
• views
581016

Rotations

111 views

I've decided that the next really cool thing that would add a dimension to my game without involving loads of artwork is to take advantage of Direct3D rotations.

I just want to be able to rotate quads in 2D flat on the screen.

My understanding is that all I have to do is leave the texture co-ords as they are and translate the actual screen quad co-ordinates and D3D will do the rest, hopefully in hardware and very quick.

Now, I reckon that because I am submitting loads of quads in a single vertex buffer for efficiency, I'm going to have to manually rotate the corners of the quad with sine and cosine.

That's not a problem, but if anyone knows a D3D way of doing this, bearing in mind that I need a load of quads, all rotated at different angles or not rotated at all in the same vertex buffer to pass to DrawIndexedPrimitive, please let me know.

I think this will be a great addition to my sprite library and will mean I can think about adding in a spin attack for Udo, sort of like a cross between Sonic's jump and Mario's attack from above move for bashing boxes, as well as maybe make enemies spin as they die and fall off the screen.

Also a good way to liven up stuff like the checkpoint pickup, which would probably look ace if it was spinning on its z axis as it bounced up and down.

And best of all, does not require drawing any more sprites to get the various effects, which suits me fine.

Really I'd like to learn to use something like Blender, so I could model my graphics in 3D then take snapshots to make sprites from, but I reckon that would take a long time to learn. Might download it tonight and have a look.

On an unrelated note, something else I've been thinking about is that I should add into the library a system for having a global "faded" value for the diffuse colour of each quad.

At the moment, all code passing quads to the QuadBuffer is peppered with stuff like:

int C=Item->GetColor()-(255-GlobalFader.Value());Qu.Add(X,Y,Rect,rgb(C,C,C));

where rgb ensures that its args stay within 0-255.

If the quad buffer maintained a current global value for the diffuse colour, the above would only have to be calculated inside the Add method, and I could then just add quads without specifying a colour (defaults to solid white) if they are never individually diffuse faded, or just specify the diffuse for a quad as if the screen was being rendered at full brightness.

Fading the screen in and out would then not affect the calls to render individual items, since they would be called as if the screen was at full brightness. Obvioulsy if I want to exclude some quads from the screen fade in and out, it would be simple to write some calls to override this.

Making the screen fade in and out would then just be a question of updating the buffer's global diffuse value.

Seems like quite a good idea really.

There are no comments to display.

Create an account

Register a new account