Start a new topic

Draw several 3D objects with a single AR.Positionable within C++ plugin

Dear,

We are trying to position several AR.positionables using as a basis the C++ plugin “MarkerTrackerPlugin” provided with the SDK.

Inside the “updatePositionables” function in the cpp file, the view, world and projection matrix of a single AR.Positionable, instantiated in the javascript file, can be set:

it->second->setWorldMatrix(identity.get());
it->second->setViewMatrix(modelViewMatrix.get());
it->second->setProjectionMatrix(_projectionMatrix.get());

In the javascript file we have added a second AR:Positionable and we are able to get the corresponding iterator inside the c++ class

    createOverlays: function createOverlaysFn() {
        var carModel = new AR.Model(
            "assets/car.wt3", {
                scale: {x: 0.01, y: 0.01, z: 0.01 },
                translate: { x: 0.0, y: 0.0, z: 0.0 },
                rotate: { x: 0, y: 0, z: 0 }
            });

        World.positionable = new AR.Positionable("myPositionable", {
            drawables: { cam: carModel }
        });

        World.positionable_2 = new AR.Positionable("myPositionable_2", {
            drawables: { cam: carModel }
        });
    }
std::unordered_map<std::string, wikitude::sdk_core::impl::PositionableWrapper*>::const_iterator it = positionables_.find("myPositionable");
std::unordered_map<std::string, wikitude::sdk_core::impl::PositionableWrapper*>::const_iterator it_2 = positionables_.find("myPositionable_2");

it->second->setWorldMatrix(identity.get());
it->second->setViewMatrix(modelViewMatrix.get());
it->second->setProjectionMatrix(_projectionMatrix.get());

it_2->second->setWorldMatrix(identity.get());
it_2->second->setViewMatrix(modelViewMatrix_2.get());
it_2->second->setProjectionMatrix(_projectionMatrix.get());

However, we are not able to change the position of the two Positionables independently by changing their ViewMatrix (we use two different but similar ViewMatrix) because we always see one single object (the two are overlapped ¿?) as it seems that the ViewMatrix is shared between the two objects. Are we doing something wrong or missing something?


Our final goal is to use the matrix provided by Aruco to position different objects in different locations related to this unique matrix. Is there a way in which this can be done?

Many thanks in advance

Best rewars,

Javier

cpp
js
(965 Bytes)

Dear Andreas Schacherbauer:


We are glad to hear about it and we would be deligthed to try the new API. I would like to point out that last time I forgot to mention that we are developing for the Epson BT-200.


At the same time, I would want to ask yout if there is any way in which we could get the position of the camera from either the javascript or the c++ plugin. Thank you in advance for enligthening us.


We are looking forward to hearing from you,

Javier Román

Hi Javier,

It might be that you're running into an issue that we discovered and fixed a couple of weeks ago. This will be part of the next release which will be publicly available beginning of 2019 (if everything continuous as planned). This update contains some breaking changes for plugin developer but you get much more flexibility with those changes. I would like to give you early access but the documentation for the new plugin changes are not yet documented. Please let me know if you're up for a little experiment with those new APIs ;)


Best regards,
Andreas Schacherbauer


Hi Javier,

Sorry for my late response. The Epson support is delayed for the new SDK update. Would it still be helpful for you to try a current development build of the SDK that does not run on Epson glasses?


The new C++ plugin API will give you information about the camera position. In general the SDK would start with the back camera if you don't change this in the startup configuration, so you could also keep track of if yourself in the JS API.


Best regards,
Andreas Schacherbauer

Hi Andreas:


Thank you for the reply. We would be glad to try the standard Android SDK.


However, we are still trying to figure out how to get the position of a given recognized  ImageTarget with the JS API. Could you enlighten us on how to get the translation and rotation of the device's camera related to a target once it has been detected?


As far as we know, the ImageTrackable class has the onImageRecognized event where the related ImageTarget is passed as an argument. The ImageTarget has two methods (getRotationTo, getTranslationTo) that return the translation/rotation to other target but as a number instead of a matrix, which is bit annoying. Moreover, the traslation/rotation of the target has to be calculated with regard to other detected target (we want the raw position, the one realted to the camera ). Is there a better way to get the transformation matrix realted to the camera? Are we missing something?


Finally, we have a quick question about the SDU unit used to position drawables. We want to make sure that the conversion between the SDU unit and e.g. milimeters is as easy as multiplying by the height of the target in milimeters.


Many thanks in advance,

Javier

Hi Javier,

Finally you can download an Android build here.


Regarding the transformation you're asking for: This information is not available in the JS API. It's not what it was build for. You have those kind of information available in the Native API SDK, Unity or plugins (Plugins are also available for the JS API SDK). I guess plugin's is the way to go for you if you want to use the JS API SDK. You get all known targets for one frame as parameter to the `update` method and they contain all matrices needed to do such calculations. Other plugin examples included in our example app demonstrate how to use them to render augmentations (advanced custom camera). You could also have a look at our Native API SDK's as the information given there is the same as for plugins.


Regarding SDU's: They usually work in meters. Just be aware of the dynamic adoption based on the distance. But this is something you can turn off.


Best regards,
Andreas Schacherbauer

Login or Signup to post a comment