public void Write(OpenTK.Vector4 v)
 {
     Write(v.X);
     Write(v.Y);
     Write(v.Z);
     Write(v.W);
 }
示例#2
0
 public GLMesh Instantiate(bool renderWireframe, bool enableBackfaceCulling, Vector4 color)
 {
     return(new GLMesh(new GLVertexArray(mVertices, null, null, mIndices, mPrimitiveType),
                       new GLMaterial {
         RenderWireframe = renderWireframe, Diffuse = color, EnableBackfaceCulling = enableBackfaceCulling
     }, true));
 }
示例#3
0
        //TODO: Maybe rewrite and document?
        /// <summary>
        ///
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="name"></param>
        /// <param name="input"></param>
        public void SetAttribute <T>(String name, T input)
        {
            Int32 program = GL.GetUniformLocation(this.address, name);

            switch (typeof(T).Name) //hmm
            {
            case nameof(Int16): { Int16 output = (Int16)(Object)input; GL.Uniform1(program, output); break; }

            case nameof(Int32): { Int32 output = (Int32)(Object)input; GL.Uniform1(program, output); break; }

            case nameof(Int64): { Int64 output = (Int64)(Object)input; GL.Uniform1(program, output); break; }

            case nameof(Single): { Single output = (Single)(Object)input; GL.Uniform1(program, output); break; }

            case nameof(Double): { Double output = (Double)(Object)input; GL.Uniform1(program, output); break; }

            case nameof(OpenTK.Vector2): { OpenTK.Vector2 output = (OpenTK.Vector2)(Object) input; GL.Uniform2(program, ref output); break; }

            case nameof(OpenTK.Vector3): { OpenTK.Vector3 output = (OpenTK.Vector3)(Object) input; GL.Uniform3(program, ref output); break; }

            case nameof(OpenTK.Vector4): { OpenTK.Vector4 output = (OpenTK.Vector4)(Object) input; GL.Uniform4(program, ref output); break; }

            case nameof(OpenTK.Matrix2): { OpenTK.Matrix2 output = (OpenTK.Matrix2)(Object) input; GL.UniformMatrix2(program, false, ref output); break; }

            case nameof(OpenTK.Matrix3): { OpenTK.Matrix3 output = (OpenTK.Matrix3)(Object) input; GL.UniformMatrix3(program, false, ref output); break; }

            case nameof(OpenTK.Matrix4): { OpenTK.Matrix4 output = (OpenTK.Matrix4)(Object) input; GL.UniformMatrix4(program, false, ref output); break; }

            default: throw new Exception("Bad type providen");
            }
        }
示例#4
0
        internal void render(RenderList list, RenderObject obj, ref Transform parent, byte drawLayers = 255)
        {
            Transform trs = Local * parent;
            uint      pos;

            if (this.forceBillboard)
            {
                list.Camera.MakeBillboard(ref trs);
            }
            if (0 != (drawLayers & ChildrenDrawLayerMask))
            {
                GeoNode node;
                for (pos = NumImmediate, node = FirstChild; 0 != pos; node = node.Sibling, --pos)
                {
                    if (0 != (drawLayers & node.DrawLayerMask))
                    {
                        node.render(list, obj, ref trs, drawLayers);
                    }
                }
            }
            if (0 != (drawLayers & SelfDrawLayerMask))
            {
                OpenTK.Vector4 viewProj = list.Camera.ViewProj * new OpenTK.Vector4(trs.translation, 1f);
                GeoModel       model;
                for (pos = ModelCount, model = FirstModel; 0 != pos; model = model.Next, --pos)
                {
                    if (0 != (drawLayers & model.DrawLayerMask))
                    {
                        RenderLayer.Insert(list, obj, model, ref trs, ref viewProj, (byte)(drawLayers & model.DrawLayerMask));
                    }
                }
            }
        }
