Changeset 1676
- Timestamp:
- 06/30/09 12:46:53 (4 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/Projects/Axiom/Source/Engine/Core/WireBoundingBox.cs
r1663 r1676 48 48 public sealed class WireBoundingBox : SimpleRenderable 49 49 { 50 #region Member variables50 #region Field and Properties 51 51 52 52 private float radius; 53 53 54 #endregion Member variables54 #endregion Field and Properties 55 55 56 56 #region Constants 57 57 58 58 const int POSITION = 0; 59 const int COLOR = 1; 60 59 61 60 #endregion Constants 62 61 … … 78 77 // add elements for position and color only 79 78 decl.AddElement( POSITION, 0, VertexElementType.Float3, VertexElementSemantic.Position ); 80 decl.AddElement( COLOR, 0, VertexElementType.Color, VertexElementSemantic.Diffuse );81 79 82 80 // create a new hardware vertex buffer for the position data … … 90 88 binding.SetBinding( POSITION, buffer ); 91 89 92 // create a new hardware vertex buffer for the color data 93 buffer = HardwareBufferManager.Instance.CreateVertexBuffer( 94 decl.GetVertexSize( COLOR ), 95 vertexData.vertexCount, 96 BufferUsage.StaticWriteOnly ); 97 98 // bind the color buffer 99 binding.SetBinding( COLOR, buffer ); 100 101 this.Material = (Material)MaterialManager.Instance[ "BaseWhite" ]; 102 103 //Material mat = MaterialManager.Instance[ "Core/WireBB" ]; 104 105 //if ( mat == null ) 106 //{ 107 // mat = MaterialManager.Instance[ "BaseWhite" ]; 108 // mat = mat.Clone( "Core/WireBB", "" ); 109 // mat.Lighting = false; 110 //} 111 112 //this.Material = mat; 90 this.Material = (Material)MaterialManager.Instance[ "BaseWhiteNoLighting" ]; 91 113 92 } 114 93 … … 123 102 public override void GetWorldTransforms( Matrix4[] matrices ) 124 103 { 104 // return identity matrix to prevent parent transforms 125 105 matrices[ 0 ] = Matrix4.Identity; 126 106 } … … 129 109 { 130 110 SetupAABBVertices( box ); 131 132 // get a reference to the color buffer133 HardwareVertexBuffer buffer =134 vertexData.vertexBufferBinding.GetBuffer( COLOR );135 136 // lock the buffer137 IntPtr colPtr = buffer.Lock( BufferLocking.Discard );138 139 // load the color buffer with the specified color for each element140 unsafe141 {142 int* pCol = (int*)colPtr.ToPointer();143 144 for ( int i = 0; i < vertexData.vertexCount; i++ )145 pCol[ i ] = Root.Instance.ConvertColor( ColorEx.Red );146 }147 148 // unlock the buffer149 buffer.Unlock();150 111 151 112 // store the bounding box locally … … 162 123 radius = Utility.Sqrt( lengthSquared ); 163 124 164 float maxx = max.x + 1.0f;165 float maxy = max.y + 1.0f;166 float maxz = max.z + 1.0f;167 168 float minx = min.x - 1.0f;169 float miny = min.y - 1.0f;170 float minz = min.z - 1.0f;125 float maxx = max.x; 126 float maxy = max.y; 127 float maxz = max.z; 128 129 float minx = min.x; 130 float miny = min.y; 131 float minz = min.z; 171 132 172 133 int i = 0; 173 134 174 HardwareVertexBuffer buffer = 175 vertexData.vertexBufferBinding.GetBuffer( POSITION ); 135 HardwareVertexBuffer buffer = vertexData.vertexBufferBinding.GetBuffer( POSITION ); 176 136 177 137 IntPtr posPtr = buffer.Lock( BufferLocking.Discard ); … … 282 242 min = box.Minimum; 283 243 max = box.Maximum; 284 mid = ( ( m in - max) * 0.5f ) + min;244 mid = ( ( max - min ) * 0.5f ) + min; 285 245 dist = camera.DerivedPosition - mid; 286 246
