aboutsummaryrefslogtreecommitdiffstats
path: root/src/ru/olamedia/geom/SimpleQuadMesh.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/ru/olamedia/geom/SimpleQuadMesh.java')
-rw-r--r--src/ru/olamedia/geom/SimpleQuadMesh.java145
1 files changed, 105 insertions, 40 deletions
diff --git a/src/ru/olamedia/geom/SimpleQuadMesh.java b/src/ru/olamedia/geom/SimpleQuadMesh.java
index ad3c27c..c28c799 100644
--- a/src/ru/olamedia/geom/SimpleQuadMesh.java
+++ b/src/ru/olamedia/geom/SimpleQuadMesh.java
@@ -1,9 +1,28 @@
package ru.olamedia.geom;
+import javax.vecmath.Point3f;
+
+import ru.olamedia.asset.SpriteRectangle;
+
public class SimpleQuadMesh extends Mesh {
public boolean restart = true;
+ public Point3f bottomLeftBack = new Point3f();
+ public Point3f bottomLeftFront = new Point3f();
+ public Point3f bottomRightBack = new Point3f();
+ public Point3f bottomRightFront = new Point3f();
+
+ public Point3f topLeftBack = new Point3f();
+ public Point3f topLeftFront = new Point3f();
+ public Point3f topRightBack = new Point3f();
+ public Point3f topRightFront = new Point3f();
+
+ public float textureTop = 1;
+ public float textureBottom = 0;
+ public float textureLeft = 0;
+ public float textureRight = 1;
+
public void restart() {
restart = true;
}
@@ -16,108 +35,154 @@ public class SimpleQuadMesh extends Mesh {
super(size * 4);
}
- private void addBottomLeftBackVertex() {
- setPoint3f(-0.5f, -0.5f, -0.5f);
+ public void addBottomLeftBackVertex() {
+ setPoint3f(bottomLeftBack);
}
- private void addBottomLeftFrontVertex() {
- setPoint3f(-0.5f, -0.5f, 0.5f);
+ public void addBottomLeftFrontVertex() {
+ setPoint3f(bottomLeftFront);
}
- private void addBottomRightBackVertex() {
- setPoint3f(0.5f, -0.5f, -0.5f);
+ public void addBottomRightBackVertex() {
+ setPoint3f(bottomRightBack);
}
- private void addBottomRightFrontVertex() {
- setPoint3f(0.5f, -0.5f, 0.5f);
+ public void addBottomRightFrontVertex() {
+ setPoint3f(bottomRightFront);
}
- private void addTopLeftBackVertex() {
- setPoint3f(-0.5f, 0.5f, -0.5f);
+ public void addTopLeftBackVertex() {
+ setPoint3f(topLeftBack);
}
- private void addTopLeftFrontVertex() {
- setPoint3f(-0.5f, 0.5f, 0.5f);
+ public void addTopLeftFrontVertex() {
+ setPoint3f(topLeftFront);
}
- private void addTopRightBackVertex() {
- setPoint3f(0.5f, 0.5f, -0.5f);
+ public void addTopRightBackVertex() {
+ setPoint3f(topRightBack);
}
- private void addTopRightFrontVertex() {
- setPoint3f(0.5f, 0.5f, 0.5f);
+ public void addTopRightFrontVertex() {
+ setPoint3f(topRightFront);
}
public void addFrontQuad() {
// triangle strip: И
- setUV(0, 1);
+ setUV(textureLeft, textureTop);
addTopLeftFrontVertex(); // top left
- setUV(0, 0);
+ setUV(textureLeft, textureBottom);
addBottomLeftFrontVertex(); // bottom left
- setUV(1, 0);
+ setUV(textureRight, textureBottom);
addBottomRightFrontVertex(); // bottom right
- setUV(1, 1);
+ setUV(textureRight, textureTop);
addTopRightFrontVertex(); // top right
}
public void addBackQuad() {
// triangle strip: И
- setUV(0, 1);
+ setUV(textureLeft, textureTop);
addTopRightBackVertex();
- setUV(0, 0);
+ setUV(textureLeft, textureBottom);
addBottomRightBackVertex();
- setUV(1, 0);
+ setUV(textureRight, textureBottom);
addBottomLeftBackVertex();
- setUV(1, 1);
+ setUV(textureRight, textureTop);
addTopLeftBackVertex();
}
public void addLeftQuad() {
// triangle strip: И
- setUV(0, 1);
+ setUV(textureLeft, textureTop);
addTopLeftBackVertex();
- setUV(0, 0);
+ setUV(textureLeft, textureBottom);
addBottomLeftBackVertex();
- setUV(1, 0);
+ setUV(textureRight, textureBottom);
addBottomLeftFrontVertex();
- setUV(1, 1);
+ setUV(textureRight, textureTop);
addTopLeftFrontVertex();
}
public void addRightQuad() {
// triangle strip: И
- setUV(0, 1);
+ setUV(textureLeft, textureTop);
addTopRightFrontVertex();
- setUV(0, 0);
+ setUV(textureLeft, textureBottom);
addBottomRightFrontVertex();
- setUV(1, 0);
+ setUV(textureRight, textureBottom);
addBottomRightBackVertex();
- setUV(1, 1);
+ setUV(textureRight, textureTop);
addTopRightBackVertex();
}
public void addTopQuad() {
// triangle strip: И
- setUV(0, 0);
+ setUV(textureLeft, textureBottom);
addTopLeftBackVertex();
- setUV(0, 1);
+ setUV(textureLeft, textureTop);
addTopLeftFrontVertex();
- setUV(1, 1);
+ setUV(textureRight, textureTop);
addTopRightFrontVertex();
- setUV(1, 0);
+ setUV(textureRight, textureBottom);
addTopRightBackVertex();
}
public void addBottomQuad() {
// triangle strip: И
- setUV(0, 0);
+ setUV(textureLeft, textureBottom);
addBottomLeftFrontVertex();
- setUV(0, 1);
+ setUV(textureLeft, textureTop);
addBottomLeftBackVertex();
- setUV(1, 1);
+ setUV(textureRight, textureTop);
addBottomRightBackVertex();
- setUV(1, 0);
+ setUV(textureRight, textureBottom);
addBottomRightFrontVertex();
}
+ public void setPointOffset(float offset) {
+ bottomLeftBack.x = -offset;
+ bottomLeftBack.y = -offset;
+ bottomLeftBack.z = -offset;
+ //
+ bottomLeftFront.x = -offset;
+ bottomLeftFront.y = -offset;
+ bottomLeftFront.z = offset;
+ //
+ bottomRightBack.x = offset;
+ bottomRightBack.y = -offset;
+ bottomRightBack.z = -offset;
+ //
+ bottomRightFront.x = offset;
+ bottomRightFront.y = -offset;
+ bottomRightFront.z = offset;
+ //
+ topLeftBack.x = -offset;
+ topLeftBack.y = offset;
+ topLeftBack.z = -offset;
+ //
+ topLeftFront.x = -offset;
+ topLeftFront.y = offset;
+ topLeftFront.z = offset;
+ //
+ topRightBack.x = offset;
+ topRightBack.y = offset;
+ topRightBack.z = -offset;
+ //
+ topRightFront.x = offset;
+ topRightFront.y = offset;
+ topRightFront.z = offset;
+
+ }
+
+ public void setTextureOffset(SpriteRectangle offset) {
+ if (null != offset) {
+ // System.out.print("Offset " + "[" + offset.topLeft.x + "," +
+ // offset.topLeft.y + "]");
+ textureTop = offset.topLeft.y;
+ textureLeft = offset.topLeft.x;
+ textureRight = offset.bottomRight.x;
+ textureBottom = offset.bottomRight.y;
+ }
+ }
+
}