Results 1 to 10 of 10

Thread: hollow tube with wall thickness

  1. #1
    Newbie Newbie
    Join Date
    Sep 2016
    Posts
    4

    hollow tube with wall thickness

    hi,
    i am very new to open gl programming and need to create a straight tube with a certain wall thickness. from 3dsmax i would think to create two cylinders with different radii and boolean subtract the narrow one from the wide one. i also read about creating a circle und extruding it along a path.
    what would be the best way and can someone give me a code example? i will have to create hundreds of tubes on one canvas, so efficiency is quite important.
    thank you!

  2. #2
    Senior Member Regular Contributor
    Join Date
    May 2016
    Posts
    477
    Quote Originally Posted by mael15 View Post
    hi,
    i am very new to open gl programming and need to create a straight tube with a certain wall thickness. from 3dsmax i would think to create two cylinders with different radii and boolean subtract the narrow one from the wide one.
    sure, but openGL is a graphics API, not a modelling software
    what you have to do is to provide the vertices of the tube yourself, for example you model a tube (in blender, 3dsmax or whatever) and export it into a file format from which you are able to load the vertices (for example .obj)
    then put those vertices into a "buffer object", create a "vertex aray object" and a "program object" (shaders), then you can render the tube
    "instanced rendering" is a way to render effciently the same model multiple times

  3. #3
    Newbie Newbie
    Join Date
    Sep 2016
    Posts
    4
    Quote Originally Posted by john_connor View Post
    you model a tube (in blender, 3dsmax or whatever) and export it into a file format from which you are able to load the vertices (for example .obj)
    thank you, i just mentioned 3dsmax as an example for how i know an object might be constructed. i do not plan to use any modelling software with opengl.
    what i want to do is enable my program to visualize a bundle of hundreds of tubes. tubes of one bundle all have the same diameter, wall thickness and length, but another bundle might have different tubes. so i have to custom create the tubes for every bundle. additionally, every tube will get its individual texture.
    so what is the best way?

  4. #4
    Senior Member Regular Contributor
    Join Date
    Jul 2012
    Posts
    459
    Just do that the same than with your modeler. Maths are not that complicated. It's just two disks, and you just join each vertex of the two disks. Then join the vertices of the inner and outter cylinders.

    Here I found an old topic about this. It uses fixed-pipeline OpenGL but it will be easy to adapt it to use VBOs if needed.

  5. #5
    Newbie Newbie
    Join Date
    Sep 2016
    Posts
    4
    Quote Originally Posted by Silence View Post
    Then join the vertices of the inner and outter cylinders.
    ok, thank you, and with "join" you mean put everything between glBegin(GL_TRIANGLE_STRIP) and glEnd()? sorry, but i am VERY new to this.

  6. #6
    Senior Member Regular Contributor
    Join Date
    May 2016
    Posts
    477
    Quote Originally Posted by mael15 View Post
    ok, thank you, and with "join" you mean put everything between glBegin(GL_TRIANGLE_STRIP) and glEnd()? sorry, but i am VERY new to this.
    "join" means how you create "primitives" (like triangles of quads)
    GL_QUADS gives you a quad for each 4 vertices
    GL_TRIANGLE_STRIP gives you a triangle for the first 3 vertices, then for each addidional vertex

    i would recommend you to first understand 2D rendering (simple triangle / quad / line / etc), then make a simple 3D task (cube with camera)
    after you have understood these basic things, it is just a "math problem" to make a tube (a simple for-loop), you just have to calculate the "corner points" of the tube (inner and outer circle points), but them into a buffer an issue a drawcall

    http://www.opengl-tutorial.org/begin...irst-triangle/

  7. #7
    Senior Member OpenGL Guru
    Join Date
    Jun 2013
    Posts
    3,104
    Find a tutorial (or book) on modern OpenGL (using shaders and VBOs) rather than legacy OpenGL (glBegin/glEnd).

    If you're rendering many of these tubes, instanced rendering is likely to be useful, and you can't do that with the legacy approach.

  8. #8
    Senior Member Regular Contributor
    Join Date
    Apr 2012
    Location
    Los Angeles
    Posts
    394
    Quote Originally Posted by mael15 View Post
    thank you, i just mentioned 3dsmax as an example for how i know an object might be constructed. i do not plan to use any modelling software with opengl.
    what i want to do is enable my program to visualize a bundle of hundreds of tubes. tubes of one bundle all have the same diameter, wall thickness and length, but another bundle might have different tubes. so i have to custom create the tubes for every bundle. additionally, every tube will get its individual texture.
    so what is the best way?
    So each individual tube is straight, not bent like a strand of hair?

    If you have a starting program written in Legacy GL, post the code, and I'll help you.

    This is not that hard.

  9. #9
    Senior Member Regular Contributor
    Join Date
    Jul 2012
    Posts
    459
    Quote Originally Posted by mael15 View Post
    ok, thank you, and with "join" you mean put everything between glBegin(GL_TRIANGLE_STRIP) and glEnd()? sorry, but i am VERY new to this.
    Exactly. You just swap from one cylinder vertex to the other cylinder vertex until you reach the first point again.

  10. #10
    Newbie Newbie
    Join Date
    Sep 2016
    Posts
    4
    thank you everyone! i think i am on my way now. my boss just changed the requirements from "hollow tube" to "plain cylinders" but it is good to know how a hollow tube with a specific wall thickness can be made

    Quote Originally Posted by GClements View Post
    If you're rendering many of these tubes, instanced rendering is likely to be useful, and you can't do that with the legacy approach.
    that sounds very helpful and i will look into that.

    Quote Originally Posted by Carmine
    If you have a starting program written in Legacy GL, post the code, and I'll help you.
    that is very kind, thank you. i think i can handle it

Similar Threads

  1. Hollow Cylinder?
    By Feenixb1o7 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 11-05-2012, 03:07 PM
  2. Hollow texture
    By stenio in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 10-28-2011, 10:04 AM
  3. Hollow 3d Texture
    By Tomy in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 03-27-2005, 07:38 AM
  4. Thickness
    By ^DaNiEl^ in forum OpenGL: Advanced Coding
    Replies: 5
    Last Post: 10-08-2004, 10:20 AM
  5. hollow sphere
    By dj_indo_420 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 12-08-2003, 10:11 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean