Skip to content
Permalink
Browse files
update GEOEngine with the Code from https://github.com/zzsort/monono2
  • Loading branch information
Falke3434 committed May 23, 2020
1 parent e968a53 commit 686f928
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 8 deletions.
@@ -89,7 +89,7 @@ public static Map<String, Spatial> loadMeshs(String fileName) throws IOException
for (int c = 0; c < modelCount; c++) {
Mesh m = new Mesh();

int vectorCount = (geo.getShort()) * 3;
int vectorCount = (geo.getInt()) * 3;
ByteBuffer floatBuffer = ByteBuffer.allocateDirect(vectorCount * 4);
FloatBuffer vertices = floatBuffer.asFloatBuffer();
for (int x = 0; x < vectorCount; x++) {
@@ -157,15 +157,26 @@ public static boolean loadWorld(int worldId, Map<String, Spatial> models, GeoMap
geo = roChannel.map(FileChannel.MapMode.READ_ONLY, 0, (int) roChannel.size()).load();
geo.order(ByteOrder.LITTLE_ENDIAN);
if (geo.get() == 0) {
map.setTerrainData(new short[] { geo.getShort() });
}
else {
// no terrain
map.setTerrainData(new short[]{geo.getShort()});
/*int cutoutSize =*/ geo.getInt();
} else {
int size = geo.getInt();
short[] terrainData = new short[size];
for (int i = 0; i < size; i++) {
terrainData[i] = geo.getShort();
}
map.setTerrainData(terrainData);

// read list of terrain indexes to remove.
int cutoutSize = geo.getInt();
if (cutoutSize > 0) {
int[] cutoutData = new int[cutoutSize];
for (int i = 0; i < cutoutSize; i++) {
cutoutData[i] = geo.getInt();
}
map.setTerrainCutouts(cutoutData);
}
}

while (geo.hasRemaining()) {
@@ -179,6 +190,7 @@ public static boolean loadWorld(int worldId, Map<String, Spatial> models, GeoMap
matrix[i] = geo.getFloat();
}
float scale = geo.getFloat();
geo.get(); // TODO : use the data: EventType eventType = EventType.fromByte(geo.get());
Matrix3f matrix3f = new Matrix3f();
matrix3f.set(matrix);
Spatial node = models.get(name.toLowerCase().intern());
@@ -17,6 +17,7 @@
package com.aionemu.gameserver.geoEngine.models;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -317,10 +318,18 @@ private Vector3f terraionCollision(float x, float y, Ray ray) {
else {
int size = (int) Math.sqrt(terrainData.length);
try {
p1 = terrainData[(yInt + (xInt * size))] / 32f;
p2 = terrainData[((yInt + 1) + (xInt * size))] / 32f;
p3 = terrainData[((yInt) + ((xInt + 1) * size))] / 32f;
p4 = terrainData[((yInt + 1) + ((xInt + 1) * size))] / 32f;
int index = yInt + (xInt * size);
p1 = terrainData[index] / 32f;
p2 = terrainData[index + 1] / 32f;
p3 = terrainData[index + size] / 32f;
p4 = terrainData[index + size+ 1] / 32f;

// check if the terrain quad is removed.
if (terrainCutoutData != null) {
if (Arrays.binarySearch(terrainCutoutData, index) >= 0) {
//return false;
}
}
}
catch (Exception e) {
return null;
@@ -392,4 +401,11 @@ public void updateModelBound() {
}
super.updateModelBound();
}

private int[] terrainCutoutData;
public void setTerrainCutouts(int[] cutoutData) {
int[] arr = cutoutData.clone();
Arrays.sort(arr);
this.terrainCutoutData = arr;
}
}

0 comments on commit 686f928

Please sign in to comment.