Exemplo n.º 1
0
        protected void Awake()
        {
            this.RectTm = base.GetComponent <RectTransform>();
            Transform[] children = TransformExtensions.GetChildren(this.LockedContentRoot.transform, false);
            for (int i = 0; i < children.Length; i++)
            {
                TransformAnimation item = GameObjectExtensions.AddOrGetComponent <TransformAnimation>(children[i].gameObject);
                this.m_lockedContentTransformAnimations.Add(item);
                RectTransform transform = children[i].GetComponent <RectTransform>();
                this.m_lockedContentRectTransforms.Add(item, transform);
                this.m_lockedContentOriginalAnchoredPositions.Add(item, transform.anchoredPosition);
                Image       image   = children[i].GetComponent <Image>();
                MenuOverlay overlay = GameObjectExtensions.AddOrGetComponent <MenuOverlay>(children[i].gameObject);
                overlay.Image = image;
                this.m_lockedContentImages.Add(item, overlay);
            }
            this.m_dummyRectTmObj           = new GameObject("DummyRectTm").AddComponent <RectTransform>();
            this.m_dummyRectTmObj.sizeDelta = Vector2.zero;
            this.m_dummyRectTmObj.SetParent(this.LockedContentRoot.transform, false);
            this.m_dimmableImages.Clear();
            Image component = this.BackgroundCanvas.GetComponent <Image>();

            this.m_dimmableImages.Add(component);
            this.m_dimmableImageOriginalColors.Add(component, component.color);
            Image[] componentsInChildren = this.OpenContentRoot.GetComponentsInChildren <Image>();
            for (int j = 0; j < componentsInChildren.Length; j++)
            {
                this.m_dimmableImages.Add(componentsInChildren[j]);
                this.m_dimmableImageOriginalColors.Add(componentsInChildren[j], componentsInChildren[j].color);
            }
        }
Exemplo n.º 2
0
    private void VisualsAndEffectsUpdate()
    {
        // Tire positions
        SetTirePos(ref m_TireLeft, m_WheelLeftFront, m_WheelLeftBack);
        SetTirePos(ref m_TireRight, m_WheelRightFront, m_WheelRightBack);

        ParticleUpdate();

        // JumpThruster
        TransformAnimation JTanim = m_TankProperties.JumpThrusterAnimation;

        m_JumpThruster.localPosition    = JTanim.GetTranslate(m_JumpThrusterAnimationTimer) + m_JumpThrusterDefaultPos;
        m_JumpThruster.localEulerAngles = JTanim.GetEuler(m_JumpThrusterAnimationTimer);
        m_JumpThruster.localScale       = JTanim.GetScale(m_JumpThrusterAnimationTimer);

        // Camera shake on impact
        m_previousVelocity = m_currentVelocity;
        m_currentVelocity  = Vector3.Distance(Vector3.zero, Rigidbody.velocity);

        float difference = m_previousVelocity - m_currentVelocity;

        if (difference > 10)
        {
            Camera.AddScreenshake(0.02f * difference);
        }
    }
Exemplo n.º 3
0
        // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
        override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            //animatorListener = animator.GetComponent<IAnimatorBehaviour>();
            //if (animatorListener != null) animatorListener.OnStateEnter(Hash.Tag_Unmounting, stateInfo, layerIndex);

            #region OldWay
            animator.SetInteger(Hash.MountSide, 0);                 //remove the side of the mounted **IMPORTANT*** otherwise it will keep trying to dismount

            rider       = animator.GetComponent <Rider3rdPerson>();
            ScaleFactor = rider.Montura.Animal.ScaleFactor;                                     //Get the scale Factor from the Montura

            LeftFoot  = animator.GetBoneTransform(HumanBodyBones.LeftFoot);
            RightFoot = animator.GetBoneTransform(HumanBodyBones.RightFoot);

            MountPoint = rider.Montura.MountPoint;

            BottomPosition = MountPoint.InverseTransformPoint((LeftFoot.position + RightFoot.position) / 2); //Convert it to Local Space
            HipPosition    = MountPoint.InverseTransformPoint(animator.rootPosition);                        //Convert it to Local Space

            Fix = rider.MountTrigger.Adjustment;                                                             //Store the Fix

            transform = animator.transform;
            rider.Start_Dismounting();

            transform.position = rider.Montura.MountPoint.position;
            transform.rotation = rider.Montura.MountPoint.rotation;

            LastRelativeRiderPosition = MountPoint.InverseTransformPoint(transform.position);
            #endregion
        }
