Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: how to create house - which shape

  1. #1
    Newbie Newbie
    Join Date
    May 2018
    Posts
    1

    how to create house - which shape

    Hello,
    for my final work I have to create a 3D house - 3D model with textures. Something like this
    http://appliedarts.net/blog/wp-conte...Rear-Large.jpg

    I've read a few articles how to create 3D model, but I still don't know which shape use to as the basic shape for every part of the house?

    Should I use triangles, rectangles or cubes?

    If I use triangles it will be hundreds or thousands triangles?

    Which is the best way to do this 3D model?

    thanks

  2. #2
    Junior Member Newbie
    Join Date
    May 2018
    Posts
    3
    Quote Originally Posted by Leboww View Post
    Hello,
    for my final work I have to create a 3D house - 3D model with textures. Something like this
    http://appliedarts.net/blog/wp-conte...Rear-Large.jpg

    I've read a few articles how to create 3D model, but I still don't know which shape use to as the basic shape for every part of the house?

    Should I use triangles, rectangles or cubes?

    If I use triangles it will be hundreds or thousands triangles?

    Which is the best way to do this 3D model?

    thanks
    I'm not expert in the OpenGL, but I had readed about making 3d models in special programms (like: maya 3D, blender, 3ds max),
    and then load its from file (exists c/c++ libraries for import 3d models)

  3. #3
    Member Regular Contributor
    Join Date
    Apr 2012
    Location
    Los Angeles
    Posts
    394
    What kind of class is this project for?

  4. #4
    Junior Member Newbie
    Join Date
    May 2018
    Posts
    9
    Should I use triangles, rectangles or cubes?
    Triangles are ideal for what you want to do. More specifically - triangle strips.

    If I use triangles it will be hundreds or thousands triangles?
    That's not the case. Actually, all the primatives you mentioned above are made of triangles... except a triangle.
    A quad or rectangle is made up of two triangles. A cube - 2 triangles each side - 12.


    For starters if you need a good guide, (there are many out there, but...) I like these two -
    Texturing:
    https://learnopengl.com/Getting-started/Textures
    https://open.gl/textures

    Build a house (at least one side):
    https://learnopengl.com/Advanced-OpenGL/Geometry-Shader

    Running through these tutorials, you will learn how to create and use shaders, including the geometry shader - which you'll need.

    Next, you will need to have a means of knowing where your vertices for building your house are positioned. I can think of a few ways, but since I haven't started to implement those, we can take the easy way out.
    I threw together a simple "house", if it can be called such (it's just for the purpose of demonstration), and retrieved the vertex coordinates.
    To do this, all you need is a 3d modeler - Blender, Wings, etc. (I used Gmax). Build your model. Export it to an .obj file. Open the file in Notepad, and copy the vertex points to selective text files (remove the letters). So for example :
    In a folder named "house" (actually, you can try these. I haven't tested them)
    chimney.txt
    56.7521 4.78635 58.8034
    73.1624 4.78635 58.8034
    56.7521 17.094 58.8034
    73.1624 17.094 58.8034
    56.7521 4.78635 52.1282
    73.1624 4.78635 52.1282
    73.1624 17.094 44.7436
    56.7521 17.094 44.7436

    houseSiding1.txt
    75.0 -25.0 0.0
    75.0 25.0 0.0
    75.0 -25.0 40.0
    75.0 25.0 40.0
    75.0 1.90735 55.0

    houseSiding2.txt
    -75.0 -25.0 0.0
    -75.0 25.0 0.0
    -75.0 -25.0 40.0
    -75.0 25.0 40.0
    -75.0 3.8147 55.0

    houseSiding3.txt
    -75.0 25.0 0.0
    75.0 25.0 0.0
    -75.0 25.0 40.0
    75.0 25.0 40.0
    -9.57265 25.0 1.36752
    7.52137 25.0 1.36752
    7.52137 25.0 31.453
    -9.57265 25.0 31.453
    -58.1197 25.0 12.3077
    -40.3419 25.0 12.3077
    -40.3419 25.0 19.5356
    -40.3419 25.0 32.1368
    -58.1197 25.0 32.1368
    -58.1197 25.0 30.0328

    houseSiding4.txt
    -75.0 -25.0 0.0
    75.0 -25.0 0.0
    -75.0 -25.0 40.0
    75.0 -25.0 40.0

    roofA.txt
    -80.0 -0.0343582 56.2923
    80.0 -0.0343566 56.2923
    -80.0 33.17 37.1412
    80.0 33.17 37.1412

    roofB.txt
    -80.0 0.0343636 56.2923
    80.0 0.034348 56.2923
    -80.0 -33.1699 37.1412
    80.0 -33.17 37.1412

    Next, you need a way to read these files into float arrays, so that you can input them into your geometry shader via code, otherwise you have to manually input them by hand, which is a lot of work to build the house in your image. I'm sure you'll have fun creating code to do all this. Let me know if you want a push start.

    Basically though, you just need a way to plot out your vertices, and then write a code that inputs them in your geometry shader.

    All the best.

  5. #5
    I made a simple house in Blender, textured it in GIMP, exported it to .obj format, imported it to a program written in Python/GLFW/OpenGL 3.3

    See the tutorial: Modern OpenGL programming in Python

    You can rewrite the code to any language because OpenGL programs look the same in any languages.

    Source Code: house.zip

    Last edited by 8Observer8; 06-01-2018 at 01:52 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
  •