How to Draw a 3d House in Opengl TUTORIAL
In this article, we will have a await at project that is i of the nigh complete projects I have seen to kickoff 3D programming from scratch. We will see the project overview, interesting objects and list the openGL topics covered by this project.
- Download source code - 1.two MB
Introduction
Eight years agone, I was trying to enter the 3D programming world. I was studying NEHE tutorials but due to its complication, I quit like 3 times. The tutorials were written in C++ and were sometimes very hard to understand. Then I came across this project. I have to say this is i of the most complete projects I have seen to commencement 3D programming from scratch.
In the project, you volition see a business firm with everything inside. But the astonishing function of it is that everything is done by lawmaking. That means that the project doesn't load any 3D object. Information technology just creates them at runtime. In that location is no 3D engine used so you get to see how most of the code looks that is used to make cameras, object interaction, collisions, amongst others. The programmers made all the objects just by combining elementary OpenGL primitives.
Projection Overview
The project language is coded in C# using TAO namespace. TAO is a library that maps all OpenGL functions to .NET. In this mode, you will exist using OpenGL from the .Cyberspace sandbox. The project is very modular. That means that every object is almost standalone. Each object actually contains all its own working logic so you won't go lost with too many dependencies across the project. The main grade is primary.cs so you tin can kickoff discovering the project from at that place.
This is a code example of the main.cs. You can see how objects are added to the scene during runtime.
public MainClass(string[] args) { GlControl ViewPort = new GlControl(Width,Height); GlObjectList earth = new GlObjectList(); world.Add(new LightSource()); #if !testingObjects world.Add(new TranslatedObject(new Point3D(0,-ten,0),new SkyBox())); GlObjectList casa = new GlObjectList(); casa.Add(new Casa2()); casa.Add(new Librero(new Point3D(210,0,-318),0)); casa.Add together(new Librero(new Point3D(210,Librero.Height+.three,-316),-3)); casa.Add(new Lamp(new Point3D(threescore,270,190),70)); casa.Add(new Refrigerador(new Point3D(-145,0,120),180)); Plantilla obj = new Mesita(new Point3D(80,0,40),90); casa.Add(obj); casa.Add together(new Idiot box(new Point3D(80,obj.Height+.2,lx),0)); casa.Add(new Cama(new Point3D(370,0,-250),0,100,70)); casa.Add together(new Cama(new Point3D(370,0,-480),0,100,60)); casa.Add(new Cama(new Point3D(-210,0,-420),0,ninety,40)); casa.Add together(new Estante(new Point3D(-210,170,-108))); obj = new Mesa(new Point3D(380,0,200)); casa.Add(obj); casa.Add together(new Silla(new Point3D(440,0,160))); casa.Add(new Silla(new Point3D(440,0,240))); casa.Add(new Silla(new Point3D(330,0,160),180)); casa.Add together(new Silla(new Point3D(330,0,240),180)); casa.Add(new Silla(new Point3D(385,0,110),90)); casa.Add together(new Silla(new Point3D(385,0,290),-90)); casa.Add(new Plato(new Point3D(380,obj.Height+.ii,200))); casa.Add together(new Vaso(new Point3D(380,obj.Elevation+.two,230))); casa.Add(new MesitaDeNoche(new Point3D(455,0,-140),-90)); casa.Add together(new MesitaDeNoche(new Point3D(455,0,-380),-90)); casa.Add(new MesitaDeNoche(new Point3D(455,0,-580),-ninety)); casa.Add(new MesitaDeNoche(new Point3D(-280,0,-340),ninety)); obj = new EstanteHorizontal(new Point3D(330,0,-seventy),180); casa.Add(obj); casa.Add(new Butaca(new Point3D(-30,0,200),90,ii)); casa.Add(new Butaca(new Point3D(200,0,270),250,1)); casa.Add(new Butaca(new Point3D(200,0,110),-70,one)); casa.Add(new MesetaConFregadero(new Point3D(-307,0,-64),0)); casa.Add(new Clock(new Point3D(485,200,325),270)); GlObject c = new TranslatedObject(new Point3D(0,0,-seventy),casa); world.Add(c);
Comments
Post a Comment