コード例 #1
0
 static AnimationManager()
 {
     AnimatedObjects[SLINGBULLET]  = new AnimatedObject(SLINGBULLET, "gamedata/meshes/slingbullet.obj", "projectile");
     AnimatedObjects[ARROW]        = new AnimatedObject(ARROW, "gamedata/meshes/arrow.obj", "projectile");
     AnimatedObjects[CROSSBOWBOLT] = new AnimatedObject(CROSSBOWBOLT, "gamedata/meshes/crossbowbolt.obj", "projectile");
     AnimatedObjects[LEADBULLET]   = new AnimatedObject(LEADBULLET, "gamedata/meshes/leadbullet.obj", "projectile");
 }
コード例 #2
0
    static public AnimatedObject[] CollectAnimatedObjects(Transform root)
    {
        var animationComponents = (root == null) ?
                                  Object.FindObjectsOfType(typeof(Animation)) as Animation[] :
                                  root.GetComponentsInChildren <Animation> (false) as Animation[];

        var animatedObjects = new ArrayList();

        foreach (var anim in animationComponents)
        {
            if (anim.clip != null && anim.enabled && anim.playAutomatically)
            {
                var ao = new AnimatedObject();
                ao.Reset(anim);
                CacheAnimationState(ao);

                /*#if UNITY_EDITOR
                 * var assetPath = AssetDatabase.GetAssetPath(anim.clip);
                 * ao.restoreMaterials = Path.GetExtension(assetPath) == ".anim";
                 #endif*/

                animatedObjects.Add(ao);
            }
        }

        return(animatedObjects.ToArray(typeof(AnimatedObject)) as AnimatedObject[]);
    }
コード例 #3
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown(GameManager.SELECT_KEY))
        {
            if (selectedObject != null)
            {
                releaseObject();
            }
            else if (selectedObject == null && inRangeObject != null)
            {
                StartCoroutine(ToggleAnimation(true, 0));
                if (inRangeObject.CompareTag(GameManager.ANIMATED_OBJECT_TAG))
                {
                    AnimatedObject anim = inRangeObject.GetComponent <AnimatedObject>();
                    anim.Invoke("ActivateAnimation", 0.3f);
                    StartCoroutine(ToggleAnimation(false, 0.05f));
                }

                else if (inRangeObject.CompareTag(GameManager.SCRIPTED_OBJECT_TAG))
                {
                    ScriptedObject scrpt = inRangeObject.GetComponent <ScriptedObject>();
                    scrpt.runScript();
                    StartCoroutine(ToggleAnimation(false, 0.1f));
                }

                else if (inRangeObject.CompareTag(GameManager.MOVABLE_OBJECT_TAG))
                {
                    selectObject();
                }
            }
        }
    }
コード例 #4
0
 static public AnimationState CacheAnimationState(AnimatedObject ao)
 {
     if (ao.animation)
     {
         if (ao.cachedState == null)
         {
             if (ao.clipName == "")
             {
                 if (ao.animation.clip)
                 {
                     ao.clipName = ao.animation.clip.name;
                 }
                 else
                 {
                     Debug.LogError("Missing default clip (" + ao.animation + ")");
                 }
             }
             ao.cachedState = ao.animation [ao.clipName];
         }
         if (ao.cachedState == null)
         {
             Debug.LogError("State is null (" + ao.animation + " " + ao.clipName + ")");
         }
     }
     else
     {
         ao.cachedState = null;
     }
     return(ao.cachedState);
 }
コード例 #5
0
    public void AddAnimationTrack(AnimatedObject obj)
    {
        GameObject g = Instantiate(timeline.trackPrefab.gameObject, timeline.transform.parent);

        g.transform.rotation   = timeline.trackPrefab.transform.rotation;
        g.transform.localScale = timeline.trackPrefab.transform.localScale;

        AnimationTrack newTrack = g.GetComponent <AnimationTrack>();

        animationTracks.Add(newTrack);

        int     trackIndex       = animationTracks.IndexOf(newTrack);
        Vector3 newTrackPosition = TimelineTrackPosition(trackIndex);

        newTrack.SetUpTrackProperties(obj, newTrackPosition, timeline, trackIndex, timeline.trackPrefab.unselectedColor, timeline.trackPrefab.selectedColor);
        obj.animTrack = newTrack;

        /// add animationOwner
        GameObject trackOwner = Instantiate(timeline.timelineTrackOwnerPrefab.gameObject, timeline.transform);

        Debug.Log("created trackOwner " + trackOwner);
        trackOwner.transform.rotation   = timeline.timelineTrackOwnerPrefab.transform.rotation;
        trackOwner.transform.localScale = new Vector3(1, 1, 1);

        trackOwner.transform.localPosition = TimelineTrackOwnerPosition(trackIndex);
        TimelineTrackOwner newTrackOwner = trackOwner.GetComponent <TimelineTrackOwner>();

        newTrack.timelineTrackOwner = newTrackOwner;
        newTrackOwner.track         = newTrack;
    }
コード例 #6
0
        public void IsImmutableTest()
        {
            var testObjects = new AnimatedObject[]
            {
                new AnimatedObject(new System.Drawing.Rectangle()),
                new AnimatedObject(new System.Drawing.Point()),
                new AnimatedObject(new ValueAnimation(0, 1))
            };
            var testResults = new bool[]
            {
                false,
                false,
                false
            };

            for (int i = 0; i < testObjects.Length; i++)
            {
                var actual   = testObjects[i].IsImmutable();
                var expected = testResults[i];
                Assert.AreEqual(
                    actual,
                    expected,
                    String.Format(
                        "Test Case #{0} - Expected: {1} Actual: {2}",
                        i + 1,
                        expected,
                        actual
                        )
                    );
            }
        }
コード例 #7
0
 static AnimationManager()
 {
     AnimatedObjects[SLINGBULLET]  = new AnimatedObject(SLINGBULLET, GameInitializer.MESH_PATH + "slingbullet.ply");
     AnimatedObjects[ARROW]        = new AnimatedObject(ARROW, GameInitializer.MESH_PATH + "arrow.ply");
     AnimatedObjects[CROSSBOWBOLT] = new AnimatedObject(CROSSBOWBOLT, GameInitializer.MESH_PATH + "crossbowbolt.ply");
     AnimatedObjects[LEADBULLET]   = new AnimatedObject(LEADBULLET, GameInitializer.MESH_PATH + "leadbullet.ply");
 }
コード例 #8
0
    static public void SampleAnimation(AnimatedObject ao, float t, bool forceSample)
    {
#if UNITY_EDITOR
        if (!activeInEditor)
        {
            return;
        }
#endif
        var animation = ao.animation;
        var state     = CacheAnimationState(ao);
        if (state == null)
        {
            return;
        }

        state.time = t;

        if (forceSample)
        {
            state.enabled = true;
            state.weight  = 1;
            animation.Sample();
            state.enabled = false;

                        #if UNITY_EDITOR
            EditorUtility.SetDirty(animation);
                        #endif
        }
    }
コード例 #9
0
 // add object for custom timetable
 internal static void AddObjectForCustomTimetable(AnimatedObject obj)
 {
     if (CustomObjectsUsed >= CustomObjects.Length)
     {
         Array.Resize(ref CustomObjects, CustomObjects.Length << 1);
     }
     CustomObjects[CustomObjectsUsed] = obj;
     CustomObjectsUsed++;
 }
コード例 #10
0
    private void Start()
    {
        animObj = videoKeyframe.animTrack.animatedObject;

        gimbals = AnimatedObjectGimbals.Instance;
        Debug.Log("creating " + gimbals);

        // objMenu.gameObject.SetActive(false);
    }
コード例 #11
0
 public void ResumePlaceableAnimations()
 {
     GameObject[] placeables = GameObject.FindGameObjectsWithTag("placeable");
     foreach (var placeable in placeables)
     {
         AnimatedObject animatedObject = placeable.GetComponent <AnimatedObject> ();
         animatedObject.ResumeAnimation();
     }
     animationStatus = LevelAnimationStatus.RUNNING;
 }
コード例 #12
0
 public void PausePlaceableAnimations()
 {
     GameObject[] placeables = GameObject.FindGameObjectsWithTag("placeable");
     foreach (var placeable in placeables)
     {
         AnimatedObject animatedObject = placeable.GetComponent <AnimatedObject> ();
         animatedObject.PauseAnimation();
     }
     animationStatus = LevelAnimationStatus.PAUSED;
 }
コード例 #13
0
 public void StopPlaceableAnimations()
 {
     GameObject[] placeables = GameObject.FindGameObjectsWithTag("placeable");
     foreach (var placeable in placeables)
     {
         AnimatedObject animatedObject = placeable.GetComponent <AnimatedObject> ();
         animatedObject.StopAnimationAndReset();
     }
     animationStatus = LevelAnimationStatus.STOPPED_OR_NONE;
 }
コード例 #14
0
 public void Animate(GameObject go, GameObject from, GameObject to, string animation)
 {
     AnimatedObject anim = new AnimatedObject();
     List<Animator> engines = mAnimators[animation];
     anim.animator = engines[Random.Range(0, engines.Count - 1)].gameObject.transform.GetChild(0).gameObject;
     anim.from = from;
     anim.to = to;
     anim.animated = go;
     mAnimatedObjects.Add(go, anim);
 }
コード例 #15
0
    public override void OnInspectorGUI()
    {
        AnimatedObject cc = (AnimatedObject)target;

        cc.FlipX = EditorGUILayout.Toggle("Flip X", cc.FlipX);
        cc.FlipY = EditorGUILayout.Toggle("Flip Y", cc.FlipY);

        base.OnInspectorGUI();
        EditorUtility.SetDirty(target);
    }
コード例 #16
0
    public AnimationTrack(AnimatedObject aObj, Vector3 trackPosition, Timeline t, int trackNumber)
    {
        animatedObject = aObj;
        timeline       = t;

        transform.parent        = timeline.transform;
        transform.localPosition = trackPosition;

        // SetUpTrackProperties(trackNumber);
    }
コード例 #17
0
ファイル: Slime.cs プロジェクト: Stureplan/InfiniteDungeon
    private void Initialize()
    {
        map       = Map.FindMap();
        barbarian = Barbarian.FindBarbarian();
        anim      = GetComponent <AnimatedObject>();
        anim.Initialize();
        anim.PlayAnimation("Slime_Idle");

        value = 3;
    }
コード例 #18
0
    public AnimationTrack(AnimationPlayableOutput apo, AnimationMixerPlayable amp, AnimationClipPlayable acp, AnimationClip c, GameObject objToAnimate)
    {
        animationPlayableOutput = apo;
        animMixerPlayable       = amp;
        animClipPlayable        = acp;
        animCurve           = new AnimCurve();
        animCurve.animTrack = this;

        animatedObject = objToAnimate.AddComponent <AnimatedObject>();
        clip           = c;
    }
