Esempio n. 1
0
        protected override void OnNodeSet()
        {
            base.OnNodeSet();

            m_transformable = DomNode.As<ITransformable>();
            DomNode.AttributeChanged += OnAttributeChanged;
        }
Esempio n. 2
0
 private async void ApplyBitmapTransformation(ITransformable transformation)
 {
     var f = new BitmapTransformation(transformation);
     if (transformation is IProgressTracking) {
         var progressBarForm = new ProgressForm {
             Text = "Идёт применение фильтра: {0} (0%)".F(transformation.ToString())
         };
         progressBarForm.Show();
         var trackingObj = transformation as IProgressTracking;
         trackingObj.ProgressChanged += (s, p) => BeginInvoke((MethodInvoker)delegate {
             progressBarForm.Progress.Value = p.Progress;
             progressBarForm.Text = "Идёт применение фильтра: {0} ({1}%)"
                 .F(transformation.ToString(), p.Progress);
         });
         trackingObj.OperationComplete += (s, p) => BeginInvoke((MethodInvoker)progressBarForm.Close);
     }
     if (transformation is IСonfigurable) {
         var optionsWin = new TransformationOptions {
             PreviewBitmap = (Bitmap) _workingBitmap.Clone()
         };
         optionsWin.Show();
     }
     _workingBitmap = await Task<Bitmap>.Factory.StartNew(() => f.Apply(_workingBitmap));
     _history.SaveState(_workingBitmap);
     UpdateMenuHistoryItems();
     SyncPicture();
 }
Esempio n. 3
0
        public static void Insert(ITransformable item)
        {
            if (tree == null) throw new Exception("SceneManager needs to be initialized before using any of it's methods.");
            if (item == null) throw new ArgumentException("Inserted item can not be null!", "item");

            if (tree.Insert(item))
                ObjectCount++;
        }
Esempio n. 4
0
 /// <summary>
 /// Decomposes the given matrix to translation, scale, 
 /// and rotation and set them to given Transformable node.        
 /// </summary>        
 public static void SetTransform(ITransformable xform, Matrix4F mtrx)
 {
     xform.Translation = mtrx.Translation;
     xform.Scale = mtrx.GetScale();
     Vec3F rot = new Vec3F();
     mtrx.GetEulerAngles(out rot.X, out rot.Y, out rot.Z);
     xform.Rotation = rot;
     xform.UpdateTransform();
 }
Esempio n. 5
0
 public static LinkInfo Link(ITransformable parent, ITransformable child, Vector3 offset, Quaternion Rotation)
 {
     var link = new LinkInfo()
     {
         Parent = parent,
         Child = child,
         Offset = offset,
         Rotation = Rotation
     };
     Links.Add(link);
     return link;
 }
Esempio n. 6
0
 /// <summary>
 /// Computes world transformation matrix for the given 
 /// Transformable node.</summary>        
 public static Matrix4F ComputeWorldTransform(ITransformable xform)
 {
     Matrix4F world = new Matrix4F();
     DomNode node = xform.As<DomNode>();
     foreach (DomNode n in node.Lineage)
     {
         ITransformable xformNode = n.As<ITransformable>();
         if (xformNode != null)
         {
             world.Mul(world, xformNode.Transform);
         }
     }
     return world;
 }
Esempio n. 7
0
        public static Vec3F CalcSnapFromOffset(ITransformable node, SnapFromMode snapFrom)
        {
            // AABB in local space.
            AABB box = node.As<IBoundable>().LocalBoundingBox;

            Vec3F offsetLocal = box.Center;
            switch (snapFrom)
            {
                case SnapFromMode.Pivot:
                    offsetLocal = node.Pivot;
                    break;
                case SnapFromMode.Origin:
                    offsetLocal = box.Center;
                    break;
                case SnapFromMode.TopCenter:
                    offsetLocal.Y = box.Max.Y;
                    break;
                case SnapFromMode.BottomCenter:
                    offsetLocal.Y = box.Min.Y;
                    break;
                case SnapFromMode.FrontCenter:
                    offsetLocal.Z = box.Max.Z;
                    break;
                case SnapFromMode.BackCenter:
                    offsetLocal.Z = box.Min.Z;
                    break;
                case SnapFromMode.LeftCenter:
                    offsetLocal.X = box.Min.X;
                    break;
                case SnapFromMode.RightCenter:
                    offsetLocal.X = box.Max.X;
                    break;
                default:
                    throw new ArgumentOutOfRangeException("Invalid snap-from node");
            }

            Path<DomNode> path = new Path<DomNode>(node.Cast<DomNode>().GetPath());
            Matrix4F toWorld = TransformUtils.CalcPathTransform(path, path.Count - 1);

            Vec3F offset;
            toWorld.TransformVector(offsetLocal, out offset); //local-to-world
            return offset; //world
        }
Esempio n. 8
0
        /// <summary>
        /// For an object 'node' that is being manipulated, this function returns
        /// the offset (in world space) from the object's origin to to the point that is being
        /// "snapped from". This calculation is determined by the snapping modes.</summary>
        /// <param name="node">The object that is being snapped-to some other object</param>
        /// <param name="snapFromMode">The "snap from" mode, as an enum</param>
        /// <param name="axisType">Axis system type (y or z is up)</param>
        /// <param name="pivot">Pass in either node.RotatePivot or node.ScalePivot</param>
        /// <returns>Offset from this object's origin to the "snap from" point, in world space</returns>
        /// <remarks>Must be kept in sync with SnapFromModes property.</remarks>
        public static Vec3F CalcSnapFromOffset(
            ITransformable node,
            SnapFromMode snapFromMode,
            AxisSystemType axisType, Vec3F pivot)
        {
            switch (snapFromMode)
            {
                case SnapFromMode.Pivot:
                    {
                        Vec3F offset;
                        Path<DomNode> path = new Path<DomNode>(node.Cast<DomNode>().Ancestry);
                        Matrix4F parentToWorld = TransformUtils.CalcPathTransform(path, path.Count - 2);
                        node.Transform.TransformVector(pivot, out offset); //local-to-parent
                        parentToWorld.TransformVector(offset, out offset); //parent-to-world
                        return offset; //world
                    }
                case SnapFromMode.Origin:
                    return new Vec3F(0, 0, 0);
                case SnapFromMode.BottomCenter:
                    {
                        Box box = node.BoundingBox;
                        Vec3F btmWorld;
                        if (axisType == AxisSystemType.YIsUp)
                        {
                            btmWorld = new Vec3F(
                                (box.Min.X + box.Max.X) * 0.5f,
                                box.Min.Y,
                                (box.Min.Z + box.Max.Z) * 0.5f);
                        }
                        else
                        {
                            btmWorld = new Vec3F(
                                (box.Min.X + box.Max.X) * 0.5f,
                                (box.Min.Y + box.Max.Y) * 0.5f,
                                box.Min.Z);
                        }
                        Vec3F origin = node.Transform.Translation;
                        Vec3F offset = btmWorld - origin; //local space offset

                        Path<DomNode> path = new Path<DomNode>(node.Cast<DomNode>().GetPath());
                        Matrix4F parentToWorld = TransformUtils.CalcPathTransform(path, path.Count - 2);
                        parentToWorld.TransformVector(offset, out offset);

                        return offset;
                    }
                default:
                    throw new ArgumentException("Invalid snap-from node");
            }
        }
 public BitmapTransformation(ITransformable trans)
 {
     this.Transformation = trans;
 }
Esempio n. 10
0
        public override void OnEndDrag(ViewControl vc, Point scrPt)
        {
            if (CanManipulate(m_node))
            {
                var transactionContext = DesignView.Context.As<ITransactionContext>();
                try
                {
                    if (transactionContext.InTransaction)
                        transactionContext.End();
                }
                catch (InvalidTransactionException ex)
                {
                    if (transactionContext.InTransaction)
                        transactionContext.Cancel();

                    if (ex.ReportError)
                        Outputs.WriteLine(OutputMessageType.Error, ex.Message);
                }
            }

            m_hitRegion = HitRegion.None;
            m_node = null;
        }
Esempio n. 11
0
 public void DrawFrame(MX.Animation animation, ITransformable transformObj, IRenderable renderableObj)
 {
     DrawFrame(animation.Frames[animation.CurrentFrame], transformObj, renderableObj);
 }
 public override bool BeginCapture(ITransformable target, Ray3f worldRay, UIRayHit hit)
 {
     return(true);
 }
