Exemple #1
0
        /// <summary>
        /// Initializes the radar behavior
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            this.screenplay = this.EntityManager.Find("ScreenplayManager").FindComponent<ScreenplayManager>();

            foreach (var fighter in this.screenplay.FighterList)
            {
                if (fighter.State == FighterState.Player)
                {
                    continue;
                }

                Transform3D radarTickTransform;
                BasicMaterial radarTickMaterial;
                Entity radarTick = new Entity()
                .AddComponent(radarTickTransform = new Transform3D())
                .AddComponent(new Model("Content/Models/Hud/HudRadarTick.FBX"))
                .AddComponent(new ModelRenderer())
                .AddComponent(new MaterialsMap(radarTickMaterial = new BasicMaterial("Content/Textures/Hud/RadarTick.png", typeof(CockpitAdditiveLayer))
                    {
                        DiffuseColor = colors[(int)fighter.State]
                    }))
                ;

                radarTick.Enabled = false;

                this.Owner.AddChild(radarTick);
                this.radarTicks.Add(radarTickTransform);
                this.radarTickMaterials.Add(radarTickMaterial);
            }
        }
Exemple #2
0
 public TimBehavior()
     : base("TimBehavior")
 {
     this.direction = NONE;
     this.anim2D = null;
     this.trans2D = null;
     MyScene.currentState = MyScene.AnimState.Idle;
 }
        /// <summary>
        /// Resolves the dependencies needed for this instance to work.
        /// </summary>
        protected override void ResolveDependencies()
        {
            base.ResolveDependencies();

            // fast references for players and its transform
            this.player = this.Owner;
            this.playerTransform = this.player.FindComponent<Transform3D>();            
        }
        public IGameAction CreateDeadAnimation(Entity entity, Transform3D transform, Vector3 to)
        {
            var actionAnimation = new Vector3AnimationGameAction(entity, Vector3.One, to, TimeSpan.FromMilliseconds(100), EaseFunction.CubicOutEase, (value) =>
            {
                transform.LocalScale = value;
            });

            return actionAnimation;
        }
Exemple #5
0
        protected override void Initialize()
        {
            base.Initialize();

            if (string.IsNullOrEmpty(this.EntityPath))
            {
                return;
            }

            var entity = this.EntityManager.Find(this.EntityPath);
            this.targetTransform = entity.FindComponent<Transform3D>();
        }
        protected override void ResolveDependencies()
        {
            base.ResolveDependencies();

            this.visibleTerrain = new List<Entity>();

            this.firstUpdate = true;

            var player = this.EntityManager.Find("player");
            this.PlayerTransform = player.FindComponent<Transform3D>();

            this.entityPoolComponent.HalfExtendLimits = this.HalfExtendLimits;
        }
 /// <summary>
 /// Instantiates a new asteroid sector
 /// </summary>
 /// <param name="name">The name</param>
 /// <param name="sectorType">Sector type</param>
 /// <param name="lod">The LOD level</param>
 public AsteroidSectorDecorator(string name, int sectorType, int lod)
 {
     this.entity = new Entity(name)
     .AddComponent(this.transform = new Transform3D())
     .AddComponent(new Model(string.Format("Content/Assets/Models/Asteroids/Asteroids_{0}_{1}.FBX", sectorType, lod)))
     .AddComponent(new ModelRenderer())
     .AddComponent(new BoxCollider3D())
     .AddComponent(new MaterialsMap()
     {
         DefaultMaterialPath = WaveContent.Assets.Materials.AsteroidMat
     })
     ;
 }
 /// <summary>
 /// Instantiates a new asteroid sector
 /// </summary>
 /// <param name="name">The name</param>
 /// <param name="sectorType">Sector type</param>
 /// <param name="lod">The LOD level</param>
 public AsteroidSectorDecorator(string name, int sectorType, int lod)
 {
     this.entity = new Entity(name)
     .AddComponent(this.transform = new Transform3D())
     .AddComponent(new Model(string.Format("Content/Models/Asteroids/Asteroids_{0}_{1}.FBX", sectorType, lod)))
     .AddComponent(new ModelRenderer())
     .AddComponent(new BoxCollider())
     .AddComponent(new MaterialsMap(new NormalMappingMaterial(
         "Content/Textures/Asteroids/Asteroid_diffuse.png",
         "Content/Textures/Asteroids/Asteroid_norm_spec.png")
     {
         AmbientColor = GameResources.AmbientColor
     }))
     ;
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="ScaleTo3DGameAction"/> class.
        /// </summary>
        /// <param name="entity">The target entity</param>
        /// <param name="to">The target scale</param>
        /// <param name="time">Animation duration</param>
        /// <param name="ease">The ease function</param>
        /// /// <param name="local">If the scale is in local coordinate</param>
        public ScaleTo3DGameAction(Entity entity, Vector3 to, TimeSpan time, EaseFunction ease = EaseFunction.None, bool local = false)
            : base(entity, Vector3.Zero, to, time, ease)
        {
            this.local = local;

            if (local)
            {
                this.updateAction = this.LocalScaleAction;
            }
            else
            {
                this.updateAction = this.ScaleAction;
            }

            this.transform = entity.FindComponent<Transform3D>();
        }
        protected override void CreateScene()
        {
            this.Load(WaveContent.Scenes.MyScene);

            this.ball = this.EntityManager.Find("ball");
            this.ballTransform3D = this.ball.FindComponent<Transform3D>();
            this.ballInitialPosition = this.ballTransform3D.Position;

            WaveServices.TimerFactory.CreateTimer(TimeSpan.FromSeconds(3),
                () =>
                {
                    this.ball.RemoveComponent<RigidBody3D>();
                    this.ballTransform3D.Position = this.ballInitialPosition;
                    this.ball.AddComponent(new RigidBody3D());
                    this.ball.RefreshDependencies();
                },
                true);
        }
Exemple #11
0
        /// <summary>
        /// Get a free trail
        /// </summary>
        /// <param name="transform">The transform to follow the trail</param>
        /// <returns></returns>
        public TrailSetting GetFreeTrail(Transform3D transform)
        {
            if (this.FreeTrails.Count == 0)
            {
                this.InstantiateTrails(TrailCountIncrement);
            }

            TrailSetting trail = this.FreeTrails[0];
            this.FreeTrails.RemoveAt(0);
            this.BusyTrails.Add(trail);
            this.NumTrails++;

            trail.Transform = transform;
            trail.Reset();

            if (!this.IsActive)
            {
                this.IsActive = true;
            }

            return trail;
        }
 private void myViewport_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
 {
     currentTransform = Camera.Transform;
 }
Exemple #13
0
        /// <summary>
        /// Draw all entities stored in buffer
        /// </summary>
        public void Flush()
        {
            // initialize
            Vector3D vLight = _vCameraPos - _vTarget; vLight.Normalize();

            _boxDrawingCounter = 0;
            _currentTransf     = null;
            System.Drawing.Graphics g = Graphics;
            g.Clear(_backgroundColor);

            if (EnableFaceSorting)
            {
                // sort face list
                FaceComparison faceComparer = new FaceComparison(GetWorldToEyeTransformation());
                _faces.Sort(faceComparer);
            }
            // draw background segments
            foreach (Segment s in _segmentsBackground)
            {
                Draw(s);
            }
            // draw background faces
            foreach (Face face in _facesBackground)
            {
                Draw(face, FaceDir.FRONT);
            }
            // draw all faces using solid / transparency depending on
            foreach (Face face in _faces)
            {
                Draw(face, FaceDir.BACK);
            }

            // sort box list
            if (_useBoxelOrderer)
            {
                BoxelOrderer boxelOrderer = new BoxelOrderer(_boxes);
                boxelOrderer.Direction = _vTarget - _vCameraPos;
                _boxes = boxelOrderer.GetSortedList();
            }
            else
            {
                _boxes.Sort(new BoxComparerSimplifiedPainterAlgo(GetWorldToEyeTransformation()));
            }

            // sort cylinder list
            _cylinders.Sort(new CylinderComparerSimplifiedPainterAlgo(GetWorldToEyeTransformation()));

            if (_cylinders.Count > 0)
            {
                // sort by Z
                List <Drawable> drawableList = new List <Drawable>();
                drawableList.AddRange(_boxes);
                drawableList.AddRange(_cylinders);
                drawableList.Sort(new DrawableComparerSimplifiedPainterAlgo());

                List <Box>      boxes         = new List <Box>();
                List <Cylinder> cylinders     = new List <Cylinder>();
                bool            processingBox = drawableList[0] is Box;
                foreach (Drawable drawable in drawableList)
                {
                    Box      b = drawable as Box;
                    Cylinder c = drawable as Cylinder;

                    if ((null != b) && processingBox)
                    {
                        boxes.Add(b);
                    }
                    else if ((null == b) && !processingBox)
                    {
                        cylinders.Add(c);
                    }
                    else
                    {
                        if (boxes.Count > 0)
                        {
                            BoxelOrderer boxelOrderer = new BoxelOrderer(boxes);
                            boxelOrderer.Direction = _vTarget - _vCameraPos;
                            boxes = boxelOrderer.GetSortedList();
                            // draw boxes
                            foreach (Box bb in boxes)
                            {
                                Draw(bb);
                            }
                            // clear
                            boxes.Clear();
                        }
                        if (cylinders.Count > 0)
                        {
                            cylinders.Sort(new CylinderComparerSimplifiedPainterAlgo(GetWorldToEyeTransformation()));
                            // draw cylinders
                            foreach (Cylinder cc in cylinders)
                            {
                                Draw(cc);
                            }
                            // clear
                            cylinders.Clear();
                        }
                        if (null != b)
                        {
                            boxes.Add(b);
                            processingBox = true;
                        }
                        else
                        {
                            cylinders.Add(c);
                            processingBox = false;
                        }
                    }
                }

                // remaining boxes
                BoxelOrderer boxelOrdererRem = new BoxelOrderer(boxes);
                boxelOrdererRem.Direction = _vTarget - _vCameraPos;
                boxes = boxelOrdererRem.GetSortedList();
                // draw boxes
                foreach (Box bb in boxes)
                {
                    Draw(bb);
                }

                // remaining cylinders
                cylinders.Sort(new CylinderComparerSimplifiedPainterAlgo(GetWorldToEyeTransformation()));
                // draw cylinders
                foreach (Cylinder cc in cylinders)
                {
                    Draw(cc);
                }
                // clear
                boxes.Clear();
            }
            else
            {
                // draw all boxes
                foreach (Box box in _boxes)
                {
                    Draw(box);
                }
            }
            // images inst
            if (_listImageInst.Count > 0)
            {
                // --- sort image inst
                Analysis   analysis   = _listImageInst[0].Analysis;
                BBox3D     bbox       = analysis.Solution.BBoxGlobal;
                List <Box> boxesImage = new List <Box>();
                foreach (ImageInst imageInst in _listImageInst)
                {
                    boxesImage.Add(imageInst.ToBox());
                }

                if (_useBoxelOrderer && false) // NOT WORKING ?
                {
                    BoxelOrderer boxelOrderer = new BoxelOrderer(boxesImage);
                    boxelOrderer.TuneParam = 10.0;
                    boxelOrderer.Direction = _vTarget - _vCameraPos;
                    boxesImage             = boxelOrderer.GetSortedList();
                }
                else
                {
                    boxesImage.Sort(new BoxComparerSimplifiedPainterAlgo(GetWorldToEyeTransformation()));
                }
                // ---

                List <ImageInst> listImageInstSorted = new List <ImageInst>();
                foreach (Box b in boxesImage)
                {
                    listImageInstSorted.Add(new ImageInst(analysis, new Vector3D(b.Length, b.Width, b.Height), b.BPosition));
                }

                // draw image inst
                foreach (ImageInst im in listImageInstSorted)
                {
                    Draw(im);
                }
            }
            // draw faces : end
            foreach (Face face in _faces)
            {
                Draw(face, FaceDir.FRONT);
            }

            // draw segment list (e.g. hatching)
            foreach (Segment seg in _segments)
            {
                Draw(seg);
            }

            // draw cotation cubes
            if (ShowDimensions)
            {
                foreach (DimensionCube qc in _dimensions)
                {
                    qc.Draw(this);
                }
            }
        }
        private void InitCoffee()
        {
            Color coffeeColor = new Color(111 / 255.0f, 78 / 255.0f, 55 / 255.0f, 0.95f);
            CoffeeEffectParameters coffeeEffect = new CoffeeEffectParameters(main.Effects["Coffee"],
                                                                             main.Textures["CoffeeUV"], main.Textures["CoffeeFlow"], coffeeColor);
            Transform3D transform3D = new Transform3D(Vector3.Zero, -Vector3.Forward, Vector3.Up);

            coffee = new Coffee("Coffee", ActorType.Primitive,
                                StatusType.Update | StatusType.Drawn, transform3D, coffeeEffect,
                                main.Models["CoffeePlane"], levelData.coffeeInfo,
                                main.ObjectManager.ActorList.Find(actor3D => actor3D.ActorType == ActorType.Player) as PlayerTile);
            //Most of these constructor arguments are not used, need to refactor the entire structure.
            coffee.ControllerList.Add(new CoffeeMovementComponent("cmc", ControllerType.Movement,
                                                                  ActivationType.Activated, 0, Smoother.SmoothingMethod.Smooth, coffee));
            coffee.ControllerList.Add(new ColliderComponent("cc Coffee", ControllerType.Collider,
                                                            (skin0, skin1) =>
            {
                if (skin1.Owner.ExternalData is Tile tile)
                {
                    if (tile.TileType == ETileType.Player)
                    {
                        EventManager.FireEvent(new RemoveActorEvent {
                            body = tile.Body
                        });
                        EventManager.FireEvent(new SoundEventInfo()
                        {
                            category       = SoundCategory.UI, sfxType = SfxType.Lose,
                            soundEventType = SoundEventType.PlaySfx
                        });
                        TimeManager.CallFunctionInSeconds("lose",
                                                          () =>
                        {
                            EventManager.FireEvent(new GameStateMessageEventInfo {
                                GameState = GameState.Lost
                            });
                        }, 2);
                    }

                    if (tile.SpawnPos.Y < ((Coffee)skin0.Owner.ExternalData).Transform3D.Translation.Y)
                    {
                        EventManager.FireEvent(new RemoveActorEvent {
                            body = tile.Body
                        });
                        EventManager.FireEvent(new TileEventInfo {
                            Id = tile.ID, Type = TileEventType.Consumed
                        });
                    }
                    else
                    {
                        tile.Body.SetInactive();
                        EventManager.FireEvent(new TileEventInfo
                        {
                            Id = tile.ID, Type = TileEventType.Reset, IsEasy = main.IsEasy
                        });
                    }

                    return(true);
                }

                return(false);
            }));

            main.ObjectManager.Add(coffee);
            UiTimeController controller =
                main.UiManager.UIObjectList.Find(actor2D => actor2D.ID == "TimeText")?.ControllerList[0] as
                UiTimeController;

            controller?.SetCoffee(coffee);
        }
Exemple #15
0
 public static godot_variant CreateFromTransform3D(Transform3D from)
 {
     NativeFuncs.godotsharp_variant_new_transform3d(out godot_variant ret, from);
     return(ret);
 }
Exemple #16
0
        /// <summary>
        /// Initialize the hierachy of entities.
        /// </summary>
        private void InitializeHierachy()
        {
            if (this.ElBowAnchor == null)
            {
                this.ElBowAnchor = this.ConfigureAnchor(this.Owner, "ElBow");
                this.ElBowTransfom = this.ElBowAnchor.FindComponent<Transform3D>();
            }

            if (this.WristAnchor == null)
            {
                this.WristAnchor = this.ConfigureAnchor(this.Owner, "Wrist");
                this.WristTransfom = this.WristAnchor.FindComponent<Transform3D>();
            }

            if (this.PalmAnchor == null)
            {
                this.PalmAnchor = this.ConfigureAnchor(this.Owner, "Plam");
                this.PlamTransfom = this.PalmAnchor.FindComponent<Transform3D>();
            }

            if (this.ThumbAnchor == null)
            {
                this.ThumbAnchor = this.ConfigureAnchor(this.Owner, "Thumb");
                this.ThumbTransform = this.ThumbAnchor.FindComponent<Transform3D>();
            }

            if (this.IndexAnchor == null)
            {
                this.IndexAnchor = this.ConfigureAnchor(this.Owner, "Index");
                this.IndexTransform = this.IndexAnchor.FindComponent<Transform3D>();
            }

            if (this.MiddleAnchor == null)
            {
                this.MiddleAnchor = this.ConfigureAnchor(this.Owner, "Middle");
                this.MiddleTransform = this.MiddleAnchor.FindComponent<Transform3D>();
            }

            if (this.RingAnchor == null)
            {
                this.RingAnchor = this.ConfigureAnchor(this.Owner, "Ring");
                this.RingTransform = this.RingAnchor.FindComponent<Transform3D>();
            }

            if (this.PinkyAnchor == null)
            {
                this.PinkyAnchor = this.ConfigureAnchor(this.Owner, "Pinky");
                this.PinkyTransform = this.PinkyAnchor.FindComponent<Transform3D>();
            }
        }
        /// <summary>
        /// Initialize the LeapMotionRig entity hierarchy.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            this.LeapService = WaveServices.GetService<LeapMotionService>();

            if (this.LeapService == null)
            {
                Console.WriteLine("You need to register the LeapMotion service.");
            }

            if (!this.LeapService.IsReady)
            {
                Console.WriteLine("You need to call to start method before.");
            }

            if (this.TrackingSpace == null)
            {
                this.TrackingSpace = this.ConfigureRootAnchor("TrackingSpace");
            }

            this.TrackingSpaceTransform = this.TrackingSpace.FindComponent<Transform3D>();

            if (this.LeftHandAnchor == null)
            {
                this.LeftHandAnchor = this.ConfigureHandAnchor(this.TrackingSpace, "LeftHand");
            }

            this.LeftHandRig = this.LeftHandAnchor.FindComponent<HandRig>();
            this.LeftHandTransform = this.LeftHandAnchor.FindComponent<Transform3D>();

            if (this.RightHandAnchor == null)
            {
                this.RightHandAnchor = this.ConfigureHandAnchor(this.TrackingSpace, "RightHand");
            }

            this.RightHandRig = this.RightHandAnchor.FindComponent<HandRig>();
            this.RightHandTransform = this.RightHandAnchor.FindComponent<Transform3D>();
        }
        /// <summary>
        /// Applies the cutting planes to the model.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <param name="transform">The transform.</param>
        /// <param name="updateRequired">An update is required if set to <c>true</c>.</param>
        /// <exception cref="System.InvalidOperationException">No inverse transform.</exception>
        /// <exception cref="System.NotImplementedException"></exception>
        private void ApplyCuttingPlanesToModel(GeometryModel3D model, Transform3D transform, bool updateRequired)
        {
            if (model.Geometry == null)
            {
                return;
            }

            if (!this.IsEnabled)
            {
                updateRequired = true;
            }

            Geometry3D cutGeometry;

            if (this.cutGeometries.TryGetValue(model, out cutGeometry))
            {
                // ReSharper disable once RedundantNameQualifier
                if (object.ReferenceEquals(cutGeometry, model.Geometry))
                {
                    updateRequired = true;
                }
            }

            Geometry3D originalGeometry;

            if (!this.originalGeometries.TryGetValue(model, out originalGeometry))
            {
                originalGeometry = model.Geometry;
                updateRequired   = true;
            }

            this.newOriginalGeometries.Add(model, originalGeometry);

            if (!updateRequired)
            {
                return;
            }

            var newGeometry          = originalGeometry;
            var originalMeshGeometry = originalGeometry as MeshGeometry3D;

            if (this.IsEnabled && originalMeshGeometry != null)
            {
                var inverseTransform = transform.Inverse;
                if (inverseTransform == null)
                {
                    throw new InvalidOperationException("No inverse transform.");
                }

                switch (this.Operation)
                {
                case CuttingOperation.Intersect:

                    var intersectedGeometry = originalMeshGeometry;

                    // Calculate the intersection of all the intersections
                    foreach (var cp in this.CuttingPlanes)
                    {
                        intersectedGeometry = this.Intersect(intersectedGeometry, inverseTransform, cp, false);
                    }

                    newGeometry = intersectedGeometry;
                    break;

                case CuttingOperation.Subtract:
                    var builder = new MeshBuilder(originalMeshGeometry.Normals.Any(), originalMeshGeometry.TextureCoordinates.Any());

                    // Calculate the union of all complement intersections
                    foreach (var cp in this.CuttingPlanes)
                    {
                        var cg = this.Intersect(originalMeshGeometry, inverseTransform, cp, true);
                        builder.Append(cg);
                    }

                    newGeometry = builder.ToMesh(true);
                    break;
                }
            }

            model.Geometry = newGeometry;
            this.newCutGeometries.Add(model, originalMeshGeometry);
        }
Exemple #19
0
 public static Vector3 Transform3DToPosition(Transform3D transform)
 {
     return(new Vector3((float)transform.Value.OffsetX, (float)transform.Value.OffsetY, (float)transform.Value.OffsetZ));
 }
Exemple #20
0
        public static MyVoxelMap BuildAsteroidFromModel(bool multiThread, string sourceVolumetricFile, byte materialIndex, byte faceMaterialIndex, bool fillObject, byte?interiorMaterialIndex, ModelTraceVoxel traceType, double scale, Transform3D transform, Action <double, double> resetProgress, Action incrementProgress)
        {
            var volmeticMap = Modelling.ReadModelVolmetic(sourceVolumetricFile, scale, transform, traceType, resetProgress, incrementProgress);
            // these large values were to fix issue with large square gaps in voxlized asteroid model.
            var size = new Vector3I(volmeticMap.Length + 12, volmeticMap[0].Length + 12, volmeticMap[0][0].Length + 12);

            var action = (Action <MyVoxelBuilderArgs>) delegate(MyVoxelBuilderArgs e)
            {
                if (e.CoordinatePoint.X > 5 && e.CoordinatePoint.Y > 5 && e.CoordinatePoint.Z > 5 &&
                    (e.CoordinatePoint.X <= volmeticMap.Length + 5) && (e.CoordinatePoint.Y <= volmeticMap[0].Length + 5) && (e.CoordinatePoint.Z <= volmeticMap[0][0].Length + 5))
                {
                    var cube = volmeticMap[e.CoordinatePoint.X - 6][e.CoordinatePoint.Y - 6][e.CoordinatePoint.Z - 6];
                    if (cube == CubeType.Interior && fillObject)
                    {
                        e.Volume = 0xff;    // 100%
                        if (interiorMaterialIndex != null)
                        {
                            e.MaterialIndex = interiorMaterialIndex.Value;
                        }
                    }
                    else if (cube == CubeType.Cube)
                    {
                        e.Volume = 0xff;    // 100% "11111111"
                    }
                    else if (cube.ToString().StartsWith("InverseCorner"))
                    {
                        e.Volume = 0xD4;    // 83%  "11010100"
                    }
                    else if (cube.ToString().StartsWith("Slope"))
                    {
                        e.Volume = 0x7F;    // 50%  "01111111"
                    }
                    else if (cube.ToString().StartsWith("NormalCorner"))
                    {
                        e.Volume = 0x2B;    // 16%  "00101011"
                    }
                    else
                    {
                        e.Volume = 0x00;    // 0%   "00000000"
                    }
                }
                else
                {
                    e.Volume = 0x00;
                }
            };

            return(BuildAsteroid(multiThread, size, materialIndex, faceMaterialIndex, action));
        }
Exemple #21
0
 public static MyVoxelMap BuildAsteroidFromModel(bool multiThread, string sourceVolumetricFile, byte materialIndex, byte faceMaterialIndex, bool fillObject, byte?interiorMaterialIndex, ModelTraceVoxel traceType, double scale, Transform3D transform)
 {
     return(BuildAsteroidFromModel(multiThread, sourceVolumetricFile, materialIndex, faceMaterialIndex, fillObject, interiorMaterialIndex, traceType, scale, transform, null, null));
 }
Exemple #22
0
        private void UpdateState(MissionEnum state)
        {
            // Updates the state
            var lastState = this.currentState;

            this.currentState = state;

            if (!this.validCameras)
            {
                return;
            }

            Transform3D firstTarget    = null;
            Transform3D secondTarget   = null;
            TimeSpan    firstDuration  = TimeSpan.FromSeconds(5);
            TimeSpan    secondDuration = TimeSpan.FromSeconds(5);

            // Animates the camera towards the new state target
            switch (this.currentState)
            {
            case MissionEnum.Curiosity:

                if (lastState != MissionEnum.MarsGlobarSurveyor)
                {
                    firstTarget = this.curiosityCamera;
                }
                else
                {
                    firstTarget  = this.atmosphereCamera;
                    secondTarget = this.curiosityCamera;
                }

                break;

            case MissionEnum.Spirit:

                if (lastState != MissionEnum.MarsGlobarSurveyor)
                {
                    firstTarget = this.spiritCamera;
                }
                else
                {
                    firstTarget  = this.atmosphereCamera;
                    secondTarget = this.spiritCamera;
                }

                break;

            case MissionEnum.MarsGlobarSurveyor:
                firstTarget  = this.atmosphereCamera;
                secondTarget = this.globalSurveyorCamera;
                break;

            default:
                break;
            }

            // Animates the camera
            if (secondTarget != null)
            {
                // The camera navigates through 2 different points
                this.Owner.Scene.CreateParallelGameActions(
                    new MoveTo3DGameAction(this.Owner, firstTarget.Position, firstDuration, EaseFunction.QuinticInOutEase),
                    new RotateTo3DGameAction(this.Owner, firstTarget.Rotation, firstDuration, EaseFunction.CubicInOutEase))
                .WaitAll().ContinueWith(
                    this.Owner.Scene.CreateParallelGameActions(
                        new MoveTo3DGameAction(this.Owner, secondTarget.Position, secondDuration, EaseFunction.QuinticInOutEase),
                        new RotateTo3DGameAction(this.Owner, secondTarget.Rotation, secondDuration, EaseFunction.SineInOutEase)
                        ).WaitAll()
                    )
                .ContinueWithAction(() =>
                {
                    // We mark the camera animation finished
                    StateManager.Instance.StateInitialized(state);
                }).Run();
            }
            else
            {
                this.Owner.Scene.CreateParallelGameActions(
                    new MoveTo3DGameAction(this.Owner, firstTarget.Position, firstDuration, EaseFunction.QuinticInOutEase),
                    new RotateTo3DGameAction(this.Owner, firstTarget.Rotation, firstDuration, EaseFunction.CubicInOutEase))
                .WaitAll()
                .ContinueWithAction(() =>
                {
                    // We mark the camera animation finished
                    StateManager.Instance.StateInitialized(state);
                }).Run();
            }
        }
 public override void FinalizeTransformations()
 {
     Transform3D.Recalculate();
     GL.UniformMatrix4(UniformLocations[(int)UniformParts.WorldViewProjection], 1, false, ref Transform3D.WorldViewProjection.Row0.X);
 }
 public PathMoveTile(string id, ActorType actorType, StatusType statusType, Transform3D transform,
                     OurEffectParameters effectParameters, Model model, bool isBlocking, ETileType tileType) : base(id,
                                                                                                                    actorType, statusType, transform, effectParameters, model, isBlocking, tileType)
 {
     Path = new List <Vector3>();
 }
Exemple #25
0
 /// <summary>
 /// Resolves the dependencies needed for this instance to work.
 /// </summary>
 protected override void ResolveDependencies()
 {
     this.modelFactoryService = ModelFactoryService.Instance;
     this.playScene = this.Scene as PlayScene;
     this.playerTransform = this.playScene.Player.FindComponent<Transform3D>();
     this.playerCollider = this.playScene.Player.FindComponent<BoxCollider>();
     this.playerBoundingBox = new BoundingBox(this.playerTransform.Position - this.playerCollider.Size / 2, this.playerTransform.Position + this.playerCollider.Size / 2);
     this.tempBoundingBox = new BoundingBox();
 }
        /// <summary>
        /// Initialize stereoscopic camera controller
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            this.headTrack = WaveServices.GetService<HeadTrackSensor>();

            this.leftLookAtEntity = this.Owner.FindChild("leftLookAt");
            this.rightLookAtEntity = this.Owner.FindChild("rightLookAt");
            this.leftEyeEntity = this.Owner.FindChild("leftEye");
            this.rightEyeEntity = this.Owner.FindChild("rightEye");

            this.leftEye = this.leftEyeEntity.FindComponent<Camera3D>();
            this.rightEye = this.rightEyeEntity.FindComponent<Camera3D>();

            this.leftLookAtTransform = this.leftLookAtEntity.FindComponent<Transform3D>();
            this.rightLookAtTransform = this.rightLookAtEntity.FindComponent<Transform3D>();
            this.leftEyeTransform = this.leftEyeEntity.FindComponent<Transform3D>();
            this.rightEyeTransform = this.rightEyeEntity.FindComponent<Transform3D>();

            // Left eye
            this.leftEye.Viewport = new Viewport(0, 0, 0.5f, 1);
            this.leftEye.FieldOfView = this.FieldOfView;
            this.leftEye.NearPlane = this.NearPlane;
            this.leftEye.FarPlane = this.FarPlane;

            // Right eye
            this.rightEye.Viewport = new Viewport(0.5f, 0, 0.5f, 1);
            this.rightEye.FieldOfView = this.FieldOfView;
            this.rightEye.NearPlane = this.NearPlane;
            this.rightEye.FarPlane = this.FarPlane;

            this.isInitialized = true;
            this.RefreshCameraCalibration();
        }
 /// <summary>
 /// Gets the evade entity transform.
 /// </summary>        
 private void GetEvadeEntityTransform()
 {
     if (this.evadeFromEntity != null)
     {
         this.evadeFromTransform = this.evadeFromEntity.FindComponent<Transform3D>();
         if (this.evadeFromTransform == null)
         {
             throw new Exception(this.evadeFromEntity.Name + " entity need a Transform2D component");
         }
     }
 }
 public CylPosition Transform(Transform3D transf)
 => new CylPosition(transf.transform(XYZ), HalfAxis.Transform(Direction, transf));
 /// <summary>
 /// Collideses the specified block transform.
 /// </summary>
 /// <param name="blockTransform">The block transform.</param>
 /// <returns></returns>
 public bool Collides(Transform3D blockTransform)
 {
     bool res =(this.playerTransform.Position.Y - ModelFactoryService.Instance.Scale.Y / 2 < blockTransform.Position.Y);
     return res;
 }
