Skip to content

Commit

Permalink
Add some licenses for attribution purposes on associated code
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleaker committed Feb 23, 2014
1 parent 127210f commit d717f74
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 21 deletions.
32 changes: 26 additions & 6 deletions src/com/jme3/cubed/render/GreedyMesher.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,29 @@
/**
* The MIT License (MIT)
*
* Copyright (c) 2013 Mikola Lysenko - https://github.com/mikolalysenko/greedy-mesher
*
* Adaptation to Java by Robert O'Leary - https://github.com/roboleary/GreedyMesh
* Minor updates to allow Texturing by Nick Minkler
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
package com.jme3.cubed.render;

import com.jme3.cubed.ChunkTerrain;
Expand All @@ -8,12 +34,6 @@
import com.jme3.scene.Mesh;
import java.util.ArrayList;

/**
*
* @author Nicholas Minkler <sleaker@gmail.com>
*/


public class GreedyMesher extends VoxelMesher {

@Override
Expand Down
1 change: 0 additions & 1 deletion src/com/jme3/cubed/render/MarchingCubesMesher.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.jme3.cubed.ChunkTerrain;
import com.jme3.cubed.math.Vector3i;
import com.jme3.math.Vector2f;
import com.jme3.math.Vector3f;
import com.jme3.scene.Mesh;
import java.util.ArrayList;
Expand Down
41 changes: 35 additions & 6 deletions src/com/jme3/cubed/render/NaiveMesher.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
/**
*
* Copyright (c) 2014, Nicholas Minkler
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package com.jme3.cubed.render;

import com.jme3.cubed.Block;
Expand All @@ -17,11 +50,6 @@
import com.jme3.scene.Mesh;
import java.util.ArrayList;


/**
*
* @author Nicholas Minkler <sleaker@gmail.com>
*/
public class NaiveMesher extends VoxelMesher {

@Override
Expand Down Expand Up @@ -77,7 +105,7 @@ public Mesh generateMesh(ChunkTerrain terrain) {
break;
default:
}
// Write the texture coords
// Write the texture coords, width and height is always 1 as we render each cube individually
this.writeTextureCoords(textCoords, terrain, tmpI, face, 1, 1, skin);
}
}
Expand All @@ -86,6 +114,7 @@ public Mesh generateMesh(ChunkTerrain terrain) {
if (indices.isEmpty()) {
return null;
}
// Return the generated mesh from the list of data
return genMesh(verts, textCoords, indices, normals);
}
}
53 changes: 45 additions & 8 deletions src/com/jme3/cubed/render/VoxelMesher.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
/**
*
* Copyright (c) 2014, Nicholas Minkler
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package com.jme3.cubed.render;

import com.jme3.cubed.BlockSkin;
Expand All @@ -10,10 +43,6 @@
import com.jme3.util.BufferUtils;
import java.util.ArrayList;

/**
*
* @author Nicholas Minkler <sleaker@gmail.com>
*/
public abstract class VoxelMesher {
public abstract Mesh generateMesh(ChunkTerrain terrain);

Expand Down Expand Up @@ -56,7 +85,7 @@ protected Mesh genMesh(ArrayList<Vector3f> vertexList, ArrayList<Vector3f> textC
*/
protected void writeQuad(ArrayList<Vector3f> verts, ArrayList<Integer> indices, ArrayList<Float> normals,
Vector3f bottomLeft, Vector3f topLeft, Vector3f topRight, Vector3f bottomRight, Face face) {
//System.out.println("BL: " + bottomLeft + " BR: " + bottomRight + " TL: " + topLeft + " TR: " + topRight);

// Get current vertex count, and add indices to the index list
int vertCount = verts.size();
indices.add(vertCount + 2);
Expand All @@ -73,11 +102,19 @@ protected void writeQuad(ArrayList<Vector3f> verts, ArrayList<Integer> indices,
verts.add(bottomLeft);
verts.add(topLeft);
verts.add(topRight);
verts.add(bottomRight);


verts.add(bottomRight);
}

/**
* Write the texture coordinates t othe coordinate list takes into account the texture offset, then calculates what the 4 corners of the u,v should be.
* @param textureCoords
* @param terrain
* @param blockLoc
* @param face
* @param width
* @param height
* @param skin
*/
protected void writeTextureCoords(ArrayList<Vector3f> textureCoords, ChunkTerrain terrain, Vector3i blockLoc, Face face, int width, int height, BlockSkin skin) {
int textOffset = skin.getTextureOffset(terrain, blockLoc, face);
textureCoords.add(new Vector3f(0, 0, textOffset));
Expand Down

0 comments on commit d717f74

Please sign in to comment.