public void InitializeAnimator(string cacheDictKey, Vec3f rotation = null)
        {
            if (api.Side != EnumAppSide.Client)
            {
                throw new NotImplementedException("Server side animation system not implemented yet.");
            }

            ICoreClientAPI capi = api as ICoreClientAPI;

            Block block = api.World.BlockAccessor.GetBlock(be.Pos);

            ITexPositionSource texSource = capi.Tesselator.GetTexSource(block);
            MeshData           meshdata;
            IAsset             asset = api.Assets.TryGet(block.Shape.Base.Clone().WithPathPrefixOnce("shapes/").WithPathAppendixOnce(".json"));
            Shape shape = asset.ToObject <Shape>();

            shape.ResolveReferences(api.World.Logger, cacheDictKey);
            BlockEntityAnimationUtil.CacheInvTransforms(shape.Elements);
            shape.ResolveAndLoadJoints();

            capi.Tesselator.TesselateShapeWithJointIds("entity", shape, out meshdata, texSource, null, block.Shape.QuantityElements, block.Shape.SelectiveElements);

            //meshdata.Rgba2 = null;

            InitializeAnimator(cacheDictKey, rotation, shape, capi.Render.UploadMesh(meshdata));
        }
        public void InitializeAnimator(string cacheDictKey, Vec3f rotation = null, Shape shape = null)
        {
            if (api.Side != EnumAppSide.Client)
            {
                throw new NotImplementedException("Server side animation system not implemented yet.");
            }

            ICoreClientAPI capi = api as ICoreClientAPI;

            Block block = api.World.BlockAccessor.GetBlock(be.Pos);

            ITexPositionSource texSource = capi.Tesselator.GetTexSource(block);
            MeshData           meshdata;

            if (shape == null)
            {
                AssetLocation shapePath = block.Shape.Base.Clone().WithPathPrefixOnce("shapes/").WithPathAppendixOnce(".json");
                shape = Shape.TryGet(api, shapePath);
                if (shape == null)
                {
                    api.World.Logger.Error("Shape for block {0} not found or errored, was supposed to be at {1}. Block animations not loaded!", this.be.Block.Code, shapePath);
                    return;
                }
            }

            shape.ResolveReferences(api.World.Logger, cacheDictKey);
            BlockEntityAnimationUtil.CacheInvTransforms(shape.Elements);
            shape.ResolveAndLoadJoints();

            capi.Tesselator.TesselateShapeWithJointIds("entity", shape, out meshdata, texSource, null, block.Shape.QuantityElements, block.Shape.SelectiveElements);

            InitializeAnimator(cacheDictKey, rotation, shape, capi.Render.UploadMesh(meshdata));
        }
        public override void Initialize(ICoreAPI api, JsonObject properties)
        {
            base.Initialize(api, properties);

            animUtil = new BlockEntityAnimationUtil(api, Blockentity);
        }
Esempio n. 4
0
        public override void Initialize(ICoreAPI api)
        {
            base.Initialize(api);

            animUtil = new BlockEntityAnimationUtil(api, this);
        }