示例#5
0
文件: IOHelp.cs 项目: Hengle/Fusion3D
 public static void WriteVec(OpenTK.Vector4 v)
 {
     w.Write(v.X);
     w.Write(v.Y);
     w.Write(v.Z);
     w.Write(v.W);
 }
        /// <summary> Updates the character </summary>
        /// <param name="timeSinceUpdate"></param>
        public override void Update(TimeSpan timeSinceUpdate)
        {
            if (_Dead)
            {
                return;
            }
            base.Update(timeSinceUpdate);
            if (_RechargeTime > TimeSpan.Zero)
            {
                _RechargeTime -= timeSinceUpdate;
                Double value = _RechargeTime.TotalSeconds % 0.2 - 0.1;
                if (value > 0)
                {
                    Colour = new OpenTK.Vector4(1, 1, 1, 1);
                }
                else
                {
                    Colour = new OpenTK.Vector4(1, 1, 1, 0);
                }
            }
            else
            {
                Colour = new OpenTK.Vector4(1, 1, 1, 1);
            }

            if (Position.Y - Height < ZippyGame.Camera.BottomRight.Y - ZippyGame.Camera.Dimensions.Y)
            {
                Damage(_Health);
            }
        }
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.Name  = binaryReader.ReadString32();
     this.Color = binaryReader.ReadVector4();
     return(pointerQueue);
 }
示例#8
0
 private void editorY_Edited(object sender, EventArgs e)
 {
     if (this.IsUpdatingFromObject)
     {
         return;
     }
     if (!this.ReadOnly)
     {
         object[] values = this.GetValue().ToArray();
         Vector4  newVal = (Vector4)this.DisplayedValue;
         for (int i = 0; i < values.Length; i++)
         {
             if (values[i] == null)
             {
                 values[i] = this.DisplayedValue;
             }
             else
             {
                 Vector4 oldVal = (Vector4)values[i];
                 values[i] = new Vector4(oldVal.X, newVal.Y, oldVal.Z, oldVal.W);
             }
         }
         this.SetValues(values);
     }
     this.PerformGetValue();
 }
示例#9
0
        public ImageForm()
        {
            MouseDown = (b) =>
            {
                Click?.Invoke(0);
            };
            Col = new OpenTK.Vector4(1, 1, 1, 1);
            void DrawFunc()
            {
                if (Peak)
                {
                    if (Refract)
                    {
                        DrawFormBlurRefract(CoreTex, NormTex, Blur, Col, RefractV);
                    }
                    else
                    {
                        DrawFormBlur(CoreTex, Blur, Col);
                    }
                }
                else
                {
                    DrawForm(CoreTex);
                }
            }

            Draw = DrawFunc;
        }
示例#10
0
        public bool UpdateUniform(String name, OpenTK.Vector4 vec)
        {
            GL.Uniform4(uniforms[name], ref vec);

            CheckError();
            return(true);
        }
示例#11
0
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.SectionIndex = binaryReader.ReadInt16();
     this.PartIndex    = binaryReader.ReadInt16();
     this.Plane        = binaryReader.ReadVector4();
     return(pointerQueue);
 }
示例#12
0
 public override int Serialize(ref byte[] bytes, int offset, OpenTK.Vector4 value)
 {
     BinaryUtil.WriteSingle(ref bytes, offset, value.X);
     BinaryUtil.WriteSingle(ref bytes, offset + Marshal.SizeOf(typeof(float)), value.Y);
     BinaryUtil.WriteSingle(ref bytes, offset + Marshal.SizeOf(typeof(float)) * 2, value.Z);
     BinaryUtil.WriteSingle(ref bytes, offset + Marshal.SizeOf(typeof(float)) * 3, value.W);
     return(OpenTK.Vector4.SizeInBytes);
 }
 public void SetValue(Vector4 value)
 {
     GL.UseProgram(_parentEffect.CurrentTechnique.Passes[0].shaderProgram);
     OpenTK.Vector4 vect4 = new OpenTK.Vector4(value.X, value.Y, value.Z, value.W);
     _cachedValue = vect4;
     GL.Uniform4(internalIndex, vect4.X, vect4.Y, vect4.Z, vect4.W);
     GL.UseProgram(0);
 }
        public static BulletSharp.Math.Vector3 Transform(this BulletSharp.Math.Vector3 coordinate, ref OpenTK.Matrix4 transform)
        {
            OpenTK.Vector4 vector = new OpenTK.Vector4();
            vector.X = (coordinate.X * transform.M11) + (coordinate.Y * transform.M21) + (coordinate.Z * transform.M31) + transform.M41;
            vector.Y = (coordinate.X * transform.M12) + (coordinate.Y * transform.M22) + (coordinate.Z * transform.M32) + transform.M42;
            vector.Z = (coordinate.X * transform.M13) + (coordinate.Y * transform.M23) + (coordinate.Z * transform.M33) + transform.M43;
            vector.W = 1f / ((coordinate.X * transform.M14) + (coordinate.Y * transform.M24) + (coordinate.Z * transform.M34) + transform.M44);

            return(new BulletSharp.Math.Vector3(vector.X * vector.W, vector.Y * vector.W, vector.Z * vector.W));
        }
