Beispiel #1
0
 public Light()
 {
     Ambient  = new Vector3(0.3f);
     Diffuse  = new Vector3(0.7f);
     Specular = new Vector3(0.5f);
     Rotation = new Vector2(MathLarx.DegToRad(0), MathLarx.DegToRad(45));
 }
Beispiel #2
0
        private void move(float frameTime)
        {
            var rx = MathLarx.DegToRad(Rotation.X);

            Look.Z += LookSpeed.Z * MathF.Cos(rx);
            Look.X += LookSpeed.Z * MathF.Sin(rx);

            Look.Z += LookSpeed.X * MathF.Cos(rx + MathF.PI / 2);
            Look.X += LookSpeed.X * MathF.Sin(rx + MathF.PI / 2);

            LookSpeed /= (frameTime * LookDeceleration) + 1.0f;
        }
Beispiel #3
0
        public void Update(float frameTime)
        {
            move(frameTime);
            rotate(frameTime);
            zoom(frameTime);

            var rx = MathLarx.DegToRad(Rotation.X);
            var ry = MathLarx.DegToRad(Rotation.Y);

            Position = new Vector3(
                Look.X - (MathF.Sin(rx) * MathF.Cos(ry) * Distance),
                Distance * MathF.Sin(ry),
                Look.Z - (MathF.Cos(rx) * MathF.Cos(ry) * Distance)
                );

            ProjectionMatrix = Matrix4.CreatePerspectiveFieldOfView(MathF.PI / 4f, State.Window.Aspect, State.Near, State.Far);
            ViewMatrix       = Matrix4.LookAt(Position, Look, new Vector3(0, 1, 0));
            FrustumPlanes    = Frustum.ExtractFrustum(ViewMatrix, ProjectionMatrix);
        }
Beispiel #4
0
        public void Add(Vector2 position, TerrainRenderer terrain, string key)
        {
            var elev = terrain.HeightMap.GetElevationAtPoint(position);

            if (elev == null)
            {
                return;
            }

            if (!Map.MapData.Assets.ContainsKey(key))
            {
                Map.MapData.Assets.Add(key, new List <PlacedAsset>());
            }

            var count = (State.ToolHardness - 1) * State.ToolHardness + 1;
            var half  = Map.MapData.MapSize / 2.0f;

            for (var i = 0; i < count; i++)
            {
                var r     = (float)(random.NextDouble() * (State.ToolRadius - 1.0f));
                var angle = (float)(random.NextDouble() * 2 * MathF.PI);
                var x     = position.X + r * MathF.Cos(angle);
                var y     = position.Y + r * MathF.Sin(angle);
                var scale = 1.0f + ((float)(random.NextDouble() * 0.5f) - 0.25f);

                if (x < -half || x >= half - 1 ||
                    y < -half || y >= half - 1)
                {
                    continue;
                }

                Map.MapData.Assets[key].Add(new PlacedAsset(key, new Vector2(x, y), MathLarx.DegToRad((float)random.NextDouble() * 360.0f), scale));
            }

            assetQuadTree.UpdateQuadTree(terrain);
        }