Jump to content

Recommended Posts

Posted

Hi Everybody

 

I posted on here a few months back now and never got a solid answer to my question, However i did gain more info on what was going on in the code.

I really need an effect like the one seen in

but i just need one colour. I have learnt that this invokes a render effect within the tile entity class but i have never used such code.

 

I would like it to follow the walls just like in the video but one solid colour of grey.

 

I have been trying to get a similar effect for a few months now with no success.

 

Hopefully i can get an answer

 

thanks

Posted

Hi

 

You can draw whatever you like in the TileEntity Renderer.

 

The basic idea is:

1) in your tile entity tick, shoot out a ray for every spot and figure out where it hits a nearby wall.  (MovingObjectLocation and EntityRenderer.getMouseOver gives you an example of how that can be done).  Remember that location.

2) in your tile entity renderer, take the location of every spot and draw a small rectangle using the Tessellator.  The hardest part is making sure that the [x,y,z] translation is set up correctly to align with the world [x,y,z] coordinates.  Standard tutorials on TileEntitySpecialRenderer will show you how to do that.

 

Look at EntityDropParticleFX and EntityFX.renderParticle for some clues on how to use the tessellator.  Remember to move your particle slightly away from the wall so that it renders just on top of the wall and not inside it.

 

-TGG

Posted

HI there

Thanks for your reply. I have had a look at some tutorials on a tile entity special renderer. I think i know how i am going to move the dots but i am not sure about the drawing still, Would i need an image or could i get it all done in code?. I am only early stage in learning about tessalators and such.

 

Also how would i find the block locations for the squares to move along? Would you have to go through and check every block around the centre "emitter" or would there be a more efficient way?

 

Posted

Hi

 

If you just want a grey dot, then you don't need an image.  Just use the

Tessellator.setColorRGBA() and then

Tessellator.addVertex() instead of Tessellator.addVertexWithUV()

 

You would need to check every block around the centre emitter.  But so long as you don't try and go silly with the range of your dots, or have too many dots, I wouldn't worry about the efficiency.  Retrieving blocks is very fast.

 

-TGG

 

 

Posted

So in the video - they would be using a base image then changing the hue of the image for the different colours? How would they modify the image?

 

also how would you search for a block - would it be a for loo[p with a bunch of statements that ceck if a block is there?

Posted

So in the video - they would be using a base image then changing the hue of the image for the different colours? How would they modify the image?

Yes they would change the hue of the image.  Assuming they're just drawing plain dots, they don't use an image. 

 

 

also how would you search for a block - would it be a for loo[p with a bunch of statements that ceck if a block is there?

EntityRenderer.getMouseOver() is a good example of this.

EntityLivingBase.rayTrace() --> World.rayTraceBlocks_do_do() does all the work for the blocks part of it.  The rest of getMouseOver handles collisions with Entities.

 

-TGG

Posted

So in the video - they would be using a base image then changing the hue of the image for the different colours? How would they modify the image?

Yes they would change the hue of the image.  Assuming they're just drawing plain dots, they don't use an image. 

 

 

also how would you search for a block - would it be a for loo[p with a bunch of statements that ceck if a block is there?

EntityRenderer.getMouseOver() is a good example of this.

EntityLivingBase.rayTrace() --> World.rayTraceBlocks_do_do() does all the work for the blocks part of it.  The rest of getMouseOver handles collisions with Entities.

 

-TGG

 

How would i be able to make a solid colour dot as i don't think i can use and image as well as have a custom 3d rendered block as the textures conflict. Ive had a look through the entity renderer but cannot understand much at all and would not know how to implement it in such a way that scans the area then emits the dots on the blocks.

 

How would the block scanning code look?

Posted

Hi

 

This link might help with the Tessellator

http://greyminecraftcoder.blogspot.com.au/2013/08/the-tessellator.html

 

The block scanning code will look very similar to the vanilla code I mentioned. 

The basic idea is:

1) start from the middle of your ball

2) choose a direction vector for your ray of light from the ball (in the case of the code I mentioned, this is the direction the player is looking)

3) calculate the intersection of that vector with one of the six faces of your ball, i.e. top, bottom, east, west, north, south

4) Check the block that is touching that face.

4a) if the block is solid, you mark this face as the position of the dot and draw it

4b) if the block is not solid, extend the vector into this block.  Figure out which block face it will hit next, i.e. repeat from step 3 until you reach a maximum distance (say, 10 blocks)

 

You will need some basic background in vector maths to understand what is happening in the vanilla code (i.e. enough to understand about vector direction, length, and intersection with a plane).

 

-TGG

Posted

Hi

 

This link might help with the Tessellator

http://greyminecraftcoder.blogspot.com.au/2013/08/the-tessellator.html

 

The block scanning code will look very similar to the vanilla code I mentioned. 

The basic idea is:

1) start from the middle of your ball

2) choose a direction vector for your ray of light from the ball (in the case of the code I mentioned, this is the direction the player is looking)

3) calculate the intersection of that vector with one of the six faces of your ball, i.e. top, bottom, east, west, north, south

4) Check the block that is touching that face.

4a) if the block is solid, you mark this face as the position of the dot and draw it

4b) if the block is not solid, extend the vector into this block.  Figure out which block face it will hit next, i.e. repeat from step 3 until you reach a maximum distance (say, 10 blocks)

 

You will need some basic background in vector maths to understand what is happening in the vanilla code (i.e. enough to understand about vector direction, length, and intersection with a plane).

 

-TGG

 

I have a basic understanding of vectors and understand most of the code you suggested but cannot think how to implement a similar sort of thing to can an area. I understand the code is creating a vector, that is as long as your reach distance, outwards in line with the crosshair and checking whether or not the end point of that vector is in a block.

 

