Is it possible to change the positions of the corners of an SCNPlane? Or do I have to make a custom plane to change the positions of its vertices?
EDIT:
So i have a SCNPlane or a custom created plane, and i want to atleast print the coordinates of the vertices that the plane has.
For simple effects, you can effectively change the plane's corners by using the plane's transform matrix. You can do more complex effects with a shader modifier (see SCNShadable) or a morpher (see SCNMorpher). What effect are you trying to achieve?
Related
I am trying to mirror a mesh to another mesh by using procedural mesh generation as seen below. The original mesh is at the positive z axis while the mirrored is at the negative z axis.
The vertices are all mirrored as I wanted but the color is facing down instead of up.
I tried to change the mesh uvs and normals but both did no affect on the mirrored mesh. I heard the triangles have to be reversed in their array or something that I do not understand. How do I make the mirrored mesh color face up?
The black plane is supposed to be half transparent blue water plane but it is not part of my question so I guess do not mind it.
Not 100% sure but I suspect it is the triangles as you say.
You would probably simply need to invert the triangles => simply invert the array e.g. using Array.Reverse like e.g.
var triangles = mirroredMesh.triangles;
Array.Reverse(triangles);
mirroredMesh.triangles = triangles;
I'm pretty new to shader graph and shaders in general. I'm working on a 2D project and I'm trying to make a shader that rotates an arrow to make a flow-like material and use it on a sprite shape.
Basically what I want to do is make a proper version of this:
What I'm currently doing is multiplying the Y position of the position node by an exposed vector 1 and using it in Rotate node (which I know is pretty hacky and won't work if the shape is not an arc.)
Aligning UV with arbitrary mesh seems bit hard. Why not bend pre-made mesh instead? Graph below bends vertex positions around axis Z at given point and strength (0 makes mesh invisible tho), but, you can easily replace that Position node with UV and plug results into Sample Texture 2D. I just guess bending a mesh will give you better/easier results.
Create a subdivided and well UV-mapped rectangle plane
Bend that plane with a vertex shader (attached graph bends around Z axis)
graph is based on code from Blender source
TLDR: Can't figure out the correct Shader Graph setup for using UV and vertex displacement to cheaply animate a (unrigged) mesh.
I am trying to rotate a part of the mesh based on the UV coordinates, e.g: fromX 0 toX 0.4, fromY 0 toY 0.6. The mesh is created uv-mapped with this in mind.
I have no problem getting the affected vertices in this area. Problem is that I want to rotate these verts for customizable axis e.g. axis(X:1, Y:0, Z:1) using a weight so that the rotation takes place around a pivoted point. I want the bottom selection to stay connected to the rest of the mesh while the other affected vertices neatly rotate around this point.
The weight can be painted by using split UV channels as seen in the picture:
I multiply the weighted area with a rotation node to rotate it.
And I add that to the negative multiplied position (the rest of the verts, excluding the rotated area) to get the final output displacement.
But the rotated mesh is bent. I need it to be stiff as in the whole part rotated with weight=1 except for the very pivoting vertex.
I can get it as described using a weight=1 based rotation, but the pivot point becomes the center of the mesh, not the desired point.
How can I do this correctly?
Been at it for days, please help :')
I started using Unity about a month ago, and this is one of the first issues I faced.
The node you are using will always transform the vertices around the origin.
I think you have two options available:
Translate the vertices by the offset of where you want to rotate the wings. This would require storing the pivot point of the wings in the mesh somehow - This could done by utilizing a spare UV channel, or by using the vertex color channel.
Use bones and paint the weights in your chosen 3D package. This way, you can record the animation, and use Unity's skinned mesh shader to render it.
Hope that helps.
Try this:
I've used the UV ranges from your example applied to a sphere of unit size. The spheres original pivot is in the centre, and its adjusted pivot is shifted 0.5 on the Y axis.
The only variable the shader doesn't know, is the adjusted pivot position; so I pass this through the material.
I've not implemented your weight in the graph, as I just wanted to show you the process. You can easily plug that in.
The color output is just being used for debug purposes.
The first image is with the default object pivot.
The second image is with the adjusted pivot.
The final image is the graph. (Note the logic group is driving the vertex rotation based on the UV mask).
I have a set of control point pairs. One part of the pair is in world coordinates (3D). The other one is in pixel corrdinates of the image (2D).
My goal is to transform a surface you can see in this image onto a flat plane. The problem is that the surface is not perfectly flat, it kinda looks like a ribbon. Otherwise I could have used OpenCV's getPerspectiveTransform() or Matlab's fitgeotrans().
I know that I can use OpenCV's solvePnP() or Matlab's estimateWorldCameraPose() to get the pose of the camera. The camera matrix is known and the image is rectified. But what is the next step then? How can I transform my ribbon shaped surface onto a flat plane, i.e. get an orthographic top view? That is the step, I'm stuck on.
Assume you have a large array of Vector3 points. These points were plotted by hand by the player when asked to draw a 2d shape (i.e. a 2d triangle) in a 3-dimentional environment (drawing 2d shapes with htc vive controller in a virtual environment).
I would like to project these points on to a plane to 'flatten' the shape they drew. To do this properly I need to know the average plane they're sitting on so that there is minimal 'squishing/distorting' when projecting them on to it.
Basically, I want to ask them to draw any 2D Shape in the air (which won't be 2D because humans) rotated any way they want and convert that shape into a 2d picture with a known plane for further manipulation.
If you would like to know more specifics I would be happy to provide them.