Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 1452 | chris | 1 | using System; |
| 2 | using System.Collections.Generic; |
||
| 3 | |||
| 4 | using OpenTK; |
||
| 5 | |||
| 6 | namespace Examples.Shapes |
||
| 7 | { |
||
| 8 | public sealed class Capsule: DrawableShape |
||
| 9 | { |
||
| 10 | public enum eSubdivisions |
||
| 11 | { |
||
| 12 | None = 0, |
||
| 13 | One = 1, |
||
| 14 | Two = 2, |
||
| 15 | Three = 3, |
||
| 16 | Four = 4, |
||
| 17 | } |
||
| 18 | |||
| 19 | |||
| 20 | public Capsule( double radius, double height, eSubdivisions subdivs, bool useDL ) |
||
| 21 | : base( useDL ) |
||
| 22 | { |
||
| 23 | uint HoseSubDivs = 0; |
||
| 24 | SlicedSphere.eSubdivisions spheresubdivs = SlicedSphere.eSubdivisions.Zero; |
||
| 25 | |||
| 26 | switch ( subdivs ) |
||
| 27 | { |
||
| 28 | case eSubdivisions.None: |
||
| 29 | spheresubdivs = SlicedSphere.eSubdivisions.Zero; |
||
| 30 | HoseSubDivs = 0; |
||
| 31 | break; |
||
| 32 | case eSubdivisions.One: |
||
| 33 | spheresubdivs = SlicedSphere.eSubdivisions.One; |
||
| 34 | HoseSubDivs = 1; |
||
| 35 | break; |
||
| 36 | case eSubdivisions.Two: |
||
| 37 | spheresubdivs = SlicedSphere.eSubdivisions.Two; |
||
| 38 | HoseSubDivs = 3; |
||
| 39 | break; |
||
| 40 | case eSubdivisions.Three: |
||
| 41 | spheresubdivs = SlicedSphere.eSubdivisions.Three; |
||
| 42 | HoseSubDivs = 7; |
||
| 43 | break; |
||
| 44 | case eSubdivisions.Four: |
||
| 45 | spheresubdivs = SlicedSphere.eSubdivisions.Four; |
||
| 46 | HoseSubDivs = 15; |
||
| 47 | break; |
||
| 48 | } |
||
| 49 | PrimitiveMode = OpenTK.Graphics.OpenGL.BeginMode.Triangles; |
||
| 50 | |||
| 51 | OpenTK.Graphics.OpenGL.BeginMode TemporaryMode; |
||
| 52 | VertexT2dN3dV3d[] TemporaryVBO; |
||
| 53 | uint[] TemporaryIBO; |
||
| 54 | |||
| 55 | List<Chunk> AllChunks = new List<Chunk>(); |
||
| 56 | Vector3d offset1 = new Vector3d( 0.0, 0.0, height ), |
||
| 57 | offset2 = new Vector3d( 0.0, 0.0, -height ); |
||
| 58 | for ( int i = 0; i < 4; i++ ) |
||
| 59 | { |
||
| 60 | SlicedHose.eSide tempSide = SlicedHose.eSide.FrontTop; |
||
| 61 | switch ( i ) |
||
| 62 | { |
||
| 63 | case 0: |
||
| 64 | tempSide = SlicedHose.eSide.FrontBottom; |
||
| 65 | break; |
||
| 66 | case 1: |
||
| 67 | tempSide = SlicedHose.eSide.BackBottom; |
||
| 68 | break; |
||
| 69 | case 2: |
||
| 70 | tempSide = SlicedHose.eSide.BackTop; |
||
| 71 | break; |
||
| 72 | case 3: |
||
| 73 | tempSide = SlicedHose.eSide.FrontTop; |
||
| 74 | break; |
||
| 75 | } |
||
| 76 | SlicedHose tempHose = new SlicedHose( tempSide, HoseSubDivs, radius, offset1, offset2, false ); |
||
| 77 | tempHose.GetArraysforVBO( out TemporaryMode, out TemporaryVBO, out TemporaryIBO ); |
||
| 78 | tempHose.Dispose(); |
||
| 79 | AllChunks.Add( new Chunk( ref TemporaryVBO, ref TemporaryIBO ) ); |
||
| 80 | } |
||
| 81 | |||
| 82 | SlicedSphere front = new SlicedSphere( radius, offset1, spheresubdivs, |
||
| 83 | new SlicedSphere.eDir[] { |
||
| 84 | SlicedSphere.eDir.BackBottomRight, |
||
| 85 | SlicedSphere.eDir.FrontTopRight, |
||
| 86 | SlicedSphere.eDir.BackTopRight, |
||
| 87 | SlicedSphere.eDir.FrontBottomRight, |
||
| 88 | }, |
||
| 89 | false ); |
||
| 90 | |||
| 91 | front.GetArraysforVBO( out TemporaryMode, out TemporaryVBO, out TemporaryIBO ); |
||
| 92 | AllChunks.Add( new Chunk( ref TemporaryVBO, ref TemporaryIBO ) ); |
||
| 93 | front.Dispose(); |
||
| 94 | |||
| 95 | SlicedSphere back = new SlicedSphere( radius, offset2, spheresubdivs, |
||
| 96 | new SlicedSphere.eDir[] { |
||
| 97 | SlicedSphere.eDir.FrontBottomLeft, |
||
| 98 | SlicedSphere.eDir.FrontTopLeft, |
||
| 99 | SlicedSphere.eDir.BackTopLeft, |
||
| 100 | SlicedSphere.eDir.BackBottomLeft }, |
||
| 101 | false ); |
||
| 102 | back.GetArraysforVBO( out TemporaryMode, out TemporaryVBO, out TemporaryIBO ); |
||
| 103 | AllChunks.Add( new Chunk( ref TemporaryVBO, ref TemporaryIBO ) ); |
||
| 104 | back.Dispose(); |
||
| 105 | |||
| 106 | Chunk.GetArray( ref AllChunks, out VertexArray, out IndexArray ); |
||
| 107 | AllChunks.Clear(); |
||
| 108 | } |
||
| 109 | } |
||
| 110 | } |