示例#15
0
        protected override void onClickOculusTrigger(ref VREvent_t vrEvent)
        {
            OpenTK.Vector4 controller_p      = UtilOld.getLeftControllerTipPosition(ref mScene, true) * new OpenTK.Vector4(0, 0, 0, 1);
            Point3d        controller_pRhino = UtilOld.openTkToRhinoPoint(UtilOld.vrToPlatformPoint(ref mScene, new OpenTK.Vector3(controller_p.X, controller_p.Y, controller_p.Z)));

            Rhino.DocObjects.RhinoObject rhobj = mScene.rhinoDoc.Objects.Find(cutPGuid);
            rhobj.Attributes.Name = "cut:" + controller_pRhino.X + ":" + controller_pRhino.Y + ":" + controller_pRhino.Z;
            rhobj.CommitChanges();
            Rhino.RhinoApp.WriteLine(rhobj.Attributes.Name);
        }
示例#16
0
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.ScenarioPlanarFogIndex = binaryReader.ReadInt16();
     this.fieldpad = binaryReader.ReadBytes(2);
     this.Plane    = binaryReader.ReadVector4();
     this.StructureBspFogPlaneFlags = ((Flags)(binaryReader.ReadInt16()));
     this.Priority = binaryReader.ReadInt16();
     return(pointerQueue);
 }
        public static BulletSharp.Math.Vector3 Transform(this BulletSharp.Math.Vector3 coordinate, ref OpenTK.Matrix4 transform)
        {
            OpenTK.Vector4 vector = new OpenTK.Vector4();
            vector.X = (coordinate.X * transform.M11) + (coordinate.Y * transform.M21) + (coordinate.Z * transform.M31) + transform.M41;
            vector.Y = (coordinate.X * transform.M12) + (coordinate.Y * transform.M22) + (coordinate.Z * transform.M32) + transform.M42;
            vector.Z = (coordinate.X * transform.M13) + (coordinate.Y * transform.M23) + (coordinate.Z * transform.M33) + transform.M43;
            vector.W = 1f / ((coordinate.X * transform.M14) + (coordinate.Y * transform.M24) + (coordinate.Z * transform.M34) + transform.M44);

            return new BulletSharp.Math.Vector3(vector.X * vector.W, vector.Y * vector.W, vector.Z * vector.W);
        }
示例#18
0
 public ThemeOpenGL(string n, OpenTK.Vector4 iJ, OpenTK.Vector4 tJ, OpenTK.Vector4 iB, OpenTK.Vector4 tB, System.Drawing.Color pF, System.Drawing.Color b, string sN)
 {
     name      = n;
     iJC       = iJ;
     tJC       = tJ;
     iBC       = iB;
     tBC       = tB;
     pFC       = pF;
     bC        = b;
     soundName = sN;
 }
示例#19
0
        public override OpenTK.Vector4 Deserialize(ref byte[] bytes, int offset, DirtyTracker tracker, out int byteSize)
        {
            var result = new OpenTK.Vector4();

            result.X = (float)BinaryUtil.ReadSingle(ref bytes, offset);
            result.Y = (float)BinaryUtil.ReadSingle(ref bytes, offset + Marshal.SizeOf(typeof(float)));
            result.Z = (float)BinaryUtil.ReadSingle(ref bytes, offset + Marshal.SizeOf(typeof(float)) * 2);
            result.W = (float)BinaryUtil.ReadSingle(ref bytes, offset + Marshal.SizeOf(typeof(float)) * 3);
            byteSize = OpenTK.Vector4.SizeInBytes;
            return(result);
        }
