Example #1
0
 private void SetPreview(_3DComponent component)
 {
     if (this.Preview != null)
     {
         Scene.Remove(Preview);
     }
     this.Preview = component;
     Scene.Add(component);
 }
Example #2
0
        public override void Update(UpdateState state)
        {
            Scene.Update(state);
            //ChangeGraphic(128+5);
            Invalidate();

            if (Comp3D != null)
            {
                foreach (var e in Comp3D)
                {
                    e.Wireframe = state.MouseState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed;
                }
            }

            if (!MouseDown)
            {
                LastMouse = state.MouseState.Position;
            }
            MouseDown = state.MouseState.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed;
            if (MouseDown)
            {
                var mpos = state.MouseState.Position;
                RotationX += (mpos.X - LastMouse.X) / 100f;
                RotationY += (mpos.Y - LastMouse.Y) / 100f;
                LastMouse  = mpos;
            }

            var mat = Microsoft.Xna.Framework.Matrix.CreateRotationZ(RotationY) * Microsoft.Xna.Framework.Matrix.CreateRotationY(RotationX);

            Camera.Position = Vector3.Transform(new Vector3(4, 4, 0), mat);
            Camera.Target   = new Vector3(0, 1f, 0);
            RotationX      += 0.01f;

            base.Update(state);
            if ((bool)state.SharedData["ExternalDraw"] && TargetTile?.WorldUI is ObjectComponent)
            {
                if (Comp3D != null)
                {
                    foreach (var e in Comp3D)
                    {
                        e.Dispose();
                        Scene.Remove(e);
                    }
                }
                Comp3D = new List <Debug3DDGRPComponent>();

                foreach (var obj in TargetTile.MultitileGroup.Objects)
                {
                    if (obj.GetValue(VMStackObjectVariable.Room) == 2)
                    {
                        continue;
                    }
                    var c    = new Debug3DDGRPComponent();
                    var dgrp = ((ObjectComponent)obj.WorldUI).DGRP;
                    c.Mesh = (dgrp == null)?null:Content.Content.Get().RCMeshes.Get(dgrp, obj.Object.OBJ); //new DGRP3DMesh(((ObjectComponent)obj.WorldUI).DGRP, obj.Object.OBJ, GameFacade.GraphicsDevice, null);
                    Scene.Add(c);
                    var vp = obj.VisualPosition;
                    c.Position = new Vector3(-(vp.X - 0.5f), vp.Z, -(vp.Y - 0.5f));
                    c.Initialize();
                    if (obj == TargetTile)
                    {
                        TargetComp3D = c;
                    }
                    Comp3D.Add(c);
                }
                //try get our dgrp;
            }
        }