예제 #1
0
파일: gxtWorld.cs 프로젝트: Loko/GXT
 public void AddAnimation(gxtAnimation animation)
 {
     animations.Add(animation);
 }
예제 #2
0
파일: gxtWorld.cs 프로젝트: Loko/GXT
 public bool RemoveAnimation(gxtAnimation animation)
 {
     return animations.Remove(animation);
 }
예제 #3
0
 /// <summary>
 /// Adds a new animation to the controller with the given name
 /// </summary>
 /// <param name="name">Name</param>
 /// <param name="clip">Animation Clip</param>
 public void AddAnimation(string name, gxtAnimation animation)
 {
     gxtDebug.Assert(!animations.ContainsKey(name), "Controller Already Has An Animation with the Name: {0}", name);
     gxtDebug.Assert(!animations.ContainsValue(animation), "Controller Already Has This Animation with a Different Name: {0}", name);
     animations.Add(name, animation);
 }
예제 #4
0
 /// <summary>
 /// Determines if the clip is inside the controller
 /// </summary>
 /// <param name="clip">Clip</param>
 /// <param name="animationName">Name of the animation, if found</param>
 /// <returns>If in controller</returns>
 public bool GetAnimationName(gxtAnimation animation, out string animationName)
 {
     bool wasFound = animations.ContainsValue(animation);
     animationName = ANIMATION_NOT_FOUND;
     if (wasFound)
     {
         foreach (KeyValuePair<string, gxtAnimation> pair in animations)
         {
             if (pair.Value.Equals(animation))
             {
                 animationName = pair.Key;
                 break;
             }
         }
     }
     return wasFound;
 }
예제 #5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="animation"></param>
 /// <returns></returns>
 public bool ContainsAnimation(gxtAnimation animation)
 {
     return animations.Values.Contains(animation);
 }
예제 #6
0
 public gxtAnimationPlayerProcess(gxtAnimation animClip)
     : base(true, true, gxtProcess.ANIMATION_TYPE)
 {
     this.animClip = animClip;
 }