コード例 #19
0
    internal AnimatedObject Clone()
    {
        AnimatedObject Result = new AnimatedObject();

        Result.States = new AnimatedObjectState[this.States.Length];
        for (int i = 0; i < this.States.Length; i++)
        {
            Result.States[i].Position = this.States[i].Position;
            //Result.States[i].Object = ObjectManager.Instance.CloneObject(this.States[i].Object);
        }
        //Result.StateFunction = this.StateFunction == null ? null : this.StateFunction.Clone();
        Result.CurrentState        = this.CurrentState;
        Result.TranslateZDirection = this.TranslateZDirection;
        Result.TranslateYDirection = this.TranslateYDirection;
        Result.TranslateXDirection = this.TranslateXDirection;
        //Result.TranslateXFunction = this.TranslateXFunction == null ? null : this.TranslateXFunction.Clone();
        //Result.TranslateYFunction = this.TranslateYFunction == null ? null : this.TranslateYFunction.Clone();
        //Result.TranslateZFunction = this.TranslateZFunction == null ? null : this.TranslateZFunction.Clone();
        Result.RotateXDirection = this.RotateXDirection;
        Result.RotateYDirection = this.RotateYDirection;
        Result.RotateZDirection = this.RotateZDirection;
        //Result.RotateXFunction = this.RotateXFunction == null ? null : this.RotateXFunction.Clone();
        //Result.RotateXDamping = this.RotateXDamping == null ? null : this.RotateXDamping.Clone();
        //Result.RotateYFunction = this.RotateYFunction == null ? null : this.RotateYFunction.Clone();
        //Result.RotateYDamping = this.RotateYDamping == null ? null : this.RotateYDamping.Clone();
        //Result.RotateZFunction = this.RotateZFunction == null ? null : this.RotateZFunction.Clone();
        //Result.RotateZDamping = this.RotateZDamping == null ? null : this.RotateZDamping.Clone();
        Result.TextureShiftXDirection = this.TextureShiftXDirection;
        Result.TextureShiftYDirection = this.TextureShiftYDirection;
        //Result.TextureShiftXFunction = this.TextureShiftXFunction == null ? null : this.TextureShiftXFunction.Clone();
        //Result.TextureShiftYFunction = this.TextureShiftYFunction == null ? null : this.TextureShiftYFunction.Clone();
        Result.LEDClockwiseWinding = this.LEDClockwiseWinding;
        Result.LEDInitialAngle     = this.LEDInitialAngle;
        Result.LEDLastAngle        = this.LEDLastAngle;
        if (this.LEDVectors != null)
        {
            Result.LEDVectors = new Vector3[this.LEDVectors.Length];
            for (int i = 0; i < this.LEDVectors.Length; i++)
            {
                Result.LEDVectors[i] = this.LEDVectors[i];
            }
        }
        else
        {
            Result.LEDVectors = null;
        }
        //Result.LEDFunction = this.LEDFunction == null ? null : this.LEDFunction.Clone();
        Result.RefreshRate            = this.RefreshRate;
        Result.CurrentTrackZOffset    = 0.0;
        Result.SecondsSinceLastUpdate = 0.0;
        //Result.ObjectIndex = -1;
        return(Result);
    }
コード例 #20
0
    public void YMovementToggled()
    {
        LevelEditor editor = GameObject.FindObjectOfType <LevelEditor> ();

        if (editor.CurrentSelection != null)
        {
            AnimatedObject ao = editor.CurrentSelection.GetComponent <AnimatedObject>();
            if (ao != null)
            {
                ao.useY = yToggle.isOn;
            }
        }
    }
コード例 #21
0
    // Abstract function callbacks
    public override void onAwake()
    {
        imagePopout = transform.GetChild(4).GetComponent<AnimatedObject>();
        imageBackground = transform.GetChild(5).GetChild(0).GetComponent<AnimatedObject>();
        loadingBar = transform.GetChild(2).GetChild(0).GetComponent<AnimatedObject>();

        animatedObjects = new List<AnimatedObject>();
        animatedObjects.Add(imagePopout);
        animatedObjects.Add(imageBackground);
        animatedObjects.Add(loadingBar);

        hotspot = transform.GetChild(0).gameObject;
    }
コード例 #22
0
ファイル: Interpreter.cs プロジェクト: lanceewing/agile
 /// <summary>
 /// Constructor for Interpreter.
 /// </summary>
 /// <param name="game"></param>
 /// <param name="userInput"></param>
 /// <param name="pixels"></param>
 public Interpreter(Game game, UserInput userInput, int[] pixels)
 {
     this.state        = new GameState(game);
     this.userInput    = userInput;
     this.pixels       = pixels;
     this.textGraphics = new TextGraphics(pixels, state, userInput);
     this.parser       = new Parser(state);
     this.soundPlayer  = new SoundPlayer(state);
     this.menu         = new Menu(state, textGraphics, pixels, userInput);
     this.commands     = new Commands(pixels, state, userInput, textGraphics, parser, soundPlayer, menu);
     this.ego          = state.Ego;
     this.state.Init();
     this.textGraphics.UpdateInputLine();
 }
コード例 #23
0
    private void Start()
    {
        camOffset = cam.transform.position - transform.position;
        anim      = GetComponent <AnimatedObject>();
        anim.Initialize();
        anim.PlayAnimation("Barbarian_LookingDown");


        map.Generate(); // <-- initiates the animation sequence
        //cell = map.StartCell();

        //ui.FadePanelsIn();
        //ui.SetMinimap(map.GetMinimap());
    }
コード例 #24
0
    public void StartPlaceableAnimations()
    {
        GameObject[] placeables = GameObject.FindGameObjectsWithTag("placeable");
        foreach (var placeable in placeables)
        {
            AnimatedObject animatedObject = placeable.GetComponent <AnimatedObject> ();
//			if (animatedObject == null){
//				animatedObject = placeable.AddComponent<AnimatedObject> ();
//				animatedObject.SetData (placeable.GetComponent<Placeable> ().pData.AnimationData);
//			}
            animatedObject.StartAnimation();
        }
        animationStatus = LevelAnimationStatus.RUNNING;
    }
コード例 #25
0
        public override void Load()
        {
            // Load pacman.
            pacSheet            = game.Content.Load <Texture2D>(@"Textures/Game/pacman-sheet");
            pacTextureAnimation = new TextureAnimation(pacSheet, 16, 16, new TimeSpan(0, 0, 0, 0, 66));
            pacman           = new AnimatedObject(pacTextureAnimation);
            pacStartPosition = new Vector2(startDrawLocation.X - 5, startDrawLocation.Y);

            // Load ghost.
            ghostTexture          = game.Content.Load <Texture2D>(@"Textures/Game/ghost_01");
            ghostTextureAnimation = new TextureAnimation(ghostTexture, ghostTexture.Width, ghostTexture.Height, new TimeSpan(1, 0, 0));
            ghost = new AnimatedObject(ghostTextureAnimation);
            ghostStartPosition = new Vector2(startDrawLocation.X - 60, startDrawLocation.Y + 1);
        }
コード例 #26
0
        public override void Animate(InGameEngine engine)
        {
            Explosion obj;

            if (AnimatedObject == null || (obj = AnimatedObject as Explosion) == null)
            {
                return;
            }
            AnimatedObject.ChangeSizeAtCentre(AnimatedObject.Size.Add(Speed));
            if (obj.Destroying)
            {
                //Todo Destroying Explosions (from mines) have not been implemented yet - destroy the stuff!
            }
        }
コード例 #27
0
        public AnimatedSprite(Texture texture, Vector2u size, List <Animation> aList = null)
        {
            _sprite        = new Sprite(texture);
            _size          = size;
            _sprite.Origin = new Vector2f(32, 32);
            if (aList == null)
            {
                return;
            }
            _animationList = aList;

            _animatedObject = new AnimatedObject <Sprite>(_sprite);
            _tSize          = texture.Size;
            _animator       = new Animator <Sprite, string>();
            AddFrames();
            _animator.PlayAnimation(aList[0].Name, true);
        }
コード例 #28
0
    /// <summary>
    /// Paints the placeable.
    /// </summary>
    /// <param name="placeable">Placeable.</param>
    public Placeable PaintPlaceable(Placeable placeable)
    {
        float x = Mathf.Round(Camera.main.ScreenToWorldPoint(Input.mousePosition).x);
        float y = Mathf.Round(Camera.main.ScreenToWorldPoint(Input.mousePosition).y);

        Placeable newPlaceable = Instantiate(placeable, new Vector2(x, y), Quaternion.identity);

        newPlaceable.SetData(new PlaceableData(placeable.name));
        CurrentLevel.levelData.AddPlaceableData(newPlaceable.pData);
        newPlaceable.gameObject.transform.SetParent(GameObject.FindGameObjectWithTag("placeable container").transform);
        newPlaceable.gameObject.name = placeable.gameObject.name + " " + newPlaceable.pData.ID;
        AnimatedObject animation = newPlaceable.gameObject.AddComponent <AnimatedObject> ();

        animation.SetData(newPlaceable.pData);
        OnPlaceablePainted(newPlaceable);
        return(newPlaceable);
    }
コード例 #29
0
    // when a gimbal event takes place, you have to let the animation curve know of the event that is taking place
    // 1st) let gimbal move object
    // 2nd) update animation key frame, delete that specific key frame
    // 3rd) update animation curve, and reset keyframe
    // 4th) update animation track Keyframe UI (if the timing has been shifted)

    // the animation curve what is happening
    private void Awake()
    {
        animObj = null;

        gimbals    = new AnimatedGimbal[6];
        gimbals[0] = gimbalX;
        gimbals[1] = gimbalY;
        gimbals[2] = gimbalZ;

        gimbals[3] = gimbalRotateX;
        gimbals[4] = gimbalRotateY;
        gimbals[5] = gimbalRotateZ;

        foreach (AnimatedGimbal gimbal in gimbals)
        {
            gimbal.animObjGimbals = this;
        }
    }
コード例 #30
0
ファイル: Inventory.cs プロジェクト: lanceewing/agile
        /// <summary>
        /// Shows a special view of an object that has an attached description. Intended for use
        /// with the "look at object" scenario when the object looked at is an inventory item.
        /// </summary>
        /// <param name="viewNumber">The number of the view to show the special inventory object view of.</param>
        public void ShowInventoryObject(byte viewNumber)
        {
            // Set up the AnimatedObject that will be used to display this view.
            AnimatedObject aniObj = new AnimatedObject(state, -1);

            aniObj.SetView(viewNumber);
            aniObj.X             = aniObj.PrevX = (short)((Defines.MAXX - aniObj.XSize) / 2);
            aniObj.Y             = aniObj.PrevY = Defines.MAXY;
            aniObj.Priority      = 15;
            aniObj.FixedPriority = true;
            aniObj.PreviousCel   = aniObj.Cel;

            // Display the description in a window along with the item picture.
            textGraphics.WindowPrint(state.Views[viewNumber].Description, aniObj);

            // Restore the pixels that were behind the item's image.
            aniObj.RestoreBackPixels();
            aniObj.Show(pixels);
        }
コード例 #31
0
    /// <summary>
    /// Updates animation inputs to have the same values as the curremtly selected object, should be called when an object is selected.
    /// </summary>
    public void SetInputs()
    {
        LevelEditor editor = GameObject.FindObjectOfType <LevelEditor> ();

        if (editor.CurrentSelection)
        {
            AnimatedObject ao = editor.CurrentSelection.GetComponent <AnimatedObject>();
            if (ao != null)
            {
                // Set inputs to current movemnt values
                xTarget.text                   = ao.xDestination.ToString();
                yTarget.text                   = ao.yDestinastion.ToString();
                movementTime.text              = ao.movementTime.ToString();
                movementDelay.text             = ao.movementDelay.ToString();
                movementEaseTypeDropdown.value = (int)ao.movementEaseType;
                movementLoopTypeDropdown.value = (int)ao.movementLoopType;
                xToggle.isOn                   = ao.useX;
                yToggle.isOn                   = ao.useY;


                //Rotation
                clockwiseRotationToggle.isOn   = ao.clockwise;
                rotationTime.text              = ao.rotationTime.ToString();
                rotationDelay.text             = ao.rotationDelay.ToString();
                rotationEaseTypeDropdown.value = (int)ao.rotationEaseType;
                rotationLoopTypeDropdown.value = (int)ao.rotationLoopType;
                if (ao.rotationType == AnimatedObject.RotationTypes.ROTATE_BY)
                {
                    rotationMethodToggle.isOn = true;
                }
                else
                {
                    rotationMethodToggle.isOn = false;
                }
                rotationDegrees.text = ao.rotationDegrees.ToString();
            }
            else
            {
                Debug.LogWarning("AnimationControlsWidget:SetInputs:: No animated object is selected. Animated controls widget should likely be closed.");
            }
        }
    }
コード例 #32
0
//	public void btn_ToggleMovementAnimation()
//	{
//		if (movementAnimationWindow.isActiveAndEnabled)
//		{
//			movementAnimationWindow.gameObject.SetActive(false);
//
//		}
//		else
//		{
//			movementAnimationWindow.gameObject.SetActive(true);
//
//		}
//	}
//	public void btn_ToggleRotationAnimation()
//	{
//		if (rotationAnimationWindow.isActiveAndEnabled)
//		{
//			rotationAnimationWindow.gameObject.SetActive(false);
//		}
//		else
//		{
//			rotationAnimationWindow.gameObject.SetActive(true);
//		}
//
//	}


    public void RotationMethodToggled()
    {
        LevelEditor editor = GameObject.FindObjectOfType <LevelEditor> ();

        if (editor.CurrentSelection != null)
        {
            AnimatedObject ao = editor.CurrentSelection.GetComponent <AnimatedObject>();
            if (ao != null)
            {
                if (rotationMethodToggle.isOn)
                {
                    ao.rotationType = AnimatedObject.RotationTypes.ROTATE_BY;
                }
                else
                {
                    ao.rotationType = AnimatedObject.RotationTypes.ROTATE_TO;
                }
            }
        }
    }
コード例 #33
0
ファイル: ObjectManager.cs プロジェクト: sladen/openbve
 internal static void UpdateAnimatedObject(ref AnimatedObject Object, bool IsPartOfTrain, TrainManager.Train Train, int CarIndex, int SectionIndex, double TrackPosition, Vector3 Position, Vector3 Direction, Vector3 Up, Vector3 Side, bool Overlay, bool UpdateFunctions, bool Show, double TimeElapsed)
 {
     int s = Object.CurrentState;
     int i = Object.ObjectIndex;
     // state change
     if (Object.StateFunction != null & UpdateFunctions) {
         double sd = Object.StateFunction.Perform(Train, CarIndex, Position, TrackPosition, SectionIndex, IsPartOfTrain, TimeElapsed);
         int si = (int)Math.Round(sd);
         int sn = Object.States.Length;
         if (si < 0 | si >= sn) si = -1;
         if (s != si) {
             InitializeAnimatedObject(ref Object, si, Overlay, Show);
             s = si;
         }
     }
     if (s == -1) return;
     // translation
     if (Object.TranslateXFunction != null) {
         double x;
         if (UpdateFunctions) {
             x = Object.TranslateXFunction.Perform(Train, CarIndex, Position, TrackPosition, SectionIndex, IsPartOfTrain, TimeElapsed);
         } else  {
             x = Object.TranslateXFunction.LastResult;
         }
         double rx = Object.TranslateXDirection.X, ry = Object.TranslateXDirection.Y, rz = Object.TranslateXDirection.Z;
         World.Rotate(ref rx, ref ry, ref rz, Direction.X, Direction.Y, Direction.Z, Up.X, Up.Y, Up.Z, Side.X, Side.Y, Side.Z);
         Position.X += x * rx;
         Position.Y += x * ry;
         Position.Z += x * rz;
     }
     if (Object.TranslateYFunction != null) {
         double y;
         if (UpdateFunctions) {
             y = Object.TranslateYFunction.Perform(Train, CarIndex, Position, TrackPosition, SectionIndex, IsPartOfTrain, TimeElapsed);
         } else {
             y = Object.TranslateYFunction.LastResult;
         }
         double rx = Object.TranslateYDirection.X, ry = Object.TranslateYDirection.Y, rz = Object.TranslateYDirection.Z;
         World.Rotate(ref rx, ref ry, ref rz, Direction.X, Direction.Y, Direction.Z, Up.X, Up.Y, Up.Z, Side.X, Side.Y, Side.Z);
         Position.X += y * rx;
         Position.Y += y * ry;
         Position.Z += y * rz;
     }
     if (Object.TranslateZFunction != null) {
         double z;
         if (UpdateFunctions) {
             z = Object.TranslateZFunction.Perform(Train, CarIndex, Position, TrackPosition, SectionIndex, IsPartOfTrain, TimeElapsed);
         } else {
             z = Object.TranslateZFunction.LastResult;
         }
         double rx = Object.TranslateZDirection.X, ry = Object.TranslateZDirection.Y, rz = Object.TranslateZDirection.Z;
         World.Rotate(ref rx, ref ry, ref rz, Direction.X, Direction.Y, Direction.Z, Up.X, Up.Y, Up.Z, Side.X, Side.Y, Side.Z);
         Position.X += z * rx;
         Position.Y += z * ry;
         Position.Z += z * rz;
     }
     // rotation
     bool rotateX = Object.RotateXFunction != null;
     bool rotateY = Object.RotateYFunction != null;
     bool rotateZ = Object.RotateZFunction != null;
     double cosX, sinX;
     if (rotateX) {
         double a;
         if (UpdateFunctions) {
             a = Object.RotateXFunction.Perform(Train, CarIndex, Position, TrackPosition, SectionIndex, IsPartOfTrain, TimeElapsed);
         } else {
             a = Object.RotateXFunction.LastResult;
         }
         ObjectManager.UpdateDamping(ref Object.RotateXDamping, TimeElapsed, ref a);
         cosX = Math.Cos(a);
         sinX = Math.Sin(a);
     } else {
         cosX = 0.0; sinX = 0.0;
     }
     double cosY, sinY;
     if (rotateY) {
         double a;
         if (UpdateFunctions) {
             a = Object.RotateYFunction.Perform(Train, CarIndex, Position, TrackPosition, SectionIndex, IsPartOfTrain, TimeElapsed);
         } else {
             a = Object.RotateYFunction.LastResult;
         }
         ObjectManager.UpdateDamping(ref Object.RotateYDamping, TimeElapsed, ref a);
         cosY = Math.Cos(a);
         sinY = Math.Sin(a);
     } else {
         cosY = 0.0; sinY = 0.0;
     }
     double cosZ, sinZ;
     if (rotateZ) {
         double a;
         if (UpdateFunctions) {
             a = Object.RotateZFunction.Perform(Train, CarIndex, Position, TrackPosition, SectionIndex, IsPartOfTrain, TimeElapsed);
         } else {
             a = Object.RotateZFunction.LastResult;
         }
         ObjectManager.UpdateDamping(ref Object.RotateZDamping, TimeElapsed, ref a);
         cosZ = Math.Cos(a);
         sinZ = Math.Sin(a);
     } else {
         cosZ = 0.0; sinZ = 0.0;
     }
     // texture shift
     bool shiftx = Object.TextureShiftXFunction != null;
     bool shifty = Object.TextureShiftYFunction != null;
     if ((shiftx | shifty) & UpdateFunctions) {
         for (int k = 0; k < ObjectManager.Objects[i].Mesh.Vertices.Length; k++) {
             ObjectManager.Objects[i].Mesh.Vertices[k].TextureCoordinates = Object.States[s].Object.Mesh.Vertices[k].TextureCoordinates;
         }
         if (shiftx) {
             double x = Object.TextureShiftXFunction.Perform(Train, CarIndex, Position, TrackPosition, SectionIndex, IsPartOfTrain, TimeElapsed);
             x -= Math.Floor(x);
             for (int k = 0; k < ObjectManager.Objects[i].Mesh.Vertices.Length; k++) {
                 ObjectManager.Objects[i].Mesh.Vertices[k].TextureCoordinates.X += (float)(x * Object.TextureShiftXDirection.X);
                 ObjectManager.Objects[i].Mesh.Vertices[k].TextureCoordinates.Y += (float)(x * Object.TextureShiftXDirection.Y);
             }
         }
         if (shifty) {
             double y = Object.TextureShiftYFunction.Perform(Train, CarIndex, Position, TrackPosition, SectionIndex, IsPartOfTrain, TimeElapsed);
             y -= Math.Floor(y);
             for (int k = 0; k < ObjectManager.Objects[i].Mesh.Vertices.Length; k++) {
                 ObjectManager.Objects[i].Mesh.Vertices[k].TextureCoordinates.X += (float)(y * Object.TextureShiftYDirection.X);
                 ObjectManager.Objects[i].Mesh.Vertices[k].TextureCoordinates.Y += (float)(y * Object.TextureShiftYDirection.Y);
             }
         }
     }
     // led
     bool led = Object.LEDFunction != null;
     double ledangle;
     if (led) {
         if (UpdateFunctions) {
             double lastangle = Object.LEDFunction.LastResult;
             ledangle = Object.LEDFunction.Perform(Train, CarIndex, Position, TrackPosition, SectionIndex, IsPartOfTrain, TimeElapsed);
         } else {
             ledangle = Object.LEDFunction.LastResult;
         }
     } else {
         ledangle = 0.0;
     }
     // null object
     if (Object.States[s].Object == null) {
         return;
     }
     // initialize vertices
     for (int k = 0; k < Object.States[s].Object.Mesh.Vertices.Length; k++) {
         ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates = Object.States[s].Object.Mesh.Vertices[k].Coordinates;
     }
     // led
     if (led) {
         /*
          * Edges:         Vertices:
          * 0 - bottom     0 - bottom-left
          * 1 - left       1 - top-left
          * 2 - top        2 - top-right
          * 3 - right      3 - bottom-right
          *                4 - center
          * */
         int v = 1;
         if (Object.LEDClockwiseWinding) {
             /* winding is clockwise*/
             if (ledangle < Object.LEDInitialAngle) {
                 ledangle = Object.LEDInitialAngle;
             }
             if (ledangle < Object.LEDLastAngle) {
                 double currentEdgeFloat = Math.Floor(0.636619772367582 * (ledangle + 0.785398163397449));
                 int currentEdge = ((int)currentEdgeFloat % 4 + 4) % 4;
                 double lastEdgeFloat = Math.Floor(0.636619772367582 * (Object.LEDLastAngle + 0.785398163397449));
                 int lastEdge = ((int)lastEdgeFloat % 4 + 4) % 4;
                 if (lastEdge < currentEdge | lastEdge == currentEdge & Math.Abs(currentEdgeFloat - lastEdgeFloat) > 2.0) {
                     lastEdge += 4;
                 }
                 if (currentEdge == lastEdge) {
                     /* current angle to last angle */
                     {
                         double t = 0.5 + (0.636619772367582 * ledangle) - currentEdgeFloat;
                         if (t < 0.0) {
                             t = 0.0;
                         } else if (t > 1.0) {
                             t = 1.0;
                         }
                         t = 0.5 * (1.0 - Math.Tan(0.25 * (Math.PI - 2.0 * Math.PI * t)));
                         double cx = (1.0 - t) * Object.LEDVectors[(currentEdge + 3) % 4].X + t * Object.LEDVectors[currentEdge].X;
                         double cy = (1.0 - t) * Object.LEDVectors[(currentEdge + 3) % 4].Y + t * Object.LEDVectors[currentEdge].Y;
                         double cz = (1.0 - t) * Object.LEDVectors[(currentEdge + 3) % 4].Z + t * Object.LEDVectors[currentEdge].Z;
                         Object.States[s].Object.Mesh.Vertices[v].Coordinates = new Vector3(cx, cy, cz);
                         v++;
                     }
                     {
                         double t = 0.5 + (0.636619772367582 * Object.LEDLastAngle) - lastEdgeFloat;
                         if (t < 0.0) {
                             t = 0.0;
                         } else if (t > 1.0) {
                             t = 1.0;
                         }
                         t = 0.5 * (1.0 - Math.Tan(0.25 * (Math.PI - 2.0 * Math.PI * t)));
                         double lx = (1.0 - t) * Object.LEDVectors[(lastEdge + 3) % 4].X + t * Object.LEDVectors[lastEdge].X;
                         double ly = (1.0 - t) * Object.LEDVectors[(lastEdge + 3) % 4].Y + t * Object.LEDVectors[lastEdge].Y;
                         double lz = (1.0 - t) * Object.LEDVectors[(lastEdge + 3) % 4].Z + t * Object.LEDVectors[lastEdge].Z;
                         Object.States[s].Object.Mesh.Vertices[v].Coordinates = new Vector3(lx, ly, lz);
                         v++;
                     }
                 } else {
                     {
                         /* current angle to square vertex */
                         double t = 0.5 + (0.636619772367582 * ledangle) - currentEdgeFloat;
                         if (t < 0.0) {
                             t = 0.0;
                         } else if (t > 1.0) {
                             t = 1.0;
                         }
                         t = 0.5 * (1.0 - Math.Tan(0.25 * (Math.PI - 2.0 * Math.PI * t)));
                         double cx = (1.0 - t) * Object.LEDVectors[(currentEdge + 3) % 4].X + t * Object.LEDVectors[currentEdge].X;
                         double cy = (1.0 - t) * Object.LEDVectors[(currentEdge + 3) % 4].Y + t * Object.LEDVectors[currentEdge].Y;
                         double cz = (1.0 - t) * Object.LEDVectors[(currentEdge + 3) % 4].Z + t * Object.LEDVectors[currentEdge].Z;
                         Object.States[s].Object.Mesh.Vertices[v + 0].Coordinates = new Vector3(cx, cy, cz);
                         Object.States[s].Object.Mesh.Vertices[v + 1].Coordinates = Object.LEDVectors[currentEdge];
                         v += 2;
                     }
                     for (int j = currentEdge + 1; j < lastEdge; j++) {
                         /* square-vertex to square-vertex */
                         Object.States[s].Object.Mesh.Vertices[v + 0].Coordinates = Object.LEDVectors[(j + 3) % 4];
                         Object.States[s].Object.Mesh.Vertices[v + 1].Coordinates = Object.LEDVectors[j % 4];
                         v += 2;
                     }
                     {
                         /* square vertex to last angle */
                         double t = 0.5 + (0.636619772367582 * Object.LEDLastAngle) - lastEdgeFloat;
                         if (t < 0.0) {
                             t = 0.0;
                         } else if (t > 1.0) {
                             t = 1.0;
                         }
                         t = 0.5 * (1.0 - Math.Tan(0.25 * (Math.PI - 2.0 * Math.PI * t)));
                         double lx = (1.0 - t) * Object.LEDVectors[(lastEdge + 3) % 4].X + t * Object.LEDVectors[lastEdge % 4].X;
                         double ly = (1.0 - t) * Object.LEDVectors[(lastEdge + 3) % 4].Y + t * Object.LEDVectors[lastEdge % 4].Y;
                         double lz = (1.0 - t) * Object.LEDVectors[(lastEdge + 3) % 4].Z + t * Object.LEDVectors[lastEdge % 4].Z;
                         Object.States[s].Object.Mesh.Vertices[v + 0].Coordinates = Object.LEDVectors[(lastEdge + 3) % 4];
                         Object.States[s].Object.Mesh.Vertices[v + 1].Coordinates = new Vector3(lx, ly, lz);
                         v += 2;
                     }
                 }
             }
         } else {
             /* winding is counter-clockwise*/
             if (ledangle > Object.LEDInitialAngle) {
                 ledangle = Object.LEDInitialAngle;
             }
             if (ledangle > Object.LEDLastAngle) {
                 double currentEdgeFloat = Math.Floor(0.636619772367582 * (ledangle + 0.785398163397449));
                 int currentEdge = ((int)currentEdgeFloat % 4 + 4) % 4;
                 double lastEdgeFloat = Math.Floor(0.636619772367582 * (Object.LEDLastAngle + 0.785398163397449));
                 int lastEdge = ((int)lastEdgeFloat % 4 + 4) % 4;
                 if (currentEdge < lastEdge | lastEdge == currentEdge & Math.Abs(currentEdgeFloat - lastEdgeFloat) > 2.0) {
                     currentEdge += 4;
                 }
                 if (currentEdge == lastEdge) {
                     /* current angle to last angle */
                     {
                         double t = 0.5 + (0.636619772367582 * Object.LEDLastAngle) - lastEdgeFloat;
                         if (t < 0.0) {
                             t = 0.0;
                         } else if (t > 1.0) {
                             t = 1.0;
                         }
                         t = 0.5 * (1.0 - Math.Tan(0.25 * (Math.PI - 2.0 * Math.PI * t)));
                         double lx = (1.0 - t) * Object.LEDVectors[(lastEdge + 3) % 4].X + t * Object.LEDVectors[lastEdge].X;
                         double ly = (1.0 - t) * Object.LEDVectors[(lastEdge + 3) % 4].Y + t * Object.LEDVectors[lastEdge].Y;
                         double lz = (1.0 - t) * Object.LEDVectors[(lastEdge + 3) % 4].Z + t * Object.LEDVectors[lastEdge].Z;
                         Object.States[s].Object.Mesh.Vertices[v].Coordinates = new Vector3(lx, ly, lz);
                         v++;
                     }
                     {
                         double t = 0.5 + (0.636619772367582 * ledangle) - currentEdgeFloat;
                         if (t < 0.0) {
                             t = 0.0;
                         } else if (t > 1.0) {
                             t = 1.0;
                         }
                         t = t - Math.Floor(t);
                         t = 0.5 * (1.0 - Math.Tan(0.25 * (Math.PI - 2.0 * Math.PI * t)));
                         double cx = (1.0 - t) * Object.LEDVectors[(currentEdge + 3) % 4].X + t * Object.LEDVectors[currentEdge].X;
                         double cy = (1.0 - t) * Object.LEDVectors[(currentEdge + 3) % 4].Y + t * Object.LEDVectors[currentEdge].Y;
                         double cz = (1.0 - t) * Object.LEDVectors[(currentEdge + 3) % 4].Z + t * Object.LEDVectors[currentEdge].Z;
                         Object.States[s].Object.Mesh.Vertices[v].Coordinates = new Vector3(cx, cy, cz);
                         v++;
                     }
                 } else {
                     {
                         /* current angle to square vertex */
                         double t = 0.5 + (0.636619772367582 * ledangle) - currentEdgeFloat;
                         if (t < 0.0) {
                             t = 0.0;
                         } else if (t > 1.0) {
                             t = 1.0;
                         }
                         t = 0.5 * (1.0 - Math.Tan(0.25 * (Math.PI - 2.0 * Math.PI * t)));
                         double cx = (1.0 - t) * Object.LEDVectors[(currentEdge + 3) % 4].X + t * Object.LEDVectors[currentEdge % 4].X;
                         double cy = (1.0 - t) * Object.LEDVectors[(currentEdge + 3) % 4].Y + t * Object.LEDVectors[currentEdge % 4].Y;
                         double cz = (1.0 - t) * Object.LEDVectors[(currentEdge + 3) % 4].Z + t * Object.LEDVectors[currentEdge % 4].Z;
                         Object.States[s].Object.Mesh.Vertices[v + 0].Coordinates = Object.LEDVectors[(currentEdge + 3) % 4];
                         Object.States[s].Object.Mesh.Vertices[v + 1].Coordinates = new Vector3(cx, cy, cz);
                         v += 2;
                     }
                     for (int j = currentEdge - 1; j > lastEdge; j--) {
                         /* square-vertex to square-vertex */
                         Object.States[s].Object.Mesh.Vertices[v + 0].Coordinates = Object.LEDVectors[(j + 3) % 4];
                         Object.States[s].Object.Mesh.Vertices[v + 1].Coordinates = Object.LEDVectors[j % 4];
                         v += 2;
                     }
                     {
                         /* square vertex to last angle */
                         double t = 0.5 + (0.636619772367582 * Object.LEDLastAngle) - lastEdgeFloat;
                         if (t < 0.0) {
                             t = 0.0;
                         } else if (t > 1.0) {
                             t = 1.0;
                         }
                         t = 0.5 * (1.0 - Math.Tan(0.25 * (Math.PI - 2.0 * Math.PI * t)));
                         double lx = (1.0 - t) * Object.LEDVectors[(lastEdge + 3) % 4].X + t * Object.LEDVectors[lastEdge].X;
                         double ly = (1.0 - t) * Object.LEDVectors[(lastEdge + 3) % 4].Y + t * Object.LEDVectors[lastEdge].Y;
                         double lz = (1.0 - t) * Object.LEDVectors[(lastEdge + 3) % 4].Z + t * Object.LEDVectors[lastEdge].Z;
                         Object.States[s].Object.Mesh.Vertices[v + 0].Coordinates = new Vector3(lx, ly, lz);
                         Object.States[s].Object.Mesh.Vertices[v + 1].Coordinates = Object.LEDVectors[lastEdge % 4];
                         v += 2;
                     }
                 }
             }
         }
         for (int j = v; v < 11; v++) {
             Object.States[s].Object.Mesh.Vertices[j].Coordinates = Object.LEDVectors[4];
         }
     }
     // update vertices
     for (int k = 0; k < Object.States[s].Object.Mesh.Vertices.Length; k++) {
         // rotate
         if (rotateX) {
             World.Rotate(ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.X, ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Y, ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Z, Object.RotateXDirection.X, Object.RotateXDirection.Y, Object.RotateXDirection.Z, cosX, sinX);
         }
         if (rotateY) {
             World.Rotate(ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.X, ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Y, ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Z, Object.RotateYDirection.X, Object.RotateYDirection.Y, Object.RotateYDirection.Z, cosY, sinY);
         }
         if (rotateZ) {
             World.Rotate(ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.X, ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Y, ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Z, Object.RotateZDirection.X, Object.RotateZDirection.Y, Object.RotateZDirection.Z, cosZ, sinZ);
         }
         // translate
         if (Overlay & World.CameraRestriction != World.CameraRestrictionMode.NotAvailable) {
             ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.X += Object.States[s].Position.X - Position.X;
             ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Y += Object.States[s].Position.Y - Position.Y;
             ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Z += Object.States[s].Position.Z - Position.Z;
             World.Rotate(ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.X, ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Y, ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Z, World.AbsoluteCameraDirection.X, World.AbsoluteCameraDirection.Y, World.AbsoluteCameraDirection.Z, World.AbsoluteCameraUp.X, World.AbsoluteCameraUp.Y, World.AbsoluteCameraUp.Z, World.AbsoluteCameraSide.X, World.AbsoluteCameraSide.Y, World.AbsoluteCameraSide.Z);
             double dx = -Math.Tan(World.CameraCurrentAlignment.Yaw) - World.CameraCurrentAlignment.Position.X;
             double dy = -Math.Tan(World.CameraCurrentAlignment.Pitch) - World.CameraCurrentAlignment.Position.Y;
             double dz = -World.CameraCurrentAlignment.Position.Z;
             ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.X += World.AbsoluteCameraPosition.X + dx * World.AbsoluteCameraSide.X + dy * World.AbsoluteCameraUp.X + dz * World.AbsoluteCameraDirection.X;
             ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Y += World.AbsoluteCameraPosition.Y + dx * World.AbsoluteCameraSide.Y + dy * World.AbsoluteCameraUp.Y + dz * World.AbsoluteCameraDirection.Y;
             ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Z += World.AbsoluteCameraPosition.Z + dx * World.AbsoluteCameraSide.Z + dy * World.AbsoluteCameraUp.Z + dz * World.AbsoluteCameraDirection.Z;
         } else {
             ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.X += Object.States[s].Position.X;
             ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Y += Object.States[s].Position.Y;
             ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Z += Object.States[s].Position.Z;
             World.Rotate(ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.X, ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Y, ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Z, Direction.X, Direction.Y, Direction.Z, Up.X, Up.Y, Up.Z, Side.X, Side.Y, Side.Z);
             ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.X += Position.X;
             ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Y += Position.Y;
             ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Z += Position.Z;
         }
     }
     // update normals
     for (int k = 0; k < Object.States[s].Object.Mesh.Faces.Length; k++) {
         for (int h = 0; h < Object.States[s].Object.Mesh.Faces[k].Vertices.Length; h++) {
             ObjectManager.Objects[i].Mesh.Faces[k].Vertices[h].Normal = Object.States[s].Object.Mesh.Faces[k].Vertices[h].Normal;
         }
         for (int h = 0; h < Object.States[s].Object.Mesh.Faces[k].Vertices.Length; h++) {
             if (!Object.States[s].Object.Mesh.Faces[k].Vertices[h].Normal.IsZero()) {
                 if (rotateX) {
                     World.Rotate(ref ObjectManager.Objects[i].Mesh.Faces[k].Vertices[h].Normal.X, ref ObjectManager.Objects[i].Mesh.Faces[k].Vertices[h].Normal.Y, ref ObjectManager.Objects[i].Mesh.Faces[k].Vertices[h].Normal.Z, Object.RotateXDirection.X, Object.RotateXDirection.Y, Object.RotateXDirection.Z, cosX, sinX);
                 }
                 if (rotateY) {
                     World.Rotate(ref ObjectManager.Objects[i].Mesh.Faces[k].Vertices[h].Normal.X, ref ObjectManager.Objects[i].Mesh.Faces[k].Vertices[h].Normal.Y, ref ObjectManager.Objects[i].Mesh.Faces[k].Vertices[h].Normal.Z, Object.RotateYDirection.X, Object.RotateYDirection.Y, Object.RotateYDirection.Z, cosY, sinY);
                 }
                 if (rotateZ) {
                     World.Rotate(ref ObjectManager.Objects[i].Mesh.Faces[k].Vertices[h].Normal.X, ref ObjectManager.Objects[i].Mesh.Faces[k].Vertices[h].Normal.Y, ref ObjectManager.Objects[i].Mesh.Faces[k].Vertices[h].Normal.Z, Object.RotateZDirection.X, Object.RotateZDirection.Y, Object.RotateZDirection.Z, cosZ, sinZ);
                 }
                 World.Rotate(ref ObjectManager.Objects[i].Mesh.Faces[k].Vertices[h].Normal.X, ref ObjectManager.Objects[i].Mesh.Faces[k].Vertices[h].Normal.Y, ref ObjectManager.Objects[i].Mesh.Faces[k].Vertices[h].Normal.Z, Direction.X, Direction.Y, Direction.Z, Up.X, Up.Y, Up.Z, Side.X, Side.Y, Side.Z);
             }
         }
         // visibility changed
         if (Show) {
             if (Overlay) {
                 Renderer.ShowObject(i, Renderer.ObjectType.Overlay);
             } else {
                 Renderer.ShowObject(i, Renderer.ObjectType.Dynamic);
             }
         } else {
             Renderer.HideObject(i);
         }
     }
 }
コード例 #34
0
ファイル: ObjectManager.cs プロジェクト: sladen/openbve
 internal static void InitializeAnimatedObject(ref AnimatedObject Object, int StateIndex, bool Overlay, bool Show)
 {
     int i = Object.ObjectIndex;
     Renderer.HideObject(i);
     int t = StateIndex;
     if (t >= 0 && Object.States[t].Object != null) {
         int m = Object.States[t].Object.Mesh.Vertices.Length;
         ObjectManager.Objects[i].Mesh.Vertices = new World.Vertex[m];
         for (int k = 0; k < m; k++) {
             ObjectManager.Objects[i].Mesh.Vertices[k] = Object.States[t].Object.Mesh.Vertices[k];
         }
         m = Object.States[t].Object.Mesh.Faces.Length;
         ObjectManager.Objects[i].Mesh.Faces = new World.MeshFace[m];
         for (int k = 0; k < m; k++) {
             ObjectManager.Objects[i].Mesh.Faces[k].Flags = Object.States[t].Object.Mesh.Faces[k].Flags;
             ObjectManager.Objects[i].Mesh.Faces[k].Material = Object.States[t].Object.Mesh.Faces[k].Material;
             int o = Object.States[t].Object.Mesh.Faces[k].Vertices.Length;
             ObjectManager.Objects[i].Mesh.Faces[k].Vertices = new World.MeshFaceVertex[o];
             for (int h = 0; h < o; h++) {
                 ObjectManager.Objects[i].Mesh.Faces[k].Vertices[h] = Object.States[t].Object.Mesh.Faces[k].Vertices[h];
             }
         }
         ObjectManager.Objects[i].Mesh.Materials = Object.States[t].Object.Mesh.Materials;
     } else {
         ObjectManager.Objects[i] = null;
         ObjectManager.Objects[i] = new StaticObject();
         ObjectManager.Objects[i].Mesh.Faces = new World.MeshFace[] { };
         ObjectManager.Objects[i].Mesh.Materials = new World.MeshMaterial[] { };
         ObjectManager.Objects[i].Mesh.Vertices = new World.Vertex[] { };
     }
     Object.CurrentState = StateIndex;
     if (Show) {
         if (Overlay) {
             Renderer.ShowObject(i, Renderer.ObjectType.Overlay);
         } else {
             Renderer.ShowObject(i, Renderer.ObjectType.Dynamic);
         }
     }
 }
