Log in or register to post comments

How To Dynamically Add a 3D Model to a Ground Plane?

March 5, 2018 - 6:22am #1

I'm a beginner and I got ground plane to place one model by keeping a 3D model as a child of the Ground Plane Stage.

But what I'd like to do is dynamically do that through the script to attach a 3D object. Whenever a ground plane is detected, I'd like to place a prefab through a script to the detected ground plane.

The similar functionality is achieved for Image Targets using this script attached to the Image Target. --> https://library.vuforia.com/articles/Solution/Working-with-Vuforia-and-Unity.html#dynamically-add

I'd like to achieve this for Ground Plane.

Thank you! :D

How To Dynamically Add a 3D Model to a Ground Plane?

March 6, 2019 - 10:31am #5

Hello and thank you for this useful post.

I readily admit to being relatively new to Unity and Vuforia, and though familiar with development languages, i don't have the use of the C# with Unity completely understood. When i came across your post, it seemed to be a way to accomplish my goal in putting together a Proof of Concept for an AR app.

My goal is to have a user be able to select a model using a button, which would set the selected model be the active object on the Anchor Stage, place the model one or more times (duplicate set to on), then select a different model and have it become the current Anchor Stage object.

Following your guidance, i created the script and attached it to the button. I get close, but the model isn't selected. So, it is clear i am missing something in the Unity framework.

To be clear, i am not asking for someone else to write the script, but i am asking for some guidance that will help me complete this basic behavior. Any guidance you can offer is most appreciated. I have attached screencaps of my configurations to better explain the scenario.

respectfully,

AttachmentSize
Image icon ButtonConfig.png36.34 KB
Image icon myScript.png53.25 KB
Image icon PlaneFinderConfig.png41.2 KB
Image icon SceneHeirarchy.png27.6 KB

How To Dynamically Add a 3D Model to a Ground Plane?

November 20, 2018 - 8:37pm #4

I'm not sure if it is suit for your condition.

First , you will need to declare a ContentPositioningBehaviour in your script.

And then, a prefab model that you want to change.(The prefab model must be the child of the Ground Plane Stage too)

With these you can just simply access the AnchorStage (which is the model for placement in Vuforia Ground Plane)by:

    ContentPositioningBehaviour.AnchorStage

And my code is below:

    public ContentPositioningBehaviour content;

    public GameObject Model_Prefab;

void create()

{

    content.AnchorStage = Model_Prefab.GetComponent<AnchorBehaviour>();

}

In my case the function "create" is a button On click function that will change the AnchorStage to my PrefabModel.

And then, you need to drag your plane finder object to both plane and content and your prefab to Model_Prefab to get it work.

 

AttachmentSize
Image icon 擷取.PNG149.3 KB

How To Dynamically Add a 3D Model to a Ground Plane?

May 14, 2018 - 8:33am #3

I have the same question. Vuforia Ground Plane example from Unity3D assetstore shows the way to place the AR object in the place where user has tapped on the screen. But I need dynamically add AR objects to the stage. Not on the tap place projected to Ground Plane but at the certain place: i.e. 3 meters forward and 1 meter right from AR Camera.

As I can see from the Vuforia Ground Plane example the AR object is added by ContentPositioningBehaviour.PositionContentAtPlaneAnchor(HitTestResult result) method. There is the documentation page about HitTestResult:

https://library.vuforia.com/content/vuforia-library/en/reference/unity/classVuforia_1_1HitTestResult.html

But there is no class variables description at all. There is no description of public constructor for HitTestResult class. So, I cannot even try to add the object via PositionContentAtPlaneAnchor() with customly configured HitTestResult argument.

Could you please give us the sample of code that dinamically places AR object on Ground Plane.

How To Dynamically Add a 3D Model to a Ground Plane?

April 24, 2018 - 3:14am #2

Im also interested in adding a 3d model to Ground Plane , is this possible using Vuforia ?

Thanks

Log in or register to post comments