Announcement

Collapse
No announcement yet.

Best way to create a tube

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Best way to create a tube

    I wanted to fill up my tool bar with more standard model types and a tube would be next.
    First I thought that Tmeshbuffer.Disc might have a value for an inner radius, but it seems not.

    Then I looked at the extrusion method which can be easily used to create a tube model by using 2 circles, but I dont see any way to adjust the number of sections for the extrusion or steps for the circles in Pathbuilder. So the result seems to have a high polygon count by default.

    Would using the lineto method to manually create a circle path result in the same number of vertices in the extruded model later? Basically a manual circle method where I can adjust the number of steps?

    Take care, Ben.

  • #2
    TMeshBuffer.Disc has "AInitRadius" parameter with the value in range [0, 1], defining where the disc actually starts. However, it is better to use "CylinderCaps" function, which also has similar parameter. Therefore, for a tube, you would use two cylinders and "cylinder caps". For the inner cylinder, remember to change the winding of the indices (last boolean parameter) and you may need to invert the normals as well using InvertNormals function (for the "first vertex" and "vertex count" parameters, make sure to save existing vertex count from TMeshBuffer before creating cylinder).

    The whole idea of "cylinder" and "cylinder caps" functions is that you can apply a bending angle, to make a coupling between two tubes.

    You can also achieve similar result using extrusion, but it's more complicated. "Circle" uses an approximation with curves, so the number of subdivisions will be determined dynamically by the extrusion function. Instead, as you correctly pointed out, you can manually create circle using "MoveTo" and "LineTo" functions, to explicitly control the segments.

    Comment


    • #3
      Ah... I thought I checked the AInitRadius value which I kinda did.. but only for the bottom disc and I simply didnt see the effect. Yeah that works. I cannot find the Cylindercaps function though.

      For each Cylinder or Cube I use two meshes, one for top and bottom and one for the sides or in case of a cylinder the caps (discs) are a second mesh. This way I can assign different textures to them in the editor.

      Comment

      Working...
      X