Animating a character
Hi I am creating a simple game and I want to animate my character in a top view. I have my image drawn at high resolution and now i need to create multiple images rotated at 45 degrees scaled down and optimised. I have tried to do the images one at a time and decided that was time consuming if i have to do more characters late on. Next i thought of tiling the images into one large picture, and scaling that and optimising in one go. But this still seems imprecise and time consuming. Do you know an easy way this can be done? Perhaps there is a script for photoshop that can do this? Or some other software? Thanks for your advice, Regards, Martin.
As I understood your question, you want to draw an animated character that can be rotated each 45 degrees ?. Then you shouldn't calculate it but draw the rotated images out side the program and load it into an array of textures instead. In run-time, you just simply choose which texture to draw. That's the principle concept of animated sprites.
--> The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones <--
I have one still image and i want to animate the character by rotating the image by 45 degrees. But later on i will have more than one such image that i will want to rotate. So i am looking for a way of automating the rotation process. Also i am scaling the image so i want to automate the scaling as well.
The best i came up with was to place that image and all it's rotations into a single image. Then export that image scaled into a single scaled image and chop it up when i load the image in the game.
But i am thinking that this process could be done automatically for me somehow by some tool or a script.
Martin.
The best i came up with was to place that image and all it's rotations into a single image. Then export that image scaled into a single scaled image and chop it up when i load the image in the game.
But i am thinking that this process could be done automatically for me somehow by some tool or a script.
Martin.
The algorimth for this is kinda simple, I think there's no tool outside ready for your need.
There's some assumings here:
1. You draw the animated character using indexed vertices and triangle strip, so you will need 4 vertices for each image.
2. Your character's image is square, then the center of your character is the center of that square.
1-------------2
| |
| |
| C | Here's the vertices order of the drawing primitives.
| | n = 0
| |
0-------------3
The character rotates "n" degree (where "n" is 0, 45, 90, 135...)
Your original code: X and Y take some values only depend on character's center.
Vertices[0] = {m_CenterX - ImageWidth, m_CenterY - ImageHeight, ...}
Vertices[1] = {m_CenterX - ImageWidth, m_CenterY + ImageHeight, ...}
and so on Vertices[2] and [3]...
Your new code (hope it should be :) ):
Vertices[0] = {(m_CenterX - ImageWidth) * cos (n) + ImageWidth, (m_CenterX - ImageHeight) * sin (n) + ImageHeight}
so on with Vertices[1] --> [3].
Sorry in advance if my code isn't clear enough for you, I didn't implement it and I don't know how to add pictures to the post. But I think this would 'open' something useful.
Of course sin and cosin is computationally expensive, you can use a look-up table or EVEN pre-calculated values - because these values is constant for faster speed.
A minor drawback: The rotated image can 'somehow' be distort. You can use anti-aliasing feature for this.
There's some assumings here:
1. You draw the animated character using indexed vertices and triangle strip, so you will need 4 vertices for each image.
2. Your character's image is square, then the center of your character is the center of that square.
1-------------2
| |
| |
| C | Here's the vertices order of the drawing primitives.
| | n = 0
| |
0-------------3
The character rotates "n" degree (where "n" is 0, 45, 90, 135...)
Your original code: X and Y take some values only depend on character's center.
Vertices[0] = {m_CenterX - ImageWidth, m_CenterY - ImageHeight, ...}
Vertices[1] = {m_CenterX - ImageWidth, m_CenterY + ImageHeight, ...}
and so on Vertices[2] and [3]...
Your new code (hope it should be :) ):
Vertices[0] = {(m_CenterX - ImageWidth) * cos (n) + ImageWidth, (m_CenterX - ImageHeight) * sin (n) + ImageHeight}
so on with Vertices[1] --> [3].
Sorry in advance if my code isn't clear enough for you, I didn't implement it and I don't know how to add pictures to the post. But I think this would 'open' something useful.
Of course sin and cosin is computationally expensive, you can use a look-up table or EVEN pre-calculated values - because these values is constant for faster speed.
A minor drawback: The rotated image can 'somehow' be distort. You can use anti-aliasing feature for this.
--> The great thing about Object Oriented code is that it can make small, simple problems look like large, complex ones <--
You are right. There would be distortion on the 45 degree rotation for example. For this reason I have decided to rotate the images at higher resolution and only then scale the images.
However I think I have found a partial solution. I am using actual 3D model in 3ds max so all i have to do is to rotate the camera above the model. 3D max can actually save images at designated times so that i get multiple images that way and it's automated. If i want an isometric view i can just change the angle of the camera and rotate it about the character.
Not perfect or completely automated, but i think it will have to do.
Cheers and thanks for your help, Martin.
However I think I have found a partial solution. I am using actual 3D model in 3ds max so all i have to do is to rotate the camera above the model. 3D max can actually save images at designated times so that i get multiple images that way and it's automated. If i want an isometric view i can just change the angle of the camera and rotate it about the character.
Not perfect or completely automated, but i think it will have to do.
Cheers and thanks for your help, Martin.
Also, perhaps if you rotate it from a single point of view each time it won't change its x and y.
I do know that if you continue to rotate an image from a previous rotated angle, it begins to change the pivot-point. So, rotating it, undoing that rotation, then rotating 90 degrees, undoing, rotating 135 degrees, and so on should fix that problem.
I do know that if you continue to rotate an image from a previous rotated angle, it begins to change the pivot-point. So, rotating it, undoing that rotation, then rotating 90 degrees, undoing, rotating 135 degrees, and so on should fix that problem.
Maybe i'm completely missing the point, but cant you just set up some macro's in photoshop? I've missed the point haven't I?
------ ----- ---- --- -- -Export-Games.com is searching for talented and friendly developers. Visit our Help Wanted post for more info!My Indie development uber Journal - A game production walk through.
Quote:
Original post by DogCity
Maybe i'm completely missing the point, but cant you just set up some macro's in photoshop? I've missed the point haven't I?
No you didn't. That is exactly what i was thinking but i don't know how to do that. However i have experimented with 3ds max and discovered that the whole process can be automated without even writing any code. Only the images are perhaps bit too large (ie. not optimised for internet).
Well, you can do everything using photoshop macro's including exporting however you like, and it realy is easy to learn, so... BAM
------ ----- ---- --- -- -Export-Games.com is searching for talented and friendly developers. Visit our Help Wanted post for more info!My Indie development uber Journal - A game production walk through.
This is great, i will have to have a look into this soon. For now I am going to push with my mini game for the browser that I am working on using java applets.
By the way DogCity, if you want I can send u my resumae. It is not an exact match for a Technical Director and I am kind of bussy right now with my own little creation, but you never know when I could be usefull to ya. I do have 5.5 yrs of C++ under the belt and 6 months of java on top of that.
Cheers, Martin.
By the way DogCity, if you want I can send u my resumae. It is not an exact match for a Technical Director and I am kind of bussy right now with my own little creation, but you never know when I could be usefull to ya. I do have 5.5 yrs of C++ under the belt and 6 months of java on top of that.
Cheers, Martin.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement