0

I'm building augmented reality app for android and I'm using jMonkey as my 3D engine. I want to do simple thing. Move object from left side of screen to right (X axis) by changing the azimuth of view (I got it from compass). I can calculate where the object is (rendered object has gps location) so I can say am I looking directly or maybe it is on the left or right. Now my problem is smooth move and calculate the change for local translation. My questions are: 1. how can I calculate position in local translation for the object based on azimuth thay I have 2. how make the change of local translation smooth. Now when I change the value from (for example) -4 to -1 the Spatial jumps. I would like to move it smoothly. I've tried to use Cinematic but either it is not for that or I'm not using it properly

About the calculating I've tried something like this

(objectAzimuth - azimuthWhereIlook) / offset

where offset is the scrope of X axis for example if my scope is <-20, 20> the offset is 40

the diffrence

 (objectAzimuth - azimuthWhereIlook)

is a proper way of checking where the object is according to two azimuth (I have strong math for that and I've this is working. Based on that I know where the object is (directly, on left, on right). So I have the point where the object should be on screen but I don't know how to cast it on X axis

Fixus
  • 4,631
  • 10
  • 38
  • 67
  • not sure if i get what you're trying to do. but can't you just rotate the camera instead of moving the objects around? – 1000ml May 31 '15 at 07:18
  • @1000ml - hi. why do you think that rotation is better aproach ? even so it still won't solve the problem cause I need to combine rotation and positions of both objects (user and 3D obejct that is rendered) so I still need to translate position to internal position – Fixus Jun 01 '15 at 08:08
  • 1
    Generally I prefer to build a 3D scene like it is in reality: Create a mapping of GPS coordinates to 'ingame' coordinates and place the objects where they belong. Then link the rotation of the smartphone to the rotation of the virtual avatar (the camera). The Modelview Transformation takes care of combining all the positions etc. This makes the scene more logical especially when working with multiple objects. After all, that's the reason we're using scenegraphs. – 1000ml Jun 02 '15 at 08:42
  • thanks for update. I'm working and I will work only with one spatial. I have rotation (when I move around gps location) i rotate object in X axis. But when I move forward/backward to the side I'm changing the local translation of spatial. I've added MotionPath and it started to work preaty nice. Do you thinkt is bat solution ? – Fixus Jun 02 '15 at 08:54
  • 1
    In your question you don't describe your original problem so it's hard to say anything about it. What's the purpose of the displayed object? How often does it change it's position? Do you need the smoothing just for a nice animation or are you maybe trying to get rid of jitter from the compass input? Anyway, I'm glad you found your solution. I still recommend you to look into jME's Custom Controls that are a good way to implement spatial behaviour: [link](http://wiki.jmonkeyengine.org/doku.php/jme3:advanced:custom_controls) – 1000ml Jun 02 '15 at 08:54
  • Thanks for your advices. I will look at the problem from diffrent point of view :) – Fixus Jun 02 '15 at 08:58

0 Answers0