Example #1
0
        public void AddVisual(Visual3D visual, AegirLib.Behaviour.World.Transform transform)
        {
            RenderItemListener listener = new RenderItemListener(visual, transform);

            listeners.Add(listener);
            viewport.Children.Add(visual);
        }
Example #2
0
 public void CalculateFollowCameraOffset(AegirLib.Behaviour.World.Transform followTransform)
 {
     viewport.Dispatcher.Invoke(() =>
     {
         this.followTransform         = followTransform;
         AegirLib.MathType.Vector3 fp = followTransform.LocalPosition;
         CameraPositionOffset         = new Vector3D(fp.X, fp.Y, fp.Z) - (Vector3D)viewport.CameraController.CameraPosition;
     });
 }
Example #3
0
        private void RenderMeshBehaviour(MeshBehaviour renderBehaviour, LibTransform transform)
        {
            if (renderBehaviour == null)
            {
                throw new ArgumentNullException($"Could not render Mesh {nameof(renderBehaviour)} was null");
            }
            if (transform == null)
            {
                throw new ArgumentNullException($"Could not render Mesh {nameof(transform)} was null");
            }
            DebugUtil.LogWithLocation($"Rendering MeshBehaviour: {transform.Parent.Name}");
            MeshGeometry3D geometry = meshFactory.GetGeometry(renderBehaviour.Mesh.Data);
            SceneActor     actor    = new SceneActor(geometry, transform);

            for (int i = 0, l = viewports.Count; i < l; i++)
            {
                viewports[i].RenderActor(actor);
            }
        }
Example #4
0
        private void RenderEntity(EntityViewModel entity)
        {
            foreach (EntityViewModel child in entity.Children)
            {
                RenderEntity(child);
            }
            DebugUtil.LogWithLocation($"Rendering entity: {entity.Name}");
            LibTransform  transformBehaviour = entity.GetEntityComponent <LibTransform>();
            MeshBehaviour renderBehaviour    = entity.GetEntityComponent <MeshBehaviour>();

            if (renderBehaviour != null)
            {
                renderBehaviours.Add(renderBehaviour);
                renderBehaviour.MeshChanged += RenderBehaviour_MeshChanged;
                if (renderBehaviour?.Mesh?.Data != null)
                {
                    RenderMeshBehaviour(renderBehaviour, transformBehaviour);
                }
                else
                {
                    SceneActor actor = new SceneActor(null, transformBehaviour);
                    for (int i = 0, l = viewports.Count; i < l; i++)
                    {
                        viewports[i].RenderActor(actor);
                    }
                }
            }
            else
            {
                DebugUtil.LogWithLocation($"No meshdata present for:{entity.Name} ");
                //No meshdata, lets show a dummy
                SceneActor actor = new SceneActor(null, transformBehaviour);
                for (int i = 0, l = viewports.Count; i < l; i++)
                {
                    viewports[i].RenderActor(actor);
                }
            }
        }
Example #5
0
        private void RenderBehaviour_MeshChanged(MeshBehaviour source, MeshChangedArgs eventArgs)
        {
            switch (eventArgs.Action)
            {
            case MeshChangeAction.New:
                LibTransform t = source.Parent.GetComponent <LibTransform>();
                RenderMeshBehaviour(source, t);
                break;

            case MeshChangeAction.Remove:
                throw new NotImplementedException();
                //RemoveMesh(eventArgs.Old);
                break;

            case MeshChangeAction.Change:
                throw new NotImplementedException();
                //ChangeMesh(source, eventArgs.Old.Data);
                break;

            default:
                break;
            }
        }
Example #6
0
 public RenderItemListener(Visual3D visual, AegirLib.Behaviour.World.Transform item)
 {
     this.Visual = visual;
     this.Item   = item;
 }
Example #7
0
 internal void CameraFollow(EntityViewModel selectedItem)
 {
     AegirLib.Behaviour.World.Transform transform = selectedItem.GetEntityComponent <AegirLib.Behaviour.World.Transform>();
     //viewports[1].FollowTransform = transform;
 }
Example #8
0
        public void AddDummy(AegirLib.Behaviour.World.Transform transformBehaviour)
        {
            Visual3D dummyVisual = VisualFactory.GetDummyVisual();

            AddVisual(dummyVisual, transformBehaviour);
        }
Example #9
0
 public SceneActor(MeshGeometry3D mesh, AegirLib.Behaviour.World.Transform transform)
 {
     Geometry  = mesh;
     Transform = transform;
 }