コード例 #35
0
ファイル: ObjectManager.cs プロジェクト: sladen/openbve
 internal static void CreateAnimatedWorldObjects(AnimatedObject[] Prototypes, Vector3 Position, World.Transformation BaseTransformation, World.Transformation AuxTransformation, int SectionIndex, bool AccurateObjectDisposal, double StartingDistance, double EndingDistance, double BlockLength, double TrackPosition, double Brightness, bool DuplicateMaterials)
 {
     bool[] free = new bool[Prototypes.Length];
     bool anyfree = false;
     for (int i = 0; i < Prototypes.Length; i++) {
         free[i] = Prototypes[i].IsFreeOfFunctions();
         if (free[i]) anyfree = true;
     }
     if (anyfree) {
         for (int i = 0; i < Prototypes.Length; i++) {
             if (Prototypes[i].States.Length != 0) {
                 if (free[i]) {
                     Vector3 p = Position;
                     World.Transformation t = new OpenBve.World.Transformation(BaseTransformation, AuxTransformation);
                     Vector3 s = t.X;
                     Vector3 u = t.Y;
                     Vector3 d = t.Z;
                     p.X += Prototypes[i].States[0].Position.X * s.X + Prototypes[i].States[0].Position.Y * u.X + Prototypes[i].States[0].Position.Z * d.X;
                     p.Y += Prototypes[i].States[0].Position.X * s.Y + Prototypes[i].States[0].Position.Y * u.Y + Prototypes[i].States[0].Position.Z * d.Y;
                     p.Z += Prototypes[i].States[0].Position.X * s.Z + Prototypes[i].States[0].Position.Y * u.Z + Prototypes[i].States[0].Position.Z * d.Z;
                     double zOffset = Prototypes[i].States[0].Position.Z;
                     CreateStaticObject(Prototypes[i].States[0].Object, p, BaseTransformation, AuxTransformation, AccurateObjectDisposal, zOffset, StartingDistance, EndingDistance, BlockLength, TrackPosition, Brightness, DuplicateMaterials);
                 } else {
                     CreateAnimatedWorldObject(Prototypes[i], Position, BaseTransformation, AuxTransformation, SectionIndex, TrackPosition, Brightness);
                 }
             }
         }
     } else {
         for (int i = 0; i < Prototypes.Length; i++) {
             if (Prototypes[i].States.Length != 0) {
                 CreateAnimatedWorldObject(Prototypes[i], Position, BaseTransformation, AuxTransformation, SectionIndex, TrackPosition, Brightness);
             }
         }
     }
 }
コード例 #36
0
ファイル: ObjectManager.cs プロジェクト: sladen/openbve
 internal static int CreateAnimatedWorldObject(AnimatedObject Prototype, Vector3 Position, World.Transformation BaseTransformation, World.Transformation AuxTransformation, int SectionIndex, double TrackPosition, double Brightness)
 {
     int a = AnimatedWorldObjectsUsed;
     if (a >= AnimatedWorldObjects.Length) {
         Array.Resize<AnimatedWorldObject>(ref AnimatedWorldObjects, AnimatedWorldObjects.Length << 1);
     }
     World.Transformation FinalTransformation = new World.Transformation(BaseTransformation, AuxTransformation);
     AnimatedWorldObjects[a] = new AnimatedWorldObject();
     AnimatedWorldObjects[a].Position = Position;
     AnimatedWorldObjects[a].Direction = FinalTransformation.Z;
     AnimatedWorldObjects[a].Up = FinalTransformation.Y;
     AnimatedWorldObjects[a].Side = FinalTransformation.X;
     AnimatedWorldObjects[a].Object = Prototype.Clone();
     AnimatedWorldObjects[a].Object.ObjectIndex = CreateDynamicObject();
     AnimatedWorldObjects[a].SectionIndex = SectionIndex;
     AnimatedWorldObjects[a].TrackPosition = TrackPosition;
     for (int i = 0; i < AnimatedWorldObjects[a].Object.States.Length; i++) {
         if (AnimatedWorldObjects[a].Object.States[i].Object == null) {
             AnimatedWorldObjects[a].Object.States[i].Object = new StaticObject();
             AnimatedWorldObjects[a].Object.States[i].Object.Mesh.Faces = new World.MeshFace[] { };
             AnimatedWorldObjects[a].Object.States[i].Object.Mesh.Materials = new World.MeshMaterial[] { };
             AnimatedWorldObjects[a].Object.States[i].Object.Mesh.Vertices = new World.Vertex[] { };
             AnimatedWorldObjects[a].Object.States[i].Object.RendererIndex = -1;
         }
     }
     double r = 0.0;
     for (int i = 0; i < AnimatedWorldObjects[a].Object.States.Length; i++) {
         for (int j = 0; j < AnimatedWorldObjects[a].Object.States[i].Object.Mesh.Materials.Length; j++) {
             AnimatedWorldObjects[a].Object.States[i].Object.Mesh.Materials[j].Color.R = (byte)Math.Round((double)Prototype.States[i].Object.Mesh.Materials[j].Color.R * Brightness);
             AnimatedWorldObjects[a].Object.States[i].Object.Mesh.Materials[j].Color.G = (byte)Math.Round((double)Prototype.States[i].Object.Mesh.Materials[j].Color.G * Brightness);
             AnimatedWorldObjects[a].Object.States[i].Object.Mesh.Materials[j].Color.B = (byte)Math.Round((double)Prototype.States[i].Object.Mesh.Materials[j].Color.B * Brightness);
         }
         for (int j = 0; j < AnimatedWorldObjects[a].Object.States[i].Object.Mesh.Vertices.Length; j++) {
             double x = Prototype.States[i].Object.Mesh.Vertices[j].Coordinates.X;
             double y = Prototype.States[i].Object.Mesh.Vertices[j].Coordinates.Y;
             double z = Prototype.States[i].Object.Mesh.Vertices[j].Coordinates.Z;
             double t = x * x + y * y + z * z;
             if (t > r) r = t;
         }
     }
     AnimatedWorldObjects[a].Radius = Math.Sqrt(r);
     AnimatedWorldObjects[a].Visible = false;
     InitializeAnimatedObject(ref AnimatedWorldObjects[a].Object, 0, false, false);
     AnimatedWorldObjectsUsed++;
     return a;
 }