Would i need a for loop that runs for 360 loops for every degree? Then each degree i get the length of the vector? - If it is that i am unsure on how to actually draw the particle images.

 

Ive got everything like the colour and dots setup now, i just need the drawing

Posted

I have been staring at the code for a day now and all attempts fail. Cant seem to figure out how - I've been using the method i suggested with a loop that has 360 checks each degree. Ive totally scrapped all that and have come back to ask the best and correct way of implementing this piece of code

 

Thanks

Posted

Hi

 

I would suggest starting with something easy, i.e. just try to draw a single point.  Is that what you want to do, i.e. draw a number of dots?  Or something more fancy?

 

There are two separate parts to this

1) find the dot location

2) draw the dot

 

Show us an example of your code that worked the best for each part of that?  A cut and paste of EntityRenderer.getMouseOver() should do basically everything you need for part 1.

 

In your TileEntitySpecialRenderer.renderTileEntityAt(TileEntity par1TileEntity, double xOffset, double yOffset, double zOffset, float par8)

your rendering code should look something like this, where [dx, dy, dz] is the difference between your wall spot and the tile entity, i.e.

 

if your tile entity world x = 25 and the spot on the wall is at x = 32, then dx = 7

[umin, vmin] and [umax, vmax] are the texture coordinates you want to draw

 

For the example where the dot is on the west (x negative) wall:

GL11.glPushMatrix();
GL11.glTranslatef(xOffset, yOffset, zOffset);
double SMALL_OFFSET = 0.001;
double DOT_HEIGHT_DIV_2 = 0.1;
double DOT_WIDTH_DIV_2 = 0.1;
            tessellator.startDrawingQuads();
            tessellator.setColorRGBA(255, 255, 255, 255);  // all white
            tessellator.addVertexWithUV(dx - SMALL_OFFSET, dy - DOT_HEIGHT_DIV_2, dz +DOT_WIDTH_DIV_2, umax, vmax); 
            tessellator.addVertexWithUV(dx - SMALL_OFFSET, dy + DOT_HEIGHT_DIV_2, dz + DOT_WIDTH_DIV_2, umax, vmin);
            tessellator.addVertexWithUV(dx - SMALL_OFFSET, dy + DOT_HEIGHT_DIV_2, dz - DOT_WIDTH_DIV_2, umin, vmin);
            tessellator.addVertexWithUV(dx - SMALL_OFFSET, dy - DOT_HEIGHT_DIV_2, dz - DOT_WIDTH_DIV_2, umin, vmax);
tessellator.draw()

GL11.glPopMatrix();

 

I haven't compiled this code but it should be about right.  To draw on other wall faces you will need to alter the addVertexWithUV commands to draw parallel to the face.

If you don't properly understand the tessellator code, looking at this link might help.

http://greyminecraftcoder.blogspot.com.au/2013/08/the-tessellator.html

 

-TGG

 

Posted

Hi

 

I would suggest starting with something easy, i.e. just try to draw a single point.  Is that what you want to do, i.e. draw a number of dots?  Or something more fancy?

 

There are two separate parts to this

1) find the dot location

2) draw the dot

 

Show us an example of your code that worked the best for each part of that?  A cut and paste of EntityRenderer.getMouseOver() should do basically everything you need for part 1.

 

In your TileEntitySpecialRenderer.renderTileEntityAt(TileEntity par1TileEntity, double xOffset, double yOffset, double zOffset, float par8)

your rendering code should look something like this, where [dx, dy, dz] is the difference between your wall spot and the tile entity, i.e.

 

if your tile entity world x = 25 and the spot on the wall is at x = 32, then dx = 7

[umin, vmin] and [umax, vmax] are the texture coordinates you want to draw

 

For the example where the dot is on the west (x negative) wall:

GL11.glPushMatrix();
GL11.glTranslatef(xOffset, yOffset, zOffset);
double SMALL_OFFSET = 0.001;
double DOT_HEIGHT_DIV_2 = 0.1;
double DOT_WIDTH_DIV_2 = 0.1;
            tessellator.startDrawingQuads();
            tessellator.setColorRGBA(255, 255, 255, 255);  // all white
            tessellator.addVertexWithUV(dx - SMALL_OFFSET, dy - DOT_HEIGHT_DIV_2, dz +DOT_WIDTH_DIV_2, umax, vmax); 
            tessellator.addVertexWithUV(dx - SMALL_OFFSET, dy + DOT_HEIGHT_DIV_2, dz + DOT_WIDTH_DIV_2, umax, vmin);
            tessellator.addVertexWithUV(dx - SMALL_OFFSET, dy + DOT_HEIGHT_DIV_2, dz - DOT_WIDTH_DIV_2, umin, vmin);
            tessellator.addVertexWithUV(dx - SMALL_OFFSET, dy - DOT_HEIGHT_DIV_2, dz - DOT_WIDTH_DIV_2, umin, vmax);
tessellator.draw()

GL11.glPopMatrix();

 

I haven't compiled this code but it should be about right.  To draw on other wall faces you will need to alter the addVertexWithUV commands to draw parallel to the face.

If you don't properly understand the tessellator code, looking at this link might help.

http://greyminecraftcoder.blogspot.com.au/2013/08/the-tessellator.html

 

-TGG

 

I have already deleted the other code as it didn't work as expected - i can recreate a similar piece if you would like to work from that

 

I was aiming towards a similar this to in the video wherer they slid around the wall at a speed that is set by a variable - i believe that wouldn't be hard to add once you know the bounding blocks for the effect.

 

The tesselator code i am ok at - i know what all the parameters for it are and how it draws the image.

 

I will post the experimental code once i am finished with it

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.