x


Custom Mesh Plane Two-Sided Question

I dynamically create meshes at runtime, and sometimes they end up inside-out (see this question). I thought I had solved the problem with a clockwise-detection script, but there are still random instances where it fails, causing the surface normals to point inwards.

My question is, would it be possible to simply "double" the triangle list, with the second half being reversed, therefore creating a two-sided, "hollow" object, so that no matter if it was "inside-out" or not, it would still look and function correctly?

I have a MeshCollider on these objects (they're static), and when the surface normals face the wrong way, objects become "trapped" inside the object instead of bouncing off of them, if that makes sense. This is what I'm trying to prevent.

more ▼

asked Jul 04 '10 at 12:34 AM

qJake gravatar image

qJake
11.6k 43 78 161

@SpikeX, is it really random failures, or are there specific shapes where it fails? Remember that the algorithm doesn't work for some shapes - such as self-intersecting shapes, or shapes with holes. How does your drawing algorithm work? Could it be generating some of these invalid shapes?

Jul 04 '10 at 01:16 AM Cyclops

The shapes are pre-checked. They are solid, and non-intersecting. They're also limited to a certain size (not too few or too many datapoints, basically). And yes, it's random. Say, one out of every 50 triangles drawn exhibits this weird behavior. It's entirely non-reproducable.

Jul 04 '10 at 01:23 AM qJake
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

So it turns out I can do this (creating a "hollow" object, with normals facing inward and outward), and it works great.

The downsides, however, are that your UV mapping and/or shadowing might get screwed up, as mine did. Luckily I was able to use an unlit diffuse shader which still looks good. The other problem is that you're drawing unnecessary triangles (literally, twice as many) inside the object. For objects with as few triangles as mine, this doesn't pose a problem, but for larger objects it may.

more ▼

answered Jul 07 '10 at 07:48 PM

qJake gravatar image

qJake
11.6k 43 78 161

@SpikeX, you managed to checkmark your answer after 6 hours? The one time I tried, UA invoked a 2-day delay. Guess 5K has it's perks after all... :)

Jul 08 '10 at 02:29 AM Cyclops

I think it's because I asked it four days ago ;)

Jul 08 '10 at 05:54 AM qJake
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1356
x231

asked: Jul 04 '10 at 12:34 AM

Seen: 2160 times

Last Updated: Jul 04 '10 at 12:34 AM