Example #1
0
        /// <summary>
        /// Load your graphics content.
        /// </summary>
        protected override void LoadContent()
        {
            var basePath = GetAppDir();

            Dictionary <string, object> load_data = CreatureModule.Utils.LoadCreatureJSONData(basePath + "\\Content\\iceDemonExport_character_data.json");

            curCreature = new CreatureModule.Creature(ref load_data);
            curManager  = new CreatureModule.CreatureManager(curCreature);
            batch       = new SpriteBatch(this.GraphicsDevice);


            curManager.CreateAnimation(ref load_data, "default");

            curAnimationName = "default";
            curManager.SetActiveAnimationName(curAnimationName);
            curManager.SetIsPlaying(true);
            curManager.should_loop = true;

            Texture2D curTexture;

            curTexture = Content.Load <Texture2D>("ice.png");

            curRenderer       = new CreatureRenderer.Renderer(graphics.GraphicsDevice, curManager, ref curTexture);
            curRenderer.world = Matrix.CreateScale(new Vector3(25.0f, 25.0f, 1.0f));
        }
Example #2
0
    public MeshBone GetRootBone()
    {
        CreatureManager cur_manager = creature_renderer.creature_manager;

        CreatureModule.Creature   cur_creature     = cur_manager.target_creature;
        MeshRenderBoneComposition bone_composition = cur_creature.render_composition;
        MeshBone root_bone = bone_composition.root_bone;

        return(root_bone);
    }
    public CreatureManager GetCreatureManager()
    {
        if (HasNoValidAsset())
        {
            Debug.LogError("Input Creature JSON file not set for CreatureAsset: " + name, this);
            ResetState();
            return(null);
        }

        if (creature_manager != null)
        {
            return(creature_manager);
        }

        Dictionary <string, object> load_data = LoadCreatureJsonData();

        CreatureModule.Creature new_creature = new CreatureModule.Creature(ref load_data);
        creature_manager = new CreatureModule.CreatureManager(new_creature);
        creature_manager.CreateAllAnimations(ref load_data);

        var all_animations = creature_manager.animations;

        foreach (KeyValuePair <string, CreatureAnimationAssetData> entry in animation_clip_overides)
        {
            var cur_name           = entry.Key;
            var cur_animation_data = entry.Value;

            if (all_animations.ContainsKey(cur_name))
            {
                // Set Animation Frame Ranges
                all_animations[cur_name].start_time = cur_animation_data.start_frame;
                all_animations[cur_name].end_time   = cur_animation_data.end_frame;

                // Decide if we need to make point caches
                if (cur_animation_data.make_point_cache)
                {
                    var stopWatch = new System.Diagnostics.Stopwatch();
                    stopWatch.Start();

                    creature_manager.MakePointCache(cur_name, cur_animation_data.cache_approximation);

                    stopWatch.Stop();
                    Debug.Log("Creature Point Cache generation took: " + stopWatch.ElapsedMilliseconds);
                }
            }
        }



        is_dirty = true;

        // Load meta data if available
        creature_meta_data = null;
        if (creatureMetaJSON != null)
        {
            creature_meta_data = new CreatureMetaData();
            CreatureModule.Utils.BuildCreatureMetaData(
                creature_meta_data,
                creatureMetaJSON.text,
                physics_assets,
                skin_swap_names);
        }

        return(creature_manager);
    }