コード例 #1
1
ファイル: Program.cs プロジェクト: dragosb112/Model
        static void Main(string[] args)
        {
            Console.WriteLine("Sanity Check!");

            Sender _sender = new Sender();

            KeyboardInput _key = new KeyboardInput();

            EventListener _listener = new EventListener(_key);

            vec3 start = vec3.Zero;
            vec3 end = new vec3(110.0f, 100.0f, 10.0f);
            float vel = 1f;
            bool complete = false;

            while (!complete)
            {
                MoveVector3(out complete, ref start, end, vel, AXIS.X);
            }

            Console.WriteLine("########################################################################");
            Console.WriteLine("###########              STOPPED SIM                         ###########");
            Console.WriteLine("########################################################################");

            _key.Send();
        }
コード例 #2
0
ファイル: ClockRenderer.cs プロジェクト: bitzhuwei/CSharpGL
 public ClockRenderer(vec3 worldPosition)
 {
     this.WorldPosition = worldPosition;
     const float factor = 0.5f;
     this.Scale = new vec3(factor, factor, factor);
     this.ModelSize = new vec3(2, 2, 2);
 }
コード例 #3
0
        public LinesBase(OpenGL gl, List<Tuple<vec3, vec3>> lines, Material material = null, OGLModelUsage usage = OGLModelUsage.StaticRead)
        {
            var verts = new vec3[lines.Count * 2];
            var normals = new vec3[lines.Count * 2];
            var indices = new uint[lines.Count * 2];

            for (int i = 0; i < lines.Count; i++)
            {
                var i2 = i * 2;
                verts[i2] = lines[i].Item1;
                verts[i2 + 1] = lines[i].Item2;

                normals[i2] = new vec3(1, 1, 1);
                normals[i2 + 1] = new vec3(1, 1, 1);

                indices[i2] = (uint)i2;
                indices[i2 + 1] = (uint)(i2 + 1);
            }

            if (material != null)
                Material = material;

            Vertices = verts;
            Normals = normals;
            Indices = indices;
            GlDrawMode = OpenGL.GL_LINES;

            if (gl != null)
                GenerateGeometry(gl, usage);
        }
コード例 #4
0
        /// <summary>
        /// 判定三点是否共线。
        /// </summary>
        /// <param name="walker"></param>
        /// <param name="start"></param>
        /// <param name="end"></param>
        /// <param name="percent">如果三点共线,<paramref name="percent"/>代表(<paramref name="walker"/> - <paramref name="start"/>)/(<paramref name="end"/> - <paramref name="start"/>)</param>
        /// <returns></returns>
        public static bool InTheSameLine(this vec3 walker, vec3 start, vec3 end, out float percent, float allowableError = 0.01f)
        {
            vec3 v1 = walker - start;
            vec3 v2 = end - start;
            var values = new List<float>();
            for (int i = 0; i < 3; i++)
            {
                if (v2[i] == 0.0f)
                {
                    if (v1[i] != 0.0f)
                    {
                        percent = 0;
                        return false;
                    }
                }
                else
                {
                    values.Add(v1[i] / v2[i]);
                }
            }

            float average, variance;
            values.ToArray().AverageVariance(out average, out variance);
            if (variance <= allowableError)
            {
                percent = average;
                return true;
            }
            else
            {
                percent = 0;
                return false;
            }
        }
コード例 #5
0
ファイル: ChainModel.cs プロジェクト: bitzhuwei/CSharpGL
        /// <summary>
        /// 链条。若干个点用直线连接起来。
        /// </summary>
        /// <param name="pointCount">有多少个点</param>
        /// <param name="length">点的范围(长度)</param>
        /// <param name="width">点的范围(宽度)</param>
        /// <param name="height">点的范围(高度)</param>
        public ChainModel(int pointCount = 10, int length = 5, int width = 5, int height = 5)
        {
            var random = new Random();
            var positions = new vec3[pointCount];
            for (int i = 0; i < pointCount; i++)
            {
                var point = new vec3();
                point.x = (float)random.NextDouble() * length;
                point.y = (float)random.NextDouble() * width;
                point.z = (float)random.NextDouble() * height;
                positions[i] = point;
            }
            BoundingBox box = positions.Move2Center();
            this.Lengths = box.MaxPosition - box.MinPosition;
            this.Positions = positions;

            this.Colors = new vec3[pointCount];
            {
                for (int i = 0; i < pointCount; i++)
                {
                    uint p = (uint)((256 * 256 * 256) / pointCount * (i + 1));
                    var color = new vec3();
                    color.x = ((p >> 0) & 0xFF) / 255.0f;
                    color.y = ((p >> 8) & 0xFF) / 255.0f;
                    color.z = ((p >> 16) & 0xFF) / 255.0f;
                    this.Colors[i] = color;
                }
            }
        }
