<html> <head> <title>OgreOctreeCamera.cpp Source File - OGRE Documentation</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <link type="text/css" rel="stylesheet" href="style.css"> </head> <body> <!-- Generated by Doxygen 1.2.16 --> <center> <a class="qindex" href="index.html">Main Page</a> <a class="qindex" href="namespaces.html">Namespace List</a> <a class="qindex" href="hierarchy.html">Class Hierarchy</a> <a class="qindex" href="classes.html">Alphabetical List</a> <a class="qindex" href="annotated.html">Compound List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="namespacemembers.html">Namespace Members</a> <a class="qindex" href="functions.html">Compound Members</a> <a class="qindex" href="globals.html">File Members</a> <a class="qindex" href="pages.html">Related Pages</a> </center> <hr><h1>OgreOctreeCamera.cpp</h1><a href="OgreOctreeCamera_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre>00001 <font class="comment">/***************************************************************************</font> 00002 <font class="comment">octreecamera.cpp - description</font> 00003 <font class="comment">-------------------</font> 00004 <font class="comment">begin : Fri Sep 27 2002</font> 00005 <font class="comment">copyright : (C) 2002 by Jon Anderson</font> 00006 <font class="comment">email : janders@users.sf.net</font> 00007 <font class="comment">***************************************************************************/</font> 00008 00009 <font class="comment">/***************************************************************************</font> 00010 <font class="comment">* *</font> 00011 <font class="comment">* This program is free software; you can redistribute it and/or modify *</font> 00012 <font class="comment">* it under the terms of the GNU Lesser General Public License as *</font> 00013 <font class="comment">* published by the Free Software Foundation; either version 2 of the * </font> 00014 <font class="comment">* License, or (at your option) any later version. *</font> 00015 <font class="comment">* *</font> 00016 <font class="comment">***************************************************************************/</font> 00017 00018 <font class="preprocessor">#include <<a class="code" href="OgreMath_8h.html">OgreMath.h</a>></font> 00019 <font class="preprocessor">#include <<a class="code" href="OgreAxisAlignedBox_8h.html">OgreAxisAlignedBox.h</a>></font> 00020 <font class="preprocessor">#include <<a class="code" href="OgreRoot_8h.html">OgreRoot.h</a>></font> 00021 00022 <font class="preprocessor">#include <<a class="code" href="OgreOctreeCamera_8h.html">OgreOctreeCamera.h</a>></font> 00023 00024 <font class="keyword">namespace </font>Ogre 00025 { <a name="l00026"></a><a class="code" href="OgreOctreeCamera_8cpp.html#a0">00026</a> <font class="preprocessor">#define POSITION_BINDING 0</font> <a name="l00027"></a><a class="code" href="OgreOctreeCamera_8cpp.html#a1">00027</a> <font class="preprocessor"></font><font class="preprocessor">#define COLOUR_BINDING 1</font> 00028 <font class="preprocessor"></font> <a name="l00029"></a><a class="code" href="namespaceOgre.html#a476">00029</a> <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> <a class="code" href="namespaceOgre.html#a476">red</a> = 0xFF0000FF; 00030 <a name="l00031"></a><a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCameraq0">00031</a> <font class="keywordtype">unsigned</font> <font class="keywordtype">short</font> OctreeCamera::mIndexes[ 24 ] = {0, 1, 1, 2, 2, 3, 3, 0, <font class="comment">//back</font> 00032 0, 6, 6, 5, 5, 1, <font class="comment">//left</font> 00033 3, 7, 7, 4, 4, 2, <font class="comment">//right</font> 00034 6, 7, 5, 4 }; <font class="comment">//front</font> 00035 <a name="l00036"></a><a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCameraq1">00036</a> <font class="keywordtype">unsigned</font> <font class="keywordtype">long</font> OctreeCamera::mColors[ 8 ] = {<a class="code" href="namespaceOgre.html#a476">red</a>, <a class="code" href="namespaceOgre.html#a476">red</a>, <a class="code" href="namespaceOgre.html#a476">red</a>, <a class="code" href="namespaceOgre.html#a476">red</a>, <a class="code" href="namespaceOgre.html#a476">red</a>, <a class="code" href="namespaceOgre.html#a476">red</a>, <a class="code" href="namespaceOgre.html#a476">red</a>, <a class="code" href="namespaceOgre.html#a476">red</a>}; 00037 <a name="l00038"></a><a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCameraa0">00038</a> OctreeCamera::OctreeCamera( <font class="keyword">const</font> <a class="code" href="classOgre_1_1String.html">String</a>& name, <a class="code" href="classOgre_1_1SceneManager.html">SceneManager</a>* sm ) : <a class="code" href="classOgre_1_1Camera.html">Camera</a>( name, sm ) 00039 { 00040 <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCameran1">mMaterial</a> = sm->getMaterial(<font class="stringliteral">"BaseWhite"</font>); 00041 00042 <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCamerao0">mVertexData</a> = <font class="keyword">new</font> <a class="code" href="classOgre_1_1VertexData.html">VertexData</a>; 00043 <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCamerao0">mVertexData</a>-><a class="code" href="classOgre_1_1VertexData.html#Ogre_1_1VertexDatam2">vertexStart</a> = 0; 00044 <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCamerao0">mVertexData</a>-><a class="code" href="classOgre_1_1VertexData.html#Ogre_1_1VertexDatam3">vertexCount</a> = 8; 00045 00046 <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCamerao1">mIndexData</a> = <font class="keyword">new</font> <a class="code" href="classOgre_1_1IndexData.html">IndexData</a>; 00047 <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCamerao1">mIndexData</a>-><a class="code" href="classOgre_1_1IndexData.html#Ogre_1_1IndexDatam1">indexStart</a> = 0; 00048 <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCamerao1">mIndexData</a>-><a class="code" href="classOgre_1_1IndexData.html#Ogre_1_1IndexDatam2">indexCount</a> = 24; 00049 00050 <a class="code" href="classOgre_1_1VertexDeclaration.html">VertexDeclaration</a>* decl = <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCamerao0">mVertexData</a>-><a class="code" href="classOgre_1_1VertexData.html#Ogre_1_1VertexDatam0">vertexDeclaration</a>; 00051 <a class="code" href="classOgre_1_1VertexBufferBinding.html">VertexBufferBinding</a>* bind = <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCamerao0">mVertexData</a>-><a class="code" href="classOgre_1_1VertexData.html#Ogre_1_1VertexDatam1">vertexBufferBinding</a>; 00052 00053 decl-><a class="code" href="classOgre_1_1VertexDeclaration.html#Ogre_1_1VertexDeclarationa3">addElement</a>(<a class="code" href="OgreOctreeCamera_8cpp.html#a0">POSITION_BINDING</a>, 0, <a class="code" href="namespaceOgre.html#a631a154">VET_FLOAT3</a>, <a class="code" href="namespaceOgre.html#a630a143">VES_POSITION</a>); 00054 decl-><a class="code" href="classOgre_1_1VertexDeclaration.html#Ogre_1_1VertexDeclarationa3">addElement</a>(<a class="code" href="OgreOctreeCamera_8cpp.html#a1">COLOUR_BINDING</a>, 0, <a class="code" href="namespaceOgre.html#a631a156">VET_COLOUR</a>, <a class="code" href="namespaceOgre.html#a630a147">VES_DIFFUSE</a>); 00055 00056 <a class="code" href="classOgre_1_1HardwareVertexBufferSharedPtr.html">HardwareVertexBufferSharedPtr</a> vbuf = 00057 HardwareBufferManager::getSingleton().createVertexBuffer( 00058 decl-><a class="code" href="classOgre_1_1VertexDeclaration.html#Ogre_1_1VertexDeclarationa9">getVertexSize</a>(<a class="code" href="OgreOctreeCamera_8cpp.html#a0">POSITION_BINDING</a>), 00059 <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCamerao0">mVertexData</a>-><a class="code" href="classOgre_1_1VertexData.html#Ogre_1_1VertexDatam3">vertexCount</a>, 00060 HardwareBuffer::HBU_STATIC_WRITE_ONLY); 00061 00062 bind-><a class="code" href="classOgre_1_1VertexBufferBinding.html#Ogre_1_1VertexBufferBindinga2">setBinding</a>(<a class="code" href="OgreOctreeCamera_8cpp.html#a0">POSITION_BINDING</a>, vbuf); 00063 00064 <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCamerao1">mIndexData</a>-><a class="code" href="classOgre_1_1IndexData.html#Ogre_1_1IndexDatam0">indexBuffer</a> = 00065 HardwareBufferManager::getSingleton().createIndexBuffer( 00066 HardwareIndexBuffer::IT_16BIT, 00067 24, HardwareBuffer::HBU_STATIC_WRITE_ONLY); 00068 00069 } 00070 <a name="l00071"></a><a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCameraa1">00071</a> OctreeCamera::~OctreeCamera() 00072 { 00073 <font class="keywordflow">if</font>(mVertexData) 00074 <font class="keyword">delete</font> <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCamerao0">mVertexData</a>; 00075 <font class="keywordflow">if</font>(mIndexData) 00076 <font class="keyword">delete</font> <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCamerao1">mIndexData</a>; 00077 } 00078 <a name="l00079"></a><a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCameraa2">00079</a> OctreeCamera::Visibility OctreeCamera::getVisibility( <font class="keyword">const</font> <a class="code" href="classOgre_1_1AxisAlignedBox.html">AxisAlignedBox</a> &bound ) 00080 { 00081 00082 <font class="comment">// Null boxes always invisible</font> 00083 <font class="keywordflow">if</font> ( bound.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa16">isNull</a>() ) 00084 <font class="keywordflow">return</font> <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCameras3Ogre_1_1OctreeCameras0">NONE</a>; 00085 00086 <font class="comment">// Make any pending updates to the calculated frustum</font> 00087 <a class="code" href="classOgre_1_1Camera.html#Ogre_1_1OctreeCamerab2">updateView</a>(); 00088 00089 <font class="comment">// Get corners of the box</font> 00090 <font class="keyword">const</font> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a>* pCorners = bound.<a class="code" href="classOgre_1_1AxisAlignedBox.html#Ogre_1_1AxisAlignedBoxa11">getAllCorners</a>(); 00091 00092 <font class="comment">// For each plane, see if all points are on the negative side</font> 00093 <font class="comment">// If so, object is not visible.</font> 00094 <font class="comment">// If one or more are, it's partial.</font> 00095 <font class="comment">// If all aren't, full</font> 00096 00097 <font class="keywordtype">int</font> corners[ 8 ] = {0, 4, 3, 5, 2, 6, 1, 7}; 00098 00099 <font class="keywordtype">int</font> planes[ 6 ] = {<a class="code" href="namespaceOgre.html#a625a130">FRUSTUM_PLANE_TOP</a>, <a class="code" href="namespaceOgre.html#a625a131">FRUSTUM_PLANE_BOTTOM</a>, 00100 <a class="code" href="namespaceOgre.html#a625a128">FRUSTUM_PLANE_LEFT</a>, <a class="code" href="namespaceOgre.html#a625a129">FRUSTUM_PLANE_RIGHT</a>, 00101 <a class="code" href="namespaceOgre.html#a625a127">FRUSTUM_PLANE_FAR</a>, <a class="code" href="namespaceOgre.html#a625a126">FRUSTUM_PLANE_NEAR</a> }; 00102 00103 <font class="keywordtype">bool</font> all_inside = <font class="keyword">true</font>; 00104 00105 <font class="keywordflow">for</font> ( <font class="keywordtype">int</font> plane = 0; plane < 6; ++plane ) 00106 { 00107 00108 <font class="keywordtype">bool</font> all_outside = <font class="keyword">true</font>; 00109 00110 <font class="keywordtype">float</font> distance = 0; 00111 00112 <font class="keywordflow">for</font> ( <font class="keywordtype">int</font> corner = 0; corner < 8; ++corner ) 00113 { 00114 distance = <a class="code" href="classOgre_1_1Camera.html#Ogre_1_1OctreeCameran16">mFrustumPlanes</a>[ planes[ plane ] ].<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planea6">getDistance</a>( pCorners[ corners[ corner ] ] ); 00115 all_outside = all_outside && ( distance < 0 ); 00116 all_inside = all_inside && ( distance >= 0 ); 00117 00118 <font class="keywordflow">if</font> ( !all_outside && !all_inside ) 00119 <font class="keywordflow">break</font>; 00120 } 00121 00122 <font class="keywordflow">if</font> ( all_outside ) 00123 <font class="keywordflow">return</font> <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCameras3Ogre_1_1OctreeCameras0">NONE</a>; 00124 } 00125 00126 <font class="keywordflow">if</font> ( all_inside ) 00127 <font class="keywordflow">return</font> <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCameras3Ogre_1_1OctreeCameras2">FULL</a>; 00128 <font class="keywordflow">else</font> 00129 <font class="keywordflow">return</font> <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCameras3Ogre_1_1OctreeCameras1">PARTIAL</a>; 00130 00131 } 00132 <a name="l00133"></a><a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCameraa3">00133</a> <font class="keywordtype">void</font> OctreeCamera::getRenderOperation( <a class="code" href="classOgre_1_1RenderOperation.html">RenderOperation</a>& op ) 00134 { 00135 std::cerr << <font class="stringliteral">"OctreeCamera::getRenderOperation\n"</font>; 00136 00137 <a class="code" href="namespaceOgre.html#a349">Real</a> * r = <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCameran0">mCorners</a>; 00138 <font class="comment">//could also project pts using inverse of 4x4 Projection matrix, but no inverse function on that.</font> 00139 <font class="comment">/*</font> 00140 <font class="comment"> Matrix4 invP =getProjectionMatrix().Inverse();</font> 00141 <font class="comment"></font> 00142 <font class="comment"> Vector3 f1(-1,-1,-1); f1 = f1*invP;</font> 00143 <font class="comment"> Vector3 f2(-1, 1,-1); f2 = f2*invP;</font> 00144 <font class="comment"> Vector3 f3( 1, 1,-1); f3 = f3*invP;</font> 00145 <font class="comment"> Vector3 f4( 1,-1,-1); f4 = f4*invP;</font> 00146 <font class="comment"></font> 00147 <font class="comment"> Vector3 b1(-1,-1,1); b1 = b1*invP;</font> 00148 <font class="comment"> Vector3 b2(-1, 1,1); b2 = b2*invP;</font> 00149 <font class="comment"> Vector3 b3( 1, 1,1); b3 = b3*invP;</font> 00150 <font class="comment"> Vector3 b4( 1,-1,1); b4 = b4*invP;</font> 00151 <font class="comment"> */</font> 00152 <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCamerab0">_getCorner</a>( r, <a class="code" href="namespaceOgre.html#a625a127">FRUSTUM_PLANE_FAR</a>, <a class="code" href="namespaceOgre.html#a625a128">FRUSTUM_PLANE_LEFT</a>, <a class="code" href="namespaceOgre.html#a625a131">FRUSTUM_PLANE_BOTTOM</a> ); r += 3; 00153 <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCamerab0">_getCorner</a>( r, <a class="code" href="namespaceOgre.html#a625a127">FRUSTUM_PLANE_FAR</a>, <a class="code" href="namespaceOgre.html#a625a128">FRUSTUM_PLANE_LEFT</a>, <a class="code" href="namespaceOgre.html#a625a130">FRUSTUM_PLANE_TOP</a> ); r += 3; 00154 <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCamerab0">_getCorner</a>( r, <a class="code" href="namespaceOgre.html#a625a127">FRUSTUM_PLANE_FAR</a>, <a class="code" href="namespaceOgre.html#a625a129">FRUSTUM_PLANE_RIGHT</a>, <a class="code" href="namespaceOgre.html#a625a130">FRUSTUM_PLANE_TOP</a> ); r += 3; 00155 <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCamerab0">_getCorner</a>( r, <a class="code" href="namespaceOgre.html#a625a127">FRUSTUM_PLANE_FAR</a>, <a class="code" href="namespaceOgre.html#a625a129">FRUSTUM_PLANE_RIGHT</a>, <a class="code" href="namespaceOgre.html#a625a131">FRUSTUM_PLANE_BOTTOM</a> ); r += 3; 00156 00157 <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCamerab0">_getCorner</a>( r, <a class="code" href="namespaceOgre.html#a625a126">FRUSTUM_PLANE_NEAR</a>, <a class="code" href="namespaceOgre.html#a625a129">FRUSTUM_PLANE_RIGHT</a>, <a class="code" href="namespaceOgre.html#a625a130">FRUSTUM_PLANE_TOP</a> ); r += 3; 00158 <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCamerab0">_getCorner</a>( r, <a class="code" href="namespaceOgre.html#a625a126">FRUSTUM_PLANE_NEAR</a>, <a class="code" href="namespaceOgre.html#a625a128">FRUSTUM_PLANE_LEFT</a>, <a class="code" href="namespaceOgre.html#a625a130">FRUSTUM_PLANE_TOP</a> ); r += 3; 00159 <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCamerab0">_getCorner</a>( r, <a class="code" href="namespaceOgre.html#a625a126">FRUSTUM_PLANE_NEAR</a>, <a class="code" href="namespaceOgre.html#a625a128">FRUSTUM_PLANE_LEFT</a>, <a class="code" href="namespaceOgre.html#a625a131">FRUSTUM_PLANE_BOTTOM</a> ); r += 3; 00160 <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCamerab0">_getCorner</a>( r, <a class="code" href="namespaceOgre.html#a625a126">FRUSTUM_PLANE_NEAR</a>, <a class="code" href="namespaceOgre.html#a625a129">FRUSTUM_PLANE_RIGHT</a>, <a class="code" href="namespaceOgre.html#a625a131">FRUSTUM_PLANE_BOTTOM</a> ); 00161 00162 <a class="code" href="classOgre_1_1Camera.html#Ogre_1_1OctreeCamerab2">updateView</a>(); 00163 00164 <a class="code" href="classOgre_1_1HardwareVertexBufferSharedPtr.html">HardwareVertexBufferSharedPtr</a> vbuf = 00165 <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCamerao0">mVertexData</a>-><a class="code" href="classOgre_1_1VertexData.html#Ogre_1_1VertexDatam1">vertexBufferBinding</a>-><a class="code" href="classOgre_1_1VertexBufferBinding.html#Ogre_1_1VertexBufferBindinga6">getBuffer</a>(<a class="code" href="OgreOctreeCamera_8cpp.html#a0">POSITION_BINDING</a>); 00166 00167 vbuf->writeData(0, 8 * <font class="keyword">sizeof</font>(<a class="code" href="namespaceOgre.html#a349">Real</a>), <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCameran0">mCorners</a>); 00168 00169 vbuf = <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCamerao0">mVertexData</a>-><a class="code" href="classOgre_1_1VertexData.html#Ogre_1_1VertexDatam1">vertexBufferBinding</a>-><a class="code" href="classOgre_1_1VertexBufferBinding.html#Ogre_1_1VertexBufferBindinga6">getBuffer</a>(<a class="code" href="OgreOctreeCamera_8cpp.html#a1">COLOUR_BINDING</a>); 00170 vbuf->writeData(0, 8 * <font class="keyword">sizeof</font>(<a class="code" href="namespaceOgre.html#a53">RGBA</a>), <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCameraq1">mColors</a>); 00171 00172 <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCamerao1">mIndexData</a>-><a class="code" href="classOgre_1_1IndexData.html#Ogre_1_1IndexDatam0">indexBuffer</a>->writeData(0, 24 * <font class="keyword">sizeof</font>(<font class="keywordtype">unsigned</font> <font class="keywordtype">short</font>), <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCameraq0">mIndexes</a>); 00173 00174 op.<a class="code" href="classOgre_1_1RenderOperation.html#Ogre_1_1RenderOperationm2">useIndexes</a> = <font class="keyword">true</font>; 00175 op.<a class="code" href="classOgre_1_1RenderOperation.html#Ogre_1_1RenderOperationm1">operationType</a> = RenderOperation::OT_LINE_LIST; 00176 op.<a class="code" href="classOgre_1_1RenderOperation.html#Ogre_1_1RenderOperationm0">vertexData</a> = <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCamerao0">mVertexData</a>; 00177 op.<a class="code" href="classOgre_1_1RenderOperation.html#Ogre_1_1RenderOperationm3">indexData</a> = <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCamerao1">mIndexData</a>; 00178 00179 <font class="comment">/* </font> 00180 <font class="comment"> rend.useIndexes = true;</font> 00181 <font class="comment"> rend.numTextureCoordSets = 0; // no textures</font> 00182 <font class="comment"> rend.vertexOptions = LegacyRenderOperation::VO_DIFFUSE_COLOURS;</font> 00183 <font class="comment"> rend.numVertices = 8;</font> 00184 <font class="comment"> rend.numIndexes = 24;</font> 00185 <font class="comment"></font> 00186 <font class="comment"> rend.pVertices = mCorners;</font> 00187 <font class="comment"> rend.pIndexes = mIndexes;</font> 00188 <font class="comment"> rend.pDiffuseColour = mColors;</font> 00189 <font class="comment"> */</font> 00190 00191 } 00192 <a name="l00193"></a><a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCamerab0">00193</a> <font class="keywordtype">void</font> OctreeCamera::_getCorner( <a class="code" href="namespaceOgre.html#a349">Real</a> *r, <a class="code" href="namespaceOgre.html#a625">FrustumPlane</a> pp1, <a class="code" href="namespaceOgre.html#a625">FrustumPlane</a> pp2, <a class="code" href="namespaceOgre.html#a625">FrustumPlane</a> pp3 ) 00194 { 00195 <font class="comment">//intersect the three planes to get a point.</font> 00196 <font class="comment">//this could be faster since we know what Z is, but showing the camera is only a debug tool...</font> 00197 00198 00199 <a class="code" href="classOgre_1_1Plane.html">Plane</a> p1 = <a class="code" href="classOgre_1_1Camera.html#Ogre_1_1OctreeCameran16">mFrustumPlanes</a>[ pp1 ]; 00200 <a class="code" href="classOgre_1_1Plane.html">Plane</a> p2 = mFrustumPlanes[ pp2 ]; 00201 <a class="code" href="classOgre_1_1Plane.html">Plane</a> p3 = mFrustumPlanes[ pp3 ]; 00202 00203 <a class="code" href="classOgre_1_1Matrix3.html">Matrix3</a> mdet ( p1.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem0">normal</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m0">x</a> , p1.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem0">normal</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m1">y</a> , p1.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem0">normal</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m2">z</a> , 00204 p2.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem0">normal</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m0">x</a> , p2.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem0">normal</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m1">y</a> , p2.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem0">normal</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m2">z</a> , 00205 p3.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem0">normal</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m0">x</a> , p3.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem0">normal</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m1">y</a> , p3.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem0">normal</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m2">z</a> ); 00206 00207 <font class="keywordtype">float</font> det = mdet.<a class="code" href="classOgre_1_1Matrix3.html#Ogre_1_1Matrix3a21">Determinant</a> (); 00208 00209 <font class="keywordflow">if</font> ( det == 0 ) <font class="keywordflow">return</font> ; <font class="comment">//some planes are parallel.</font> 00210 00211 <a class="code" href="classOgre_1_1Matrix3.html">Matrix3</a> mx ( -p1.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem1">d</a> , p1.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem0">normal</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m1">y</a> , p1.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem0">normal</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m2">z</a>, 00212 -p2.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem1">d</a>, p2.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem0">normal</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m1">y</a> , p2.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem0">normal</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m2">z</a>, 00213 -p3.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem1">d</a>, p3.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem0">normal</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m1">y</a> , p3.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem0">normal</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m2">z</a> ); 00214 00215 <font class="keywordtype">float</font> xdet = mx.<a class="code" href="classOgre_1_1Matrix3.html#Ogre_1_1Matrix3a21">Determinant</a>(); 00216 00217 <a class="code" href="classOgre_1_1Matrix3.html">Matrix3</a> my ( p1.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem0">normal</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m0">x</a>, -p1.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem1">d</a>, p1.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem0">normal</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m2">z</a>, 00218 p2.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem0">normal</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m0">x</a>, -p2.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem1">d</a>, p2.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem0">normal</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m2">z</a>, 00219 p3.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem0">normal</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m0">x</a>, -p3.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem1">d</a>, p3.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem0">normal</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m2">z</a> ); 00220 00221 <font class="keywordtype">float</font> ydet = my.<a class="code" href="classOgre_1_1Matrix3.html#Ogre_1_1Matrix3a21">Determinant</a> (); 00222 00223 <a class="code" href="classOgre_1_1Matrix3.html">Matrix3</a> mz ( p1.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem0">normal</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m0">x</a>, p1.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem0">normal</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m1">y</a>, -p1.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem1">d</a>, 00224 p2.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem0">normal</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m0">x</a>, p2.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem0">normal</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m1">y</a>, -p2.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem1">d</a>, 00225 p3.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem0">normal</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m0">x</a>, p3.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem0">normal</a>.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3m1">y</a>, -p3.<a class="code" href="classOgre_1_1Plane.html#Ogre_1_1Planem1">d</a> ); 00226 00227 <font class="keywordtype">float</font> zdet = mz.<a class="code" href="classOgre_1_1Matrix3.html#Ogre_1_1Matrix3a21">Determinant</a> (); 00228 00229 r[ 0 ] = xdet / det; 00230 00231 r[ 1 ] = ydet / det; 00232 00233 r[ 2 ] = zdet / det; 00234 00235 } 00236 <a name="l00237"></a><a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCameraa9">00237</a> <a class="code" href="namespaceOgre.html#a349">Real</a> OctreeCamera::getSquaredViewDepth(<font class="keyword">const</font> <a class="code" href="classOgre_1_1Camera.html">Camera</a>* cam)<font class="keyword"> const</font> 00238 <font class="keyword"></font>{ 00239 <a class="code" href="classOgre_1_1Vector3.html">Vector3</a> dist = cam-><a class="code" href="classOgre_1_1Camera.html#Ogre_1_1OctreeCameraa54">getDerivedPosition</a>() - this-><a class="code" href="classOgre_1_1Camera.html#Ogre_1_1OctreeCameraa54">getDerivedPosition</a>(); 00240 <font class="keywordflow">return</font> dist.<a class="code" href="classOgre_1_1Vector3.html#Ogre_1_1Vector3a22">squaredLength</a>(); 00241 } <a name="l00242"></a><a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCameraa4">00242</a> <a class="code" href="classOgre_1_1Material.html">Material</a>* OctreeCamera::getMaterial(<font class="keywordtype">void</font>)<font class="keyword"> const</font> 00243 <font class="keyword"></font>{ 00244 <font class="keywordflow">return</font> <a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCameran1">mMaterial</a>; 00245 } 00246 <a name="l00247"></a><a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCameraa5">00247</a> <font class="keywordtype">void</font> OctreeCamera::getWorldTransforms(<a class="code" href="classOgre_1_1Matrix4.html">Matrix4</a>* xform)<font class="keyword"> const</font> 00248 <font class="keyword"></font>{ 00249 xform[0] = Matrix4::IDENTITY; 00250 } 00251 <a name="l00252"></a><a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCameraa6">00252</a> <font class="keyword">const</font> <a class="code" href="classOgre_1_1Quaternion.html">Quaternion</a>& OctreeCamera::getWorldOrientation(<font class="keywordtype">void</font>)<font class="keyword"> const</font> 00253 <font class="keyword"></font>{ 00254 <font class="keywordflow">return</font> Quaternion::IDENTITY; 00255 } <a name="l00256"></a><a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCameraa7">00256</a> <font class="keyword">const</font> <a class="code" href="classOgre_1_1Vector3.html">Vector3</a>& OctreeCamera::getWorldPosition(<font class="keywordtype">void</font>)<font class="keyword"> const</font> 00257 <font class="keyword"></font>{ 00258 <font class="keywordflow">return</font> Vector3::ZERO; 00259 } <a name="l00260"></a><a class="code" href="classOgre_1_1OctreeCamera.html#Ogre_1_1OctreeCameraa8">00260</a> <font class="keyword">const</font> <a class="code" href="namespaceOgre.html#a56">LightList</a>& OctreeCamera::getLights(<font class="keywordtype">void</font>)<font class="keyword"> const</font> 00261 <font class="keyword"></font>{ 00262 <font class="comment">// N/A</font> 00263 <font class="keyword">static</font> <a class="code" href="namespaceOgre.html#a56">LightList</a> ll; 00264 <font class="keywordflow">return</font> ll; 00265 } 00266 00267 } 00268 00269 00270 00271 </pre></div><p> Copyright © 2002-2003 by The OGRE Team<br /> Last modified Wed Jan 21 00:10:19 2004 </p> </body> </html>