Jump to content

Recommended Posts

Posted

Somehow when i try rotating some lines i draw with the tesselator, they just stay as they are. Any solution?

Here is what i tried so far(Don't wonder about the complicated for loops, i gonna make them in a method later):

 

 

GL11.glRotated(tile.rotation, 0, 1, 0);

GL11.glPushMatrix();

GL11.glLineWidth(2.5F);

WorldRenderer worldRenderer = Tessellator.getInstance().getWorldRenderer();

TileEntity_PowerLine connectedTile = tile.connected;

 

if (connectedTile != null) {

BlockPos pos = connectedTile.getPos();

BlockPos pos2 = tile.getPos();

Vector3f temp = Vector3f.sub(MathUtil.blockPosVec(pos), MathUtil.blockPosVec(pos2), null);

double distance = euclidianDistance(MathUtil.blockPosVec(pos), MathUtil.blockPosVec(pos2));

double scalefactor = distance*5.81;

//Drawing

GlStateManager.pushAttrib();

GlStateManager.pushMatrix();

worldRenderer.startDrawing(GL11.GL_LINE_STRIP);

worldRenderer.setColorOpaque(0, 0, 0);

 

 

for (double i = -distance/2; i <= distance/2; i+=1D) {

double cosh = Math.cosh(i /  distance/2.0)*scalefactor;

double offsetY=(Math.cosh(distance/2 /  distance/2)*scalefactor);

worldRenderer.addVertex(posX+0.5 + 7, posY+21.98 -offsetY + cosh , posZ+0.5 + distance/2 + i);

 

}

Tessellator.getInstance().draw();

 

worldRenderer.startDrawing(GL11.GL_LINE_STRIP);

worldRenderer.setColorOpaque(0, 0, 0);

for (double i = -distance/2; i <= distance/2; i+=1D) {

double cosh = Math.cosh(i / distance/2.0)*scalefactor;

double offsetY=(Math.cosh(distance/2 /  distance/2)*scalefactor);

worldRenderer.addVertex(posX - 7, posY+21.98 -offsetY + cosh, posZ+0.5 + distance/2 + i);

 

}

Tessellator.getInstance().draw();

 

worldRenderer.startDrawing(GL11.GL_LINE_STRIP);

worldRenderer.setColorOpaque(0, 0, 0);

for (double i = -distance/2; i <= distance/2; i+=1D) {

double cosh = Math.cosh(i / distance/2.0)*scalefactor;

double offsetY=(Math.cosh(distance/2 /  distance/2)*scalefactor);

worldRenderer.addVertex(posX+0.5 + 3.5, posY+21.98 -offsetY + cosh, posZ+0.5 + distance/2 + i);

 

}

Tessellator.getInstance().draw();

 

worldRenderer.startDrawing(GL11.GL_LINE_STRIP);

worldRenderer.setColorOpaque(0, 0, 0);

for (double i = -distance/2; i <= distance/2; i+=1D) {

double cosh = Math.cosh(i / distance/2.0)*scalefactor;

double offsetY=(Math.cosh(distance/2 /  distance/2)*scalefactor);

worldRenderer.addVertex(posX+0.5 - 3.5, posY+21.98 -offsetY + cosh, posZ +0.5 + distance/2 + i);

 

}

Tessellator.getInstance().draw();

 

worldRenderer.startDrawing(GL11.GL_LINE_STRIP);

worldRenderer.setColorOpaque(0, 0, 0);

for (double i = -distance/2; i <= distance/2; i+=1D) {

double cosh = Math.cosh(i / distance/2.0)*scalefactor;

double offsetY=(Math.cosh(distance/2 /  distance/2)*scalefactor);

worldRenderer.addVertex(posX+0.5, posY+29.98 -offsetY + cosh, posZ+0.5 + distance/2 + i);

 

}

Tessellator.getInstance().draw();

 

GlStateManager.popMatrix();

GlStateManager.popAttrib();

}

if (tile.connected != null) {

BlockPos p = tile.getPos();

BlockPos p2 = tile.getPos();

Vector3f tilePos = new Vector3f(p.getX(), p.getY(), p.getZ());

Vector3f connectedTilePos = new Vector3f(p2.getX(), p2.getY(), p2.getZ());

double dot = Vector3f.dot(tilePos, connectedTilePos);

double angle = Vector3f.angle(tilePos, connectedTilePos);

GL11.glRotated(angle, 0, 1, 0);

}

GL11.glPopMatrix();

 

 

Posted

Well I would start by isolating the code that draws lines into another method, then try running your GL11.rotate before running the method.

 

Edit: Try calling your GL11.glRotated(tile.rotation, 0, 1, 0); after you call the pushMatrix(); talking about the first 2 lines

"you seem to be THE best modder I've seen imo."

~spynathan

 

ლ(́◉◞౪◟◉‵ლ

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.