Exemple #30
0
        private void CreateCube3D()
        {
            Entity cube = new Entity("Cube")
                 .AddComponent(new Transform3D())
                 .AddComponent(Model.CreateCube())
                 .AddComponent(new MaterialsMap(new BasicMaterial("Content/crate.jpg")))
                 .AddComponent(new ModelRenderer());


            this.cubeTransform = cube.FindComponent<Transform3D>();
            this.cubeMaterial = (BasicMaterial)cube.FindComponent<MaterialsMap>().DefaultMaterial;

            EntityManager.Add(cube);
        }
        /// <summary>
        /// Resolves the dependencies needed for this instance to work.
        /// </summary>
        /// <exception cref="System.InvalidOperationException">If the transform was not set.</exception>
        protected override void ResolveDependencies()
        {
            base.ResolveDependencies();

            if ((this.targetTransform = this.entity.FindComponent<Transform3D>()) == null)
            {
                throw new InvalidOperationException("Transform not found.");
            }
        }
Exemple #32
0
        public override int Execute(params string[] parameters)
        {
            string documentspath = System.Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
            string fileoutpath   = documentspath + "\\" + "CoordinationModel.nwd";

            Document doc         = Autodesk.Navisworks.Api.Application.ActiveDocument;
            double   scalefactor = UnitConversion.ScaleFactor(Units.Meters, doc.Units);

            DocumentSelectionSets myselectionsets = doc.SelectionSets;
            ModelItemCollection   clipbox         = new ModelItemCollection();

            foreach (SavedItem childItem in ((GroupItem)myselectionsets.RootItem).Children)
            {
                if (childItem.DisplayName == "hidden")
                {
                    SelectionSet oSet = childItem as SelectionSet;
                    doc.Models.SetHidden(oSet.ExplicitModelItems, false);
                    myselectionsets.Remove((GroupItem)myselectionsets.RootItem, oSet);
                }
                else if (childItem.DisplayName == "clipbox")
                {
                    SelectionSet oSet = childItem as SelectionSet;
                    clipbox.AddRange(oSet.ExplicitModelItems);
                }
            }

            Point3D selbbmin, selbbmax;

            if (parameters.Length == 0)
            {
                ModelItemCollection mysel = doc.CurrentSelection.SelectedItems;
                selbbmin = mysel.BoundingBox().Min;
                selbbmax = mysel.BoundingBox().Max;
            }
            else
            {
                fileoutpath = @parameters[0];
                selbbmin    = new Point3D(Convert.ToDouble(parameters[1].Replace("neg", "-")) * scalefactor, Convert.ToDouble(parameters[2].Replace("neg", "-")) * scalefactor, Convert.ToDouble(parameters[3].Replace("neg", "-")) * scalefactor);
                selbbmax    = new Point3D(Convert.ToDouble(parameters[4].Replace("neg", "-")) * scalefactor, Convert.ToDouble(parameters[5].Replace("neg", "-")) * scalefactor, Convert.ToDouble(parameters[6].Replace("neg", "-")) * scalefactor);
            }

            if (selbbmin.IsOrigin && selbbmax.IsOrigin)
            {
                doc.SaveFile(fileoutpath);
                return(0);
            }

            string        logfile = documentspath + "\\" + Path.GetFileName(fileoutpath) + ".txt";
            List <string> log     = new List <string>();
            //log.Add("scalefactor###" + scalefactor);
            //selbbmin = new Point3D(-7.000, 14.000, 17.000);
            //selbbmax = new Point3D(-5.000, 16.000, 19.000);

            Point3D  mid       = selbbmin.ToVector3D().Add(selbbmax).ToVector3D().Divide(2).ToPoint3D();
            Vector3D diff      = new Point3D(1, 1, 1).ToVector3D();
            double   deltaval  = 0.01;
            Vector3D delta     = new Point3D(deltaval, deltaval, deltaval).ToVector3D();
            double   clearance = 0;

            while (diff.X > 0 && diff.Y > 0 && diff.Z > 0)
            {
                clearance += deltaval;
                selbbmax   = selbbmax.Subtract(delta);
                selbbmin   = selbbmin.Add(delta);
                diff       = selbbmax.ToVector3D().Subtract(selbbmin.ToVector3D());
            }

            Transform3D           EndTransform         = new Transform3D();
            Transform3DComponents Transform3DComponent = EndTransform.Factor();

            Transform3DComponent.Scale = selbbmax.ToVector3D().Subtract(selbbmin.ToVector3D());
            Rotation3D ScaleOrientation = new Rotation3D(new UnitVector3D(0, 0, 1), 0);

            Transform3DComponent.Rotation    = ScaleOrientation;
            Transform3DComponent.Translation = mid.ToVector3D();
            EndTransform = Transform3DComponent.Combine();

            doc.Models.OverridePermanentTransform(clipbox, EndTransform, true);

            try
            {
                DocumentClash      documentClash  = doc.GetClash();
                DocumentClashTests myClashTests   = documentClash.TestsData;
                ClashTest          myClashTestorg = myClashTests.Tests[0] as ClashTest;
                ClashTest          myClashTest    = myClashTestorg.CreateCopy() as ClashTest;
                myClashTest.TestType  = ClashTestType.Clearance;
                myClashTest.Tolerance = Math.Pow((3 * Math.Pow(clearance, 2)), 0.5);
                myClashTest.Status    = ClashTestStatus.New;
                myClashTests.TestsEditTestFromCopy(myClashTestorg, myClashTest);
                myClashTests.TestsRunTest(myClashTestorg);
                myClashTest = myClashTests.Tests[0] as ClashTest;
                ModelItemCollection myClashingElements = new ModelItemCollection();
                for (var i = 0; i < myClashTest.Children.Count; i++)
                {
                    ClashResult myClash = myClashTest.Children[i] as ClashResult;
                    myClashingElements.AddRange(myClash.Selection2);
                }

                myClashingElements.Invert(doc);
                doc.Models.SetHidden(myClashingElements, true);

                SelectionSet allhidden = new SelectionSet(myClashingElements);
                allhidden.DisplayName = "hidden";
                myselectionsets.AddCopy(allhidden);

                myClashTests.TestsClearResults(myClashTest);
                //clipbox.AddRange((doc.SelectionSets.RootItem.Children[0] as SelectionSet).GetSelectedItems());
                doc.Models.ResetPermanentTransform(clipbox);
                doc.SaveFile(fileoutpath);
            }
            catch (Exception e) { log.Add(e.Message + "###" + e.StackTrace); }
            finally { File.WriteAllText(logfile, string.Join("\r\n", log)); }

            return(0);
        }
        /// <summary>
        ///     Our Slave objects that we will later clone are all made here. Like "templates" of objects. (Like Prefabs in Unity)
        /// </summary>
        private void InitStaticModels()
        {
            /*
             * Some initialization
             */

            Color coffeeColor = new Color(111 / 255.0f, 78 / 255.0f, 55 / 255.0f, 0.95f);

            CoffeeEffectParameters coffeeEffect = new CoffeeEffectParameters(main.Effects["Coffee"],
                                                                             main.Textures["CoffeeUV"], main.Textures["CoffeeFlow"], coffeeColor);
            Transform3D            transform3D            = new Transform3D(Vector3.Zero, -Vector3.Forward, Vector3.Up);
            NormalEffectParameters normalEffectParameters = new NormalEffectParameters(main.Effects["Normal"],
                                                                                       main.Textures["Chocolate"], main.Textures["big-normalmap"],
                                                                                       main.Textures["big-displacement"], Color.White, 1, light);

            /*
             * Here we make the static Tiles.
             */

            #region StaticTiles

            //Create the Basic Tile

            Tile chocolateTile = new Tile("ChocolateTile", ActorType.Primitive, StatusType.Drawn | StatusType.Update,
                                          transform3D, normalEffectParameters, main.Models["Cube"],
                                          true, ETileType.Static);

            //Create the Plate Stacks
            BasicEffectParameters effectParameters =
                new BasicEffectParameters(main.ModelEffect, main.Textures["Ceramic"], Color.White, 1);
            Tile plateStackTile = new Tile("plateStackTile", ActorType.Primitive, StatusType.Drawn | StatusType.Update,
                                           transform3D, effectParameters, main.Models["PlateStack"],
                                           true, ETileType.Static);

            //Create the Fork Model
            effectParameters = new BasicEffectParameters(main.ModelEffect, main.Textures["Finish"], Color.White, 1);
            OurModelObject forkModelObject =
                new OurModelObject("fork", ActorType.Decorator, StatusType.Drawn | StatusType.Update, transform3D,
                                   effectParameters, main.Models["Fork"]);
            //forkModelObject.ControllerList.Add(new RandomRotatorController("rotator", ControllerType.Curve));

            //Create the Knife Model
            effectParameters = new BasicEffectParameters(main.ModelEffect, main.Textures["Knife"], Color.White, 1);
            OurModelObject knifeModelObject =
                new OurModelObject("knife", ActorType.Decorator, StatusType.Drawn | StatusType.Update, transform3D,
                                   effectParameters, main.Models["Knife"]);
            //knifeModelObject.ControllerList.Add(new RandomRotatorController("rotator", ControllerType.Curve));

            //Create the Single Plate Model
            effectParameters = new BasicEffectParameters(main.ModelEffect, main.Textures["Finish"], Color.White, 1);
            OurModelObject singlePlateModelObject = new OurModelObject("singlePlate", ActorType.Decorator,
                                                                       StatusType.Drawn | StatusType.Update, transform3D, effectParameters,
                                                                       main.Models["SinglePlate"]);
            //singlePlateModelObject.ControllerList.Add(new RandomRotatorController("rotator", ControllerType.Curve));

            #endregion StaticTiles

            /*
             * Here we create the Tiles that interact with you on collision.
             */

            #region InteractableTiles

            //Create Button Tile
            effectParameters = new BasicEffectParameters(main.ModelEffect, main.Textures["Button"], Color.White, 1);
            ActivatableTile activatable = new ActivatableTile("Button", ActorType.Primitive,
                                                              StatusType.Drawn | StatusType.Update, transform3D, effectParameters,
                                                              main.Models["Button"], false, ETileType.Button);
            activatable.ControllerList.Add(new ColliderComponent("ButtonCC", ControllerType.Collider,
                                                                 OnActivatableCollisionEnter));

            //Create the Puddle (We call them spikes because they kill the player on collision)
            coffeeEffect = (CoffeeEffectParameters)coffeeEffect.Clone();
            coffeeEffect.UvTilesTexture = main.Textures["DropUV"];
            coffeeEffect.CoffeeColor    = new Color(new Color(239, 228, 176), 255);
            Tile spike = new Tile("Spike", ActorType.Primitive, StatusType.Drawn | StatusType.Update, transform3D,
                                  coffeeEffect, main.Models["Puddle"], false, ETileType.Spike);
            spike.ControllerList.Add(new ColliderComponent("CC", ControllerType.Collider, OnHostileCollision));

            //Create the Mug Pickups
            effectParameters = new BasicEffectParameters(main.ModelEffect, main.Textures["Mug"], Color.White, 1);
            Tile pickup = new Tile("Mug", ActorType.Primitive, StatusType.Drawn | StatusType.Update, transform3D,
                                   effectParameters, main.Models["Mug"], false, ETileType.Star);
            pickup.ControllerList.Add(new PlayerDeathComponent("PDC", ControllerType.Event));
            pickup.ControllerList.Add(new ColliderComponent("CC", ControllerType.Collider, OnCollectibleCollision));

            //Create the Goal Tile
            effectParameters = new BasicEffectParameters(main.ModelEffect, main.Textures["sugarbox"], Color.White, 1);
            Tile goal = new Tile("Goal", ActorType.Primitive, StatusType.Drawn | StatusType.Update, transform3D,
                                 effectParameters, main.Models["SugarBox"], false, ETileType.Win);
            goal.ControllerList.Add(new ColliderComponent("CCG", ControllerType.Collider, OnGoalCollided));

            //Create the Checkpoint Tile
            effectParameters =
                new BasicEffectParameters(main.ModelEffect, main.Textures["WhiteSquare"], Color.White, 1);
            Tile checkpoint = new Tile("Checkpoint", ActorType.Primitive, StatusType.Drawn | StatusType.Update,
                                       transform3D, effectParameters, main.Models["Smarties"], false, ETileType.Checkpoint);
            checkpoint.ControllerList.Add(new ColliderComponent("CC", ControllerType.Collider, OnCheckPointCollision));

            #endregion

            /*
             * Here we create the Tiles that can Move
             */

            #region MovableTiles

            //Create the Attachable Tiles
            effectParameters = new BasicEffectParameters(main.ModelEffect, main.Textures["SugarB"], Color.White, 1);
            AttachableTile attachableTile = new AttachableTile("AttachableTile", ActorType.Primitive,
                                                               StatusType.Drawn | StatusType.Update, transform3D, effectParameters,
                                                               main.Models["Cube"], ETileType.Attachable);
            attachableTile.ControllerList.Add(new TileMovementComponent("AttachableTileMC", ControllerType.Movement,
                                                                        300));
            attachableTile.ControllerList.Add(new PlayerDeathComponent("PDC", ControllerType.Event));

            //Create the Player Tile
            effectParameters = new BasicEffectParameters(main.ModelEffect, main.Textures["SugarW"], Color.White, 1);
            PlayerTile playerTile = new PlayerTile("Player", ActorType.Player, StatusType.Drawn, transform3D,
                                                   effectParameters, main.Models["Cube"], ETileType.Player);
            playerTile.ControllerList.Add(new PlayerController("PlayerPC", ControllerType.Player, main.KeyboardManager,
                                                               main.CameraManager));
            TileMovementComponent tileMovementComponent = new TileMovementComponent("PTMC", ControllerType.Movement,
                                                                                    300);
            playerTile.ControllerList.Add(tileMovementComponent);
            playerTile.ControllerList.Add(new PlayerMovementComponent("PlayerMC", ControllerType.Movement));
            playerTile.ControllerList.Add(new PlayerDeathComponent("PDC", ControllerType.Event));

            //Create the Enemy Tiles
            coffeeColor  = new Color(coffeeColor, 255);
            coffeeEffect = new CoffeeEffectParameters(main.Effects["Coffee"], main.Textures["DropUV"],
                                                      main.Textures["CoffeeFlow"], coffeeColor);
            PathMoveTile enemy = new PathMoveTile("Enemy", ActorType.NonPlayer, StatusType.Drawn | StatusType.Update,
                                                  transform3D, coffeeEffect, main.Models["Drop"], false, ETileType.Enemy);
            enemy.ControllerList.Add(new EnemyMovementComponent("emc", ControllerType.Movement, ActivationType.AlwaysOn,
                                                                0.5f, Smoother.SmoothingMethod.Smooth));
            enemy.ControllerList.Add(new ColliderComponent("CC", ControllerType.Collider, OnHostileCollision));

            //Create the Moving Platform Tiles
            effectParameters = new BasicEffectParameters(main.ModelEffect, main.Textures["Biscuit"], Color.White, 1);
            MovingPlatformTile movingPlatform = new MovingPlatformTile("MovingPlatform", ActorType.Platform,
                                                                       StatusType.Drawn | StatusType.Update, transform3D, effectParameters,
                                                                       main.Models["Biscuit"], true, ETileType.MovingPlatform);
            movingPlatform.ControllerList.Add(new PathMovementComponent("platformpmc", ControllerType.Movement,
                                                                        ActivationType.Activated, 0.5f, Smoother.SmoothingMethod.Decelerate));

            //Create the Doors Tiles
            effectParameters = new BasicEffectParameters(main.ModelEffect, main.Textures["Biscuit"], Color.White, 1);
            PathMoveTile doorTile = new PathMoveTile("Door Tile", ActorType.Platform,
                                                     StatusType.Drawn | StatusType.Update, transform3D, effectParameters,
                                                     main.Models["Cube"], true, ETileType.Door);
            doorTile.ControllerList.Add(new DoorMovementComponent("doorPMC", ControllerType.Movement,
                                                                  ActivationType.Activated, 0.5f, Smoother.SmoothingMethod.Accelerate));

            #endregion MovableTiles

            //Now we add them all to our dictionary to later clone.
            drawnActors = new Dictionary <string, OurDrawnActor3D>
            {
                { "StaticTile", chocolateTile },
                { "PlateStackTile", plateStackTile },
                { "AttachableBlock", attachableTile },
                { "PlayerBlock", playerTile },
                { "GoalTile", goal },
                { "EnemyTile", enemy },
                { "ButtonTile", activatable },
                { "MovingPlatformTile", movingPlatform },
                { "DoorTile", doorTile },
                { "SpikeTile", spike },
                { "StarPickupTile", pickup },
                { "CheckpointTile", checkpoint },
                { "Knife", knifeModelObject },
                { "Fork", forkModelObject },
                { "SinglePlate", singlePlateModelObject },
                { "Coffee", coffee }
            };
        }
        public static Point3D ToPoint3D(this Transform3D transform)
        {
            Matrix3D matrix = transform.Value;

            return(new Point3D(matrix.OffsetX, matrix.OffsetY, matrix.OffsetZ));
        }
