JustInvoke / Randomation-Vehicle-Physics

Vehicle physics system for the Unity engine.
https://justinvoke.com/game-assets/#randomation-vehicle-physics
864 stars 184 forks source link

Calculate Tangents for Tire Marks #2

Closed JustInvoke closed 7 years ago

JustInvoke commented 7 years ago

Calculating tangents for tire mark meshes would allow for them to use materials with normal maps. This is useful for mud/snow tracks where they should appear to leave a impressions in the surface.

Tire marks are generated in the TireMarkCreate script. The tangent arrays should be handled similarly to the others such as vertex and uv.

hemik1 commented 7 years ago

Hey! I'm not that familiar with GitHub, so would rather not commit it myself, but here's a dropbox link to a MeshUtil class with static CalculateMeshTangents method: https://www.dropbox.com/s/rs373bcyex8b9r9/MeshUtil.cs?dl=0 And your script modified to make use of it, just 2 extra lines, first calculating Normals using unity's RecalculateNormals method and then doing the tangents (tangents require normals info): https://www.dropbox.com/s/2s9un7chsiypmnj/TireMarkCreate.cs?dl=0

JustInvoke commented 7 years ago

Thanks, I'll take a look at this when I get a chance.

On Mon, Jan 9, 2017 at 12:14 PM, hemik1 notifications@github.com wrote:

Hey! I'm not that familiar with GitHub, so would rather not commit it myself, but here's a dropbox link to a MeshUtil class with static CalculateMeshTangents method: https://www.dropbox.com/s/rs373bcyex8b9r9/MeshUtil.cs?dl=0 And your script modified to make use of it, just 2 extra lines, first calculating Normals using unity's RecalculateNormals method and then doing the tangents (tangents require normals info): https://www.dropbox.com/s/2s9un7chsiypmnj/TireMarkCreate.cs?dl=0

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/RandomationGames/Randomation-Vehicle-Physics/issues/2#issuecomment-271394719, or mute the thread https://github.com/notifications/unsubscribe-auth/AXt5JziHDJzNKP8SB5mslgI4a6RiBnh5ks5rQpUigaJpZM4LdS2K .

JustInvoke commented 7 years ago

Did you write the MeshUtil script or did someone else?

hemik1 commented 7 years ago

The tangents calculating method i've found on the web, took one from this thread if I'm not mistaken: http://answers.unity3d.com/questions/7789/calculating-tangents-vector4.html I've only moved some stuff around for optimization purposes (fewer pointer allocations).

JustInvoke commented 7 years ago

I have integrated your changes.