Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (480)
Games in Android Showcase (110)
games submitted by our members
Games in WIP (547)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Drawing walls  (Read 1957 times)
0 Members and 1 Guest are viewing this topic.
Offline sproket

Junior Member


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.

(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;
}


Offline Riven
« League of Dukes »

JGO Overlord


Medals: 781
Projects: 4
Exp: 16 years


Hand over your head.


« 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
Offline sproket

Junior Member


Medals: 1



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

Thanks. Yes I figured it out.  Grin

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

atombrot (23 views)
2014-08-19 09:29:53

Tekkerue (22 views)
2014-08-16 06:45:27

Tekkerue (21 views)
2014-08-16 06:22:17

Tekkerue (12 views)
2014-08-16 06:20:21

Tekkerue (19 views)
2014-08-16 06:12:11

Rayexar (57 views)
2014-08-11 02:49:23

BurntPizza (37 views)
2014-08-09 21:09:32

BurntPizza (29 views)
2014-08-08 02:01:56

Norakomi (36 views)
2014-08-06 19:49:38

BurntPizza (66 views)
2014-08-03 02:57:17
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
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
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!