Exemple #35
0
        private Point TransformPoint(Transform3D transform, Vector3D point3d)
        {
            Vector3D vt = transform.transform(point3d);

            return(new Point((int)vt.X, (int)vt.Y));
        }
Exemple #36
0
 /// <summary>
 /// Exports the light.
 /// </summary>
 /// <param name="writer">The writer.</param>
 /// <param name="light">The light.</param>
 /// <param name="inheritedTransform">The inherited transform.</param>
 protected virtual void ExportLight(T writer, Light light, Transform3D inheritedTransform)
 {
 }
Exemple #37
0
        public Transform3D GetCurrentTransformation()
        {
            if (null == _currentTransf)
            {
                // get transformations
                Transform3D world2eye        = GetWorldToEyeTransformation();
                Transform3D orthographicProj = GetOrthographicProjection(
                    new Vector3D(_viewport[0], _viewport[1], -10000.0)
                    , new Vector3D(_viewport[2], _viewport[3], 10000.0));

                // build automatic viewport
                if (_autoViewport)
                {
                    Vector3D vecMin = new Vector3D(double.MaxValue, double.MaxValue, double.MaxValue);
                    Vector3D vecMax = new Vector3D(double.MinValue, double.MinValue, double.MinValue);

                    // boxes
                    foreach (Box box in _boxes)
                    {
                        foreach (Vector3D pt in box.Points)
                        {
                            Vector3D ptT = world2eye.transform(pt);
                            vecMin.X = Math.Min(vecMin.X, ptT.X);
                            vecMin.Y = Math.Min(vecMin.Y, ptT.Y);
                            vecMin.Z = Math.Min(vecMin.Z, ptT.Z);
                            vecMax.X = Math.Max(vecMax.X, ptT.X);
                            vecMax.Y = Math.Max(vecMax.Y, ptT.Y);
                            vecMax.Z = Math.Max(vecMax.Z, ptT.Z);
                        }
                    }
                    // cylinders
                    foreach (Cylinder cyl in _cylinders)
                    {
                        foreach (Vector3D pt in cyl.BottomPoints)
                        {
                            Vector3D ptT = world2eye.transform(pt);
                            vecMin.X = Math.Min(vecMin.X, ptT.X);
                            vecMin.Y = Math.Min(vecMin.Y, ptT.Y);
                            vecMin.Z = Math.Min(vecMin.Z, ptT.Z);
                            vecMax.X = Math.Max(vecMax.X, ptT.X);
                            vecMax.Y = Math.Max(vecMax.Y, ptT.Y);
                            vecMax.Z = Math.Max(vecMax.Z, ptT.Z);
                        }
                        foreach (Vector3D pt in cyl.TopPoints)
                        {
                            Vector3D ptT = world2eye.transform(pt);
                            vecMin.X = Math.Min(vecMin.X, ptT.X);
                            vecMin.Y = Math.Min(vecMin.Y, ptT.Y);
                            vecMin.Z = Math.Min(vecMin.Z, ptT.Z);
                            vecMax.X = Math.Max(vecMax.X, ptT.X);
                            vecMax.Y = Math.Max(vecMax.Y, ptT.Y);
                            vecMax.Z = Math.Max(vecMax.Z, ptT.Z);
                        }
                    }
                    // faces
                    foreach (Face face in _faces)
                    {
                        foreach (Vector3D pt in face.Points)
                        {
                            Vector3D ptT = world2eye.transform(pt);
                            vecMin.X = Math.Min(vecMin.X, ptT.X);
                            vecMin.Y = Math.Min(vecMin.Y, ptT.Y);
                            vecMin.Z = Math.Min(vecMin.Z, ptT.Z);
                            vecMax.X = Math.Max(vecMax.X, ptT.X);
                            vecMax.Y = Math.Max(vecMax.Y, ptT.Y);
                            vecMax.Z = Math.Max(vecMax.Z, ptT.Z);
                        }
                    }

                    // segments
                    foreach (Segment seg in _segments)
                    {
                        foreach (Vector3D pt in seg.Points)
                        {
                            Vector3D ptT = world2eye.transform(pt);
                            vecMin.X = Math.Min(vecMin.X, ptT.X);
                            vecMin.Y = Math.Min(vecMin.Y, ptT.Y);
                            vecMin.Z = Math.Min(vecMin.Z, ptT.Z);
                            vecMax.X = Math.Max(vecMax.X, ptT.X);
                            vecMax.Y = Math.Max(vecMax.Y, ptT.Y);
                            vecMax.Z = Math.Max(vecMax.Z, ptT.Z);
                        }
                    }

                    // cube dimensions
                    foreach (DimensionCube dimCube in _dimensions)
                    {
                        foreach (Vector3D pt in dimCube.DrawingPoints(this))
                        {
                            Vector3D ptT = world2eye.transform(pt);
                            vecMin.X = Math.Min(vecMin.X, ptT.X);
                            vecMin.Y = Math.Min(vecMin.Y, ptT.Y);
                            vecMin.Z = Math.Min(vecMin.Z, ptT.Z);
                            vecMax.X = Math.Max(vecMax.X, ptT.X);
                            vecMax.Y = Math.Max(vecMax.Y, ptT.Y);
                            vecMax.Z = Math.Max(vecMax.Z, ptT.Z);
                        }
                    }

                    Vector3D vecMin1 = vecMin, vecMax1 = vecMax;
                    // adjust width/height
                    if ((vecMax.Y - vecMin.Y) / Size.Height > (vecMax.X - vecMin.X) / Size.Width)
                    {
                        double actualWidth = (vecMax.Y - vecMin.Y) * Size.Width / Size.Height;
                        vecMin1.X = 0.5 * (vecMin.X + vecMax.X) - 0.5 * actualWidth;
                        vecMax1.X = 0.5 * (vecMin.X + vecMax.X) + 0.5 * actualWidth;
                    }
                    else
                    {
                        double actualHeight = (vecMax.X - vecMin.X) * Size.Height / Size.Width;
                        vecMin1.Y = 0.5 * (vecMin.Y + vecMax.Y) - 0.5 * actualHeight;
                        vecMax1.Y = 0.5 * (vecMin.Y + vecMax.Y) + 0.5 * actualHeight;
                    }
                    // set margins
                    double width = vecMax1.X - vecMin1.X;
                    vecMin1.X -= _margin * width;
                    vecMax1.X += _margin * width;
                    double height = vecMax1.Y - vecMin1.Y;
                    vecMin1.Y -= _margin * height;
                    vecMax1.Y += _margin * height;

                    orthographicProj = GetOrthographicProjection(vecMin1, vecMax1);
                }
                _currentTransf = orthographicProj * world2eye;
            }
            return(_currentTransf);
        }
Exemple #38
0
 /// <summary>
 /// Exports the model.
 /// </summary>
 /// <param name="writer">The writer.</param>
 /// <param name="model">The model.</param>
 /// <param name="inheritedTransform">The inherited transform.</param>
 protected virtual void ExportModel(T writer, GeometryModel3D model, Transform3D inheritedTransform)
 {
 }
Exemple #39
0
 public Tile(string id, ActorType actorType, StatusType statusType, Transform3D transform,
             OurEffectParameters effectParameters, Model model, bool isBlocking, ETileType tileType) : base(id,
                                                                                                            actorType, statusType, transform, effectParameters, model, isBlocking)
 {
     TileType = tileType;
 }
Exemple #40
0
 /// <summary>
 /// Constructor FaceComparison
 /// </summary>
 /// <param name="transform">Transform</param>
 public FaceComparison(Transform3D transform)
 {
     _transform = transform;
 }
        public static Vector4 ToVector4(this Transform3D trafo)
        {
            var matrix = trafo.Value;

            return(new Vector4((float)matrix.OffsetX, (float)matrix.OffsetY, (float)matrix.OffsetZ, (float)matrix.M44));
        }
Exemple #42
0
        private void RunBoxologic(int variant, HSolution hSol, Vector3D dimContainer, Vector3D offset, List <ContentItem> contentItems)
        {
            // ContentItem -> BoxItem
            List <BoxItem> boxItems = new List <BoxItem>();

            foreach (ContentItem ci in contentItems)
            {
                if (ci.Pack is BoxProperties b)
                {
                    boxItems.Add(
                        new BoxItem()
                    {
                        ID     = BoxToID(b),
                        Boxx   = (decimal)b.Length,
                        Boxy   = (decimal)b.Width,
                        Boxz   = (decimal)b.Height,
                        AllowX = ci.AllowOrientX,
                        AllowY = ci.AllowOrientY,
                        AllowZ = ci.AllowOrientZ,
                        N      = (int)ci.Number,
                        Order  = ci.PriorityLevel
                    }
                        );
                }
            }

            // solve
            var bl = new Boxlogic()
            {
                OutputFilePath = string.Empty
            };
            var solArray = new SolutionArray();

            bl.Run(variant, boxItems.ToArray(), (decimal)dimContainer.X, (decimal)dimContainer.Y, (decimal)dimContainer.Z, ref solArray);
            var solution = solArray.Solutions[0];

            HSolItem    hSolItem = hSol.CreateSolItem();
            Transform3D transform;

            switch (solution.Variant)
            {
            case 1: transform = Transform3D.Translation(new Vector3D(0.0, dimContainer.Y, 0.0)) * Transform3D.RotationX(90.0); break;

            case 2: transform = Transform3D.Translation(new Vector3D(dimContainer.X, 0.0, 0.0)) * Transform3D.RotationZ(90.0); break;

            case 3: transform = Transform3D.Translation(new Vector3D(dimContainer.X, 0.0, 0.0)) * Transform3D.RotationZ(90.0); break;

            case 4: transform = Transform3D.Translation(new Vector3D(dimContainer.X, 0.0, 0.0)) * Transform3D.RotationY(-90.0); break;

            case 5: transform = Transform3D.Translation(new Vector3D(0.0, dimContainer.Y, 0.0)) * Transform3D.RotationX(90.0); break;

            default: transform = Transform3D.Identity; break;
            }

            foreach (var item in solution.ItemsPacked)
            {
                BoxInfoToSolItem(contentItems, offset, item, transform, out int index, out BoxPosition pos);
                hSolItem.InsertContainedElt(index, pos.Adjusted(new Vector3D((double)item.DimX, (double)item.DimY, (double)item.DimZ)));
            }

            // remaining
            List <ContentItem> remainingBoxItems = new List <ContentItem>();

            foreach (var solItem in solution.ItemsUnpacked)
            {
                var         ci          = contentItems[(int)solItem.Id];
                ContentItem contentItem = new ContentItem(ci.Pack, 1)
                {
                    AllowOrientX = ci.AllowOrientX,
                    AllowOrientY = ci.AllowOrientY,
                    AllowOrientZ = ci.AllowOrientZ
                };
                remainingBoxItems.Add(contentItem);
            }
            if (remainingBoxItems.Count > 0)
            {
                RunBoxologic(variant, hSol, dimContainer, offset, remainingBoxItems);
            }
        }
 /// <summary>
 /// Updates the target
 /// </summary>
 private void UpdateTarget()
 {
     if (this.lookAtEntity)
     {
         var target = this.EntityManager.Find(this.targetEntity);
         if (target != null)
         {
             this.targetTransform = target.FindComponent<Transform3D>();
         }
         else
         {
             this.targetTransform = null;
         }
     }
     else
     {
         this.targetTransform = null;
     }
 }
