Paradroidz question...

Started by Jamison, August 31, 2006, 06:33:45 AM

Previous topic - Next topic

Jamison

How did you achieve such perfect lighting in Paradroidz? I looked through your level code, and your placing walls by referancing a text file and placing them accordingly - so your levels are not in one 3DS object file. Okay anyway, so I tried loading my walls and floors the same way, individually placing them (I already wanted to do it this way before I even found the Paradroidz source) accordingly. But my lighting is all messy. Take a look: http://www.jamisongames.info/Screenshot.jpg

Here's some of my code:
String map[] = {
"    ********",
"    *......*",
"  ***......*",
"  *........***",
"********.....*",
"*......*.....******",
"*......D..........*",
"*......*..........*",
"********..........*",
"   *..............*",
"   ****************"
};

.....

public void Init() {
ObjectHolder.init();
world.setAmbientLight(200, 200, 200);
camera.rotateCameraX((float)Math.toRadians(32));
camera.setPosition(new SimpleVector(10, -10, -5));

world.addLight(new SimpleVector(10, -0.5, 10), 255, 0, 0);
world.setLightDiscardDistance(0, 5);

BuildLevel();
}

public void BuildLevel() {
int mapH = map.length;
for (int i=0; i<mapH; i++) {
int mapW = map[i].length();
for (int j=0; j<mapW; j++) {
char c = map[i].charAt(j);
if (c == '*') {
Object3D wall = new Object3D(ObjectHolder.getObject(0));
float bBox[] = wall.getMesh().getBoundingBox();
wall.translate(bBox[1]*j, 0, bBox[5]*i);
world.addObject(wall);
}
if (c == '.') {
Object3D floor = new Object3D(ObjectHolder.getObject(1));
float bBox[] = floor.getMesh().getBoundingBox();
floor.translate(bBox[1]*j, 0, bBox[5]*i);
world.addObject(floor);
}
}
}
world.buildAllObjects();
}

.....

The "....." represents code that's not necessary to be shown.

EgonOlsen

The lighting (at least most of it) is static and uses multi texturing light mapping. To create it, i've used this tool: http://www.frecle.net/giles/. But beware: The 1.36 is bugged and makes the lighting look bad. So i've bought the 1.36 version but am using the 1.32 with the same license instead.
Anyway...Paradroidz comes with two small files in the ...util.tools-package: ASCExtractor and LightMapper. With ASCExtractor, i've created 3D-model-files in ASC-format out of the geometry generated from the actual ascii-based level maps. I've loaded these files into Gile, placed the lights, let it calculate the light maps and saved map and geometry (including the texture coords for the light mapping) in 3ds format. Then i used the LightMapper to load these 3ds-files and convert them into a simple text file containing texture coords only which i'm loading after loading the actual level in Paradroidz.
Problem with this approach is: The level is still based on the ascii-map, i.e. i can be edited with notepad but the lighting doesn't match if any longer if you do so.

Jamison

But what about the dynamic lights? Such as the red light surrounding the player droid (and the blue light surrounding it when pressing RMB). And also the alert lights.

EgonOlsen

Oh well, those are using simple vertex lighting. You've to play around with the discard distance and attenuation to make this look good. Either global by using the settings in Config or for each light by using the methods in World. The upcoming 1.12 will include a helper class for lights that makes managing lights easier and more OO. But it won't add new features, so you can already use what's there to get the effect.

Jamison

Okay, I'll play around with the settings. I appreciate the help. Hopefully I can get my desired effect.