Exemplo n.º 4
0
    void Start()
    {
        codeAnimation = new TransformAnimation(this.transform, destination, origin, 1f, Curve.Linear);

        Debug.Log("Press G to play and T to stop the animation inserted by code");
        Debug.Log("Press H to play and Y to stop the animation inserted trough the inspector");
    }
        private void animatedObjectScaling(GameObject go, Vector3 targetLocalScale)
        {
            go.SetActive(true);
            TransformAnimation     animation     = this.m_transformAnimations[go];
            TransformAnimationTask animationTask = new TransformAnimationTask(animation.transform, 0.3f, 0f, TimeUtil.DeltaTimeType.UNSCALED_DELTA_TIME);

            animationTask.scale(targetLocalScale, true, ConfigUi.MENU_EASING_OUT);
            animation.addTask(animationTask);
        }
Exemplo n.º 6
0
        /// <summary>
        /// Plays the Transform Animations for the Selected item
        /// </summary>
        protected IEnumerator PlayTransformAnimation(MItem item, TransformAnimation animTransform)
        {
            if (item != null && animTransform != null)
            {
                isAnimating = true;

                if (animTransform.delay != 0)
                {
                    yield return(new WaitForSeconds(animTransform.delay));                                  //Wait for the Delay
                }
                float elapsedTime = 0;

                Vector3    CurrentPos   = item.transform.localPosition;                                     //Store the Current Position Rotation and Scale
                Quaternion CurrentRot   = item.transform.localRotation;
                Vector3    CurrentScale = item.transform.localScale;

                while ((animTransform.time > 0) && (elapsedTime <= animTransform.time))
                {
                    float resultPos = animTransform.PosCurve.Evaluate(elapsedTime / animTransform.time);               //Evaluation of the Pos curve
                    float resultRot = animTransform.RotCurve.Evaluate(elapsedTime / animTransform.time);               //Evaluation of the Rot curve
                    float resultSca = animTransform.ScaleCurve.Evaluate(elapsedTime / animTransform.time);             //Evaluation of the Scale curve

                    if (animTransform.UsePosition)
                    {
                        item.transform.localRotation = !S_Editor.UseWorld ? item.StartRotation : UseWorldRotation * item.StartRotation;                    //Reset the Rotation for the rotation animations
                        item.transform.localPosition =
                            Vector3.LerpUnclamped(CurrentPos,
                                                  item.StartPosition + transform.InverseTransformDirection(item.transform.TransformDirection(animTransform.Position)),
                                                  resultPos);
                    }

                    if (animTransform.UseRotation)
                    {
                        item.transform.localRotation = item.StartRotation * Quaternion.Euler(animTransform.Rotation * resultRot);
                        if (S_Editor.UseWorld)
                        {
                            item.transform.localRotation = UseWorldRotation * item.transform.localRotation;
                        }
                    }

                    if (animTransform.UseScale)
                    {
                        item.transform.localScale = Vector3.LerpUnclamped(CurrentScale, Vector3.Scale(item.StartScale, animTransform.Scale), resultSca);
                    }

                    elapsedTime += Time.deltaTime;

                    yield return(null);
                }
                EndAnimationTransform(item, animTransform);
            }
            isAnimating = false;
            yield return(null);
        }
Exemplo n.º 7
0
    private void BarrelAnimation()
    {
        float time = m_BarrelAnimationTimer;
        TransformAnimation anim = m_EquippedWeapon.ReloadAnimation;

        // Apply values
        m_Barrel.localPosition    = anim.GetTranslate(time);
        m_Barrel.localEulerAngles = anim.GetEuler(time);
        m_Barrel.localScale       = anim.GetScale(time);


        // Timer
        m_BarrelAnimationTimer += Time.deltaTime;
    }
Exemplo n.º 8
0
        override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            MTools.ResetFloatParameters(animator);

            rider = animator.FindComponent <MRider>();

            rider.SetMountSide(0);                                          //Remove the side of the mounted **IMPORTANT*** otherwise it will keep trying to dismount
            ScaleFactor = rider.Montura.Animal.ScaleFactor;                 //Get the scale Factor from the Montura
            MountPoint  = rider.Montura.MountPoint;

            Fix = rider.MountTrigger.Adjustment;                            //Get the Fix fo the Dismount

            rider.Start_Dismounting();

            LastRelativeRiderPosition = MountPoint.InverseTransformPoint(rider.transform.position); //Get the Relative position of the Rider Position
        }
Exemplo n.º 9
0
        override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            animator.SetInteger(Hash.MountSide, 0);                //remove the side of the mounted ****IMPORTANT
            rider = animator.GetComponent <Rider3rdPerson>();

            transform = animator.transform;

            AnimalScaleFactor = rider.Montura.Animal.ScaleFactor;         //Get the scale Factor from the Montura

            ResetFloatParameters(animator);

            MountTrigger = rider.MountTrigger.transform;

            Fix = rider.MountTrigger.Adjustment;            //Store the Fix

            rider.Start_Mounting();
        }
Exemplo n.º 10
0
        override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            animator.SetInteger(Hash.MountSide, 0);               //Remove the side of the mounted ****IMPORTANT
            rider = animator.GetComponent <MRider>();             //Get the Rider

            alignTime    = rider.AlingMountTrigger;               //Get the Mount Trigger Time
            transform    = animator.transform;                    //Get the transform
            MountTrigger = rider.MountTrigger.transform;          //Get the MountTrigger for the Position

            AnimalScaleFactor = rider.Montura.Animal.ScaleFactor; //Get the Scale Factor on the Mount

            MalbersTools.ResetFloatParameters(animator);          //Set All Float values to their defaut (For all the Float Values on the Controller  while is not riding)

            Fix = rider.MountTrigger.Adjustment;                  //Get the Fix for the Mount Trigger

            rider.Start_Mounting();                               //Call Start Mounting
        }
Exemplo n.º 11
0
        /// <summary>
        /// Set an item tranform values on the Final State of a Transform Animation
        /// </summary>
        protected virtual void EndAnimationTransform(MItem item, TransformAnimation animTransform)
        {
            //if (item == PreviousItem) return; ERROR OF THE ESA TALLA GLitch

            if (item == null)
            {
                return;
            }

            //Set to the Last Value on the Curve POS ROT and SCALE
            if (animTransform.UsePosition)
            {
                item.transform.localPosition = item.StartPosition +
                                               transform.InverseTransformDirection(item.transform.TransformDirection(animTransform.Position * animTransform.PosCurve.Evaluate(1)));
            }


            if (animTransform.UseRotation)
            {
                if (S_Editor.UseWorld)
                {
                    item.transform.localRotation = UseWorldRotation * item.StartRotation * Quaternion.Euler(animTransform.Rotation * animTransform.RotCurve.Evaluate(1));
                }
                else
                {
                    item.transform.localRotation = item.StartRotation * Quaternion.Euler(animTransform.Rotation * animTransform.RotCurve.Evaluate(1));
                }
            }

            if (animTransform.UseScale)
            {
                item.transform.localScale = Vector3.LerpUnclamped(item.StartScale, Vector3.Scale(item.StartScale, animTransform.Scale), animTransform.ScaleCurve.Evaluate(1));
            }
            ;

            isAnimating = false;

            //if (!IsSelectTransformAnimation)                                               //Don't Store if is doing an Idle Animation //Para que no se escale pa abajo o siga subiendo foreva
            //{
            //    LastTCurrentItem.LocalPosition = item.transform.localPosition;              //Store the last local position after the animation
            //    LastTCurrentItem.LocalScale = item.transform.localScale;                //Store the last local Scale after the animation
            //}
        }
Exemplo n.º 12
0
        // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
        override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            animator.SetInteger(Hash.MountSide, 0);                 //remove the side of the mounted **IMPORTANT*** otherwise it will keep trying to dismount

            rider       = animator.GetComponent <Rider3rdPerson>();
            ScaleFactor = rider.Montura.Animal.ScaleFactor;                                     //Get the scale Factor from the Montura

            Vector3 LeftFoot  = animator.GetBoneTransform(HumanBodyBones.LeftFoot).position;
            Vector3 RightFoot = animator.GetBoneTransform(HumanBodyBones.RightFoot).position;

            laspos        = (LeftFoot + RightFoot) / 2;
            MountPosition = animator.rootPosition;

            Fix = rider.MountTrigger.Adjustment;            //Store the Fix

            transform = animator.transform;
            rider.Start_Dismounting();

            hip = animator.GetBoneTransform(HumanBodyBones.Hips);   //Get the Hip Bone
        }
Exemplo n.º 13
0
        override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
        {
            animator.SetInteger(Hash.MountSide, 0);                //remove the side of the mounted ****IMPORTANT

            rider = animator.GetComponent <Rider3rdPerson>();

            transform = animator.transform;
            hip       = animator.GetBoneTransform(HumanBodyBones.Hips);

            AnimalScaleFactor = rider.Montura.Animal.ScaleFactor;         //Get the scale Factor from the Montura

            ResetFloatParameters(animator);

            float CenterDiference = animator.transform.position.y - animator.pivotPosition.y;                                     //Mount Animations have the pivot on the CoG (Center of Gravity)

            transform.position = new Vector3(transform.position.x, transform.position.y + CenterDiference, transform.position.z); //Change the Position of the Rider from Feet to CoG

            MountTrigger = rider.MountTrigger.transform;

            Fix = rider.MountTrigger.Adjustment;            //Store the Fix


            rider.Start_Mounting();
        }
        /// <summary>
        /// Plays a transform Animation
        /// </summary>
        /// <param name="animTransform">The Animation Set to Play</param>
        public virtual void _PlayAnimationTransform(TransformAnimation animTransform)
        {
            if (IndexSelected == -1)
            {
                return;                         //Skip if the Selection is clear
            }
            if (PlayTransformAnimationC != null)
            {
                StopCoroutine(PlayTransformAnimationC);
            }

            //This is used for Finishing the previous animation if a new  animation is being called
            if (LastAnimation && CurrentItem && LastAnimatedItem &&
                CurrentItem == LastAnimatedItem && isAnimating)
            {
                EndAnimationTransform(LastAnimatedItem, LastAnimation);
            }

            PlayTransformAnimationC = PlayTransformAnimation(CurrentItem, animTransform);
            StartCoroutine(PlayTransformAnimationC);

            LastAnimation    = animTransform;           //Store the Last Animation
            LastAnimatedItem = CurrentItem;             //Store the last Item that was animated.
        }
Exemplo n.º 15
0
 protected void Awake()
 {
     this.m_ta      = GameObjectExtensions.AddOrGetComponent <TransformAnimation>(base.gameObject);
     this.m_enabled = this.PLAY_ON_AWAKE;
 }
Exemplo n.º 16
0
        public override void Convert(ResourceLocation source, ResourceLocation dest)
        {
            XmlReader xml = XmlReader.Create(source.GetStream);

            MeshData[] entities = null;
            ModelObject[] modelObjects = null;

            List<Material> materials = new List<Material>();
            List<TapeHelper> targetHelpers = new List<TapeHelper>();

            xml.Read();

            string srcPath = Path.GetDirectoryName(((FileLocation)source).Path);

            int depth;
            int index = 0;

            while (xml.Read())
            {
                if (xml.IsStartElement() && !xml.IsEmptyElement)
                {
                    switch (xml.Name)
                    {
                        case "Info":
                            depth = xml.Depth;
                            while (xml.Read() && xml.Depth > depth)
                            {
                                if (xml.IsStartElement() && !xml.IsEmptyElement)
                                {
                                    if (xml.Name == "MeshCount")
                                    {
                                        int meshCount = int.Parse(xml.ReadString());
                                        entities = new MeshData[meshCount];
                                        modelObjects = new ModelObject[meshCount];
                                    }
                                }
                            }
                            break;
                        case "Material":
                            //XmlReader xmlMats = xml.ReadSubtree();
                            depth = xml.Depth;
                            while (xml.Read() && xml.Depth > depth)
                            {
                                if (xml.IsStartElement() && !xml.IsEmptyElement)
                                {
                                    if (xml.Name == "Slot")
                                    {
                                        materials.Add(ParseMaterial(xml, dest, srcPath));
                                    }
                                }
                            }

                            Material defMat = new Material(null);
                            defMat.Ambient = Material.DefaultMaterial.Ambient;
                            defMat.Diffuse = Material.DefaultMaterial.Diffuse;
                            defMat.Specular = Material.DefaultMaterial.Specular;
                            defMat.Emissive = Material.DefaultMaterial.Emissive;
                            materials.Add(defMat);
                            //materialArray = materials.ToArray();
                            //xmlMats.Close();
                            break;
                        case "Object":
                            string objName = xml.GetAttribute("Name");
                            string objClass = xml.GetAttribute("Class");
                            int oindex = int.Parse(xml.GetAttribute("ID"));

                            switch (objClass)
                            {
                                case "Editable_mesh":
                                    modelObjects[index] = ParseMeshData(xml);

                                    modelObjects[index].Index = oindex;

                                    entities[index] = modelObjects[index].Mesh;
                                    entities[index].Name = objName;

                                    index++;
                                    break;

                                //case "Tape":
                                //    Vector3 pos = ParseTapeTarget(xml);


                                //    break;
                                //case "Targetobject":
                                //    pos = ParseTapeTarget(xml);


                                //    break;
                                case "BoneGeometry":

                                    break;
                            }
                            break;
                    }
                }
            }

            xml.Close();

            for (int i = 0; i < entities.Length; i++)
            {
                bool[] useState = new bool[materials.Count];
                for (int j = 0; j < entities[i].Faces.Length; j++)
                {
                    int mId = entities[i].Faces[j].MaterialIndex;
                    if (mId == -1)
                    {
                        mId = materials.Count - 1;
                        entities[i].Faces[j].MaterialIndex = mId;
                    }
                    useState[mId] = true;
                }

                int[] matIdxShift = new int[materials.Count];
                int shifts = 0;
                List<Material> entMats = new List<Material>();
                for (int j = 0; j < materials.Count; j++)
                {
                    if (useState[j])
                    {
                        entMats.Add(materials[j]);
                        matIdxShift[j] = shifts;
                    }
                    else
                    {
                        shifts++;
                    }
                }

                entities[i].Materials = new Material[entMats.Count][];  //entMats.ToArray();
                entities[i].MaterialAnimation = new MaterialAnimationInstance[entMats.Count];
                
                for (int j = 0; j < entMats.Count; j++)
                {
                    entities[i].Materials[j] = new Material[] { entMats[j] };

                    entities[i].MaterialAnimation[j] = new MaterialAnimationInstance(new MaterialAnimation(1, 1));
                }
                    
                for (int j = 0; j < entities[i].Faces.Length; j++)
                {
                    entities[i].Faces[j].MaterialIndex -= matIdxShift[entities[i].Faces[j].MaterialIndex];
                }
            }

            EditableModel mdl = new EditableModel();
            mdl.Entities = entities;

            #region
            TransformAnimation tranAnim = new TransformAnimation(entities.Length);
            for (int i = 0; i < entities.Length; i++) 
            {
                tranAnim.Nodes[i].Transforms[0] = modelObjects[i].LocalTransform;
            }
            #endregion


            new TransformAnimationInstance(tranAnim);
//#warning impl skeleton
//            mdl.ModelAnimation = new NoAnimation(GraphicsDevice.Instance.Device, trans);

            EditableModel.ToStream(mdl, dest.GetStream);

            mdl.Dispose();
        }