Exemple #44
0
        private bool BoxInfoToSolItem(List <ContentItem> contentItems, Vector3D offset, SolItem solItem, Transform3D transform, out int index, out BoxPosition pos)
        {
            index = 0;
            pos   = BoxPosition.Zero;

            BoxProperties b = IDToBox(solItem.Id);

            if (null != b)
            {
                try
                {
                    index = (int)solItem.Id;
                    pos   = BoxPosition.FromPositionDimension(
                        new Vector3D((double)solItem.X, (double)solItem.Y, (double)solItem.Z),
                        new Vector3D((double)solItem.BX, (double)solItem.BY, (double)solItem.BZ),
                        new Vector3D((double)solItem.DimX, (double)solItem.DimY, (double)solItem.DimZ)
                        );
                    pos = pos.Transform(Transform3D.Translation(offset) * transform);

                    return(true);
                }
                catch (Exception ex)
                {
                    _log.Error(ex.Message);
                }
            }
            return(false);
        }
        public static global::SharpDX.Vector3 ToVector3(this Transform3D trafo)
        {
            var matrix = trafo.Value;

            return(new global::SharpDX.Vector3((float)matrix.OffsetX, (float)matrix.OffsetY, (float)matrix.OffsetZ));
        }
        /// <summary>
        /// Gets the target transform.
        /// </summary>
        private void GetTargetTransform()
        {
            if (this.targetEntity != null)
            {
                this.targetTransform = this.targetEntity.FindComponent<Transform3D>();

                if (this.targetTransform == null)
                {
                    throw new Exception(this.targetEntity.Name + " entity need a Transform3D component");
                }
            }
        }
        /// <summary>
        /// Creates a new explosion decorator
        /// </summary>
        /// <param name="name">The entity name</param>
        /// <param name="frame">The explosion frame </param>
        public ExplosionDecorator(string name, int frame)
        {
            this.particleSystems = new List<ParticleSystem3D>();

            this.entity = new Entity(name)
            .AddComponent(this.cachedTransform = new Transform3D())
            ;

            ParticleSystem3D particleSystem;
            var emitter1 = new Entity()
            .AddComponent(new Transform3D())
            .AddComponent(emitter = new Sound3DEmitter())
            .AddComponent(particleSystem = new ParticleSystem3D()
            {
                NumParticles = 25,
                EmitRate = 300000,
                MinLife = TimeSpan.FromSeconds(1),
                MaxLife = TimeSpan.FromSeconds(1.5),
                LocalVelocity = Vector3.Zero,
                RandomVelocity = Vector3.One * 0.7f,
                MinSize = 20,
                MaxSize = 25,
                MaxRotateSpeed = 0.025f,
                MinRotateSpeed = -0.055f,
                InitialAngle = MathHelper.TwoPi,
                EndDeltaScale = 2f,
                EmitterSize = new Vector2(4),
                EmitterShape = ParticleSystem3D.Shape.FillRectangle,
                InterpolationColors = new List<Color>() { Color.White, Color.White, Color.Black },
                LinearColorEnabled = true,
                Gravity = Vector3.Zero,
                Emit = false
            })
            .AddComponent(new ParticleSystemRenderer3D())
            .AddComponent(new MaterialsMap(new BasicMaterial("Content/Textures/Explosion/Explosion_1.png", DefaultLayers.Additive) { VertexColorEnabled = true }))
            ;

            this.particleSystems.Add(particleSystem);

            var emitter2 = new Entity()
            .AddComponent(new Transform3D())
            .AddComponent(particleSystem = new ParticleSystem3D()
            {
                NumParticles = 4,
                EmitRate = 300000,
                MinLife = TimeSpan.FromSeconds(0.2),
                MaxLife = TimeSpan.FromSeconds(0.3),
                LocalVelocity = Vector3.Zero,
                RandomVelocity = Vector3.One * 0.01f,
                MinSize = 30,
                MaxSize = 40,
                InitialAngle = MathHelper.TwoPi,
                MaxRotateSpeed = 0.1f,
                MinRotateSpeed = -0.1f,
                EndDeltaScale = 0.3f,
                EmitterSize = new Vector2(1),
                EmitterShape = ParticleSystem3D.Shape.FillRectangle,
                InterpolationColors = new List<Color>() { Color.White, Color.Black },
                LinearColorEnabled = true,
                Gravity = Vector3.Zero,
                Emit = false
            })
            .AddComponent(new ParticleSystemRenderer3D())
            .AddComponent(new MaterialsMap(new BasicMaterial("Content/Textures/Explosion/Explosion_3.png", DefaultLayers.Additive) { VertexColorEnabled = true }))
            ;

            this.particleSystems.Add(particleSystem);

            var emitter3 = new Entity()
            .AddComponent(new Transform3D())
            .AddComponent(particleSystem = new ParticleSystem3D()
            {
                NumParticles = 60,
                EmitRate = 300000,
                MinLife = TimeSpan.FromSeconds(2),
                MaxLife = TimeSpan.FromSeconds(2.4),
                LocalVelocity = Vector3.Zero,
                RandomVelocity = Vector3.One * 1f,
                MinSize = 0.7f,
                MaxSize = 0.7f,
                InitialAngle = MathHelper.TwoPi,
                Gravity = Vector3.Zero,
                EndDeltaScale = 1,
                EmitterSize = new Vector2(1),
                EmitterShape = ParticleSystem3D.Shape.FillRectangle,
                InterpolationColors = new List<Color>() { Color.White, Color.Black },
                LinearColorEnabled = true,
                Emit = false
            })
            .AddComponent(new ParticleSystemRenderer3D())
            .AddComponent(new MaterialsMap(new BasicMaterial("Content/Textures/Blaster.png", DefaultLayers.Additive) { VertexColorEnabled = true }))
            ;

            this.particleSystems.Add(particleSystem);

            var emitter4 = new Entity()
            .AddComponent(new Transform3D())
            .AddComponent(particleSystem = new ParticleSystem3D()
            {
                NumParticles = 15,
                EmitRate = 300000,
                MinLife = TimeSpan.FromSeconds(1.5),
                MaxLife = TimeSpan.FromSeconds(4),
                LocalVelocity = Vector3.Zero,
                RandomVelocity = Vector3.One * 0.2f,
                MinSize = 15,
                MaxSize = 20,
                MaxRotateSpeed = 0.015f,
                MinRotateSpeed = -0.015f,
                InitialAngle = MathHelper.TwoPi,
                EndDeltaScale = 2f,
                EmitterSize = new Vector2(4),
                EmitterShape = ParticleSystem3D.Shape.FillRectangle,
                AlphaEnabled = true,
                InterpolationColors = new List<Color>() { Color.White * 0.5f, Color.Black },

                LinearColorEnabled = true,

                Gravity = Vector3.Zero,
                Emit = false
            })
            .AddComponent(new ParticleSystemRenderer3D())
            .AddComponent(new MaterialsMap(new BasicMaterial("Content/Textures/Explosion/Explosion_5.png", DefaultLayers.Alpha) { VertexColorEnabled = true }))
            ;

            this.particleSystems.Add(particleSystem);

            Entity shockwave = new Entity("shockwave")
            .AddComponent(new Transform3D() { Rotation = new Vector3(0.3f, -0.2f, -0.4f)})
            .AddComponent(new Model("Content/Models/Plane.FBX"))
            .AddComponent(new ModelRenderer())
            .AddComponent(this.shockwave = new ShockwaveBehavior())
            .AddComponent(new MaterialsMap(new BasicMaterial("Content/Textures/Explosion/Explosion_4.png", DefaultLayers.Additive)))
            ;

            this.entity.AddChild(emitter1);
            this.entity.AddChild(emitter2);
            this.entity.AddChild(emitter3);
            this.entity.AddChild(emitter4);
            this.entity.AddChild(shockwave);

            this.entity.EntityInitialized += (s, e) =>
                {
                    var screenplay = this.entity.Scene.EntityManager.Find("ScreenplayManager").FindComponent<ScreenplayManager>();
                    screenplay.FrameEvent(frame, this.BayExplosion);
                };
        }
        /// <summary>
        /// Allows this instance to execute custom logic during its 
        /// <c>Update</c>.
        /// </summary>
        /// <param name="gameTime">The game time.</param>
        /// <remarks>
        /// This method will not be executed if it are not 
        /// <c>Active</c>.
        /// </remarks>
        protected override void Update(TimeSpan gameTime)
        {
            if (!this.initialized)
            {
                this.modelFactoryService = ModelFactoryService.Instance;
                this.playScene = this.Owner.Scene as MyScene;
                this.player = this.EntityManager.Find(this.PlayerSource);
                this.playerTransform = this.player.FindComponent<Transform3D>();
                this.playerCollider = this.player.FindComponent<BoxCollider3D>();
                this.playerBehavior = this.player.FindComponent<PlayerBehavior>();
                this.tempBoundingBox = new BoundingBox();

                this.initialized = true;
            }

            // Game Tri-state machine
            switch (GameState)
            {
                // Initial level state
                case GameState.INIT:
                    // Loads the level
                    // it can be done in everywhere we want, in scene too, but then we need to call a Reset method or similar
                    this.LevelModel = ImportService.Instance.ImportLevel(WaveContent.Assets.Levels.level1A_level);

                    // Restart Camera, Player states and positions
                    this.player.FindComponent<PlayerBehavior>().Restart();

                    // put player over the first ground block
                    // FIRST BLOCK OF LEVEL SHOULD BE A GROUND, logically
                    this.playerTransform.Position = new Vector3(0f, this.modelFactoryService.Scale.Y, 0.0f);

                    // fills the intiial Buffer, we need to load some elements prior playing
                    float currentZ = 0;
                    for (int i = 0; i < BlockBufferSize; i++)
                    {
                        // Create Column
                        this.CreateNextColumnEntity(currentZ);
                        currentZ += this.modelFactoryService.Scale.Z;
                    }
                    GameState = GameState.PLAY;
                    break;

                // Playing State of game:
                case GameState.PLAY:
                    // new player position, using acceleration, falling, etc... where applicable
                    //// this.UpdatePlayerPosition(elapsedGameTime);

                    // Check if dead by level platform falling down
                    if (this.playerTransform.Position.Y <= UnderDeadLevel)
                    {
                        this.GameState = Enums.GameState.DIE;
                        break;
                    }

                    // Selects the current and next column, selects the columns to free too.
                    // the current column and next column are used to check collisions, only with those two columns, others are ignored
                    for (int i = 0; i < this.ColumnCollection.Count - 1; i++)
                    {
                        Entity column = this.ColumnCollection[i];
                        var columnTransform = column.FindComponent<Transform3D>();

                        // Remove passedby columns by distance
                        if (columnTransform.Position.Z < this.playerTransform.Position.Z - PasseByBlocksToDiscardColumn * this.modelFactoryService.Scale.Z)
                        {
                            ////// removes column
                            this.modelFactoryService.FreeColumn(column);
                            this.ColumnCollection.RemoveAt(i);

                            ////// Create new column at the end
                            this.CreateNextColumnEntity(columnTransform.Position.Z + BlockBufferSize * this.modelFactoryService.Scale.Z);
                        }
                        // check if player is over this column and sets current and next column
                        else if (this.playerTransform.Position.Z < columnTransform.Position.Z + this.modelFactoryService.Scale.Z
                           && this.playerTransform.Position.Z >= columnTransform.Position.Z)
                        {
                            this.CurrentColumn = column;
                            this.NextColumn = this.ColumnCollection[i + 1];

                            // update the ground level for current and next columns
                            this.CheckGroundPosition();
                            break;
                        }
                    }

                    // if there are a current column checks the collision in current and next column
                    if (this.CurrentColumn != null && !this.CurrentColumn.IsDisposed && this.NextColumn!=null && !this.NextColumn.IsDisposed)
                    {
                        // creates the union of each column entities
                        List<Entity> collidableCollection = this.CurrentColumn.ChildEntities.ToList();
                        collidableCollection.AddRange(this.NextColumn.ChildEntities.ToList());

                        // check if collides
                        foreach (Entity block in collidableCollection)
                        {
                            var blockTransform = block.FindComponent<Transform3D>();
                            var blockCollider = block.FindComponent<BoxCollider3D>();

                            // updates the block boundingbox to check collision
                            this.tempBoundingBox.Max = blockTransform.Position + blockCollider.Size / 2;
                            this.tempBoundingBox.Min = blockTransform.Position - blockCollider.Size / 2;

                            // we use intersects of boundboxes cause collider class has not a Intersects with boundingboxes
                            if (this.tempBoundingBox.Intersects(this.playerBehavior.PlayerBoundingBox))
                            {
                                BlockTypeEnum blockType = BlockTypeEnum.EMPTY;
                                Enum.TryParse<BlockTypeEnum>(block.Tag, out blockType);

                                // if player colliders with the block, we must to check the block effect:
                                switch (blockType)
                                {
                                    case BlockTypeEnum.EMPTY:
                                        break;
                                    // ground and box obstacles can walk over they, but if crash horizontally player dies
                                    case BlockTypeEnum.GROUND:
                                    case BlockTypeEnum.BOX:
                                        if (this.playerBehavior.Collides(blockTransform))
                                        {
                                            this.GameState = Enums.GameState.DIE;
                                        }
                                        break;
                                    case BlockTypeEnum.PYRAMID:
                                        // pyramid collision dies player
                                        this.GameState = Enums.GameState.DIE;
                                        break;
                                    case BlockTypeEnum.SPEEDERBLOCK:
                                        // if collide with speeder then player accelerates
                                        this.playerBehavior.Accelerate((float)gameTime.TotalSeconds);
                                        break;
                                    default:
                                        break;
                                }
                            }
                        }
                    }
                    break;

                // player die state
                case GameState.DIE:
                    // free every column entity and remove containers from entitymanager
                    foreach (Entity column in this.ColumnCollection)
                    {
                        this.modelFactoryService.FreeColumn(column);
                    }

                    // clears the collection and colums
                    this.ColumnCollection.Clear();
                    this.CurrentColumn = null;
                    this.NextColumn = null;

                    // just init
                    GameState = GameState.INIT;
                    break;
            }
        }
        /// <summary>
        /// Initializes the fighter controller
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();

            // Init engine trails
            this.trails = new List<TrailSetting>();
            for (int i = 0; i < this.trailPositions.Count; i++)
            {
                var trailPosition = this.trailPositions[i];
                Transform3D trailTransform;

                Entity trailEntity = new Entity("trail_" + i)
                    .AddComponent(trailTransform = new Transform3D() { LocalPosition = trailPosition });

                this.Owner.AddChild(trailEntity);

                TrailSetting trail = this.trailManager.GetFreeTrail(trailTransform);

                trail.Thickness = 1;
                trail.ExpirationTime = 1f;
                trail.TimeStep = 0.02;
            }

            // Register fighter in screenplay manager
            var screenplay = this.EntityManager.Find("ScreenplayManager").FindComponent<ScreenplayManager>();
            screenplay.RegisterFighter(new FighterSetting()
                {
                    State = this.state,
                    Transform = transform3D
                });

            // Gets all fighter guns
            this.guns = new List<ProjectileEmitter>();
            var gunEntities = this.Owner.ChildEntities.Where(e => e.Tag == "Gun");
            foreach (var gunEntity in gunEntities)
            {
                var projectileEmitter = gunEntity.FindComponent<ProjectileEmitter>();
                this.guns.Add(projectileEmitter);

                projectileEmitter.OnShoot += projectileEmitter_OnShoot;
            }

            this.laserTrigger.OnActionChange += laserTrigger_OnActionChange;

            // Load sound emitters
            var engineSoundEntity = this.Owner.FindChild("engineSoundEmitter");
            if (engineSoundEntity == null)
            {
                engineSoundEntity = this.Owner;
            }

            this.engineSoundEmitter = engineSoundEntity.FindComponent<Sound3DEmitter>();

            var gunsSoundEntity = this.Owner.FindChild("gunsSoundEmitter");
            if (gunsSoundEntity == null)
            {
                gunsSoundEntity = this.Owner;
            }

            this.gunsSoundEmitter = gunsSoundEntity.FindComponent<Sound3DEmitter>();
        }
