Organizing the code for apartment modelling in C++ with OpenGl -
i making apartment c++ , opengl. have made basic walls, roof , floor declaring points in drawing function , of course works code messy , adding furniture way of course painful. asking how should organize objects , format drawing function?
here's current code:
// floor , roof of room 1 glbegin(gl_quads); glnormal3f(0.0, 1.0, 0.0); glcolor3f(0.0, 1.0, 1.0); glvertex3f(0.0, 0.0, 0.0); glvertex3f(1.0, 0.0, 0.0); glvertex3f(1.0, 0.0, 1.0); glvertex3f(0.0, 0.0, 1.0); glnormal3f(0.0, -1.0, 0.0); glcolor3f(0.0, 1.0, 0.0); glvertex3f(0.0, 1.0, 0.0); glvertex3f(1.0, 1.0, 0.0); glvertex3f(1.0, 1.0, 1.0); glvertex3f(0.0, 1.0, 1.0); glend(); // walls glbegin(gl_quad_strip); glnormal3f(1.0, 0.0, 0.0); glcolor3f(1.0, 1.0, 1.0); glvertex3f(0.0, 0.0, 0.0); glvertex3f(0.0, 1.0, 0.0); glcolor3f(1.0, 0.0, 0.0); glvertex3f(0.0,0.0,1.0); glvertex3f(0.0,1.0,1.0); glnormal3f(0.0, 0.0, -1.0); glcolor3f(0.0, 0.0, 1.0); glvertex3f(1.0, 0.0, 1.0); glvertex3f(1.0, 1.0, 1.0); glnormal3f(-1.0, 0.0, 0.0); glcolor3f(0.5, 0.0, 0.5); glvertex3f(1.0, 0.0, 0.0); glvertex3f(1.0, 1.0, 0.0); glend(); , on room 2 , door spots..
any places read subject?
you can use 3d modelling software, e.g. →blender define geometry etc. recommend use →assimp load exported model. recommend avoid old fixed-function pipeline – write own little scenegraph engine , manage matrices , 3d math →glm
Comments
Post a Comment