Java-Gaming.org Hi !
 Featured games (91) games approved by the League of Dukes Games in Showcase (757) Games in Android Showcase (229) games submitted by our members Games in WIP (844) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
Pages: [1]
 ignore  |  Print
 Drawing walls  (Read 2855 times) 0 Members and 1 Guest are viewing this topic.
sproket

Junior Devvie

Medals: 1

 « Posted 2009-09-23 23:00:18 »

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.

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);

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);
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);
return posnTG;
}

Riven

« JGO Overlord »

Medals: 1340
Projects: 4
Exp: 16 years

 « Reply #1 - Posted 2009-09-27 10:55:57 »

for 45 degrees, divide by 0.707

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social rankings!
sproket

Junior Devvie

Medals: 1

 « Reply #2 - Posted 2009-10-10 10:48:43 »

Thanks. Yes I figured it out.

Pages: [1]
 ignore  |  Print

 EgonOlsen (47 views) 2018-06-10 19:43:48 EgonOlsen (29 views) 2018-06-10 19:43:44 EgonOlsen (49 views) 2018-06-10 19:43:20 DesertCoockie (213 views) 2018-05-13 18:23:11 nelsongames (130 views) 2018-04-24 18:15:36 nelsongames (129 views) 2018-04-24 18:14:32 ivj94 (870 views) 2018-03-24 14:47:39 ivj94 (131 views) 2018-03-24 14:46:31 ivj94 (782 views) 2018-03-24 14:43:53 Solater (146 views) 2018-03-17 05:04:08
 Java Gaming Resourcesby philfrei2017-12-05 19:38:37Java Gaming Resourcesby philfrei2017-12-05 19:37:39Java Gaming Resourcesby philfrei2017-12-05 19:36:10Java Gaming Resourcesby philfrei2017-12-05 19:33:10List of Learning Resourcesby elect2017-03-13 14:05:44List of Learning Resourcesby elect2017-03-13 14:04:45SF/X Librariesby philfrei2017-03-02 08:45:19SF/X Librariesby philfrei2017-03-02 08:44:05
 java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org