Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Need a 3d shape class

Need a 3d shape class

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
7 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    anderslundsgard
    wrote on last edited by
    #1

    I’m working on a project using VRML to show 3d shapes of all kinds. I now search a class (or tips of how to create one) to represent an arbitary shape. For e.g. se this pic: http://www.ceco.se/xsim/ape/BoxWithSubtractionBox.GIF One shape could for e.g. be a wall (a regular box). Later the wall could have a window. Perfect would be if I in some way could create one box and later subtract one or many smaller shapes (the windows and doors) whenever I want. For creating the VRML it then would be good to retrieve the outside areas of the shape (the connection of all corners). All tips are welcomed. _____________________________ ...and justice for all APe

    V J C V 4 Replies Last reply
    0
    • A anderslundsgard

      I’m working on a project using VRML to show 3d shapes of all kinds. I now search a class (or tips of how to create one) to represent an arbitary shape. For e.g. se this pic: http://www.ceco.se/xsim/ape/BoxWithSubtractionBox.GIF One shape could for e.g. be a wall (a regular box). Later the wall could have a window. Perfect would be if I in some way could create one box and later subtract one or many smaller shapes (the windows and doors) whenever I want. For creating the VRML it then would be good to retrieve the outside areas of the shape (the connection of all corners). All tips are welcomed. _____________________________ ...and justice for all APe

      V Offline
      V Offline
      V 0
      wrote on last edited by
      #2

      Divide it in smaller shapes. They call it meshing I think. It's an intensive operation, but afterwards you can do virtually anything with it. (cutting, bending, translations ...) Try searching on meshing or something? Hope this helps a little. "If I don't see you in this world, I'll see you in the next one... and don't be late." ~ Jimi Hendrix

      1 Reply Last reply
      0
      • A anderslundsgard

        I’m working on a project using VRML to show 3d shapes of all kinds. I now search a class (or tips of how to create one) to represent an arbitary shape. For e.g. se this pic: http://www.ceco.se/xsim/ape/BoxWithSubtractionBox.GIF One shape could for e.g. be a wall (a regular box). Later the wall could have a window. Perfect would be if I in some way could create one box and later subtract one or many smaller shapes (the windows and doors) whenever I want. For creating the VRML it then would be good to retrieve the outside areas of the shape (the connection of all corners). All tips are welcomed. _____________________________ ...and justice for all APe

        J Offline
        J Offline
        Johann Gerell
        wrote on last edited by
        #3

        This is a task that might grow exponentially in complexity as new 3D shapes are added. If you haven't read up on 3D scenery data structure modeling, now is a good time to do so. I don't know if there such a class, but what you'll need the following: 1. Track all vertices. 2. Track all edges. 3. Track all faces. Also, 4. Define what characteristics a face can have (flat, convex, concave, etc.) 5. Define where the interior and exterior of a face is and what their characteristics are (solid, hollow, etc.) Hmmm... upon further reading of your question, I realize that you already most likely know this and that you're asking for something else. Oh, well... :doh: -- The Blog: Bits and Pieces

        A 1 Reply Last reply
        0
        • J Johann Gerell

          This is a task that might grow exponentially in complexity as new 3D shapes are added. If you haven't read up on 3D scenery data structure modeling, now is a good time to do so. I don't know if there such a class, but what you'll need the following: 1. Track all vertices. 2. Track all edges. 3. Track all faces. Also, 4. Define what characteristics a face can have (flat, convex, concave, etc.) 5. Define where the interior and exterior of a face is and what their characteristics are (solid, hollow, etc.) Hmmm... upon further reading of your question, I realize that you already most likely know this and that you're asking for something else. Oh, well... :doh: -- The Blog: Bits and Pieces

          A Offline
          A Offline
          anderslundsgard
          wrote on last edited by
          #4

          Johann Gerell wrote: upon further reading of your question, I realize that you already most likely know this and that you're asking for something else. No, all thoughts that makes my brain active :) are good. I sure think there is some kind of algorithm out there that make what I want. Of course the best thing is to find it out myself but don’t really know where to start. _____________________________ ...and justice for all APe

          1 Reply Last reply
          0
          • A anderslundsgard

            I’m working on a project using VRML to show 3d shapes of all kinds. I now search a class (or tips of how to create one) to represent an arbitary shape. For e.g. se this pic: http://www.ceco.se/xsim/ape/BoxWithSubtractionBox.GIF One shape could for e.g. be a wall (a regular box). Later the wall could have a window. Perfect would be if I in some way could create one box and later subtract one or many smaller shapes (the windows and doors) whenever I want. For creating the VRML it then would be good to retrieve the outside areas of the shape (the connection of all corners). All tips are welcomed. _____________________________ ...and justice for all APe

            C Offline
            C Offline
            cmk
            wrote on last edited by
            #5

            d00_ape wrote: Perfect would be if I in some way could create one box and later subtract one or many smaller shapes (the windows and doors) whenever I want. This is combining solid objects using boolean operators, also called Constructive Solid Geometry (CSG). http://www.flipcode.com/cgi-bin/msg.cgi?showThread=00008781&forum=3dtheory&id=-1[^] ...cmk Save the whales - collect the whole set

            A 1 Reply Last reply
            0
            • C cmk

              d00_ape wrote: Perfect would be if I in some way could create one box and later subtract one or many smaller shapes (the windows and doors) whenever I want. This is combining solid objects using boolean operators, also called Constructive Solid Geometry (CSG). http://www.flipcode.com/cgi-bin/msg.cgi?showThread=00008781&forum=3dtheory&id=-1[^] ...cmk Save the whales - collect the whole set

              A Offline
              A Offline
              anderslundsgard
              wrote on last edited by
              #6

              cmk wrote: Constructive Solid Geometry Thanks for that. To bad there is no article on CP. I've looked at the link. Do you have others :-O _____________________________ ...and justice for all APe

              1 Reply Last reply
              0
              • A anderslundsgard

                I’m working on a project using VRML to show 3d shapes of all kinds. I now search a class (or tips of how to create one) to represent an arbitary shape. For e.g. se this pic: http://www.ceco.se/xsim/ape/BoxWithSubtractionBox.GIF One shape could for e.g. be a wall (a regular box). Later the wall could have a window. Perfect would be if I in some way could create one box and later subtract one or many smaller shapes (the windows and doors) whenever I want. For creating the VRML it then would be good to retrieve the outside areas of the shape (the connection of all corners). All tips are welcomed. _____________________________ ...and justice for all APe

                V Offline
                V Offline
                vmaltsev
                wrote on last edited by
                #7

                I think CSG that was mentioned in previous post is too complex for your task. What you need is indeed a simple mesh object and elements of it were mentioned above as well. Let's start with a simple class for 3D point (you can call it vector if you want) with all possible geometrical manipulations like add, sub, mul, dev with point, with scalar, dot and cross products. After that you have to create a class to represent a face. If you remember geometry you know that three points in space is enough to represent a plane, so your "face" class have to include those three poins. Plus I suggest to include Normal Vector (normalized cross product of two differences between our three points, like p=b-a, q=c-a, n=cross(p,q) N=n/length(n)) which will represend visible side of a face and some props like single/double faced, shading method etc. Normal vector is very important cuz it'll help you to eliminate invisible faces on rendering stage. Another thing that we have to include in our face class is info about edges. That's all. Now to represent a normal 4-point plane you need 2 faces, so to represent a cube you need 12 faces. All boolean operation are very simple to perform on such objects. You need to solve only one equation to find points in space where two faces intersect and create new faces there. Hope it'll help.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups