public override OpenTK.Vector2 ModifyRange(OpenTK.Vector2 source_range)
        {
            // Three cases to handle:
            //	 1.) min and max both positive - no change.
            //  2.) min and max both negative - make both positive and flip max and min.
            //  3.) min negative, max positive - new min = 0, new max = larger of (old max) or (-old min)
            //
            OpenTK.Vector2 modified_range;

            if (source_range.X >= 0.0f)
            {
                modified_range = source_range;
            }
            else if (source_range.Y < 0.0f)
            {
                modified_range.X = -1.0f * source_range.Y;
                modified_range.Y = -1.0f * source_range.X;
            }
            else
            {
                modified_range.X = 0.0f;
                modified_range.Y = System.Math.Max(source_range.Y, -1.0f * source_range.X);
            }

            return(modified_range);
        }
        public override OpenTK.Vector2 GetNoiseRange()
        {
            if (m_basis_noise_module == null)
            {
                throw new System.InvalidOperationException("Cannot evaluate fractal noise when no basis noise module has been provided.");
            }

            float persistence = System.Convert.ToSingle(System.Math.Pow(m_lacunarity, -1.0f * m_fractal_increment));

            float amplitude_min           = 0.0f;
            float amplitude_max           = 0.0f;
            float current_amplitude_scale = 1.0f;

            OpenTK.Vector2 basis_noise_range = m_basis_noise_module.GetNoiseRange();

            for (uint octave = 0; octave < m_num_octaves; ++octave)
            {
                amplitude_min += (basis_noise_range.X * current_amplitude_scale);
                amplitude_max += (basis_noise_range.Y * current_amplitude_scale);

                current_amplitude_scale *= persistence;
            }

            OpenTK.Vector2 output_noise_range = new OpenTK.Vector2(amplitude_min, amplitude_max);

            foreach (var modifier in m_modifiers)
            {
                output_noise_range = modifier.ModifyRange(output_noise_range);
            }

            return(output_noise_range);
        }
コード例 #3
0
 internal FlockSourceBlockBase(BinaryReader binaryReader)
 {
     this.position = binaryReader.ReadVector3();
     this.startingYawPitchDegrees = binaryReader.ReadVector2();
     this.radius = binaryReader.ReadSingle();
     this.weight = binaryReader.ReadSingle();
 }
コード例 #4
0
 internal  ScenarioCutsceneFlagBlockBase(BinaryReader binaryReader)
 {
     this.invalidName_ = binaryReader.ReadBytes(4);
     this.name = binaryReader.ReadString32();
     this.position = binaryReader.ReadVector3();
     this.facing = binaryReader.ReadVector2();
 }
コード例 #5
0
        protected Action <IEnumerable <object> > CreateUniformVec2ValueSetter(string name)
        {
            return(delegate(IEnumerable <object> values)
            {
                IEnumerator <OpenTK.Vector2> valuesEnum = values.Cast <OpenTK.Vector2>().GetEnumerator();
                BatchInfo[] batchInfoArray = this.GetValue().Cast <BatchInfo>().ToArray();

                OpenTK.Vector2 curValue = OpenTK.Vector2.Zero;
                if (valuesEnum.MoveNext())
                {
                    curValue = valuesEnum.Current;
                }
                foreach (BatchInfo info in batchInfoArray)
                {
                    if (info != null)
                    {
                        info.SetUniform(name, 0, curValue.X);
                        info.SetUniform(name, 1, curValue.Y);
                    }
                    if (valuesEnum.MoveNext())
                    {
                        curValue = valuesEnum.Current;
                    }
                }
                this.OnPropertySet(ReflectionInfo.Property_BatchInfo_Uniforms, batchInfoArray);
            });
        }