コード例 #37
0
ファイル: ObjectManager.cs プロジェクト: sladen/openbve
 internal AnimatedObject Clone()
 {
     AnimatedObject Result = new AnimatedObject();
     Result.States = new AnimatedObjectState[this.States.Length];
     for (int i = 0; i < this.States.Length; i++) {
         Result.States[i].Position = this.States[i].Position;
         Result.States[i].Object = CloneObject(this.States[i].Object);
     }
     Result.StateFunction = this.StateFunction == null ? null : this.StateFunction.Clone();
     Result.CurrentState = this.CurrentState;
     Result.TranslateZDirection = this.TranslateZDirection;
     Result.TranslateYDirection = this.TranslateYDirection;
     Result.TranslateXDirection = this.TranslateXDirection;
     Result.TranslateXFunction = this.TranslateXFunction == null ? null : this.TranslateXFunction.Clone();
     Result.TranslateYFunction = this.TranslateYFunction == null ? null : this.TranslateYFunction.Clone();
     Result.TranslateZFunction = this.TranslateZFunction == null ? null : this.TranslateZFunction.Clone();
     Result.RotateXDirection = this.RotateXDirection;
     Result.RotateYDirection = this.RotateYDirection;
     Result.RotateZDirection = this.RotateZDirection;
     Result.RotateXFunction = this.RotateXFunction == null ? null : this.RotateXFunction.Clone();
     Result.RotateXDamping = this.RotateXDamping == null ? null : this.RotateXDamping.Clone();
     Result.RotateYFunction = this.RotateYFunction == null ? null : this.RotateYFunction.Clone();
     Result.RotateYDamping = this.RotateYDamping == null ? null : this.RotateYDamping.Clone();
     Result.RotateZFunction = this.RotateZFunction == null ? null : this.RotateZFunction.Clone();
     Result.RotateZDamping = this.RotateZDamping == null ? null : this.RotateZDamping.Clone();
     Result.TextureShiftXDirection = this.TextureShiftXDirection;
     Result.TextureShiftYDirection = this.TextureShiftYDirection;
     Result.TextureShiftXFunction = this.TextureShiftXFunction == null ? null : this.TextureShiftXFunction.Clone();
     Result.TextureShiftYFunction = this.TextureShiftYFunction == null ? null : this.TextureShiftYFunction.Clone();
     Result.LEDClockwiseWinding = this.LEDClockwiseWinding;
     Result.LEDInitialAngle = this.LEDInitialAngle;
     Result.LEDLastAngle = this.LEDLastAngle;
     if (this.LEDVectors != null) {
         Result.LEDVectors = new Vector3[this.LEDVectors.Length];
         for (int i = 0; i < this.LEDVectors.Length; i++) {
             Result.LEDVectors[i] = this.LEDVectors[i];
         }
     } else {
         Result.LEDVectors = null;
     }
     Result.LEDFunction = this.LEDFunction == null ? null : this.LEDFunction.Clone();
     Result.RefreshRate = this.RefreshRate;
     Result.CurrentTrackZOffset = 0.0;
     Result.SecondsSinceLastUpdate = 0.0;
     Result.ObjectIndex = -1;
     return Result;
 }
コード例 #38
0
ファイル: ObjectManager.cs プロジェクト: leezer3/OpenBVE
		internal static void CreateAnimatedWorldObjects(AnimatedObject[] Prototypes, Vector3 Position, World.Transformation BaseTransformation, World.Transformation AuxTransformation, int SectionIndex, bool AccurateObjectDisposal, double StartingDistance, double EndingDistance, double BlockLength, double TrackPosition, double Brightness, bool DuplicateMaterials) {
			bool[] free = new bool[Prototypes.Length];
			bool anyfree = false;
			bool allfree = true;
			for (int i = 0; i < Prototypes.Length; i++) {
				free[i] = Prototypes[i].IsFreeOfFunctions();
				if (free[i])
				{
					anyfree = true;
				}
				else
				{
					allfree = false;
				}
			}
			if (anyfree && !allfree && Prototypes.Length > 1)
			{
				var X = new Vector3(1.0, 0.0, 0.0);
				var Y = new Vector3(0.0, 1.0, 0.0);
				var Z = new Vector3(0.0, 0.0, 1.0);
				//Optimise a little: If *all* are free of functions, this can safely be converted into a static object without regard to below
				if (AuxTransformation.X != X|| AuxTransformation.Y != Y || AuxTransformation.Z != Z)
				{
					//HACK:
					//An animated object containing a mix of functions and non-functions and using yaw, pitch or roll must not be converted into a mix
					//of animated and static objects, as this causes rounding differences....
					anyfree = false;
				}
			}
			if (anyfree) {
				for (int i = 0; i < Prototypes.Length; i++) {
					if (Prototypes[i].States.Length != 0) {
						if (free[i]) {
							Vector3 p = Position;
							World.Transformation t = new OpenBve.World.Transformation(BaseTransformation, AuxTransformation);
							Vector3 s = t.X;
							Vector3 u = t.Y;
							Vector3 d = t.Z;
							p.X += Prototypes[i].States[0].Position.X * s.X + Prototypes[i].States[0].Position.Y * u.X + Prototypes[i].States[0].Position.Z * d.X;
							p.Y += Prototypes[i].States[0].Position.X * s.Y + Prototypes[i].States[0].Position.Y * u.Y + Prototypes[i].States[0].Position.Z * d.Y;
							p.Z += Prototypes[i].States[0].Position.X * s.Z + Prototypes[i].States[0].Position.Y * u.Z + Prototypes[i].States[0].Position.Z * d.Z;
							double zOffset = Prototypes[i].States[0].Position.Z;
							CreateStaticObject(Prototypes[i].States[0].Object, p, BaseTransformation, AuxTransformation, AccurateObjectDisposal, zOffset, StartingDistance, EndingDistance, BlockLength, TrackPosition, Brightness, DuplicateMaterials);
						} else {
							CreateAnimatedWorldObject(Prototypes[i], Position, BaseTransformation, AuxTransformation, SectionIndex, TrackPosition, Brightness);
						}
					}
				}
			} else {
				for (int i = 0; i < Prototypes.Length; i++) {
					if (Prototypes[i].States.Length != 0) {
						CreateAnimatedWorldObject(Prototypes[i], Position, BaseTransformation, AuxTransformation, SectionIndex, TrackPosition, Brightness);
					}
				}
			}
		}
コード例 #39
0
        public void HandleLevelCollisions(LevelBlock levelBlock, AnimatedObject moveableObject)
        {
            if (levelBlock.IntersectRectangle.Intersects(moveableObject.IntersectRectangle))
            {
                if(moveableObject.PrevPosition.Y > levelBlock.IntersectRectangle.Bottom)
                {
                    moveableObject.Position = moveableObject.PrevPosition;
                    if(moveableObject is Player)
                    {
                        Player.AbortJump();
                    }

                }
                else if (levelBlock.IsAboveLevelObject(moveableObject))
                {
                    //moveableObject.Position.Y = levelBlock.Position.Y - moveableObject.ImageSize.Y;
                    moveableObject.Position = new Vector2(moveableObject.Position.X,
                                                          levelBlock.Position.Y - moveableObject.ImageSize.Y);
                }
                else if(levelBlock.Position.X > moveableObject.Position.X)
                {
                    //moveableObject.Position.X = moveableObject.PrevPosition.X;
                    moveableObject.Position = new Vector2(moveableObject.PrevPosition.X, moveableObject.Position.Y);
                }
                else if (levelBlock.Position.X < moveableObject.Position.X)
                {
                    //moveableObject.position.X = moveableObject.PrevPosition.X;
                    moveableObject.Position = new Vector2(moveableObject.PrevPosition.X, moveableObject.Position.Y);
                }
            }
        }
