Persistant object in ADF - google-project-tango

I am trying to formulate how to create an ADF, drop an object in it, then have that object always be there when I run the app again, after localization occurs, of course. Do I have to save off the locations of virtual objects into a separate file when the user is done "dropping" objects into the scene and then reload them on subsequent runs? Or is there a way to save them into the ADF?

We cannot save objects with ADF, instead while loading ADF, object can be added (after recognition of ADF) to the recognised coordinate.
I did something like this and got it working, but found placed objects oscillating and not get placed exactly on the same place in the subsequent ADF loading. Because whenever Tango connection is established, that location is considered as origin(0,0,0) and objects get placed related to this origin. So it is hard to see those objects exactly on same places.

There's no good way to save it into ADF, unless you hack some of the ADF's meta data. But hacking meta data is not suggested.

I did what you say.
You have to write coordinates of Objects into a separated file then when you reload scene and recognized your room (thanks to the adf), just put back objects at same coords.
Of course every coord (x y z) must refer to the ADF Tango pose -> base = TangoEnums.TangoCoordinateFrameType.TANGO_COORDINATE_FRAME_AREA_DESCRIPTION
On Unity it's very simple, you just have to check to "true" the "Use Area description poses" on your ARCamera tango script and same on your PointCloud script if you use it also.

Related

Copy camera viewpoint using open3d gui

Open3d's easy draw_geometries utility makes it possible to copy & paste camera parameters to restore a certain view point after it has been changed. It seems like this functionality would also be available when using the SceneWidget and its Open3DScene high level scene. However I have not figured out a way to mimic this behavior.
Copying and pasting a viewpoint from draw_geometries onto notepad reveals this information:
boundingbox_max, boundingbox_min, field_of_view, front, lookat, up, zoom
In order for it to have the same effect using the SceneWidget I would have to somehow obtain this information from the scene's camera, create a copy, and then load it later when it is needed. Nevertheless, I cannot access the above properties explicitly through the camera object, nor have I found a way to set them (assuming I already have them).
The next "obvious" solution would be the camera class's copy_from method, which sounds great, except I am unable to instantiate the Camera class in order to use it.
How can I achieve this save & restore viewpoint effect?
Thanks in advance

Monogame Extended Tiled

I'm making an isometric city builder using Monogame Extended and Tiled. I've got everything set-up and now i need to somehow access the specific tiles so i can change them at runtime as the user clicks on a tile to build an object. The problem is, i can't seem to find a "map.GetLayer("Layername").GetTile(x,y) or .SetTile(x,y) function or something similar.
Now what i can do is edit the xml(.tmx) file which has a matrix in it that represents the map and it's drawn tiles. The problem with this is that i need to build the map in the content pipeline again after editing for the changes to be displayed. I can't really build at runtime or can i?
Thanks in advance!
Something like this will get you part way there.
var tileLayer = map.GetLayer<TiledMapTileLayer>("layername");
TiledMapTile tile;
if(tileLayer.TryGetTile(x, y, out tile))
{
// do something with tile
}
However, there's only a limited amount of things you can actually do with the tile once you've got it from the map.
There's no such thing as a SetTile method because changing tile data at runtime is not currently supported. This is a limitation of the renderer, which has been optimized for rendering very large maps by building static geometry that can't be changed once it's loaded into the graphics card.
There has been some discussion about building another renderer that would handle dynamic map changes but at this stage nothing like that has been implemented in the library. You could always have a go at implementing a simple renderer yourself, a really basic one is not as hard as you might think.
An alternative approach to dealing with this kind of problem might be to pre-process the map data before giving it to the renderer. The idea would be to effectively separate the layers of the map that are static from those that are dynamic and render the dynamic tiles as normal sprites. Just a thought, I'm not sure about the details of how this might work.
I plan to eventually revisit the Tiled API in the next major version of MonoGame.Extended. Don't hold your breath, these things can take a lot of time, but I am paying attention to the feedback and kinds of problems people are experiencing with the existing API.
Since the map data is stored in a XML (or csv) file which runs through the Content Pipeline you can not change it at runtime.
Anyways, in a city builder you usually do not change existing tiles but you place object on top of existing tiles.

3D model scn file does not rotate or scale in AR kit

I started a new Xcode project with the ARKit template and simply replaced the "ship.scn" with my "test.scn" filename asset. The object is about 16.5mm wide and 4.8mm tall. The ship worked fine of course, but my test object that reads "test" does not rotate as I move around it, or scale when I move towards or away from it, yet it does track in one location.
I compared the ship and test attribute panels, and I can't find anything that is different about them, except that the ship is textured and my test text is not. What is inherently special about scn objects that would make them behave correctly in ARKit besides their size? I've read through the documentation about anchoring, but it seems like I wouldn't have to do this in code if it's already a scn object.
In case anyone wants to test the file I'm using in the ARKit template to see how it's behaving, the file is here: https://ufile.io/ey49t
I’m answering the question because I think it could help others that are making a similar mistake, but it can be closed if it doesn’t make sense.
The problem is that the size was much too large where I could not see scaling or rotation no matter how much I moved around the room. Compare the scaled size in the last attribute panel on the ship model - not its actual size. Then get the size of your own model scaled down enough so that it is actually resonable.

SceneKit and NSKeyedArchiver

I am trying to archive my SceneKit scene for saving using NSKeyedArchiver. This is so I can save the scene allowing me to restore it at a later date. I am finding that the restored scene seems to ignore/lose the SCNTransformConstraints I have added to various SCNNodes. This results is the nodes being placed in the wrong place.
I am wondering if this is by design or a bug? Or am I doing something wrong?
Any pointers would be appreciated.
SCNTransformConstraints works with a block provided by the client of the API. Blocks can't be archived with NSKeyedArchiver.
You need to archive another object instead that is be able to reconstruct the block and re-assign the transform constraint.

Core Data and image entities

I'm new to Core Data. I'm creating an app that will allow a user to add a document importing/exporting from/to either Dropbox, Mail (haven't figured that out), or the camera or photo library.
I see in CoreDataRecipes that Apple creating an entity for image and have a relationship to recipes. And their PhotoPicker app the camera part is a little ridiculous in my opinion. Cool but not practical. Plus they're not using Core Data.
I just have a table view, an add button at the top, the user will be prompted to choose any of the options mentioned, add a title, and that title added to the table view. Hope all that is clear, I'm trying to be brief. In a way I want to do this part of the app like a scanner app.
So my question is, do I really need to create an entity for the image? Or can I just go about figuring how to do all this?
Thanks in advance for any help or info you can provide.
In my case, I kept the images out of sql store altogether and just saved the images in the application's /Cache folder. I then stored a filename in my entity in core data which allowed me to access the image.
Below 1MB do with it whatever you like. Beyond 1MB you should put the binary data on a separate table. What you get doing this is lazy loading, that is, the data remains at fault until the user needs it. It also depends on your memory usage and number of images, this part is only common sense.

Resources