示例#20
0
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.Type             = ((TypeEnum)(binaryReader.ReadInt16()));
     this.Priority         = ((PriorityEnum)(binaryReader.ReadInt16()));
     this.Duration         = binaryReader.ReadSingle();
     this.FadeFunction     = ((FadeFunctionEnum)(binaryReader.ReadInt16()));
     this.fieldpad         = binaryReader.ReadBytes(2);
     this.MaximumIntensity = binaryReader.ReadSingle();
     this.Color            = binaryReader.ReadVector4();
     return(pointerQueue);
 }
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.Duration           = binaryReader.ReadRange();
     this.TransitionDuration = binaryReader.ReadRange();
     this.Physics            = binaryReader.ReadTagReference();
     this.Width           = binaryReader.ReadSingle();
     this.ColorLowerBound = binaryReader.ReadVector4();
     this.ColorUpperBound = binaryReader.ReadVector4();
     this.ContrailPointStatesScaleFlags = ((ScaleFlags)(binaryReader.ReadInt32()));
     return(pointerQueue);
 }
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.ShapeReferenceFlags             = ((Flags)(binaryReader.ReadInt32()));
     this.AnimationIndex                  = ((AnimationIndexEnum)(binaryReader.ReadInt16()));
     this.IntroAnimationDelayMilliseconds = binaryReader.ReadInt16();
     this.Color = binaryReader.ReadVector4();
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(4));
     this.RenderDepthBias = binaryReader.ReadInt16();
     this.fieldpad        = binaryReader.ReadBytes(14);
     return(pointerQueue);
 }
示例#23
0
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.TableViewListReferenceFlags = ((Flags)(binaryReader.ReadInt32()));
     this.AnimationIndex = ((AnimationIndexEnum)(binaryReader.ReadInt16()));
     this.IntroAnimationDelayMilliseconds = binaryReader.ReadInt16();
     this.CustomFont = ((CustomFontEnum)(binaryReader.ReadInt16()));
     this.fieldpad   = binaryReader.ReadBytes(2);
     this.TextColor  = binaryReader.ReadVector4();
     this.Topleft    = binaryReader.ReadPoint();
     pointerQueue.Enqueue(binaryReader.ReadBlamPointer(16));
     return(pointerQueue);
 }
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.ColonyFlags = ((Flags)(binaryReader.ReadInt16()));
     this.fieldpad    = binaryReader.ReadBytes(2);
     this.fieldpad0   = binaryReader.ReadBytes(4);
     this.Radius      = binaryReader.ReadRange();
     this.fieldpad1   = binaryReader.ReadBytes(12);
     this.DebugColor  = binaryReader.ReadVector4();
     this.BaseMap     = binaryReader.ReadTagReference();
     this.DetailMap   = binaryReader.ReadTagReference();
     return(pointerQueue);
 }
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.RasterizerScreenEffectTexcoordGenerationAdvancedControlStage0Flags = ((Stage0Flags)(binaryReader.ReadInt16()));
     this.RasterizerScreenEffectTexcoordGenerationAdvancedControlStage1Flags = ((Stage1Flags)(binaryReader.ReadInt16()));
     this.RasterizerScreenEffectTexcoordGenerationAdvancedControlStage2Flags = ((Stage2Flags)(binaryReader.ReadInt16()));
     this.RasterizerScreenEffectTexcoordGenerationAdvancedControlStage3Flags = ((Stage3Flags)(binaryReader.ReadInt16()));
     this.Stage0Offset = binaryReader.ReadVector4();
     this.Stage1Offset = binaryReader.ReadVector4();
     this.Stage2Offset = binaryReader.ReadVector4();
     this.Stage3Offset = binaryReader.ReadVector4();
     return(pointerQueue);
 }