コード例 #40
0
 internal static void UpdateAnimatedObject(ref AnimatedObject Object, TrainManager.Train Train, int SectionIndex, double TrackPosition, World.Vector3D Position, World.Vector3D Direction, World.Vector3D Up, World.Vector3D Side, bool Overlay, bool UpdateFunctions, bool Show, double TimeElapsed)
 {
     int s = Object.CurrentState;
     int i = Object.ObjectIndex;
     // state change
     if (Object.StateFunction != null & UpdateFunctions) {
         double sd = Object.StateFunction.Perform(Train, Position, TrackPosition, SectionIndex, TimeElapsed);
         int si = (int)Math.Round(sd);
         int sn = Object.States.Length;
         if (si < 0 | si >= sn) si = -1;
         if (s != si) {
             InitializeAnimatedObject(ref Object, si, Overlay, Show);
             s = si;
         }
     }
     if (s == -1) return;
     // translation
     if (Object.TranslateXFunction != null) {
         double x;
         if (UpdateFunctions) {
             x = Object.TranslateXFunction.Perform(Train, Position, TrackPosition, SectionIndex, TimeElapsed);
         } else  {
             x = Object.TranslateXFunction.LastResult;
         }
         double rx = Object.TranslateXDirection.X, ry = Object.TranslateXDirection.Y, rz = Object.TranslateXDirection.Z;
         World.Rotate(ref rx, ref ry, ref rz, Direction.X, Direction.Y, Direction.Z, Up.X, Up.Y, Up.Z, Side.X, Side.Y, Side.Z);
         Position.X += x * rx;
         Position.Y += x * ry;
         Position.Z += x * rz;
     }
     if (Object.TranslateYFunction != null) {
         double y;
         if (UpdateFunctions) {
             y = Object.TranslateYFunction.Perform(Train, Position, TrackPosition, SectionIndex, TimeElapsed);
         } else {
             y = Object.TranslateYFunction.LastResult;
         }
         double rx = Object.TranslateYDirection.X, ry = Object.TranslateYDirection.Y, rz = Object.TranslateYDirection.Z;
         World.Rotate(ref rx, ref ry, ref rz, Direction.X, Direction.Y, Direction.Z, Up.X, Up.Y, Up.Z, Side.X, Side.Y, Side.Z);
         Position.X += y * rx;
         Position.Y += y * ry;
         Position.Z += y * rz;
     }
     if (Object.TranslateZFunction != null) {
         double z;
         if (UpdateFunctions) {
             z = Object.TranslateZFunction.Perform(Train, Position, TrackPosition, SectionIndex, TimeElapsed);
         } else {
             z = Object.TranslateZFunction.LastResult;
         }
         double rx = Object.TranslateZDirection.X, ry = Object.TranslateZDirection.Y, rz = Object.TranslateZDirection.Z;
         World.Rotate(ref rx, ref ry, ref rz, Direction.X, Direction.Y, Direction.Z, Up.X, Up.Y, Up.Z, Side.X, Side.Y, Side.Z);
         Position.X += z * rx;
         Position.Y += z * ry;
         Position.Z += z * rz;
     }
     // rotation
     bool rotateX = Object.RotateXFunction != null;
     bool rotateY = Object.RotateYFunction != null;
     bool rotateZ = Object.RotateZFunction != null;
     double cosX, sinX;
     if (rotateX) {
         double a;
         if (UpdateFunctions) {
             a = Object.RotateXFunction.Perform(Train, Position, TrackPosition, SectionIndex, TimeElapsed);
         } else {
             a = Object.RotateXFunction.LastResult;
         }
         ObjectManager.UpdateDamping(ref Object.RotateXDamping, TimeElapsed, ref a);
         cosX = Math.Cos(a);
         sinX = Math.Sin(a);
     } else {
         cosX = 0.0; sinX = 0.0;
     }
     double cosY, sinY;
     if (rotateY) {
         double a;
         if (UpdateFunctions) {
             a = Object.RotateYFunction.Perform(Train, Position, TrackPosition, SectionIndex, TimeElapsed);
         } else {
             a = Object.RotateYFunction.LastResult;
         }
         ObjectManager.UpdateDamping(ref Object.RotateYDamping, TimeElapsed, ref a);
         cosY = Math.Cos(a);
         sinY = Math.Sin(a);
     } else {
         cosY = 0.0; sinY = 0.0;
     }
     double cosZ, sinZ;
     if (rotateZ) {
         double a;
         if (UpdateFunctions) {
             a = Object.RotateZFunction.Perform(Train, Position, TrackPosition, SectionIndex, TimeElapsed);
         } else {
             a = Object.RotateZFunction.LastResult;
         }
         ObjectManager.UpdateDamping(ref Object.RotateZDamping, TimeElapsed, ref a);
         cosZ = Math.Cos(a);
         sinZ = Math.Sin(a);
     } else {
         cosZ = 0.0; sinZ = 0.0;
     }
     // texture shift
     bool shiftx = Object.TextureShiftXFunction != null;
     bool shifty = Object.TextureShiftYFunction != null;
     if ((shiftx | shifty) & UpdateFunctions) {
         for (int k = 0; k < ObjectManager.Objects[i].Mesh.Vertices.Length; k++) {
             ObjectManager.Objects[i].Mesh.Vertices[k].TextureCoordinates = Object.States[s].Object.Mesh.Vertices[k].TextureCoordinates;
         }
         if (shiftx) {
             double x = Object.TextureShiftXFunction.Perform(Train, Position, TrackPosition, SectionIndex, TimeElapsed);
             x -= Math.Floor(x);
             for (int k = 0; k < ObjectManager.Objects[i].Mesh.Vertices.Length; k++) {
                 ObjectManager.Objects[i].Mesh.Vertices[k].TextureCoordinates.X += (float)(x * Object.TextureShiftXDirection.X);
                 ObjectManager.Objects[i].Mesh.Vertices[k].TextureCoordinates.Y += (float)(x * Object.TextureShiftXDirection.Y);
             }
         }
         if (shifty) {
             double y = Object.TextureShiftYFunction.Perform(Train, Position, TrackPosition, SectionIndex, TimeElapsed);
             y -= Math.Floor(y);
             for (int k = 0; k < ObjectManager.Objects[i].Mesh.Vertices.Length; k++) {
                 ObjectManager.Objects[i].Mesh.Vertices[k].TextureCoordinates.X += (float)(y * Object.TextureShiftYDirection.X);
                 ObjectManager.Objects[i].Mesh.Vertices[k].TextureCoordinates.Y += (float)(y * Object.TextureShiftYDirection.Y);
             }
         }
     }
     // led
     bool led = Object.LEDFunction != null;
     double ledangle;
     if (led) {
         if (UpdateFunctions) {
             ledangle = Object.LEDFunction.Perform(Train, Position, TrackPosition, SectionIndex, TimeElapsed);
         } else {
             ledangle = Object.LEDFunction.LastResult;
         }
     } else {
         ledangle = 0.0;
     }
     // null object
     if (Object.States[s].Object == null) {
         return;
     }
     // initialize vertices
     for (int k = 0; k < Object.States[s].Object.Mesh.Vertices.Length; k++) {
         ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates = Object.States[s].Object.Mesh.Vertices[k].Coordinates;
     }
     // led
     if (led) {
         double max = Object.LEDMaximumAngle;
         for (int j = 0; j < 5; j++) {
             double pos1 = 0.0;
             double pos2 = 1.0;
             switch (j) {
                 case 0:
                     if (ledangle <= -0.5 * Math.PI) {
                         pos1 = 0.5;
                     } else if (ledangle >= 0.5 * Math.PI) {
                         pos1 = 1.0;
                     } else {
                         pos1 = 0.5 * Math.Tan(ledangle - 2.0 * Math.PI) + 0.5;
                         if (pos1 < 0.5) pos1 = 0.5;
                         else if (pos1 > 1.0) pos1 = 1.0;
                     }
                     if (max <= -0.5 * Math.PI) {
                         pos2 = 0.5;
                     } else if (max >= 0.5 * Math.PI) {
                         pos2 = 1.0;
                     } else {
                         pos2 = 0.5 * Math.Tan(max - 2.0 * Math.PI) + 0.5;
                         if (pos2 < 0.5) pos2 = 0.5;
                         else if (pos2 > 1.0) pos2 = 1.0;
                     }
                     break;
                 case 1:
                     if (ledangle <= 0.0) {
                         pos1 = 0.0;
                     } else if (ledangle >= Math.PI) {
                         pos1 = 1.0;
                     } else {
                         pos1 = 0.5 * Math.Tan(ledangle - 0.5 * Math.PI) + 0.5;
                         if (pos1 < 0.0) pos1 = 0.0;
                         else if (pos1 > 1.0) pos1 = 1.0;
                     }
                     if (max <= 0.0) {
                         pos2 = 0.0;
                     } else if (max >= Math.PI) {
                         pos2 = 1.0;
                     } else {
                         pos2 = 0.5 * Math.Tan(max - 0.5 * Math.PI) + 0.5;
                         if (pos2 < 0.0) pos2 = 0.0;
                         else if (pos2 > 1.0) pos2 = 1.0;
                     }
                     break;
                 case 2:
                     if (ledangle <= 0.5 * Math.PI) {
                         pos1 = 0.0;
                     } else if (ledangle >= 1.5 * Math.PI) {
                         pos1 = 1.0;
                     } else {
                         pos1 = 0.5 * Math.Tan(ledangle - Math.PI) + 0.5;
                         if (pos1 < 0.0) pos1 = 0.0;
                         else if (pos1 > 1.0) pos1 = 1.0;
                     }
                     if (max <= 0.5 * Math.PI) {
                         pos2 = 0.0;
                     } else if (max >= 1.5 * Math.PI) {
                         pos2 = 1.0;
                     } else {
                         pos2 = 0.5 * Math.Tan(max - Math.PI) + 0.5;
                         if (pos2 < 0.0) pos2 = 0.0;
                         else if (pos2 > 1.0) pos2 = 1.0;
                     }
                     break;
                 case 3:
                     if (ledangle <= Math.PI) {
                         pos1 = 0.0;
                     } else if (ledangle >= 2.0 * Math.PI) {
                         pos1 = 1.0;
                     } else {
                         pos1 = 0.5 * Math.Tan(ledangle - 1.5 * Math.PI) + 0.5;
                         if (pos1 < 0.0) pos1 = 0.0;
                         else if (pos1 > 1.0) pos1 = 1.0;
                     }
                     if (max <= Math.PI) {
                         pos2 = 0.0;
                     } else if (max >= 2.0 * Math.PI) {
                         pos2 = 1.0;
                     } else {
                         pos2 = 0.5 * Math.Tan(max - 1.5 * Math.PI) + 0.5;
                         if (pos2 < 0.0) pos2 = 0.0;
                         else if (pos2 > 1.0) pos2 = 1.0;
                     }
                     break;
                 case 4:
                     if (ledangle <= 1.5 * Math.PI) {
                         pos1 = 0.0;
                     } else if (ledangle >= 2.5 * Math.PI) {
                         pos1 = 0.5;
                     } else {
                         pos1 = 0.5 * Math.Tan(ledangle - 2.0 * Math.PI) + 0.5;
                         if (pos1 < 0.0) pos1 = 0.0;
                         else if (pos1 > 0.5) pos1 = 0.5;
                     }
                     if (max <= 1.5 * Math.PI) {
                         pos2 = 0.0;
                     } else if (max >= 2.5 * Math.PI) {
                         pos2 = 0.5;
                     } else {
                         pos2 = 0.5 * Math.Tan(max - 2.0 * Math.PI) + 0.5;
                         if (pos2 < 0.0) pos2 = 0.0;
                         else if (pos2 > 0.5) pos2 = 0.5;
                     }
                     break;
             }
             int k = 2 * j + 1;
             double cpos1 = 1.0 - pos1;
             double cpos2 = 1.0 - pos2;
             double x0 = Object.States[s].Object.Mesh.Vertices[k].Coordinates.X;
             double y0 = Object.States[s].Object.Mesh.Vertices[k].Coordinates.Y;
             double z0 = Object.States[s].Object.Mesh.Vertices[k].Coordinates.Z;
             double x1 = Object.States[s].Object.Mesh.Vertices[k + 1].Coordinates.X;
             double y1 = Object.States[s].Object.Mesh.Vertices[k + 1].Coordinates.Y;
             double z1 = Object.States[s].Object.Mesh.Vertices[k + 1].Coordinates.Z;
             if (Object.LEDClockwiseWinding) {
                 ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.X = x0 * cpos1 + x1 * pos1;
                 ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Y = y0 * cpos1 + y1 * pos1;
                 ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Z = z0 * cpos1 + z1 * pos1;
                 ObjectManager.Objects[i].Mesh.Vertices[k + 1].Coordinates.X = x0 * cpos2 + x1 * pos2;
                 ObjectManager.Objects[i].Mesh.Vertices[k + 1].Coordinates.Y = y0 * cpos2 + y1 * pos2;
                 ObjectManager.Objects[i].Mesh.Vertices[k + 1].Coordinates.Z = z0 * cpos2 + z1 * pos2;
             } else {
                 ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.X = x0 * cpos2 + x1 * pos2;
                 ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Y = y0 * cpos2 + y1 * pos2;
                 ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Z = z0 * cpos2 + z1 * pos2;
                 ObjectManager.Objects[i].Mesh.Vertices[k + 1].Coordinates.X = x0 * cpos1 + x1 * pos1;
                 ObjectManager.Objects[i].Mesh.Vertices[k + 1].Coordinates.Y = y0 * cpos1 + y1 * pos1;
                 ObjectManager.Objects[i].Mesh.Vertices[k + 1].Coordinates.Z = z0 * cpos1 + z1 * pos1;
             }
         }
     }
     // update vertices
     for (int k = 0; k < Object.States[s].Object.Mesh.Vertices.Length; k++) {
         // rotate
         if (rotateX) {
             World.Rotate(ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.X, ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Y, ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Z, Object.RotateXDirection.X, Object.RotateXDirection.Y, Object.RotateXDirection.Z, cosX, sinX);
         }
         if (rotateY) {
             World.Rotate(ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.X, ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Y, ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Z, Object.RotateYDirection.X, Object.RotateYDirection.Y, Object.RotateYDirection.Z, cosY, sinY);
         }
         if (rotateZ) {
             World.Rotate(ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.X, ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Y, ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Z, Object.RotateZDirection.X, Object.RotateZDirection.Y, Object.RotateZDirection.Z, cosZ, sinZ);
         }
         // translate
         if (Overlay & World.CameraRestriction != World.CameraRestrictionMode.NotAvailable) {
             ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.X += Object.States[s].Position.X - Position.X;
             ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Y += Object.States[s].Position.Y - Position.Y;
             ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Z += Object.States[s].Position.Z - Position.Z;
             World.Rotate(ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.X, ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Y, ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Z, World.AbsoluteCameraDirection.X, World.AbsoluteCameraDirection.Y, World.AbsoluteCameraDirection.Z, World.AbsoluteCameraUp.X, World.AbsoluteCameraUp.Y, World.AbsoluteCameraUp.Z, World.AbsoluteCameraSide.X, World.AbsoluteCameraSide.Y, World.AbsoluteCameraSide.Z);
             double dx = -Math.Tan(World.CameraCurrentAlignment.Yaw) - World.CameraCurrentAlignment.Position.X;
             double dy = -Math.Tan(World.CameraCurrentAlignment.Pitch) - World.CameraCurrentAlignment.Position.Y;
             double dz = -World.CameraCurrentAlignment.Position.Z;
             ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.X += World.AbsoluteCameraPosition.X + dx * World.AbsoluteCameraSide.X + dy * World.AbsoluteCameraUp.X + dz * World.AbsoluteCameraDirection.X;
             ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Y += World.AbsoluteCameraPosition.Y + dx * World.AbsoluteCameraSide.Y + dy * World.AbsoluteCameraUp.Y + dz * World.AbsoluteCameraDirection.Y;
             ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Z += World.AbsoluteCameraPosition.Z + dx * World.AbsoluteCameraSide.Z + dy * World.AbsoluteCameraUp.Z + dz * World.AbsoluteCameraDirection.Z;
         } else {
             ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.X += Object.States[s].Position.X;
             ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Y += Object.States[s].Position.Y;
             ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Z += Object.States[s].Position.Z;
             World.Rotate(ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.X, ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Y, ref ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Z, Direction.X, Direction.Y, Direction.Z, Up.X, Up.Y, Up.Z, Side.X, Side.Y, Side.Z);
             ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.X += Position.X;
             ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Y += Position.Y;
             ObjectManager.Objects[i].Mesh.Vertices[k].Coordinates.Z += Position.Z;
         }
     }
     // update normals
     for (int k = 0; k < Object.States[s].Object.Mesh.Faces.Length; k++) {
         for (int h = 0; h < Object.States[s].Object.Mesh.Faces[k].Vertices.Length; h++) {
             ObjectManager.Objects[i].Mesh.Faces[k].Vertices[h].Normal = Object.States[s].Object.Mesh.Faces[k].Vertices[h].Normal;
         }
         for (int h = 0; h < Object.States[s].Object.Mesh.Faces[k].Vertices.Length; h++) {
             if (!Object.States[s].Object.Mesh.Faces[k].Vertices[h].Normal.IsZero()) {
                 if (rotateX) {
                     World.Rotate(ref ObjectManager.Objects[i].Mesh.Faces[k].Vertices[h].Normal.X, ref ObjectManager.Objects[i].Mesh.Faces[k].Vertices[h].Normal.Y, ref ObjectManager.Objects[i].Mesh.Faces[k].Vertices[h].Normal.Z, Object.RotateXDirection.X, Object.RotateXDirection.Y, Object.RotateXDirection.Z, cosX, sinX);
                 }
                 if (rotateY) {
                     World.Rotate(ref ObjectManager.Objects[i].Mesh.Faces[k].Vertices[h].Normal.X, ref ObjectManager.Objects[i].Mesh.Faces[k].Vertices[h].Normal.Y, ref ObjectManager.Objects[i].Mesh.Faces[k].Vertices[h].Normal.Z, Object.RotateYDirection.X, Object.RotateYDirection.Y, Object.RotateYDirection.Z, cosY, sinY);
                 }
                 if (rotateZ) {
                     World.Rotate(ref ObjectManager.Objects[i].Mesh.Faces[k].Vertices[h].Normal.X, ref ObjectManager.Objects[i].Mesh.Faces[k].Vertices[h].Normal.Y, ref ObjectManager.Objects[i].Mesh.Faces[k].Vertices[h].Normal.Z, Object.RotateZDirection.X, Object.RotateZDirection.Y, Object.RotateZDirection.Z, cosZ, sinZ);
                 }
                 World.Rotate(ref ObjectManager.Objects[i].Mesh.Faces[k].Vertices[h].Normal.X, ref ObjectManager.Objects[i].Mesh.Faces[k].Vertices[h].Normal.Y, ref ObjectManager.Objects[i].Mesh.Faces[k].Vertices[h].Normal.Z, Direction.X, Direction.Y, Direction.Z, Up.X, Up.Y, Up.Z, Side.X, Side.Y, Side.Z);
             }
         }
         // visibility changed
         if (Show) {
             Renderer.ShowObject(i, Overlay);
         } else {
             Renderer.HideObject(i);
         }
     }
 }
