我正在为Minecraft制作一个“航点模型”。这个想法是一条线将被绘制到坐标,一个3d框(非旋转)也将。下面是行代码。
public void WaypointLine(boolean flag) {
try {
GL11.glBlendFunc(770, 771);
GL11.glLineWidth(3F);
GL11.glDisable(2929 /*GL_DEPTH_TEST*/);
GL11.glDepthMask(false);
GL11.glColor3f(255, 0, 0);
double size = 0.45;
double ytSize = 0.35;
GL11.glBegin(GL11.GL_LINES);
double X = EntityClientPlayerMP.waypointX;
double Y = EntityClientPlayerMP.waypointY;
double Z = EntityClientPlayerMP.waypointZ;
double mX = mc.thePlayer.posX;
double mY = mc.thePlayer.posY;
double mZ = mc.thePlayer.posZ;
double dX = (mX - X);
double dY = (mY - Y);
double dZ = (mZ - Z);
if(X != mX && Y != mY && Z != mZ) {
GL11.glVertex3d(0, 0, 0);
GL11.glVertex3d((-dX + size) - 0.5, (ytSize - dY) + 1.0, (-dZ - size) + 0.5);
}
GL11.glEnd();
GL11.glDepthMask(true);
GL11.glEnable(2929 /*GL_DEPTH_TEST*/);
} catch (Exception e) {}
}
完美无缺。我真的不知道如何绘制立方体。我如何能?例子或资源请...我做了一些搜索并且在理解方面遇到了一些麻烦。
答案 0 :(得分:0)
耶!立即模式ftw!
float sizeX = 100;
float sizeY = 200;
float sizeZ = 80;
float centerX = 20;
float centerY = 30;
float centerZ = 10;
float [] yay = {
centerX-sizeX*.5,centerY+sizeY*.5,centerZ+sizeZ*.5,
centerX-sizeX*.5,centerY-sizeY*.5,centerZ+sizeZ*.5,
centerX+sizeX*.5,centerY-sizeY*.5,centerZ+sizeZ*.5,
centerX+sizeX*.5,centerY+sizeY*.5,centerZ+sizeZ*.5,
centerX-sizeX*.5,centerY+sizeY*.5,centerZ-sizeZ*.5,
centerX-sizeX*.5,centerY-sizeY*.5,centerZ-sizeZ*.5,
centerX+sizeX*.5,centerY-sizeY*.5,centerZ-sizeZ*.5,
centerX+sizeX*.5,centerY+sizeY*.5,centerZ-sizeZ*.5,
centerX+sizeX*.5,centerY+sizeY*.5,centerZ-sizeZ*.5,
centerX+sizeX*.5,centerY-sizeY*.5,centerZ-sizeZ*.5,
centerX+sizeX*.5,centerY-sizeY*.5,centerZ+sizeZ*.5,
centerX+sizeX*.5,centerY+sizeY*.5,centerZ+sizeZ*.5,
centerX-sizeX*.5,centerY+sizeY*.5,centerZ-sizeZ*.5,
centerX-sizeX*.5,centerY-sizeY*.5,centerZ-sizeZ*.5,
centerX-sizeX*.5,centerY-sizeY*.5,centerZ+sizeZ*.5,
centerX-sizeX*.5,centerY+sizeY*.5,centerZ+sizeZ*.5,
centerX+sizeX*.5,centerY+sizeY*.5,centerZ-sizeZ*.5,
centerX-sizeX*.5,centerY+sizeY*.5,centerZ-sizeZ*.5,
centerX-sizeX*.5,centerY+sizeY*.5,centerZ+sizeZ*.5,
centerX+sizeX*.5,centerY+sizeY*.5,centerZ+sizeZ*.5,
centerX+sizeX*.5,centerY-sizeY*.5,centerZ-sizeZ*.5,
centerX-sizeX*.5,centerY-sizeY*.5,centerZ-sizeZ*.5,
centerX-sizeX*.5,centerY-sizeY*.5,centerZ+sizeZ*.5,
centerX+sizeX*.5,centerY-sizeY*.5,centerZ+sizeZ*.5};
GL11.glBegin(GL11.QUADS);
for(int i = 0; i < yay.length; i+=3)
GL11.glVertex3d(yay[i],yay[i+1],yay[i+2]);
GL11.glEnd();