コード例 #6
0
 public BrickFragmentShader(vec2 size, vec2 pct, vec3 brickColor, vec3 mortColor)
 {
     BrickSize = size;
     BrickPct = pct;
     BrickColor = brickColor;
     MortarColor = mortColor;
 }
コード例 #7
0
 public Entity(TexturedModel model, vec3 position, vec3 rot, float scale)
 {
     this.model = model;
     this.position = position;
     this.rot = rot;
     this.scale = scale;
 }
コード例 #8
0
ファイル: glm_camera.cs プロジェクト: bitzhuwei/CSharpGL
        /// <summary>
        /// Build a look at view matrix.
        /// transform object's coordinate from world's space to camera's space.
        /// </summary>
        /// <param name="eye">The eye.</param>
        /// <param name="center">The center.</param>
        /// <param name="up">Up.</param>
        /// <returns></returns>
        public static mat4 lookAt(vec3 eye, vec3 center, vec3 up)
        {
            // camera's back in world space coordinate system
            vec3 back = (eye - center).normalize();
            // camera's right in world space coordinate system
            vec3 right = up.cross(back).normalize();
            // camera's up in world space coordinate system
            vec3 standardUp = back.cross(right);

            mat4 viewMatrix = new mat4(1);
            viewMatrix.col0.x = right.x;
            viewMatrix.col1.x = right.y;
            viewMatrix.col2.x = right.z;
            viewMatrix.col0.y = standardUp.x;
            viewMatrix.col1.y = standardUp.y;
            viewMatrix.col2.y = standardUp.z;
            viewMatrix.col0.z = back.x;
            viewMatrix.col1.z = back.y;
            viewMatrix.col2.z = back.z;

            // Translation in world space coordinate system
            viewMatrix.col3.x = -eye.dot(right);
            viewMatrix.col3.y = -eye.dot(standardUp);
            viewMatrix.col3.z = -eye.dot(back);

            return viewMatrix;
        }
コード例 #9
0
ファイル: geometric.cs プロジェクト: chantsunman/glmnet
 public static vec3 cross(vec3 lhs, vec3 rhs)
 {
     return new vec3(
         lhs.y * rhs.z - rhs.y * lhs.z,
         lhs.z * rhs.x - rhs.z * lhs.x,
         lhs.x * rhs.y - rhs.x * lhs.y);
 }
コード例 #10
0
        public TrefoilKnotModel(double interval = 0.02)
        {
            this.interval = interval;
            bool initialized = false;
            vec3 max = new vec3();
            vec3 min = new vec3();
            int uCount = GetUCount(interval);
            for (int uIndex = 0; uIndex < uCount; uIndex++)
            {
                double t = Math.PI * 2 * uIndex / uCount;
                var position = GetPosition(t);

                if (!initialized)
                {
                    max = position;
                    min = position;
                    initialized = true;
                }
                else
                {
                    position.UpdateMax(ref max);
                    position.UpdateMin(ref min);
                }
            }
            this.Lengths = max - min;
        }
コード例 #11
0
ファイル: Rectangle3D.cs プロジェクト: chantsunman/CSharpGL
 public Rectangle3D(vec3 min, vec3 max)
 {
     vec3 realMin, realMax;
     MakesureMinMax(min, max, out realMin, out realMax);
     this.min = realMin;
     this.max = realMax;
 }
コード例 #12
0
        private static vec3 GetLengths(BuildInSceneObject buildIn)
        {
            var lengths = new vec3(1, 1, 1) * 2;

            switch (buildIn)
            {
                case BuildInSceneObject.Cube:
                    break;

                case BuildInSceneObject.Sphere:
                    break;

                case BuildInSceneObject.Ground:
                    lengths = new vec3(groundXLength, 1, groundZLength);
                    break;

                case BuildInSceneObject.Axis:
                    break;

                default:
                    throw new NotImplementedException();
            }

            return lengths;
        }
コード例 #13
0
 public override MeshBase CreateMesh(GridderSource source)
 {
     PointGridderSource src = (PointGridderSource)source;
     vec3 minvec3 = new vec3();
     vec3 maxvec3 = new vec3();
     bool isSet = false;
     PointPositionBuffer positions = new PointPositionBuffer();
     PointRadiusBuffer radiusBuffer = null;
     int dimSize = src.DimenSize;
     Random random = new Random();
     // setup positions
     unsafe
     {
         positions.AllocMem(dimSize);
         var cells = (vec3*)positions.Data;
         for (int gridIndex = 0; gridIndex < dimSize; gridIndex++)
         {
             vec3 p = src.TranslateMatrix * src.Positions[gridIndex];
             cells[gridIndex] = p;
         }
     }
     radiusBuffer = this.CreateRadiusBufferData(src, src.Radius);
     PointMeshGeometry3D mesh = new PointMeshGeometry3D(positions, radiusBuffer, dimSize);
     mesh.Max = src.TransformedActiveBounds.Max;
     mesh.Min = src.TransformedActiveBounds.Min;
     return mesh;
 }
コード例 #14
0
        static BigDipperModel()
        {
            positions = new vec3[11];
            positions[0] = new vec3(0, 2, 0);
            positions[1] = new vec3(1, 2, 0);
            positions[2] = new vec3(2, 1.5f, 0);
            positions[3] = new vec3(3, 1.25f, 0);
            positions[4] = new vec3(3.5f, 0, 0);
            positions[5] = new vec3(4.5f, 0, 0);
            positions[6] = new vec3(5, 1, 0);
            positions[7] = new vec3(5.9f, 4.1f, 0);
            positions[8] = new vec3(6.1f, 4.2f, 0);
            positions[9] = new vec3(6.2f, 3.9f, 0);
            positions[10] = new vec3(6.4f, 3.9f, 0);
            positions.Move2Center();

            colors = new vec3[11];
            colors[0] = new vec3(1, 0, 0);
            colors[1] = new vec3(1, 0.5f, 0);
            colors[2] = new vec3(1, 1, 0);
            colors[3] = new vec3(0, 1, 0);
            colors[4] = new vec3(0, 1, 1);
            colors[5] = new vec3(0, 0, 1);
            colors[6] = new vec3(0.5f, 0, 1);
            colors[7] = new vec3(1.0f, 215.0f / 255.0f, 0.0f);
            colors[8] = new vec3(1.0f * 0.9f, 215.0f / 255.0f * 0.9f, 0.0f);
            colors[9] = new vec3(1.0f * 0.8f, 215.0f / 255.0f * 0.8f, 0.0f);
            colors[10] = new vec3(1.0f * 0.7f, 215.0f / 255.0f * 0.7f, 0.0f);
        }
コード例 #15
0
        public KleinBottleModel(double interval = 0.02)
        {
            this.interval = interval;
            bool initialized = false;
            vec3 max = new vec3();
            vec3 min = new vec3();
            int uCount = GetUCount(interval);
            int vCount = GetVCount(interval);
            for (int uIndex = 0; uIndex < uCount; uIndex++)
            {
                for (int vIndex = 0; vIndex < vCount; vIndex++)
                {
                    double u = Math.PI * uIndex / uCount;
                    double v = Math.PI * 2 * vIndex / vCount;
                    var position = GetPosition(u, v);

                    if (!initialized)
                    {
                        max = position;
                        min = position;
                        initialized = true;
                    }
                    else
                    {
                        position.UpdateMax(ref max);
                        position.UpdateMin(ref min);
                    }
                }
            }
            this.Lengths = max - min;
        }
