Jump to content

Recommended Posts

Posted

I am changing the way the third person camera works (with base edits) for a project. I've made it so that the camera only rotates in third person when middle mouse is down so the mouse is ungrabbed. I also unbound the player rotation from the camera rotation. My problem now is getting the block that the mouse is hovering over. I've overridden the getLook function in EntityPlayer but can't get anywhere from there. Heres the code in the base getLook function:

            float f1;
            float f2;
            float f3;
            float f4;

            if (par1 == 1.0F)
            {
                f1 = MathHelper.cos(-this.rotationYaw * 0.017453292F - (float)Math.PI);
                f2 = MathHelper.sin(-this.rotationYaw * 0.017453292F - (float)Math.PI);
                f3 = -MathHelper.cos(-this.rotationPitch * 0.017453292F);
                f4 = MathHelper.sin(-this.rotationPitch * 0.017453292F);
                return this.worldObj.getWorldVec3Pool().getVecFromPool((double)(f2 * f3), (double)f4, (double)(f1 * f3));
            }
            else
            {
                f1 = this.prevRotationPitch + (this.rotationPitch - this.prevRotationPitch) * par1;
                f2 = this.prevRotationYaw + (this.rotationYaw - this.prevRotationYaw) * par1;
                f3 = MathHelper.cos(-f2 * 0.017453292F - (float)Math.PI);
                f4 = MathHelper.sin(-f2 * 0.017453292F - (float)Math.PI);
                float f5 = -MathHelper.cos(-f1 * 0.017453292F);
                float f6 = MathHelper.sin(-f1 * 0.017453292F);
                return this.worldObj.getWorldVec3Pool().getVecFromPool((double)(f4 * f5), (double)f6, (double)(f3 * f5));
            }

 

I... Well I have no idea what to do here... Any help would be appreciated! Thanks. 

 

EDIT: I know the basics of what to do but have no idea how to implement it. If anyone has done anything similar to this then please help me out :)

Posted

That would work but I have no idea where to start... And also would that work really? I want to check which block the mouse is hovering over in the custom view and have the black box and allow for right click, left click, etc. while ray tracing seems to be more for things like reflections.

Posted

yes it will work, its true that raytraycing is more popular when used with reflection/refraction/shadow/lighting but thats in the context of graphic rendering. in game programming ray traycing is used a lot to see if the trajectory of 2 object will interact (in your case blocks and your vision)

how to debug 101:http://www.minecraftforge.net/wiki/Debug_101

-hydroflame, author of the forge revolution-

Posted

I have no idea where to start... Any ideas?

 

EDIT: Researched ray tracing a bit and I get how it works... kinda... Well anyways does anyone know the simplest way, or even any way, to do the ray tracing like does anyone have the algorithm that fits this purpose?

Posted

Oh a question for you is, are you familiar with Vectors?

If not, this would be the time to look into that part of math ;)

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

Posted

I know the basics of vectors: They are pretty much x, y, z either representing a location on a 3D grid or the movement of an object over a 3D grid. Checking out the clip methods.

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.