@author codex

*/

public class Wall {

Vector3f pos, axis;

float width, height, thickness;

Node wallNode = new Node();

RigidBodyControl phys = new RigidBodyControl(0);

Material mat = null;

public static final String REG = “regular”, NONE = “none”, ENTIRE = “entire”, SAME = “same”, WINDOW = “window”;

String doorMode = REG;

float doorWidth = 3f, doorTop = 1.5f, doorOffset = 0;

Vector3f posiPos = new Vector3f();

Vector3f posiSize = new Vector3f();

Vector3f negPos = new Vector3f();

Vector3f negSize = new Vector3f();

Wall(Vector3f pos, Vector3f axis, float width, float height, float thickness) {

this.pos = pos;

this.axis = axis;

this.width = width;

this.height = height;

this.thickness = thickness;

}

protected void setMaterial(Material m) {

mat = m;

}

protected void setDoorWidth(float w) {

if (w != 0) doorWidth = w;

}

protected void setDoorOffset(float off) {

if (off != 0) doorOffset = off;

}

protected void setDoorMode(String mode) {

if (!mode.equals(SAME)) doorMode = mode;

}

protected void setDoorTop(float top) {

if (top != 0) doorTop = top;

}

protected void setDoorMat(Material m) {

}

private void setPosiCoord() {

if (doorMode.equals(REG) || doorMode.equals(WINDOW)) {

float s = Math.abs(width+doorOffset-doorWidth)/2;

if (axis == Vector3f.UNIT_X) {

posiPos.set(width-s, height*0.5f, 0);*

posiSize.set(s, height, thickness);

}

else if (axis == Vector3f.UNIT_Z) {

posiPos.set(0, height0.5f, width-s);

posiSize.set(thickness, height, s);

}

}

else if (doorMode.equals(NONE)) {

if (axis == Vector3f.UNIT_X) {

posiPos.set(0, height*0.5f, 0);*

posiSize.set(width, height, thickness);

}

else if (axis == Vector3f.UNIT_Z) {

posiPos.set(0, height0.5f, 0);

posiSize.set(thickness, height, width);

}

}

}

private void setNegCoord() {

float s = Math.abs(width-doorOffset-doorWidth)/2;

if (axis == Vector3f.UNIT_X) {

negPos.set(-width+s, height*0.5f, 0);*

negSize.set(s, height, thickness);

}

else if (axis == Vector3f.UNIT_Z) {

negPos.set(0, height0.5f, -width+s);

negSize.set(thickness, height, s);

}

}

private void initPosiWall() {

if (!doorMode.equals(ENTIRE)) {

Box b = new Box(posiSize.x, posiSize.y, posiSize.z);

Geometry g = new Geometry(“pos wall”, b);

g.setLocalTranslation(posiPos);

g.setMaterial(mat);

g.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);

//g.setUserData(KEY, this);

wallNode.attachChild(g);

}

}

private void initNegWall() {

if (!doorMode.equals(ENTIRE) && !doorMode.equals(NONE)) {

Box b = new Box(negSize.x, negSize.y, negSize.z);

Geometry g = new Geometry(“neg wall”, b);

g.setLocalTranslation(negPos);

g.setMaterial(mat);

g.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);

wallNode.attachChild(g);

}

}

private void initTop() {

if (!doorMode.equals(ENTIRE) && !doorMode.equals(NONE)) {

Geometry g = new Geometry();

Geometry g2 = new Geometry();

if (axis == Vector3f.UNIT_X) {

Box b = new Box(doorWidth, doorTop, thickness);

g = new Geometry(“top wall”, b);

//g.setMesh(b);

g.setLocalTranslation(-doorOffset, height*1.5f-doorTop, 0);*

g2 = new Geometry(“bottom wall”, b);

g2.setLocalTranslation(-doorOffset, -height0.45f+doorTop, 0);

}

else if (axis == Vector3f.UNIT_Z) {

Box b = new Box(thickness, doorTop, doorWidth);

g = new Geometry(“top wall”, b);

g.setLocalTranslation(0, height*1.5f-doorTop, -doorOffset);*

g2 = new Geometry(“bottom wall”, b);

g2.setLocalTranslation(0, -height0.45f+doorTop, -doorOffset);

}

g.setMaterial(mat);

g2.setMaterial(mat);

g.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);

g2.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);

wallNode.attachChild(g);

if (doorMode.equals(WINDOW)) wallNode.attachChild(g2);

}

}

private void initDoor() {

}

protected void build() {

setPosiCoord();

setNegCoord();

initPosiWall();

initNegWall();

initTop();

```
wallNode.setLocalTranslation(pos);
//wallNode.setUserData(Interactable.KEY, this);
```

}

protected Node getNode() {

return wallNode;

}

}