Doc.txt 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. * SplineMesh documentation *
  2. // What is it?
  3. A spline is a set of nodes connected by bezier curves. Each node is defined by a position and a direction.
  4. The MeshBender component create a deformed mesh from a source mesh by moving its vertices accordingly to a bezier curve.
  5. // How to create a spline object?
  6. Menu -> GameObject -> 3D Object -> Spline
  7. - or -
  8. on any object, add the Spline component
  9. // How to draw a spline?
  10. select an object with Spline component (and make sure the component is expanded)
  11. a basic 2-nodes spline is created by default
  12. select a node and move it
  13. when a node is selected, the directions appear. Select one of them and move it
  14. use the add button in the inspector to insert a node in the spline, directly after the selected one
  15. use the delete button in the inspector to delete the selected node (you can't have less than two nodes)
  16. // How to bend a mesh?
  17. add the SplineMeshTiling component along with Spline
  18. set the mesh, a material and an optional transform to apply to the mesh
  19. SplineMeshTiling can bend meshes in a number of ways. Here are some examples:
  20. - one mesh fitting each curve,
  21. - a single mesh stretched along the spline,
  22. - as many meshes as possible in the length of the spline,
  23. - a single mesh stretched in a specific interval [start, end] along the curve.
  24. SplineMeshTiling covers 80% of the use cases but you will most likely reach limitations. Every use case is unique and you may need to write you own
  25. script. SplineMesh is designed for this pupose, and you should be able to exapand the SplineMeshTiling or the other examples to fit you need.
  26. // What else can I do?
  27. roads, snake, tentacle, footprint track, tunnels, walls, caves, coconut tree trunks...
  28. SplineMesh can also simply place GameObjects along a spline: lamps on the side of a road, asteroids around a planet, leafs in a wind stream, bat trajectory, action camera...
  29. you can add the AutoSmoother component to automaticaly find a smooth direction for the nodes.
  30. you can bake lighting safely on bent meshes by unchecking UpdateInPlayMode option.
  31. you can generate a MeshCollider as well
  32. Troubleshooting :
  33. - I can't see my bent mesh at all
  34. Try changing the scale of your mesh in SplineMeshTiling for another order of magnitude. It can be either to small, or to big to be seen
  35. - My mesh is not bent smoothly
  36. Your mesh probably lack vertices along the axis to bend : SplineMesh doesn't add vertices to the mesh, it only move existing ones.
  37. Try adding vertices on the mesh along the axis to bend
  38. Try to have more smaller curves on your spline
  39. - My MeshCollider is not updated
  40. MeshColliders are computationaly intensive and need baking. It is not reasonbly possible to update such a collider each frame.
  41. Try replace your MeshCollider by sowing primitive colliders that fit in the shape.
  42. - My mesh seems broken
  43. The MeshBender only bend along X axis. Your mesh is probably not oriented this way. You can specify a rotation (see ExemplePipe)
  44. - My mesh is twisted
  45. When the curve goes vertical, you will encounter a gimbal lock effect. That means that in this configuration, Y and X axis are merged and SplineMesh can't decide
  46. which direction is the "up". By default, the world up is used. In gimbal lock situations (looping for example), you can display the up vector and specify a value.
  47. See the bridge in the showcase scene for an example.
  48. - Mesh or extrusion generation is slow in the editor
  49. More vertices means less performances. Try to reduce the vertex count.
  50. Very long splines can lead to performance issues too. Try many splines with less nodes.