Questions in topic: "geometry"
http://answers.unity.com/questions/topics/single/1488.html
The latest questions for the topic "geometry"Probuilder Fill hole Issue
http://answers.unity.com/questions/1792861/probuilder-fill-hole-issue.html
I am pretty new to using Probuilder and am having an issue with filling a hole in my mesh. It seems like a simple hole (its literally a one-sided/faced rectangle) and I can not for the life of me figure out what is going on. The second image shows the edges I have selected and the setting for the hole. I tried doing the fill for the entire hole and turning that off as well to see if it made any difference. Every time I click fill hole the edges get deselected and nothing gets filled. Am I missing something simple?
Thanks in advance.3dgeometryfillWed, 02 Dec 2020 00:33:32 GMTrekameGet closest point on 2D perimeter using Bounds
http://answers.unity.com/questions/1787626/get-closest-point-on-2d-perimeter-using-bounds.html
I'm using the [Bounds.ClosestPoint][1] to get the closest point on bounds but when inside the bounds you just get the current spot but I want to keep getting a point on the perimeter.
Can anyone throw me the calculations for that?
[1]: https://docs.unity3d.com/ScriptReference/Bounds.ClosestPoint.html2ddistanceboundspointgeometryWed, 11 Nov 2020 10:57:01 GMTPlayCreativelyUsing raycast to sonify point cloud data and geometry of shapes
http://answers.unity.com/questions/1787484/using-raycast-to-sonify-point-cloud-data-of-shapes.html
Hello community,
I am working with the blind and the visually impaired to assist with object identification.
I am looking for development advice for the best approach to sonify shapes with accuracy using sound in a 3D unity scene at runtime.
I have been using existing datasets of simple objects and also iPad Pro and have seen the geometry mesh and point cloud information that can be captured. I am really interested in the communities opinion of how sonification of this data could be approached. I have a procedural and spatial audio background but am struggling with getting the dataset/data to a usable format for audio implementation.
I have looked into volumetric audio, however surfaces don’t have great definition with this method and if blindfolded you could not detect that object shape or detail of edges.
I feel as though a raycast, focused, almost an audio scrubbing method, from FPS view then spatialised would possibly be the best approach, although I want to know your thoughts, I am unsure dev wise how to implement this. Would be great to scan through the point cloud or geometry data and extrapolate it so that I could use those parameters to drive sound. I have attempted to draw this https://share.icloud.com/photos/0o81uJF3vmaz6YM5vOm-efzzQ
I would need to leverage the raw point cloud data or geometry to sonify, I am just really unsure on this and would appreciate any advice on this.
This video is unique but is actually quite interesting in terms of approach, if a user/player had control of this it would be an interesting way for a blind person to inspect a complicated object. https://vimeo.com/195054847
I would want to start with boxes and spheres first and the consideration of someone moving round the object needs consideration also.
Thanks in advance
RraycastaudioruntimedatageometryTue, 10 Nov 2020 21:13:56 GMTRich_XRGenerate 3d Mesh from 2d drawing
http://answers.unity.com/questions/1783977/generate-3d-mesh-from-2d-drawing.html
Hello guys, I try to make a mechanic like in "Draw Climber", the most important thing is creating 3d mesh with collider by 2d drawing on grid from player, for example you draw a circle - and it spawns a 3d sircle with collider. I thought about spawning mutiple cubes like pixels to build some shape, but how to controll it via c#?
I tried to find a solution, but there is only one and It's not for free. From where should I start?gridalgorithm3d modelgeometryalgebraTue, 27 Oct 2020 17:41:38 GMTunity_lSXJSIZAvqe3QwTestPlanesAABB Does not work when looking up.
http://answers.unity.com/questions/1781467/testplanesaabb-does-not-work-when-looking-up.html
In the following simple setup, TestPlanesAABB claims the cube is visible when it is very clearly not. ![alt text][1]
[1]: /storage/temp/169444-screen-shot-2020-10-18-at-32817-pm.png
Steps to recreate:
Camera at (0,0,0) pointing at (-50, 0, 0) (pointing at the sky).
Cube at (0,-2,0) with scale (1, 1, 10) (below the camera).
This [example script from the unity documentation](https://docs.unity3d.com/ScriptReference/GeometryUtility.TestPlanesAABB.html) attached to the cube claims that the cube is visible, when it is very clearly not.
Playing around I notice some strange behaviors like when I change the FOV to be >61 it works, but <=61 it doesn't. It detects the cube at angles -50 and -60, but not at -40 or -70 for some reason.cameracolliderplaneboundsgeometrySun, 18 Oct 2020 22:38:36 GMTluchris429Problems building animation with completely scripted objects - everything is pink!
http://answers.unity.com/questions/1779126/problems-building-animation-with-completely-script.html
Hi.
I'm making an animation for an artist, converting to Unity after 10 years of ActionScript.
It's purely code, there are no assets or materials at all, I use vertices on the fly to create shapes and then colour cycle them.
I'm using UniversalRenderPipelineAsset, and when I run the code, the shapes get a 'Lit (instance)' of shader Universal Render Pipeline/Lit.
![alt text][1]
Works as expected in the editor, but when I build, I just get the default pink for the colours.
Can someone help - I'm thinking of re-making the whole thing in Phaser!!
I obviously need to tell it what I'm using for the build, but can't figure it out.
Here's what I tried:
- Adding a material 'Lit' to a material folder in my assets
- Added all the 'UI/Lit/' options to Always Included Shaders in the Graphics settings
- Checked 'Keep All' in Shader Stripping Instancing Variants
- Little bit of crying.
Thanks.
[1]: /storage/temp/168987-capture.jpgbuild settingspipelinegeometryvertex shadergeometry shaderSat, 10 Oct 2020 19:12:07 GMTFlusteredLondonAdjustable mesh geometry,Create a mesh with adjustable geometry
http://answers.unity.com/questions/1771171/adjustable-mesh-geometrycreate-a-mesh-with-adjusta.html
Hi all!
I am looking to create a game where you can ride a bike through various levels, such as a skatepark.
I would like to make the bike geometry user adjustable (ex. change frame size, wheel size, headtube angle, etc) from some kind of "Bike Creator" menu, kind of like a Character Creator menu. This means that once you create your bike, the geometry is set and couldn't be changed from in level.
I am currently investigating creating a model in Blender and using Bones to define the bike geometry. However I'm not sure if that is the right approach because my understanding is that is usually used for animation.
I am having a tough time figuring out how to accomplish this, and could use some high level guidance to point me in the right direction.
I would appreciate any pointers or tips to set me on my way. Thanks!meshgeometrybikeadjustWed, 16 Sep 2020 19:54:44 GMTnickcamps92Fit in squares in a dedicated space
http://answers.unity.com/questions/1764863/fit-in-squares-in-a-dedicated-space.html
A random number between 2 and 100, What I want to do is;
create a number of squares(doesn't have to be, any shape is ok) that will fit accordingly inside the dedicated
space for them(let's say half of the screen, etc).
if the number is 2, create two squares that are half the space size big.
if the number is 10, create 10 squares 1/10 space size big.
maximum squares per rows and columns are 10...
Example:
![alt text][1]
**How can I achieve something like this, any tutorial or idea?**
[1]: /storage/temp/166126-squares.png2dgraphicsmathgeometrySun, 23 Aug 2020 16:58:04 GMTZozeRHelp with implementing a wall climbing mechanic like botw?
http://answers.unity.com/questions/1761468/help-with-implementing-a-wall-climbing-mechanic-li.html
So I have recently been doing research into how to implement dynamic wall climbing similar to Conan exiles and BOTW. My system as of now uses a raycast to get the direction of a geometry's normal, and I make the player face that. I send another raycast in the direction of the players input, which gets takes the hit point, and lerps the player to that ray's hit position on the geometry. Although this system works well on a flat wall it struggles a lot on complex geometry such as a bumpy cliff, and constantly hangs on small edges. I recently saw this [video][1] from a cancelled game that seems to implement some sort of navmesh by making a flat plane that follows the terrains normals. This allows the player to climb over gaps and complex geometry as if it was a smooth surface. I don't completely understand how they managed this, and I was wondering if someone who is knowledgeable about these things could explain how I could implement something like this in unity, I would appreciate any advice!
[1]: https://www.youtube.com/watch?v=EbNxBXaBol0raycastcontrollergeometryclimbingThu, 13 Aug 2020 21:46:37 GMTsupersulubuild not showing geometry
http://answers.unity.com/questions/1751473/build-not-showing-geometry.html
so i made a 2d game and everything is working fine in the editor but when i test the build it doesnt show some geometry. the gameobjects are there, the gameobject's physics and scripts work as planned but its invisible. how can i fix that?gameobjectbuildinvisiblegeometryFri, 17 Jul 2020 11:00:29 GMTunity_9P58GcCHwkNUOAHow do you do taxicab geometry in Unity?
http://answers.unity.com/questions/1748315/how-do-you-do-taxicab-geometry-in-unity.html
I have a ball and I want to move it around in 3d space (Specifically in SteamVR) using taxicab geometry.
I want to be able to move it along the prebuilt unity 3d grid lines. How would I go about doing this? Thanks in advance.vrgeometrySat, 04 Jul 2020 23:05:32 GMTYurtle_ButlerSmoothness of geometry look
http://answers.unity.com/questions/1743936/smoothness-of-geometry-look.html
Hi! I exported my flower model from Blender to Unity using FBX.
And the petals look not smooth with a lot of ugly stripes on it.
When I export the petals itself without flower they look alright.
And other elements like leaves look good and smooth.
Maybe it's something with rendering settings?
Please help.
![alt text][1]
[1]: /storage/temp/162424-screenshot-00359.jpgsmoothgeometryrendersettingsSat, 20 Jun 2020 12:42:40 GMTLiliaUlibkaHow to calculate a following camera with a restrain angle
http://answers.unity.com/questions/1735633/how-to-calculate-a-following-camera-with-a-restrai.html
Hello I have a math related problem I can't seem to resolve, I am trying to create a tps camera in unity in 3D similar to what we can see in Diablo3 or the latest Minecraft Dungeon, I never did that so I made a drawing to see how I can program that.
I have multiple constraints :
- My camera angle on the y axis should be 45°
- My camera angle on the x axis is a fixed variable
- The distance from my camera to the targeted object (character) is a fixed variable
Here's my drawing :
![alt text][1]
To tacle this problem I then need to find the position of the camera, I must use Thalès theorem
To find y I think I just need to multiply the cosinus of the angle (here 70°) by the hypotenuse which is the length of my fixed variable (here it's 3)
However to find x and z I think I first have to find the hypotenuse of those two light grey triangles, it's suppose to be the sinus of the angle (70) by the distance (3)
Now I can get x and z with those operations : x = sin(45) \* hypotenuse of the light grey triangle and z = cos(45) \* hypotenuse of the light grey triangle
Here is my code ![alt text][2]
The thing is I get something completely off center and I don't know why, I think my thinking is correct and my code as well
[1]: /storage/temp/160572-explanation.png
[2]: https://i.gyazo.com/c0b7a637d3dcfbb26b227e37da19fc23.pngcamerapositionmathgeometryThu, 28 May 2020 09:47:22 GMTMilleMillieImpossible non euclidean geometry help
http://answers.unity.com/questions/1732579/impossible-non-euclidean-geometry-help.html
I've found a way to make non euclidean geometry in Unity using stencil buffer portals.
The portals are not made with multiple cameras and there is no teleporting.
The portals only hide the overlapping geometry by separating the two using stencil buffer portals and layers.
I'm importing maps from an old game named Marathon.
Marathon maps need portals to function properly.
The Marathon map editor Weland can export maps as .obj model files, then normals and textures are added with blender.
All normals point inward and the map is separated into sectors.
The sectors and portals are separate game objects.
I found a way to use stencil buffer portals without having to edit or move sectors in the maps.
The game objects that occupy the same space are separated into two layers.
Layer 1 and layer 2 cannot collide with each other or interact.
Unity explains how to make layers.
https://docs.unity3d.com/Manual/Layers.html
https://docs.unity3d.com/Manual/LayerBasedCollision.html
The default layer connects and collides with both layer 1 and 2.
When the game object, player camera or enemy enters a portal, the portal checks if they cross the portal plane.
The portal changes the layer of the game object that crosses the portal plane to that layer the sector is.
Portal layer 1 changes player to layer 1.
Exiting the sector portal changes the game object player layer to default.
Unity explains how to change layers with script.
https://docs.unity3d.com/ScriptReference/GameObject-layer.html
There are four stencil buffer shaders, a read and write for layer 1 and a read and write for layer 2.
The read shader goes on the game object sector and the write shader goes on the portal game object.
Ronja explains how the stencil buffer works.
https://www.ronja-tutorials.com/2018/08/18/stencil-buffers.html
One read and write shader is set to ref 1 and the other read and write shader is ref 2.
Write shader ref 1 only renders read shader ref 1 from behind the portal.
This Youtube video explains how stencil buffer portals work.
https://www.youtube.com/watch?v=OBb4iUiXaRA
When the player camera crosses the portal plane and enters the sector, the read shader comparison is changed from equal to always.
When the player exits the sector portal the read shader on the sector is changed back to equal.
Unity explains the stencil buffer.
https://docs.unity3d.com/Manual/SL-Stencil.html
The portals have box colliders.
Ontriggerstay with crossing the portal does two things for the player, it changes the player game object layer and it changes the sectors read shader comp to always or equal.
To hide the enemy or player, when entering the portal they also have a read shader attached.
Anything that enters a portal is changed to that sectors layer and stencil reference value changed to that portals value.
The overlapping space stays separate and only what enters or exits the portals is changed.
Is there a better way to do this?layersgeometrystencilTue, 19 May 2020 19:12:58 GMTTharzzatHow would you go at making a spherical grid layout
http://answers.unity.com/questions/1732040/how-would-you-go-at-making-a-spherical-grid-layout.html
I want to create a grid in the shape of a sphere yet ,as little as I know, I can't figure where to even begin research this and how to implement it by code, The only grids i ever made were 2D square grids and never had any experience with 3D ones.
So the question is, How would you approach this and is it even possible (not hex grid but a square grid)?
Thanks in advance.gridgeometryMon, 18 May 2020 10:31:16 GMTsexysnizelFinding the intersection of vertical plane and scene mesh geometry
http://answers.unity.com/questions/1731511/finding-the-intersection-of-vertical-plane-and-sce.html
I need to find all the intersections of an upright plane with the main character's position and rotation. I currently have some code that works but is spewing out some strange values. In my code, I convert the 3-dimensional edges of all the meshes into two-dimensional equations in the form of Ax + By = C with bounds. I make an equation for the plane with the same form and calculate their intersection. If the intersection is within the edge's bounds, it calculates the percentage along the line from point 1 to point 2 and uses that the calculate a 3d position where the intersection takes place.
Here is my code:
public class Edge
{
public Vector3 p1;
public Vector3 p2;
public LineEquation Xequation;
public LineEquation Yequation;
public LineEquation Zequation;
public BoxRange Range;
public float Length;
public Edge(Vector3 p, Vector3 pp)
{
p1 = p;
p2 = pp;
float x = Mathf.Abs(p.x - pp.x);
float y = Mathf.Abs(p.y - pp.y);
float z = Mathf.Abs(p.z - pp.z);
Xequation = new LineEquation(new Vector2(p.y, p.z), new Vector2(pp.y, pp.z));
Yequation = new LineEquation(new Vector2(p.x, p.z), new Vector2(pp.x, pp.z));
Zequation = new LineEquation(new Vector2(p.x, p.y), new Vector2(pp.x, pp.y));
Range = new BoxRange(p, pp);
Length = (p - pp).sqrMagnitude;
}
}
public class LineEquation
{
public float A, B, C;
public LineEquation(float a, float b, float c)
{
A = a;
B = b;
C = c;
}
public LineEquation(Vector2 p1, Vector2 p2)
{
A = p2.y - p1.y;
B = p1.x - p2.x;
C = A * p1.x + B * p1.y;
}
public LineEquation(Vector2 p, float angle)
{
angle *= Mathf.Deg2Rad;
Vector2 p2 = new Vector2(p.x + Mathf.Sin(angle), p.y + Mathf.Cos(angle));
A = p2.y - p.y;
B = p.x - p2.x;
C = A * p.x + B * p.y;
}
}
public class BoxRange
{
public Vector3 lowerBound;
public Vector3 higherBound;
public BoxRange(Vector3 p1, Vector3 p2)
{
lowerBound = new Vector3(
Mathf.Min(p1.x, p2.x),
Mathf.Min(p1.y, p2.y),
Mathf.Min(p1.z, p2.z)
);
higherBound = new Vector3(
Mathf.Max(p1.x, p2.x),
Mathf.Max(p1.y, p2.y),
Mathf.Max(p1.z, p2.z)
);
}
}
public class PlaneCaster
{
public Edge[] edges;
public string layer { get; private set; }
public PlaneCaster(string tagLayer)
{
layer = tagLayer;
GameObject[] list = GameObject.FindGameObjectsWithTag(tagLayer);
List<Edge> buffer = new List<Edge>();
for (int i = 0; i < list.Length; i++)
{
Vector3 scale = list[i].transform.localScale;
Vector3 pos = list[i].transform.position;
Mesh mesh = list[i].GetComponent<MeshFilter>().sharedMesh;
Vector3[] vertices = mesh.vertices;
int[] triangles = mesh.triangles;
for (int j = 0; j < triangles.Length / 3; j++)
{
Edge edge1 = new Edge(Vector3.Scale(vertices[triangles[j * 3]], scale) + pos, Vector3.Scale(vertices[triangles[j * 3 + 1]], scale) + pos);
Edge edge2 = new Edge(Vector3.Scale(vertices[triangles[j * 3 + 1]], scale) + pos, Vector3.Scale(vertices[triangles[j * 3 + 2]], scale) + pos);
Edge edge3 = new Edge(Vector3.Scale(vertices[triangles[j * 3 + 2]], scale) + pos, Vector3.Scale(vertices[triangles[j * 3]], scale) + pos);
if (!CheckMatch(buffer, edge1)) buffer.Add(edge1);
if (!CheckMatch(buffer, edge2)) buffer.Add(edge2);
if (!CheckMatch(buffer, edge3)) buffer.Add(edge3);
}
}
edges = buffer.ToArray();
}
public void DrawPlaneRay(Vector3 pos, float rot)
{
rot *= Mathf.Deg2Rad;
LineEquation plane = new LineEquation(new Vector2(pos.x, pos.z), rot);
Debug.DrawRay(pos, new Vector3(Mathf.Sin(rot), 0f, Mathf.Cos(rot)), Color.green, 0.1f, false);
}
public void DrawDebug()
{
for (int i = 0; i < edges.Length; i++)
{
Debug.DrawLine(edges[i].p1, edges[i].p2, Color.red, 2f, false);
}
}
private bool CheckMatch(List<Edge> buff, Edge check)
{
for (int i = 0; i < buff.Count; i++)
{
if (
(buff[i].p1 == check.p1 && buff[i].p2 == check.p2) ||
(buff[i].p1 == check.p2 && buff[i].p2 == check.p1)
)
{
return true;
}
}
return false;
}
public List<Vector3> Cast(Vector3 pos, string axis, float rot)
{
List<Vector3> result = new List<Vector3>();
LineEquation plane;
if (axis == "x") plane = new LineEquation(new Vector2(pos.y, pos.z), rot);
else if (axis == "y") plane = new LineEquation(new Vector2(pos.x, pos.z), rot);
else if (axis == "z") plane = new LineEquation(new Vector2(pos.x, pos.y), rot);
else throw new Exception("Undefined Axis");
for (int i = 0; i < edges.Length; i++)
{
try
{
Vector2 reference;
if (axis == "x") reference = new Vector2(edges[i].p1.y, edges[i].p1.z);
else if (axis == "y") reference = new Vector2(edges[i].p1.x, edges[i].p1.z);
else if (axis == "z") reference = new Vector2(edges[i].p1.x, edges[i].p1.y);
else throw new Exception("Undefined Axis");
Vector2 intercept = GetIntercept(i, axis, plane);
if (
(axis == "x" && intercept.x > edges[i].Range.lowerBound.z && intercept.x < edges[i].Range.higherBound.z && intercept.y > edges[i].Range.lowerBound.y && intercept.y < edges[i].Range.higherBound.y) ||
(axis == "y" && intercept.x > edges[i].Range.lowerBound.x && intercept.x < edges[i].Range.higherBound.x && intercept.y > edges[i].Range.lowerBound.z && intercept.y < edges[i].Range.higherBound.z) ||
(axis == "z" && intercept.x > edges[i].Range.lowerBound.x && intercept.x < edges[i].Range.higherBound.x && intercept.y > edges[i].Range.lowerBound.y && intercept.y < edges[i].Range.higherBound.y)
)
{
float dist = (reference - intercept).sqrMagnitude;
float perc = dist / edges[i].Length;
result.Add((edges[i].p1 * (1f - perc)) + (edges[i].p2 * perc));
}
}
catch(Exception e)
{
}
}
return result;
}
public Vector2 GetIntercept(int index, string axis, LineEquation eq)
{
LineEquation line;
if (axis == "x") line = edges[index].Xequation;
else if (axis == "y") line = edges[index].Yequation;
else if (axis == "z") line = edges[index].Zequation;
else
{
throw new Exception("Axis is Incorrect");
}
float delta = line.A * eq.B - eq.A * line.B;
if (delta == 0)
throw new Exception("Lines are Paralell");
float x = (eq.B * line.C - line.B * eq.C) / delta;
float y = (line.A * eq.C - eq.A * line.C) / delta;
return new Vector2(x, y);
}
}
![alt text][1]
![alt text][2]
In the images above, the green line represents the plane's rotation, the red lines are all the calculated edges in the scene and the blue lines are lines going from the main player to the points of intersection. In theory, all of the blue lines should be parallel with the green line.
Any help in finding the problem with my code is appreciated.
[1]: /storage/temp/159675-capture.png
[2]: /storage/temp/159676-capture1.pngplanegeometrylinesintersectioncalculationsMon, 18 May 2020 06:06:08 GMTargentummanusbetamoving vertices dynamicly relative to other Object
http://answers.unity.com/questions/1730308/moving-vertices-dynamicly-relative-to-other-object.html
Hi, I have a cube, let's call it player, under that i have a procedurally generated plain, the palyer is going to move or rather float above and along that plain, I want to:
**A)** get the vertices around the cube that are in the radius of the player.
now i have achived that by looping through all vertices in that plain but that massivly cuts performance.
i want to be able to get the vertices that are in the radius with somthing like `physics.overlapsphere`
without having to loop through all the vertices, this obviusly doesn't work since overlapsphere ruturns a collider array and i want vertices which are a verctor3.
**B)** raise those vertices on the y axis relative to the players position (the closer the vertex is to the player the higher it is), now i have also gotten this to work but its not as nice and smooth as i want it to be, the vertices just lerp the Y axis to 3 if they are in the radius, and if not the don't move at all.
i want it to more dependent on more of where the player is rather than if its in the radius,
If you get what i mean.
Here is my current code:
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
using UnityEngine.UIElements;
[RequireComponent(typeof(MeshFilter))]
public class MeshGenerator : MonoBehaviour
{
//player's refrence
public Transform player;
//minimum distance for the vertex from the player to be affected and raised up
public float minDistance;
//limit for the vertices on the Y axis
public float meshOffset;
//mesh generation stuff
Mesh mesh;
Vector3[] vertices;
int[] triangles;
public int xSize = 20;
public int zSize = 20;
void Start()
{
mesh = new Mesh();
GetComponent<MeshFilter>().mesh = mesh;
CreateShape();
UpdateMesh();
}
void Update()
{
MoveVertices();
}
//Basically creating a plain at runtime to have a refrence to the vertices
void CreateShape()
{
vertices = new Vector3[(xSize + 1) * (zSize + 1)];
for (int i = 0, z = 0; z <= zSize; z++)
{
for (int x = 0; x <= xSize; x++)
{
vertices[i] = new Vector3(x, 0, z);
i++;
}
}
triangles = new int[xSize * zSize * 6];
int vert = 0;
int tris = 0;
for (int z = 0; z < zSize; z++)
{
for (int x = 0; x < xSize; x++)
{
triangles[tris + 0] = vert + 0;
triangles[tris + 1] = vert + xSize + 1;
triangles[tris + 2] = vert + 1;
triangles[tris + 3] = vert + 1;
triangles[tris + 4] = vert + xSize + 1;
triangles[tris + 5] = vert + xSize + 2;
vert++;
tris += 6;
}
vert++;
}
}
//updating the meshes vertices and triangles and recalculating lighting on the surface of it
void UpdateMesh()
{
mesh.Clear();
mesh.vertices = vertices;
mesh.triangles = triangles;
mesh.RecalculateNormals();
}
//Using the players refrence to get his pos and looping through the vertices array to find which vertices are in the redius of the player
// This is the part that i am not certain of
void MoveVertices()
{
for (int i = 0; i < vertices.Length; i++)
{
float distance = Mathf.Sqrt((player.position - vertices[i]).sqrMagnitude);
if (distance < minDistance)
{
vertices[i].y = Mathf.Lerp(vertices[i].y, meshOffset, Time.deltaTime * distance);
UpdateMesh();
}else
{
vertices[i].y = Mathf.Lerp(vertices[i].y, 0, Time.deltaTime * distance);
UpdateMesh();
}
}
}
private void OnDrawGizmos()
{
if (vertices == null)
return;
for (int i = 0; i < vertices.Length; i++)
{
Gizmos.DrawSphere(vertices[i], 0.1f);
Gizmos.color = Color.red;
}
}
}
for visualization, i am basically triying to mimic geometry wars meshs and how they react to objects positions and what's happening on the battle field
https://www.youtube.com/watch?v=x9eT6RWZ--0
As always, any help is appreciated
Thanks in advance!meshverticesvertexgeometryThu, 14 May 2020 02:56:47 GMTOnEd0tProBuilder Fill Hole Not Working
http://answers.unity.com/questions/1729538/probuilder-fill-hole-not-working.html
Hi,
I am new to using Probuilder. I am looking to create a ramp from a pentagon I sliced in half.
I tried Select Holes, then Fill Holes. Here are some of the the screenshots of the geometry I am trying to make:![alt text][1]![alt text][2]
[1]: /storage/temp/159263-1.png
[2]: /storage/temp/159264-2.png3d3d modelsgeometryfillTue, 12 May 2020 07:43:35 GMTdecoy98Inverse projection vertex shader
http://answers.unity.com/questions/1724876/inverse-projection-vertex-shader.html
Hello , i'm working on some piece of code to create some volumetric 3dtexture mapped to the frustum of a camera.
To create that volumetric texture i multiply some position vector with the inverse projection matrix.
So my frustum and geometry inside become a normalized cube.
This work so far if the model is inside frustum , but if vertices are far outisdes the frustum and cross the "eye view plane" my model got distorted.
here is my code to transform position.
float4 Local = mul(mul(Projection,View),float4(WorldPos,1.0));
Local.xyz /=Local.w;
I believe the Local.w become 0 / negative or infinite at the point where vertices cross the eye view plane and then the model is not correct anymore.
i tried a few things by checking if Local.w is equal 0 or smaller than 0 ... but nothing really worked for me atm.
I would like to find a solution to keep the mesh inside my normalized frustum always correct.
How to deal with this vertices crossing the eye view plane ?
![alt text][1]
Here is a litle drawing of my problem , after applying inverse projection transform to my vector A and C are always correct , but i can't find a way to preserve B position after it cross the eye plane.
I'm working with shader/compute shader .
[1]: /storage/temp/158198-example.pngmathgeometryprojectionprojection-matrixtransformationThu, 30 Apr 2020 18:36:59 GMTdaviddessensMake camera rotate around an object while keeping entire area visible
http://answers.unity.com/questions/1719314/make-camera-rotate-around-an-object-while-keeping.html
I attached my camera to an empty gameobject that is positioned at 0/0/0. If i rotate the object the camera will stay focused on the object and rotate around the area. This works perfectly.
The issue that im facing now is that my ares isnt a circle but a rectangle. This means that at certain angles corners of the area are cut off which is not good:
![alt text][1]
The solution to this problem should be really simple. The game object would have to move depending on the rotation of the camera so that the entire area stays visible (The sphere is just a representation of the gameobjects position) :
![alt text][2]
I could hard code it but with 360 degrees it would be a nightmare and probably a lagging mess.
Is there a formula or some better solution for my problem? Thanks in advance.
[1]: /storage/temp/156850-bad.png
[2]: /storage/temp/156852-good.pngcamerarotationscripting problemscripting beginnergeometryThu, 16 Apr 2020 21:52:30 GMTmagstaxxxImporting collada (.dae) files makes no sense?
http://answers.unity.com/questions/1710471/importing-collada-dae-files-makes-no-sense.html
Hello together,
I have got an issue with Unity3D. I want to import the geometry of a robot. The file-format is .dae (Collada). I can either drag&drop the file into the Project-browser or do a right click and then "Import New Asset". That works perfectly. But what I'm concerned about is that when is drag that imported geometry into the Screne-editor it's is a 100 times bigger then it was supposed to be. So I went through all the settings in Unity3D to find a solution. So when one selects the geometry in the Project-browser there are 2 significant settings.![Inspector-settings][1] . The first one is the scale-factor. With that setting I can perform a little work-around. I just have to type 0.01. But then there is the question: why would sombody make it so difficult? The next setting says that units will be converted from millimeters into 0.1 meters (so decimeters). But why??? What sense does that make? And why is there no way to change that setting? So I went though the code of the .dae-file and at the top of this code I found the following declaration:
<?xml version="1.0" encoding="UTF-8"?>
<COLLADA version="1.5.0" xmlns="http://www.collada.org/2008/03/COLLADASchema">
<asset>
<contributor>
<author>W.E.S.T. GmbH</author>
<author_email>info@west-gmbh.com</author_email>
<authoring_tool>WestUniversalConverter WUC v1610100855</authoring_tool>
<copyright>W.E.S.T. GmbH</copyright>
</contributor>
<created>2018-09-07T11:54:29</created>
<modified>2018-09-07T11:54:29</modified>
<unit meter="0.001" name="mm"/>
<up_axis>Z_UP</up_axis>
</asset>
It says that the unit of the data in that file is 0.001 meters and that this again is called millimeter. So that is correct. Then again, why would Unity3D mess up the units? I experimentally changed that number from 0.001 to 1.0 and went back to Unity3D. What happend was that the text changed from "1mm to 0.1m" into "1m to 100m"??? This makes totally no sense at all? Please, could somebody explain that to me and more important give me a solution other than changing the scale factor, because I already know.
Best regards
Leon
[1]: /storage/temp/154847-2020-03-23-12-17-03-roboter-test-samplescene-pc-ma.pngconvertimporting assetsgeometrycolladadaeMon, 23 Mar 2020 12:08:19 GMTlh97Use Unity's transform API to manipulate points?
http://answers.unity.com/questions/1707454/use-unitys-transform-api-to-manipulate-points.html
I want to proceduraly generate meshes.
I created a method to supply the vertices of a circle.
The idea is that it creates a shape in 2d and then rotates it in 3d assuming that "rotation" is the vector of the shapes normal axis.
public List<Vector3> Loop (Vector3 center, Vector3 rotation, float radius, int divisions)
{
List<Vector3> loop = new List<Vector3>();
for(int p = 0; p < divisions; p++)
{
float u = (float)Math.Cos(2 * Math.PI * p / divisions) * radius;
float v = (float)Math.Sin(2 * Math.PI * p / divisions) * radius;
float x = 0;
float y = 0;
float z = 0;
// Apply rotation to u & v to get x, y, z
loop.Add(new Vector3(x, y, z));
}
return loop;
}
Creating the circle in 2d (u & v) was super easy but when I looked into applying 3d rotations, it seemed to be a complete rabbit hole completely beyond my comprehension.
Is there a way to use existing API to do this?rotationmeshvector3geometrySat, 14 Mar 2020 01:16:17 GMTExistingmanI can't keep building. Due to the inability to create geometry
http://answers.unity.com/questions/1706373/i-cant-keep-building-due-to-the-inability-to-creat.html
An error like this picture will occur.
And I can't keep building.
If you know anyone, help me!
unity version : 2018.2.13f1c#build-errorgeometryTue, 10 Mar 2020 09:17:49 GMTHyeongeunProbuilder and Progrids
http://answers.unity.com/questions/1703868/probuilder-and-progrids.html
I have a problem with Probuilder edge loops, when i put the in, all is ok but when i move it, it takes a side with it, breaking geometry i want. Im new to probuilder, just started today.
image link : https://imgur.com/20UCdKfunity 5unity5assetgeometrySat, 29 Feb 2020 17:51:35 GMTPiticIntersection of a Plane and an object
http://answers.unity.com/questions/1703569/intersection-of-a-plane-and-an-objectintersection.html
Hi! So i'm looking for a way to find a set of points representative of the intersection of a plane and an object, and beeing able to work with this set of points informations.
The final objective is to show the user where an object can move on a terrain with a maximum travel distance.
So, after a quick chat with some friends, the best way to build this seems to use a certain amount of verticals planes (or just one rotating plane), which all have in common the start point of the object, and then find the intersection of theses planes with the terrain (a low poly layer of the terrain to make the calculations easier), then on each intersections obtained, simply calcul a perimeter to find the most distant point on theses, and finally, interpolate theses differents point to build the estimation layer.
![alt text][1]
![alt text][2]
In this diagram, it's almost simplifiable by a circle because the terrain is mostly plane, but it's more destined to complex terrain of course !
Also, I precise "considering intersection perimeter" because it's not the point with a distance x from the start point considering the space referential, but the distance x following the intersection perimeter.
The idea is there, my unity knowledge : not '^^
I'd love get your advices and ideas !
[1]: /storage/temp/153408-diagram-plane-intersections.png
[2]: /storage/temp/153409-diagram-plane-intersections-final-step.pngmathplanegeometryFri, 28 Feb 2020 18:25:36 GMTkaboomitoHow do i go about stereo graphic projection?
http://answers.unity.com/questions/1702915/how-do-i-go-about-stereo-graphic-projection.html
I have a List of points that describe a sphere, and in order to use the Cell algorithm i want to use i need to project it to 2d, so from what i understand i need for points[i] to output a new(x,y) where new x = (x/1-z)
and new y = (y/1-z), but that doesn't seem to output the correct values. help please.script.mathgeometryWed, 26 Feb 2020 06:38:37 GMTRazzputanExtrude Geometry shader
http://answers.unity.com/questions/1701200/extrude-geometry-shader.html
Hi I need a geometry shader that extrudes faces from a flat mesh, I found [this][1] shader, which does *almost* what I need it to. But this shader also extrudes faces within the extruded volume, not normally seen with culling turned off. But in my use case this will definitely be seen and ruin the effect I'm going for, I basically only want to extrude from the outer edge.
[1]: http://www.shaderslab.com/demo-82---extrude-faces.htmlshadershader programminggeometrygeometry shaderWed, 19 Feb 2020 13:47:19 GMTewoudwerfDrawing sprite along colliders
http://answers.unity.com/questions/1691126/drawing-sprite-along-colliders.html
Hi,
I am having problem with realistic laser pointer. I am trying to create real moving laser in my VR game and I am using texture of laser dot, placing it wherever the laser hit:
<br>
![alt text][1]
<br>
However as you can see there is a problem on the edges, and it looks bad. I would like to get similiar effect to the spotlight:
<br>
![alt text][2]
<br>
<br>
How can I modify the mesh /or sprite to draw it on the collider? I guess drawing on mesh is not the solution, because I it would be very complicated if I have 2 objects (like pillar and wall, 2 different objects) and laser hit both. Can i somehow draw it in the shape of colliders? Or is there any other known solution for showing laser sight on mesh?
Thanks in advance for any answers!
<br>
<br>
PS. I tried spotlight with cookie, but you have minimum spot angle, that is too big for me and it looks bad (laser point don't scale up with distance like spotlight), not to mention problems with texture colors. Also used projector, but can't get around texture showing on both sides of the object (no matter the size of far clip plane, it always go through the object texture it is projected on).
[1]: /storage/temp/151249-laserdotunity.png
[2]: /storage/temp/151250-laserspotlight.pngvrshaderslighteffectsgeometryTue, 14 Jan 2020 14:27:35 GMTmiszczykFind intersecting volume of two cubes -or- submerged volume of object
http://answers.unity.com/questions/1685318/calculate-submerged-volume-volume-of-intersecting.html
Hey Unity users!
I am trying to find out how much of an object is below a certain surface. I basically have a (fake) bath and want to use the displaced volume by the controlled object as a measure for the disturbance of the fluid.
This bath is static and has a fixed height. The controlled object can have any orientation/position. What I've tried:
- Simplify the controlled object to a box & find out how far the box is below the surface. I managed to get the positions of all the vertices and the positions where the edges cross the surface of the bath. However, I found out that calculating this volume for an arbitrary orientation is rather difficult. I basically need a formula that calculates the volume of an arbitrary (irregular) polyhedron, but haven't been able to find something that works here.
- I could also draw a voxel grid on the controlled object, and found out how much of it is underneath the surface, and use that to estimate the volume. However, I have no idea how to do this and haven't been able to find much guidance either.
- I have found this thread: https://answers.unity.com/questions/1178637/finding-volume-of-two-3d-meshes-intersection.html but was not able to use it to solve my problem unfortunately.
Does anyone have an idea on how I could approach this problem? Any help would be greatly appreciated!voxelvolumegeometryWed, 18 Dec 2019 06:43:31 GMTavandenbergHow to find symmetry plane of an object
http://answers.unity.com/questions/1684190/how-to-find-symmetry-plane-of-an-object.html
Hello.
I need a script able to find the symmetry of a given object inside the Unity 3D space.
The idea is the following (I simply drawn a plane wich divides in half a car, just to give an hint):
![alt text][1]
[1]: /storage/temp/149960-symmetry-plane.png
Any idea on how to do this? I would like to exploit the points of the mesh and check wether each point has a simmetrical counterpart.meshplanegeometryThu, 12 Dec 2019 18:09:21 GMTRizzutp