Jump to content

  • Log In with Google      Sign In   
  • Create Account

Need algorith to rotate isometric image sprite !


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
10 replies to this topic

#1 greenpig83   Members   -  Reputation: 326

Like
0Likes
Like

Posted 18 February 2014 - 04:54 AM

Hi I'm working with an isometric project. That require me, each unit animation need 8 direction (5 for flipping : E flip to W, NE flip to WE, SE flip to SW!). 

I've found many resource on net that are isometric, but not all 8 direction, some 6 direction (hexa tile game), some only 4...! 

So I think that because its isometric view, we can base on 1 direction and rotate to its closest direction (about 30 degree rotate)!  Of course it will not look nice (because we reverse engine it), but better than unit move to West, but his heads and legs heading NW. 

 

Here is an example of the dragon from MM8! 

This frame it's heading SE (south-East). 

m492Fa1_zps75c1b023.png

 

And this one is what I want to achive, heading E (East)

m492Fa2_zps59c1ab3a.png

 

Normally we lack the East,West direction because in isometric world! But just 1 is enough, because East can be flipped into West! North cant flipped to South...

Thanks! I think I can write my own this but it will take time and need time to make it look nice, so if there are already a solution I dont want to reinvent the wheel!


Edited by greenpig83, 18 February 2014 - 04:58 AM.


Sponsor:

#2 Buckeye   Crossbones+   -  Reputation: 4902

Like
2Likes
Like

Posted 18 February 2014 - 07:36 AM

Post some code showing how you do one or more directions.


Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.


#3 JTippetts   Moderators   -  Reputation: 8490

Like
4Likes
Like

Posted 18 February 2014 - 09:36 AM

I can't think of any real way to perform this rotation on the sprite itself, at least not that wouldn't just look like ass. Typically, you do the rotation when you create the sprite frames during development. For example, if the sprites are created from 3D models you simply set the camera, render, spin the camera, render, and so forth until all facing directions are rendered.

 

Note that using 5 frames and mirroring some of them does work, technically. However, it is a bit of a hack that assumes your characters are symmetrical. ie, look at older Zelda games, and note in particular how Link's sword and shield switch hands when he reverses direction, due to the mirroring. If you pre-render your sprites with accurate lighting, the lighting won't be accurate if you use mirroring either. If you really want it to look nice, I'd avoid mirroring unless hardware constraints force you to.



#4 greenpig83   Members   -  Reputation: 326

Like
0Likes
Like

Posted 18 February 2014 - 09:51 AM

I can't think of any real way to perform this rotation on the sprite itself, at least not that wouldn't just look like ass. Typically, you do the rotation when you create the sprite frames during development. For example, if the sprites are created from 3D models you simply set the camera, render, spin the camera, render, and so forth until all facing directions are rendered.

 

Note that using 5 frames and mirroring some of them does work, technically. However, it is a bit of a hack that assumes your characters are symmetrical. ie, look at older Zelda games, and note in particular how Link's sword and shield switch hands when he reverses direction, due to the mirroring. If you pre-render your sprites with accurate lighting, the lighting won't be accurate if you use mirroring either. If you really want it to look nice, I'd avoid mirroring unless hardware constraints force you to.

Of course I'm using mostly 5 frames and mirroring for my units. Because it saves quite alot (texture memory) and my units are quite small so it does look quite OK. I dont have the 3d mesh so I cant create the dir I want, and I cant afford real artist for my hobby project! The sprites for my project are mostly found on net, I'm not good enough to draw just 1 sad.png I found some very great sprites for my project, but it lacks East,West dir, and to see the cool units running with wrong heading like that, it make me sad sad.png

 

In theory, I think we can do this, because of isometric view, with some matrix for rotating ! Because the rotate angle (30-45 degree) is small and everything is fixed!


Edited by greenpig83, 18 February 2014 - 10:00 AM.


#5 Álvaro   Crossbones+   -  Reputation: 13309

Like
2Likes
Like

Posted 18 February 2014 - 10:36 AM

You think you can take a 2D rendering of a 3D figure and compute a rendering from a different camera angle? How do you think that would work? Do you at least have depth information in the original image?



#6 greenpig83   Members   -  Reputation: 326

Like
0Likes
Like

Posted 18 February 2014 - 10:55 AM

You think you can take a 2D rendering of a 3D figure and compute a rendering from a different camera angle? How do you think that would work? Do you at least have depth information in the original image?

Of course it cant be perfect because we doing reverse here. Just as nice as possible. 

Let see this image : he's runing South_East (Down-Right) ! His spear heading Down-Right. I want to rotate he heading East. It will be about 30 degree! So first we will need to rotate he up, center at his body for example, so that his spear will looking East!

And it will need at least 2 rotation, and some interpolation because of hidden pixels! But as I said, the purpose is looking as good as possible not to recreate the 3d Model!

 

SO I dont want to spend time testing this. I hope someone did this before, so I can use his solution. 

running_zps553258a4.png


Edited by greenpig83, 18 February 2014 - 10:59 AM.


#7 Álvaro   Crossbones+   -  Reputation: 13309

Like
4Likes
Like

Posted 18 February 2014 - 12:22 PM

A solution does not exist, and I'll give you an informal proof. If I only have that last picture to work with, I don't know if the spear is parallel to the ground or if he is holding it in a direction that is very close to the direction of projection and the spear is very very long: Both situations produce the same projection. When the figure is rotated, the two scenarios will look dramatically different.

 

Just get a 3D model that you can render yourself, or get someone else to render more angles for you.



#8 greenpig83   Members   -  Reputation: 326

Like
0Likes
Like

Posted 18 February 2014 - 03:08 PM

Just did a little test with a simple solution. Not rotate the sprite, but move the pixel up! It will need a bit stretch but because the angle is small so it still look OK. 

I will optimize it later. When it run in an animation, it will look better !

 

horse_zpsbbce4221.png



#9 xbattlestation   Members   -  Reputation: 320

Like
0Likes
Like

Posted 18 February 2014 - 07:48 PM

You are trying to generate a side view projection (i.e. east / west facing) from an isometric projection (i.e. south west / south east) projection?  This wont look good with complex objects - try it with your dragon instead of the horse.  There is just too much Z - axis information hidden in the rendered 2D sprite.  I'll admit though that horse example does look ok, if it is only to be used as part of an animation, and not a final state.


Storm Clouds over the Western Front - 2D aerial combat WIP | DarklightXNA on Twitter | 2DFlightSim on Youtube

#10 ankhd   Members   -  Reputation: 1280

Like
0Likes
Like

Posted 20 February 2014 - 12:32 AM

Hi. what I had to do in my 2d rts was take the image of each direction and use that. it sux big time to do.



#11 Carver413   Members   -  Reputation: 157

Like
0Likes
Like

Posted 02 March 2014 - 09:37 AM

there are a number of dragons in Blenderswap, maybe you should check them out






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS