Log in or register to post comments

Move objects independently

November 26, 2012 - 3:46am #1

Hi everyone,

My situation is that I track a framemarker, and the scene is loaded. Once I touch the screen on my android device, an independent object is created (a bullet) with a force and direction. The thing here is that I do not want the bullet to follow the framemarker movement: if a move up and down the marker, the bullet should follow his own direction, regardless the framemarker movement.

Any ideas? I am really stuck on this.

Move objects independently

November 29, 2012 - 1:40am #7

Hi, a little rectification to my previous answer;

actually, storing the "reference frame" at Firing time (and then describing the motion of the bullet in such reference frame) will produce the same result as describing the bullet motion in Camera reference fram (instead of world reference frame).

The problem with your scenario is that Vuforia provides two reference frames, one is the World as defined by one of your targets, and the other is the Camera reference frame; these two frames are linked to each other by the trackable Pose transformation.

You would need in theory a "third" reference frame, a sort of "static" world reference that never changes, so that both the camera and the target reference frames can be represented with respect to such "static" frame.

So, the only way you can do this is to use 2 Image Targets (or FrameMarkers) instead of one:

- the first Image Target can be used to define the "static" reference frame

- the second Image target can be used to define the "moving target" reference frame (i.e. your moving target); the idea is that so you can move Image Target 2 (which is the target at which you want to shoot your bullet), while keeping the first Image target fixed at some position

 

In Unity + Vuforia, it is then quite easy to setup such scenario, as you just need to change the World Center Mode in the ARCamera game-object

(just click on the ARCamera object and check the World Center Mode property in the Inspector);

By default, this is set to Auto, which means that the World Reference frame will automatically be centered on the First Image Target detected

(so, if you have two image targets, the first one detected defines the World Ref; however, if you loose tracking of such Image Target, then the Worlkd Center will be recentered onto the other target)

So, you will need to set the World Center Mode to "USER"; when you do so, an exra field called "World Center" will appear, and there you can specify which Image target should always be used as World Center.

If you do so, the bullet will move in the world reference of the first target, while you will be able to move around with your hands the second target, achieving (hopefully) the desired effect.

I hope this helps.

 

Move objects independently

November 28, 2012 - 3:05am #6

My mistake...

I am using Unity to create the scenario, the bullet (as a prefab) and so on. I should said that. So this is why I am not sure how to accomplish the solution you gave me.

Once I have all the scenario, the problem is the one I told here: everything is moving accordingly to the framemarker (and now I know why is this happening), but I need like an intermediate step to get to the solution explained here.

I will explain my self clearly next time, sorry.

EDIT: I do not have any problem using Android natively, I am wide open with that. 

Move objects independently

November 28, 2012 - 2:56am #5

So, you are using Unity then ? 

I was assuming you were programming in Android natively. 

Move objects independently

November 27, 2012 - 3:40pm #4

Hello again,

 

I think I understood the thing here, I mean, it is like the "theory" is ok for me, but when you say "store the pose" I know what you mean, but I really do not know where I have to implement it, maybe via Unity Script? or is in the Vuforia SDK? in this case, once I have made the changes, how this is connected to Unity to make senses? I have been searching in the docs to get some ideas, but I can not find nothing that answer my doubts.

Hope you could give me some ideas to start with.

Thanks

Move objects independently

November 26, 2012 - 7:33am #3

Wow...I think I do understand this, I will try as soon as I can. I will post any progress/doubt.

Thank you very much. 

Move objects independently

November 26, 2012 - 6:16am #2

Hi, your problem is about choosing a "world reference" system that fits your expectations:

As you know already, the trackable->getPose() method returns a matrix which represents the target reference frame as seen from the camera point of view.

The usual assumption would be to consider the marker reference frame (as reported via the pose) as the "World" reference frame;

with that assumption, your bullet will move in the world reference frame defined by the target.

To avoid this, you can take one of these two paths:

1. describe the bullet motion in the camera reference frame (this will attach the bullet trajectory to your camera...but maybe this is not what you wish in this case)

OR:

2. store the Pose of the marker at the time when the bullet is created/fired (i.e. save the pose into some global variable for instance), so that the frame marker reference frame AT THAT TIME (bullet creation) is "frozen"; then, this frozen frame will define your World reference frame during all the life-time of your bullet.

So, basically, you set the world reference frame at bulet creation, then the bullet motion occurs in that reference system, instead of following the continuously changing reference frame of the marker (which is changing at every frame).

 

In the OpenGL code, when you redner your bullet, you simply need to use the modelview matrix that was saved at the time of bullet creation;

 

for the marker rendering instead, you can keep using the actual Pose matrix which is updated every frame.

 

I hope this helps.

 

Log in or register to post comments