コード例 #6
0
 internal ActorStartingLocationsBlockBase(BinaryReader binaryReader)
 {
     this.name                    = binaryReader.ReadStringID();
     this.position                = binaryReader.ReadVector3();
     this.referenceFrame          = binaryReader.ReadInt16();
     this.invalidName_            = binaryReader.ReadBytes(2);
     this.facingYawPitchDegrees   = binaryReader.ReadVector2();
     this.flags                   = (Flags)binaryReader.ReadInt32();
     this.characterType           = binaryReader.ReadShortBlockIndex1();
     this.initialWeapon           = binaryReader.ReadShortBlockIndex1();
     this.initialSecondaryWeapon  = binaryReader.ReadShortBlockIndex1();
     this.invalidName_0           = binaryReader.ReadBytes(2);
     this.vehicleType             = binaryReader.ReadShortBlockIndex1();
     this.seatType                = (SeatType)binaryReader.ReadInt16();
     this.grenadeType             = (GrenadeType)binaryReader.ReadInt16();
     this.swarmCount              = binaryReader.ReadInt16();
     this.actorVariantName        = binaryReader.ReadStringID();
     this.vehicleVariantName      = binaryReader.ReadStringID();
     this.initialMovementDistance = binaryReader.ReadSingle();
     this.emitterVehicle          = binaryReader.ReadShortBlockIndex1();
     this.initialMovementMode     = (InitialMovementMode)binaryReader.ReadInt16();
     this.placementScript         = binaryReader.ReadString32();
     this.invalidName_1           = binaryReader.ReadBytes(2);
     this.invalidName_2           = binaryReader.ReadBytes(2);
 }
