how to get coordinates of imageview after rotate animation in android? - android-animation

I'm very new to android. I'm developing a train game. In the game i am using Translate Animation to move horizontally and RotateAnimation to rotate my train. The problem is I'm unable to get the coordinates of the while it is moving or rotating.
For example : At game starting my train is at (0,0).Then I rotated it by 90 degrees.
Train=new ImageView(this);
Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.train);
BitmapDrawable bmd = new BitmapDrawable(bmp);
Train.setImageDrawable(bmd);
RotateAnimation r=new RotateAnimation(0,90,70,30);
r.setDuration(2000);
r.setFillAfter(true);
Train.startAnimation(r);
Now I want to get the coordinates of the train programatically at the end of animation.
I'm searching for this in Google from two weeks. Till now I didnt find any solution.
Is there a way to find coordinates or not?

Use AnimationListener to object of RotateAnimation class
and in onAnimationEnd method of the listener try to use Use View.getLocationOnScreen() and/or getLocationInWindow() method

Related

How to make 3d text to appear on camera view in blender

I am creating a 3d text on blender2.8 but I am having a hard time trying to make it appear on the camera view.
I have tried rotating and scaling the camera but it doesn't help.
The camera object is the focal point for the final image, like in real life, if you want to get more in the picture you need to move the camera back or zoom out.
With the camera close -
With the camera far away -
To zoom out, you reduce the camera's focal length.

LibGDX - Orthographic camera translation and rotation

I'm making a 2D top-down game in LibGDX, using orthographic camera. The camera is supposed to follow player, rotate with him etc. I'm also using Box2D, which means every sprite is updated by model coordinates and angle. And I want to make the same with the camera.
This code:
Vector3 v = new Vector3(playerModel.getPosition().x, playerModel.getPosition().y, 0);
camera.rotateAround(v, Vector3.Z, -playerModel.getAngle() * MathUtils.radiansToDegrees);
camera.translate(deltaMove);
camera.update();
gives me only relative translation and rotation - relative to current position and angle of the camera. And although this works I don't think It's the best, is it?:
Vector3 v = new Vector3(playerModel.getPosition().x, playerModel.getPosition().y, 0);
camera.up.x = (float) Math.cos(playerModel.getAngle());
camera.up.y = (float) Math.sin(playerModel.getAngle());
camera.position.x = v.x;
camera.position.y = v.y;
camera.update();
Is it possible to do it smoother way with orthographic camera or should I use a classis 3D camera?
You can remove the jerky movements of the camera by interpolating the current frame's camera properties between the last camera properties and the new camera properties. Camera movements are very jerky if you don't use some kind of interpolation.
I hope this helps, I would go into how to implement such such a change, but it seems a bit beyond the scope of this question.

Three.js: Camera Collision on Terrain

How should I go about adding camera collision to a terrain in three.js.
The terrain is from 'mrdoob's three.js' examples and is randomly generated and I am currently converting it to height map.
I am thinking of implementing the collision as follows:
Create a 'box' object around the camera
If the box object is not touching the terrain, move the camera down.
If the box object IS touching the terrain, keep the Y axis of the camera.
How should I go about doing this?
The theory is that you send a ray from the location you are (camera position) straight down. You find the intersection point and based on the distance you decide what to do. Implementation wise I cannot help you but THREE.Ray should help you.

Simple polygon texture mapping / iOS / cocos2d

I got some problems with opengl and cocos2d. I suck with opengl i know. I was trying to find just a simple answer but no luck.
What I'm trying to do is to map a texture like this:
... so i got points
CGPoint points[4];
points[0] = ccp(x1,y1);
points[1] = ccp(x2,y2);
points[2] = ccp(x3,y3);
points[3] = ccp(x4,y4);
Whats next :( ?
All I want to do is map that texture on that polygon.
I will show it in "idiot" way :)
Firstly I would design the texture with the bottom horizontal and then rotate the sprite at the end, as this makes it a whole lot easier.
I would load the texture into a UIImage. Then use CGContexts to remove the triangular portions in the top corners.
Then load that UIImage into a CCTexture2D which I would then create a sprite from. Then rotate the sprite, so that it is at the required orientation.
Alternatively, if you don't need the texture to be generated programmatically you could just remove the corners from the texture, using gimp, photoshop or pixelmator. Then just load that texture the same way you would load any other.

how to get the custom projection matrix of UIImagePickerController 's camera

I use UIImagePickerController as camera. Now I want to integrate with ogre 3d render to make an ar application. Does someone know how to get the custom projection matrix of UIImagePickerController.
I convert cameracontroller.cameraviewtransform to a matrix. and the view matrix I just convert 2dar affinetransform to transform3d.
but it doesn't work.
Worse comes to worst, you can generate the projection transform from what you know about the camera, which is primarily just the FOV angle. Things like the orientation and location of the camera in an AR application are simply offsets from whatever your defaults are, and this data can be retrieved from the gyro and accelerometer.