How can I change hand-rays in my MRTK v2 project for HoloLens 2 to parabolic instead of linear? - unity3d

My HoloLens 2 project has content that is arranged as such I cannot target colliders with the existing hand-rays. I used to target my content with the head-gaze, but with hand-rays being lower on the body it is more difficult to reach the content that I want to select. I believe I would benefit from a parabolic selection ray, similar to those used when teleporting in Mixed Reality to reach surfaces above the participant.
The primary method of interacting with my content would be via a parabolic ray. There are instances within my application where I might change modality to focus on a menu system from close or far, and when I am far I'd like to change to a linear ray. So, having this capability to change the type of ray exposed via code would be preferred.
My project is employing the MRTK v2, and the standard linear hand-rays are functioning.
I would like to be able to change the type of ray being used in the Unity inspector, and to be able to change the style via code during run-time. I'd like to have control over the arc of the ray, as the scale of my content may impact the need for a different arc and min/max distance.

You can modify the DefaultControllerPointer prefab to use a Physical Parabolic Line Data Provider instead of a Bezier Line Data provider. This will distort the line used by the pointer to be more parabolic.
Before:
After:
Note that I removed the pink components and added the green components.
You will also want to increase the line cast resolution of the pointer from 2 to something larger, this means that the ray used to query what you have hit will have higher resolution:
And you may want to increase the resolution of the MR Line Renderer itself.
Demo of parabolic hand pointer:

Related

Unity: skinned mesh vertexbuffer output slightly different than correct results

It’s like this hip is stuck in place, with in the pictures(being at different times in the animation since I can’t upload a gif) the red wireframe is the drawing of the raw output triangles and everything else being default unity, aka the correct output
What am I doing wrong? What am I missing? This has been driving me nuts for 2-3 days now, any help is appreciated
As you do not post any code, I will try to do some guessing over what is going on. Disclamair: I actually happen to run into similar problem myself.
First, you must know that Update's of MonoBehaviour are called in random order (not neccessery random-random, but yous see the point). If you bake mesh in one component, it can still be one-frame late to the Animator component.
There are actually two solution of this case: first is to specify the order of Script Execution Order in Project Settings, while the second is to use LateUpdate instead of Update when updating mesh after skinning.
The second problem you might have run into is scale / position of skinned mesh. Even if it does not contribute at all to the animation movement it can still wreck the mesh baking collision later on.
To fix that make sure that all your SkinnedMeshRenderers objects have Local Position, Local Rotation and Local Scale set in Transform component to identity (0,0,0 for position and rotation, 1,1,1 for scale). If not - reset those values in editor. It will not change animations, but it will change mesh generator.
If both solutions does not work, please describe the problem more thoroughly.

How to automatically create walls of a given height with collisions on the edges of auto generated AR plane in Unity?

I am working on an application that uses horizontal surfaces in AR. I don't have much experience with Unity but I was able to create automatically generated planes with which objects can collide (example: a falling and rolling dice). Unfortunately, sometimes such objects fall outside the plane area and fall into the void.
I would like to create something similar to invisible walls around the detected plane to keep the objects inside the plane.
Plane configuration i am currently using:
Application:
Edges of plane are marked with red line.
I think the term for what you are trying to do is geo-fencing. The easiest example is to put a square around the area your objects are contained where you have four conditions, one for each edge, like if objectX >= edgeX then objectX = edgeX and so forth. To do that in Unity you would probably have to mess with that C# language.

Hololens Spatial Mapping Collision - Mixed Reality Toolkit

I want to put a hologram-poster in AR, on the Hololens 1, on a wall using the Mixed Reality Toolkit. But everytime I try to put a hologram onto the spatial mapping it slides right through it and vanishes behind the spatial mapping.
What did I miss?
My understanding is you are implementing tap-to-place that enables users to move objects and place them on real-world surfaces. And your issue is that when you placing the object, it did not place on the surface as expected.
Usually, in MRTKv2, the Solver would be a good direction to implement tap-to-place.
The SurfaceMagnetism Solver can cast rays to surfaces in the world, and align the object to that surface.
So, you can add SurfaceMagnetism Component to the object and create a script that has two methods, one that turns on the solver when the object is selected and one that turns off the solver while the object is deselected. When you close the solver, the object will stay in the last position.

Drawing a 3D arc and helix in SceneKit