コード例 #7
0
        public static OpenTK.Vector2 GetVector2(this JToken tok, OpenTK.Vector2?defaultValue = null)
        {
            if (!tok.IsValid() || tok.Type != JTokenType.Array || ((JArray)tok).Count != 2)
            {
                if (defaultValue.HasValue)
                {
                    return(defaultValue.Value);
                }
                return(OpenTK.Vector2.Zero);
            }

            OpenTK.Vector2 vec     = new OpenTK.Vector2();
            var            asArray = (JArray)tok;

            for (int i = 0; i < 2; ++i)
            {
                var val = asArray[i];
                if (val == null || (val.Type != JTokenType.Integer && val.Type != JTokenType.Float))
                {
                    if (defaultValue.HasValue)
                    {
                        return(defaultValue.Value);
                    }
                    return(OpenTK.Vector2.Zero);
                }
                vec[i] = (float)val;
            }
            return(vec);
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: Metapyziks/ASMCellSim
        internal Program()
            : base(800, 600, new GraphicsMode( new ColorFormat( 8, 8, 8, 0 ), 0, 0, 4 ), "ASMCellSim Visualizer")
        {
            myWorld = new World( 256f, true );
            myCamPos = new OpenTK.Vector2( 128f, 128f );
            myCamScale = 4.0f;

            myUpdatePeriod = 1f / 60f;

            myTimer = new Stopwatch();

            Random rand = new Random();

            for ( int g = 0; g < 64; ++g )
            {
                int chainLength = rand.Next( 4, 17 );
                Vector2 start = new Vector2( (float) rand.NextDouble() * myWorld.Width, (float) rand.NextDouble() * myWorld.Height );
                float ang = (float) ( rand.NextDouble() * Math.PI * 2.0 );
                Vector2 add = new Vector2( (float) Math.Cos( ang ), (float) Math.Sin( ang ) ) * Cell.Radius * 2f;
                Cell[] cells = new Cell[ chainLength ];
                for ( int i = 0; i < chainLength; ++i )
                {
                    cells[ i ] = myWorld.AddCell( start + add * i + new Vector2( rand.NextDouble() - 0.5, rand.NextDouble() - 0.5 ) );

                    if ( i > 0 )
                        cells[ i ].Attach( cells[ i - 1 ], Hectant.Front, Hectant.Back );
                }

                myDraggedCell = cells[ 0 ];
            }
        }
コード例 #9
0
 internal GlobalWaterDefinitionsBlockBase(BinaryReader binaryReader)
 {
     this.shader              = binaryReader.ReadTagReference();
     this.section             = ReadWaterGeometrySectionBlockArray(binaryReader);
     this.geometryBlockInfo   = new GlobalGeometryBlockInfoStructBlock(binaryReader);
     this.sunSpotColor        = binaryReader.ReadColorR8G8B8();
     this.reflectionTint      = binaryReader.ReadColorR8G8B8();
     this.refractionTint      = binaryReader.ReadColorR8G8B8();
     this.horizonColor        = binaryReader.ReadColorR8G8B8();
     this.sunSpecularPower    = binaryReader.ReadSingle();
     this.reflectionBumpScale = binaryReader.ReadSingle();
     this.refractionBumpScale = binaryReader.ReadSingle();
     this.fresnelScale        = binaryReader.ReadSingle();
     this.sunDirHeading       = binaryReader.ReadSingle();
     this.sunDirPitch         = binaryReader.ReadSingle();
     this.fOV               = binaryReader.ReadSingle();
     this.aspect            = binaryReader.ReadSingle();
     this.height            = binaryReader.ReadSingle();
     this.farz              = binaryReader.ReadSingle();
     this.rotateOffset      = binaryReader.ReadSingle();
     this.center            = binaryReader.ReadVector2();
     this.extents           = binaryReader.ReadVector2();
     this.fogNear           = binaryReader.ReadSingle();
     this.fogFar            = binaryReader.ReadSingle();
     this.dynamicHeightBias = binaryReader.ReadSingle();
 }
コード例 #10
0
        /// <summary>
        /// Transform a single Vector2 object and return the result.
        /// </summary>
        /// <param name="mat"></param>
        /// <param name="p"></param>
        /// <returns></returns>
        public static tk.Vector2 eTransformSingleVector2(this d2d.Matrix mat, tk.Vector2 p)
        {
            var tmp = new tk.Vector2[] { p };

            mat.eTransformVector2(tmp);
            return(tmp[0]);
        }
コード例 #11
0
        public void TestComplexInversableLocalAndWorldConversion_World()
        {
            var t = new Transform();

            t.Translate(new Vector2(1, 2), Space.World);
            var tpInput = new Vector2(1, 2);
            var tpLocal = t.TransformPoint(tpInput, Space.Local);
            var tpWorld = t.TransformPoint(tpLocal, Space.World);

            Assert.AreEqual(tpInput, tpWorld);

            t.Rotate(90);
            var rpInput = new Vector2(-11, 2);
            var rpLocal = t.TransformPoint(rpInput, Space.Local);
            var rpWorld = t.TransformPoint(rpLocal, Space.World);

            Assert.AreEqual(rpInput, rpWorld);

            t.Scale(3f, 2f, Space.World);
            var spInput = new Vector2(40, 20);
            var spLocal = t.TransformPoint(spInput, Space.Local);
            var spWorld = t.TransformPoint(spLocal, Space.World);

            Assert.AreEqual(spInput, spWorld);
        }
コード例 #12
0
 internal ScenarioFunctionBlockBase(BinaryReader binaryReader)
 {
     this.flags                  = (Flags)binaryReader.ReadInt32();
     this.name                   = binaryReader.ReadString32();
     this.periodSeconds          = binaryReader.ReadSingle();
     this.scalePeriodBy          = binaryReader.ReadShortBlockIndex1();
     this.function               = (Function)binaryReader.ReadInt16();
     this.scaleFunctionBy        = binaryReader.ReadShortBlockIndex1();
     this.wobbleFunction         = (WobbleFunctionCurveUsedForWobble)binaryReader.ReadInt16();
     this.wobblePeriodSeconds    = binaryReader.ReadSingle();
     this.wobbleMagnitudePercent = binaryReader.ReadSingle();
     this.squareWaveThreshold    = binaryReader.ReadSingle();
     this.stepCount              = binaryReader.ReadInt16();
     this.mapTo                  = (MapTo)binaryReader.ReadInt16();
     this.sawtoothCount          = binaryReader.ReadInt16();
     this.invalidName_           = binaryReader.ReadBytes(2);
     this.scaleResultBy          = binaryReader.ReadShortBlockIndex1();
     this.boundsMode             = (BoundsModeControlsHowBoundsBelowAreUsed)binaryReader.ReadInt16();
     this.bounds                 = binaryReader.ReadVector2();
     this.invalidName_0          = binaryReader.ReadBytes(4);
     this.invalidName_1          = binaryReader.ReadBytes(2);
     this.turnOffWith            = binaryReader.ReadShortBlockIndex1();
     this.invalidName_2          = binaryReader.ReadBytes(16);
     this.invalidName_3          = binaryReader.ReadBytes(16);
 }
コード例 #13
0
        public ParticleDigging(World world, Vector3 pos, Vector3 motion, float particleScale, BlockState state, FaceSides side) : base(world, pos, motion, particleScale, JsonModelLoader.TextureBlocks)
        {
            State = state;

            if (state.Model.RawModel is ModelBlockRaw)
            {
                var tex = state.Model.ParticleTexture;

                Vector2 start = tex.UVMin;
                Vector2 end   = tex.UVMax;

                Vector2 size = end - start;

                Vector2 pixel = size / 16;

                UVmin = start + pixel * new Vector2(MathUtil.NextFloat(0, 12), MathUtil.NextFloat(0, 12));
                UVmax = UVmin + pixel * 4;
            }

            if (side == FaceSides.Up)
            {
                Motion.Xz = SharpCraft.Instance.Camera.GetLookVec().Xz * 0.15f;
            }

            Vector3 vec = new Vector3(MathUtil.NextFloat(-1), MathUtil.NextFloat(-1), MathUtil.NextFloat(-1));

            _rotStep = vec.Normalized() * MathUtil.NextFloat(40, 75);
        }
コード例 #14
0
        public static GameObject CreateCube(Vector3 position, Vector3 scale, Quaternion rotation, Texture texture,
                                            ShaderProgram program, Vector2 tiling, Vector2 offset, Texture tesS = null, int mass = -1)
        {
            GameObject box = new GameObject(position, "Box");

            box.Scale    = scale;
            box.Rotation = rotation;
            Mesh cube = Prefabs.Cube;
            LitMeshRendererComponent mr = new LitMeshRendererComponent(program, cube, texture, 1, false);

            if (tesS != null)
            {
                tesS.TexType = TextureType.Specular;
                mr.Textures  = new[] { mr.Textures[0], tesS };
            }

            mr.Tiling = tiling;
            mr.Offset = offset;
            box.AddComponent(mr);
            Vector3  bounds = scale * 2;
            Collider coll;

            if (mass == -1)
            {
                coll = new Collider(new Box(Vector3.Zero, bounds.X, bounds.Y, bounds.Z), "physics");
            }
            else
            {
                coll = new Collider(new Box(Vector3.Zero, bounds.X, bounds.Y, bounds.Z, mass), "physics");
            }

            coll.PhysicsCollider.Material = new Material(0.1f, 0.1f, 0.1f);
            box.AddComponent(coll);
            return(box);
        }
コード例 #15
0
        private static Ray ConstructRayFromMousePosition(Vector3 localPosition)
        {
            Vector2 mpos     = GameEngine.Instance.MousePosition;
            Vector3 mousepos = GameEngine.Instance.ConvertScreenToWorldCoords((int)mpos.X, (int)mpos.Y);

            return(new Ray(localPosition, (mousepos - localPosition).Normalized()));
        }
コード例 #16
0
 internal ScenarioAtmosphericFogPaletteBase(BinaryReader binaryReader)
 {
     this.name  = binaryReader.ReadStringID();
     this.color = binaryReader.ReadColorR8G8B8();
     this.spreadDistanceWorldUnits = binaryReader.ReadSingle();
     this.invalidName_             = binaryReader.ReadBytes(4);
     this.maximumDensity01         = binaryReader.ReadSingle();
     this.startDistanceWorldUnits  = binaryReader.ReadSingle();
     this.opaqueDistanceWorldUnits = binaryReader.ReadSingle();
     this.color0                          = binaryReader.ReadColorR8G8B8();
     this.invalidName_0                   = binaryReader.ReadBytes(4);
     this.maximumDensity010               = binaryReader.ReadSingle();
     this.startDistanceWorldUnits0        = binaryReader.ReadSingle();
     this.opaqueDistanceWorldUnits0       = binaryReader.ReadSingle();
     this.invalidName_1                   = binaryReader.ReadBytes(4);
     this.planarColor                     = binaryReader.ReadColorR8G8B8();
     this.planarMaxDensity01              = binaryReader.ReadSingle();
     this.planarOverrideAmount01          = binaryReader.ReadSingle();
     this.planarMinDistanceBiasWorldUnits = binaryReader.ReadSingle();
     this.invalidName_2                   = binaryReader.ReadBytes(44);
     this.patchyColor                     = binaryReader.ReadColorR8G8B8();
     this.invalidName_3                   = binaryReader.ReadBytes(12);
     this.patchyDensity01                 = binaryReader.ReadVector2();
     this.patchyDistanceWorldUnits        = binaryReader.ReadRange();
     this.invalidName_4                   = binaryReader.ReadBytes(32);
     this.patchyFog                       = binaryReader.ReadTagReference();
     this.mixers                          = ReadScenarioAtmosphericFogMixerBlockArray(binaryReader);
     this.amount01                        = binaryReader.ReadSingle();
     this.threshold01                     = binaryReader.ReadSingle();
     this.brightness01                    = binaryReader.ReadSingle();
     this.gammaPower                      = binaryReader.ReadSingle();
     this.cameraImmersionFlags            = (CameraImmersionFlags)binaryReader.ReadInt16();
     this.invalidName_5                   = binaryReader.ReadBytes(2);
 }
コード例 #17
0
        public void TestCellRasterization()
        {
            var v1 = new Vector2(1.2f, 1.5f);
            var v2 = new Vector2(0.55f, -1.55f);
            var v3 = new Vector2(-2.4f, -1.1f);
            var v4 = new Vector2(-0.5f, 2.3f);

            var h1 = new HalfPlane(v1, v2, Vector2.Zero);
            var h2 = new HalfPlane(v2, v3, Vector2.Zero);
            var h3 = new HalfPlane(v3, v4, Vector2.Zero);
            var h4 = new HalfPlane(v4, v1, Vector2.Zero);

            var isContains = new Predicate <Vector2>(p => HalfPlane.ContainsInConvex(p, new [] { h1, h2, h3, h4 }));

            var boundingBox   = new Box2(-2.4f, 2.3f, 1.2f, -1.55f);
            var result        = Rasterization.ConvexToBlocks(isContains, boundingBox);
            var correctAnswer = new[] { new Vector2i(0, 1), new Vector2i(0, 0), new Vector2i(0, -1), new Vector2i(0, -2),
                                        new Vector2i(-1, 1), new Vector2i(-1, 0), new Vector2i(-1, -1),
                                        new Vector2i(-2, 0), new Vector2i(-2, -1) };

            Assert.That(result, Is.EquivalentTo(correctAnswer));

            //Draw polygon
            //UnityEngine.Debug.DrawLine(v1, v2, Color.blue, 10);
            //UnityEngine.Debug.DrawLine(v2, v3, Color.blue, 10);
            //UnityEngine.Debug.DrawLine(v3, v4, Color.blue, 10);
            //UnityEngine.Debug.DrawLine(v4, v1, Color.blue, 10);

            //Draw bbox
            //DrawRectangle.ForDebug();
        }
コード例 #18
0
ファイル: Camera.cs プロジェクト: xorle/MineEdit
        void control_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
        {
            long ms = movetime.ElapsedMilliseconds;

            movetime.Reset();
            movetime.Start();
            if (MouseEnabled && _lastMouseEnabled && control.Focused)
            {
                float yaw   = Rotation.X;
                float pitch = Rotation.Y;
                yaw            += (e.X - MousePosition.X) * MouseSpeed * (float)ms;
                pitch          += (e.Y - MousePosition.Y) * MouseSpeed * (float)ms;
                yaw             = ((yaw % 360) + 360) % 360;
                pitch           = Math.Max(-90, Math.Min(90, pitch));
                Cursor.Position = control.PointToScreen(MousePosition);
                Rotation        = new Vector2(yaw, pitch);
                //Console.WriteLine("Camera's rotation is now {0}", Rotation);
            }
            else if (MouseEnabled && !_lastMouseEnabled && control.Focused)
            {
                Cursor.Position = control.PointToScreen(MousePosition);
                Cursor.Hide();
                _lastMouseEnabled = true;
            }
            else
            {
                Cursor.Show();
                _lastMouseEnabled = false;
            }
        }
コード例 #19
0
 internal DecalVerticesBlockBase(BinaryReader binaryReader)
 {
     this.position  = binaryReader.ReadVector3();
     this.texcoord0 = binaryReader.ReadVector2();
     this.texcoord1 = binaryReader.ReadVector2();
     this.color     = binaryReader.ReadRGBColor();
 }
コード例 #20
0
 public void BuildObj(GameObject gameObject)
 {
     if (gameObject.m_Components.Length == 3)               // extract monitor data
     {
         Component comp;
         gameObject.m_Components[1].TryGet(out comp);
         if (comp != null && new Guid(comp.serializedType.m_ScriptID).Equals(prop_monitor_script_id))
         {
             is_monitor = true;
             var monitor_data = comp.GetRawData();
             monitor_uv1      = new Vector2(BitConverter.ToSingle(monitor_data, 0x78), BitConverter.ToSingle(monitor_data, 0x7c));
             monitor_uv2      = new Vector2(BitConverter.ToSingle(monitor_data, 0x80), BitConverter.ToSingle(monitor_data, 0x84));
             monitor_sideways = monitor_data[0x88] != 0;
             //System.Diagnostics.Debug.WriteLine(string.Format("uv1 {0} uv2 {1} sideways {2}", monitor_uv1, monitor_uv2, monitor_sideways));
         }
     }
     if (gameObject.m_MeshRenderer != null)
     {
         BuildObj(gameObject.m_MeshRenderer);
     }
     foreach (var childPtr in gameObject.m_Transform.m_Children)
     {
         Transform child;
         if (childPtr.TryGet(out child))
         {
             BuildObj(child);
         }
     }
 }
コード例 #21
0
        public void Rotate()
        {
            OpenTK.Vector2 delta = lastMousePos - new OpenTK.Vector2(OpenTK.Input.Mouse.GetState().X, OpenTK.Input.Mouse.GetState().Y);

            cam.AddRotation(delta.X, delta.Y);
            ResetCursor();
            UpdateImage();
        }
コード例 #22
0
 internal SpriteVerticesBlockBase(BinaryReader binaryReader)
 {
     this.position = binaryReader.ReadVector3();
     this.offset   = binaryReader.ReadVector3();
     this.axis     = binaryReader.ReadVector3();
     this.texcoord = binaryReader.ReadVector2();
     this.color    = binaryReader.ReadRGBColor();
 }
コード例 #23
0
        public static JToken Serialize(this OpenTK.Vector2 vec)
        {
            var res = new JArray();

            res.Add(vec.X);
            res.Add(vec.Y);
            return(res);
        }
コード例 #24
0
 internal CsPointBlockBase(BinaryReader binaryReader)
 {
     this.name            = binaryReader.ReadString32();
     this.position        = binaryReader.ReadVector3();
     this.referenceFrame  = binaryReader.ReadInt16();
     this.invalidName_    = binaryReader.ReadBytes(2);
     this.surfaceIndex    = binaryReader.ReadInt32();
     this.facingDirection = binaryReader.ReadVector2();
 }
コード例 #25
0
        public void TestIdentityInversableLocalAndWorldConversion()
        {
            var t       = new Transform();
            var tpInput = new Vector2(1, 2);
            var tpLocal = t.TransformPoint(tpInput, Space.Local);
            var tpWorld = t.TransformPoint(tpLocal, Space.World);

            Assert.AreEqual(tpInput, tpWorld);
        }
コード例 #26
0
ファイル: InventoryView.cs プロジェクト: Metapyziks/LewtRPG
            protected override void OnRender(OpenTK.Vector2 renderPosition = new Vector2())
            {
                base.OnRender(renderPosition);

                if (Slot.HasItem)
                {
                    Slot.Item.InventoryRender(renderPosition + new Vector2(4, 4));
                }
            }
コード例 #27
0
        /// <summary>
        /// Do not accurately rasterize, need invesigation
        /// </summary>
        /// <param name="v1"></param>
        /// <param name="v2"></param>
        /// <param name="v3"></param>
        /// <returns></returns>
        public static IEnumerable <Vector2i> Triangle(Vector2 v1, Vector2 v2, Vector2 v3)
        {
            //Based on http://www.sunshine2k.de/coding/java/TriangleRasterization/TriangleRasterization.html

            var v1i = (Vector2i)v1;
            var v2i = (Vector2i)v2;
            var v3i = (Vector2i)v3;

            if (v1i.Z > v2i.Z)
            {
                Swap(ref v1, ref v2);
                Swap(ref v1i, ref v2i);
            }
            if (v1i.Z > v3i.Z)
            {
                Swap(ref v1, ref v3);
                Swap(ref v1i, ref v3i);
            }
            if (v2i.Z > v3i.Z)
            {
                Swap(ref v2, ref v3);
                Swap(ref v2i, ref v3i);
            }

            if (v1i.Z == v3i.Z)
            {
                yield break;
            }

            if (v1i.Z == v2i.Z)
            {
                foreach (var pos in FillTopFlatTriangle(v1i, v2i, v3i))
                {
                    yield return(pos);
                }
            }

            else if (v2i.Z == v3i.Z)
            {
                foreach (var pos in FillBottomFlatTriangle(v1i, v2i, v3i))
                {
                    yield return(pos);
                }
            }
            else
            {
                var v4 = new Vector2(v1.X + (v2.Y - v1.Y) / (v3.Y - v1.Y) * (v3.X - v1.X), v2.Y);
                foreach (var pos in FillBottomFlatTriangle(v1i, v2i, (Vector2i)v4))
                {
                    yield return(pos);
                }
                foreach (var pos in FillTopFlatTriangle(v2i, (Vector2i)v4, v3i))
                {
                    yield return(pos);
                }
            }
        }
コード例 #28
0
 internal FiringPositionsBlockBase(BinaryReader binaryReader)
 {
     this.positionLocal  = binaryReader.ReadVector3();
     this.referenceFrame = binaryReader.ReadInt16();
     this.flags          = (Flags)binaryReader.ReadInt16();
     this.area           = binaryReader.ReadShortBlockIndex1();
     this.clusterIndex   = binaryReader.ReadInt16();
     this.invalidName_   = binaryReader.ReadBytes(4);
     this.normal         = binaryReader.ReadVector2();
 }
コード例 #29
0
 public GLVertex(OpenTK.Vector3 a_v3Position, System.Drawing.Color a_oColor, OpenTK.Vector2 a_v2UV)
 {
     m_v3Position = a_v3Position;
     // We order the color RGBA because this is the order expected by OpenGL/Graphics card.
     m_v4Color.X = (OpenTK.Half)(a_oColor.R * 8);
     m_v4Color.Y = (OpenTK.Half)(a_oColor.G * 8);
     m_v4Color.Z = (OpenTK.Half)(a_oColor.B * 8);
     m_v4Color.W = (OpenTK.Half)(a_oColor.A * 8);
     m_v2UV      = a_v2UV;
 }
コード例 #30
0
ファイル: RenderForm.cs プロジェクト: superowner/MLTDTools
        private void RenderForm_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.Button == MouseButton.Right)
            {
                _trackingMouse = true;

                var mouseState = Mouse.GetState();
                _lastMousePos = new Vector2(mouseState.X, mouseState.Y);
            }
        }