示例#26
0
        public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
        {
            System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
            int i;

            for (i = 0; (i < 4); i = (i + 1))
            {
                this.Points00[i] = new PointsBlock();
                pointerQueue     = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(pointerQueue.Concat(this.Points00[i].ReadFields(binaryReader)));
            }
            this.Color = binaryReader.ReadVector4();
            return(pointerQueue);
        }
        /// <summary>
        /// Updates the AudienceMember current's face(2D) or color(3D) according to their interest level.
        /// </summary>
        /// <author> Oummar Mayaki </author>
        private void updateFace()
        {
            // With view direction
            if (TrackingSideTool.Get().LookRightCheckBox.IsChecked == true)
            {
                // Face
                if (GlobalInterest + interest <= this.thresholds[0] * 2)
                {
                    currentFace = "Audience_Bore";
                }
                else if (GlobalInterest + interest > this.thresholds[1] * 2)
                {
                    currentFace = "Audience_Interest";
                }
                else
                {
                    currentFace = "Audience_SlightBore";
                }

                // Color
                float totalInterest = (GlobalInterest + interest) / 2;
                float red           = Math.Min(2 - (2 * totalInterest), 1) * 150 / 255f;
                float green         = Math.Min(totalInterest * 2, 1) * 150 / 255f;
                faceColor = new OpenTK.Vector4(red, green, 0, 1);
            }

            // Without view direction
            else
            {
                // Face
                if (GlobalInterest <= this.thresholds[0])
                {
                    currentFace = "Audience_Bore";
                }
                else if (GlobalInterest > this.thresholds[1])
                {
                    currentFace = "Audience_Interest";
                }
                else
                {
                    currentFace = "Audience_SlightBore";
                }

                // Color
                float red   = Math.Min(2 - (2 * GlobalInterest), 1) * 150 / 255f;
                float green = Math.Min(GlobalInterest * 2, 1) * 150 / 255f;
                faceColor = new OpenTK.Vector4(red, green, 0, 1);
            }
        }
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.SpringStrengthCoefficient = binaryReader.ReadSingle();
     this.fieldpad      = binaryReader.ReadBytes(24);
     this.Angles        = binaryReader.ReadVector2();
     this.Length        = binaryReader.ReadSingle();
     this.SequenceIndex = binaryReader.ReadInt16();
     this.fieldpad0     = binaryReader.ReadBytes(2);
     this.Color         = binaryReader.ReadVector4();
     this.LODColor      = binaryReader.ReadVector4();
     this.fieldpad1     = binaryReader.ReadBytes(40);
     this.fieldpad2     = binaryReader.ReadBytes(12);
     return(pointerQueue);
 }
 public override System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> ReadFields(System.IO.BinaryReader binaryReader)
 {
     System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer> pointerQueue = new System.Collections.Generic.Queue <Moonfish.Tags.BlamPointer>(base.ReadFields(binaryReader));
     this.TextReferenceTextFlags          = ((TextFlags)(binaryReader.ReadInt32()));
     this.AnimationIndex                  = ((AnimationIndexEnum)(binaryReader.ReadInt16()));
     this.IntroAnimationDelayMilliseconds = binaryReader.ReadInt16();
     this.fieldpad        = binaryReader.ReadBytes(2);
     this.CustomFont      = ((CustomFontEnum)(binaryReader.ReadInt16()));
     this.TextColor       = binaryReader.ReadVector4();
     this.TextBounds      = binaryReader.ReadVector2();
     this.StringId        = binaryReader.ReadStringID();
     this.RenderDepthBias = binaryReader.ReadInt16();
     this.fieldpad0       = binaryReader.ReadBytes(2);
     return(pointerQueue);
 }
