For an academy project I have to find parts of a object (location / angle relative to the object ). The object is marked with a QR-code.
Currently I'm stuck on the basics. I scanned a room and load this room with "Spatial Object Mesh Observer".
But this observer gives no relevant information:
The observer does not attempt to find 3D model LODs when sending the meshes to the application.
Someone a hint where I could start?
Scanned Room with a box ( object to find ):
var observer = CoreServices.GetSpatialAwarenessSystemDataProvider<IMixedRealitySpatialAwarenessMeshObserver>();
// Loop through all known Meshes
foreach (SpatialAwarenessMeshObject meshObject in observer.Meshes.Values)
{
Mesh mesh = meshObject.Filter.mesh;
var vertices = mesh.vertices;
// mesh.vertexCount -> 15978
// mesh.vertices -> empty
// mesh.triangles -> empty
// Do something with the Mesh object
}
Edit: 29.04.2021
Unity: Unity 2019.4.21f1
MRTK: 2.6.1
Everything seems to be loaded correctly and the triangles are recognized in an external tool.
However, this information is not available in Unity.
From our understanding, you can't obtain the vertices and triangles property of Spatial Mesh at the runtime. So, we try to make some modifications based on the SpatialAwarenessMeshDemo scene (Assets/MRTK/Examples/Demos/SpatialAwareness/Scenes) to reproduce this issue. We added the following code to the ToggleObservers() method and made it to be invoked when the sphere is clicked.
var observer = CoreServices.GetSpatialAwarenessSystemDataProvider<IMixedRealitySpatialAwarenessMeshObserver>();
foreach (SpatialAwarenessMeshObject meshObject in observer.Meshes.Values)
{
Mesh mesh = meshObject.Filter.mesh;
Debug.Log(mesh.vertexCount);
Debug.Log(mesh.vertices);
Debug.Log(mesh.triangles);
}
After our test, everything works well both in the HoloLens2 Device and Unity Holographic Remoting, it always outputs the expected value. So we recommend that you check for updates in Settings to see If there is a system update available for HoloLens 2. Then follow our steps to make a simple test to see if that works. This may help you locate the problem in your project.
I moved the code to "void OnBecameVisible()", now the information are available
I'm trying to load a mesh with scripts to replace another mesh. I'm not doing a Unity project but rather a visual studio project with unity references.
My code for loading the asset bundle and getting the mesh is:
var vshojoBundle = AssetBundle.LoadFromFile("vshojo");
if (vshojoBundle == null) meshNames.Add("bundle not read");
GameObject silverObject = vshojoBundle.LoadAsset("SilverAssets.obj");
MeshFilter silverNewMesh = silverObject.GetComponent<MeshFilter>();
meshNames.Add(silverNewMesh.mesh.name);
MeshNames is just a list that later gets written in a log file to help me figure out things. When trying to get the name of the mesh in the last line, I get the following error: NullReferenceExpection: System.NullReferenceException: Object reference not set to an instance of an Object. The same exception occurs if I don't use that line to write on log and skip to the mesh replacement, when I replace the mesh I get the same error.
In the script
difference() {
polyhedron(
points=[[0,0,0],
[2,0,0],
[2,1,0],
[0,1,0],
[0,0,2],
[0,1,2]],
faces=[[0,1,2,3],
[5,4,1,2],
[5,4,0,3],
[0,1,4],
[2,3,5]]);
cube([1,1,1]);
};
the polyhedron alone works fine (is rendered without warnings), but adding the cube above causes the warning WARNING: Object may not be a valid 2-manifold and may need repair! to be logged and the output to only render some parts of some surfaces.
I'm using OpenSCAD 2015.03-1 on Ubuntu 16.04.
This is because your polyhedron has some faces pointing into the wrong direction, causing issues when calculating the difference().
See the Manual and FAQ for details.
Changing the winding order of the affected polygons fixes the polyhedron:
difference() {
polyhedron(
points=[[0,0,0],
[2,0,0],
[2,1,0],
[0,1,0],
[0,0,2],
[0,1,2]],
faces=[[0,1,2,3],
[2,1,4,5],
[5,4,0,3],
[0,4,1],
[2,5,3]]);
cube([1,1,1]);
};
The difference is still non-manifold as cutting the cube results in 2 prism shaped objects just touching at one edge. That's also by definition not 2-manifold, so the warning remains.
Depending on how the exported model is supposed to be used, you could choose to ignore this warning and hope the tool processing the 3d model can handle that.
To remove the issue, for example the cube could be made a bit smaller like cube([1, 1, 0.999]).
An unrelated, but still useful strategy for preventing issues later on is to always make the cutting object a bit larger to ensure that no very thin planes remain, e.g. use cube([2,3,1.999], center = true). That will also remove the display artifacts in preview mode.
I am trying to clip many vector layers to a boundary by following the tutorial at http://www.qgistutorials.com/en/docs/batch_processing.html
ie using Clip in the Processing Toolbox, then 'execute as batch process'. However, I recieve an error message -
Algorithm Clip starting...
'NoneType' object has no attribute 'pendingFields'
but I don't know what that message means or how to fix it. Thanks for any help
EDIT: in the end I clipped the layers one by one through the 'Geoprocessing - Clip' menu. That worked, so now I suppose the issue is with the batch processing command rather than the shapefiles themselves.
I think the problem is that bash didn't get the target layer.
I get the similar error when I run reprojection.
before the input layer was "A layer", the input is a string.
then I redo select from open layers. the quotation mark disappear.
it works for me.
I've had the same problem. I solved it by using layers from file system instead of opened layers.
This is not very convenient but it can help !
I'm working on a game in Unity where a sprite is imported using Resources.Load(), and as expected, the memory increases.
But the problem is, I can't seem to figure out how to free the memory.
I know I need to use Resources.UnloadUnusedAssets(), but even when I remove every reference to the sprite that I can think of, the memory doesn't go back down.
Here's my code right now:
Loading the sprite (works fine):
map = Resources.Load <Sprite> ("Map7");
spRend = this.GetComponent<SpriteRenderer>();
spRend.sprite = map;
Unloading the sprite (memory isn't freed):
spRend.sprite = null;
map = null;
Resources.UnloadUnusedAssets();
UPDATE:
After further research, I found this on the Unity wiki:
When not used anymore, you can free the memory it took up by calling Object.Destroy on the object, followed by Resources.UnloadUnusedAssets
But the problem is when I try to destroy 'map', I get the following error:
Destroying assets is not permitted to avoid data loss.
If you really want to remove an asset use DestroyImmediate (theObject, true);