コード例 #16
0
 public OrderIndependentTransparencyRenderer(IBufferable model, vec3 lengths,
     string positionName, string normalName)
 {
     {
         var map = new AttributeMap();
         map.Add("position", positionName);
         map.Add("normal", normalName);
         var build_lists = new ShaderCode[2];
         build_lists[0] = new ShaderCode(File.ReadAllText(@"shaders\OIT\build_lists.vert"), ShaderType.VertexShader);
         build_lists[1] = new ShaderCode(File.ReadAllText(@"shaders\OIT\build_lists.frag"), ShaderType.FragmentShader);
         this.buildListsRenderer = new PickableRenderer(model, build_lists, map, positionName);
     }
     {
         var map = new AttributeMap();
         map.Add("position", positionName);
         var resolve_lists = new ShaderCode[2];
         resolve_lists[0] = new ShaderCode(File.ReadAllText(@"shaders\OIT\resolve_lists.vert"), ShaderType.VertexShader);
         resolve_lists[1] = new ShaderCode(File.ReadAllText(@"shaders\OIT\resolve_lists.frag"), ShaderType.FragmentShader);
         this.resolve_lists = new PickableRenderer(model, resolve_lists, map, positionName);
     }
     {
         this.depthTestState = new DepthTestState(false);
         this.cullFaceState = new CullFaceState(false);
     }
     this.ModelSize = lengths;
 }
コード例 #17
0
ファイル: TrefoilKnot.cs プロジェクト: hhool/sharpgl
        /// <summary>
        /// Evaluates the trefoil, providing the vertex at a given coordinate.
        /// </summary>
        /// <param name="s">The s.</param>
        /// <param name="t">The t.</param>
        /// <returns>The vertex at (s,t).</returns>
        private static vec3 EvaluateTrefoil(float s, float t)
        {
            const float TwoPi = (float)Math.PI * 2;

            float a = 0.5f;
            float b = 0.3f;
            float c = 0.5f;
            float d = 0.1f;
            float u = (1 - s) * 2 * TwoPi;
            float v = t * TwoPi;
            float r = (float)(a + b * Math.Cos(1.5f * u));
            float x = (float)(r * Math.Cos(u));
            float y = (float)(r * Math.Sin(u));
            float z = (float)(c * Math.Sin(1.5f * u));

            vec3 dv = new vec3();
            dv.x = (float) (-1.5f*b*Math.Sin(1.5f*u)*Math.Cos(u) - (a + b*Math.Cos(1.5f*u))*Math.Sin(u));
            dv.y = (float) (-1.5f*b*Math.Sin(1.5f*u)*Math.Sin(u) + (a + b*Math.Cos(1.5f*u))*Math.Cos(u)); 
            dv.z = (float) (1.5f*c*Math.Cos(1.5f*u));
            
            vec3 q = glm.normalize(dv);
            vec3 qvn = glm.normalize(new vec3(q.y, -q.x, 0.0f));
            vec3 ww =  glm.cross(q, qvn);

            vec3 range = new vec3();
            range.x = (float) (x + d*(qvn.x*Math.Cos(v) + ww.x*Math.Sin(v)));
            range.y = (float)(y + d * (qvn.y * Math.Cos(v) + ww.y * Math.Sin(v)));
            range.z = (float)(z + d * ww.z * Math.Sin(v));
            
            return range;
        }
コード例 #18
0
ファイル: BoundedRenderer.cs プロジェクト: xzoth/CSharpGL
        public BoundedRenderer(Renderer scientificRenderer, vec3 lengths)
        {
            if (scientificRenderer == null)
            { throw new ArgumentNullException(); }

            this.BoundingBoxRenderer = BoudingBoxRendererFactory.GetBoundingBoxRenderer(lengths);
            this.ScientificRenderer = scientificRenderer;
        }
コード例 #19
0
        public void CanCreateLookAtProjection()
        {
            var eye = new vec3(4f, 4f, 4f);
            var centre = new vec3(0f, 0f, 0f);
            var up = new vec3(0f, 1f, 0f);

            var result = glm.lookAt(eye, centre, up);
        }
コード例 #20
0
ファイル: Matrix4Util.cs プロジェクト: Wiladams/NewTOAPIA
 public static mat4 Translate(ref vec3 t)
 {
     return new mat4(
         1, 0, 0, 0,
         0, 1, 0, 0,
         0, 0, 1, 0,
         t.x, t.y, t.z, 1
         );
 }
コード例 #21
0
 internal void SetDirection(vec3 direction)
 {
     direction.y = 0;
     direction = direction.normalize();
     float cosRadian = direction.dot(new vec3(1, 0, 0));
     float radian = (float)Math.Acos(cosRadian);
     if (direction.z > 0) { radian = -radian; }
     this.radian = radian;
 }
