Hot answers tagged

14

Usually the distance of the midpoint of a polygon to the camera is being used for z-sorting. The painter's algorithm cannot be 100% accurate by it's nature. There will always be cases where sorting will fail, no matter what reference point you use. If you want correct z-sorting with the painter's algorithm, you'll have to slice overlapping polygons into ...


9

OpenGL wiki's pseudocode (as referenced by Peter Taylor, as well) is correct. What you want is the normal of the plane the triangle, quad or other polygon represents. All you need are two edges of any planar polygon that share a common vertex. The number of edges does not matter. All you need is to get enough information to define the plane, and then get ...


2

I can't answer your question directly but I can offer some suggestions and questions to ask yourself to narrow it down... Depending on your research goals, ask yourself if you really need a realistic facial animation in the first place. Computer faces will never be as good as the real thing. Can you literally take photos/videos of real people and use ...


2

I'll post my solution too, it takes the average of the normals of all triangles that a vertex belongs to. It takes a mesh with vertices and indices and calculates the normals for all vertices. for(int i = 0; i < indices.Length; i += 3) { Vector3 v0 = vertices[indicies[i]].Position; Vector3 v1 = vertices[indicies[i+1]].Position; Vector3 v2 = ...


2

I'm successfully using this for quads / triangles. Loop through each face, and pass in 3 verticies. If you have a quad ABCD pass in ABD. For example for the front facing face on this cube, I would pass in, v2, v3, v0 // cube /////////////////////////////////////////////////////////////////////// // v6----- v5 // /| /| // v1------v0| // | | ...


2

A cross product ought to be perfectly reliable for any planar polygon. If you've got problems with that, it's almost certainly just a bug in your code. As others have said, it would be useful to know why you think your normals are wrong.


1

The skid system I wrote works like this: When in a skidding condition, every frame capture the contact point of the skid, and the normal of the surface contact point - you would probably already have this from the raycast/contact you used for your physics simulation. When you have two or more points, you can start drawing the skid - to begin with just draw ...


1

Well, the thing is, trail renderers (and the underlying line renderer) are supposed to face the camera. There are a couple ways I can think of doing this, but I'm humming over which one would be the best. One way would be to buy a decal system (there are a couple on the asset store for under $10, at least one which is free). The tracks left via decals ...


1

Unity allows you to easily edit the vertices in a mesh. The problem would be the editing only some parts of the mesh. You could edit vertices based on how close they are to an origin, like Blender's "proportional edit".


1

It may be mathematically equivalent - check it if you want - but the code given there is not the same as the pseudocode for Newell's method given on the OpenGL wiki. See http://www.opengl.org/wiki/Calculating_a_Surface_Normal



Only top voted, non community-wiki answers of a minimum length are eligible