update to libgdx 1.7.0
not the most current version! have encountered some difficulty with something 1.8.0+ which i've not yet resolved
This commit is contained in:
parent
f10dd8dee5
commit
9ea200b7ff
4
pom.xml
4
pom.xml
|
@ -48,8 +48,8 @@
|
||||||
<maven.compiler.target>1.6</maven.compiler.target>
|
<maven.compiler.target>1.6</maven.compiler.target>
|
||||||
<maven.compiler.source>1.6</maven.compiler.source>
|
<maven.compiler.source>1.6</maven.compiler.source>
|
||||||
|
|
||||||
<gdx.version>1.0.0</gdx.version>
|
<gdx.version>1.7.0</gdx.version>
|
||||||
<gdx-toolbox.version>0.1</gdx-toolbox.version>
|
<gdx-toolbox.version>0.2-SNAPSHOT</gdx-toolbox.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
|
@ -41,13 +41,13 @@ public class ChunkVertexGenerator {
|
||||||
|
|
||||||
builder.begin(
|
builder.begin(
|
||||||
VertexAttributes.Usage.Position |
|
VertexAttributes.Usage.Position |
|
||||||
VertexAttributes.Usage.Color |
|
VertexAttributes.Usage.ColorUnpacked |
|
||||||
VertexAttributes.Usage.Normal |
|
VertexAttributes.Usage.Normal |
|
||||||
VertexAttributes.Usage.TextureCoordinates
|
VertexAttributes.Usage.TextureCoordinates
|
||||||
);
|
);
|
||||||
alphaBuilder.begin(
|
alphaBuilder.begin(
|
||||||
VertexAttributes.Usage.Position |
|
VertexAttributes.Usage.Position |
|
||||||
VertexAttributes.Usage.Color |
|
VertexAttributes.Usage.ColorUnpacked |
|
||||||
VertexAttributes.Usage.Normal |
|
VertexAttributes.Usage.Normal |
|
||||||
VertexAttributes.Usage.TextureCoordinates
|
VertexAttributes.Usage.TextureCoordinates
|
||||||
);
|
);
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.nio.ShortBuffer;
|
||||||
public abstract class BaseModelTileMesh extends TileMesh {
|
public abstract class BaseModelTileMesh extends TileMesh {
|
||||||
private final Vector3 tmpPosition = new Vector3();
|
private final Vector3 tmpPosition = new Vector3();
|
||||||
private final Vector3 tmpNormal = new Vector3();
|
private final Vector3 tmpNormal = new Vector3();
|
||||||
|
private final Vector3 tmpDimensions = new Vector3();
|
||||||
private final BoundingBox tmpBounds = new BoundingBox();
|
private final BoundingBox tmpBounds = new BoundingBox();
|
||||||
|
|
||||||
public BaseModelTileMesh(byte opaqueSides, boolean alpha, float translucency, byte lightValue, Color color) {
|
public BaseModelTileMesh(byte opaqueSides, boolean alpha, float translucency, byte lightValue, Color color) {
|
||||||
|
@ -54,7 +55,7 @@ public abstract class BaseModelTileMesh extends TileMesh {
|
||||||
destVertices.setPos(tmpPosition);
|
destVertices.setPos(tmpPosition);
|
||||||
offset += 3;
|
offset += 3;
|
||||||
|
|
||||||
if (meshPart.mesh.getVertexAttribute(VertexAttributes.Usage.Color) != null) {
|
if (meshPart.mesh.getVertexAttribute(VertexAttributes.Usage.ColorUnpacked) != null) {
|
||||||
// TODO: blend mesh color and source model color somehow?
|
// TODO: blend mesh color and source model color somehow?
|
||||||
destVertices.setCol(vertices.get(offset), vertices.get(offset + 1), vertices.get(offset + 2), vertices.get(offset + 3));
|
destVertices.setCol(vertices.get(offset), vertices.get(offset + 1), vertices.get(offset + 2), vertices.get(offset + 3));
|
||||||
offset += 4;
|
offset += 4;
|
||||||
|
@ -84,8 +85,8 @@ public abstract class BaseModelTileMesh extends TileMesh {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < node.children.size; ++i)
|
for (int i = 0; i < node.getChildCount(); ++i)
|
||||||
collectModelNodeVertices(node.children.get(i), destVertices, textures, color, scaleFactor, positionOffset);
|
collectModelNodeVertices(node.getChild(i), destVertices, textures, color, scaleFactor, positionOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void collectModelNodeVertexPositions(Node node, Array<Vector3> destVertices, Vector3 scaleFactor, Vector3 positionOffset) {
|
protected void collectModelNodeVertexPositions(Node node, Array<Vector3> destVertices, Vector3 scaleFactor, Vector3 positionOffset) {
|
||||||
|
@ -110,13 +111,14 @@ public abstract class BaseModelTileMesh extends TileMesh {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < node.children.size; ++i)
|
for (int i = 0; i < node.getChildCount(); ++i)
|
||||||
collectModelNodeVertexPositions(node.children.get(i), destVertices, scaleFactor, positionOffset);
|
collectModelNodeVertexPositions(node.getChild(i), destVertices, scaleFactor, positionOffset);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void getScaleFactorForModel(Model model, Vector3 scaleToSize, Vector3 out) {
|
protected void getScaleFactorForModel(Model model, Vector3 scaleToSize, Vector3 out) {
|
||||||
model.calculateBoundingBox(tmpBounds);
|
model.calculateBoundingBox(tmpBounds);
|
||||||
MathHelpers.getScaleFactor(tmpBounds.getDimensions(), scaleToSize, out);
|
tmpBounds.getDimensions(tmpDimensions);
|
||||||
|
MathHelpers.getScaleFactor(tmpDimensions, scaleToSize, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int countModelVertices(Model model) {
|
protected int countModelVertices(Model model) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ import com.badlogic.gdx.utils.Array;
|
||||||
public class ModelTileMesh extends BaseModelTileMesh {
|
public class ModelTileMesh extends BaseModelTileMesh {
|
||||||
static final Vector3 tmpPosition = new Vector3();
|
static final Vector3 tmpPosition = new Vector3();
|
||||||
static final Vector3 tmpNormal = new Vector3();
|
static final Vector3 tmpNormal = new Vector3();
|
||||||
|
static final Vector3 tmpDimensions = new Vector3();
|
||||||
static final BoundingBox tmpModelBounds = new BoundingBox();
|
static final BoundingBox tmpModelBounds = new BoundingBox();
|
||||||
static final Vector3 tmpScaleFactor = new Vector3();
|
static final Vector3 tmpScaleFactor = new Vector3();
|
||||||
|
|
||||||
|
@ -74,11 +75,12 @@ public class ModelTileMesh extends BaseModelTileMesh {
|
||||||
);
|
);
|
||||||
|
|
||||||
model.calculateBoundingBox(tmpModelBounds);
|
model.calculateBoundingBox(tmpModelBounds);
|
||||||
|
tmpModelBounds.getDimensions(tmpDimensions);
|
||||||
if (scaleToSize != null) {
|
if (scaleToSize != null) {
|
||||||
MathHelpers.getScaleFactor(tmpModelBounds.getDimensions(), scaleToSize, tmpScaleFactor);
|
MathHelpers.getScaleFactor(tmpDimensions, scaleToSize, tmpScaleFactor);
|
||||||
bounds = new BoundingBox().set(Vector3.Zero, scaleToSize);
|
bounds = new BoundingBox().set(Vector3.Zero, scaleToSize);
|
||||||
} else {
|
} else {
|
||||||
bounds = new BoundingBox().set(Vector3.Zero, tmpModelBounds.getDimensions());
|
bounds = new BoundingBox().set(Vector3.Zero, tmpDimensions);
|
||||||
tmpScaleFactor.set(1.0f, 1.0f, 1.0f);
|
tmpScaleFactor.set(1.0f, 1.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +91,8 @@ public class ModelTileMesh extends BaseModelTileMesh {
|
||||||
private void setupCollisionVertices(Model collisionModel) {
|
private void setupCollisionVertices(Model collisionModel) {
|
||||||
if (scaleToSize != null) {
|
if (scaleToSize != null) {
|
||||||
collisionModel.calculateBoundingBox(tmpModelBounds);
|
collisionModel.calculateBoundingBox(tmpModelBounds);
|
||||||
MathHelpers.getScaleFactor(tmpModelBounds.getDimensions(), scaleToSize, tmpScaleFactor);
|
tmpModelBounds.getDimensions(tmpDimensions);
|
||||||
|
MathHelpers.getScaleFactor(tmpDimensions, scaleToSize, tmpScaleFactor);
|
||||||
} else
|
} else
|
||||||
tmpScaleFactor.set(1.0f, 1.0f, 1.0f);
|
tmpScaleFactor.set(1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,7 @@ public class MultiModelTileMesh extends BaseModelTileMesh {
|
||||||
|
|
||||||
bounds = new BoundingBox();
|
bounds = new BoundingBox();
|
||||||
BoundingBox tmpBounds = new BoundingBox();
|
BoundingBox tmpBounds = new BoundingBox();
|
||||||
|
Vector3 tmpDimensions = new Vector3();
|
||||||
|
|
||||||
// collect the vertices from each of the models provided
|
// collect the vertices from each of the models provided
|
||||||
for (int i = 0; i < models.length; ++i) {
|
for (int i = 0; i < models.length; ++i) {
|
||||||
|
@ -102,11 +103,12 @@ public class MultiModelTileMesh extends BaseModelTileMesh {
|
||||||
Vector3 scaleFactor = new Vector3();
|
Vector3 scaleFactor = new Vector3();
|
||||||
|
|
||||||
submodel.calculateBoundingBox(tmpBounds);
|
submodel.calculateBoundingBox(tmpBounds);
|
||||||
|
tmpBounds.getDimensions(tmpDimensions);
|
||||||
if (scaleToSize != null) {
|
if (scaleToSize != null) {
|
||||||
MathHelpers.getScaleFactor(tmpBounds.getDimensions(), scaleToSize, scaleFactor);
|
MathHelpers.getScaleFactor(tmpDimensions, scaleToSize, scaleFactor);
|
||||||
submodelBounds.set(Vector3.Zero, scaleToSize);
|
submodelBounds.set(Vector3.Zero, scaleToSize);
|
||||||
} else {
|
} else {
|
||||||
submodelBounds.set(Vector3.Zero, tmpBounds.getDimensions());
|
submodelBounds.set(Vector3.Zero, tmpDimensions);
|
||||||
scaleFactor.set(1.0f, 1.0f, 1.0f);
|
scaleFactor.set(1.0f, 1.0f, 1.0f);
|
||||||
}
|
}
|
||||||
bounds.ext(submodelBounds);
|
bounds.ext(submodelBounds);
|
||||||
|
@ -119,11 +121,12 @@ public class MultiModelTileMesh extends BaseModelTileMesh {
|
||||||
|
|
||||||
// figure out what the final scaled bounds and scale factor will be
|
// figure out what the final scaled bounds and scale factor will be
|
||||||
Vector3 scaleFactor = new Vector3();
|
Vector3 scaleFactor = new Vector3();
|
||||||
|
bounds.getDimensions(tmpDimensions);
|
||||||
if (scaleToSize != null) {
|
if (scaleToSize != null) {
|
||||||
MathHelpers.getScaleFactor(bounds.getDimensions(), scaleToSize, scaleFactor);
|
MathHelpers.getScaleFactor(tmpDimensions, scaleToSize, scaleFactor);
|
||||||
bounds = new BoundingBox().set(Vector3.Zero, scaleToSize);
|
bounds = new BoundingBox().set(Vector3.Zero, scaleToSize);
|
||||||
} else {
|
} else {
|
||||||
bounds = new BoundingBox().set(Vector3.Zero, bounds.getDimensions());
|
bounds = new BoundingBox().set(Vector3.Zero, tmpDimensions);
|
||||||
scaleFactor.set(1.0f, 1.0f, 1.0f);
|
scaleFactor.set(1.0f, 1.0f, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,11 +143,12 @@ public class MultiModelTileMesh extends BaseModelTileMesh {
|
||||||
private void setupCollisionVertices(Model collisionModel) {
|
private void setupCollisionVertices(Model collisionModel) {
|
||||||
if (collisionModel != null) {
|
if (collisionModel != null) {
|
||||||
BoundingBox tmpBounds = new BoundingBox();
|
BoundingBox tmpBounds = new BoundingBox();
|
||||||
|
Vector3 tmpDimensions = new Vector3();
|
||||||
Vector3 scaleFactor = new Vector3();
|
Vector3 scaleFactor = new Vector3();
|
||||||
|
|
||||||
if (scaleToSize != null) {
|
if (scaleToSize != null) {
|
||||||
collisionModel.calculateBoundingBox(tmpBounds);
|
collisionModel.calculateBoundingBox(tmpBounds);
|
||||||
MathHelpers.getScaleFactor(tmpBounds.getDimensions(), scaleToSize, scaleFactor);
|
MathHelpers.getScaleFactor(tmpDimensions, scaleToSize, scaleFactor);
|
||||||
} else
|
} else
|
||||||
scaleFactor.set(1.0f, 1.0f, 1.0f);
|
scaleFactor.set(1.0f, 1.0f, 1.0f);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue