Drawing walls

HI all,

I’m writing a maze app which is based on the example in Killer Game Programming in Java chapter 25. In that code the author draws blocks at the coordinates defined in a 2d array.

(http://fivedots.coe.psu.ac.th/~ad/jg/ch16/index.html)

In my case I want to draw separate walls including walls at an angle (like / or ).

When I draw the angle walls they are too short. I thought that I could use a standard calculation for the hypotenuse but then it’s too long.

Here’s the relevant code:
`
private static final float RADIUS = 0.5f;

private static final float HEIGHT = 1.3f;

private static final float THICKNESS = 0.025f;

private TransformGroup frontWall(int x, int z, int flags, Appearance app) {
Primitive wall = new Box(THICKNESS, HEIGHT / 2, RADIUS, flags, app);

Transform3D rot = new Transform3D();
rot.rotY(-Math.PI / 2.0d); // 90

TransformGroup posnTG = new TransformGroup();
Transform3D trans = new Transform3D(rot);
trans.setTranslation(new Vector3d(x, HEIGHT / 2, z + RADIUS - THICKNESS));
posnTG.setTransform(trans);
posnTG.addChild(wall);

return posnTG;
}

private TransformGroup leftWall(int x, int z, int flags, Appearance app) {
Primitive wall = new Box(THICKNESS, HEIGHT / 2, RADIUS, flags, app);
TransformGroup posnTG = new TransformGroup();
Transform3D trans = new Transform3D();
trans.setTranslation(new Vector3d(x - RADIUS, HEIGHT / 2, z));
posnTG.setTransform(trans);
posnTG.addChild(wall);
return posnTG;
}

private TransformGroup bslashWall(int x, int z, int flags, Appearance app) {
// angles need to be a bit longer. BY HOW MUCH?
//
Primitive wall = new Box(THICKNESS, HEIGHT / 2, RADIUS, flags, app);

Transform3D rot = new Transform3D();
rot.rotY(Math.PI / 4.0d); // 45
TransformGroup posnTG = new TransformGroup();
Transform3D trans = new Transform3D(rot);
trans.setTranslation(new Vector3d(x, HEIGHT / 2, z + THICKNESS));
posnTG.setTransform(trans);
posnTG.addChild(wall);
return posnTG;
}
`

for 45 degrees, divide by 0.707

Thanks. Yes I figured it out. ;D