void DrawTopFace(int count) { int texId = BlockInfo.textures[curBlock * Side.Sides + Side.Top]; int i = texId >> Atlas1D.Shift; float vOrigin = (texId & Atlas1D.Mask) * Atlas1D.invTileSize; int offset = (lightFlags >> Side.Top) & 1; float u1 = minBB.X, u2 = (count - 1) + maxBB.X * 15.99f / 16f; float v1 = vOrigin + maxBB.Y * Atlas1D.invTileSize; float v2 = vOrigin + minBB.Y * Atlas1D.invTileSize * 15.99f / 16f; DrawInfo part = isTranslucent ? translucentParts[i] : normalParts[i]; PackedCol col = fullBright ? PackedCol.White : light.LightCol_YTop_Fast(X, (Y + 1) - offset, Z); if (tinted) { col *= BlockInfo.FogCol[curBlock]; } float y2_x1z1 = y2, y2_x1z2 = y2, y2_x2z1 = y2, y2_x2z2 = y2; if (BlockInfo.Draw[curBlock] == DrawType2.SlopeDownXMax) { y2_x2z1 = y1; y2_x2z2 = y1; if (!fullBright) { col = PackedCol.Scale(col, 0.8f); } } else if (BlockInfo.Draw[curBlock] == DrawType2.SlopeDownXMin) { y2_x1z1 = y1; y2_x1z2 = y1; if (!fullBright) { col = PackedCol.Scale(col, 0.8f); } } else if (BlockInfo.Draw[curBlock] == DrawType2.SlopeDownZMin) { y2_x1z1 = y1; y2_x2z1 = y1; if (!fullBright) { col = PackedCol.Scale(col, 0.9f); } } else if (BlockInfo.Draw[curBlock] == DrawType2.SlopeDownZMax) { y2_x1z2 = y1; y2_x2z2 = y1; if (!fullBright) { col = PackedCol.Scale(col, 0.9f); } } vertices[part.vIndex[Side.Top]++] = new VertexP3fT2fC4b(x2 + (count - 1), y2_x2z1, z1, u2, v1, col); vertices[part.vIndex[Side.Top]++] = new VertexP3fT2fC4b(x1, y2_x1z1, z1, u1, v1, col); vertices[part.vIndex[Side.Top]++] = new VertexP3fT2fC4b(x1, y2_x1z2, z2, u1, v2, col); vertices[part.vIndex[Side.Top]++] = new VertexP3fT2fC4b(x2 + (count - 1), y2_x2z2, z2, u2, v2, col); }
/// <summary> Calculates the location and size of the caret character </summary> protected void UpdateCaret() { int maxChars = UsedLines * MaxCharsPerLine; if (caret >= maxChars) { caret = -1; } Text.GetCoords(caret, lines, out caretX, out caretY); DrawTextArgs args = new DrawTextArgs(null, font, false); IDrawer2D drawer = game.Drawer2D; caretAccumulator = 0; if (caretX == MaxCharsPerLine) { caretTex.X1 = X + Padding + lineSizes[caretY].Width; caretCol = PackedCol.Yellow; caretTex.Width = (ushort)caretWidth; } else { args.Text = lines[caretY].Substring(0, caretX); Size trimmedSize = drawer.MeasureText(ref args); if (caretY == 0) { trimmedSize.Width += prefixWidth; } caretTex.X1 = X + Padding + trimmedSize.Width; caretCol = PackedCol.Scale(PackedCol.White, 0.8f); string line = lines[caretY]; if (caretX < line.Length) { args.Text = new String(line[caretX], 1); args.UseShadow = true; caretTex.Width = (ushort)drawer.MeasureText(ref args).Width; } else { caretTex.Width = (ushort)caretWidth; } } caretTex.Y1 = lineSizes[0].Height * caretY + inputTex.Y1 + 2; // Update the colour of the caret char code = GetLastCol(caretX, caretY); if (code != '\0') { caretCol = IDrawer2D.GetCol(code); } }
unsafe void CalculatePalette(int *palette) { for (int i = 0; i < Palette.Length; i++) { PackedCol col = Palette[i]; if (!Active) { col = PackedCol.Scale(col, 0.7f); } palette[i] = col.ToArgb(); } }
public override PackedCol Colour() { Player realP = game.LocalPlayer; PackedCol col = realP.Colour(); // Adjust pitch so angle when looking straight down is 0. float adjHeadX = realP.HeadX - 90; if (adjHeadX < 0) { adjHeadX += 360; } // Adjust colour so held block is brighter when looking straght up float t = Math.Abs(adjHeadX - 180) / 180; float colScale = Utils.Lerp(0.9f, 0.7f, t); return(PackedCol.Scale(col, colScale)); }
public override void DrawModel(Entity p) { ApplyTexture(p); DrawRotate(-p.HeadXRadians, 0, 0, Head, true); DrawRotate(-p.HeadXRadians, 0, 0, Head2, true); DrawRotate(-p.HeadXRadians, 0, 0, Head3, true); DrawPart(Torso); DrawRotate(0, 0, -Math.Abs(p.anim.leftArmX), LeftWing, false); DrawRotate(0, 0, Math.Abs(p.anim.leftArmX), RightWing, false); PackedCol col = cols[0]; for (int i = 0; i < cols.Length; i++) { cols[i] = PackedCol.Scale(col, 0.7f); } DrawRotate(p.anim.leftLegX, 0, 0, LeftLeg, false); DrawRotate(p.anim.rightLegX, 0, 0, RightLeg, false); UpdateVB(); }
public void SetupState(Entity p) { index = 0; PackedCol col = p.Colour(); cols[0] = col; if (!p.NoShade) { cols[1] = PackedCol.Scale(col, PackedCol.ShadeYBottom); cols[2] = PackedCol.Scale(col, PackedCol.ShadeZ); cols[4] = PackedCol.Scale(col, PackedCol.ShadeX); } else { cols[1] = col; cols[2] = col; cols[4] = col; } cols[3] = cols[2]; cols[5] = cols[4]; float yawDelta = p.HeadY - p.RotY; cosHead = (float)Math.Cos(yawDelta * Utils.Deg2Rad); sinHead = (float)Math.Sin(yawDelta * Utils.Deg2Rad); }
public override void DrawModel(Entity p) { cols[1] = cols[2] = cols[3] = cols[4] = cols[5] = PackedCol.Scale(cols[0], PackedCol.ShadeZ); ApplyTexture(p); SetUVScale(); headTilt = -p.HeadX; if (headTilt >= -180) { headTilt *= 0.5f; } else { headTilt = -180 + headTilt * 0.5f; // -360 + (360 + headTilt) * 0.5f } game.Graphics.AlphaTest = false; DrawRotate(headTilt * Utils.Deg2Rad, 0, 0, Head, true); DrawRotate(tempRotate, 0, 0, Torso, false); //TORSO********************************* //DrawPart(Torso); UpdateVB(); game.Graphics.AlphaTest = true; index = 0; DrawRotate(tempRotate, 0, 0, LeftWing, false); DrawRotate(tempRotate, 0, 0, RightWing, false); DrawRotate(headTilt * Utils.Deg2Rad, 0, 0, Hat, true); DrawRotate(headTilt * Utils.Deg2Rad - 0.4F, 0, 0, Horn, true); DrawRotate(headTilt * Utils.Deg2Rad, 0, 0, LeftEar, true); DrawRotate(headTilt * Utils.Deg2Rad, 0, 0, RightEar, true); DrawRotate(headTilt * Utils.Deg2Rad, 0, 0, Snout, true); DrawRotate(-0.4F, 0, 0, Neck, false); const float tailTilt = 0.05F; const float tailRoll = 0.1F; PackedCol tempCol = cols[0]; cols[0] = PackedCol.Scale(cols[0], PackedCol.ShadeZ); DrawRotate(tempRotate, 0, 0, Tail, false); DrawRotate(tempRotate, tailTilt, -tailRoll, Tail, false); DrawRotate(tempRotate, -tailTilt, tailRoll, Tail, false); cols[0] = tempCol; DrawRotate(0.4F, 0, 0, LeftLegFront, false); DrawRotate(0.4F, 0, 0, RightLegFront, false); DrawRotate(90 * Utils.Deg2Rad, legRotY, legRotZ, LeftLegBack, false); DrawRotate(90 * Utils.Deg2Rad, legRotY, -legRotZ, RightLegBack, false); cols[0] = PackedCol.Scale(cols[0], PackedCol.ShadeZ); DrawRotate(headTilt * Utils.Deg2Rad, -0.2f, 0, Hair1, true); //-0.2f DrawRotate(headTilt * Utils.Deg2Rad, -0, 0, Hair2, true); //-0.2f DrawRotate(headTilt * Utils.Deg2Rad, -0, 0, Hair3, true); //-0.2f UpdateVB(); }
public override void DrawModel(Entity p) { cols[1] = cols[2] = cols[3] = cols[4] = cols[5] = PackedCol.Scale(cols[0], PackedCol.ShadeZ); ApplyTexture(p); SetUVScale(); headTilt = -p.HeadX; if (headTilt >= -180) { headTilt *= 0.5f; } else { headTilt = -180 + headTilt * 0.5f; // -360 + (360 + headTilt) * 0.5f } game.Graphics.AlphaTest = false; DrawRotate(headTilt * Utils.Deg2Rad, 0, 0, Head, true); DrawPart(Torso); UpdateVB(); game.Graphics.AlphaTest = true; index = 0; if (NotAllBelowAir(p)) { DrawPart(LeftWing); DrawPart(RightWing); } else { const float legMax = 80 * Utils.Deg2Rad; // stolen from animatedcomponent float wingZRot = -(float)(Math.Cos(game.accumulator * 10) * legMax); DrawRotate(0, 0, -wingZRot, RightWing2, false); DrawRotate(0, 0, wingZRot, LeftWing2, false); } DrawRotate(headTilt * Utils.Deg2Rad, 0, 0, Hat, true); DrawRotate(headTilt * Utils.Deg2Rad - 0.4F, 0, 0, Horn, true); DrawRotate(headTilt * Utils.Deg2Rad, 0, 0, LeftEar, true); DrawRotate(headTilt * Utils.Deg2Rad, 0, 0, RightEar, true); DrawRotate(headTilt * Utils.Deg2Rad, 0, 0, Snout, true); DrawRotate(-0.4F, 0, 0, Neck, false); const float tailTilt = 0.05F; const float tailRoll = 0.1F; PackedCol tempCol = cols[0]; cols[0] = PackedCol.Scale(cols[0], PackedCol.ShadeZ); DrawRotate(0, 0, 0, Tail, false); DrawRotate(0, tailTilt, -tailRoll, Tail, false); DrawRotate(0, -tailTilt, tailRoll, Tail, false); cols[0] = tempCol; if (!NotAllBelowAir(p)) { DrawPart(LeftLegFront); DrawPart(RightLegFront); DrawPart(LeftLegBack); DrawPart(RightLegBack); } else { DrawRotate(p.anim.leftLegX * 0.5F, 0, 0, LeftLegFront, false); DrawRotate(p.anim.rightLegX * 0.5F, 0, 0, RightLegFront, false); DrawRotate(p.anim.rightLegX * 0.5F, 0, 0, LeftLegBack, false); DrawRotate(p.anim.leftLegX * 0.5F, 0, 0, RightLegBack, false); } cols[0] = PackedCol.Scale(cols[0], PackedCol.ShadeZ); DrawRotate(headTilt * Utils.Deg2Rad, -0.2f, 0, Hair1, true); //-0.2f DrawRotate(headTilt * Utils.Deg2Rad, -0, 0, Hair2, true); //-0.2f DrawRotate(headTilt * Utils.Deg2Rad, -0, 0, Hair3, true); //-0.2f UpdateVB(); }
static void GetShadedAngleShadow(PackedCol normal, out PackedCol xSide, out PackedCol zSide, out PackedCol yBottom) { xSide = PackedCol.Scale(normal, ShadeAHX); zSide = PackedCol.Scale(normal, ShadeAHZ); yBottom = PackedCol.Scale(normal, ShadeAHYBottom); }
static void GetShadedAngleSun(PackedCol normal, out PackedCol xSide, out PackedCol zSide, out PackedCol yBottom) { xSide = PackedCol.Scale(normal, ShadeASX); zSide = PackedCol.Scale(normal, ShadeASZ); yBottom = PackedCol.Scale(normal, ShadeASYBottom); }