Rotating sprites

Started by Wretched, Thu 29/09/2005 15:07:48

Previous topic - Next topic

Wretched

Well I was bored last night waiting an upload to finish and wrote a rotating sprite module. I know it's a bit redundant as the next version supports them, but you never know, someone might want it.

Rotation demo

If anyone wants all the bits and pieces let me know, I'm afraid I don't really have the time to work much on it, or maintain it, but am happy to hand over what there is.

Kweepa

Interesting - does it draw the sprites pixel by pixel?
Nice movement!
Still waiting for Purity of the Surf II

Wretched

Yeah, only way(?), draws two triangles per pixel, and can scale and stretch in X & Y relative to rotation.

Kweepa

It's an interesting technique and could certainly be useful for more complex transformations than pure rotation. For example, for perspective correct texturing without resorting to plugins.

Shame that the textures need to be processed into "arse" files :) I suppose one could read bmps or pcxs instead using script.

That must have been a big upload!
Still waiting for Purity of the Surf II

GarageGothic

Steve, I wonder if you could be persuaded to turn some of the Allegro sprite deformation commands used in the AGS3D plugin, into an actual DynamicSprite-deformation plugin? If it's even possible to read/write DynamicSprites from a plugin.


Kweepa

Quote from: GarageGothic on Thu 29/09/2005 19:42:13
Steve, I wonder if you could be persuaded to turn some of the Allegro sprite deformation commands used in the AGS3D plugin, into an actual DynamicSprite-deformation plugin?
What exactly do you need? I could put something simple together - for example
Code: ags
int Transform(int sprite, float heading, float pitch, float bank, float z);

would return a sprite that could be drawn centred on the old sprite centre.
Or:
Code: ags

void StartTransform(int sprite);
void SetCorner(float x, float y, float z); // call this four times
int EndTransform();

would return a sprite that fit closely around the four corners.

Quote
If it's even possible to read/write DynamicSprites from a plugin.
Yes, I think so.

Sorry for hijacking your thread, Wretched.
Still waiting for Purity of the Surf II

GarageGothic

Steve, I've been trying to look into the different kinds of sprite transformation, and I must admit that I still don't really understand the concepts. What exactly does the z coodinate in your second example do?

When I asked, I imagined something like the Distort function in photoshop, where you simple move the coordinates for the corners of a previously rectangular sprite. But perhaps there are more factors than these needed for correct perspective transformation?

Kweepa

Quote from: GarageGothic on Sun 02/10/2005 23:13:04
What exactly does the z coodinate in your second example do?
That's so that the texture can be stretched in a non-linear way over the sprite. If you imagine being close to a wall and looking down it, the pixels near you are much wider than the pixels further away. The scale of the pixels depends on this z value.

Quote
When I asked, I imagined something like the Distort function in photoshop, where you simple move the coordinates for the corners of a previously rectangular sprite. But perhaps there are more factors than these needed for correct perspective transformation?
I think there's a "perspective" distort in Photoshop, which (I'm guessing) estimates the z values. If you have a rectangular sprite and you just make the right hand side shorter then you can guess good values for z. It's much harder if the four corners are arbitrarily moved - as far as I know there's not necessarily an exact solution.
Still waiting for Purity of the Surf II

GarageGothic

Thanks for the clarification. So where would you get the z value from? I've pretty much been doing the perspective calculations for my module using the same techniques as you would when drawing projection in 2D. Would I need some kind of 3D calculations to get the z value?

Kweepa

Quote from: GarageGothic on Sun 02/10/2005 23:32:56
Would I need some kind of 3D calculations to get the z value?
Yes, that's normally how it's done. I'd have to see/understand how you're doing your 2d calculations - there might be some way to pull the z value out from those.
Still waiting for Purity of the Surf II

GarageGothic

#10
Hmm, I'm not quite sure, but I might have been thinking about the wrong scaling factor. I'll have to take a look at my code. It could be that the only sprite deformation made now is for the shadow being projected onto the wall.

At one time I had a script for finding the vanishing point, and another for reconstruction the perspective by GetScalingAt at different points of the screen. But currently those are commented out. Let me get back to you when I'd had a chance to go over my module. And probably by PM rather than flooding Wretched's thread :)

Edit: I just remembered, or rather, I checked where the perspective scaling comes from. Turns out that I'm using some hokey value based around a simple Maths.Sin of a user-defined camera angle. Well, it made sense at the time :)

SMF spam blocked by CleanTalk