I'm developing a game in Android and Java. In android I am using andengine for sprite image and i was able to rotate in all directions.
int bikeFrame:
//bikeFrame++,bikeFrame--
bikeSprite.setRotation(bikeFrame);
I want to make the game in j2me also. But in j2me we have only four methods to rotate angle
(TRANS_MIRROR,TRANS_MIRROR 90,TRANS_MIRROR 270,TRANS_MIRROR 180)..
If i take images as frames I am still not getting smooth animation.
How to rotate sprite image in all angles in j2me?
See this thread, omarhassan123 created a code snippet that should allow you to rotate the image by any angle you like.
There is a library called J2ME ARMY KNIFE that provides all sorts of image manipulation techniques, you can get it here.
Also, see this question:
Image rotation algorithm
Another idea: decompile a game called Flexis Extreme. They do a lot of image rotation in real time so you could try to find out how they did it.
If you can, try LWUIT Image.rotate there is a sample at this page http://lwuit.blogspot.com.br/2008/11/round-round-infinite-progress-and.html
Related
I am trying to implement something like the technique described in this (old) paper to use the phone camera's video frames to create an illusion of environment mapping in an AR app.
I want to take the camera frame, divide it into sub-areas and then use those as faces on the cube map. The division of the camera frame would look something like this:
Now the X area is easy, I can use glCopyTexImage2D to copy that square area to my cubemap texture. But I need help with the trapezoid shaped areas around X (forget about the trianlges for now).
How can I take those trapezoidal areas and distort them into square textures? I think I need the opposite transformation of the later occurring perspective projection, so that the two will cancel each other out in the final render if I render the cubemap as a skybox around my camera (does that explain what I want?).
Before doing this I tried a simpler step of putting the square X area on every side of the cubemap just to see if glCopyTexImage2D can even be used for this. It can, but the results are not rotated right, some faces are "upside down" when I render the cubemap as a skybox. The question is similar: How can I rotate them before using them as textures?
I also thought about solving the problem from the other side and modifying the "texture coordinates" to make the necessary adjustments, but that also does not seem easy since the lookup in the fragment shader with "textureCube" is more complicated than a normal texture lookup.
Any ideas?
I'm trying to do this in my AR app on Android with OpenGL ES 2.0 but I guess more general OpenGL advice might also be useful.
Update
I have come to the conclusion that this is not worth pursuing anymore. The paper makes it look nice, but my experiments with a phone camera have shown a major contradiction. If you want to reflect the environment in an object rendered in AR, the camera view is very limited. When the camera is far away from the tracked object you have enough environment information for a good reflection, but you will barely see it because the camera is far away. But when you bring the camera closer to see the awesome reflection in detail, the tracked object will fill most of the camera's field of view and you barely have any environment to reflect anymore. So in either case you lose and the result is not worth the effort.
It seems that you need to create mesh with UV mapping described in article and render it with texture from camera to another texture. Then use it as cubemap.
I have an image. i want it to spin/flip 360 degree continuously. All the tutorials i m referring are of rotating image 360 on a 2D axis.
I tried using the rotate animation from android but it has same problem of rotating around a point but not 3D spin or flip.
Thanks
What you are describing sounds very similar to a card flip (google android documentation). Bare in mind that you need to think about what is on the opposite side of the image (for your specific use case) if you are going to implement that.
I've just learned about the capabilities of libGDX in terms of animation. I know how to use the texture packer,read atlases to be used animation, and use the animation class.
I use Adobe Flash to create animations and export them into PNG sequences then use the texture packer. But it fails when there are too many images to be converted. I tested it by using 80 images(600X600). I was trying to rotate a big magic circle.
My question is, what are the other methods to create animation? What is the best way to create PNG Sequences?
EDIT: I used the TexturePacker-Gui:
http://www.aurelienribon.com/blog/2012/06/texturepacker-gui-support-for-multiple-packs/
and was able to pack my sprites into an atlas..Clicking 'Pack Selected' instead of 'Pack Em All' did the trick (maybe a bug for the program). And rotating that magic circle by sprite animation was a big mistake. The only question that remains is if there is any better way to create animation other than using Flash?
I have some tool form create spritesheet.
I didnt use this one
libgdx-texturepacker-gui, maybe you can try.
I am using this Texture Packer
If you want to just rotate something you don't need animation. You can create a Sprite using only one image and then do something like sprite.rotate(...);
I'm making an android game using andengine. I'm makin some sprites as object, where I can rotate sprite. But when I touch transparent part of image still it rotates the sprite.
To prevent this, I need to get Bitmap from Sprite. So can anyone provide method for that, by using that I can convert sprite to Bitmap.
I looked into this link.But in this it was using GLES1, but I'm working with GLES2.
bitmap for sprite follow this link for more
If you have not see this, there is a GLES2 version of Pixel-perfect collision. Its an android extension called "Andengine Collision Extension"
https://github.com/MakersF/AndEngineCollisionsExtension
It should handle the case you are describing.
NOTE: You have to modify you copy of the Andengine source code to use the extension.
What I'm trying to do is have a background image, for sake of simplicity, lets say it's a picture of the front of a house. Then, I want to have a red ball move from window to window.
**I want to have a background picture, and a picture on top of it.
**I then want to be able to tell the top picture EXACTLY where to go.
How can I do this?
I'm just beginning to learn about animations in Android, and have not yet run across any way to do this.
There are two routes to animation in android: Canvas and OpenGL ES.
I would recommend OpenGL for anything requiring smoothness and speed, like a moving ball.
You should create a view using the helper class GLSurfaceView
http://android-developers.blogspot.com/2009/04/introducing-glsurfaceview.html, and implement a Renderer.
I assume you have the images saved in your res/drawable folders, in a format like png and the ball file contains an alpha channel.
You can see many tutorials online, but basically you need to load your background image and your ball resource at onSurfaceCreated and store it in a texture using GLUtils.texImage2D.
In the onDrawFrame method, you should set up a 2D projection such as glOrtho2D, then draw the background.
Then just before you draw the ball texture, you can use the glTranslate(x,y,0) function to move the ball over the house. Use an alpha blend for the ball:
glBlendFunc(GL_SRC_ALPHA, GL_SRC_ONE_MINUS_ALPHA);
glEnable(GL_BLEND);
Unfortunately writing in OpenGL isn't as straightforward as you might hope. Everything is done with 3D coordinates, despite the fact you want only a 2D image. But hopefully this gives you enough info to google for good exmaples, which are abundant!