コード例 #41
0
 internal AnimatedObject Clone()
 {
     AnimatedObject Result = new AnimatedObject();
     Result.States = new AnimatedObjectState[this.States.Length];
     for (int i = 0; i < this.States.Length; i++) {
         Result.States[i].Position = this.States[i].Position;
         Result.States[i].Object = CloneObject(this.States[i].Object);
     }
     Result.StateFunction = this.StateFunction == null ? null : this.StateFunction.Clone();
     Result.CurrentState = this.CurrentState;
     Result.TranslateZDirection = this.TranslateZDirection;
     Result.TranslateYDirection = this.TranslateYDirection;
     Result.TranslateXDirection = this.TranslateXDirection;
     Result.TranslateXFunction = this.TranslateXFunction == null ? null : this.TranslateXFunction.Clone();
     Result.TranslateYFunction = this.TranslateYFunction == null ? null : this.TranslateYFunction.Clone();
     Result.TranslateZFunction = this.TranslateZFunction == null ? null : this.TranslateZFunction.Clone();
     Result.RotateXDirection = this.RotateXDirection;
     Result.RotateYDirection = this.RotateYDirection;
     Result.RotateZDirection = this.RotateZDirection;
     Result.RotateXFunction = this.RotateXFunction == null ? null : this.RotateXFunction.Clone();
     Result.RotateXDamping = this.RotateXDamping == null ? null : this.RotateXDamping.Clone();
     Result.RotateYFunction = this.RotateYFunction == null ? null : this.RotateYFunction.Clone();
     Result.RotateYDamping = this.RotateYDamping == null ? null : this.RotateYDamping.Clone();
     Result.RotateZFunction = this.RotateZFunction == null ? null : this.RotateZFunction.Clone();
     Result.RotateZDamping = this.RotateZDamping == null ? null : this.RotateZDamping.Clone();
     Result.TextureShiftXDirection = this.TextureShiftXDirection;
     Result.TextureShiftYDirection = this.TextureShiftYDirection;
     Result.TextureShiftXFunction = this.TextureShiftXFunction == null ? null : this.TextureShiftXFunction.Clone();
     Result.TextureShiftYFunction = this.TextureShiftYFunction == null ? null : this.TextureShiftYFunction.Clone();
     Result.LEDClockwiseWinding = this.LEDClockwiseWinding;
     Result.LEDMaximumAngle = this.LEDMaximumAngle;
     Result.LEDFunction = this.LEDFunction == null ? null : this.LEDFunction.Clone();
     Result.RefreshRate = this.RefreshRate;
     Result.CurrentTrackZOffset = 0.0;
     Result.TimeNextUpdating = 0.0;
     Result.ObjectIndex = -1;
     return Result;
 }
コード例 #42
0
ファイル: ObjectManager.cs プロジェクト: leezer3/OpenBVE
		internal static int CreateAnimatedWorldObject(AnimatedObject Prototype, Vector3 Position, World.Transformation BaseTransformation, World.Transformation AuxTransformation, int SectionIndex, double TrackPosition, double Brightness) {
			int a = AnimatedWorldObjectsUsed;
			if (a >= AnimatedWorldObjects.Length) {
				Array.Resize<AnimatedWorldObject>(ref AnimatedWorldObjects, AnimatedWorldObjects.Length << 1);
			}
			World.Transformation FinalTransformation = new World.Transformation(AuxTransformation, BaseTransformation);
			AnimatedWorldObjects[a] = new AnimatedWorldObject
			{
				Position = Position,
				Direction = FinalTransformation.Z,
				Up = FinalTransformation.Y,
				Side = FinalTransformation.X,
				Object = Prototype.Clone()
			};
			AnimatedWorldObjects[a].Object.ObjectIndex = CreateDynamicObject();
			AnimatedWorldObjects[a].SectionIndex = SectionIndex;
			AnimatedWorldObjects[a].TrackPosition = TrackPosition;
			//Place track followers if required
			if (Prototype.TrackFollowerFunction != null)
			{
				AnimatedWorldObjects[a].FollowsTrack = true;
				AnimatedWorldObjects[a].FrontAxleFollower.TrackPosition = TrackPosition + Prototype.FrontAxlePosition;
				AnimatedWorldObjects[a].RearAxleFollower.TrackPosition = TrackPosition + Prototype.RearAxlePosition;
				AnimatedWorldObjects[a].FrontAxlePosition = Prototype.FrontAxlePosition;
				AnimatedWorldObjects[a].RearAxlePosition = Prototype.RearAxlePosition;
			}
			for (int i = 0; i < AnimatedWorldObjects[a].Object.States.Length; i++) {
				if (AnimatedWorldObjects[a].Object.States[i].Object == null) {
					AnimatedWorldObjects[a].Object.States[i].Object = new StaticObject
					{
						Mesh =
						{
							Faces = new World.MeshFace[] {},
							Materials = new World.MeshMaterial[] {},
							Vertices = new World.Vertex[] {}
						},
						RendererIndex = -1
					};
				}
			}
			double r = 0.0;
			for (int i = 0; i < AnimatedWorldObjects[a].Object.States.Length; i++) {
				for (int j = 0; j < AnimatedWorldObjects[a].Object.States[i].Object.Mesh.Materials.Length; j++) {
					AnimatedWorldObjects[a].Object.States[i].Object.Mesh.Materials[j].Color.R = (byte)Math.Round((double)Prototype.States[i].Object.Mesh.Materials[j].Color.R * Brightness);
					AnimatedWorldObjects[a].Object.States[i].Object.Mesh.Materials[j].Color.G = (byte)Math.Round((double)Prototype.States[i].Object.Mesh.Materials[j].Color.G * Brightness);
					AnimatedWorldObjects[a].Object.States[i].Object.Mesh.Materials[j].Color.B = (byte)Math.Round((double)Prototype.States[i].Object.Mesh.Materials[j].Color.B * Brightness);
				}
				for (int j = 0; j < AnimatedWorldObjects[a].Object.States[i].Object.Mesh.Vertices.Length; j++) {
					double x = Prototype.States[i].Object.Mesh.Vertices[j].Coordinates.X;
					double y = Prototype.States[i].Object.Mesh.Vertices[j].Coordinates.Y;
					double z = Prototype.States[i].Object.Mesh.Vertices[j].Coordinates.Z;
					double t = x * x + y * y + z * z;
					if (t > r) r = t;
				}
			}
			AnimatedWorldObjects[a].Radius = Math.Sqrt(r);
			AnimatedWorldObjects[a].Visible = false;
			InitializeAnimatedObject(ref AnimatedWorldObjects[a].Object, 0, false, false);
			AnimatedWorldObjectsUsed++;
			return a;
		}
コード例 #43
0
ファイル: Player.cs プロジェクト: Rosthouse/JumpNRun
 public override void killObject(AnimatedObject killer)
 {
     lifes--;
     base.killObject(killer);
     if(lifes < 0)
     {
         if(OutOfLives != null)
         {
             OutOfLives(this, new EventArgs());
         }
     }
 }
コード例 #44
0
ファイル: ObjectManager.cs プロジェクト: leezer3/OpenBVE
		internal static double UpdateTrackFollowerScript(ref AnimatedObject Object, bool IsPartOfTrain, TrainManager.Train Train, int CarIndex, int SectionIndex, double TrackPosition, Vector3 Position, Vector3 Direction, Vector3 Up, Vector3 Side, bool Overlay, bool UpdateFunctions, bool Show, double TimeElapsed)
		{
			if (Object.CurrentState == -1)
			{
				return 0;
			}
			double x = 0.0;
			if (Object.TrackFollowerFunction != null)
			{
				if (UpdateFunctions)
				{
					x = Object.TrackFollowerFunction.Perform(Train, CarIndex, Position, TrackPosition, SectionIndex, IsPartOfTrain,
						TimeElapsed, Object.CurrentState);
				}
				else
				{
					x = Object.TrackFollowerFunction.LastResult;
				}
			}
			return x;
		}