Jump to content
  • Advertisement

Recommended Posts

Posted (edited)

So the only difference between mine and scrawks code seems to be the code below.

Scrawk's code :

//Get the values in the 8 neighbours which make up a cube
                        for (i = 0; i < 8; i++)
                        {
                            ix = x + VertexOffset[i, 0];
                            iy = y + VertexOffset[i, 1];
                            iz = z + VertexOffset[i, 2];

                            Cube[i] = voxels[ix + iy * width + iz * width * height];
                        }

 

My code :

private static boolean checkIfExpose(Voxel[][][] voxels, int x, int y, int z, float[] cube) {

		Voxel[] surroundingVoxels = getSurroundingVoxels(voxels, x, y, z);
		boolean bool = false;

		for (int i = 0; i < cube.length; i++) {
			cube[i] = 0;
		}

		if (surroundingVoxels[0].getMaterial().equals(VoxelMaterial.Air)) {

			cube[0] = 1f;
			cube[1] = 1f;
			cube[4] = 1f;
			cube[5] = 1f;
			bool = true;

		}

		if (surroundingVoxels[1].getMaterial().equals(VoxelMaterial.Air)) {

			cube[0] = 1f;
			cube[3] = 1f;
			cube[4] = 1f;
			cube[7] = 1f;
			bool = true;

		}

		if (surroundingVoxels[2].getMaterial().equals(VoxelMaterial.Air)) {

			cube[4] = 1f;
			cube[5] = 1f;
			cube[6] = 1f;
			cube[7] = 1f;
			bool = true;

		}

		if (surroundingVoxels[3].getMaterial().equals(VoxelMaterial.Air)) {

			cube[0] = 1f;
			cube[1] = 1f;
			cube[2] = 1f;
			cube[3] = 1f;
			bool = true;

		}

		if (surroundingVoxels[4].getMaterial().equals(VoxelMaterial.Air)) {

			cube[1] = 1f;
			cube[2] = 1f;
			cube[5] = 1f;
			cube[6] = 1f;
			bool = true;

		}

		if (surroundingVoxels[5].getMaterial().equals(VoxelMaterial.Air)) {

			cube[2] = 1f;
			cube[3] = 1f;
			cube[6] = 1f;
			cube[7] = 1f;
			bool = true;

		}

		return bool;
	}

Bare in mind my code is Java and his is C#. If anyone has any ideas, please let me know. Here's a link to the file overall : here

Edit : when I print out the value of a single cube to be rendered (a grid of 1 x 1 x 1) the corners all return 1, shouldn't that mean they are to be rendered?

Edited by thelordposeidon
More info

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!