Exemplo n.º 17
0
        /// <summary>
        /// Plays an Enter or Exit Animation for the selector
        /// </summary>
        private IEnumerator PlayAnimation(TransformAnimation animTransform, bool Enter)
        {
            if (Enter)                                                      //Enable the controller and UI GAME OBJECTS
            {
                if (Controller)
                {
                    Controller.gameObject.SetActive(true);
                    if (Controller.FocusedItemIndex == -1)
                    {
                        ItemSelected = null;
                    }
                    Controller.enabled = true;                       //Enable the Controller component after the animation.
                    //   StartCoroutine(CheckItemsNextFrame());           //Position all the Items on the default position
                }
                if (UI)
                {
                    UI.UpdateSelectedItemUI(ItemSelected);
                    UI.gameObject.SetActive(true);
                }
            }
            else
            {
            }


            if (animTransform && Target)
            {
                isAnimating = true;

                LastTarget.StoreTransform(Target);


                if (animTransform.delay > 0)
                {
                    yield return(new WaitForSeconds(animTransform.delay));
                }

                float elapsedTime = 0;

                while ((animTransform.time > 0) && (elapsedTime <= animTransform.time))

                {
                    float resultPos = animTransform.PosCurve.Evaluate(elapsedTime / animTransform.time);               //Evaluation of the Pos curve
                    float resultRot = animTransform.RotCurve.Evaluate(elapsedTime / animTransform.time);               //Evaluation of the Rot curve
                    float resultSca = animTransform.ScaleCurve.Evaluate(elapsedTime / animTransform.time);             //Evaluation of the Scale curve

                    if (animTransform.UsePosition)
                    {
                        Target.localPosition =
                            Vector3.LerpUnclamped(LastTarget.LocalPosition, LastTarget.LocalPosition + animTransform.Position, resultPos);
                    }

                    if (animTransform.UseRotation)
                    {
                        Target.localEulerAngles = Vector3.LerpUnclamped(LastTarget.LocalEulerAngles, animTransform.Rotation, resultRot);
                    }

                    if (animTransform.UseScale)
                    {
                        Target.localScale = Vector3.LerpUnclamped(LastTarget.LocalScale, Vector3.Scale(LastTarget.LocalScale, animTransform.Scale), resultSca);
                    }

                    elapsedTime += Time.deltaTime;

                    yield return(null);
                }

                isAnimating = false;
                LastTarget.RestoreLocalTransform(Target);
            }

            if (!Enter)
            {
                if (Controller)
                {
                    Controller.gameObject.SetActive(false);
                    Controller.enabled = false;                      //Disable the Controller component after the animation.
                }
                if (UI)
                {
                    UI.gameObject.SetActive(false);
                }
            }
            else
            {
                if (UI)
                {
                    UI.gameObject.SetActive(true);
                    UI.UpdateSelectedItemUI(ItemSelected);
                }
            }

            yield return(null);
        }