示例#30
0
        void OpenGLViewContainerOnLoad(object sender, EventArgs e)
        {
            UpdateProjectionButtons();
            UpdateModeButtons();

            for (int i = MinEdgeCount; i <= MaxEdgeCount; ++i)
            {
                this.toolStripComboBoxNumEdges.Items.Add(i.ToString());
            }

            this.toolStripComboBoxNumEdges.SelectedIndex = (DefaultEdgeCount - MinEdgeCount);


            this.loaded = true;

            GL.Enable(EnableCap.DepthTest);

            GL.Enable(EnableCap.Light0);

            GL.Light(LightName.Light0, LightParameter.Ambient, new float[] { 0.0f, .0f, .0f, 1.0f });
            GL.Light(LightName.Light0, LightParameter.Diffuse, new float[] { 1, 1, 1, 1 });
            GL.Light(LightName.Light0, LightParameter.Specular, new float[] { 0, 0, 0, 1 });

            // Position the light.
            GL.Light(LightName.Light0, LightParameter.Position, new float[] { 0, 0, 1, 0 });

            var materialKa = new OpenTK.Vector4(1, 1, 1, 1);
            var materialKd = new OpenTK.Vector4(1, 1, 1, 1);
            var materialKe = new OpenTK.Vector4(0, 0, 0, 1);

            GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Ambient, materialKa);
            GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Diffuse, materialKd);
            GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Emission, materialKe);

            GL.Enable(EnableCap.ColorMaterial);
            GL.ColorMaterial(MaterialFace.FrontAndBack, ColorMaterialParameter.AmbientAndDiffuse);

            GL.Enable(EnableCap.CullFace);
            GL.Enable(EnableCap.Lighting);

            float[] a = new float [] { 0.3f, 0.3f, 0.3f, 1.0f };
            GL.LightModel(LightModelParameter.LightModelAmbient, a);

            GL.Enable(EnableCap.Normalize);
        }
示例#31
0
        /// <summary>
        /// Draws an irregeular cone
        /// </summary>
        /// <param name="strains">The x,y,z,w radii</param>
        /// <param name="top">The position of the top of the cone</param>
        /// <param name="L1">The direction of the cone</param>
        /// <param name="rot">The rotation of the cone</param>
        /// <param name="resolution">The amount of lines the cone shoud be drawn from</param>
        /// <param name="scale">The height of the cone</param>
        public static void CreateIrregularCone(OpenTK.Vector4 strains, OpenTK.Vector3 top, OpenTK.Vector3 L1, OpenTK.Quaternion rot, int resolution, float scale)
        {
            L1.Normalize();
            List <OpenTK.Vector3> positions = new List <OpenTK.Vector3>();

            positions.AddRange(GetQuarter(strains.X, strains.Y, top, L1, rot, resolution, 1, scale));
            positions.AddRange(GetQuarter(strains.Z, strains.Y, top, L1, rot, resolution, 2, scale));
            positions.AddRange(GetQuarter(strains.Z, strains.W, top, L1, rot, resolution, 3, scale));
            positions.AddRange(GetQuarter(strains.X, strains.W, top, L1, rot, resolution, 4, scale));
            OpenTK.Vector3 prev = positions.First();
            Color          c;
            Color          c2 = Color.black;
            int            i  = 0;

            foreach (OpenTK.Vector3 v in positions)
            {
                float part = ((float)i % ((float)resolution / 4f)) / ((float)resolution / 4f);
                if (i < resolution * 0.25)
                {  //Q1
                    c = Color.Lerp(Color.blue, Color.red, part);
                }
                else if (i < resolution * 0.5)
                {   //Q4
                    c = Color.Lerp(Color.red, Color.green, part);
                }
                else if (i < resolution * 0.75)
                {   //Q3
                    c = Color.Lerp(Color.green, Color.yellow, part);
                }
                else
                {   //Q2
                    c = Color.Lerp(Color.yellow, Color.blue, part);
                }
                i++;
                DrawLine(v, prev, c2);
                DrawLine(top, v, c);
                prev = v;
            }

            c = Color.blue;
            DrawLine(prev, positions.First(), c);
            DrawLine(top, positions.First(), c);
            //return positions.ToArray();
        }
		private void editorX_Edited(object sender, EventArgs e)
		{
			if (this.IsUpdatingFromObject) return;
			if (!this.ReadOnly)
			{
				object[] values = this.GetValue().ToArray();
				Vector4 newVal = (Vector4)this.DisplayedValue;
				for (int i = 0; i < values.Length; i++)
				{
					if (values[i] == null)
						values[i] = this.DisplayedValue;
					else
					{
						Vector4 oldVal = (Vector4)values[i];
						values[i] = new Vector4(newVal.X, oldVal.Y, oldVal.Z, oldVal.W);
					}
				}
				this.SetValues(values);
			}
			this.PerformGetValue();
		}
