Jump to content

TESR has dropouts


ss7

Recommended Posts

Hello,

 

I render a cable with a TESR and connected textures. It's all working fine except when a cable is at the side of the screen it's not connecting anymore.

 

Here are 2 screenshots of what i mean:

 

width=800 height=640http://i.imagebanana.com/img/ppdhckxb/20131117_12.17.03.png[/img]

 

width=800 height=640http://i.imagebanana.com/img/pbi82ziz/20131117_12.17.13.png[/img]

 

Here is the TESR code:

 

 

GL11.glPushMatrix();

        GL11.glTranslatef((float)d0 + 0.5F, (float)d1 + 0.5F, (float)d2 + 0.5F);
        
        FMLClientHandler.instance().getClient().renderEngine.bindTexture(new ResourceLocation("brickcraft", "/textures/blocks/poseblock.png"));
    
        TileEntity front = tileentity.worldObj.getBlockTileEntity(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord + 1);
        TileEntity back = tileentity.worldObj.getBlockTileEntity(tileentity.xCoord, tileentity.yCoord, tileentity.zCoord - 1);
        TileEntity top = tileentity.worldObj.getBlockTileEntity(tileentity.xCoord, tileentity.yCoord + 1, tileentity.zCoord);
        TileEntity bottom = tileentity.worldObj.getBlockTileEntity(tileentity.xCoord, tileentity.yCoord - 1, tileentity.zCoord);
        TileEntity left = tileentity.worldObj.getBlockTileEntity(tileentity.xCoord - 1, tileentity.yCoord, tileentity.zCoord);
        TileEntity right = tileentity.worldObj.getBlockTileEntity(tileentity.xCoord + 1, tileentity.yCoord, tileentity.zCoord);
        
        model.renderPart("Middle");
        
        if (front instanceof IElectric)
        {
        	model.renderPart("Front");
        }
        
        if (back instanceof IElectric)
        {
        	model.renderPart("Back");
        }
        
        if (top instanceof IElectric)
        {
        	model.renderPart("Top");
        }
        
        if (bottom instanceof IElectric)
        {
        	model.renderPart("Bottom");
        }
        
        if (left instanceof IElectric)
        {
        	model.renderPart("Left");
        }
        
        if (right instanceof IElectric)
        {
        	model.renderPart("Right");
        }
        
        GL11.glPopMatrix();

 

 

I'm using a .obj to render the cable.

 

Thanks in advance!

 

ss7

You sir are a god damn hero.

Link to comment
Share on other sites

Hi

 

It looks to me like the bounding box for your TileEntity is too small.  When the bounding box is off the screen (outside the "frustrum") Minecraft thinks "OK the player can't see the TileEntity anymore so I don't need to draw it".

 

That's a pure guess and I'm not sure how to fix it.  But it might point you in the right direction.    Overriding TileEntity.getRenderBoundingBox() looks promising.  The default is to use the bounding box of the associated block, and it looks like your TileEntity might span over several blocks?

 

-TGG

Link to comment
Share on other sites

Hello,

 

Thank you for your answer, but i don't know what i should return there.

I tried it with this:

 

 

TileEntity front = worldObj.getBlockTileEntity(xCoord, yCoord, zCoord + 1);
        TileEntity back = worldObj.getBlockTileEntity(xCoord, yCoord, zCoord - 1);
        TileEntity top = worldObj.getBlockTileEntity(xCoord, yCoord + 1, zCoord);
        TileEntity bottom = worldObj.getBlockTileEntity(xCoord, yCoord - 1, zCoord);
        TileEntity left = worldObj.getBlockTileEntity(xCoord - 1, yCoord, zCoord);
        TileEntity right = worldObj.getBlockTileEntity(xCoord + 1, yCoord, zCoord);

        if (front instanceof IElectric || back instanceof IElectric || top instanceof IElectric || bottom instanceof IElectric || left instanceof IElectric || right instanceof IElectric)
        {
        	return AxisAlignedBB.getBoundingBox(0, 0, 0, 1, 1, 1);
        }
        
	return super.getRenderBoundingBox();

 

 

But when i place a cable next to another both cables are not rendering at all.

 

Should i also extends the BoundingBox in the Block class?

 

ss7

You sir are a god damn hero.

Link to comment
Share on other sites

Hi

 

To be honest I don't really understand what your code is supposed to do, but I'm pretty sure it's not right...

 

your TileEntity.getRenderBoundingBox() needs to create a bounding box that encloses the entire TileEntity.

If your TileEntity is three blocks wide, then the bounding box needs to enclose it.

 

Perhaps you could explain how your TileEntities interact with each other - how big they are, how they render differently.  How many TileEntities are in the screenshot to make up the double loop thing?

 

By the way I think the reason it's not rendering at all with the code below is because your bounding box needs to enclose the coordinates of the TileEntity, not 0,0,0 to [1,1,1]

 

eg

            bb = AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1);

not      bb = AxisAlignedBB.getBoundingBox(0,0,0,1,1,1);

 

And actually the vanilla code usually uses eg

            bb = AxisAlignedBB.getAABBPool().getAABB(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1);

(I don't know why)

 

I don't think extending Block's BoundingBox will help.

 

-TGG

Link to comment
Share on other sites

Somewhat related side question here:

 

There are several bounding boxes related to a block.

Like collision and render boxes.

 

I was under the impression that they couldn't be wider than the block, is that just for collision boxes or have I mayhaps been wrongly informed? :)

If you guys dont get it.. then well ya.. try harder...

Link to comment
Share on other sites

Hi

 

I don't know of anything stopping them from being wider than the block (although it may lead to strange behaviour). 

 

For example the Beacon does this in TileEntity

  public AxisAlignedBB getRenderBoundingBox()
    {
        AxisAlignedBB bb = INFINITE_EXTENT_AABB;
        Block type = getBlockType();
        if (type == Block.enchantmentTable)
        {
            bb = AxisAlignedBB.getAABBPool().getAABB(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1);
        }
        else if (type == Block.chest || type == Block.chestTrapped)
        {
            bb = AxisAlignedBB.getAABBPool().getAABB(xCoord - 1, yCoord, zCoord - 1, xCoord + 2, yCoord + 2, zCoord + 2);
        }
        else if (type != null && type != Block.beacon)
        {
            AxisAlignedBB cbb = getBlockType().getCollisionBoundingBoxFromPool(worldObj, xCoord, yCoord, zCoord);
            if (cbb != null)
            {
                bb = cbb;
            }
        }
        return bb;
    }

 

i.e. has an infinite bounding box for rendering

 

-TGG

Link to comment
Share on other sites

Hello,

 

Thank you very much, TGG. This line of code really helped me:

 

AxisAlignedBB.getBoundingBox(xCoord, yCoord, zCoord, xCoord + 1, yCoord + 1, zCoord + 1);

 

BTW: On the picture are 6 TileEntitys that are connecting to each other. Now it works perfectly!

 

Thank you VERY much!

 

ss7

You sir are a god damn hero.

Link to comment
Share on other sites

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.