예제 #7
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();
            IsMouseVisible = true;
            camera = new gxtCamera(Vector2.Zero, 0.0f, 0.0f, false);
            gxtDisplayManager.Singleton.WindowTitle = "Animation Scene Graph Test";
            sceneGraph = new gxtSceneGraph();
            sceneGraph.Initialize();

            Texture2D grassTexture, metalTexture;
            bool textureLoaded = gxtResourceManager.Singleton.LoadTexture("Textures\\grass", out grassTexture);
            gxtDebug.Assert(textureLoaded, "Texture load failed!");
            textureLoaded = gxtResourceManager.Singleton.LoadTexture("Textures\\scratched_metal", out metalTexture);
            gxtDebug.Assert(textureLoaded, "Texture load failed!");

            parent = new gxtSceneNode();
            Vector2[] rectangleVertices = gxtGeometry.CreateRectangleVertices(150, 100);
            gxtDynamicMesh rectangle = new gxtDynamicMesh(rectangleVertices);
            gxtIMaterial rectangleMaterial = new gxtMaterial(true, Color.Yellow, 0.5f);
            rectangle.Material = rectangleMaterial;
            rectangle.ApplyTexture(grassTexture, gxtTextureCoordinateType.WRAP);
            parent.AttachDrawable(rectangle);

            child = new gxtSceneNode();
            child.Position = new Vector2(37.5f, 55.5f);
            Vector2[] rectangleVertices2 = gxtGeometry.CreateRectangleVertices(75, 175);
            gxtIMaterial rectangleMaterial2 = new gxtMaterial(true, Color.Blue, 1.0f);
            gxtDynamicMesh rectangle2 = new gxtDynamicMesh(rectangleVertices2);
            rectangle2.Material = rectangleMaterial2;
            rectangle2.ApplyTexture(metalTexture, gxtTextureCoordinateType.WRAP);
            child.AttachDrawable(rectangle2);
            parent.AddChild(child);

            sceneGraph.AddNode(parent);

            gxtAnimationPose a0 = new gxtAnimationPose();
            a0.InterpolateUVCoords = true;
            a0.InterpolateColorOverlay = true;
            a0.UVCoordinates = rectangle.GetTextureCoordinates();

            gxtAnimationPose a1 = new gxtAnimationPose();
            a1.InterpolateUVCoords = false;
            a1.InterpolateColorOverlay = true;
            a1.ColorOverlay = Color.Red;
            a1.Translation = new Vector2(-150, -200);

            Vector2[] uvCoordsCopy = rectangle.GetTextureCoordinates();
            for (int i = 0; i < uvCoordsCopy.Length; ++i)
            {
                uvCoordsCopy[i] += new Vector2(-0.75f);
            }
            a1.UVCoordinates = uvCoordsCopy;

            gxtAnimationPose a2 = new gxtAnimationPose();
            a2.Translation = new Vector2(200, -225);
            a2.Rotation = gxtMath.PI_OVER_FOUR;
            a2.InterpolateUVCoords = false;
            Vector2[] uvCoordsCopy2 = rectangle.GetTextureCoordinates();
            for (int i = 0; i < uvCoordsCopy2.Length; ++i)
            {
                uvCoordsCopy2[i] *= (1.0f / 1.5f);
                //uvCoordsCopy2[i] += new Vector2(-3.75f, 0.0f);
            }
            a2.UVCoordinates = uvCoordsCopy2;


            gxtAnimationPose a3 = new gxtAnimationPose();
            a3.Translation = new Vector2(50, 200);
            a3.Rotation = gxtMath.DegreesToRadians(-235);
            a3.Scale = new Vector2(1.85f, 1.75f);

            gxtKeyframe k0 = new gxtKeyframe(a0, 0.0f);
            gxtKeyframe k1 = new gxtKeyframe(a1, 0.4f);
            gxtKeyframe k2 = new gxtKeyframe(a2, 0.65f);
            gxtKeyframe k3 = new gxtKeyframe(a3, 1.0f);


            gxtAnimationClip clip = new gxtAnimationClip(parent, rectangle);
            clip.AddKeyframe(k0);
            clip.AddKeyframe(k1);
            clip.AddKeyframe(k2);
            clip.AddKeyframe(k3);

            animClip = new gxtAnimation(TimeSpan.FromSeconds(5.0), true, true, 1.0f);
            animClip.AddClip(clip);

            animController = new gxtAnimationController();
            animController.AddAnimation("default", animClip);
            //animClip.AddTween();
            /*
            gxtAnimationKeyFrame k3 = new gxtAnimationKeyFrame();
            */

            /*
            parent = new gxtSceneNode();
            //gxtIDrawable rectangleDrawable = new gxtDrawable(Color.Yellow, true, 0.5f);
            gxtRectangle rectangle = new gxtRectangle(150, 100);
            gxtIMaterial rectangleMaterial = new gxtMaterial(true, Color.Yellow, 0.2f);
            rectangle.Material = rectangleMaterial;
            parent.AttachDrawable(rectangle);

            child = new gxtSceneNode();
            //gxtIDrawable childRectDrawable = new gxtDrawable(Color.Blue, true, 0.0f);
            gxtRectangle childRect = new gxtRectangle(75, 175);
            gxtIMaterial childRectangleMaterial = new gxtMaterial(true, new Color(0, 0, 255, 100), 0.0f);
            childRect.Material = childRectangleMaterial;
            child.AttachDrawable(childRect);
            child.Position = new Vector2(37.5f, 55.5f);

            parent.AddChild(child);

            sceneGraph.AddNode(parent);

            initKeyframe = new gxtKeyframe(gxtNodeTransform.Identity, 0.0f);

            gxtNodeTransform midTransform = new gxtNodeTransform();
            midTransform.Translation = new Vector2(-185, -100);
            midTransform.Scale = new Vector2(-1.5f, 1.5f);
            midTransform.Rotation = gxtMath.DegreesToRadians(-25.0f);
            gxtKeyframe midKeyFrame = new gxtKeyframe(midTransform, 0.235f);

            gxtNodeTransform finalPose = new gxtNodeTransform();
            finalPose.Translation = new Vector2(100.0f, -200.0f);
            finalPose.Rotation = gxtMath.DegreesToRadians(90.0f);
            finalKeyframe = new gxtKeyframe(finalPose, 0.6f);

            gxtNodeTransform lastXform = new gxtNodeTransform();
            lastXform.Translation = new Vector2(100.0f, -200.0f);
            lastXform.Rotation = -6.0f * gxtMath.PI;
            lastXform.Scale = new Vector2(0.25f, 1.45f);
            gxtKeyframe lastKeyframe = new gxtKeyframe(lastXform, 0.85f);


            gxtTween tween = new gxtTween(parent);
            tween.AddKeyframe(initKeyframe);
            tween.AddKeyframe(finalKeyframe);
            tween.AddKeyframe(midKeyFrame);
            tween.AddKeyframe(lastKeyframe);


            animClip = new gxtAnimationClip(TimeSpan.FromSeconds(10.0));
            animClip.AddTween(tween);
            animClip.Loop = false;
            animClip.PlaybackRate = 1.0f;

            animController = new gxtAnimationController();
            animController.AddClip("default", animClip);
            animController.Stop("default");
            */

            gxtLog.WriteLineV(gxtVerbosityLevel.INFORMATIONAL, "Window Width: {0}", gxtDisplayManager.Singleton.ResolutionWidth);
            gxtLog.WriteLineV(gxtVerbosityLevel.INFORMATIONAL, "Window Height: {0}", gxtDisplayManager.Singleton.ResolutionHeight);
            //gxtSprite sprite = new gxtSprite(texture);
            //sprite.Depth = 0.0f;
            //sprite.Alpha = 100;
            //manager.Add(sprite);
        }