Exemplo n.º 1
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);
    }
Exemplo n.º 2
0
        public Creature(ref Dictionary<string, object> load_data)
        {
            total_num_pts = 0;
            total_num_indices = 0;
            global_indices = null;
            global_pts = null;
            global_uvs = null;
            render_pts = null;
            render_colours = null;
            render_composition = null;
            uv_swap_packets = new Dictionary<String, List<CreatureUVSwapPacket>>();
            active_uv_swap_actions = new Dictionary<String, int>();
            anchor_point_map = new Dictionary<String, XnaGeometry.Vector2>();
            anchor_points_active = false;

            LoadFromData(ref load_data);
        }
Exemplo n.º 3
0
        public void LoadFromData(ref Dictionary<string, object> load_data)
        {
            // Load points and topology
            Dictionary<string, object> json_mesh = (Dictionary<string, object>)load_data["mesh"];

            global_pts = Utils.ReadFloatArray3DJSON(json_mesh, "points");
            total_num_pts = global_pts.Count / 3;

            global_indices = Utils.ReadIntArrayJSON (json_mesh, "indices");
            total_num_indices = global_indices.Count;

            global_uvs = Utils.ReadFloatArrayJSON (json_mesh, "uvs");

            render_colours = new List<byte>(new byte[total_num_pts * 4]);
            FillRenderColours(255, 255, 255, 255);

            render_pts = new List<float> (new float[global_pts.Count]);

            // Load bones
            MeshBone root_bone = Utils.CreateBones(load_data,
                                                   "skeleton");

            // Load regions
            List<MeshRenderRegion> regions = Utils.CreateRegions(json_mesh,
                                                                 "regions",
                                                                 global_indices,
                                                                 global_pts,
                                                                 global_uvs);

            // Add into composition
            render_composition = new MeshRenderBoneComposition();
            render_composition.setRootBone(root_bone);
            render_composition.getRootBone().computeRestParentTransforms();

            foreach(MeshRenderRegion cur_region in regions) {
                cur_region.setMainBoneKey(root_bone.getKey());
                cur_region.determineMainBone(root_bone);
                render_composition.addRegion(cur_region);
            }

            render_composition.initBoneMap();
            render_composition.initRegionsMap();

            foreach(MeshRenderRegion cur_region in regions) {
                cur_region.initFastNormalWeightMap(ref render_composition.bones_map);
            }

            render_composition.resetToWorldRestPts();

            // Fill up uv swap packets
            uv_swap_packets = Utils.FillSwapUvPacketMap(load_data, "uv_swap_items");

            // Load Anchor Points
            anchor_point_map = Utils.FillAnchorPointMap(load_data, "anchor_points_items");
        }