- Home /
Fill in mesh?
Hello
My Game requires the Camera to Clip into 3D Objects
The Problem is where the Insides of the Object are empty
I do not want to see the other side of the Object as a workaround.
So is there any way to fill the object, or at least create a plane where the Camera Clips the Mesh?
Thanks,
Answer by helgrind21 · Oct 27, 2020 at 07:41 PM
link textIf you haven't solved your problem yet.
Try using this: Triangulator
It worked for me with a non-convex shape.
Update
The link is off so I'm uploading the code I took from the unity doc.
Answer by Cornelis-de-Jager · Jul 06, 2017 at 02:39 AM
So when Meshes are drawn, the mesh is constructed out of triangles which are only visible from one side. If you want to have the inside drawn aswell you essentially need to reverse all the triangles so that they are drawn from the other perspective then add the original perspective. This doubles the size of all your meshes. Below is a script I just wrote, not tested, that should draw the inside and outside on the start of the object lifespan. Just add the script to any in-game transform.Explanation:
Solution:
using UnityEngine;
using Linq; // Add this <------------------------------------
using System.Collections;
public class FlipInsideOut: MonoBehaviour {
void Start () {
// Get the mesh
Mesh mesh = GetComponent<MeshFilter>().mesh;
// Get the both the inside and outside triangles
int[] inside = mesh.triangles.Reverse().ToArray();
int[] outside = mesh.triangles.ToArray();
// Combine them into a new mesh array
int[] combined = new int[inside.Length + outside.Length];
Array.Copy(inside, combined, inside.Length);
Array.Copy(outside, 0, combined, inside.Length, outside.Length);
// Set the mesh array
mesh.triangles = combined;
}
A lot Of Errors X[. T, Array2 and Array don't exist. Am I $$anonymous$$issing Something?
Raw-
Sorry the 'T' should be 'int'. I'll update
Your answer
Follow this Question
Related Questions
Viewport Cliping, not camera. 0 Answers
Procedurally generated mesh disappears from certain camera angles 1 Answer
Render inside of mesh as black 2 Answers
Oblique Frustum Clipping 0 Answers
Mesh is deleting itself when the camera approaches it 2 Answers