コード例 #31
0
ファイル: GLVertex.cs プロジェクト: zenosisalive/Pulsar4x
 public GLVertex(OpenTK.Vector4 a_v4Position, Color4 a_oColor, OpenTK.Vector2 a_v2UV)
 {
     m_v4Position = a_v4Position;
     // We order the color RGBA because this is the order expected by OpenGL/Graphics card.
     m_v4Color.X = a_oColor.R / 255.0f;
     m_v4Color.Y = a_oColor.G / 255.0f;
     m_v4Color.Z = a_oColor.B / 255.0f;
     m_v4Color.W = a_oColor.A / 255.0f;
     m_v2UV      = a_v2UV;
 }
コード例 #32
0
ファイル: GLVertex.cs プロジェクト: EterniaLogic/Pulsar4x
 public GLVertex(OpenTK.Vector4 a_v4Position, System.Drawing.Color a_oColor, OpenTK.Vector2 a_v2UV)
 {
     m_v4Position = a_v4Position;
     // We order the color RGBA because this is the order expected by OpenGL/Graphics card.
     m_v4Color.X = a_oColor.R / 255.0f;
     m_v4Color.Y = a_oColor.G / 255.0f;
     m_v4Color.Z = a_oColor.B / 255.0f;
     m_v4Color.W = a_oColor.A / 255.0f;
     m_v2UV = a_v2UV;
 }
