File: Capsule.cs

package info (click to toggle)
opentk 1.1.4c%2Bdfsg-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster
  • size: 68,640 kB
  • sloc: cs: 525,501; xml: 277,501; ansic: 3,597; makefile: 41
file content (110 lines) | stat: -rw-r--r-- 4,571 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using System;
using System.Collections.Generic;

using OpenTK;

namespace Examples.Shapes
{
    public sealed class Capsule: DrawableShape
    {
        public enum eSubdivisions
        {
            None = 0,
            One = 1,
            Two = 2,
            Three = 3,
            Four = 4,
        }


        public Capsule( double radius, double height, eSubdivisions subdivs, bool useDL )
            : base( useDL )
        {
            uint HoseSubDivs = 0;
            SlicedSphere.eSubdivisions spheresubdivs = SlicedSphere.eSubdivisions.Zero;

            switch ( subdivs )
            {
            case eSubdivisions.None:
                spheresubdivs = SlicedSphere.eSubdivisions.Zero;
                HoseSubDivs = 0;
                break;
            case eSubdivisions.One:
                spheresubdivs = SlicedSphere.eSubdivisions.One;
                HoseSubDivs = 1;
                break;
            case eSubdivisions.Two:
                spheresubdivs = SlicedSphere.eSubdivisions.Two;
                HoseSubDivs = 3;
                break;
            case eSubdivisions.Three:
                spheresubdivs = SlicedSphere.eSubdivisions.Three;
                HoseSubDivs = 7;
                break;
            case eSubdivisions.Four:
                spheresubdivs = SlicedSphere.eSubdivisions.Four;
                HoseSubDivs = 15;
                break;
            }
            PrimitiveMode = OpenTK.Graphics.OpenGL.PrimitiveType.Triangles;

            OpenTK.Graphics.OpenGL.PrimitiveType TemporaryMode;
            VertexT2dN3dV3d[] TemporaryVBO;
            uint[] TemporaryIBO;

            List<Chunk> AllChunks = new List<Chunk>();
            Vector3d offset1 = new Vector3d( 0.0, 0.0, height ),
                     offset2 = new Vector3d( 0.0, 0.0, -height );
            for ( int i = 0; i < 4; i++ )
            {
                SlicedHose.eSide tempSide = SlicedHose.eSide.FrontTop;
                switch ( i )
                {
                case 0:
                    tempSide = SlicedHose.eSide.FrontBottom;
                    break;
                case 1:
                    tempSide = SlicedHose.eSide.BackBottom;
                    break;
                case 2:
                    tempSide = SlicedHose.eSide.BackTop;
                    break;
                case 3:
                    tempSide = SlicedHose.eSide.FrontTop;
                    break;
                }
                SlicedHose tempHose = new SlicedHose( tempSide, HoseSubDivs, radius, offset1, offset2, false );
                tempHose.GetArraysforVBO( out TemporaryMode, out TemporaryVBO, out TemporaryIBO );
                tempHose.Dispose();
                AllChunks.Add( new Chunk( ref TemporaryVBO, ref TemporaryIBO ) );
            }

            SlicedSphere front = new SlicedSphere( radius, offset1, spheresubdivs,
                                                       new SlicedSphere.eDir[] {
                                                           SlicedSphere.eDir.BackBottomRight,
                                                           SlicedSphere.eDir.FrontTopRight,
                                                           SlicedSphere.eDir.BackTopRight,
                                                           SlicedSphere.eDir.FrontBottomRight, 
                                                          },
                                                       false );

            front.GetArraysforVBO( out TemporaryMode, out TemporaryVBO, out TemporaryIBO );
            AllChunks.Add( new Chunk( ref TemporaryVBO, ref TemporaryIBO ) );
            front.Dispose();

            SlicedSphere back = new SlicedSphere( radius, offset2, spheresubdivs,
                                                      new SlicedSphere.eDir[] { 
                                                          SlicedSphere.eDir.FrontBottomLeft,
                                                          SlicedSphere.eDir.FrontTopLeft, 
                                                          SlicedSphere.eDir.BackTopLeft,
                                                          SlicedSphere.eDir.BackBottomLeft },
                                                      false );
            back.GetArraysforVBO( out TemporaryMode, out TemporaryVBO, out TemporaryIBO );
            AllChunks.Add( new Chunk( ref TemporaryVBO, ref TemporaryIBO ) );
            back.Dispose();

            Chunk.GetArray( ref AllChunks, out VertexArray, out IndexArray );
            AllChunks.Clear();
        }
    }
}