Exemple #50
0
        /// <summary>
        /// Populates <paramref name="result"/> with the location data from the given <see cref="TileEntry"/> and <see cref="ShallowTileConfig"/> (instead of by trying to reference the original implementation)
        /// </summary>
        /// <param name="entry"></param>
        /// <param name="shallowTile"></param>
        /// <param name="result"></param>
        [Obsolete] public static void GetTransformFromShallow(this TileEntry entry, ShallowTileConfig shallowTile, out Transform3D result)
        {
            result = new Transform3D();
            int x = entry.getLocation().x;
            int y = entry.getLocation().y;
            int w = entry.GetWidth(shallowTile);
            int h = entry.GetHeight(shallowTile);

            TudeySceneMetrics.getTileTransform(w, h, x, y, entry.elevation, entry.rotation, result);
        }
Exemple #51
0
 /// <summary>
 /// Initializes this instance.
 /// </summary>
 protected override void Initialize()
 {
     base.Initialize();
     try
     {
         // Obtains the target transform
         var entity = this.EntityManager.Find(this.EntityPath);
         this.targetTransform = entity.FindComponent<Transform3D>();
     }
     catch (Exception)
     {
         this.targetTransform = null;
     }
 }
        /// <summary>
        ///     Sets and puts level Decor at it's place.
        /// </summary>
        private void InitLevelDecor()
        {
            float   size  = 1.5f;
            Vector3 scale = new Vector3(size, size, size);

            BasicEffectParameters effectParameters =
                new BasicEffectParameters(main.ModelEffect, main.Textures["Wood"], Color.White, 1);
            Transform3D    transform3D = new Transform3D(new Vector3(10, -15, 15), Vector3.UnitZ, Vector3.UnitY);
            OurModelObject table       = new OurModelObject("Table", ActorType.Primitive, StatusType.Drawn, transform3D,
                                                            effectParameters, main.Models["Table"])
            {
                Transform3D = { Scale = scale }
            };

            main.ObjectManager.Add(table);

            effectParameters = new BasicEffectParameters(main.ModelEffect, main.Textures["Ceramic"], Color.White, 1);
            OurModelObject cups = new OurModelObject("Cups", ActorType.Primitive, StatusType.Drawn, transform3D,
                                                     effectParameters, main.Models["Cups"])
            {
                Transform3D = { Scale = scale }
            };

            drawnActors.Add("Cups", cups);
            main.ObjectManager.Add(cups);

            effectParameters =
                new BasicEffectParameters(main.ModelEffect, main.Textures["WhiteChocolate"], Color.White, 1);
            OurModelObject choco = new OurModelObject("Chocolate", ActorType.Primitive, StatusType.Drawn, transform3D,
                                                      effectParameters, main.Models["Chocolate"])
            {
                Transform3D = { Scale = scale }
            };

            main.ObjectManager.Add(choco);

            effectParameters = new BasicEffectParameters(main.ModelEffect, main.Textures["blackTile"], Color.White, 1);
            OurModelObject cat = new OurModelObject("Cat", ActorType.Primitive, StatusType.Drawn, transform3D,
                                                    effectParameters, main.Models["Cat"])
            {
                Transform3D = { Scale = scale }
            };

            main.ObjectManager.Add(cat);

            OurModelObject coffeePot = new OurModelObject("CPot", ActorType.Primitive, StatusType.Drawn, transform3D,
                                                          effectParameters, main.Models["Pot"])
            {
                Transform3D = { Scale = scale }
            };

            main.ObjectManager.Add(coffeePot);

            effectParameters =
                new BasicEffectParameters(main.ModelEffect, main.Textures["coffeeSpill"], Color.White, 1);
            OurModelObject coffeeSpill = new OurModelObject("potSpill", ActorType.Primitive, StatusType.Drawn,
                                                            transform3D, effectParameters, main.Models["Spill"])
            {
                Transform3D = { Scale = scale }
            };

            main.ObjectManager.Add(coffeeSpill);

            effectParameters = new BasicEffectParameters(main.ModelEffect, main.Textures["Checkers"], Color.White, 1);
            OurModelObject catBed = new OurModelObject("Catbed", ActorType.Primitive, StatusType.Drawn, transform3D,
                                                       effectParameters, main.Models["CatBed"])
            {
                Transform3D = { Scale = scale }
            };

            main.ObjectManager.Add(catBed);
        }
        public IGameAction CreateFallAnimation(Entity entity, Transform3D transform)
        {
            var actionAnimation = new RotateTo3DGameAction(entity, Vector3.UnitX * MathHelper.PiOver2, TimeSpan.FromMilliseconds(550), EaseFunction.BounceOutEase);

            return actionAnimation;
        }
 private void InitLight()
 {
     light = new Transform3D(new Vector3(-0.2f, 1, 0.4f), -Vector3.Forward, Vector3.Up);
 }
Exemple #55
0
 public DrawnActor3D(string id, ActorType actorType, StatusType statusType, Transform3D transform3D,
                     EffectParameters effectParameters) : base(id, actorType, statusType, transform3D)
 {
     this.effectParameters = effectParameters;
 }
 /// <summary>
 /// Resolves the dependencies.
 /// </summary>
 protected override void ResolveDependencies()
 {
     base.ResolveDependencies();
     this.enemyPosition = this.Enemy.FindComponent<Transform3D>(isExactType: false);
 }
Exemple #57
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Spinner" /> class.
 /// </summary>
 public Spinner()
     : base("Spinner" + instances++)
 {
     this.increase = Vector3.Zero;
     this.Transform = null;
 }
Exemple #58
0
 public new object Clone()
 {
     return(new DrawnActor3D(ID, ActorType, StatusType, Transform3D.Clone() as Transform3D,
                             effectParameters.Clone() as EffectParameters));
 }