public void Draw(Game game, float positionX, float positionY, float positionZ, VehicleDirection12 dir, VehicleDirection12 lastdir, float progress) { float one = 1; if (minecarttexture == -1) { minecarttexture = game.GetTexture("minecart.png"); } game.GLPushMatrix(); float pX = positionX; float pY = positionY; float pZ = positionZ; pY += -(one * 7 / 10); game.GLTranslate(pX, pY, pZ); float currot = vehiclerotation(dir); float lastrot = vehiclerotation(lastdir); //double rot = lastrot + (currot - lastrot) * progress; float rot = AngleInterpolation.InterpolateAngle360(game.platform, lastrot, currot, progress); game.GLRotate(-rot - 90, 0, 1, 0); RectangleFloat[] cc = CuboidRenderer.CuboidNet(8, 8, 8, 0, 0); CuboidRenderer.CuboidNetNormalize(cc, 32, 16); game.platform.BindTexture2d(minecarttexture); CuboidRenderer.DrawCuboid(game, -(one * 5 / 10), -(one * 3 / 10), -(one * 5 / 10), 1, 1, 1, cc, 1); game.GLPopMatrix(); }
void DrawNode(string parent, float headDeg, float light) { for (int i = 0; i < m.nodesCount; i++) { Node n = m.nodes[i]; if (n == null) { continue; } if (n.parentName != parent) { continue; } game.GLPushMatrix(); RectangleFloat[] r = new RectangleFloat[6]; r = CuboidRenderer.CuboidNet(n.sizex, n.sizey, n.sizez, n.u, n.v); CuboidRenderer.CuboidNetNormalize(r, m.global.texw, m.global.texh); GetAnimation(n, tempVec3, KeyframeType.Scale); if (tempVec3[0] != 0 && tempVec3[1] != 0 && tempVec3[2] != 0) { game.GLScale(tempVec3[0], tempVec3[1], tempVec3[2]); } GetAnimation(n, tempVec3, KeyframeType.Position); tempVec3[0] /= 16; tempVec3[1] /= 16; tempVec3[2] /= 16; if (!IsZero(tempVec3)) { game.GLTranslate(tempVec3[0], tempVec3[1], tempVec3[2]); } GetAnimation(n, tempVec3, KeyframeType.Rotation); if (tempVec3[0] != 0) { game.GLRotate(tempVec3[0], 1, 0, 0); } if (tempVec3[1] != 0) { game.GLRotate(tempVec3[1], 0, 1, 0); } if (tempVec3[2] != 0) { game.GLRotate(tempVec3[2], 0, 0, 1); } if (n.head == 1) { game.GLRotate(headDeg, 1, 0, 0); } GetAnimation(n, tempVec3, KeyframeType.Pivot); tempVec3[0] /= 16; tempVec3[1] /= 16; tempVec3[2] /= 16; game.GLTranslate(tempVec3[0], tempVec3[1], tempVec3[2]); GetAnimation(n, tempVec3, KeyframeType.Size); tempVec3[0] /= 16; tempVec3[1] /= 16; tempVec3[2] /= 16; // Use binary minus because unary minus is truncated to integer in cito CuboidRenderer.DrawCuboid2(game, 0 - tempVec3[0] / 2, 0 - tempVec3[1] / 2, 0 - tempVec3[2] / 2, tempVec3[0], tempVec3[1], tempVec3[2], r, light); DrawNode(n.name, headDeg, light); game.GLPopMatrix(); } }