00001 /* 00002 ** TP 4ETI CPE Lyon 00003 ** Copyright (C) 2011 Damien Rohmer 00004 ** 00005 ** This program is free software: you can redistribute it and/or modify 00006 ** it under the terms of the GNU General Public License as published by 00007 ** the Free Software Foundation, either version 3 of the License, or 00008 ** (at your option) any later version. 00009 ** 00010 ** This program is distributed in the hope that it will be useful, 00011 ** but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 ** GNU General Public License for more details. 00014 ** 00015 ** You should have received a copy of the GNU General Public License 00016 ** along with this program. If not, see <http://www.gnu.org/licenses/>. 00017 */ 00018 00019 00020 00021 #ifndef _RENDER_ENGINE_HPP_ 00022 #define _RENDER_ENGINE_HPP_ 00023 00024 00025 #include <v3.hpp> 00026 #include <v3_shaded.hpp> 00027 00028 00029 namespace cpe 00030 { 00031 class image_drawable_zbuffer; 00032 class mesh; 00033 00034 struct triangle_shaded; 00035 00036 00038 class render_engine 00039 { 00040 public: 00041 00042 // ********************************************* // 00043 // ********************************************* // 00044 // RENDER HELPER 00045 // ********************************************* // 00046 // ********************************************* // 00047 00054 static void render_triangle(const triangle_shaded& tri,const shading_parameters& shading_param,const light_parameters& light,image_drawable_zbuffer *im); 00055 00062 static void render_mesh(const mesh& m,const shading_parameters& shading_param,const light_parameters& light,image_drawable_zbuffer *im); 00063 00064 00065 // ********************************************* // 00066 // ********************************************* // 00067 // PROJECTION HELPER 00068 // ********************************************* // 00069 // ********************************************* // 00070 00072 static v3 project(const v3& x); 00073 00074 }; 00075 00076 00081 struct triangle_shaded 00082 { 00083 // ********************************************* // 00084 // ********************************************* // 00085 // Constructor 00086 // ********************************************* // 00087 // ********************************************* // 00088 00090 triangle_shaded(const v3& _x0,const v3& _x1,const v3& _x2, 00091 const v3& _n0,const v3& _n1,const v3& _n2, 00092 const color& _c0,const color& _c1,const color& _c2) 00093 :x0(_x0),x1(_x1),x2(_x2),n0(_n0),n1(_n1),n2(_n2),c0(_c0),c1(_c1),c2(_c2){} 00094 00095 // ********************************************* // 00096 // ********************************************* // 00097 // Vertex position 00098 // ********************************************* // 00099 // ********************************************* // 00100 const v3& x0; 00101 const v3& x1; 00102 const v3& x2; 00103 00104 // ********************************************* // 00105 // ********************************************* // 00106 // Normal data 00107 // ********************************************* // 00108 // ********************************************* // 00109 const v3& n0; 00110 const v3& n1; 00111 const v3& n2; 00112 00113 // ********************************************* // 00114 // ********************************************* // 00115 // Color data 00116 // ********************************************* // 00117 // ********************************************* // 00118 const color& c0; 00119 const color& c1; 00120 const color& c2; 00121 }; 00122 } 00123 00124 #endif