public ResourceProvider(Game game) { m_Anim = new AnimationResource(game.GraphicsDevice); m_Art = new ArtMulResource(game.GraphicsDevice); m_Cliloc = new ClilocResource("enu"); m_Effects = new EffectDataResource(); m_Fonts = new FontsResource(game.GraphicsDevice); m_Gumps = new GumpMulResource(game.GraphicsDevice); m_Texmaps = new TexmapResource(game.GraphicsDevice); }
public ResourceProvider(object game) { _anim = new AnimationResource(game); _art = new ArtMulResource(game); _cliloc = new ClilocResource("enu"); _effects = new EffectDataResource(); _fonts = new FontsResource(game); _gumps = new GumpMulResource(game); _texmaps = new TexmapResource(game); }
private bool ResourcesCVS_Filter(object item) { AnimationResource animationRes = item as AnimationResource; if (string.IsNullOrWhiteSpace(Filter)) { return(true); } bool caseReferences = false; if (animationRes.Reference != null && animationRes.Reference.Owner != null) { caseReferences = new Regex(Filter, RegexOptions.IgnoreCase).IsMatch(animationRes.Reference.Name) || new Regex(Filter, RegexOptions.IgnoreCase).IsMatch(animationRes.Reference.Owner.Name); } return(new Regex(Filter, RegexOptions.IgnoreCase).IsMatch(animationRes.TagLine) || caseReferences); }
/// <summary> /// Initializes a new instance of the <see cref="ProgressDialog"/> class, adding it to the specified container. /// </summary> /// <param name="container">The <see cref="IContainer"/> to which the component should be added.</param> public ProgressDialog(IContainer container) { if (container != null) { container.Add(this); } InitializeComponent(); ProgressBarStyle = Enumerations.ProgressBarStyle.ProgressBar; ShowCancelButton = true; MinimizeBox = true; // Set a default animation for XP. if (!NativeMethods.IsWindowsVistaOrLater) { Animation = AnimationResource.GetShellAnimation(ShellAnimation.FlyingPapers); } }
static void BakeAnimation(CrowdManager crowd, Animator animator, GameObject go, bool morton) { // Get bone and animator info List <AnimationResource> animations = crowd.Animations; Transform rootBone = animator.GetBoneTransform(HumanBodyBones.Hips); Transform globalRoot = rootBone.parent.transform; DualQuaternion globalTransform = new DualQuaternion(globalRoot.rotation, globalRoot.position); // Decide texture size uint totalFrame = 0; uint maxFrame = 0; foreach (AnimationResource anim in animations) { MathHelper.GetAnimationTime(anim.clip, morton ? 1 : anim.sampleRate, out float animationTimeStep, out uint keyFrameCnt); totalFrame += keyFrameCnt + ATLAS_PADDING; maxFrame = Math.Max(maxFrame, keyFrameCnt); } // Allocate texture: NUM_TEXTURE * [MAXIMUM_BONE, totalFrame] int size = 1; int foldings = 1; if (morton) { while (size < totalFrame || size < allBones.Count) { size *= 2; } } else { while (foldings * size < totalFrame) { size *= 2; foldings = size / allBones.Count; } } Texture2D[] animTexture = new Texture2D[NUM_TEXTURE]; Color[][] pixels = new Color[NUM_TEXTURE][]; for (int i = 0; i < NUM_TEXTURE; i++) { animTexture[i] = new Texture2D(size, size, TextureFormat.RGBAHalf, false, false) { wrapMode = TextureWrapMode.Mirror }; pixels[i] = animTexture[i].GetPixels(); } // Allocate weapon texture int weaponSize = 1; while (weaponSize * weaponSize < totalFrame) { weaponSize *= 2; } Texture2D[] weaponTexture = new Texture2D[NUM_TEXTURE]; Color[][] weaponPixels = new Color[NUM_TEXTURE][]; for (int i = 0; i < NUM_TEXTURE; i++) { weaponTexture[i] = new Texture2D( weaponSize, weaponSize, TextureFormat.RGBAHalf, false, false) { wrapMode = TextureWrapMode.Mirror }; weaponPixels[i] = weaponTexture[i].GetPixels(); } // Bake for every available animation clip uint frameOffset = 0; for (int animID = 0; animID < animations.Count; animID++) { AnimationResource anim = animations[animID]; AnimationClip clip = anim.clip; MathHelper.GetAnimationTime(clip, morton ? 1 : anim.sampleRate, out float animationTimeStep, out uint keyFrameCnt); for (uint frame = 0; frame < keyFrameCnt + ATLAS_PADDING; frame++) { // Evaluate a frame animator.Play(clip.name, -1, (float)frame / keyFrameCnt); animator.Update(animationTimeStep); FetchBoneMatrices(rootBone, globalTransform); BakeFrame(frameOffset + frame, morton, size, weaponSize, pixels, weaponPixels); } frameOffset += keyFrameCnt + ATLAS_PADDING; } for (int i = 0; i < NUM_TEXTURE; i++) { animTexture[i].SetPixels(pixels[i]); animTexture[i].Apply(); weaponTexture[i].SetPixels(weaponPixels[i]); weaponTexture[i].Apply(); } // Save assets if (!AssetDatabase.IsValidFolder("Assets/Resources/BakedAnimations")) { AssetDatabase.CreateFolder("Assets/Resources", "BakedAnimations"); } string assetPath; for (int i = 0; i < NUM_TEXTURE; i++) { if (morton) { assetPath = string.Format("Assets/Resources/BakedAnimations/{0}_BakedAnimation_Morton{1}.asset", go.name, i); } else { assetPath = string.Format("Assets/Resources/BakedAnimations/{0}_BakedAnimation_XY{1}.asset", go.name, i); } AssetHelper.SaveAsset(animTexture[i], assetPath, true); assetPath = string.Format("Assets/Resources/BakedAnimations/{0}_BakedAnimation_Weapon{1}.asset", go.name, i); AssetHelper.SaveAsset(weaponTexture[i], assetPath, true); } Debug.Log(string.Format("Animation {0} baked to Assets/Resources/BakedAnimations/", go.name)); }
protected override AResource doLoad(string name) { var res = new AnimationResource(manager.GetResource("dummy", "texture")); // todo load correct texture throw new NotImplementedException(); }
private void CompileAnimations() { LogQueue.Put("Compiling animations..."); int id = 0; var CompiledAnimations = new Compiled.Animation[AnimationsIDTable.LastID + 1]; var AnimationNodes = new List <Compiled.Animation.Node>(); foreach (var r in AnimationsIDTable.Items) { int dist = id; while (id < r.ID) { CompiledAnimations[id++] = new Compiled.Animation(); } dist = id - dist; if (dist > 0) { LogQueue.Put("IDs skipped: " + dist); } LogQueue.Put("Compiling [" + r.Path + "]..."); AnimationResource res = null; try { res = new AnimationResource(r.Path); } catch { LogQueue.Put("Animation [" + r.Path + "] not found. ID skipped."); CompiledAnimations[id++] = new Compiled.Animation(); continue; } CompiledAnimations[id].FirstNode = AnimationNodes.Count; CompiledAnimations[id].FramesCount = res.Count; CompiledAnimations[id].NodesPerFrame = res.NodesCount; CompiledAnimations[id].Dependency = (int)res.Dependency; CompiledAnimations[id].FramesPerUnitRatio = res.FramesPerUnitRatio; foreach (var frame in res.Frames) { for (int n = 0; n < frame.Count; n++) { var node = frame[n]; var cnode = new Compiled.Animation.Node(); cnode.Properties = (int)node.Properties; cnode.OffsetX = node.OffsetX; cnode.OffsetY = node.OffsetY; cnode.Angle = node.Angle; AnimationNodes.Add(cnode); } } LogQueue.Put("Animations [" + r.Path + "] compiled with id [" + id + "]."); id++; } LogQueue.Put("Animations compiled."); Directory.CreateDirectory("../Compilation"); using (var w = new BinaryWriter(File.Create("../Compilation/Animations"))) { w.Write(AnimationNodes.Count); foreach (var n in AnimationNodes) { w.Write(n); } w.Write(CompiledAnimations.Length); foreach (var a in CompiledAnimations) { w.Write(a); } } }