Announcement

Collapse
No announcement yet.

Simple Delphi Example for Building Frames

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

  • Simple Delphi Example for Building Frames

    Greetings!

    I came across the Afterwarp library and am really excited to use it for my building structural analysis software. However, after going through the demos, I could not find a sample that builds a building frame, purely using code.

    I am willing to financially support Afterwarp, whatever little way I can, on a regular basis. After months of searching and trials with other non-delphi solutions, my heart tells me this is what I need!

    Could you please provide a Delphi example of creating a simple building frame made up of columns, beams and a slab?

    Best regards to the developers of Afterwarp!

  • #2
    Thanks for writing to us and feedback!

    I've attached a simple example that shows how to use geometric meshes to draw simple slabs, columns and beams. This is really a quick "crude" mock-up of some skeleton, with a bit of additional effort it would be possible to add more detail. If you are going to generate 3D meshes using just code, it might be worthwhile creating dedicated parametrized functions for specific sections like slabs and columns. You also didn't mention if you need glass, which could also be fairly easy to add, or alternatively, for certain visualizations, the whole scene can become semi-transparent.

    Please let me know if this is close to what you described.
    Attached Files

    Comment


    • #3
      Thank you so much for the wonderful example! This is exactly what I was looking for.

      I am a Structural Engineer with 33+ years of experience in Buildings, Steel Stacks, Pressure Vessels, Communication Towers and Bridges. I have nearly 28 years of experience in Delphi but never attempted anything on the 3D graphics front until now. My objective it to visualize the structure and its components based on geometrical data; interact with selected components of the structure to query design outcome; change shape or local orientation of members and so on.

      I have a solid understanding of 2D/3D geometry related math. Can you please suggest some references that would help me understand the terms associated with the 3D graphics journey in Delphi + Afterwarp and the required concepts to get started?

      Best regards.

      Comment


      • #4
        Working in 3D may "feel" scarier than what it really is, so the first bit of advice - do not get intimidated by it, just start using it to get things done and gradually you'll be getting better understanding of the numerous techniques and effects. I would suggest reinforcing the understanding of 3D math, specifically how transformation matrices work. There are many books on this subject, among my favorites is "3D Math Primer for Graphics and Game Development" by Fletcher Dunn and Ian Parberry (2002 edition) that I would definitely recommend.

        Specific to Afterwarp, it is important to understand that it mostly uses left-handed coordinate system, that is, a Z coordinate of 100 means that the object is in front of you at distance of 100 units. In contrast, right-handed coordinate system (which Afterwarp also supports, but such support is experimental), the same would be for Z coordinate of -100 (other X and Y coordinates are the same for both systems). In regards to projection matrices, Afterwarp uses "reverse depth" concept, where "near" and "far" planes are exchanged to provide better distribution of floating-point precision. If you use Afterwarp's 3D math functions, this is taken into account automatically, but if you use formulas from the books, this is something to be aware of. You can also use orthographic projection, which can be quite useful to render objects on schematics.

        In Afterwarp, important concepts would be a) "MeshBuffer" - a buffer in system memory containing information about 3D mesh, b) "MeshModel" - a buffer in GPU memory that is ready to be visualized, c) "SceneMesh" - a high-level container that stores "MeshModel" inside alongside its voxel representation and d) "ObjectModel" - a representation of 3D object hierarchy in the scene, which is used for visibility detection, object selection and intersection tests. Afterwarp also has lower-level concepts such as "Buffer", which can be vertex, index or compute buffers, but these are for advanced uses.

        A simple workflow is to build 3D mesh representation in system memory inside "MeshBuffer" either by filling vertices and indices yourself, or using Afterwarp's geometric primitives, as shown in above example. There are many types of geometries to choose from and some can be quite powerful. One example would be "cylinder", which has parameters for bending and lateral rotation, along with "super-circle" shape parameters, so you can create both round and square-shaped rods, bolts, tube couplings and so on. You can place multiple geometries in the same "MeshBuffer", using "Transform" property to accommodate each element where needed. Then, once the geometry is ready, you can create a "SceneMesh" out of it like in above example - this is mostly a read-only object that can be rendered. Once you have a collection of "SceneMesh" objects, you can create "ObjectModel" representations. "ObjectModel" can be seen as an object in 3D space, for which you can define size, color, transformation matrix and so on. "ObjectModel" can be parented to another "ObjectModel", thus creating parent-child relationship: moving parent would also move all of its children. By default, "ObjectModel" uses object origin located in bottom center of 3D mesh, but you can change this convention for each object. You can use "Payload" to associate "ObjectModel" with some Delphi class (for example, your own TStructureObject class), so you can quickly obtain "ObjectModel" for a particular class and vice-versa. For more advanced uses, you can use object's layers to make some objects visible on some specific layers, adjust "depth bias" to affect the priority of objects when doing object selection, assign custom "Model" and "Volume" matrices, which can change how object is viewed and picked and so on.

        In either case, I would suggest just using existing examples as templates, modifying them as needed to accommodate for what you need to render. Should you have any questions, just feel free to ask.

        Comment


        • #5
          Thank you for your very encouraging words! I am in. I do have a hard copy of this specific reference title. As you have suggested, I will experiment with existing examples, modify their code to see the impact and come back again for help.

          Best regards.

          Comment

          Working...
          X