Exemplo n.º 18
0
        public override void Convert(ResourceLocation source, ResourceLocation dest)
        {
            XmlReader xml = XmlReader.Create(source.GetStream);

            MeshData[]    entities     = null;
            ModelObject[] modelObjects = null;

            List <Material>   materials     = new List <Material>();
            List <TapeHelper> targetHelpers = new List <TapeHelper>();

            xml.Read();

            string srcPath = Path.GetDirectoryName(((FileLocation)source).Path);

            int depth;
            int index = 0;

            while (xml.Read())
            {
                if (xml.IsStartElement() && !xml.IsEmptyElement)
                {
                    switch (xml.Name)
                    {
                    case "Info":
                        depth = xml.Depth;
                        while (xml.Read() && xml.Depth > depth)
                        {
                            if (xml.IsStartElement() && !xml.IsEmptyElement)
                            {
                                if (xml.Name == "MeshCount")
                                {
                                    int meshCount = int.Parse(xml.ReadString());
                                    entities     = new MeshData[meshCount];
                                    modelObjects = new ModelObject[meshCount];
                                }
                            }
                        }
                        break;

                    case "Material":
                        //XmlReader xmlMats = xml.ReadSubtree();
                        depth = xml.Depth;
                        while (xml.Read() && xml.Depth > depth)
                        {
                            if (xml.IsStartElement() && !xml.IsEmptyElement)
                            {
                                if (xml.Name == "Slot")
                                {
                                    materials.Add(ParseMaterial(xml, dest, srcPath));
                                }
                            }
                        }

                        Material defMat = new Material(null);
                        defMat.Ambient  = Material.DefaultMaterial.Ambient;
                        defMat.Diffuse  = Material.DefaultMaterial.Diffuse;
                        defMat.Specular = Material.DefaultMaterial.Specular;
                        defMat.Emissive = Material.DefaultMaterial.Emissive;
                        materials.Add(defMat);
                        //materialArray = materials.ToArray();
                        //xmlMats.Close();
                        break;

                    case "Object":
                        string objName  = xml.GetAttribute("Name");
                        string objClass = xml.GetAttribute("Class");
                        int    oindex   = int.Parse(xml.GetAttribute("ID"));

                        switch (objClass)
                        {
                        case "Editable_mesh":
                            modelObjects[index] = ParseMeshData(xml);

                            modelObjects[index].Index = oindex;

                            entities[index]      = modelObjects[index].Mesh;
                            entities[index].Name = objName;

                            index++;
                            break;

                        //case "Tape":
                        //    Vector3 pos = ParseTapeTarget(xml);


                        //    break;
                        //case "Targetobject":
                        //    pos = ParseTapeTarget(xml);


                        //    break;
                        case "BoneGeometry":

                            break;
                        }
                        break;
                    }
                }
            }

            xml.Close();

            for (int i = 0; i < entities.Length; i++)
            {
                bool[] useState = new bool[materials.Count];
                for (int j = 0; j < entities[i].Faces.Length; j++)
                {
                    int mId = entities[i].Faces[j].MaterialIndex;
                    if (mId == -1)
                    {
                        mId = materials.Count - 1;
                        entities[i].Faces[j].MaterialIndex = mId;
                    }
                    useState[mId] = true;
                }

                int[]           matIdxShift = new int[materials.Count];
                int             shifts      = 0;
                List <Material> entMats     = new List <Material>();
                for (int j = 0; j < materials.Count; j++)
                {
                    if (useState[j])
                    {
                        entMats.Add(materials[j]);
                        matIdxShift[j] = shifts;
                    }
                    else
                    {
                        shifts++;
                    }
                }

                entities[i].Materials         = new Material[entMats.Count][]; //entMats.ToArray();
                entities[i].MaterialAnimation = new MaterialAnimationInstance[entMats.Count];

                for (int j = 0; j < entMats.Count; j++)
                {
                    entities[i].Materials[j] = new Material[] { entMats[j] };

                    entities[i].MaterialAnimation[j] = new MaterialAnimationInstance(new MaterialAnimation(1, 1));
                }

                for (int j = 0; j < entities[i].Faces.Length; j++)
                {
                    entities[i].Faces[j].MaterialIndex -= matIdxShift[entities[i].Faces[j].MaterialIndex];
                }
            }

            EditableModel mdl = new EditableModel();

            mdl.Entities = entities;

            #region
            TransformAnimation tranAnim = new TransformAnimation(entities.Length);
            for (int i = 0; i < entities.Length; i++)
            {
                tranAnim.Nodes[i].Transforms[0] = modelObjects[i].LocalTransform;
            }
            #endregion


            new TransformAnimationInstance(tranAnim);
//#warning impl skeleton
//            mdl.ModelAnimation = new NoAnimation(GraphicsDevice.Instance.Device, trans);

            EditableModel.ToStream(mdl, dest.GetStream);

            mdl.Dispose();
        }
Exemplo n.º 19
0
 private IEnumerator elementPulsatingRoutine(TransformAnimation ta)
 {