コード例 #22
0
        /// <summary>
        /// Rotates by angleRadians in the direction(s) v and forces a recalculation of the result matrix.
        /// </summary>
        /// <param name="angleRadians">The angle of the rotation in radians.</param>
        /// <param name="v">The vector that represents the axis around which should be rotated.</param>
        public virtual TransformableBase RotateAbsolute(float angleRadians, vec3 v)
        {
            if (angleRadians == 0)
                return this;

            _rotationMatrix = GlmNet.glm.rotate(_rotationMatrix, angleRadians, v);

            return RecalculateResultMatrix();
        }
コード例 #23
0
ファイル: VectorHelper.cs プロジェクト: bitzhuwei/CSharpGL
        /// <summary>
        ///
        /// </summary>
        /// <param name="item"></param>
        /// <returns></returns>
        public static vec3 Abs(this vec3 item)
        {
            vec3 result = new vec3(item.x, item.y, item.z);
            if (result.x < 0) { result.x = -result.x; }
            if (result.y < 0) { result.y = -result.y; }
            if (result.z < 0) { result.z = -result.z; }

            return result;
        }
コード例 #24
0
ファイル: PickedGeometry.cs プロジェクト: bitzhuwei/CSharpGL
 //public PickedGeometry() { }
 /// <summary>
 /// The color-coded picking result.
 /// <para>Representing a primitive(point, line, triangle, quad, polygon).</para>
 /// </summary>
 /// <param name="fromViewPort"></param>
 /// <param name="geometryType"></param>
 /// <param name="positions"></param>
 /// <param name="vertexIds"></param>
 /// <param name="stageVertexId"></param>
 /// <param name="fromRenderer"></param>
 public PickedGeometry(ViewPort fromViewPort, PickingGeometryType geometryType, vec3[] positions, uint[] vertexIds, uint stageVertexId, IPickable fromRenderer)
 {
     this.FromViewPort = fromViewPort;
     this.GeometryType = geometryType;
     this.Positions = positions;
     this.VertexIds = vertexIds;
     this.StageVertexId = stageVertexId;
     this.FromRenderer = fromRenderer;
 }
コード例 #25
0
        public static void ApplySingleLightParameters(SharpGL.OpenGL gl, ExtShaderProgram esp, vec3 lp)
        {
            var prms = esp.Parameters as ISingleLightParameters;
            var p = esp.Program;

            // Set the light position.
            if (prms.LightPositionId != null)
                p.SetUniform3(gl, prms.LightPositionId, lp.x, lp.y, lp.z);
        }
コード例 #26
0
ファイル: Matrix4Util.cs プロジェクト: Wiladams/NewTOAPIA
        public static mat4 ScaleMatrix(ref vec3 s)
        {
            mat4 r = new mat4(s.x, 0, 0, 0,
                0, s.y, 0, 0,
                0, 0, s.z, 0,
                0, 0, 0, 1);

            return r;
        }
コード例 #27
0
 public static mat4 createTransformationMatrix(GlmNet.vec3 translation, vec3 rot, float scale)
 {
     mat4 matrix = new mat4(4);
     matrix = glm.translate(matrix, translation);
     mat4 rotMatrix = glm.rotate(rot.x, new vec3(0, 0, 1)) * glm.rotate(rot.y, new vec3(0, 1, 0)) * glm.rotate(rot.z, new vec3(1, 0, 0));
     mat4 scaleMatrix = new mat4(4);
     scaleMatrix = glm.scale(scaleMatrix, new vec3(scale, scale, scale));
     return matrix * rotMatrix * scaleMatrix;
 }
コード例 #28
0
ファイル: Form12Billboard.cs プロジェクト: bitzhuwei/CSharpGL
 internal void SetDirection(IRenderable renderer, vec3 direction)
 {
     direction.y = 0;
     direction = direction.normalize();
     float cosRadian = direction.dot(new vec3(1, 0, 0));// (1, 0, 0) is teapot's default direction.
     float radian = (float)Math.Acos(cosRadian);
     if (direction.z > 0) { radian = -radian; }
     renderer.RotationAngleDegree = (float)(radian * 180.0 / Math.PI);
 }