Esempio n. 13
0
        public override void OnDragging(ViewControl vc, Point scrPt)
        {
            if (m_hitRegion == HitRegion.None || m_activeOp == null || m_activeOp.NodeList.Count == 0)
            {
                return;
            }
            Camera cam = vc.Camera;

            Matrix4F view = cam.ViewMatrix;
            Matrix4F proj = cam.ProjectionMatrix;

            Matrix4F axisMtrx = HitMatrix * view;
            Ray3F    hitRay   = HitRayV;
            Ray3F    dragRay  = vc.GetRay(scrPt, proj);

            Vec3F xAxis  = axisMtrx.XAxis;
            Vec3F yAxis  = axisMtrx.YAxis;
            Vec3F zAxis  = axisMtrx.ZAxis;
            Vec3F origin = axisMtrx.Translation;

            Vec3F rotAxis = new Vec3F();
            float theta   = 0;

            float snapAngle = ((ISnapSettings)DesignView).SnapAngle;

            switch (m_hitRegion)
            {
            case HitRegion.XAxis:
            {
                Plane3F xplane = new Plane3F(xAxis, origin);
                theta   = CalcAngle(origin, xplane, hitRay, dragRay, snapAngle);
                rotAxis = HitMatrix.XAxis;
            }
            break;

            case HitRegion.YAxis:
            {
                Plane3F yplane = new Plane3F(yAxis, origin);
                theta   = CalcAngle(origin, yplane, hitRay, dragRay, snapAngle);
                rotAxis = HitMatrix.YAxis;
            }
            break;

            case HitRegion.ZAxis:
            {
                Plane3F zplane = new Plane3F(zAxis, origin);
                theta   = CalcAngle(origin, zplane, hitRay, dragRay, snapAngle);
                rotAxis = HitMatrix.ZAxis;
            }
            break;

            case HitRegion.LookAxis:
            {
                // for billboard objects the look vector is object's negative position in viewspace.
                Vec3F   lookAxis = Vec3F.Normalize(-origin);
                Plane3F plane    = new Plane3F(lookAxis, origin);
                theta   = CalcAngle(origin, plane, hitRay, dragRay, snapAngle);
                rotAxis = m_lookAxisHitMtrx.ZAxis;
            }
            break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            AngleAxisF axf       = new AngleAxisF(-theta, rotAxis);
            Matrix4F   deltaMtrx = new Matrix4F(axf);
            Matrix4F   rotMtrx   = new Matrix4F();

            for (int i = 0; i < m_activeOp.NodeList.Count; i++)
            {
                ITransformable node = m_activeOp.NodeList[i];
                rotMtrx.Mul(m_rotations[i], deltaMtrx);
                float ax, ay, az;
                rotMtrx.GetEulerAngles(out ax, out ay, out az);
                node.Rotation = new Vec3F(ax, ay, az);
            }
        }
Esempio n. 14
0
 public static Quaternion GetOrientation(this ITransformable o)
 {
     return(o.GetTransformationManager().Orientation);
 }
Esempio n. 15
0
 public static TransformationManager SetOrientation(this ITransformable o, Quaternion orient)
 {
     o.GetTransformationManager().SetOrientation(orient);
     return(o.GetTransformationManager());
 }
Esempio n. 16
0
        /*public static TransformationManager SetOrientation(this ITransformable o, float pitch, float yaw, float roll)
         * {
         *  o.GetTransformationManager().Orientation = Quaternion.FromEulerAngles(pitch, yaw, roll);
         *  o.GetTransformationManager().MarkAsModified();
         *  return o.GetTransformationManager();
         * }*/

        public static TransformationManager SetPosition(this ITransformable o, Vector3 pos)
        {
            o.GetTransformationManager().SetPosition(pos);
            return(o.GetTransformationManager());
        }
Esempio n. 17
0
 public static TransformationManager Scale(this ITransformable o, Vector3 scale)
 {
     o.GetTransformationManager().Scale(scale);
     return(o.GetTransformationManager());
 }
Esempio n. 18
0
 public static Vector3 GetScale(this ITransformable o)
 {
     return(o.GetTransformationManager().ScaleValue);
 }
Esempio n. 19
0
 public static Vector3 GetPosition(this ITransformable o)
 {
     return(o.GetTransformationManager().Position);
 }
Esempio n. 20
0
 public Transformable(ICanyonShooterGame game, ITransformable owner, ICollisionActor collisionActor)
 {
     Init(game, owner, collisionActor);
 }
Esempio n. 21
0
 public static TransformationManager SetScale(this ITransformable o, float x, float y, float z)
 {
     o.GetTransformationManager().Scale(x, y, z);
     return(o.GetTransformationManager());
 }
Esempio n. 22
0
        private void RenderProperties(GUILayer.SimpleRenderingContext context, IEnumerable <object> objects, bool renderCaption, bool renderBound, bool renderPivot)
        {
            if (renderCaption || renderBound)
            {
                Util3D.SetRenderFlag(context, BasicRendererFlags.WireFrame);
                Matrix4F vp = Camera.ViewMatrix * Camera.ProjectionMatrix;
                foreach (object obj in objects)
                {
                    IBoundable bnode = obj.As <IBoundable>();
                    if (bnode == null || bnode.BoundingBox.IsEmpty || obj.Is <IGameObjectFolder>())
                    {
                        continue;
                    }

                    INameable      nnode = obj.As <INameable>();
                    ITransformable trans = obj.As <ITransformable>();

                    if (renderBound)
                    {
                        Util3D.DrawAABB(context, bnode.BoundingBox);
                    }
                    if (renderCaption && nnode != null)
                    {
                        Vec3F topCenter = bnode.BoundingBox.Center;
                        topCenter.Y = bnode.BoundingBox.Max.Y;
                        Point pt = Project(vp, topCenter);
                        GameEngine.DrawText2D(nnode.Name, Util3D.CaptionFont, pt.X, pt.Y, Color.White);
                    }
                }
            }

            if (renderPivot)
            {
                Util3D.SetRenderFlag(context, BasicRendererFlags.WireFrame | BasicRendererFlags.DisableDepthTest);

                // create few temp matrics to
                Matrix4F toWorld  = new Matrix4F();
                Matrix4F PV       = new Matrix4F();
                Matrix4F sc       = new Matrix4F();
                Matrix4F bl       = new Matrix4F();
                Matrix4F recXform = new Matrix4F();
                foreach (object obj in objects)
                {
                    ITransformable trans = obj.As <ITransformable>();
                    IBoundable     bnode = obj.As <IBoundable>();
                    if (trans == null || bnode == null || bnode.BoundingBox.IsEmpty || obj.Is <IGameObjectFolder>())
                    {
                        continue;
                    }

                    Path <DomNode> path = new Path <DomNode>(trans.Cast <DomNode>().GetPath());
                    toWorld.Set(Vec3F.ZeroVector);
                    TransformUtils.CalcPathTransform(toWorld, path, path.Count - 1);

                    // Offset by pivot
                    PV.Set(trans.Pivot);
                    toWorld.Mul(PV, toWorld);
                    Vec3F pos = toWorld.Translation;

                    const float pivotDiameter = 16; // in pixels
                    float       s             = Util.CalcAxisScale(Camera, pos, pivotDiameter, Height);
                    sc.Scale(s);
                    Util.CreateBillboard(bl, pos, Camera.WorldEye, Camera.Up, Camera.LookAt);
                    recXform = sc * bl;
                    Util3D.DrawPivot(context, recXform, Color.Yellow);
                }
            }
        }
Esempio n. 23
0
 public static TransformationManager SetScale(this ITransformable o, float scale)
 {
     o.GetTransformationManager().Scale(scale);
     return(o.GetTransformationManager());
 }
 public void Transform(ITransformable source, ITransformable destination)
 {
     // Perform some logic for the transform
 }
Esempio n. 25
0
 public static TransformationManager Translate(this ITransformable o, Vector3 pos)
 {
     o.GetTransformationManager().Translate(pos);
     return(o.GetTransformationManager());
 }
Esempio n. 26
0
        public override void OnDragging(ViewControl vc, Point scrPt)
        {
            if (m_hitRegion == HitRegion.None || NodeList.Count == 0)
            {
                return;
            }

            Matrix4F view = vc.Camera.ViewMatrix;
            // compute world * view
            Matrix4F wv = new Matrix4F();

            wv.Mul(HitMatrix, view);

            // create ray in view space.
            Ray3F rayV = vc.GetRay(scrPt, vc.Camera.ProjectionMatrix);


            Vec3F xAxis  = wv.XAxis;
            Vec3F yAxis  = wv.YAxis;
            Vec3F zAxis  = wv.ZAxis;
            Vec3F origin = wv.Translation;

            //Vec3F pos;
            m_scale = new Vec3F(1, 1, 1);
            float scale = 1;
            float a1, a2;

            switch (m_hitRegion)
            {
            case HitRegion.XAxis:
            {
                a1 = Math.Abs(Vec3F.Dot(HitRayV.Direction, yAxis));
                a2 = Math.Abs(Vec3F.Dot(HitRayV.Direction, zAxis));
                Vec3F axis       = (a1 > a2 ? yAxis : zAxis);
                Vec3F p0         = HitRayV.IntersectPlane(axis, -Vec3F.Dot(axis, origin));
                Vec3F p1         = rayV.IntersectPlane(axis, -Vec3F.Dot(axis, origin));
                float dragAmount = Vec3F.Dot((p1 - p0), xAxis);
                m_scale.X = 1.0f + dragAmount / m_hitScale;
                scale     = m_scale.X;
            }

            break;

            case HitRegion.YAxis:
            {
                a1 = Math.Abs(Vec3F.Dot(HitRayV.Direction, zAxis));
                a2 = Math.Abs(Vec3F.Dot(HitRayV.Direction, xAxis));
                Vec3F axis       = (a1 > a2 ? zAxis : xAxis);
                Vec3F p0         = HitRayV.IntersectPlane(axis, -Vec3F.Dot(axis, origin));
                Vec3F p1         = rayV.IntersectPlane(axis, -Vec3F.Dot(axis, origin));
                float dragAmount = Vec3F.Dot((p1 - p0), yAxis);
                m_scale.Y = 1.0f + dragAmount / m_hitScale;
                scale     = m_scale.Y;
            }
            break;

            case HitRegion.ZAxis:
            {
                a1 = Math.Abs(Vec3F.Dot(HitRayV.Direction, xAxis));
                a2 = Math.Abs(Vec3F.Dot(HitRayV.Direction, yAxis));
                Vec3F axis       = (a1 > a2 ? xAxis : yAxis);
                Vec3F p0         = HitRayV.IntersectPlane(axis, -Vec3F.Dot(axis, origin));
                Vec3F p1         = rayV.IntersectPlane(axis, -Vec3F.Dot(axis, origin));
                float dragAmount = Vec3F.Dot((p1 - p0), zAxis);
                m_scale.Z = 1.0f + dragAmount / m_hitScale;
                scale     = m_scale.Z;
            }
            break;

            case HitRegion.FreeRect:
            {
                Vec3F axis    = new Vec3F(0, 0, 1);
                Vec3F p0      = HitRayV.IntersectPlane(axis, -origin.Z);
                Vec3F p1      = rayV.IntersectPlane(axis, -origin.Z);
                Vec3F dragVec = p1 - p0;

                float dragAmount = 1.0f + dragVec.X / m_hitScale;
                m_scale.X = dragAmount;
                m_scale.Y = dragAmount;
                m_scale.Z = dragAmount;
                scale     = m_scale.X;
            }
            break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (m_isUniformScaling)
            {
                m_scale = new Vec3F(scale, scale, scale);
            }

            // scale
            for (int i = 0; i < NodeList.Count; i++)
            {
                ITransformable transformable = NodeList[i];
                transformable.Scale = Vec3F.Mul(m_originalValues[i], m_scale);
            }
        }
Esempio n. 27
0
 public void SetTransfromControl(ITransformable transformController)
 {
     transformControl = transformController;
 }
Esempio n. 28
0
 public void DrawFrame(MX.Frame frame, ITransformable transformObj, IRenderable renderableObj)
 {
     if (transformObj.X + this.Width - Camera.X > 0 && transformObj.Y + this.Height - Camera.Y > 0 &&
         transformObj.X - Camera.X < Width && transformObj.Y - Camera.Y < Height &&
         renderableObj.Visible)
     {
         Vector3 Position = new Vector3((float)transformObj.Position.X, (float)transformObj.Position.Y, 0);
         Position.X -= (float)Camera.X;
         Position.Y -= (float)Camera.Y;
         SetTransform((float)frame._BaseWidth, (float)frame._BaseHeight, (float)transformObj.X, (float)transformObj.Y, (float)transformObj.W, (float)transformObj.H, (float)transformObj.Rotation);
         SpriteBatch.Draw(frame.Texture.Surface, frame.FrameArea, Vector3.Empty, Position, renderableObj.Color.ToArgb());
     }
 }
Esempio n. 29
0
        /// <summary>
        /// Creates an array of property descriptors that are associated with the adapted DomNode's
        /// DomNodeType. No duplicates will be in the array (based on the property descriptor's Name
        /// property).</summary>
        /// <returns>Array of property descriptors</returns>
        protected override System.ComponentModel.PropertyDescriptor[] GetPropertyDescriptors()
        {
            // Initialize property desciptors with the ones from the base class
            // If this is not done, the new property descriptors would be used instead of
            // rather than in addition to the ones defined in the schema
            List <System.ComponentModel.PropertyDescriptor> descriptors =
                new List <System.ComponentModel.PropertyDescriptor>(base.GetPropertyDescriptors());

            // Add ITransformable properties:
            // Translation, Rotation, Scale, RotatePivot, ScalePivot (if supported by this object)

            ITransformable      node          = this.Cast <ITransformable>();
            TransformationTypes transformType = node.TransformationType;

            NumericTupleEditor tupleEditor =
                new NumericTupleEditor(typeof(float), new string[] { "x", "y", "z" });
            NumericTupleEditor rotationTupleEditor =
                new NumericTupleEditor(typeof(float), new string[] { "x", "y", "z" });

            rotationTupleEditor.ScaleFactor = 360 / (2 * Math.PI); // Radians to Degrees

            string category = "Transform".Localize();

            // Check for transform types
            if ((transformType & TransformationTypes.Translation) != 0)
            {
                descriptors.Add(
                    new AttributePropertyDescriptor(
                        "Translation", Schema.gameObjectType.translateAttribute, category, "Translation of Game Object along X, Y, and Z axes".Localize(),
                        false, tupleEditor));
            }

            if ((transformType & TransformationTypes.Rotation) != 0)
            {
                descriptors.Add(new AttributePropertyDescriptor(
                                    "Rotation".Localize(), Schema.gameObjectType.rotateAttribute, category,
                                    "Origin of Rotation transform relative to Game Object Translation".Localize(),
                                    false, rotationTupleEditor));
            }

            if ((transformType & TransformationTypes.Scale) != 0)
            {
                if ((transformType & TransformationTypes.UniformScale) == 0)
                {
                    descriptors.Add(
                        new AttributePropertyDescriptor(
                            "Scale".Localize(),
                            Schema.gameObjectType.scaleAttribute, category,
                            "Scale of Game Object along X, Y, and Z axes".Localize(),
                            false, tupleEditor));
                }
                else
                {
                    descriptors.Add(
                        new AttributePropertyDescriptor(
                            "Uniform Scale".Localize(), Schema.gameObjectType.scaleAttribute,
                            category,
                            "Scale of Game Object uniformly along X, Y, and Z axes".Localize(),
                            false, new UniformArrayEditor <Single>()));
                }
            }

            if ((transformType & TransformationTypes.Pivot) != 0)
            {
                descriptors.Add(
                    new AttributePropertyDescriptor(
                        "Pivot".Localize(), Schema.gameObjectType.pivotAttribute, category,
                        "Origin of Rotation and scale transform relative to Game Object Translation".Localize(),
                        false, tupleEditor));
            }


            // remove hidden properties
            HashSet <string> hiddenProps = (HashSet <string>) this.DomNode.Type.GetTag(SchemaLoader.HiddenProperties);

            if (hiddenProps != null)
            {
                List <PropertyDescriptor> removeList = new List <PropertyDescriptor>();
                foreach (AttributePropertyDescriptor propdescr in descriptors.AsIEnumerable <AttributePropertyDescriptor>())
                {
                    if (hiddenProps.Contains(propdescr.AttributeInfo.Name))
                    {
                        removeList.Add(propdescr);
                    }
                }

                foreach (PropertyDescriptor propDescr in removeList)
                {
                    descriptors.Remove(propDescr);
                }
            }


            return(descriptors.ToArray());
        }
Esempio n. 30
0
        public override bool Pick(ViewControl vc, Point scrPt)
        {
            m_hitRegion = HitRegion.None;
            if (base.Pick(vc, scrPt) == false)
                return false;

            m_node = GetManipulatorNode(TransformationTypes.Pivot);

            Camera camera = vc.Camera;
            Matrix4F view = camera.ViewMatrix;
            Matrix4F vp = view * camera.ProjectionMatrix;
            Matrix4F wvp = HitMatrix * vp;

            Ray3F rayL = vc.GetRay(scrPt, wvp);
            m_hitRegion = m_translatorControl.Pick(vc, HitMatrix, view, rayL, HitRayV);
            bool picked = m_hitRegion != HitRegion.None;
            return picked;
        }
Esempio n. 31
0
        public override void OnDragging(ViewControl vc, Point scrPt)
        {
            if (m_cancelDrag || m_hitRegion == HitRegion.None || m_activeOp == null || m_activeOp.NodeList.Count == 0)
            {
                return;
            }

            var nativeVC = vc as NativeDesignControl;

            if (nativeVC == null)
            {
                return;
            }

            bool hitAxis = m_hitRegion == HitRegion.XAxis ||
                           m_hitRegion == HitRegion.YAxis ||
                           m_hitRegion == HitRegion.ZAxis;

            Matrix4F proj = vc.Camera.ProjectionMatrix;

            // create ray in view space.
            Ray3F rayV      = vc.GetRay(scrPt, proj);
            Vec3F translate = m_translatorControl.OnDragging(rayV);

            ISnapSettings snapSettings = (ISnapSettings)DesignView;

#if false
            bool snapToGeom = Control.ModifierKeys == m_snapGeometryKey;
            if (snapToGeom)
            {
                Matrix4F view = vc.Camera.ViewMatrix;
                Matrix4F vp   = view * proj;
                // create ray in world space.
                Ray3F rayW = vc.GetRay(scrPt, vp);

                Vec3F manipPos = HitMatrix.Translation;
                Vec3F manipMove;
                if (hitAxis)
                {
                    //Make rayw to point toward moving axis and starting
                    // from manipulator’s world position.
                    rayW.Direction = Vec3F.Normalize(translate);
                    rayW.Origin    = manipPos;
                    manipMove      = Vec3F.ZeroVector;
                    m_cancelDrag   = true; //stop further snap-to's
                }
                else
                {
                    manipMove = rayW.ProjectPoint(manipPos) - manipPos;
                }

                for (int i = 0; i < m_activeOp.NodeList.Count; i++)
                {
                    ITransformable node               = m_activeOp.NodeList[i];
                    Vec3F          snapOffset         = TransformUtils.CalcSnapFromOffset(node, snapSettings.SnapFrom);
                    Path <DomNode> path               = new Path <DomNode>(Adapters.Cast <DomNode>(node).GetPath());
                    Matrix4F       parentLocalToWorld = TransformUtils.CalcPathTransform(path, path.Count - 2);
                    Vec3F          orgPosW;
                    parentLocalToWorld.Transform(m_originalValues[i], out orgPosW);

                    Matrix4F parentWorldToLocal = new Matrix4F();
                    parentWorldToLocal.Invert(parentLocalToWorld);

                    rayW.MoveToIncludePoint(orgPosW + snapOffset + manipMove);

                    var hits = XLEBridgeUtils.Picking.RayPick(
                        nativeVC.Adapter, rayW,
                        XLEBridgeUtils.Picking.Flags.Terrain | XLEBridgeUtils.Picking.Flags.Objects | XLEBridgeUtils.Picking.Flags.IgnoreSelection);
                    bool cansnap = false;
                    var  target  = new XLEBridgeUtils.Picking.HitRecord();
                    if (hits != null && hits.Length > 0)
                    {
                        // find hit record.
                        foreach (var hit in hits)
                        {
                            if (m_snapFilter.CanSnapTo(node, m_nativeIdMapping.GetAdapter(hit.documentId, hit.instanceId)))
                            {
                                target  = hit;
                                cansnap = true;
                                break;
                            }
                        }
                    }

                    if (cansnap)
                    {
                        Vec3F pos;
                        if (target.hasNearestVert && snapSettings.SnapVertex)
                        {
                            pos = target.nearestVertex;
                        }
                        else
                        {
                            pos = target.hitPt;
                        }

                        pos -= snapOffset;
                        parentWorldToLocal.Transform(ref pos);
                        Vec3F diff = pos - node.Transform.Translation;
                        node.Translation += diff;
                        bool rotateOnSnap = snapSettings.RotateOnSnap &&
                                            target.hasNormal &&
                                            (node.TransformationType & TransformationTypes.Rotation) != 0;
                        if (rotateOnSnap)
                        {
                            Vec3F localSurfaceNormal;
                            parentWorldToLocal.TransformNormal(target.normal, out localSurfaceNormal);
                            node.Rotation = TransformUtils.RotateToVector(
                                m_originalRotations[i],
                                localSurfaceNormal,
                                AxisSystemType.YIsUp);
                        }
                    }
                }
            }
            else
#endif
            {
                IGrid grid       = DesignView.Context.Cast <IGame>().Grid;
                bool  snapToGrid = Control.ModifierKeys == m_snapGridKey &&
                                   grid.Visible &&
                                   vc.Camera.ViewType == ViewTypes.Perspective;
                float gridHeight = grid.Height;
                // translate.
                for (int i = 0; i < m_activeOp.NodeList.Count; i++)
                {
                    ITransformable node = m_activeOp.NodeList[i];
                    Path <DomNode> path = new Path <DomNode>(Adapters.Cast <DomNode>(node).GetPath());
                    Matrix4F       parentLocalToWorld = TransformUtils.CalcPathTransform(path, path.Count - 2);
                    Matrix4F       parentWorldToLocal = new Matrix4F();
                    parentWorldToLocal.Invert(parentLocalToWorld);
                    Vec3F localTranslation;
                    parentWorldToLocal.TransformVector(translate, out localTranslation);
                    Vec3F trans = m_originalValues[i] + localTranslation;

                    if (snapToGrid)
                    {
                        trans = grid.SnapPoint(trans);
                    }

                    node.Translation = trans;
                }
            }
        }
Esempio n. 32
0
 private bool CanManipulate(ITransformable node, FilterDelegate filter)
 {
     bool result = node != null
         && node.Cast<IVisible>().Visible
         && node.Cast<ILockable>().IsLocked == false
         && filter(node);
     return result;
 }
Esempio n. 33
0
        /// <summary>
        /// For an object 'node' that is being manipulated, this function returns
        /// the offset (in world space) from the object's origin to to the point that is being
        /// "snapped from". This calculation is determined by the snapping modes.</summary>
        /// <param name="node">The object that is being snapped-to some other object</param>
        /// <param name="snapFromMode">The "snap from" mode, as an enum</param>
        /// <param name="axisType">Whether the Y axis is up or down</param>
        /// <returns>Offset from this object's origin to the "snap from" point, in world space</returns>
        /// <remarks>Must be kept in sync with SnapFromModes property.</remarks>
        public static Vec3F CalcSnapFromOffset(
            ITransformable node,
            SnapFromMode snapFromMode,
            AxisSystemType axisType)
        {
            Vec3F rotatePivot = new Vec3F();
            if ((node.TransformationType & TransformationTypes.RotatePivot) != 0)
                rotatePivot = node.RotatePivot;

            return CalcSnapFromOffset(node, snapFromMode, axisType, rotatePivot);
        }
 private bool CanManipulate(ITransformable node)
 {
     bool result = node != null
           && (node.TransformationType & TransformationTypes.Pivot) != 0
           && node.Cast<IVisible>().Visible
           && node.Cast<ILockable>().IsLocked == false;
     return result;
 }
Esempio n. 35
0
        /// <summary>
        /// Adjusts child transform, making it the concatenation with its parent's transform.
        /// Is recursive, looking for parents that also implement IRenderableNode.</summary>
        /// <param name="parent">Parent node</param>
        /// <param name="child">Child node</param>
        public static void RemoveChild(ITransformable parent, ITransformable child)
        {
            Path<DomNode> path = new Path<DomNode>(parent.Cast<DomNode>().GetPath());
            Matrix4F parentMatrix = TransformUtils.CalcPathTransform(path, path.Count - 1);

            Matrix4F childMatrix = child.Transform;
            Matrix4F newChildMatrix = Matrix4F.Multiply(childMatrix, parentMatrix);

            Vec3F newTranslation = child.Translation;
            parentMatrix.Transform(ref newTranslation);

            Vec3F newRotation = new Vec3F();
            newChildMatrix.GetEulerAngles(out newRotation.X, out newRotation.Y, out newRotation.Z);
            child.Rotation = newRotation;

            Vec3F newScale = newChildMatrix.GetScale();
            child.Scale = newScale;

            // We can compose together all of the separate transformations now.
            Matrix4F newTransform = CalcTransform(
                newTranslation,
                newRotation,
                newScale,
                child.ScalePivot,
                child.ScalePivotTranslation,
                child.RotatePivot,
                child.RotatePivotTranslation);

            // However, the composed matrix may not equal newChildMatrix due to rotating
            //  or scaling around a pivot. In the general case, it may be impossible to
            //  decompose newChildMatrix into all of these separate components. For example,
            //  a sheer transformation cannot be reproduced by a single rotation and scale.
            //  But for common cases, only the translation is out-of-sync now, so apply a fix.
            Vec3F desiredTranslation = newChildMatrix.Translation;
            Vec3F currentTranslation = newTransform.Translation;
            Vec3F fixupTranslation = desiredTranslation - currentTranslation;
            Matrix4F fixupTransform = new Matrix4F(fixupTranslation);
            newTransform.Mul(newTransform, fixupTransform);

            // Save the fix and the final transform.
            child.Translation = newTranslation + fixupTranslation;
            child.Transform = newTransform;
        }
Esempio n. 36
0
 /// <summary>
 /// For an object 'node' that is being manipulated, this function returns
 /// the offset (in world space) from the object's origin to to the point that is being
 /// "snapped from". This calculation is determined by the snapping modes.</summary>
 /// <param name="node">The object that is being snapped-to some other object</param>
 /// <param name="snapFromMode">The "snap from" mode, as a string. See SnapFromModes property.
 /// Pass in 'null' to get the default which is the offset to the pivot point.</param>
 /// <param name="axisType">Whether the Y axis is up or down</param>
 /// <returns>Offset from this object's origin to the "snap from" point, in world space</returns>
 /// <remarks>Must be kept in sync with SnapFromModes property.</remarks>
 public static Vec3F CalcSnapFromOffset(
     ITransformable node,
     string snapFromMode,
     AxisSystemType axisType)
 {
     SnapFromMode mode = GetSnapFromMode(snapFromMode);
     return CalcSnapFromOffset(node, mode, axisType);
 }
Esempio n. 37
0
        public static Transform GlobalTransform([NotNull] this ITransformable transformable)
        {
            Ensure.Any.IsNotNull(transformable, nameof(transformable));

            return(transformable.Spatial.GlobalTransform);
        }
Esempio n. 38
0
        /// <summary>
        /// Adjusts child transform, making it relative to new parent node's transform.
        /// Is recursive, looking for parents that also implement IRenderableNode.</summary>
        /// <param name="parent">Parent node</param>
        /// <param name="child">Child node</param>
        public static void AddChild(ITransformable parent, ITransformable child)
        {
            Path<DomNode> path = new Path<DomNode>(parent.Cast<DomNode>().GetPath());
            Matrix4F parentToWorld = TransformUtils.CalcPathTransform(path, path.Count - 1);

            // We want 'child' to appear in the same place in the world after adding to 'parent'.
            // local-point * original-local-to-world = world-point
            // new-local-point * new-local-to-parent * parent-to-world = world-point
            // ==> new-local-to-parent * parent-to-world = original-local-to-world
            // (multiply both sides by inverse of parent-to-world; call it world-to-parent)
            // ==> new-local-to-parent = original-local-to-world * world-to-parent
            Matrix4F worldToParent = new Matrix4F();
            worldToParent.Invert(parentToWorld);
            Matrix4F originalLocalToWorld = child.Transform;
            Matrix4F newLocalToParent = Matrix4F.Multiply(originalLocalToWorld, worldToParent);

            // The translation component of newLocalToParent consists of pivot translation
            //  as well as the child.Translation. So, start with the original child.Translation
            //  and transform it into our new space.
            Vec3F newTranslation = child.Translation;
            worldToParent.Transform(ref newTranslation);

            // There's only one way of getting rotation info, so get it straight from matrix.
            Vec3F newRotation = new Vec3F();
            newLocalToParent.GetEulerAngles(out newRotation.X, out newRotation.Y, out newRotation.Z);
            child.Rotation = newRotation;

            // Likewise with scale.
            Vec3F newScale = newLocalToParent.GetScale();
            child.Scale = newScale;

            // We can compose together all of the separate transformations now.
            Matrix4F newTransform = CalcTransform(
                newTranslation,
                newRotation,
                newScale,
                child.ScalePivot,
                child.ScalePivotTranslation,
                child.RotatePivot,
                child.RotatePivotTranslation);

            // However, the composed matrix may not equal newLocalToParent due to rotating
            //  or scaling around a pivot. In the general case, it may be impossible to
            //  decompose newLocalToParent into all of these separate components. For example,
            //  a sheer transformation cannot be reproduced by a single rotation and scale.
            //  But for common cases, only the translation is out-of-sync now, so apply a fix.
            Vec3F desiredTranslation = newLocalToParent.Translation;
            Vec3F currentTranslation = newTransform.Translation;
            Vec3F fixupTranslation = desiredTranslation - currentTranslation;
            Matrix4F fixupTransform = new Matrix4F(fixupTranslation);
            newTransform.Mul(newTransform, fixupTransform);

            // Save the fix and the final transform. Storing the fix in RotatePivotTranslation
            //  is done elsewhere, as well.
            child.Translation = newTranslation + fixupTranslation;
            child.Transform = newTransform;
        }
        //_items manupulation
        private void pbDashboard_MouseDown(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                pbMenu.Items.Clear();
                Point pt = new Point(e.X, e.Y);
                _menuItem = getItem(pt) as IDrawable;
                if (_menuItem == null)
                {
                    return;
                }

                if (_menuItem is Stock)
                {
                    Stock stk = _menuItem as Stock;
                    if (stk._inFlow != null)
                    {
                        pbMenu.Items.Add("Detach In Flow: " + stk._inFlow.Name);
                        pbMenu.Items[pbMenu.Items.Count - 1].Click += new EventHandler(this.MenuDeleteInFlow);
                    }
                    if (stk._outFlow != null)
                    {
                        pbMenu.Items.Add("Detach Out Flow: " + stk._outFlow.Name);
                        pbMenu.Items[pbMenu.Items.Count - 1].Click += new EventHandler(this.MenuDeleteOutFlow);
                    }
                    if (stk.Refferences.Count > 0)
                    {
                        pbMenu.Items.Add("Detach Refferences");
                        pbMenu.Items[pbMenu.Items.Count - 1].Click += new EventHandler(this.MenuDeleteRefference);
                    }

                    pbMenu.Items.Add("Edit Object");
                    pbMenu.Items[pbMenu.Items.Count - 1].Click += new EventHandler(this.MenuEditObject);

                    if (pbMenu.Items.Count > 0)
                    {
                        pbMenu.Items.Add("-");
                    }

                    pbMenu.Items.Add("Delete " + stk.Name);
                    pbMenu.Items[pbMenu.Items.Count - 1].Click += new EventHandler(this.MenuDeleteObject);
                }
                else if (_menuItem is Flow)
                {
                    Flow fl = _menuItem as Flow;
                    if (fl._source != null)
                    {
                        pbMenu.Items.Add("Detach Flow: " + fl._source.Name);
                        pbMenu.Items[pbMenu.Items.Count - 1].Click += new EventHandler(this.MenuDeleteInFlow);
                    }
                    if (fl._destination != null)
                    {
                        pbMenu.Items.Add("Detach Flow: " + fl._destination.Name);
                        pbMenu.Items[pbMenu.Items.Count - 1].Click += new EventHandler(this.MenuDeleteOutFlow);
                    }
                    if (fl.Refferences.Count > 0)
                    {
                        pbMenu.Items.Add("Detach Refferences");
                        pbMenu.Items[pbMenu.Items.Count - 1].Click += new EventHandler(this.MenuDeleteRefference);
                    }

                    pbMenu.Items.Add("Edit Object");
                    pbMenu.Items[pbMenu.Items.Count - 1].Click += new EventHandler(this.MenuEditObject);

                    if (pbMenu.Items.Count > 0)
                    {
                        pbMenu.Items.Add("-");
                    }

                    pbMenu.Items.Add("Delete " + fl.Name);
                    pbMenu.Items[pbMenu.Items.Count - 1].Click += new EventHandler(this.MenuDeleteObject);
                }
                else if (_menuItem is Coefficient)
                {
                    Coefficient fl = _menuItem as Coefficient;
                    if (fl.Refferences.Count > 0)
                    {
                        pbMenu.Items.Add("Detach Refferences");
                        pbMenu.Items[pbMenu.Items.Count - 1].Click += new EventHandler(this.MenuDeleteRefference);
                    }

                    pbMenu.Items.Add("Edit Object");
                    pbMenu.Items[pbMenu.Items.Count - 1].Click += new EventHandler(this.MenuEditObject);

                    if (pbMenu.Items.Count > 0)
                    {
                        pbMenu.Items.Add("-");
                    }

                    pbMenu.Items.Add("Delete " + fl.Name);
                    pbMenu.Items[pbMenu.Items.Count - 1].Click += new EventHandler(this.MenuDeleteObject);
                }
                else if (_menuItem is ResultTable)
                {
                    ResultTable fl = _menuItem as ResultTable;
                    pbMenu.Items.Add("Edit Object");
                    pbMenu.Items[pbMenu.Items.Count - 1].Click += new EventHandler(this.MenuEditObject);

                    if (pbMenu.Items.Count > 0)
                    {
                        pbMenu.Items.Add("-");
                    }

                    pbMenu.Items.Add("Delete " + fl.Name);
                    pbMenu.Items[pbMenu.Items.Count - 1].Click += new EventHandler(this.MenuDeleteObject);
                }
                else if (_menuItem is Diagram)
                {
                    Diagram fl = _menuItem as Diagram;
                    pbMenu.Items.Add("Show in new form");
                    pbMenu.Items[pbMenu.Items.Count - 1].Click += new EventHandler(this.MenuDiagramForm);

                    pbMenu.Items.Add("Edit Object");
                    pbMenu.Items[pbMenu.Items.Count - 1].Click += new EventHandler(this.MenuEditObject);

                    if (pbMenu.Items.Count > 0)
                    {
                        pbMenu.Items.Add("-");
                    }

                    pbMenu.Items.Add("Delete " + fl.Name);
                    pbMenu.Items[pbMenu.Items.Count - 1].Click += new EventHandler(this.MenuDeleteObject);
                }

                pbMenu.Show(pbDashboard, pt);
            }

            if (e.Button != MouseButtons.Left)
            {
                return;
            }

            Cursor.Clip = new Rectangle(this.PointToScreen(this.pbDashboard.Location), this.pbDashboard.Size);

            this.pbDashboard.Capture = true;

            if (btnStock.CheckState == CheckState.Checked)
            {
                this._items.Add(new Stock(new Rectangle(e.X - 50, e.Y - 25, 100, 50)));
                this.pbDashboard.Refresh();
                SetMenuSelectButton();
            }
            else if (tsbDiagram.CheckState == CheckState.Checked)
            {
                this._items.Add(new Diagram(new Rectangle(e.X - 250, e.Y - 125, 500, 250)));
                this.pbDashboard.Refresh();
                SetMenuSelectButton();
            }
            else if (tsbResultTable.CheckState == CheckState.Checked)
            {
                this._items.Add(new ResultTable(this.pbDashboard, new Rectangle(e.X - 150, e.Y - 100, 300, 200)));
                this.pbDashboard.Refresh();
                SetMenuSelectButton();
            }
            else if (btnFlow.CheckState == CheckState.Checked)
            {
                if (_startPoint == null)
                {
                    _startPoint = new Point(e.X, e.Y);
                    Rectangle      rect;
                    ITransformable sItem = getItem(_startPoint.Value);
                    rect = new Rectangle(_startPoint.Value.X, _startPoint.Value.Y, 10, 10);

                    if (sItem != null && sItem is Stock && ((Stock)sItem).InFlow == null)
                    {
                        this._flow             = new Flow((Stock)sItem, rect);
                        ((Stock)sItem).OutFlow = this._flow;
                    }
                    else
                    {
                        this._flow = new Flow(rect, new Rectangle(e.X, e.Y, 10, 10));
                    }
                }
                else
                {
                    Point          EndPoint = new Point(e.X, e.Y);
                    ITransformable sItem    = getItem(_startPoint.Value);
                    ITransformable eItem    = getItem(EndPoint);

                    this._items.Add(this._flow);
                    this.pbDashboard.Refresh();

                    this._startPoint = null;
                    this._flow       = null;
                    SetMenuSelectButton();
                }
            }
            else if (btnCoefficient.CheckState == CheckState.Checked)
            {
                this._items.Add(new Coefficient(new Rectangle(e.X - 25, e.Y - 25, 50, 50)));
                this.pbDashboard.Refresh();
                SetMenuSelectButton();
            }
            else if (btnRefference.CheckState == CheckState.Checked)
            {
                if (_reff == null)
                {
                    _reff = getItem(new Point(e.X, e.Y));
                    if (_reff is Diagram || _reff is ResultTable || !(_reff is IConnectable))
                    {
                        _reff = null;
                    }
                    if (_reff == null)
                    {
                        return;
                    }
                }
                else
                {
                    IConnectable cnt = getItem(new Point(e.X, e.Y)) as IConnectable;
                    if (cnt == null || cnt == _reff)
                    {
                        _reff = null;
                        SetMenuSelectButton();
                        return;
                    }
                    cnt.Connect((IConnectable)_reff);
                    _reff = null;
                    SetMenuSelectButton();
                }

                /*
                 * foreach (ITransformable item in this._items)
                 *  if (item.Contains(e.X, e.Y) != -1)
                 *  {
                 *      _selectedItem = item.Contains(e.X, e.Y);
                 *      _selectedIndex = this._items.IndexOf((IDrawable)item);
                 *      break;
                 *  }
                 *
                 * if (_selectedIndex == -1)
                 *  this.start = null;
                 * else if (this.start == null)
                 *  this.start = (IConnectable)_items[_selectedIndex];
                 * else
                 * {
                 *  this.start.Connect((IConnectable)_items[_selectedIndex]);
                 *  this.start = null;
                 * }
                 *
                 * this._selectedIndex = -1;
                 */
                this.pbDashboard.Refresh();
            }
            else if (btnSelect.CheckState == CheckState.Checked)
            {
                foreach (ITransformable item in this._items)
                {
                    if (item.Contains(e.X, e.Y) != -1)
                    {
                        _selectedItem  = item.Contains(e.X, e.Y);
                        _cursorItem    = _selectedIndex;
                        _selectedIndex = this._items.IndexOf((IDrawable)item);
                        if (item is ResultTable)
                        {
                            ((ResultTable)item).BeginDrag();
                        }
                        break;
                    }
                }
                this._X = e.X;
                this._Y = e.Y;
            }
        }
Esempio n. 40
0
        public static List <Light> AddControllableLight()
        {
            float fovdegree = 90;

            RedLight = new List <Light>();
            RedLight.Add(new Light(new TransformationManager(new Vector3(0, 5, 0), Quaternion.FromAxisAngle(new Vector3(1, 0, 0), MathHelper.DegreesToRadians(-110))))
            {
                Color = new Vector3(1) * 400,
                ShadowMappingEnabled = true,
                ShadowMapType        = Light.ShadowMapTypeEnum.Single
            });
            Picked = RedLight[0];

            /*
             * //crazyiness
             * var tmp = new List<Light>();
             * for(int i = 0; i < 10; i++)
             * {
             *  for(int g = 0; g < 4; g++)
             *  {
             *      var l = new Light(new TransformationManager(new Vector3((i - 5) * 1.6f, 1 + g * 2, 0)));
             *      tmp.Add(l);
             *      //l.Color = (new Vector3((float)Math.Sin(i), 1.0f - (float)Math.Sin(i), (float)Math.Cos(i)) * 0.5f + new Vector3(0.5f)) * 0.3f;
             *      l.Color = new Vector3(1) * (0.05f * (g + 1));
             *      l.CutOffDistance = 30.0f;
             *      l.StaticShadowMap = true;
             *      l.ShadowMapType = Light.ShadowMapTypeEnum.Cubemap;
             *      l.ShadowsQuality = ShadowMapQuality.Low;
             *      l.ShadowMappingEnabled = true;
             *      Game.World.Scene.Add(l);
             *  }
             * }
             * int ix = 0;
             * Game.OnBeforeDraw += (x, d) =>
             * {
             *  tmp[ix].ShadowMapRefreshNeeded = true;
             *  ix++;
             *  if(ix >= tmp.Count)
             *      ix = 0;
             * };*/

            //RedLight[0].camera.UpdatePerspective(1, MathHelper.DegreesToRadians(90), 0.01f, 100);

            /* RedLight.Add(new ProjectionLight(new Vector3(65, 0, 65), Quaternion.FromAxisAngle(new Vector3(1, 0, -1), MathHelper.DegreesToRadians(fovdegree)), 1, 1, MathHelper.DegreesToRadians(45), 0.1f, 100.0f)
             * {
             *   LightColor = new Vector3(1, 0.84f, 0.93f) * 25,
             *   IsStatic = true
             * });
             * RedLight.Add(new ProjectionLight(new Vector3(65, 0, 65), Quaternion.FromAxisAngle(new Vector3(1, 0, -1), MathHelper.DegreesToRadians(fovdegree)), 1, 1, MathHelper.DegreesToRadians(45), 0.1f, 100.0f)
             * {
             *   LightColor = new Vector3(1, 0.84f, 0.93f) * 25,
             *   IsStatic = true
             * });
             * RedLight.Add(new ProjectionLight(new Vector3(65, 0, 65), Quaternion.FromAxisAngle(new Vector3(1, 0, -1), MathHelper.DegreesToRadians(fovdegree)), 1, 1, MathHelper.DegreesToRadians(45), 0.1f, 100.0f)
             * {
             *   LightColor = new Vector3(1, 0.84f, 0.93f) * 25,
             *   IsStatic = true
             * });*/
            //redConeLight.BuildOrthographicProjection(600, 600, -150, 150);

            Game.OnKeyUp += (o, e) =>
            {
                if (e.Key == OpenTK.Input.Key.J)
                {
                    fovdegree += 5f;
                    if (fovdegree >= 180)
                    {
                        fovdegree = 179;
                    }
                    RedLight.ForEach((ax) => ax.Angle = MathHelper.DegreesToRadians(fovdegree));
                }
                if (e.Key == OpenTK.Input.Key.K)
                {
                    fovdegree -= 5f;
                    if (fovdegree <= 10)
                    {
                        fovdegree = 10;
                    }
                    RedLight.ForEach((ax) => ax.Angle = MathHelper.DegreesToRadians(fovdegree));
                }
            };
            RedLight.ForEach((a) => Game.World.Scene.Add(a));

            Game.OnMouseMove += (o, e) =>
            {
                MouseX = e.X;
                MouseY = e.Y;

                var kb = OpenTK.Input.Keyboard.GetState();
                if (kb.IsKeyDown(OpenTK.Input.Key.T))
                {
                    FreeCam.Freeze = true;
                    if (Picked != null)
                    {
                        Picked.SetPosition(Picked.GetPosition() + FreeCam.Cam.GetOrientation().GetTangent(MathExtensions.TangentDirection.Right) * (float)e.XDelta * -0.01f);
                        Picked.SetPosition(Picked.GetPosition() + FreeCam.Cam.GetOrientation().GetTangent(MathExtensions.TangentDirection.Up) * (float)e.YDelta * -0.01f);
                    }
                }
                else if (kb.IsKeyDown(OpenTK.Input.Key.F))
                {
                    FreeCam.Freeze = true;
                    if (Picked != null)
                    {
                        Picked.SetOrientation(Quaternion.Multiply(Picked.GetOrientation(), Quaternion.FromAxisAngle(FreeCam.Cam.GetOrientation().GetTangent(MathExtensions.TangentDirection.Up), (float)e.XDelta * -0.01f)));
                        Picked.SetOrientation(Quaternion.Multiply(Picked.GetOrientation(), Quaternion.FromAxisAngle(FreeCam.Cam.GetOrientation().GetTangent(MathExtensions.TangentDirection.Left), (float)e.YDelta * -0.01f)));
                    }
                }
                else if (kb.IsKeyDown(OpenTK.Input.Key.C))
                {
                    FreeCam.Freeze = true;
                    if (Picked != null)
                    {
                        Picked.SetScale(Picked.GetScale() + new Vector3((float)e.XDelta * -0.01f));
                    }
                }
                else
                {
                    FreeCam.Freeze = Game.DisplayAdapter.IsCursorVisible;
                }
            };
            Game.OnMouseWheel += (o, e) =>
            {
                Camera.Current.LensBlurAmount -= e.Delta / 2.0f;
            };
            Game.OnAfterDraw += (o, e) =>
            {
                //.ToString(System.Globalization.CultureInfo.InvariantCulture)

                //SettingsController.Instance.UpdatePerformance();

                /*var jpad = OpenTK.Input.GamePad.GetState(0);
                 * float deadzone = 0.15f;
                 * if(Picked != null)
                 * {
                 *  if(Math.Abs(jpad.ThumbSticks.Right.X) > deadzone)
                 *  {
                 *      var ang = Picked.GetOrientation().GetTangent(MathExtensions.TangentDirection.Up);
                 *      Picked.Rotate(Quaternion.FromAxisAngle(ang, jpad.ThumbSticks.Right.X * 0.01f));
                 *  }
                 *  if(Math.Abs(jpad.ThumbSticks.Right.Y) > deadzone)
                 *  {
                 *      var ang = Picked.GetOrientation().GetTangent(MathExtensions.TangentDirection.Left);
                 *      Picked.Rotate(Quaternion.FromAxisAngle(ang, jpad.ThumbSticks.Right.Y * 0.01f));
                 *  }
                 *  if(Math.Abs(jpad.Triggers.Left) > deadzone)
                 *  {
                 *      var ang = Picked.GetOrientation().ToDirection();
                 *      Picked.Rotate(Quaternion.FromAxisAngle(ang, jpad.Triggers.Left * 0.01f));
                 *  }
                 *  if(Math.Abs(jpad.Triggers.Right) > deadzone)
                 *  {
                 *      var ang = Picked.GetOrientation().ToDirection();
                 *      Picked.Rotate(Quaternion.FromAxisAngle(ang, -jpad.Triggers.Right*0.01f));
                 *  }
                 * }*/
                var kb = OpenTK.Input.Keyboard.GetState();
                if (Game.DisplayAdapter.IsCursorVisible)
                {
                    if (!kb.IsKeyDown(OpenTK.Input.Key.LControl))
                    {
                        //Game.DisplayAdapter.Pipeline.PostProcessor.ShowSelected = false;
                    }
                    else
                    {
                        //Game.DisplayAdapter.Pipeline.PostProcessor.ShowSelected = true;
                        PickingResult.MapData(Vector4.One);
                        MousePicker.Use();
                        var state = OpenTK.Input.Mouse.GetState();
                        MousePicker.SetUniform("Mouse", new Vector2(MouseX, Game.Resolution.Height - MouseY));
                        MousePicker.SetUniform("Resolution", new Vector2(Game.Resolution.Width, Game.Resolution.Height));
                        PickingResult.Use(0);
                        GL.ActiveTexture(TextureUnit.Texture29);
                        GL.BindTexture(TextureTarget.Texture2D, Game.DisplayAdapter.MainRenderer.MRT.TexMeshIds);
                        MousePicker.Dispatch(1, 1, 1);
                        OpenTK.Graphics.OpenGL4.GL.MemoryBarrier(OpenTK.Graphics.OpenGL4.MemoryBarrierFlags.ShaderStorageBarrierBit);
                        byte[] result = PickingResult.Read(0, 4);
                        uint   id     = BitConverter.ToUInt32(result, 0);
                        foreach (var m in Game.World.Scene.GetFlatRenderableList())
                        {
                            if (m is Mesh3d)
                            {
                                foreach (var inst in (m as Mesh3d).GetInstances())
                                {
                                    if (inst.Id == id)
                                    {
                                        Picked     = inst;
                                        PickedMesh = (m as Mesh3d);
                                        //SettingsController.Instance.SetMesh(inst);
                                    }
                                }
                            }
                        }
                    }
                }

                /*
                 * if(kb.IsKeyDown(OpenTK.Input.Key.Plus))
                 * {
                 *  var dir = Game.CascadeShadowMaps.GetDirection();
                 *  dir = Quaternion.Multiply(Quaternion.FromAxisAngle(Vector3.UnitX, -0.01f), dir);
                 *  Game.CascadeShadowMaps.SetDirection(dir);
                 * }
                 *
                 * if(kb.IsKeyDown(OpenTK.Input.Key.Minus))
                 * {
                 *  var dir = Game.CascadeShadowMaps.GetDirection();
                 *  dir = Quaternion.Multiply(Quaternion.FromAxisAngle(Vector3.UnitX, 0.01f), dir);
                 *  Game.CascadeShadowMaps.SetDirection(dir);
                 * }*/

                if (kb.IsKeyDown(OpenTK.Input.Key.T) && Picked != null)
                {
                    if (kb.IsKeyDown(OpenTK.Input.Key.Keypad4))
                    {
                        Picked.Translate(new Vector3(-0.01f, 0, 0));
                    }
                    if (kb.IsKeyDown(OpenTK.Input.Key.Keypad6))
                    {
                        Picked.Translate(new Vector3(0.01f, 0, 0));
                    }
                    if (kb.IsKeyDown(OpenTK.Input.Key.Keypad8))
                    {
                        Picked.Translate(new Vector3(0, 0, 0.01f));
                    }
                    if (kb.IsKeyDown(OpenTK.Input.Key.Keypad2))
                    {
                        Picked.Translate(new Vector3(0, 0, -0.01f));
                    }
                    if (kb.IsKeyDown(OpenTK.Input.Key.Keypad7))
                    {
                        Picked.Translate(new Vector3(0, 0.01f, 0));
                    }
                    if (kb.IsKeyDown(OpenTK.Input.Key.Keypad1))
                    {
                        Picked.Translate(new Vector3(0, -0.01f, 0));
                    }
                }
                if (kb.IsKeyDown(OpenTK.Input.Key.C) && Picked != null)
                {
                    if (kb.IsKeyDown(OpenTK.Input.Key.Keypad8))
                    {
                        Picked.Scale(1.01f);
                    }
                    if (kb.IsKeyDown(OpenTK.Input.Key.Keypad1))
                    {
                        Picked.Scale(0.99f);
                    }
                }

                var rd = new Random();/*
                                       * if(kb.IsKeyDown(OpenTK.Input.Key.Left))
                                       * {
                                       * var pos = RedLight[0].camera.Transformation.GetPosition();
                                       * RedLight.ForEach((ax) => ax.camera.Transformation.SetPosition(pos + Vector3.UnitX / 12.0f));
                                       * }
                                       * if(kb.IsKeyDown(OpenTK.Input.Key.Right))
                                       * {
                                       * var pos = RedLight[0].camera.Transformation.GetPosition();
                                       * redConeLight.camera.Transformation.SetPosition(pos - Vector3.UnitX / 12.0f);
                                       * }
                                       * if(kb.IsKeyDown(OpenTK.Input.Key.Up))
                                       * {
                                       * var pos = RedLight[0].camera.Transformation.GetPosition();
                                       * redConeLight.camera.Transformation.SetPosition(pos + Vector3.UnitZ / 12.0f);
                                       * }
                                       * if(kb.IsKeyDown(OpenTK.Input.Key.Down))
                                       * {
                                       * var pos = RedLight[0].camera.Transformation.GetPosition();
                                       * redConeLight.camera.Transformation.SetPosition(pos - Vector3.UnitZ / 12.0f);
                                       * }
                                       * if(kb.IsKeyDown(OpenTK.Input.Key.PageUp))
                                       * {
                                       * var pos = RedLight[0].camera.Transformation.GetPosition();
                                       * redConeLight.camera.Transformation.SetPosition(pos + Vector3.UnitY / 12.0f);
                                       * }
                                       * if(kb.IsKeyDown(OpenTK.Input.Key.PageDown))
                                       * {
                                       * var pos = RedLight[0].camera.Transformation.GetPosition();
                                       * redConeLight.camera.Transformation.SetPosition(pos - Vector3.UnitY / 12.0f);
                                       * }*/
                /*if(kb.IsKeyDown(OpenTK.Input.Key.U))
                 * {
                 *  var quat = Quaternion.FromAxisAngle(sun.Orientation.GetTangent(MathExtensions.TangentDirection.Left), -0.01f);
                 *  sun.Orientation = Quaternion.Multiply(sun.Orientation, quat);
                 * }
                 * if(kb.IsKeyDown(OpenTK.Input.Key.J))
                 * {
                 *  var quat = Quaternion.FromAxisAngle(sun.Orientation.GetTangent(MathExtensions.TangentDirection.Left), 0.01f);
                 *  sun.Orientation = Quaternion.Multiply(sun.Orientation, quat);
                 * }
                 * if(kb.IsKeyDown(OpenTK.Input.Key.H))
                 * {
                 *  var quat = Quaternion.FromAxisAngle(Vector3.UnitY, -0.01f);
                 *  sun.Orientation = Quaternion.Multiply(sun.Orientation, quat);
                 * }
                 * if(kb.IsKeyDown(OpenTK.Input.Key.K))
                 * {
                 *  var quat = Quaternion.FromAxisAngle(Vector3.UnitY, 0.01f);
                 *  sun.Orientation = Quaternion.Multiply(sun.Orientation, quat);
                 * }*/
            };
            return(RedLight);
        }
        private void pbDashboard_MouseMove(object sender, MouseEventArgs e)
        {
            _mousePoint = new Point(e.X, e.Y);
            if (btnRefference.CheckState == CheckState.Checked)
            {
                //  _DestinationRefferencePt = new Point(e.X, e.Y);
                pbDashboard.Refresh();
            }

            if (this._selectedIndex != -1)
            {
                int dX, dY;
                dX      = e.X - this._X;
                dY      = e.Y - this._Y;
                this._X = e.X;
                this._Y = e.Y;
                if (this._items[this._selectedIndex] is IResizable && this._selectedItem != 0)
                {
                    if (!((IResizable)this._items[this._selectedIndex]).Resize(dX, dY, this._selectedItem))
                    {
                        Cursor.Position = _mousePoint;
                    }
                }
                if (this._items[this._selectedIndex] is Flow)
                {
                    Flow fl = (Flow)this._items[this._selectedIndex];

                    IRenderable itm = getitemex(e.X, e.Y, this._items[this._selectedIndex]);

                    switch (this._selectedItem)
                    {
                    case 2:
                        if (itm != null && itm is Stock && fl._source != itm && ((Stock)itm)._inFlow == null)
                        {
                            if (fl._source == null)
                            {
                                fl.SetDestStock((Stock)itm, false);
                            }
                            else
                            {
                                fl.SetDestPoint(_mousePoint, false);
                            }
                        }
                        else
                        {
                            if (itm == null || fl._destination != itm)
                            {
                                fl.SetDestPoint(_mousePoint, false);
                            }
                        }
                        pbDashboard.Refresh();

                        return;

                    case 0:
                        if (itm != null && itm is Stock && fl._destination != itm && ((Stock)itm)._outFlow == null)
                        {
                            if (fl._destination == null)
                            {
                                fl.SetSourceStock((Stock)itm, false);
                            }
                            else
                            {
                                fl.SetSourcePoint(_mousePoint, false);
                            }
                        }
                        else
                        {
                            if (itm == null || fl._source != itm)
                            {
                                fl.SetSourcePoint(_mousePoint, false);
                            }
                        }
                        pbDashboard.Refresh();

                        return;
                    }
                }
                ((ITransformable)this._items[this._selectedIndex]).Translate(dX, dY, this._selectedItem);
                this.pbDashboard.Refresh();
            }
            else if (this.start != null)
            {
                this.pbDashboard.Refresh();
                Graphics  g      = this.pbDashboard.CreateGraphics();
                Rectangle sRect  = ((ITransformable)start).GetBounds();
                Point     sPoint = new Point(sRect.X + sRect.Width / 2, sRect.Y + sRect.Height / 2);
                g.DrawLine(new Pen(Color.Red), sPoint, new Point(e.X, e.Y));
            }
            else if (this._startPoint != null)
            {
                ITransformable item = (ITransformable)getItem(_mousePoint);
                if (item != null && item is Stock && this._flow._source != item && ((Stock)item)._inFlow == null)
                {
                    this._flow.SetDestStock((Stock)item, true);
                    ((Stock)item)._inFlow = this._flow;
                    this.pbDashboard.Refresh();
                }
                else
                {
                    if (item == null)
                    {
                        this._flow.SetDestPoint(_mousePoint, true);
                        if (this._flow._destination != null)
                        {
                            this._flow._destination._outFlow = null;
                            this._flow._destination          = null;
                        }
                    }
                    else
                    {
                        if (item != this._flow._destination)
                        {
                            this._flow.SetDestPoint(_mousePoint, true);
                        }
                    }
                    this.pbDashboard.Refresh();
                }
            }
            if (this._cursorItem == -1 && btnSelect.CheckState == CheckState.Checked)
            {
                while (true)
                {
                    ITransformable item = getItem(new Point(e.X, e.Y));
                    if (item == null || !(item is IResizable))
                    {
                        break;
                    }

                    int cnt = item.Contains(e.X, e.Y);
                    if (cnt < 1)
                    {
                        break;
                    }
                    this.pbDashboard.Cursor = ((IResizable)item).GetCursor(cnt);
                    return;
                }
                this.pbDashboard.Cursor = Cursors.Default;
                IRenderable it = getItem(new Point(e.X, e.Y)) as IRenderable;
                if (it != null)
                {
                    if (sbLabel1.Tag == it)
                    {
                        return;
                    }
                    sbLabel1.Text = it.GetHint();
                    sbLabel1.Tag  = it;
                }
                else
                {
                    if (sbLabel1.Tag != null)
                    {
                        sbLabel1.Tag  = null;
                        sbLabel1.Text = "";
                    }
                }
            }
            else
            {
                this.pbDashboard.Cursor = Cursors.Default;
            }
        }
Esempio n. 42
0
        static void CalculateMatrices(ITransformable item)
        {
            item.Transform.CalculateMatrix();

            foreach (var child in item.GetChildren(i => (!i.Transform.Static || !i.Transform.calculated)))
            {
                CalculateMatrices(child);
            }
        }
Esempio n. 43
0
        public static void SetUpInputBehaviours()
        {
            Game.OnKeyUp += (o, e) =>
            {
                if (e.Key == OpenTK.Input.Key.F1 && !e.Shift)
                {
                    InterpolateCameraFromSaved(0);
                }
                if (e.Key == OpenTK.Input.Key.F2 && !e.Shift)
                {
                    InterpolateCameraFromSaved(1);
                }
                if (e.Key == OpenTK.Input.Key.F3 && !e.Shift)
                {
                    InterpolateCameraFromSaved(2);
                }
                if (e.Key == OpenTK.Input.Key.F4 && !e.Shift)
                {
                    InterpolateCameraFromSaved(3);
                }
                if (e.Key == OpenTK.Input.Key.F5 && !e.Shift)
                {
                    InterpolateCameraFromSaved(4);
                }
                if (e.Key == OpenTK.Input.Key.F6 && !e.Shift)
                {
                    InterpolateCameraFromSaved(5);
                }
                if (e.Key == OpenTK.Input.Key.F7 && !e.Shift)
                {
                    InterpolateCameraFromSaved(6);
                }

                if (e.Key == OpenTK.Input.Key.F1 && e.Shift)
                {
                    SaveCamera(0);
                }
                if (e.Key == OpenTK.Input.Key.F2 && e.Shift)
                {
                    SaveCamera(1);
                }
                if (e.Key == OpenTK.Input.Key.F3 && e.Shift)
                {
                    SaveCamera(2);
                }
                if (e.Key == OpenTK.Input.Key.F4 && e.Shift)
                {
                    SaveCamera(3);
                }
                if (e.Key == OpenTK.Input.Key.F5 && e.Shift)
                {
                    SaveCamera(4);
                }
                if (e.Key == OpenTK.Input.Key.F6 && e.Shift)
                {
                    SaveCamera(5);
                }
                if (e.Key == OpenTK.Input.Key.F7 && e.Shift)
                {
                    SaveCamera(6);
                }

                if (e.Key == OpenTK.Input.Key.Tab)
                {
                    Game.DisplayAdapter.IsCursorVisible = !Game.DisplayAdapter.IsCursorVisible;
                    FreeCam.Freeze = Game.DisplayAdapter.IsCursorVisible;
                }
                if (e.Key == OpenTK.Input.Key.Comma)
                {
                    if (PickedMesh.GetLodLevel(0) != null)
                    {
                        PickedMesh.GetLodLevel(0).Material.Roughness -= 0.05f;
                        if (PickedMesh.GetLodLevel(0).Material.Roughness < 0)
                        {
                            PickedMesh.GetLodLevel(0).Material.Roughness = 0;
                        }
                    }
                }
                if (e.Key == OpenTK.Input.Key.Period)
                {
                    if (PickedMesh.GetLodLevel(0) != null)
                    {
                        PickedMesh.GetLodLevel(0).Material.Roughness += 0.05f;
                        if (PickedMesh.GetLodLevel(0).Material.Roughness > 1)
                        {
                            PickedMesh.GetLodLevel(0).Material.Roughness = 1;
                        }
                    }
                }

                if (e.Key == OpenTK.Input.Key.T)
                {
                    /*if(PickedMesh != null)
                     * {
                     *  PickedMesh.GetLodLevel(0).Material.ParallaxHeightMultiplier -= 0.1f;
                     *  if(PickedMesh.GetLodLevel(0).Material.ParallaxHeightMultiplier <= 0.01f)
                     *      PickedMesh.GetLodLevel(0).Material.ParallaxHeightMultiplier = 0.01f;
                     * }*/
                }
                if (e.Key == OpenTK.Input.Key.Y)
                {
                    if (PickedMesh.GetLodLevel(0) != null)
                    {
                        PickedMesh.GetLodLevel(0).Material.ParallaxHeightMultiplier += 0.1f;
                        if (PickedMesh.GetLodLevel(0).Material.ParallaxHeightMultiplier >= 24)
                        {
                            PickedMesh.GetLodLevel(0).Material.ParallaxHeightMultiplier = 24;
                        }
                    }
                }

                if (e.Key == OpenTK.Input.Key.Pause)
                {
                    ShaderProgram.RecompileAll();
                    ComputeShader.RecompileAll();
                }
                if (e.Key == OpenTK.Input.Key.R)
                {
                    // Game.DisplayAdapter.Pipeline.PostProcessor.UnbiasedIntegrateRenderMode = !Game.DisplayAdapter.Pipeline.PostProcessor.UnbiasedIntegrateRenderMode;
                }
                if (e.Key == OpenTK.Input.Key.LBracket)
                {
                    FreeCam.Cam.Brightness -= 0.1f;
                }
                if (e.Key == OpenTK.Input.Key.RBracket)
                {
                    FreeCam.Cam.Brightness += 0.1f;
                }
                if (e.Key == OpenTK.Input.Key.Number1)
                {
                    RedLight[0].GetTransformationManager().SetPosition(FreeCam.Cam.Transformation.GetPosition() + new Vector3((float)rand.NextDouble() * 2 - 1, (float)rand.NextDouble() * 2 - 1, (float)rand.NextDouble() * 2 - 1) * 0.1f);
                    RedLight[0].GetTransformationManager().SetOrientation(FreeCam.Cam.Transformation.GetOrientation());
                    Picked = RedLight[0];
                }
                if (e.Key == OpenTK.Input.Key.Tilde)
                {
                    // Interpolator.Interpolate<Vector3>(RedLight.GetTransformationManager().Position, RedLight.GetTransformationManager().Position.R, FreeCam.Cam.GetPosition(), 8.0f, Interpolator.Easing.EaseInOut);
                }
                var settings = Game.DisplayAdapter.MainRenderer.GraphicsSettings;
                if (e.Key == OpenTK.Input.Key.Number0)
                {
                    settings.UseVDAO = !settings.UseVDAO;
                }
                if (e.Key == OpenTK.Input.Key.Number9)
                {
                    settings.UseBloom = !settings.UseBloom;
                }
                if (e.Key == OpenTK.Input.Key.Number8)
                {
                    settings.UseDeferred = !settings.UseDeferred;
                }
                if (e.Key == OpenTK.Input.Key.Number7)
                {
                    settings.UseDepth = !settings.UseDepth;
                }
                if (e.Key == OpenTK.Input.Key.Number6)
                {
                    settings.UseFog = !settings.UseFog;
                }
                if (e.Key == OpenTK.Input.Key.Number5)
                {
                    settings.UseCubeMapGI = !settings.UseCubeMapGI;
                }
                if (e.Key == OpenTK.Input.Key.Number4)
                {
                    settings.UseRSM = !settings.UseRSM;
                }
                if (e.Key == OpenTK.Input.Key.Number3)
                {
                    settings.UseVXGI = !settings.UseVXGI;
                }
                if (e.Key == OpenTK.Input.Key.Number2)
                {
                    settings.UseHBAO = !settings.UseHBAO;
                }
            };
        }
Esempio n. 44
0
 public static void Remove(ITransformable item)
 {
     tree.Remove(item);
 }
Esempio n. 45
0
 public override bool EndCapture(ITransformable target)
 {
     return(true);
 }
Esempio n. 46
0
 /// <summary>
 /// Calculates the transformation matrix corresponding to the given Renderable node</summary>
 /// <param name="node">Renderable node</param>
 /// <returns>transformation matrix corresponding to the node's transform components</returns>
 public static Matrix4F CalcTransform(ITransformable node)
 {
     return CalcTransform(
         node.Translation,
         node.Rotation,
         node.Scale,
         node.Pivot);
 }
Esempio n. 47
0
 private static void TransformScale(ITransformable transformable, double scaleX, double scaleY, double scaleZ)
 {
     transformable.Transform = Scaling(scaleX, scaleY, scaleZ) * transformable.Transform;
 }
Esempio n. 48
0
 public void SetTransformable(ITransformable transformController)
 {
     this.transformControl = transformController;
 }
Esempio n. 49
0
 private static void TransformTranslate(ITransformable transformable, double tx = 0, double ty = 0, double tz = 0)
 {
     transformable.Transform = Translation(tx, ty, tz) * transformable.Transform;
 }
Esempio n. 50
0
 private static void TransformRotate(ITransformable transformable, double rx = 0, double ry = 0, double rz = 0)
 {
     transformable.Transform = RotationX(rx) * RotationY(ry) * RotationZ(rz) * transformable.Transform;
 }
Esempio n. 51
0
 public void DrawFrame(MX.Animation animation, ITransformable transformObj, IRenderable renderableObj)
 {
     DrawFrame(animation.Frames[animation.CurrentFrame], transformObj, renderableObj);
 }