A recent question here made me think of SceneKit again, and I remembered a problem I never solved.
My app displays antenna designs using SK. Most antennas use metal rods and mesh reflectors so I used SCNCylinder for the rods, SCNPlane for the reflector and SCNFloor for the ground. The whole thing took a couple of hours, and I'm utterly noob at 3D.
But some antennas use wires bent into arcs or helixes, and I punted here and made crappy segmented objects using several cylinders end-to-end. It looks ass-tastic.
Ideally I would like a single object that renders the arc or helix with a cylindrical cross section. Basically SCNTorus, but with a start and end angle. This post talks about using a UIBezierPath in SK, but it uses extrude to produce a ribbon-like shape. Is there a way to do something similar but with a cylinder cross section (like a partial SCNTorus)?
I know I can make a custom shape by creating the vertexes (and normals and such) but I'm hoping I missed a simpler solution.
An arc you can do with SCNShape. Start with the technique from my other answer to get an extruded, ribbon-like arc. You'll want to make sure that the part where your path traces back on itself is offset by a distance the same as your extrusion depth, so you end up with a shape that's square in cross section.
To make it circular in cross section, use the chamferProfile property — give it a path that's a quarter circle, and set the chamfer radius equal to half the extrusion depth, and the four quarter-circle chamfers will meet, forming a circular cross section.
A helix is another story. SCNShape takes a planar path — one that varies in only two dimensions — and extrudes it to make a three-dimensional solid. A helix is a path that varies in three dimensions to start with. SceneKit doesn't have anything that describes a shape in such terms, so there's no super simple answer here.
The shader modifier solution #HalMueller alludes to is interesting, but problematic. It's simple to use a modifier at the geometry entry point to make a simple bend — say, offset every y coordinate by some amount, even by an amount that's a function of why. But that's a one-dimensional transform, so you can't use it to wrap a wire around on itself. (It also changes the cross section.) And on top of that, shader modifiers happen on the GPU at render time, so their effects are an illusion: the "real" geometry in SceneKit's model is still a cylinder, so features like hit testing apply to that and not to the transformed geometry.
The best solution to making something like a helix is probably custom geometry — generating your own vertex data (SCNGeometrySource). The math for finding the set of points on a helix is pretty simple if you follow that shape's definition. To wrap a cross section around it, follow the Frenet formulas to create a local coordinate frame at each point on the helix. Then make an index buffer (SCNGeometryElement) to stitch all those points into a surface with triangles or tristrips. (Okay, that's a lot of hand-waving around a deep topic, but a full tutorial is too big for an SO answer. This should be enough of a breadcrumb to get started, though...)
Here are some starting points that might help.
One approach would be to use more cylinders and make them shorter. That's the same idea behind the various segmentCount properties on the SCNGeometry primitives. Can we see a screenshot of the current linked cylinders version?
If you increase the heightSegmentCount, you could use the approach outlined here: scenekit, how to bend an object.
I just took a look at SCNShape. I was thinking you could use a shader modifier to warp the extruded shape into a circular cross section. But SCNShape doesn't seem to expose a segment count property, which I think you'd need to create enough extrusion segments for a good look. The chamferRadius and chamferProfile properties look interesting. I wonder if you could use those to create an extrusion that looks good.

Tile Grid Data storage for 3D Space in Unity

This question is (mostly) game engine independent but I have been unable to find a good answer.
I'm creating a turn-based tile game in 3D space using Unity. The levels will have slopes, occasional non-planar geometry, depressions, tunnels, stairs etc. Each level is static/handcrafted so tiles should never move. I need a good way to keep track of tile-specific variables for static levels and i'd like to verify if my approaches make sense.
My ideas are:
Create 2 Meshes - 1 is the complex game world, the second is a reference mesh overlay that will have minimal geometry; it will not be rendered and will only be used for the tiles. I would then Overlay the two and use the 2nd mesh as a grid reference.
Hard-code the tiles for each level. While tedious it will work as a brute force approach. I would, however, like to avoid this since it's not very easy to deal with visually.
Workaround approach - Convert the 3d to 2D textures and only use 1 mesh.
"Project" a plane down onto the level and record height/slope to minimize complexity. Also not ideal.
Create individual tile objects for each tile manually (non-rendered). Easiest solution i could think of.
Now for the Unity3D specific question:
Does unity allow selecting and assigning individual Verts/Triangles/Squares of a mesh and adding componenets, scripts, or variables to those selections; for example, selecting 1 square in the 10x10 unity plane and telling unity the square of that plane now has a new boolean attached to it? This question mostly refers to idea #1 above, where i would use a reference mesh for positional and variable information that were directly assigned to the mesh. I have a feeling that if i do choose to have a reference mesh, i'd need to have the tiles be individual objects, snap them in place using the reference, then attach relevant scripts to those tiles.
I have found a ton of excellent resources (like http://www-cs-students.stanford.edu/~amitp/gameprog.html) on tile generation (mostly procedural), i'm a bit stuck on the basics due to being new to unity and im not looking for procedural design.