public override bool OnTesselation(ITerrainMeshPool mesher, ITesselatorAPI tessThreadTesselator) { mat.Identity(); mat.RotateYDeg(block.Shape.rotateY); return(base.OnTesselation(mesher, tessThreadTesselator)); }
public void OnRenderFrame(float deltaTime, EnumRenderStage stage) { IRenderAPI rpi = capi.Render; Vec3d camPos = capi.World.Player.Entity.CameraPos; rpi.GlDisableCullFace(); rpi.GlToggleBlend(true); IStandardShaderProgram prog = rpi.PreparedStandardShader(pos.X, pos.Y, pos.Z); capi.Render.BindTexture2d(capi.BlockTextureAtlas.AtlasTextureIds[0]); prog.DontWarpVertices = 0; prog.AddRenderFlags = 0; prog.ModelMatrix = ModelMat .Identity() .Translate(pos.X - camPos.X + 0.001f, pos.Y - camPos.Y, pos.Z - camPos.Z - 0.001f) .Translate(0f, 1 / 16f, 0f) .Values ; prog.ViewMatrix = rpi.CameraMatrixOriginf; prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; rpi.RenderMesh(potRef); if (!isInOutputSlot) { float origx = GameMath.Sin(capi.World.ElapsedMilliseconds / 300f) * 5 / 16f; float origz = GameMath.Cos(capi.World.ElapsedMilliseconds / 300f) * 5 / 16f; float cookIntensity = GameMath.Clamp((temp - 50) / 50, 0, 1); prog.ModelMatrix = ModelMat .Identity() .Translate(pos.X - camPos.X, pos.Y - camPos.Y, pos.Z - camPos.Z) .Translate(0, 6.5f / 16f, 0) .Translate(-origx, 0, -origz) .RotateX(cookIntensity * GameMath.Sin(capi.World.ElapsedMilliseconds / 50f) / 60) .RotateZ(cookIntensity * GameMath.Sin(capi.World.ElapsedMilliseconds / 50f) / 60) .Translate(origx, 0, origz) .Values ; prog.ViewMatrix = rpi.CameraMatrixOriginf; prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; rpi.RenderMesh(lidRef); } prog.Stop(); }
public void OnRenderFrame(float deltaTime, EnumRenderStage stage) { if (workItemMeshRef == null) { return; } if (stage == EnumRenderStage.AfterFinalComposition) { if (api.World.Player?.InventoryManager?.ActiveHotbarSlot?.Itemstack?.Collectible is ItemHammer) { RenderRecipeOutLine(); } return; } IRenderAPI rpi = api.Render; IClientWorldAccessor worldAccess = api.World; Vec3d camPos = worldAccess.Player.Entity.CameraPos; int temp = (int)ingot.Collectible.GetTemperature(api.World, ingot); Vec4f lightrgbs = worldAccess.BlockAccessor.GetLightRGBs(pos.X, pos.Y, pos.Z); int extraGlow = GameMath.Clamp((temp - 550) / 2, 0, 255); float[] glowColor = ColorUtil.GetIncandescenceColorAsColor4f(temp); glowRgb.R = glowColor[0]; glowRgb.G = glowColor[1]; glowRgb.B = glowColor[2]; glowRgb.A = extraGlow / 255f; rpi.GlDisableCullFace(); IShaderProgram prog = coreMod.anvilShaderProg; prog.Use(); rpi.BindTexture2d(texId); prog.Uniform("rgbaAmbientIn", rpi.AmbientColor); prog.Uniform("rgbaFogIn", rpi.FogColor); prog.Uniform("fogMinIn", rpi.FogMin); prog.Uniform("dontWarpVertices", (int)0); prog.Uniform("addRenderFlags", (int)0); prog.Uniform("fogDensityIn", rpi.FogDensity); prog.Uniform("rgbaTint", ColorUtil.WhiteArgbVec); prog.Uniform("rgbaLightIn", lightrgbs); prog.Uniform("rgbaGlowIn", glowRgb); prog.Uniform("extraGlow", extraGlow); prog.UniformMatrix("modelMatrix", ModelMat .Identity() .Translate(pos.X - camPos.X, pos.Y - camPos.Y, pos.Z - camPos.Z) .Values ); prog.UniformMatrix("viewMatrix", rpi.CameraMatrixOriginf); prog.UniformMatrix("projectionMatrix", rpi.CurrentProjectionMatrix); rpi.RenderMesh(workItemMeshRef); prog.Stop(); }
public void OnRenderFrame(float deltaTime, EnumRenderStage stage) { if (meshref == null) { return; } IRenderAPI rpi = api.Render; Vec3d camPos = api.World.Player.Entity.CameraPos; rpi.GlDisableCullFace(); rpi.GlToggleBlend(true); IStandardShaderProgram prog = rpi.PreparedStandardShader(compassPos.X, compassPos.Y, compassPos.Z); prog.Tex2D = api.BlockTextureAtlas.AtlasTextureIds[0]; // TODO: Decouple from BlockCompass var renderAngle = AngleRad ?? BlockCompass.GetWildSpinAngle(api); prog.ModelMatrix = ModelMat .Identity() .Translate(compassPos.X - camPos.X, compassPos.Y - camPos.Y, compassPos.Z - camPos.Z) .Translate(0.5f, 11f / 16f, 0.5f) .RotateY(renderAngle) .Translate(-0.5f, -11f / 16f, -0.5f) .Values ; prog.ViewMatrix = rpi.CameraMatrixOriginf; prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; rpi.RenderMesh(meshref); prog.Stop(); }
public void OnRenderFrame(float deltaTime, EnumRenderStage stage) { if (voxelHeight == 0) { return; } IStandardShaderProgram prog = api.Render.PreparedStandardShader(pos.X, pos.Y, pos.Z); prog.ExtraGlow = glowLevel; prog.RgbaBlockIn = new Vec4f(1 + glowLevel / 128f, 1 + glowLevel / 128f, 1 + glowLevel / 512f, 1); IRenderAPI rpi = api.Render; Vec3d camPos = api.World.Player.Entity.CameraPos; rpi.BindTexture2d(textureId); prog.ModelMatrix = ModelMat .Identity() .Translate(8 / 16f + pos.X - camPos.X, pos.Y - camPos.Y + voxelHeight / 24f, 8 / 16f + pos.Z - camPos.Z) .Values ; prog.ViewMatrix = rpi.CameraMatrixOriginf; prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; rpi.RenderMesh(cubeModelRef); prog.Stop(); }
private void RenderFallingBlockEntity() { IRenderAPI rapi = capi.Render; rapi.GlDisableCullFace(); rapi.GlToggleBlend(true, EnumBlendMode.Standard); double alpha = accum / GlobalConstants.PhysicsFrameTime; float div = entity.Collided ? 4f : 1.5f; IStandardShaderProgram prog = rapi.PreparedStandardShader((int)entity.Pos.X, (int)(entity.Pos.Y + 0.2), (int)entity.Pos.Z); Vec3d camPos = capi.World.Player.Entity.CameraPos; prog.Tex2D = atlasTextureId; prog.ModelMatrix = ModelMat .Identity() .Translate( prevPos.X * (1 - alpha) + curPos.X * alpha - camPos.X + GameMath.Sin(capi.InWorldEllapsedMilliseconds / 120f + 30) / 20f / div, prevPos.Y * (1 - alpha) + curPos.Y * alpha - camPos.Y, prevPos.Z * (1 - alpha) + curPos.Z * alpha - camPos.Z + GameMath.Cos(capi.InWorldEllapsedMilliseconds / 110f + 20) / 20f / div ) .RotateX(GameMath.Sin(capi.InWorldEllapsedMilliseconds / 100f) / 15f / div) .RotateZ(GameMath.Cos(10 + capi.InWorldEllapsedMilliseconds / 90f) / 15f / div) .Values ; prog.ViewMatrix = rapi.CameraMatrixOriginf; prog.ProjectionMatrix = rapi.CurrentProjectionMatrix; rapi.RenderMesh(meshRef); prog.Stop(); }
public void OnRenderFrame(float deltaTime, EnumRenderStage stage) { if (loadedTexture == null) { return; } IRenderAPI rpi = api.Render; Vec3d camPos = api.World.Player.Entity.CameraPos; rpi.GlDisableCullFace(); rpi.GlToggleBlend(true); IStandardShaderProgram prog = rpi.PreparedStandardShader(pos.X, pos.Y, pos.Z); prog.Tex2D = loadedTexture.TextureId; prog.ModelMatrix = ModelMat .Identity() .Translate(pos.X - camPos.X, pos.Y - camPos.Y, pos.Z - camPos.Z) .Translate(translateX, 0.5625f, translateZ) .RotateY(rotY * GameMath.DEG2RAD) .Scale(0.45f * QuadWidth, 0.45f * QuadHeight, 0.45f * QuadWidth) .Values ; prog.ViewMatrix = rpi.CameraMatrixOriginf; prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; rpi.RenderMesh(quadModelRef); prog.Stop(); }
public void OnRenderFrame(float deltaTime, EnumRenderStage stage) { if (workItemMeshRef == null) { return; } if (stage == EnumRenderStage.AfterFinalComposition) { RenderRecipeOutLine(); return; } IRenderAPI rpi = api.Render; IClientWorldAccessor worldAccess = api.World; Vec3d camPos = worldAccess.Player.Entity.CameraPos; rpi.GlDisableCullFace(); IStandardShaderProgram prog = rpi.PreparedStandardShader(pos.X, pos.Y, pos.Z); rpi.BindTexture2d(texId); prog.ModelMatrix = ModelMat.Identity().Translate(pos.X - camPos.X, pos.Y - camPos.Y, pos.Z - camPos.Z).Values; prog.ViewMatrix = rpi.CameraMatrixOriginf; prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; rpi.RenderMesh(workItemMeshRef); prog.Stop(); }
public void OnRenderFrame(float deltaTime, EnumRenderStage stage) { if (Level <= 0 || TextureName == null) { return; } int voxelY = (int)GameMath.Clamp(Level, 0, fillQuadsByLevel.Length - 1); IRenderAPI rpi = api.Render; IClientWorldAccessor worldAccess = api.World; EntityPos plrPos = worldAccess.Player.Entity.Pos; Vec3d camPos = worldAccess.Player.Entity.CameraPos; rpi.GlDisableCullFace(); IStandardShaderProgram prog = rpi.StandardShader; prog.Use(); prog.RgbaAmbientIn = rpi.AmbientColor; prog.RgbaFogIn = rpi.FogColor; prog.FogMinIn = rpi.FogMin; prog.FogDensityIn = rpi.FogDensity; prog.RgbaTint = ColorUtil.WhiteArgbVec; prog.WaterWave = 0; Vec4f lightrgbs = api.World.BlockAccessor.GetLightRGBs(pos.X, pos.Y, pos.Z); float[] glowColor = ColorUtil.GetIncandescenceColorAsColor4f((int)Temperature); lightrgbs.R += 2 * glowColor[0]; lightrgbs.G += 2 * glowColor[1]; lightrgbs.B += 2 * glowColor[2]; prog.RgbaLightIn = lightrgbs; prog.RgbaBlockIn = ColorUtil.WhiteArgbVec; prog.ExtraGlow = (int)GameMath.Clamp((Temperature - 500) / 4, 0, 255); int texid = api.Render.GetOrLoadTexture(TextureName); Cuboidf rect = fillQuadsByLevel[voxelY]; rpi.BindTexture2d(texid); prog.ModelMatrix = ModelMat .Identity() .Translate(pos.X - camPos.X, pos.Y - camPos.Y, pos.Z - camPos.Z) .Translate(1 - rect.X1 / 16f, 1.01f / 16f + Math.Max(0, Level / 16f - 0.0625f / 3), 1 - rect.Z1 / 16f) .RotateX(90 * GameMath.DEG2RAD) .Scale(0.5f * rect.Width / 16f, 0.5f * rect.Length / 16f, 0.5f) .Translate(-1, -1, 0) .Values ; prog.ViewMatrix = rpi.CameraMatrixOriginf; prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; rpi.RenderMesh(quadModelRefs[voxelY]); prog.Stop(); rpi.GlEnableCullFace(); }
public void OnRenderFrame(float deltaTime, EnumRenderStage stage) { if (workItemMeshRef == null) { return; } if (stage == EnumRenderStage.AfterFinalComposition) { RenderRecipeOutLine(); return; } IRenderAPI rpi = api.Render; IClientWorldAccessor worldAccess = api.World; Vec3d camPos = worldAccess.Player.Entity.CameraPos; EntityPos plrPos = worldAccess.Player.Entity.Pos; int temp = (int)ingot.Collectible.GetTemperature(api.World, ingot); Vec4f lightrgbs = worldAccess.BlockAccessor.GetLightRGBs(pos.X, pos.Y, pos.Z); float[] glowColor = ColorUtil.GetIncandescenceColorAsColor4f(temp); lightrgbs[0] += 2 * glowColor[0]; lightrgbs[1] += 2 * glowColor[1]; lightrgbs[2] += 2 * glowColor[2]; rpi.GlDisableCullFace(); IStandardShaderProgram prog = rpi.StandardShader; prog.Use(); rpi.BindTexture2d(texId); prog.RgbaAmbientIn = rpi.AmbientColor; prog.RgbaFogIn = rpi.FogColor; prog.FogMinIn = rpi.FogMin; prog.DontWarpVertices = 0; prog.AddRenderFlags = 0; prog.FogDensityIn = rpi.FogDensity; prog.RgbaTint = ColorUtil.WhiteArgbVec; prog.RgbaLightIn = lightrgbs; prog.RgbaBlockIn = ColorUtil.WhiteArgbVec; prog.ExtraGlow = GameMath.Clamp((temp - 700) / 2, 0, 255); prog.ModelMatrix = ModelMat .Identity() .Translate(pos.X - camPos.X, pos.Y - camPos.Y, pos.Z - camPos.Z) .Values ; prog.ViewMatrix = rpi.CameraMatrixOriginf; prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; rpi.RenderMesh(workItemMeshRef); prog.Stop(); }
public override void OnRenderGUI(float deltaTime) { base.OnRenderGUI(deltaTime); capi.Render.GlPushMatrix(); if (focused) { capi.Render.GlTranslate(0, 0, 150); } capi.Render.GlRotate(-14, 1, 0, 0); mat.Identity(); mat.RotateXDeg(-14); Vec4f lightRot = mat.TransformVector(lighPos); double pad = GuiElement.scaled(GuiElementItemSlotGridBase.unscaledSlotPadding); capi.Render.CurrentActiveShader.Uniform("lightPosition", new Vec3f(lightRot.X, lightRot.Y, lightRot.Z)); capi.Render.PushScissor(insetSlotBounds); if (curTab == 0) { capi.Render.RenderEntityToGui( deltaTime, capi.World.Player.Entity, insetSlotBounds.renderX + pad - GuiElement.scaled(195) * charZoom + GuiElement.scaled(115 * (1 - charZoom)), insetSlotBounds.renderY + pad - GuiElement.scaled(10 + 30 * (1 - charZoom)), (float)GuiElement.scaled(230), yaw, (float)GuiElement.scaled(330 * charZoom), ColorUtil.WhiteArgb); } else { capi.Render.RenderEntityToGui( deltaTime, capi.World.Player.Entity, insetSlotBounds.renderX + pad - GuiElement.scaled(95), insetSlotBounds.renderY + pad - GuiElement.scaled(35), (float)GuiElement.scaled(230), yaw, (float)GuiElement.scaled(180), ColorUtil.WhiteArgb); } capi.Render.PopScissor(); capi.Render.CurrentActiveShader.Uniform("lightPosition", new Vec3f(1, -1, 0).Normalize()); capi.Render.GlPopMatrix(); }
// Needs to render mash, juice quad and bucket public void OnRenderFrame(float deltaTime, EnumRenderStage stage) { if (mashMeshref == null || mashMeshref.Disposed) { return; } IRenderAPI rpi = api.Render; Vec3d camPos = api.World.Player.Entity.CameraPos; rpi.GlDisableCullFace(); rpi.GlToggleBlend(true); IStandardShaderProgram prog = rpi.StandardShader; prog.Use(); prog.Tex2D = api.BlockTextureAtlas.AtlasTextureIds[0]; prog.DontWarpVertices = 0; prog.AddRenderFlags = 0; prog.RgbaAmbientIn = rpi.AmbientColor; prog.RgbaFogIn = rpi.FogColor; prog.FogMinIn = rpi.FogMin; prog.FogDensityIn = rpi.FogDensity; prog.RgbaTint = ColorUtil.WhiteArgbVec; prog.NormalShaded = 1; prog.ExtraGodray = 0; prog.SsaoAttn = 0; prog.AlphaTest = 0.05f; prog.OverlayOpacity = 0; Vec4f lightrgbs = api.World.BlockAccessor.GetLightRGBs(pos.X, pos.Y, pos.Z); prog.RgbaLightIn = lightrgbs; double squeezeRel = befruitpress.MashSlot.Itemstack?.Attributes?.GetDouble("squeezeRel", 1) ?? 1; prog.ModelMatrix = ModelMat .Identity() .Translate(pos.X - camPos.X, pos.Y - camPos.Y, pos.Z - camPos.Z) .Translate(0, 0.8f, 0) .Scale(1, (float)squeezeRel, 1) .Values ; prog.ViewMatrix = rpi.CameraMatrixOriginf; prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; rpi.RenderMesh(mashMeshref); prog.Stop(); }
public void OnRenderFrame(float deltaTime, EnumRenderStage stage) { if (meshref == null || be.HammerStack == null) { return; } IRenderAPI rpi = api.Render; Vec3d camPos = api.World.Player.Entity.CameraPos; rpi.GlDisableCullFace(); float rotY = be.facing.HorizontalAngleIndex * 90; float offx = be.facing == BlockFacing.NORTH || be.facing == BlockFacing.WEST ? -1 / 16f : 17 / 16f; ModelMat .Identity() .Translate(pos.X - camPos.X, pos.Y - camPos.Y, pos.Z - camPos.Z) .RotateYDeg(rotY) .Translate(offx, 12.5f / 16f, 0.5f) .RotateZ(AngleRad) .Translate(-offx, -12.5f / 16f, -0.5f) .RotateYDeg(-rotY) ; if (stage == EnumRenderStage.Opaque) { IStandardShaderProgram prog = rpi.PreparedStandardShader(pos.X, pos.Y, pos.Z); prog.Tex2D = api.BlockTextureAtlas.AtlasTextureIds[0]; prog.ModelMatrix = ModelMat.Values; prog.ViewMatrix = rpi.CameraMatrixOriginf; prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; rpi.RenderMesh(meshref); prog.Stop(); AngleRad = be.Angle; } else { IRenderAPI rapi = api.Render; shadowMvpMat.Set(rapi.CurrentProjectionMatrix).Mul(rapi.CurrentModelviewMatrix).Mul(ModelMat.Values); rapi.CurrentActiveShader.BindTexture2D("tex2d", api.BlockTextureAtlas.AtlasTextureIds[0], 0); rapi.CurrentActiveShader.UniformMatrix("mvpMatrix", shadowMvpMat.Values); rapi.CurrentActiveShader.Uniform("origin", new Vec3f()); rpi.RenderMesh(meshref); } }
public void OnRenderFrame(float deltaTime, EnumRenderStage stage) { if (workItemMeshRef == null) { return; } if (stage == EnumRenderStage.AfterFinalComposition) { RenderRecipeOutLine(); return; } IRenderAPI rpi = api.Render; IClientWorldAccessor worldAccess = api.World; Vec3d camPos = worldAccess.Player.Entity.CameraPos; EntityPos plrPos = worldAccess.Player.Entity.Pos; rpi.GlDisableCullFace(); IStandardShaderProgram prog = rpi.StandardShader; prog.Use(); prog.ExtraGlow = 0; prog.RgbaAmbientIn = rpi.AmbientColor; prog.RgbaFogIn = rpi.FogColor; prog.FogMinIn = rpi.FogMin; prog.FogDensityIn = rpi.FogDensity; prog.RgbaTint = ColorUtil.WhiteArgbVec; prog.WaterWave = 0; Vec4f lightrgbs = api.World.BlockAccessor.GetLightRGBs(pos.X, pos.Y, pos.Z); prog.RgbaLightIn = lightrgbs; prog.RgbaBlockIn = ColorUtil.WhiteArgbVec; rpi.BindTexture2d(texId); prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; prog.ViewMatrix = rpi.CameraMatrixOriginf; prog.ModelMatrix = ModelMat.Identity().Translate(pos.X - camPos.X, pos.Y - camPos.Y, pos.Z - camPos.Z).Values; rpi.RenderMesh(workItemMeshRef); prog.Stop(); }
// KalmanCorrectf is called for correcting the predict of the pre-state(first update for every iteration) public void KalmanCorrectf(Matrixf measurement) { // update the output vector(measurement result) if (measurement.rows != zf.rows || measurement.columns != zf.columns) { throw new ArgumentException("Can not update the measurement with different rows or columns.", nameof(measurement)); } else { zf = measurement; } // compute the kalman gain and correct the discrete state and estimate uncertainty Kf = Matrixf.Mul(Matrixf.Mul(Pf, Matrixf.Transpose(Hf)), Matrixf.Inverse(Matrixf.Mul(Matrixf.Mul(Hf, Pf), Matrixf.Transpose(Hf)) + Rf)); xf = xf + Matrixf.Mul(Kf, (zf - Matrixf.Mul(Hf, xf))); Pf = Matrixf.Mul(Matrixf.Mul((Matrixf.Identity(xf.rows, xf.rows) - Matrixf.Mul(Kf, Hf)), Pf), Matrixf.Transpose(Matrixf.Identity(xf.rows, xf.rows) - Matrixf.Mul(Kf, Hf))) + Matrixf.Mul(Matrixf.Mul(Kf, Rf), Matrixf.Transpose(Kf)); }
public virtual void OnRenderFrame(float deltaTime, EnumRenderStage stage) { if (loadedTexture == null) { return; } if (!api.Render.DefaultFrustumCuller.SphereInFrustum(pos.X + 0.5, pos.Y + 0.5, pos.Z + 0.5, 1)) { return; } IRenderAPI rpi = api.Render; Vec3d camPos = api.World.Player.Entity.CameraPos; rpi.GlDisableCullFace(); rpi.GlToggleBlend(true, EnumBlendMode.PremultipliedAlpha); IStandardShaderProgram prog = rpi.PreparedStandardShader(pos.X, pos.Y, pos.Z); prog.Tex2D = loadedTexture.TextureId; prog.NormalShaded = 0; prog.ModelMatrix = ModelMat .Identity() .Translate(pos.X - camPos.X, pos.Y - camPos.Y, pos.Z - camPos.Z) .Translate(translateX, translateY, translateZ) .RotateY(rotY * GameMath.DEG2RAD) .Translate(offsetX, offsetY, offsetZ) .Scale(0.45f * QuadWidth, 0.45f * QuadHeight, 0.45f * QuadWidth) .Values ; prog.ViewMatrix = rpi.CameraMatrixOriginf; prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; prog.NormalShaded = 0; prog.ExtraGodray = 0; prog.SsaoAttn = 0; prog.AlphaTest = 0.05f; prog.OverlayOpacity = 0; rpi.RenderMesh(quadModelRef); prog.Stop(); rpi.GlToggleBlend(true, EnumBlendMode.Standard); }
public void OnRenderFrame(float deltaTime, EnumRenderStage stage) { if (MeshRefPerChunk == null) { return; } if (stage != EnumRenderStage.Opaque) { return; } IRenderAPI rpi = capi.Render; IClientWorldAccessor worldAccess = capi.World; Vec3d camPos = worldAccess.Player.Entity.CameraPos; rpi.GLEnableDepthTest(); rpi.GlEnableCullFace(); //IStandardShaderProgram prog = rpi.StandardShader; IStandardShaderProgram prog = rpi.PreparedStandardShader(0, 0, 0); prog.Use(); AssetLocation wireTexName = new AssetLocation("block/metal/plate/lead.png"); int texid = capi.Render.GetOrLoadTexture(wireTexName); rpi.BindTexture2d(texid); prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; prog.ViewMatrix = rpi.CameraMatrixOriginf; prog.ModelMatrix = ModelMat.Values; foreach (KeyValuePair <Vec3i, MeshRef> mesh in MeshRefPerChunk) { //worldAccess.BlockAccessor.GetLightRGBs() Vec3d offset = new Vec3d(mesh.Key.X * chunksize, mesh.Key.Y * chunksize, mesh.Key.Z * chunksize); prog.ModelMatrix = ModelMat.Identity().Translate(offset.X - camPos.X, offset.Y - camPos.Y, offset.Z - camPos.Z).Values; rpi.RenderMesh(mesh.Value); } prog.Stop(); }
public void OnRenderFrame(float deltaTime, EnumRenderStage stage) { if (meshref == null || !ShouldRender) { return; } IRenderAPI rpi = api.Render; Vec3d camPos = api.World.Player.Entity.CameraPos; rpi.GlDisableCullFace(); rpi.GlToggleBlend(true); IStandardShaderProgram prog = rpi.PreparedStandardShader(pos.X, pos.Y, pos.Z); prog.Tex2D = api.BlockTextureAtlas.AtlasTextureIds[0]; prog.ModelMatrix = ModelMat .Identity() .Translate(pos.X - camPos.X, pos.Y - camPos.Y, pos.Z - camPos.Z) .Translate(0.5f, 11f / 16f, 0.5f) .RotateY(AngleRad) .Translate(-0.5f, 0, -0.5f) .Values ; prog.ViewMatrix = rpi.CameraMatrixOriginf; prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; rpi.RenderMesh(meshref); prog.Stop(); if (ShouldRotateManual) { AngleRad += deltaTime * 40 * GameMath.DEG2RAD; } if (ShouldRotateAutomated) { AngleRad = mechPowerPart.AngleRad; } }
public void OnRenderFrame(float deltaTime, EnumRenderStage stage) { if (circuitMeshRef == null) { return; } timer = (timer + deltaTime) % period; IRenderAPI rpi = capi.Render; IClientWorldAccessor worldAccess = capi.World; Vec3d camPos = worldAccess.Player.Entity.CameraPos; rpi.GlDisableCullFace(); IStandardShaderProgram prog = capi.Render.PreparedStandardShader(pos.X, pos.Y, pos.Z); rpi.BindTexture2d(texId); prog.ModelMatrix = ModelMat .Identity() .Translate(pos.X - camPos.X, pos.Y - camPos.Y, pos.Z - camPos.Z) .Values; prog.ViewMatrix = rpi.CameraMatrixOriginf; prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; prog.RgbaGlowIn = new Vec4f(1f, 1f, 1f, 1); foreach (var item in wireMeshesRefs) { prog.ExtraGlow = networkStates.ContainsKey(item.Key)? (networkStates[item.Key] * 100 / 15):0; rpi.RenderMesh(item.Value); } prog.ExtraGlow = 0; rpi.RenderMesh(circuitMeshRef); prog.Stop(); rpi.GlEnableCullFace(); }
private void RenderFallingBlockEntity(float x, float y, float z) { IRenderAPI rapi = capi.Render; rapi.GlDisableCullFace(); rapi.GlToggleBlend(true, EnumBlendMode.Standard); IStandardShaderProgram prog = rapi.PreparedStandardShader((int)entity.Pos.X, (int)entity.Pos.Y, (int)entity.Pos.Z); Vec3d camPos = capi.World.Player.Entity.CameraPos; prog.Tex2D = atlasTextureId; prog.ModelMatrix = ModelMat .Identity() .Translate(x - camPos.X, y - camPos.Y, z - camPos.Z) .Values ; prog.ViewMatrix = rapi.CameraMatrixOriginf; prog.ProjectionMatrix = rapi.CurrentProjectionMatrix; rapi.RenderMesh(meshRef); prog.Stop(); }
public virtual void OnRenderFrame(float deltaTime, EnumRenderStage stage) { if (loadedTexture == null) { return; } IRenderAPI rpi = api.Render; Vec3d camPos = api.World.Player.Entity.CameraPos; rpi.GlDisableCullFace(); rpi.GlToggleBlend(true, EnumBlendMode.PremultipliedAlpha); IStandardShaderProgram prog = rpi.PreparedStandardShader(pos.X, pos.Y, pos.Z); prog.Tex2D = loadedTexture.TextureId; prog.ModelMatrix = ModelMat .Identity() .Translate(pos.X - camPos.X, pos.Y - camPos.Y, pos.Z - camPos.Z) .Values ; prog.ViewMatrix = rpi.CameraMatrixOriginf; prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; prog.NormalShaded = 0; prog.ExtraGodray = 0; prog.SsaoAttn = 0; prog.AlphaTest = 0.05f; prog.OverlayOpacity = 0; rpi.RenderMesh(quadModelRef); prog.Stop(); rpi.GlToggleBlend(true, EnumBlendMode.Standard); }
public void OnRenderFrame(float deltaTime, EnumRenderStage stage) { if (meshref == null || !ShouldRender) { return; } IRenderAPI rpi = Api.Render; Vec3d camPos = Api.World.Player.Entity.CameraPos; rpi.GlDisableCullFace(); rpi.GlToggleBlend(true); IStandardShaderProgram prog = rpi.PreparedStandardShader(Pos.X, Pos.Y, Pos.Z); prog.Tex2D = Api.BlockTextureAtlas.AtlasTextureIds[0]; prog.ModelMatrix = ModelMat .Identity() .Translate(Pos.X - camPos.X, Pos.Y - camPos.Y, Pos.Z - camPos.Z) .Translate(0.5f, 11f / 16f, 0.5f) .RotateY(Angle) .Translate(-0.5f, 0, -0.5f) .Translate(xf, yf, zf) .Values ; prog.ViewMatrix = rpi.CameraMatrixOriginf; prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; rpi.RenderMesh(meshref); prog.Stop(); if (ShouldRotate) { float jl = (int)Api.World.Rand.NextDouble(); if (yb && yf <= 0.5f) { xf += deltaTime * 0.02f; yf += deltaTime * jl * 5.0f; zf += deltaTime * 0.02f; } else { yb = false; if (dO && Api.Side == EnumAppSide.Client) { Api.World.PlaySoundAt(CrushSound, Pos.X, Pos.Y, Pos.Z); dO = false; } } if (!yb && yf >= -0.2f) { xf -= deltaTime * 0.04f; yf -= deltaTime * jl * 10.0f; zf -= deltaTime * 0.04f; } else { yb = true; dO = true; } if (!yb) { Angle += (deltaTime * 100) * GameMath.DEG2RAD; } if (Angle * GameMath.RAD2DEG > 360.0f) { Angle = 0.0f * GameMath.DEG2RAD; } } else { xf = 0.0f; yf = 0.0f; zf = 0.0f; Angle = 0.0f; } }
public void OnRenderFrame(float deltaTime, EnumRenderStage stage) { if (needleMeshRef == null || discMeshRef == null) { return; } long ellapsedMs = api.World.ElapsedMilliseconds; IRenderAPI rpi = api.Render; IClientWorldAccessor worldAccess = api.World; Vec3d camPos = worldAccess.Player.Entity.CameraPos; Vec4f lightrgbs = api.World.BlockAccessor.GetLightRGBs(pos.X, pos.Y, pos.Z); rpi.GlDisableCullFace(); IStandardShaderProgram prog = rpi.StandardShader; prog.Use(); prog.ExtraGlow = 0; prog.RgbaAmbientIn = rpi.AmbientColor; prog.RgbaFogIn = rpi.FogColor; prog.FogMinIn = rpi.FogMin; prog.FogDensityIn = rpi.FogDensity; prog.RgbaTint = ColorUtil.WhiteArgbVec; prog.RgbaLightIn = lightrgbs; prog.DontWarpVertices = 0; prog.AddRenderFlags = 0; prog.ExtraGodray = 0; prog.NormalShaded = 1; rpi.BindTexture2d(api.BlockTextureAtlas.AtlasTextureIds[0]); float origx = -0.5f; float origz = -0.5f; needlePos.X = 3.5f / 16f; needlePos.Y = 10.8f / 16f; needlePos.Z = -3.5f / 16f; // because i'm a noob and lazy switch (blockRotation) { case 90: needlePos.X -= 7 / 16f; break; case 180: needlePos.X -= 7 / 16f; needlePos.Z += 7 / 16f; break; case 270: needlePos.Z += 7 / 16f; break; } float wobble = GameMath.Sin(Math.Max(0, ellapsedMs - updatedTotalMs) / 50f - 0.5f) / 80f; needleRotRad.Y = -GameMath.PIHALF + Math.Min(0.4f, (ellapsedMs - updatedTotalMs) / 700f) + wobble + blockRotation * GameMath.DEG2RAD; needleRotRad.X = wobble; prog.ModelMatrix = ModelMat .Identity() .Translate(pos.X - camPos.X + needlePos.X, pos.Y - camPos.Y + needlePos.Y, pos.Z - camPos.Z + needlePos.Z) .Translate(-origx, 0, -origz) .Rotate(needleRotRad) .Translate(origx, 0, origz) .Values ; prog.ViewMatrix = rpi.CameraMatrixOriginf; prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; rpi.RenderMesh(needleMeshRef); rpi.BindTexture2d(api.ItemTextureAtlas.AtlasTextureIds[0]); origx = -9.25f / 16f; float origy = -9.5f / 16f; origz = -0.5f; discPos.X = -1.25f / 16f; discPos.Y = 11.2f / 16f; discPos.Z = 0f / 16f; discRotRad.X = GameMath.PIHALF; discRotRad.Z = -Math.Max(0, (ellapsedMs - updatedTotalMs) / 500f - 0.5f); prog.NormalShaded = 0; prog.ModelMatrix = ModelMat .Identity() .Translate(pos.X - camPos.X + discPos.X, pos.Y - camPos.Y + discPos.Y, pos.Z - camPos.Z + discPos.Z) .Translate(-origx, 0, -origz) .Rotate(discRotRad) .Scale(0.45f, 0.45f, 0.45f) .Translate(origx, origy, origz) .Values ; rpi.RenderMesh(discMeshRef); prog.Stop(); }
public void OnRenderFrame(float deltaTime, EnumRenderStage stage) { IRenderAPI rpi = capi.Render; IClientWorldAccessor worldAccess = capi.World; Vec3d camPos = worldAccess.Player.Entity.CameraPos; rpi.GlDisableCullFace(); IStandardShaderProgram prog = rpi.StandardShader; prog.Use(); prog.RgbaAmbientIn = rpi.AmbientColor; prog.RgbaFogIn = rpi.FogColor; prog.FogMinIn = rpi.FogMin; prog.FogDensityIn = rpi.FogDensity; prog.RgbaTint = ColorUtil.WhiteArgbVec; prog.DontWarpVertices = 0; prog.AddRenderFlags = 0; prog.ExtraGodray = 0; prog.OverlayOpacity = 0; Vec4f lightrgbs = capi.World.BlockAccessor.GetLightRGBs(pos.X, pos.Y, pos.Z); if (stack != null && workItemMeshRef != null) { int temp = (int)stack.Collectible.GetTemperature(capi.World, stack); //Vec4f lightrgbs = capi.World.BlockAccessor.GetLightRGBs(pos.X, pos.Y, pos.Z); float[] glowColor = ColorUtil.GetIncandescenceColorAsColor4f(temp); int extraGlow = GameMath.Clamp((temp - 550) / 2, 0, 255); prog.NormalShaded = 1; prog.RgbaLightIn = lightrgbs; prog.RgbaGlowIn = new Vec4f(glowColor[0], glowColor[1], glowColor[2], extraGlow / 255f); prog.ExtraGlow = extraGlow; prog.Tex2D = textureId; prog.ModelMatrix = ModelMat.Identity().Translate(pos.X - camPos.X, pos.Y - camPos.Y + 10 / 16f, pos.Z - camPos.Z).Values; prog.ViewMatrix = rpi.CameraMatrixOriginf; prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; rpi.RenderMesh(workItemMeshRef); } if (burning) { float[] glowColor = ColorUtil.GetIncandescenceColorAsColor4f(1200); prog.RgbaGlowIn = new Vec4f(glowColor[0], glowColor[1], glowColor[2], 1); } else { prog.RgbaGlowIn = new Vec4f(0, 0, 0, 0); } prog.NormalShaded = 1; prog.RgbaLightIn = lightrgbs; prog.ExtraGlow = burning ? 255 : 0; rpi.BindTexture2d(hetexpos.atlasTextureId); prog.ModelMatrix = ModelMat.Identity().Translate(pos.X - camPos.X, pos.Y - camPos.Y, pos.Z - camPos.Z).Values; prog.ViewMatrix = rpi.CameraMatrixOriginf; prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; rpi.RenderMesh(heQuadRef); prog.Stop(); }
public void OnRenderFrame(float deltaTime, EnumRenderStage stage) { if (stack == null && fuelLevel == 0) { return; } IRenderAPI rpi = capi.Render; IClientWorldAccessor worldAccess = capi.World; EntityPos plrPos = worldAccess.Player.Entity.Pos; Vec3d camPos = worldAccess.Player.Entity.CameraPos; rpi.GlDisableCullFace(); IStandardShaderProgram prog = rpi.StandardShader; prog.Use(); prog.RgbaAmbientIn = rpi.AmbientColor; prog.RgbaFogIn = rpi.FogColor; prog.FogMinIn = rpi.FogMin; prog.FogDensityIn = rpi.FogDensity; prog.RgbaTint = ColorUtil.WhiteArgbVec; prog.WaterWave = 0; //rpi.GlMatrixModeModelView(); if (stack != null && workItemMeshRef != null) { int temp = (int)stack.Collectible.GetTemperature(capi.World, stack); prog.ExtraGlow = GameMath.Clamp((temp - 700) / 2, 0, 255); Vec4f lightrgbs = capi.World.BlockAccessor.GetLightRGBs(pos.X, pos.Y, pos.Z); float[] glowColor = ColorUtil.GetIncandescenceColorAsColor4f(temp); lightrgbs[0] += 2 * glowColor[0]; lightrgbs[1] += 2 * glowColor[1]; lightrgbs[2] += 2 * glowColor[2]; prog.RgbaLightIn = lightrgbs; prog.RgbaBlockIn = ColorUtil.WhiteArgbVec; // The work item rpi.BindTexture2d(workItemTexPos.atlasTextureId); prog.ModelMatrix = ModelMat.Identity().Translate(pos.X - camPos.X, pos.Y - camPos.Y + 7 / 16f + fuelLevel * 0.65f, pos.Z - camPos.Z).Values; prog.ViewMatrix = rpi.CameraMatrixOriginf; prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; rpi.RenderMesh(workItemMeshRef); } if (fuelLevel > 0) { Vec4f lightrgbs = capi.World.BlockAccessor.GetLightRGBs(pos.X, pos.Y, pos.Z); prog.RgbaLightIn = lightrgbs; prog.RgbaBlockIn = ColorUtil.WhiteArgbVec; prog.ExtraGlow = 0; // The coal or embers rpi.BindTexture2d(burning ? embertexpos.atlasTextureId : coaltexpos.atlasTextureId); prog.ModelMatrix = ModelMat.Identity().Translate(pos.X - camPos.X, pos.Y - camPos.Y + 7 / 16f + fuelLevel * 0.65f, pos.Z - camPos.Z).Values; prog.ViewMatrix = rpi.CameraMatrixOriginf; prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; rpi.RenderMesh(burning ? emberQuadRef : coalQuadRef); } prog.Stop(); }
public void OnRenderFrame(float deltaTime, EnumRenderStage stage) { if (contentStackRenderer != null) { contentStackRenderer.OnRenderFrame(deltaTime, stage); return; } if (meshref == null) { return; } IRenderAPI rpi = api.Render; Vec3d camPos = api.World.Player.Entity.CameraPos; rpi.GlDisableCullFace(); rpi.GlToggleBlend(true); IStandardShaderProgram prog = rpi.StandardShader; prog.Use(); prog.WaterWave = 0; prog.RgbaAmbientIn = rpi.AmbientColor; prog.RgbaFogIn = rpi.FogColor; prog.FogMinIn = rpi.FogMin; prog.FogDensityIn = rpi.FogDensity; prog.RgbaTint = ColorUtil.WhiteArgbVec; api.Render.BindTexture2d(api.ItemTextureAtlas.AtlasTextureIds[0]); int temp = (int)ContentStack.Collectible.GetTemperature(api.World, ContentStack); Vec4f lightrgbs = api.World.BlockAccessor.GetLightRGBs(pos.X, pos.Y, pos.Z); float[] glowColor = ColorUtil.GetIncandescenceColorAsColor4f(temp); lightrgbs[0] += 2 * glowColor[0]; lightrgbs[1] += 2 * glowColor[1]; lightrgbs[2] += 2 * glowColor[2]; prog.RgbaLightIn = lightrgbs; prog.RgbaBlockIn = ColorUtil.WhiteArgbVec; prog.ExtraGlow = (int)GameMath.Clamp((temp - 500) / 4, 0, 255); prog.ModelMatrix = ModelMat .Identity() .Translate(pos.X - camPos.X + transform.Translation.X, pos.Y - camPos.Y + transform.Translation.Y, pos.Z - camPos.Z + transform.Translation.Z) .Translate(transform.Origin.X, 0.6f + transform.Origin.Y, transform.Origin.Z) .RotateX((90 + transform.Rotation.X) * GameMath.DEG2RAD) .RotateY(transform.Rotation.Y * GameMath.DEG2RAD) .RotateZ(transform.Rotation.Z * GameMath.DEG2RAD) .Scale(transform.ScaleXYZ.X, transform.ScaleXYZ.Y, transform.ScaleXYZ.Z) .Translate(-transform.Origin.X, -transform.Origin.Y, -transform.Origin.Z) .Values ; prog.ViewMatrix = rpi.CameraMatrixOriginf; prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; rpi.RenderMesh(meshref); prog.Stop(); }
public void OnRenderFrame(float deltaTime, EnumRenderStage stage) { if (fallTime < -1) { capi.Event.UnregisterRenderer(this, stage); Dispose(); return; } float percent = fallTime / startFallTime; IRenderAPI rpi = capi.Render; Vec3d camPos = capi.World.Player.Entity.CameraPos; if (isLeaves) { rpi.GlDisableCullFace(); } rpi.GlToggleBlend(true); bool shadowPass = stage != EnumRenderStage.Opaque; IShaderProgram prevProg = rpi.CurrentActiveShader; prevProg?.Stop(); IShaderProgram sProg = shadowPass ? rpi.GetEngineShader(EnumShaderProgram.Shadowmapentityanimated) : rpi.PreparedStandardShader(pos.X, pos.Y, pos.Z); var mat = ModelMat .Identity() .Translate(pos.X - camPos.X, pos.Y - camPos.Y, pos.Z - camPos.Z) ; switch (fallDirection.Code) { case "north": mat.RotateXDeg(GameMath.Max(percent * 90.0f - 90.0f, -90.0f)); break; case "south": mat.Translate(0, 0, 1); mat.RotateXDeg(GameMath.Min(percent * -90.0f + 90.0f, 90.0f)); mat.Translate(0, 0, -1); break; case "east": mat.Translate(1, 0, 1); mat.RotateZDeg(GameMath.Max(percent * 90.0f - 90.0f, -90.0f)); mat.Translate(-1, 0, -1); break; case "west": mat.Translate(0, 0, 1); mat.RotateZDeg(GameMath.Min(percent * -90.0f + 90.0f, 90.0f)); mat.Translate(0, 0, -1); break; default: break; } var matVals = mat.Values; if (!shadowPass) { var prog = (IStandardShaderProgram)sProg; prog.Tex2D = capi.BlockTextureAtlas.AtlasTextureIds[0]; prog.ModelMatrix = matVals; prog.AlphaTest = 0.4f; prog.ViewMatrix = rpi.CameraMatrixOriginf; prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; if (fallTime < 0) { prog.RgbaTint = new Vec4f(1, 1, 1, 1.0f - Math.Abs(fallTime)); } } else { sProg.Use(); sProg.BindTexture2D("entityTex", capi.BlockTextureAtlas.AtlasTextureIds[0], 1); sProg.UniformMatrix("projectionMatrix", rpi.CurrentProjectionMatrix); sProg.UniformMatrix("modelViewMatrix", Mat4f.Mul(new float[16], capi.Render.CurrentModelviewMatrix, matVals)); } rpi.RenderMesh(treeMesh); sProg.Stop(); prevProg?.Use(); fallTime -= deltaTime; }
public void update(float dt) { if (pinned) { if (pinnedTo != null) { if (pinnedTo.ShouldDespawn && pinnedTo.DespawnReason?.reason != EnumDespawnReason.Unload) { UnPin(); return; } // New ideas: // don't apply force onto the player/entity on compression // apply huge forces onto the player on strong extension (to prevent massive stretching) (just set player motion to 0 or so. or we add a new countermotion field thats used in EntityControlledPhysics?) float weight = pinnedTo.Properties.Weight; float counterTensionStrength = GameMath.Clamp(50f / weight, 0.1f, 2f); bool extraResist = (pinnedTo as EntityAgent)?.Controls.Sneak == true || pinnedTo.AnimManager?.IsAnimationActive("sit") == true || pinnedTo.AnimManager?.IsAnimationActive("sleep") == true; float tensionResistStrength = weight / 10f * (extraResist ? 200 : 0); pinOffsetTransform.Identity(); pinOffsetTransform.RotateY(pinnedTo.SidedPos.Yaw - pinnedToOffsetStartYaw); tmpvec.Set(pinnedToOffset.X, pinnedToOffset.Y, pinnedToOffset.Z, 1); Vec4f outvec = pinOffsetTransform.TransformVector(tmpvec); EntityPos pos = pinnedTo.SidedPos; Pos.Set(pos.X + outvec.X, pos.Y + outvec.Y, pos.Z + outvec.Z); bool pushable = !(pinnedTo is EntityPlayer eplr && eplr.Player.WorldData.CurrentGameMode == EnumGameMode.Creative); if (pushable && extension > 0) // Do not act on compressive force { float f = counterTensionStrength * dt * 0.003f; pos.Motion.Add( GameMath.Clamp(Math.Abs(TensionDirection.X) - tensionResistStrength, 0, 400) * f * Math.Sign(TensionDirection.X), GameMath.Clamp(Math.Abs(TensionDirection.Y) - tensionResistStrength, 0, 400) * f * Math.Sign(TensionDirection.Y), GameMath.Clamp(Math.Abs(TensionDirection.Z) - tensionResistStrength, 0, 400) * f * Math.Sign(TensionDirection.Z) ); } Velocity.Set(0, 0, 0); } else { Velocity.Set(0, 0, 0); accum1s += dt; if (accum1s >= 1) { accum1s = 0; Block block = cs.api.World.BlockAccessor.GetBlock(PinnedToBlockPos); if (!block.HasBehavior <BlockBehaviorRopeTieable>()) { UnPin(); } } } return; } // Calculate the force on this ball Vec3f force = Tension.Clone(); force.Y -= GravityStrength * 10; // Calculate the acceleration Vec3f acceleration = force * (float)InvMass; if (CollideFlags == 0) { acceleration.X += (float)cs.windSpeed.X * InvMass; } // Update velocity Vec3f nextVelocity = Velocity + (acceleration * dt); // Damp the velocity nextVelocity *= dampFactor; // Collision detection float size = 0.1f; cs.pp.HandleBoyancy(Pos, nextVelocity, cs.boyant, GravityStrength, dt, size); CollideFlags = cs.pp.UpdateMotion(Pos, nextVelocity, size); dt *= 0.99f; Pos.Add(nextVelocity.X * dt, nextVelocity.Y * dt, nextVelocity.Z * dt); Velocity.Set(nextVelocity); Tension.Set(0, 0, 0); }
public void OnRenderFrame(float deltaTime, EnumRenderStage stage) { if (beAnvil.Inventory[0].Empty) { return; } IRenderAPI rpi = capi.Render; Vec3d camPos = capi.World.Player.Entity.CameraPos; int temp = (int)beAnvil.Inventory[0].Itemstack.Collectible.GetTemperature(capi.World, beAnvil.Inventory[0].Itemstack); Vec4f lightrgbs = capi.World.BlockAccessor.GetLightRGBs(beAnvil.Pos.X, beAnvil.Pos.Y, beAnvil.Pos.Z); float[] glowColor = ColorUtil.GetIncandescenceColorAsColor4f(temp); int extraGlow = GameMath.Clamp((temp - 550) / 2, 0, 255); rpi.GlDisableCullFace(); rpi.GlToggleBlend(true); IStandardShaderProgram prog = rpi.PreparedStandardShader(beAnvil.Pos.X, beAnvil.Pos.Y, beAnvil.Pos.Z); prog.Tex2D = capi.BlockTextureAtlas.AtlasTextureIds[0]; prog.ModelMatrix = ModelMat .Identity() .Translate(beAnvil.Pos.X - camPos.X, beAnvil.Pos.Y - camPos.Y, beAnvil.Pos.Z - camPos.Z) .Values ; prog.RgbaLightIn = lightrgbs; prog.RgbaGlowIn = new Vec4f(glowColor[0], glowColor[1], glowColor[2], extraGlow / 255f); prog.ExtraGlow = extraGlow; prog.ViewMatrix = rpi.CameraMatrixOriginf; prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; rpi.RenderMesh(beAnvil.BaseMeshRef); if (beAnvil.FluxMeshRef != null) { prog.ExtraGlow = 0; rpi.RenderMesh(beAnvil.FluxMeshRef); } if (beAnvil.TopMeshRef != null) { temp = (int)beAnvil.Inventory[2].Itemstack.Collectible.GetTemperature(capi.World, beAnvil.Inventory[2].Itemstack); lightrgbs = capi.World.BlockAccessor.GetLightRGBs(beAnvil.Pos.X, beAnvil.Pos.Y, beAnvil.Pos.Z); glowColor = ColorUtil.GetIncandescenceColorAsColor4f(temp); extraGlow = GameMath.Clamp((temp - 550) / 2, 0, 255); prog.ModelMatrix = ModelMat .Identity() .Translate(beAnvil.Pos.X - camPos.X, beAnvil.Pos.Y - camPos.Y - beAnvil.hammerHits / 250f, beAnvil.Pos.Z - camPos.Z) .Values ; prog.RgbaLightIn = lightrgbs; prog.RgbaGlowIn = new Vec4f(glowColor[0], glowColor[1], glowColor[2], extraGlow / 255f); prog.ExtraGlow = extraGlow; rpi.RenderMesh(beAnvil.TopMeshRef); } prog.Stop(); }
public void OnRenderFrame(float deltaTime, EnumRenderStage stage) { if (LevelLeft <= 0 && LevelRight <= 0) { return; } IRenderAPI rpi = api.Render; IClientWorldAccessor worldAccess = api.World; EntityPos plrPos = worldAccess.Player.Entity.Pos; Vec3d camPos = worldAccess.Player.Entity.CameraPos; rpi.GlDisableCullFace(); IStandardShaderProgram prog = rpi.StandardShader; prog.Use(); prog.RgbaAmbientIn = rpi.AmbientColor; prog.RgbaFogIn = rpi.FogColor; prog.FogMinIn = rpi.FogMin; prog.FogDensityIn = rpi.FogDensity; prog.RgbaTint = ColorUtil.WhiteArgbVec; prog.DontWarpVertices = 0; prog.ExtraGodray = 0; prog.AddRenderFlags = 0; if (LevelLeft > 0 && TextureNameLeft != null) { Vec4f lightrgbs = api.World.BlockAccessor.GetLightRGBs(pos.X, pos.Y, pos.Z); float[] glowColor = ColorUtil.GetIncandescenceColorAsColor4f((int)TemperatureLeft); int extraGlow = (int)GameMath.Clamp((TemperatureLeft - 550) / 1.5f, 0, 255); prog.RgbaLightIn = lightrgbs; prog.RgbaGlowIn = new Vec4f(glowColor[0], glowColor[1], glowColor[2], extraGlow / 255f); prog.ExtraGlow = extraGlow; prog.NormalShaded = 0; int texid = api.Render.GetOrLoadTexture(TextureNameLeft); rpi.BindTexture2d(texid); float xzOffset = (QuantityMolds > 1) ? 4.5f : 8.5f; prog.ModelMatrix = ModelMat .Identity() .Translate(pos.X - camPos.X, pos.Y - camPos.Y, pos.Z - camPos.Z) .Translate(xzOffset / 16f, 1 / 16f + LevelLeft / 850f, 8.5f / 16) .RotateX(90 * GameMath.DEG2RAD) .Scale(0.5f * 3 / 16f, 0.5f * 7 / 16f, 0.5f) .Values ; prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; prog.ViewMatrix = rpi.CameraMatrixOriginf; rpi.RenderMesh(quadModelRef); } if (LevelRight > 0 && QuantityMolds > 1 && TextureNameRight != null) { Vec4f lightrgbs = api.World.BlockAccessor.GetLightRGBs(pos.X, pos.Y, pos.Z); float[] glowColor = ColorUtil.GetIncandescenceColorAsColor4f((int)TemperatureRight); int extraGlow = (int)GameMath.Clamp((TemperatureRight - 550) / 1.5f, 0, 255); prog.RgbaLightIn = lightrgbs; prog.RgbaGlowIn = new Vec4f(glowColor[0], glowColor[1], glowColor[2], extraGlow / 255f); prog.ExtraGlow = extraGlow; prog.NormalShaded = 0; int texid = api.Render.GetOrLoadTexture(TextureNameRight); rpi.BindTexture2d(texid); /* * rpi.GlPushMatrix(); * rpi.GlLoadMatrix(api.Render.CameraMatrixOrigin); * rpi.GlTranslate(pos.X - camPos.X, pos.Y - camPos.Y, pos.Z - camPos.Z); * rpi.GlTranslate(11.5f / 16f, 1 / 16f + LevelRight / 850f, 8.5f / 16); * rpi.GlRotate(90, 1, 0, 0); * rpi.GlScale(0.5f * 3 / 16f, 0.5f * 7 / 16f, 0.5f); * prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; * prog.ModelViewMatrix = rpi.CurrentModelviewMatrix; * rpi.GlPopMatrix(); */ prog.ModelMatrix = ModelMat .Identity() .Translate(pos.X - camPos.X, pos.Y - camPos.Y, pos.Z - camPos.Z) .Translate(11.5f / 16f, 1 / 16f + LevelRight / 850f, 8.5f / 16) .RotateX(90 * GameMath.DEG2RAD) .Scale(0.5f * 3 / 16f, 0.5f * 7 / 16f, 0.5f) .Values ; prog.ProjectionMatrix = rpi.CurrentProjectionMatrix; prog.ViewMatrix = rpi.CameraMatrixOriginf; rpi.RenderMesh(quadModelRef); } prog.Stop(); rpi.GlEnableCullFace(); }