コード例 #33
0
ファイル: OpenTKTestRuntime.cs プロジェクト: hach-que/SLSharp
 public ShaderDefinition.vec2 Convert(Vector2 v)
 {
     var v2 = new OpenTK.Vector2(v.X, v.Y);
     return v2.ToVector2F();
 }
コード例 #34
0
ファイル: GLPrimitive.cs プロジェクト: EterniaLogic/Pulsar4x
 public virtual void SetSize(Vector2 a_v2Size)
 {
     m_v2Size = a_v2Size;
     RecalculateModelMatrix();
 }
コード例 #35
0
ファイル: GLVertex.cs プロジェクト: EterniaLogic/Pulsar4x
        //public GLVertex()
        //{
        //    m_v3Position.X = 0;
        //    m_v3Position.Y = 0;
        //    m_v3Position.Z = 0;

        //    m_v4Color.X = (OpenTK.Half)0;
        //    m_v4Color.Y = (OpenTK.Half)0;
        //    m_v4Color.Z = (OpenTK.Half)0;
        //    m_v4Color.W = (OpenTK.Half)0;

        //    m_v2UV.X = 0;
        //    m_v2UV.Y = 0;
        //}

        public GLVertex(OpenTK.Vector4 a_v4Position, OpenTK.Vector4 a_v4Color, OpenTK.Vector2 a_v2UV)
        {
            m_v4Position = a_v4Position;
            m_v4Color = a_v4Color;
            m_v2UV = a_v2UV;
        }