示例#1
0
 private void PositionChanged(SgtFloatingCamera camera)
 {
     if (SgtHelper.Enabled(Visual) == true && camera.Scale == Visual.Scale)
     {
         UpdateOrbit();
     }
 }
示例#2
0
        public void UpdateOrbit()
        {
            var position = ParentPoint.Position;
            var rotation = ParentPoint.transform.rotation * Quaternion.Euler(Tilt);
            var r1       = Radius;
            var r2       = Radius * (1.0f - Oblateness);
            var localX   = System.Math.Sin(Angle * Mathf.Deg2Rad) * r1;
            var localY   = 0.0;
            var localZ   = System.Math.Cos(Angle * Mathf.Deg2Rad) * r2;

            Rotate(rotation, ref localX, ref localY, ref localZ);

            position.LocalX += localX;
            position.LocalY += localY;
            position.LocalZ += localZ;
            position.SnapLocal();

            cachedPoint.Position = position;
            cachedPoint.PositionChanged();

            if (SgtHelper.Enabled(Visual) == true)
            {
                Visual.Draw(this);
            }
        }
 private void FloatingCameraSnap(SgtFloatingCamera floatingCamera, Vector3 delta)
 {
     if (SgtHelper.Enabled(Visual) == true && floatingCamera.IsRendering(gameObject.layer) == true)
     {
         UpdateOrbit();
     }
 }
示例#4
0
        protected override void OnInspector()
        {
            BeginDisabled();
            DrawDefault("material", "The material that will be applied to all renderers.");
            EndDisabled();

            Each(t => t.RemoveMaterial());
            DrawDefault("renderers", "The renderers the Material will be applied to.");
            Each(t => { if (SgtHelper.Enabled(t) == true)
                        {
                            t.ApplyMaterial();
                        }
                 });
        }
示例#5
0
        protected virtual void OnDrawGizmosSelected()
        {
            if (SgtHelper.Enabled(this) == true)
            {
                var matrix = default(Matrix4x4);
                var ratio  = default(float);

                if (CalculateShadow(ref matrix, ref ratio) == true)
                {
                    Gizmos.matrix = matrix.inverse;

                    var distA = 0.0f;
                    var distB = 1.0f;
                    var scale = 1.0f * Mathf.Deg2Rad;
                    var inner = SgtHelper.Divide(RadiusMin, RadiusMax);

                    for (var i = 1; i < 10; i++)
                    {
                        var posA = new Vector3(0.0f, 0.0f, distA);
                        var posB = new Vector3(0.0f, 0.0f, distB);

                        Gizmos.color = new Color(1.0f, 1.0f, 1.0f, Mathf.Pow(0.75f, i) * 0.125f);

                        for (var a = 1; a <= 360; a++)
                        {
                            posA.x = posB.x = Mathf.Sin(a * scale);
                            posA.y = posB.y = Mathf.Cos(a * scale);

                            Gizmos.DrawLine(posA, posB);

                            posA.x = posB.x = posA.x * inner;
                            posA.y = posB.y = posA.y * inner;

                            Gizmos.DrawLine(posA, posB);
                        }

                        distA = distB;
                        distB = distB * 2.0f;
                    }
                }
            }
        }
示例#6
0
文件: SgtLight.cs 项目: dqchess/twin
        public static List <SgtLight> Find()
        {
            tempLights.Clear();

            var light = FirstInstance;

            for (var i = 0; i < InstanceCount; i++)
            {
                var cachedLight = light.CachedLight;

                if (SgtHelper.Enabled(cachedLight) == true && cachedLight.intensity > 0.0f)
                {
                    tempLights.Add(light);
                }

                light = light.NextInstance;
            }

            // TODO: Sort by apparent brightness

            return(tempLights);
        }
示例#7
0
        private void HandleDrawQuad(Camera camera, SgtTerrainQuad quad, Matrix4x4 matrix, int layer)
        {
            var finalSharedMaterial = sharedMaterial;

            if (OnOverrideSharedMaterial != null)
            {
                OnOverrideSharedMaterial.Invoke(ref finalSharedMaterial, camera);
            }

            if (SgtHelper.Enabled(finalSharedMaterial) == true && finalSharedMaterial.Material != null)
            {
                //if (cameraOffset != 0.0f)
                //{
                //	var direction = Vector3.Normalize(camera.transform.position - transform.position);
                //
                //	matrix = Matrix4x4.Translate(direction * cameraOffset) * matrix;
                //}

                foreach (var mesh in quad.CurrentMeshes)
                {
                    Graphics.DrawMesh(mesh, matrix, finalSharedMaterial.Material, gameObject.layer, camera);
                }
            }
        }