コード例 #29
0
 public static mat4 createViewMatrix(Camera camera)
 {
     mat4 viewMatrix = new mat4();
     viewMatrix = glm.rotate((float)ToRadiansExtension.ToRadians(camera.getRotation().y), new vec3(1, 0, 0));
     viewMatrix = glm.rotate(viewMatrix,(float)ToRadiansExtension.ToRadians(camera.getRotation().z), new vec3(0, 1, 0));
     viewMatrix = glm.rotate(viewMatrix,(float)ToRadiansExtension.ToRadians(camera.getRotation().x), new vec3(0, 0, 1));
     vec3 negativeCameraPos = new vec3(-camera.getPosition().x, -camera.getPosition().y, -camera.getPosition().z);
     viewMatrix = glm.translate(viewMatrix, negativeCameraPos);
     return viewMatrix;
 }
コード例 #30
0
        /// <summary>
        /// Specify a cuboid that marks a model's edges.
        /// </summary>
        /// <param name="min"></param>
        /// <param name="max"></param>
        public LegacyBoundingBoxRenderer(vec3 min, vec3 max)
        {
            this.MinPosition = min;
            this.MaxPosition = max;

            this.Scale = new vec3(1, 1, 1);
            this.RotationAxis = new vec3(0, 1, 0);

            this.ModelSize = max - min;
        }
コード例 #31
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="lengths"></param>
 public Cube(vec3 lengths)
 {
     this.Lengths = lengths;
 }
コード例 #32
0
ファイル: Utilities.cs プロジェクト: Grimelios/LudumDare46
 public static float Distance(vec3 p1, vec3 p2)
 {
     return(Length(p2 - p1));
 }
コード例 #33
0
ファイル: Utilities.cs プロジェクト: Grimelios/LudumDare46
 public static vec3 ProjectOntoPlane(vec3 v, vec3 n)
 {
     // See https://www.maplesoft.com/support/help/Maple/view.aspx?path=MathApps%2FProjectionOfVectorOntoPlane.
     return(v - Project(v, n));
 }
コード例 #34
0
 public float projection(vec3 point)
 {
     return(direction ^ (point - origin));
 }
コード例 #35
0
ファイル: Utilities.cs プロジェクト: Grimelios/LudumDare46
        public static vec3 Rotate(vec3 v, float angle, vec3 axis)
        {
            Debug.Assert(axis != vec3.Zero, "Can't rotate around a vec3.Zero axis.");

            return(angle == 0 ? v : quat.FromAxisAngle(angle, axis) * v);
        }
コード例 #36
0
 public extern mat3(vec3 col0, vec3 col1, vec3 col2);
コード例 #37
0
 public ray(vec3 origin, vec3 direction)
 {
     this.origin    = origin;
     this.direction = direction;
 }
コード例 #38
0
ファイル: Utilities.cs プロジェクト: Grimelios/LudumDare46
 public static float DistanceToLine(vec3 p, vec3 e0, vec3 e1, out float t)
 {
     return(Line3D.Distance(p, e0, e1, out t));
 }
コード例 #39
0
 public void SetSeekTarget(vec3 targetPoint)
 {
 }
コード例 #40
0
ファイル: Utilities.cs プロジェクト: Grimelios/LudumDare46
 public static bool Intersects(vec3 p1, vec3 p2, vec3[] triangle, out float t)
 {
     return(Intersects(p1, p2, triangle[0], triangle[1], triangle[2], out t));
 }
コード例 #41
0
ファイル: Utilities.cs プロジェクト: Grimelios/LudumDare46
        public static bool IsWithinTriangle(vec3 p, vec3 p0, vec3 p1, vec3 p2)
        {
            var b = Barycentric(p, p0, p1, p2);

            return(b.x >= 0 && b.x <= 1 && b.y >= 0 && b.y <= 1 && b.z >= 0 && b.z <= 1);
        }
コード例 #42
0
ファイル: Utilities.cs プロジェクト: Grimelios/LudumDare46
 public static vec3 Project(vec3 v, vec3 onto)
 {
     // See https://math.oregonstate.edu/home/programs/undergrad/CalculusQuestStudyGuides/vcalc/dotprod/dotprod.html.
     return(vec3.Dot(onto, v) / vec3.Dot(onto, onto) * onto);
 }
コード例 #43
0
ファイル: LightPostionNode.cs プロジェクト: 91yuan/CSharpGL
 public CubeModel()
 {
     this.ModelSize = new vec3(xLength * 2, yLength * 2, zLength * 2);
 }
コード例 #44
0
 public LayeredRectangleModel()
 {
     this.ModelSize = new vec3(xLength * 2, yLength * 2, (xLength + yLength) * 0.02f);
 }
