Start a new topic

Unity plug-in 1.2.1 - 3D Tracking - Set up for multiple objects?

Unity plug-in 1.2.1 - 3D Tracking - Set up for multiple objects?


Hi David,

You can send an email at support wikitude.com and I will answer any further questions there.

Recarding the physics issue, raycasting should work, it's just collisions and rigidbodies that might have issues.

Best regards,
Alexandru

Hey Alex,

Yes I can go into more detail - could I private message or email you with our use case? I skyped with Nicola in the past with a different issue and it was very helpful - maybe we could do the same to get on the same page. Let me know what would work for you. 

 

Also, the physics incompatibility may pose a big issue with our use case, as users need to be able to drag objects around after the tracker is recognized, which relies on physics/rigidbodys to do the raycasting & placement math. It would be very helpful to discuss this with you.

Hi David,

Physics might not behave as you expect in the current implementation, because the augmentation is moved and rotated to fit the target. So if you are using gravity, "down" might not be where you expect it to be, and things might not be rendered because they've flown off the screen. Even if you implement your own gravity that takes this into acount, physics will probably be very unstable because of translation applied to the augmentation. I'll do some tests, but I don't expect this to work properly at the moment. Could you provide more info about the scenario you are trying to implement? We are aware that the current setup is not ideal and we're looking into ways to improve it.

Best regards,
Alexandru

Hey Alex,

 

I've implemented the method you mentioned above and was having issues with multiple models displaying - I found out it's because I have Rigidbody components on the other models in the Container gameobject. Further, I tested and it seems that if 'Use Gravity' is ticked, the model will not display properly at all. Do you know a solution to this?

 

Will be testing instantiation with your method in the next couple days and post how it goes.

Yes, if the list of models is dynamic, the last solution is not feasable.

In the screenshot below is the Hierarchy, as I would see it for your use case. The "Container" GameObject will contain the "ToggleTrackable" script and it will have no children at first. When the user adds a new object, you instantiate the appropriate prefab and add it as a child to this "Container" GameObject. If you look at the "ToggleTrackable" script, you will see that it will activate itself when the target is recognized, so all children GameObjects will also be toggled. When you need to remove an object, just delete the prefab that you instantiated. Keep in mind that the "ToggleTrackable" script is just an example and can be modified however you need, or replaced with something more appropriate for your case. The important part is that the events from "Trackable" are linked to something.

Really appreciate the responses. I will give this a test, but this method worries me - a user would be dynamically adding prefabs to the Trackable and I don't know which ones the user will add. They will also need to be destroyed at some point (not just turned off - as it would kill memory to keep them all in the scene). 

Do you think this would be possible or would it cause issues?

Hey Alexandru,

 

Thanks again for the reply. Since I'm experiencing issues testing with 3D tracking (posted another thread, it says "Unlicensed Feature Used" and freezes), I'm testing a simple Wikitude use for now and running into an issue.

 

How do you display multiple prefabs/objects at the same time? Just using one map. I have my prefabs under the 'Trackable' parent, and only the first is displayed. The others (different prefabs) that should be displaying right next to the 1st prefab don't appear. 

They need to display simultaneously - I won't be toggling them on or off to allow only 1 at a time - I need to show many different prefabs at one time. I tried putting them all in an empty gameobject under the Trackable parent and that isn't working either. 

Edit: Also tried to create multiple 'Trackable' objects with each prefab seperated, and it still doesn't work. My main Trackable object will display then the other two are very small and just float around arbitrary to the marker. They should all be the same size. 

Thank you!

Hi,

On the Trackable behaviour, you will notice that there are two events "OnEnterFieldOfVision" and "OnExitFieldOfVision". These are linked to trigger the appropriate methods on the "ToggleTrackable" script in the child GameObject. If you have multiple models that need to be enabled the easiest solution would be to add them as children to this object, called "WikitudeEye" in the sample, instead of directly to the "Trackable" GameObject. If I understood your setup correctly, you have multiple GameObjects as children to the "Trackable" GameObject, but the Trackable behaviour is set up to trigger only the first one. You can also add multiple scripts to be called in the events themselves, but if you have a lot of models, that might not be ideal.

