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:06 $ 00024 // By : $Author: kolrabi $ 00025 // $Id: m_view.cpp,v 1.1.1.1 2002/12/07 19:02:06 kolrabi Exp $ 00026 00027 /* 00028 00029 $Log: m_view.cpp,v $ 00030 Revision 1.1.1.1 2002/12/07 19:02:06 kolrabi 00031 initial release 00032 00033 00034 */ 00035 00040 #include "omicron/internal.h" 00041 #include "omicron/input.h" 00042 #include "omicron/render.h" 00043 00044 /**************************************************************************** 00045 **************************************************************************** 00046 * FRUSTUM ROUTINES ********************************************************* 00047 **************************************************************************** 00048 ****************************************************************************/ 00049 00050 00051 /**************************************************************************** 00052 * _view_clipsphere determine visibility for sphere * 00053 ****************************************************************************/ 00054 slong renderer_c::view_clipsphere 00055 ( 00056 const vec3_t pt, 00057 float radius 00058 ) 00059 { 00060 ulong p; 00061 00062 AssertReturnValue1(pt, 1); 00063 00064 for( p = 0; p<6; p++ ) 00065 { 00066 vec3_c tmp = gv.renderer->get_viewfrustum()[p].n; 00067 00068 if( tmp.dot(pt) - gv.renderer->get_viewfrustum()[p].d <= -radius ) 00069 return -1; 00070 else if( tmp.dot(pt) - gv.renderer->get_viewfrustum()[p].d < radius ) 00071 return 0; 00072 } 00073 00074 return 1; 00075 } 00076 00077 /**************************************************************************** 00078 * _view_clippoint determine visibility for point * 00079 ****************************************************************************/ 00080 slong renderer_c::view_clippoint 00081 ( 00082 const vec3_t in 00083 ) 00084 { 00085 vec3_t spos; 00086 vec3_c tmpv; 00087 00088 AssertReturnValue1(in, 1); 00089 00090 tmpv = vec3_c(in) - gv.renderer->get_viewpos(); 00091 00092 spos[2] = tmpv.dot(gv.renderer->get_viewdir()); 00093 00094 if (spos[2]<=0 || spos[2]>gv.renderer->get_viewdepth()) 00095 return 0; 00096 00097 // spos[0] = (float)fabs(vector_dot(tmpv, gv.renderer->get_viewright())/spos[2]); 00098 00099 // TODO: lot of stuff missing here!! 00100 00101 return 1; 00102 } 00103 00104 00105 /**************************************************************************** 00106 * _view_clipbox determine visibility for box * 00107 ****************************************************************************/ 00108 slong renderer_c::view_clipbox 00109 ( 00110 const bbox_t *bbox 00111 ) 00112 { 00113 slong v; 00114 00115 AssertReturnValue1(bbox, 0); 00116 00117 // float max = -1; 00118 00119 for( ulong p = 5; p>=0; --p ) 00120 { 00121 v = plane_clip_box(&gv.renderer->get_viewfrustum()[p], bbox); 00122 00123 if (v<0) 00124 return -1; 00125 00126 if (v==0) 00127 return 0; 00128 } 00129 00130 return 1; 00131 00132 // 1 totally visible 00133 // 0 partially visible 00134 // -1 invisible 00135 } 00136 00137
1.2.18