How to Create Complex Android Animation - java

I've been surfing the web for android animation, and all what I found was the XML ones (transition,scale,...) but these simple functions cannot create complex animation. So how can I do so?
For example, I want "fireworks" in my application, so how I can animate it?
Thanks in advance.

For something like that you'll need a pixel or vertex shader, written in opengl. There is a small example here on how to load one: Shader for Android OpenGL ES
But I'll guess you'll find more if you google Android pixel shaders or something like that. Do you have any concrete questions? What are you going to do?

Related

Android Physics-Based Smooth Velocity Change Animation example code

I am trying to implement a physics-based translation animation similar to the shown in the Android docs. I need a smooth change in velocity exactly same as in the example below. I searched online docs and tutorials but no way to find the shown example. Could you give sample android java or kotlin code to generate this smooth velocity change animation? I have tried FlingAnimation and SpringAnimation.
What you're looking for is time interpolation (or easing interpolation). You can create animations with different interpolators that can replicate real motion, for example a bouncing ball.
The animation you provided most likely is using a DecelerateInterpolator.
There're many interpolators and you can also create your own. There are plenty tutorials on how to implement them.
See example:
Some xml based animations
Bounce animation example (programatically)

Animate a cube turning via mathematics (Java)

For a school project i have made a program that can solve a rubiks cube (you know, that cube with all the colors). But now my teachers asked if i could do some research and try out 3d animation for one of the sides. But they want to see the mathematical way to do it. I have found a way to move the corners with the use of polar coordinates. But i do not know how i could render a cube in 3d and be able to animate it.
So my question is: how can i render things like a cube in 3d (or are there any good libraries for it) and how could i use these polar coordinates to animate it?
And is there a good tutorial out there for java 3d rendering?
i must say that i have absolutely no experience with 3d rendering, so it might be a bit difficult. But i really would like to try it out.
thanks in advance
Depending on whether you want to take an existing implementation or if you want to build code for 3D animations from scratch, you might try this tutorial. Graphics programming in this area can be quite involved; a full answer of the question is beyond the scope of this site. However, there are a few main areas.
Usage of vector math for transformation of objects (translation, rotation). This can be done directly or via projective geometry using 4-by-4 matrices. The latter is easier for concatenation of transformations.
Backface culling to remove faces of the object which cannot be seen by the camera.
Using a projection and a camera model to transform 3D coordinates to 2D coordinates.
Using a rasterizer to render the 3D vector information to the screen. Here Bresenham's algorithm might be a good start.
I would suggest you look at one of the 3D libraries. One that I've used a lot and found to be excellent is JMonkeyEngine (JME) which is designed for games but would work well for your needs. It also has an excellent tutorial that takes you from basic to very complex. In fact the first step in the tutorial is a revolving coloured cube!
JME takes a huge amount of the work out of 3D modelling. You build a scene in code with materials, lights etc. and JME does all the work to render it. You can even build your models in a tool such as Blender so you don't even need to do the modelling in code. But I will warn you that using modelling tools is definitely not for the faint hearted.

What is a simple way of drawing sprites without OpenGL?

We are developing simple arcade game for android now and we are interested in adding some visual effects to it. Like disappearing or appearing animation and so on. Is there a simple way to do it without OpenGL for example just using some improvements to ImageView?
You could use the BitmapFactory and Bitmap Class to perform simple manipulations on images. Check out the http://developer.android.com/reference/android/graphics/Bitmap.html for what you can do with this class. It supports simple stuff like reloading, fading out, creating ScaledMaps and manipulating images on the screen on basic level.
For some simple instructions and examples see:
http://developer.android.com/guide/topics/graphics/index.html
http://www.anddev.org/resize_and_rotate_image_-_example-t621.html
Chapter 6 in "Android Developers cookbook" : http://www.informit.com/store/product.aspx?isbn=0321741234

2D OpenGL Canvas Replacement

I've created a prototype for a 2d android game using the android canvas object. Unfortunately, the performance is suffering greatly due to the large number of bitmaps that need to be redrawn frequently.
I'd like to migrate the drawing code to opengl, but I have no experience with it, and I'm having a difficult time getting the views configured properly. I've tried a wide variety of methods, but I'm not sure if the view configurations were wrong, of if the drawing functions didn't match.
Since most of my touch events are based on the coordinates, I'd like to have the opengl canvas view's coordinate system match the touch event coordinate system if possible. This would allow me to reuse a lot of code and avoid a lot of coordinate translation.
Can someone provide code or a link to code that would accomplish setting up a view and drawing a textured element?
I do not know how this question got overlooked but if you want a light introduction to OpenGL ES then you should take a look here. It is pretty good an explains things slowly enough that it is reasonably easy to understand.

Java/Graphics: Plotting 3d coordinates?

I'm coding a programm, that will produce 3d coordinates for a rocket and I would like to do a rudimentally graphic output for this.
it just has to be scaleable and rotationable, so that you can change the view manually.
the postions should be connected by lines and
it ould be nice to have spheres for earth and moon ( and perhaps addtional celestial objects).
I think, there should be some ready stuff for this kind of plott already available, but I couldn't find one.
So that's why I'm here to ask you, if you know such a thing.
and if there isn't I would kike to ask you how a bignner like me should start this?
I ust coded for console apllications, because there was no need for a real graphics output.
thank you in advance for any tip! :)
Andreas
I don't think there are sand-box ready things you can use to draw customizable 3d objects in Java, if you can live without strange things you can you just a graph library able to draw 3d graphs like for example jMathTools (link).. otherwise you should go into J3D with opengl and similar things.
I don't think they exist just because doing simple things is trivial if you work with OpenGL or similar APIs..
Doing what you need with OpenGL is not complex at all, just a GL_LINE_STRIP to draw the trajectory and some primitives if you need earth, moon and so on.. rotating and scaling come implicitly moving the camera of your viewport..
Take a look at: Java3D or JOGL
I can't believe nobody has mentioned this yet, but the NASA WorldWind project seems like exactly what you need: http://worldwind.arc.nasa.gov/java/ You can extend it with JOGL if needed, or you can use some of the vast modeling objects already available to mark trajectory and location in 3D coordinates, complete with zooming/rotating and the like. Having accurate Earth layers is nice as well =)
Use JOGL! It is easy to install, and if you know Java it should be easy. There are a few things in JOGL that require you to be decent in trigonometry. This tutorial might help you get started: http://www.youtube.com/watch?v=rT02jFYrXv0

Categories