Best regards, 
Alexandru

Hi David, 

From what I can understand, you will be working with a single 3D map. If so, there is no need to recreate the tracker / trackable objects. It's just the child object of the trackable that needs to be changed, and that can be done at runtime without any restrictions. In the sample app, the Load3DTracker instantiates a client tracker and a trackable. If you take a look at the trackable prefab, named "WikitudePipesTrackable", you will see that there is a child object named "Pipes", that has a "ToggleTrackable" script attached to it. This scipt is responsible for toggling on and off the actual model beneath it, called "polySurface1". The script could also change the model with another one at runtime, without the need to recreate the tracker and trackable each time. It should be pretty similar with what you were doing before, where the "Trackable" didn't change, only the prefab beneath it.

Best regards, 

Alexandru

Hey Alexandru,

 

I've been doing some testing with the tips you provided, and am having an issue with this part you mentioned in particular:

"Keep in mind that you cannot add or replace trackables after the parent tracker has been created. If you need to change the trackable at runtime, you need to recreate the parent tracker as well. The "Load3DTracker" function does this for you and can be called multiple times with different trackable prefabs."

 

I'm working on a program that allows you to instantiate a number of trackables (up to the user to choose what and how many via an object library), move them around, scale them, etc., and remove certain trackables if they choose. Think of it similar to the Ikea furniture AR app if you've seen that, for furniture choices in a home. Because they would be instantiating potentially a large number of trackables - and it's up to user input to choose which will be displayed when, would the parent tracker have to be recreated every single time? If so, do you have any tips I can work off of to handle this efficiently?

 

I came from using a SLAM AR system (Pointcloud by 13th Labs, no longer around) and my system has prefab clones instantiated at runtime as a child of the "Trackable" scene root parent based on user input. Could this be accomplished similarly with Wikitude and if not, are there any plans to allow that functionality? It's crucial to how our app operates. 

Awesome! Thank you for the quick reply.

Hi,

The Client3DTrackingController is part of the sample, not the plugin, and is provided only as an example of what can be done. It can be changed or replaced in whatever way you want. You can change the model that is displayed at runtime in a number of ways.

For example, if you look at the prefab that is assigned to "Trackable Prefab", named "WikitudePipesTrackable", you will see that it has a child GameObject named "Pipes" that has a script on it named "ToggleTrackable". This script responds to messages from the TrackableBehavior and controls the visibility of the model that is being displayed. It can be extended to also change the model that is displayed.

Or, you could have a list of prefabs in the controller itself and instantiate the one you want when you load the 3D tracker. The "Load3DTracker" function in the controller script could have a parameter that indicates which prefab to instantiate, instead of using the "TrackablePrefab" variable directly. Keep in mind that you cannot add or replace trackables after the parent tracker has been created. If you need to change the trackable at runtime, you need to recreate the parent tracker as well. The "Load3DTracker" function does this for you and can be called multiple times with different trackable prefabs.

You can also take a look at our documentation and reference for more information

Best regards, 
Alexandru

Got the new 1.2.1 Wikitude Unity plug-in upgrade & it looks like its features have been expanded (woohoo!), but out of the box, I may run into some usability issues with it. 

 

Currently the 3D Tracking sample scene shows a 'Controller' gameobject with the 'Client3DTrackingController' script, and as a public variable, you can assign a 'Trackable Prefab' object to display during 3D tracking. But what if I wanted to use 3D tracking for multiple 3D objects that are displayed based on user input (i.e. dragging them into the scene)?

 

The set-up for regular tracking/extended tracking in the prior version worked fine - with the parent Client Tracker > Trackable child > Prefabs heirarchy, so I could instantiate different prefabs as the child of the 'Trackable' object. 

 

Would this still work with 3D Tracking and how?
Login or Signup to post a comment