コード例 #45
0
 public ray()
 {
     origin    = vec3.zero;
     direction = vec3.forward;
 }
コード例 #46
0
 public static void AreVectorsEqual(vec3 expected, vec3 actual, float delta)
 {
     Assert.AreEqual(expected.x, actual.x, delta, "Vector X component is incorrect.");
     Assert.AreEqual(expected.y, actual.y, delta, "Vector Y component is incorrect.");
     Assert.AreEqual(expected.z, actual.z, delta, "Vector Z component is incorrect.");
 }
コード例 #47
0
 public float distance(vec3 point)
 {
     return((direction % (point - origin)).magnitude);
 }
コード例 #48
0
ファイル: Utilities.cs プロジェクト: Grimelios/LudumDare46
 public static float Dot(vec3 v1, vec3 v2)
 {
     return(vec3.Dot(v1, v2));
 }
コード例 #49
0
 public vec3 project(vec3 point)
 {
     return(origin + direction * projection(point));
 }
コード例 #50
0
ファイル: Utilities.cs プロジェクト: Grimelios/LudumDare46
 public static float Length(vec3 v)
 {
     return((float)Math.Sqrt(LengthSquared(v)));
 }
コード例 #51
0
ファイル: Utilities.cs プロジェクト: Grimelios/LudumDare46
 public static float LengthSquared(vec3 v)
 {
     return(v.x * v.x + v.y * v.y + v.z * v.z);
 }
コード例 #52
0
ファイル: Utilities.cs プロジェクト: Grimelios/LudumDare46
 public static vec3 Cross(vec3 v1, vec3 v2)
 {
     return(vec3.Cross(v1, v2));
 }
コード例 #53
0
ファイル: Utilities.cs プロジェクト: Grimelios/LudumDare46
 public static float Dot(vec3 v)
 {
     return(v.x * v.x + v.y * v.y + v.z * v.z);
 }
コード例 #54
0
 public bullet(vec3 cp, vec3 ld)
 {
     pos = cp;
     dir = ld;
 }
コード例 #55
0
ファイル: Utilities.cs プロジェクト: Grimelios/LudumDare46
 public static vec3 Barycentric(vec3 p, vec3[] triangle)
 {
     return(Barycentric(p, triangle[0], triangle[1], triangle[2]));
 }
コード例 #56
0
 public void update()
 {
     pos += dir;
 }
コード例 #57
0
ファイル: PointsNode.cs プロジェクト: winterlutos/CSharpGL
        public static PointsNode Create(IBufferSource model, string position, string color, vec3 size)
        {
            RenderMethodBuilder randomBuilder, gl_VertexIDBuilder;
            {
                var vs    = new VertexShader(randomVert);
                var fs    = new FragmentShader(randomFrag);
                var array = new ShaderArray(vs, fs);
                var map   = new AttributeMap();
                map.Add("inPosition", position);
                map.Add("inColor", color);
                randomBuilder = new RenderMethodBuilder(array, map);
            }
            {
                var vs    = new VertexShader(gl_VertexIDVert);
                var fs    = new FragmentShader(gl_VertexIDFrag);
                var array = new ShaderArray(vs, fs);
                var map   = new AttributeMap();
                map.Add("inPosition", position);
                gl_VertexIDBuilder = new RenderMethodBuilder(array, map);
            }

            var node = new PointsNode(model, position, randomBuilder, gl_VertexIDBuilder);

            node.Initialize();
            node.ModelSize = size;

            return(node);
        }
コード例 #58
0
ファイル: Utilities.cs プロジェクト: Grimelios/LudumDare46
 public static vec3 ProjectOntoPlane(vec3 p, vec3 planePoint, vec3 n)
 {
     return(ProjectOntoPlane(p - planePoint, n));
 }
コード例 #59
0
ファイル: Utilities.cs プロジェクト: Grimelios/LudumDare46
 public static float DistanceSquared(vec3 p1, vec3 p2)
 {
     return(LengthSquared(p2 - p1));
 }
コード例 #60
0
ファイル: Utilities.cs プロジェクト: Grimelios/LudumDare46
 public static bool IsWithinTriangle(vec3 p, vec3[] triangle)
 {
     return(IsWithinTriangle(p, triangle[0], triangle[1], triangle[2]));
 }