public AngledGearsBlockRenderer(ICoreClientAPI capi, MechanicalPowerMod mechanicalPowerMod, Block textureSoureBlock, CompositeShape shapeLoc) : base(capi, mechanicalPowerMod) { Vec3f rot = new Vec3f(shapeLoc.rotateX, shapeLoc.rotateY, shapeLoc.rotateZ); MeshData gearboxCageMesh; MeshData gearboxPegMesh; capi.Tesselator.TesselateShape(textureSoureBlock, capi.Assets.TryGet("shapes/block/wood/mechanics/angledgearbox-cage.json").ToObject <Shape>(), out gearboxCageMesh, rot); capi.Tesselator.TesselateShape(textureSoureBlock, capi.Assets.TryGet("shapes/block/wood/mechanics/angledgearbox-peg.json").ToObject <Shape>(), out gearboxPegMesh, rot); // 16 floats matrix, 4 floats light rgbs gearboxPegMesh.CustomFloats = floatsPeg = new CustomMeshDataPartFloat((16 + 4) * 10100) { Instanced = true, InterleaveOffsets = new int[] { 0, 16, 32, 48, 64 }, InterleaveSizes = new int[] { 4, 4, 4, 4, 4 }, InterleaveStride = 16 + 4 * 16, StaticDraw = false, }; gearboxPegMesh.CustomFloats.SetAllocationSize((16 + 4) * 10100); gearboxCageMesh.CustomFloats = floatsCage = floatsPeg.Clone(); this.gearboxPeg = capi.Render.UploadMesh(gearboxPegMesh); this.gearboxCage = capi.Render.UploadMesh(gearboxCageMesh); }
public GenericMechBlockRenderer(ICoreClientAPI capi, MechanicalPowerMod mechanicalPowerMod, Block block) : base(capi, mechanicalPowerMod, block) { this.block = block; MeshData blockMesh; Shape shape = capi.Assets.TryGet(block.Shape.Base.Clone().WithPathPrefix("shapes/") + ".json").ToObject <Shape>(); Vec3f rot = new Vec3f(block.Shape.rotateX, block.Shape.rotateY, block.Shape.rotateZ); capi.Tesselator.TesselateShape(block, shape, out blockMesh, rot); blockMesh.Rgba2 = null; // 16 floats matrix, 4 floats light rgbs blockMesh.CustomFloats = matrixAndLightFloats = new CustomMeshDataPartFloat((16 + 4) * 10100) { Instanced = true, InterleaveOffsets = new int[] { 0, 16, 32, 48, 64 }, InterleaveSizes = new int[] { 4, 4, 4, 4, 4 }, InterleaveStride = 16 + 4 * 16, StaticDraw = false, }; blockMesh.CustomFloats.SetAllocationSize((16 + 4) * 10100); this.blockMeshRef = capi.Render.UploadMesh(blockMesh); }
public FruitRenderer(ICoreClientAPI capi, Item item) { this.capi = capi; this.id = nextID++; CompositeShape shapeLoc = item.Shape; if (item.Attributes != null && item.Attributes["onGround"].AsBool(false)) { onGround = true; } AssetLocation loc = shapeLoc.Base.Clone().WithPathPrefixOnce("shapes/").WithPathAppendixOnce(".json"); Shape shape = capi.Assets.TryGet(loc).ToObject <Shape>(); Vec3f rot = new Vec3f(shapeLoc.rotateX, shapeLoc.rotateY, shapeLoc.rotateZ); capi.Tesselator.TesselateShape(item, shape, out itemMesh, rot, null, shapeLoc.SelectiveElements); //itemMesh.SetVertexFlags(0x8000800); itemMesh.CustomFloats = matrixAndLightFloats = new CustomMeshDataPartFloat((16 + 4) * 10100) { Instanced = true, InterleaveOffsets = new int[] { 0, 16, 32, 48, 64 }, InterleaveSizes = new int[] { 4, 4, 4, 4, 4 }, InterleaveStride = 16 + 4 * 16, StaticDraw = false, }; itemMesh.CustomFloats.SetAllocationSize((16 + 4) * 10100); meshref = capi.Render.UploadMesh(itemMesh); }
public MechNetworkRenderer(ICoreClientAPI capi, MechanicalPowerMod mechanicalPowerMod) { calcs[0] = UpdateGearbox; calcs[1] = UpdateAxle; calcs[2] = UpdateWindmillRotor; this.mechanicalPowerMod = mechanicalPowerMod; this.capi = capi; Block block = capi.World.GetBlock(new AssetLocation("gearbox-wood")); if (block == null) { return; } capi.Event.RegisterRenderer(this, EnumRenderStage.Opaque); capi.Event.ReloadShader += LoadShader; LoadShader(); MeshData gearboxCageMesh; MeshData gearboxPegMesh; MeshData axleMesh; MeshData windmillRotorMesh; capi.Tesselator.TesselateShape(block, capi.Assets.TryGet("shapes/block/wood/angledgearbox-cage.json").ToObject <Shape>(), out gearboxCageMesh); capi.Tesselator.TesselateShape(block, capi.Assets.TryGet("shapes/block/wood/angledgearbox-peg.json").ToObject <Shape>(), out gearboxPegMesh); capi.Tesselator.TesselateShape(block, capi.Assets.TryGet("shapes/block/wood/axle.json").ToObject <Shape>(), out axleMesh); capi.Tesselator.TesselateShape(block, capi.Assets.TryGet("shapes/block/wood/windmillrotor.json").ToObject <Shape>(), out windmillRotorMesh); gearboxPegMesh.Rgba2 = null; gearboxCageMesh.Rgba2 = null; axleMesh.Rgba2 = null; windmillRotorMesh.Rgba2 = null; // 16 floats matrix, 4 floats light rgbs gearboxPegMesh.CustomFloats = floatsPeg = new CustomMeshDataPartFloat((16 + 4) * 10100) { Instanced = true, InterleaveOffsets = new int[] { 0, 16, 32, 48, 64 }, InterleaveSizes = new int[] { 4, 4, 4, 4, 4 }, InterleaveStride = 16 + 4 * 16, StaticDraw = false, }; gearboxPegMesh.CustomFloats.SetAllocationSize((16 + 4) * 10100); gearboxCageMesh.CustomFloats = floatsCage = floatsPeg.Clone(); axleMesh.CustomFloats = floatsAxle = floatsPeg.Clone(); windmillRotorMesh.CustomFloats = floatsWindmillRotor = floatsPeg.Clone(); this.gearboxPeg = capi.Render.UploadMesh(gearboxPegMesh); this.gearboxCage = capi.Render.UploadMesh(gearboxCageMesh); this.axle = capi.Render.UploadMesh(axleMesh); this.windmillRotor = capi.Render.UploadMesh(windmillRotorMesh); }
private CustomMeshDataPartFloat createCustomFloats(int count) { CustomMeshDataPartFloat result = new CustomMeshDataPartFloat(count) { Instanced = true, InterleaveOffsets = new int[] { 0, 16, 32, 48, 64 }, InterleaveSizes = new int[] { 4, 4, 4, 4, 4 }, InterleaveStride = 16 + 4 * 16, StaticDraw = false, }; result.SetAllocationSize(count); return(result); }
public TransmissionBlockRenderer(ICoreClientAPI capi, MechanicalPowerMod mechanicalPowerMod, Block textureSoureBlock, CompositeShape shapeLoc) : base(capi, mechanicalPowerMod) { MeshData blockMesh1; MeshData blockMesh2 = null; AssetLocation loc = shapeLoc.Base.Clone().WithPathPrefixOnce("shapes/").WithPathAppendixOnce(".json"); Shape shape = capi.Assets.TryGet(loc).ToObject <Shape>(); Vec3f rot = new Vec3f(shapeLoc.rotateX, shapeLoc.rotateY, shapeLoc.rotateZ); capi.Tesselator.TesselateShape(textureSoureBlock, shape, out blockMesh1, rot); CompositeShape ovShapeCmp = new CompositeShape() { Base = new AssetLocation("shapes/block/wood/mechanics/transmission-rightgear.json") }; //rot = new Vec3f(ovShapeCmp.rotateX, ovShapeCmp.rotateY, ovShapeCmp.rotateZ); rot = new Vec3f(shapeLoc.rotateX, shapeLoc.rotateY, shapeLoc.rotateZ); Shape ovshape = capi.Assets.TryGet(ovShapeCmp.Base.Clone().WithPathPrefixOnce("shapes/").WithPathAppendixOnce(".json")).ToObject <Shape>(); capi.Tesselator.TesselateShape(textureSoureBlock, ovshape, out blockMesh2, rot); //blockMesh1.Rgba2 = null; //blockMesh2.Rgba2 = null; // 16 floats matrix, 4 floats light rgbs blockMesh1.CustomFloats = matrixAndLightFloats1 = new CustomMeshDataPartFloat((16 + 4) * 10100) { Instanced = true, InterleaveOffsets = new int[] { 0, 16, 32, 48, 64 }, InterleaveSizes = new int[] { 4, 4, 4, 4, 4 }, InterleaveStride = 16 + 4 * 16, StaticDraw = false, }; blockMesh1.CustomFloats.SetAllocationSize((16 + 4) * 10100); blockMesh2.CustomFloats = matrixAndLightFloats2 = new CustomMeshDataPartFloat((16 + 4) * 10100) { Instanced = true, InterleaveOffsets = new int[] { 0, 16, 32, 48, 64 }, InterleaveSizes = new int[] { 4, 4, 4, 4, 4 }, InterleaveStride = 16 + 4 * 16, StaticDraw = false, }; blockMesh2.CustomFloats.SetAllocationSize((16 + 4) * 10100); this.blockMeshRef1 = capi.Render.UploadMesh(blockMesh1); this.blockMeshRef2 = capi.Render.UploadMesh(blockMesh2); }
public CreativeRotorRenderer(ICoreClientAPI capi, MechanicalPowerMod mechanicalPowerMod, Block textureSoureBlock, CompositeShape shapeLoc) : base(capi, mechanicalPowerMod) { MeshData blockMesh1; MeshData blockMesh2 = null; MeshData blockMesh3 = null; MeshData blockMesh4 = null; AssetLocation loc = new AssetLocation("shapes/block/metal/mechanics/creativerotor-axle.json"); Shape shape = capi.Assets.TryGet(loc).ToObject <Shape>(); Vec3f rot = new Vec3f(shapeLoc.rotateX, shapeLoc.rotateY, shapeLoc.rotateZ); capi.Tesselator.TesselateShape(textureSoureBlock, shape, out blockMesh1, rot); rot = new Vec3f(shapeLoc.rotateX, shapeLoc.rotateY, shapeLoc.rotateZ); Shape ovshape = capi.Assets.TryGet(new AssetLocation("shapes/block/metal/mechanics/creativerotor-contra.json")).ToObject <Shape>(); capi.Tesselator.TesselateShape(textureSoureBlock, ovshape, out blockMesh2, rot); Shape ovshape2 = capi.Assets.TryGet(new AssetLocation("shapes/block/metal/mechanics/creativerotor-spinbar.json")).ToObject <Shape>(); capi.Tesselator.TesselateShape(textureSoureBlock, ovshape2, out blockMesh3, rot); Shape ovshape3 = capi.Assets.TryGet(new AssetLocation("shapes/block/metal/mechanics/creativerotor-spinball.json")).ToObject <Shape>(); capi.Tesselator.TesselateShape(textureSoureBlock, ovshape3, out blockMesh4, rot); //blockMesh1.Rgba2 = null; //blockMesh2.Rgba2 = null; //blockMesh3.Rgba2 = null; //blockMesh4.Rgba2 = null; int count = (16 + 4) * 2100; // 16 floats matrix, 4 floats light rgbs blockMesh1.CustomFloats = matrixAndLightFloats1 = createCustomFloats(count); blockMesh2.CustomFloats = matrixAndLightFloats2 = createCustomFloats(count); blockMesh3.CustomFloats = matrixAndLightFloats3 = createCustomFloats(count); blockMesh4.CustomFloats = matrixAndLightFloats4 = createCustomFloats(count); matrixAndLightFloats5 = createCustomFloats(count); this.blockMeshRef1 = capi.Render.UploadMesh(blockMesh1); this.blockMeshRef2 = capi.Render.UploadMesh(blockMesh2); this.blockMeshRef3 = capi.Render.UploadMesh(blockMesh3); this.blockMeshRef4 = capi.Render.UploadMesh(blockMesh4); }
public PulverizerRenderer(ICoreClientAPI capi, MechanicalPowerMod mechanicalPowerMod, Block textureSoureBlock, CompositeShape shapeLoc) : base(capi, mechanicalPowerMod) { MeshData toggleMesh, lPounderMesh, rPounderMesh; // 16 floats matrix, 4 floats light rgbs int count = (16 + 4) * 200; AssetLocation loc = new AssetLocation("shapes/block/wood/mechanics/pulverizer-moving.json"); Shape shape = capi.Assets.TryGet(loc).ToObject <Shape>(); Vec3f rot = new Vec3f(shapeLoc.rotateX, shapeLoc.rotateY + 90F, shapeLoc.rotateZ); capi.Tesselator.TesselateShape(textureSoureBlock, shape, out toggleMesh, rot); toggleMesh.CustomFloats = matrixAndLightFloatsAxle = createCustomFloats(count); toggleMeshref = capi.Render.UploadMesh(toggleMesh); AssetLocation locPounderL = new AssetLocation("shapes/block/wood/mechanics/pulverizer-pounder-l.json"); AssetLocation locPounderR = new AssetLocation("shapes/block/wood/mechanics/pulverizer-pounder-r.json"); Shape shapel = capi.Assets.TryGet(locPounderL).ToObject <Shape>(); Shape shaper = capi.Assets.TryGet(locPounderR).ToObject <Shape>(); texSource = capi.Tesselator.GetTexSource(textureSoureBlock); for (int i = 0; i < metals.Length; i++) { metal = metals[i]; matrixAndLightFloatsLPounder[i] = createCustomFloats(count); matrixAndLightFloatsRPounder[i] = createCustomFloats(count); capi.Tesselator.TesselateShape("pulverizer-pounder-l", shapel, out lPounderMesh, this, rot); capi.Tesselator.TesselateShape("pulverizer-pounder-r", shaper, out rPounderMesh, this, rot); lPounderMesh.CustomFloats = matrixAndLightFloatsLPounder[i]; rPounderMesh.CustomFloats = matrixAndLightFloatsRPounder[i]; lPoundMeshrefs[i] = capi.Render.UploadMesh(lPounderMesh); rPounderMeshrefs[i] = capi.Render.UploadMesh(rPounderMesh); } }
public GenericMechBlockRenderer(ICoreClientAPI capi, MechanicalPowerMod mechanicalPowerMod, Block textureSoureBlock, CompositeShape shapeLoc) : base(capi, mechanicalPowerMod) { MeshData blockMesh; AssetLocation loc = shapeLoc.Base.Clone().WithPathPrefixOnce("shapes/").WithPathAppendixOnce(".json"); Shape shape = capi.Assets.TryGet(loc).ToObject <Shape>(); Vec3f rot = new Vec3f(shapeLoc.rotateX, shapeLoc.rotateY, shapeLoc.rotateZ); capi.Tesselator.TesselateShape(textureSoureBlock, shape, out blockMesh, rot); if (shapeLoc.Overlays != null) { for (int i = 0; i < shapeLoc.Overlays.Length; i++) { MeshData overlayMesh; CompositeShape ovShapeCmp = shapeLoc.Overlays[i]; rot = new Vec3f(ovShapeCmp.rotateX, ovShapeCmp.rotateY, ovShapeCmp.rotateZ); Shape ovshape = capi.Assets.TryGet(ovShapeCmp.Base.Clone().WithPathPrefixOnce("shapes/").WithPathAppendixOnce(".json")).ToObject <Shape>(); capi.Tesselator.TesselateShape(textureSoureBlock, ovshape, out overlayMesh, rot); blockMesh.AddMeshData(overlayMesh); } } //blockMesh.Rgba2 = null; // 16 floats matrix, 4 floats light rgbs blockMesh.CustomFloats = matrixAndLightFloats = new CustomMeshDataPartFloat((16 + 4) * 10100) { Instanced = true, InterleaveOffsets = new int[] { 0, 16, 32, 48, 64 }, InterleaveSizes = new int[] { 4, 4, 4, 4, 4 }, InterleaveStride = 16 + 4 * 16, StaticDraw = false, }; blockMesh.CustomFloats.SetAllocationSize((16 + 4) * 10100); this.blockMeshRef = capi.Render.UploadMesh(blockMesh); }