public override void LookAtSelf(IEntityManager manager) { var combinedBox = new BoundingBox(); GraphicEntity entity = null; foreach (var tag in Tags) { entity = manager.GetEntity(tag); if (entity.GetComponents <IRenderableComponent>().Any(x => x.CanRender)) { var geos = entity.GetComponents <IGeometryComponent>(); if (geos.Any()) { var geo = geos.First(); combinedBox = combinedBox.Merge(geo.Box); } } } var com = new MoveCameraToTargetComponent { Target = entity.Tag, TargetPosition = combinedBox.GetCenter() }; entity.AddComponent(com); }
public bool Execute(GraphicEntity entity) { var find = entity.GetComponents <GeneralCameraComponent>(); if (!find.Any()) { return(false); } var ccom = find.First(); var delta = InputState.Delta; var p2 = InputState.CurrentPosition; var data = new MovementData { End = p2 }; entity .GetOrCreateComponent(new CameraZoomingComponent { State = ccom.GetState() }) .Do(x => { x.MovementData = data; x.Delta = delta; }); return(true); }
public bool Execute(GraphicEntity entity) { var find = entity.GetComponents <VeldridCameraBuilder.VeldridCameraComponent>(); if (!find.Any()) { return(false); } var com = find.First(); var x = box.SizeX(); var y = box.SizeY(); var ratio = x / y; var max = Math.Max(box.SizeX(), box.SizeY()) * 1.2f; com.Position = box.GetCenter() + Vector3.UnitZ * max; com.RotatePoint = box.GetCenter(); com.Width = max; com.LookDirection = new Vector3(0, 0, -3); com.UpDirection = new Vector3(0, 1, 0); com.Scale = 1; // com.LookDirection = -Vector3.UnitZ * max; //ccom.Width *= box.SizeX() / viewport.ActualWidth; //var oldTarget = pcam.Position + pcam.LookDirection; //var distance = pcam.LookDirection.Length; //var newTarget = centerRay.PlaneIntersection(oldTarget, w); //if (newTarget != null) { // orthographicCamera.LookDirection = w * distance; // orthographicCamera.Position = newTarget.Value - orthographicCamera.LookDirection; //} return(true); }
public bool Execute(GraphicEntity entity) { var find = entity.GetComponents <GeneralCameraComponent>(); if (!find.Any()) { return(false); } var ccom = find.First(); return(Executing(entity, ccom) && Executing(ccom)); }
public bool Execute(GraphicEntity entity) { var find = entity.GetComponents <GeneralCameraComponent>(); if (!find.Any()) { return(false); } entity.RemoveComponents <CameraMovementComponent>(); return(true); }
public bool Execute(GraphicEntity entity) { var find = entity.GetComponents <VeldridCameraBuilder.VeldridCameraComponent>(); if (!find.Any()) { return(false); } var ccom = find.First(); var p11 = state.ButtonsStates[GeneralMouseButtons.Right].PointDown; var p2 = state.CurrentPosition; var moveV = p2 - p11; if (moveV == Vector2.Zero) { return(false); } var v2Up = new Vector2(0, -1); var mouseMove = moveV; var angleLook = v2Up.AngleRad(mouseMove.Normalize()); //Console.WriteLine($"Angle 2D: {v2Up.Angle(mouseMove.Normalize())}"); var look = ccom.LookDirection.Normalize(); var up = ccom.UpDirection.Normalize(); var rotatedUp = Vector3.TransformNormal(up, Matrix4x4.CreateFromAxisAngle(look, angleLook)); var cross = Vector3.Cross(look, rotatedUp); var angle = mouseMove.Length(); var movetozero = Matrix4x4.CreateTranslation(ccom.RotatePoint * -1f); var rotate = Matrix4x4.CreateFromAxisAngle(cross, angle.ToRad()); var returntocenter = Matrix4x4.CreateTranslation(ccom.RotatePoint); var matrixRotate = movetozero * rotate * returntocenter; if (matrixRotate.IsIdentity) { return(false); } ccom.UpDirection = Vector3.TransformNormal(ccom.UpDirection.Normalize(), matrixRotate).Normalize(); ccom.LookDirection = Vector3.TransformNormal(ccom.LookDirection.Normalize(), matrixRotate).Normalize(); ccom.Position = Vector3.Transform(ccom.Position, matrixRotate); return(true); }
public bool Execute(GraphicEntity entity) { var find = entity.GetComponents <GeneralCameraComponent>(); if (!find.Any()) { return(false); } var ccom = find.First(); ccom.ResetToDefault(); entity.RemoveComponents <CameraMovementComponent>(); return(true); }
public bool Execute(GraphicEntity entity) { var find = entity.GetComponents <VeldridCameraBuilder.VeldridCameraComponent>(); if (!find.Any()) { return(false); } var ccom = find.First(); var delta = state.Delta; var nscale = ccom.Scale + (delta * 0.001f); if (nscale > 0) { ccom.Scale = nscale; } return(true); }
public bool Execute(GraphicEntity entity) { var find = entity.GetComponents <GeneralCameraComponent>(); if (!find.Any()) { return(false); } var ccom = find.First(); var type = KeywordMovingComponent.MovingDirection.Undefined; switch (InputState.Keyword) { case GeneralKeywords.W: type = KeywordMovingComponent.MovingDirection.MoveForward; break; case GeneralKeywords.S: type = KeywordMovingComponent.MovingDirection.MoveBackward; break; case GeneralKeywords.A: type = KeywordMovingComponent.MovingDirection.TurnLeft; break; case GeneralKeywords.D: type = KeywordMovingComponent.MovingDirection.TurnRight; break; } entity .GetOrCreateComponent(new KeywordMovingComponent()) .Do(x => { x.Direction = type; x.IsKeywordDown = InputState.IsKeywordDown; }); return(true); }
public bool Execute(GraphicEntity entity) { var find = entity.GetComponents <GeneralCameraComponent>(); if (!find.Any()) { return(false); } var p11 = InputState.ButtonsStates[GeneralMouseButtons.Right].PointV2; var p2 = InputState.CurrentPosition; var data = new MovementData { Begin = p11, End = p2 }; var ccom = find.First(); entity.GetOrCreateComponent(new CameraRotatingComponent { State = ccom.GetState() }) .MovementData = data; return(true); }
public GraphicEntityDecorator(GraphicEntity entity) { this.entity = entity; coms = entity.GetComponents().ToList(); }