Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals   Related Pages  

brush.h

Go to the documentation of this file.
00001 // OMICRON ENGINE HEADER FILE
00002 //
00003 // --------------------------------------------------------------------------
00004 // Copyright (C) 2001-2002 by Bjoern Paetzel <kolrabi@gmx.de>
00005 //
00006 // This file is part of the Omicron Engine.
00007 //
00008 // The Omicron Engine is free software; you can redistribute it and/or modify
00009 // it under the terms of the  GNU General Public License  as published by the
00010 // Free Software Foundation;  either version  2  of the License,  or (at your
00011 // option) any later version.
00012 //
00013 // The Omicron Engine  is distributed in the hope that it will be useful, but
00014 // WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00015 // or  FITNESS FOR A PARTICULAR PURPOSE.  See the  GNU General Public License
00016 // for more details.
00017 //
00018 // You should have  received a copy of the  GNU General Public License  along
00019 // with The Omicron Engine;  if not,  write to the  Free Software Foundation,
00020 // Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
00021 //
00022 // --------------------------------------------------------------------------
00023 // Last modified:       $Date: 2002/12/07 19:02:17 $
00024 // By           :       $Author: kolrabi $
00025 // $Id: brush.h,v 1.1.1.1 2002/12/07 19:02:17 kolrabi Exp $ 
00026 
00027 /*
00028 
00029   $Log: brush.h,v $
00030   Revision 1.1.1.1  2002/12/07 19:02:17  kolrabi
00031   initial release
00032 
00033 
00034 */
00035 
00043 #include            "vector.h"
00044 #include            "forward.h"
00045 
00046 /****************************************************************************
00047  ****************************************************************************
00048  * TYPES ********************************************************************
00049  ****************************************************************************
00050  ****************************************************************************/
00051  
00052 #if !defined(OMICRON_TYPES_BRUSH_DEFINED)
00053 #define             OMICRON_TYPES_BRUSH_DEFINED
00054 
00055 #define             BIGPOLYSIZE         1000
00056 
00062 class brushface_c
00063 {
00064 protected:
00065 
00066     ulong           vertexcount;        
00067     vertex_t        *vertices;          
00068 
00069     plane_t         plane;              
00070 
00071     const struct shader_s *
00072                     shader;             
00073     vec2_c          scale, offset;      
00074     float           rotation;
00075 
00076     void                                
00077         createvertices();
00078 
00079 public:
00080 
00082     // ctor, dtor
00083 
00084                     brushface_c();
00085                     ~brushface_c();
00086 
00088 
00093     void
00094         create_from_plane(const plane_t *p);
00095 
00101     bool
00102         cut(const plane_t *p);
00103 
00104     inline ulong                        
00105         get_vertex_count();
00106 
00107     inline const vertex_t *             
00108         get_vertices();
00109 
00110     inline vec3_c                       
00111         get_normal();
00112 
00113     inline const plane_t *              
00114         get_plane();
00115 
00121     void
00122         get_vertex(ulong num, vertex_t *out);
00123 
00130     void
00131         get_edge(ulong num, edge_t out);
00132 
00133     inline void                         
00134         set_shader(const struct shader_s *_shader);
00135 
00136     inline const struct shader_s *      
00137         get_shader();
00138 
00143     void
00144         set_tex_params(const vec2_t scale, const vec2_t offset, float rot);
00145 
00147     void
00148         draw();
00149         
00150 };
00151 
00153 // inlines
00154 
00156 inline ulong brushface_c::get_vertex_count()
00157 {
00158     AssertThisV;    return vertexcount;
00159 }
00160 
00162 inline const vertex_t *brushface_c::get_vertices()
00163 {
00164     AssertThisV;    return vertices;
00165 }
00166 
00168 inline vec3_c brushface_c::get_normal()
00169 {
00170     AssertThisValue(vec3_c());     
00171     return vec3_c(plane.n);
00172 }
00173 
00175 inline const plane_t *brushface_c::get_plane()
00176 {
00177     AssertThisV;    return &plane;
00178 }
00179 
00181 inline void brushface_c::set_shader(
00182     const struct shader_s *_shader      
00183 )
00184 {
00185     AssertThis;     shader = _shader;
00186 }
00187 
00189 inline const struct shader_s *brushface_c::get_shader()
00190 {
00191     AssertThisV;    return shader;
00192 };
00193 
00194 
00200 class brush_c
00201 {
00202 protected:
00203 
00204     array_c <brushface_c> *
00205                     faces;              
00206 
00207     edge_t          *edges;             
00208 
00209     ulong           edgecount;          
00210 
00211     const shader_t *shader;             
00212 
00213     void                                
00214         find_edges();
00215 
00216 public:
00217 
00219     // ctor, dtor
00220 
00221                     brush_c();
00222                     ~brush_c();
00223 
00225 
00231     void
00232         add_plane(const plane_t *p);
00233 
00238     void
00239         set_shader(const shader_t *shader);
00240 
00245     void
00246         set_face_shader(ulong face, const shader_t *shader);
00247 
00248 
00253     void
00254         draw();
00255 
00256     /*
00257     // experimental! -->
00258     void                                
00259         ray_collide(const vec3_t p1, const vec3_t p2, collision_t *out);
00260 
00261     void                                
00262         box_collide(const bbox_t *bbox, collision_t *out);
00263     // <-- experimental!
00264     */
00265 
00271     brushface_c *
00272         get_brush_face
00273     (
00274         ulong       i                   
00275     )
00276     {
00277         AssertThisV;
00278 
00279         return faces->get(i); 
00280     }
00281 };
00282 
00283 #endif

Generated on Wed Dec 18 15:48:46 2002 for omicron engine by doxygen1.2.18