示例#33
0
 void SetSun()
 {
     ambientColor = new OpenTK.Vector4(ambient, ambient, ambient, difuse);
     difuseColor = new OpenTK.Vector4(difuse, difuse, difuse, difuse);
     specularColor = new OpenTK.Vector4(specular, specular, specular, specular);
     GL.Light(LightName.Light0, LightParameter.Ambient, ambientColor);
     GL.Light(LightName.Light0, LightParameter.Diffuse, difuseColor);
     GL.Light(LightName.Light0, LightParameter.Specular, specularColor);
     GL.Light(LightName.Light0, LightParameter.Position, sunPos);
 }
示例#34
0
		public void SetValue (Vector4 value)
		{
			GL.UseProgram(_parentEffect.CurrentTechnique.Passes[0].shaderProgram);			
			OpenTK.Vector4 vect4 = new OpenTK.Vector4(value.X, value.Y, value.Z, value.W);
			_cachedValue = vect4;
			GL.Uniform4(internalIndex,vect4.X, vect4.Y, vect4.Z, vect4.W);
			GL.UseProgram(0);	
		}
        void OpenGLViewContainerOnLoad(object sender, EventArgs e)
        {
            UpdateProjectionButtons();
            UpdateModeButtons();

            for (int i = MinEdgeCount; i <= MaxEdgeCount; ++i)
            {
                this.toolStripComboBoxNumEdges.Items.Add(i.ToString());
            }

            this.toolStripComboBoxNumEdges.SelectedIndex = (DefaultEdgeCount - MinEdgeCount);

            this.loaded = true;

            GL.Enable(EnableCap.DepthTest);

            GL.Enable(EnableCap.Light0);

            GL.Light(LightName.Light0, LightParameter.Ambient, new float[] { 0.0f, .0f, .0f, 1.0f });
            GL.Light(LightName.Light0, LightParameter.Diffuse, new float[] { 1, 1, 1, 1 });
            GL.Light(LightName.Light0, LightParameter.Specular, new float[] { 0, 0, 0, 1 });

            // Position the light.
            GL.Light(LightName.Light0, LightParameter.Position, new float[] { 0, 0, 1, 0 });

            var materialKa = new OpenTK.Vector4(1, 1, 1, 1);
            var materialKd = new OpenTK.Vector4(1, 1, 1, 1);
            var materialKe = new OpenTK.Vector4(0, 0, 0, 1);
            GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Ambient, materialKa);
            GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Diffuse, materialKd);
            GL.Material(MaterialFace.FrontAndBack, MaterialParameter.Emission, materialKe);

            GL.Enable(EnableCap.ColorMaterial);
            GL.ColorMaterial(MaterialFace.FrontAndBack, ColorMaterialParameter.AmbientAndDiffuse);

            GL.Enable(EnableCap.CullFace);
            GL.Enable(EnableCap.Lighting);

            float[] a = new float [] {0.3f, 0.3f, 0.3f, 1.0f };
            GL.LightModel(LightModelParameter.LightModelAmbient, a);

            GL.Enable(EnableCap.Normalize);
        }
示例#36
0
        // Unprojects the given matricies with the given mouse coordinates to return whatevers
        private void unproject(ref float mx, ref float my, float mz, ref OpenTK.Matrix4 mdlv, ref OpenTK.Matrix4 proj, ref float[] viewport, out float x, out float y, out float z)
        {
            // Variables
            OpenTK.Vector4	i=	new OpenTK.Vector4(0, 0, 0, 0);
            OpenTK.Matrix4	f;

            f=	OpenTK.Matrix4.Mult(mdlv, proj);
            f.Invert();

            i.X=	(mx-viewport[0])/viewport[2];
            i.Y=	(my-viewport[1])/viewport[3];
            i.Z=	mz;
            i.W=	1f;

            i.X=	i.X*2f-1f;
            i.Y=	i.Y*2f-1f;
            i.Z=	i.Z*2f-1f;

            i=	OpenTK.Vector4.Transform(i, f);

            if(i.W!= 0f)
            {
                i.X/=	i.W;
                i.Y/=	i.W;
                i.Z/=	i.W;
            }

            x=	i.X;
            y=	i.Y;
            z=	i.Z;
        }