use of com.jme3.scene.shape.Line in project jmonkeyengine by jMonkeyEngine.
the class TestMultipleApplications method main.
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
final AppSettings settings = new AppSettings(true);
settings.setOpenCLSupport(true);
settings.setVSync(true);
settings.setOpenCLPlatformChooser(CustomPlatformChooser.class);
settings.setRenderer(AppSettings.JOGL_OPENGL_FORWARD_COMPATIBLE);
for (int i = 0; i < 2; ++i) {
new Thread() {
public void run() {
if (currentDeviceIndex == -1) {
return;
}
TestMultipleApplications app = new TestMultipleApplications();
app.setSettings(settings);
app.setShowSettings(false);
app.start();
}
}.start();
}
}
use of com.jme3.scene.shape.Line in project jmonkeyengine by jMonkeyEngine.
the class LODGeomap method writeIndexArrayLodDiff.
/**
* Create the LOD index array that will seam its edges with its neighbour's LOD.
* This is a scary method!!! It will break your mind.
*
* @param store to store the index buffer
* @param lod level of detail of the mesh
* @param rightLod LOD of the right neighbour
* @param topLod LOD of the top neighbour
* @param leftLod LOD of the left neighbour
* @param bottomLod LOD of the bottom neighbour
* @return the LOD-ified index buffer
*/
public IndexBuffer writeIndexArrayLodDiff(int lod, boolean rightLod, boolean topLod, boolean leftLod, boolean bottomLod, int totalSize) {
int numIndexes = calculateNumIndexesLodDiff(lod);
IndexBuffer ib = IndexBuffer.createIndexBuffer(numIndexes, numIndexes);
VerboseBuffer buffer = new VerboseBuffer(ib);
//System.out.println(" for (z="+lod+"; z<"+(getWidth()-(1*lod))+"; z+="+lod+")");
for (int r = lod; r < getWidth() - (2 * lod); r += lod) {
// row
int rowIdx = r * getWidth();
int nextRowIdx = (r + 1 * lod) * getWidth();
for (int c = lod; c < getWidth() - (1 * lod); c += lod) {
// column
int idx = rowIdx + c;
buffer.put(idx);
idx = nextRowIdx + c;
buffer.put(idx);
}
// add degenerate triangles
if (r < getWidth() - (3 * lod)) {
int idx = nextRowIdx + getWidth() - (1 * lod) - 1;
buffer.put(idx);
// inset by 1
idx = nextRowIdx + (1 * lod);
buffer.put(idx);
//System.out.println("");
}
}
//System.out.println("\nright:");
//int runningBufferCount = buffer.getCount();
//System.out.println("buffer start: "+runningBufferCount);
// right
int br = getWidth() * (getWidth() - lod) - 1 - lod;
// bottom right -1
buffer.put(br);
int corner = getWidth() * getWidth() - 1;
// bottom right corner
buffer.put(corner);
if (rightLod) {
// if lower LOD
for (int row = getWidth() - lod; row >= 1 + lod; row -= 2 * lod) {
int idx = (row) * getWidth() - 1 - lod;
buffer.put(idx);
idx = (row - lod) * getWidth() - 1;
buffer.put(idx);
if (row > lod + 1) {
//if not the last one
idx = (row - lod) * getWidth() - 1 - lod;
buffer.put(idx);
idx = (row - lod) * getWidth() - 1;
buffer.put(idx);
} else {
}
}
} else {
//br+1);//degenerate to flip winding order
buffer.put(corner);
for (int row = getWidth() - lod; row > lod; row -= lod) {
// mult to get row
int idx = row * getWidth() - 1;
buffer.put(idx);
buffer.put(idx - lod);
}
}
buffer.put(getWidth() - 1);
// top (the order gets reversed here so the diagonals line up)
if (topLod) {
// if lower LOD
if (rightLod) {
buffer.put(getWidth() - 1);
}
for (int col = getWidth() - 1; col >= lod; col -= 2 * lod) {
// next row
int idx = (lod * getWidth()) + col - lod;
buffer.put(idx);
idx = col - 2 * lod;
buffer.put(idx);
if (col > lod * 2) {
//if not the last one
idx = (lod * getWidth()) + col - 2 * lod;
buffer.put(idx);
idx = col - 2 * lod;
buffer.put(idx);
} else {
}
}
} else {
if (rightLod) {
buffer.put(getWidth() - 1);
}
for (int col = getWidth() - 1 - lod; col > 0; col -= lod) {
int idx = col + (lod * getWidth());
buffer.put(idx);
idx = col;
buffer.put(idx);
}
buffer.put(0);
}
buffer.put(0);
// left
if (leftLod) {
// if lower LOD
if (topLod) {
buffer.put(0);
}
for (int row = 0; row < getWidth() - lod; row += 2 * lod) {
int idx = (row + lod) * getWidth() + lod;
buffer.put(idx);
idx = (row + 2 * lod) * getWidth();
buffer.put(idx);
if (row < getWidth() - 1 - 2 * lod) {
//if not the last one
idx = (row + 2 * lod) * getWidth() + lod;
buffer.put(idx);
idx = (row + 2 * lod) * getWidth();
buffer.put(idx);
} else {
}
}
} else {
if (!topLod) {
buffer.put(0);
}
//buffer.put(0); // degenerate winding-flip
for (int row = lod; row < getWidth() - lod; row += lod) {
int idx = row * getWidth();
buffer.put(idx);
idx = row * getWidth() + lod;
buffer.put(idx);
}
}
buffer.put(getWidth() * (getWidth() - 1));
// bottom
if (bottomLod) {
// if lower LOD
if (leftLod) {
buffer.put(getWidth() * (getWidth() - 1));
}
// seemed to be fixed by making "getWidth()-1-2-lod" this: "getWidth()-1-2*lod", which seems more correct
for (int col = 0; col < getWidth() - lod; col += 2 * lod) {
int idx = getWidth() * (getWidth() - 1 - lod) + col + lod;
buffer.put(idx);
idx = getWidth() * (getWidth() - 1) + col + 2 * lod;
buffer.put(idx);
if (col < getWidth() - 1 - 2 * lod) {
//if not the last one
idx = getWidth() * (getWidth() - 1 - lod) + col + 2 * lod;
buffer.put(idx);
idx = getWidth() * (getWidth() - 1) + col + 2 * lod;
buffer.put(idx);
} else {
}
}
} else {
if (leftLod) {
buffer.put(getWidth() * (getWidth() - 1));
}
for (int col = lod; col < getWidth() - lod; col += lod) {
// up
int idx = getWidth() * (getWidth() - 1 - lod) + col;
buffer.put(idx);
// down
idx = getWidth() * (getWidth() - 1) + col;
buffer.put(idx);
}
//buffer.put(getWidth()*getWidth()-1-lod); // <-- THIS caused holes at the end!
}
buffer.put(getWidth() * getWidth() - 1);
// fill in the rest of the buffer with degenerates, there should only be a couple
for (int i = buffer.getCount(); i < numIndexes; i++) {
buffer.put(getWidth() * getWidth() - 1);
}
return buffer.delegate;
}
Aggregations