www.jpct.net

jPCT - a 3d engine for Java => Support => Topic started by: AGP on August 18, 2012, 10:03:04 am

Title: ShadowHelper Code Never Completes
Post by: AGP on August 18, 2012, 10:03:04 am
The following lines never complete (I put it in its own thread BECAUSE it was locking my program). The video hardware is NVidia GeForce GT 540M.

Code: [Select]
     public void run() {
Config.glDynamicBatchSize = 4000;
projector = new Projector();
projector.setFOV(1.5f);
projector.setYFOV(1.5f);
sh = new ShadowHelper(theWorld, buffer, projector, 512);
sh.setCullingMode(false);
sh.setAmbientLight(new Color(30, 30, 30));
sh.setLightMode(true);
sh.setBorder(1);
sh.addCaster(hero.get(0));
sh.addReceiver(ground);
sun = new Light(theWorld);
sun.setIntensity(250, 250, 250);
sun.setAttenuation(800);
theCamera.setFOV(1.5f);
System.out.println("\n\n\nFinished shadows.\n\n");
     }
Title: Re: ShadowHelper Code Never Completes
Post by: EgonOlsen on August 18, 2012, 10:42:42 am
I don't know in which context you call run() (some extra thread of yours?), but when using the AWTGLRenderer, you have to ensure that the paint()-method of the component can run, i.e. that the component is able to repaint itself while initializing the ShadowHelper. The ShadowHelper has to query the driver for information about the supported modes and this can only be done in the rendering thread, i.e. in the paint()-method. So the ShadowHelper has to wait for the next repaint of the component to happen to get this information. If, for whatever reason, this repaint never comes, the ShadowHelper never returns.
Title: Re: ShadowHelper Code Never Completes
Post by: AGP on August 18, 2012, 05:24:24 pm
I said it was moved to a separate thread because it locks (hence, the run() method). I'm not overriding paint(Graphics), I use my own draw() for active rendering, but I did call glCanvas.repaint(), super.repaint(), and even super.paint(this.getGraphics()). None helped.
Title: Re: ShadowHelper Code Never Completes
Post by: EgonOlsen on August 18, 2012, 09:44:13 pm
Under normal conditions, it works fine. So you are doing something that prevents the canvas from being repainted. What you are supposed to do:


There shouldn't be any need to call repaint()/paint()/whatever() yourself nor do you have to spawn another thread because the rendering already takes place in the AWT event dispatch thread, which happens in parallel to your own code.

Just make sure that you aren't blocking the AWT event dispatch thread from executing at the time you are setting up the ShadowHelper and that the canvas is visible and can be repainted.
Title: Re: ShadowHelper Code Never Completes
Post by: AGP on August 19, 2012, 04:31:33 am
I don't know what I changed about it (it wasn't the order of the operations, but I did leave the repaint calls in), but it completes now. Problem now is that the screen gets stuck on black. The following is ShadowHelper's console output. The ShadowHelper is configured for a 512x512 map. Its initialization is no longer on a separate thread, as that's no longer needed.

Driver is: igdumd64/8.15.10.2253 on NVIDIA Corporation / GeForce GT 540M/PCIe/SS
E2
GL_ARB_texture_env_combine supported and used!
FBO supported and used!
VBO supported and used!
OpenGL renderer initialized (using 4 texture stages)
Hardware supports textures up to 16384*16384 in size!
Adding Lightsource: 0
Title: Re: ShadowHelper Code Never Completes
Post by: AGP on August 19, 2012, 04:43:47 am
OK, never mind that, it was an unrelated problem. Still, though ShadowHelper completes and though I do

Code: [Select]
SimpleVector offset = new SimpleVector(1, 0, -1).normalize();
offset.rotateY(0.007f);
projector.lookAt(ground.getTransformedCenter());
projector.setPosition(hero.get(0).getTransformedCenter());
projector.moveCamera(new SimpleVector(0, -1, 0), 200);
projector.moveCamera(offset, 215);
sun.setPosition(projector.getPosition());
sh.updateShadowMap();
sh.drawScene();

before calling buffer.update, I see no shadows being cast.
Title: Re: ShadowHelper Code Never Completes
Post by: AGP on August 20, 2012, 08:50:25 am
By the way, I ran the AdvancedExample on this computer and it has no trouble casting shadows. I've compared both programs to death, and, for the life of me, can't tell the difference. I thought it might be Bones's fault, but I added a cube from the Primitives class and added it as a caster and I still get no shadows.

Also, I have since replaced the snork.md2 model on the AdvancedExample with my Bones model, using my initialization code, and it worked. But it won't work on my own program!
Title: Re: ShadowHelper Code Never Completes
Post by: EgonOlsen on August 20, 2012, 09:26:16 am
Any suspicious log output? I doubt it, but you never know so maybe you could post the log...
Title: Re: ShadowHelper Code Never Completes
Post by: AGP on August 20, 2012, 09:37:04 am
Here you go:
...
Code: [Select]
IDle: 3 Walk: 2 RUNS: 9
Driver is: igdumd64/8.15.10.2253 on NVIDIA Corporation / GeForce GT 540M/PCIe/S
E2
GL_ARB_texture_env_combine supported and used!
FBO supported and used!
VBO supported and used!
OpenGL renderer initialized (using 4 texture stages)
Hardware supports textures up to 16384*16384 in size!
Adding Lightsource: 0



Finished shadows. Initialized properly? true


OS Version: Windows 7
New WorldProcessor created using 1 thread(s) and granularity of 1!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 25/object27 compiled using 6 vertices in 0ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 25/object27 compiled using 6 vertices in 0ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 25/object27 compiled using 6 vertices in 0ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 25/object27 compiled using 6 vertices in 0ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 25/object27 compiled using 6 vertices in 1ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 25/object27 compiled using 6 vertices in 0ms!
Object 25/object27 compiled to 6 subobjects in 6ms!
Creating new world processor buffer for thread main
New WorldProcessor created using 1 thread(s) and granularity of 1!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 23997 vertices
n 47ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 10119 vertices
n 15ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 1176 vertices i
 1ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 12108 vertices
n 13ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 1044 vertices i
 1ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 816 vertices in
2ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 13728 vertices
n 15ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 18054 vertices
n 21ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 6210 vertices i
 9ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 3783 vertices i
 4ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 1368 vertices i
 1ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 1404 vertices i
 1ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 1467 vertices i
 1ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 9210 vertices i
 14ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 23997 vertices
n 26ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 10506 vertices
n 12ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 2703 vertices i
 5ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 558 vertices in
1ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 2424 vertices i
 3ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 23997 vertices
n 28ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 24000 vertices
n 35ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 19323 vertices
n 26ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 23997 vertices
n 32ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 24000 vertices
n 28ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 24000 vertices
n 31ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 14058 vertices
n 16ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 20856 vertices
n 5ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 22512 vertices
n 6ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 1626 vertices i
 1ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 768 vertices in
0ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 279 vertices in
0ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 6630 vertices i
 2ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 2784 vertices i
 2ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 372 vertices in
1ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 5/Silmaria_PT1_PT2_006_jPCT5 compiled using 7920 vertices i
 2ms!
Object 5/Silmaria_PT1_PT2_006_jPCT5 compiled to 35 subobjects in 1124ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 6/ground_jPCT6 compiled using 330 vertices in 1ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 6/ground_jPCT6 compiled using 495 vertices in 1ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 6/ground_jPCT6 compiled using 54 vertices in 0ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 6/ground_jPCT6 compiled using 984 vertices in 1ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 6/ground_jPCT6 compiled using 24 vertices in 0ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 6/ground_jPCT6 compiled using 450 vertices in 0ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 6/ground_jPCT6 compiled using 246 vertices in 1ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 6/ground_jPCT6 compiled using 180 vertices in 0ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 6/ground_jPCT6 compiled using 23997 vertices in 5ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 6/ground_jPCT6 compiled using 2883 vertices in 0ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 6/ground_jPCT6 compiled using 10386 vertices in 2ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 6/ground_jPCT6 compiled using 246 vertices in 0ms!
Object 6/ground_jPCT6 compiled to 12 subobjects in 77ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 7/leaves_jPCT7 compiled using 23997 vertices in 7ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 7/leaves_jPCT7 compiled using 651 vertices in 1ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 7/leaves_jPCT7 compiled using 9018 vertices in 3ms!
Object 7/leaves_jPCT7 compiled to 3 subobjects in 57ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 8/leaves2_jPCT8 compiled using 6744 vertices in 1ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 8/leaves2_jPCT8 compiled using 2268 vertices in 1ms!
Object 8/leaves2_jPCT8 compiled to 2 subobjects in 23ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 9/Leaves3_jPCT9 compiled using 7776 vertices in 2ms!
Object 9/Leaves3_jPCT9 compiled to 1 subobjects in 13ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 10/Leaves4_jPCT10 compiled using 21492 vertices in 6ms!
Object 10/Leaves4_jPCT10 compiled to 1 subobjects in 28ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 11/a_jPCT11 compiled using 2910 vertices in 2ms!
Object 11/a_jPCT11 compiled to 1 subobjects in 6ms!
Checking for triangle strip...
Not a triangle strip at position 1!
Subobject of object 12/Leaves5_jPCT12 compiled using 5616 vertices in 2ms!
Object 12/Leaves5_jPCT12 compiled to 1 subobjects in 29ms!
Creating new world processor buffer for thread main
Checking for triangle strip...
Not a triangle strip at position 1!
Remapping 48 vertex indices!
Creating vertex cache (1152 bytes)!
Vertex indices will be mapped!
Subobject of object 26/object28 compiled using 48 vertices in 1ms!
Object 26/object28 compiled to 1 subobjects in 1ms!
Additional visibility list (2) created with size: 128000
Additional visibility list (3) created with size: 128000
Total FPS: 1, Polygons/second: 1
VBO created for object 'ground_jPCT6'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'ground_jPCT6'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'object27'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'ground_jPCT6'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'leaves_jPCT7'
VBO created for object 'object27'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'object27'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'ground_jPCT6'
VBO created for object 'leaves2_jPCT8'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'ground_jPCT6'
VBO created for object 'Leaves4_jPCT10'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'leaves_jPCT7'
VBO created for object 'leaves_jPCT7'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'ground_jPCT6'
VBO created for object 'object27'
VBO created for object 'Leaves3_jPCT9'
VBO created for object 'ground_jPCT6'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'object27'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'ground_jPCT6'
VBO created for object 'Leaves5_jPCT12'
VBO created for object 'ground_jPCT6'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'ground_jPCT6'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'object27'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'ground_jPCT6'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'a_jPCT11'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'ground_jPCT6'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'Silmaria_PT1_PT2_006_jPCT5'
VBO created for object 'leaves2_jPCT8'
Compiled 62 VBO!
Total FPS: 2, Polygons/second: 3
Total FPS: 41, Polygons/second: 538
Total FPS: 90, Polygons/second: 2341
Title: Re: ShadowHelper Code Never Completes
Post by: EgonOlsen on August 20, 2012, 04:13:45 pm
Looks fien at first glance. Could you post your render-"loop"?
Title: Re: ShadowHelper Code Never Completes
Post by: AGP on August 20, 2012, 08:36:53 pm
No problem:

Code: [Select]
     private void draw() {
buffer.clear();
skyBox.render(theWorld, buffer);

if (!softwareMode) {
     if (!doShadows()) {
theWorld.renderScene(buffer);
theWorld.draw(buffer);
     }
     buffer.update();
     buffer.displayGLOnly();
     glCanvas.repaint();
}
else {
     theWorld.renderScene(buffer);
     if (wireframe)
theWorld.drawWireframe(buffer, Color.blue);
     else theWorld.draw(buffer);
     buffer.display(glCanvas.getGraphics());
}
     }
     private boolean doShadows() {
if (sh == null || storyMode)
     return false;
SimpleVector offset = new SimpleVector(1, 0, -1).normalize();
offset.rotateY(0.07f);
projector.lookAt(ground.getTransformedCenter());
SimpleVector position = hero.getRoot().getTransformedCenter();
position.y -= 30f;
position.z += 5f;
projector.setPosition(position);
//projector.setPosition(hero.getRoot().getTransformedCenter());//hero.getRoot().getTransformedCenter()
//projector.moveCamera(new SimpleVector(0, -1, 0), 200);
//projector.moveCamera(offset, 215);
sun.setPosition(projector.getPosition());
sh.updateShadowMap();
sh.drawScene();
return true;
     }
Title: Re: ShadowHelper Code Never Completes
Post by: EgonOlsen on August 20, 2012, 09:13:06 pm
Looks ok...and the result is...everything is shadowed? No shadows at all? Are you sure that the objects that should be receivers actually are? Maybe you missed that part somehow or are working on copies the objects or something like that!?
Title: Re: ShadowHelper Code Never Completes
Post by: AGP on August 20, 2012, 09:39:51 pm
No shadows at all. And no, I called sh.addReceiver(ground) and there's only one ground on the entire model.

Any suggestions?
Title: Re: ShadowHelper Code Never Completes
Post by: AGP on August 21, 2012, 07:35:31 am
Is it possible that it's a ShadowHelper bug related to the use of AWTGLFrame? The only difference I see between the AdvancedExample and my program is that I'm using an AWT frame.
Title: Re: ShadowHelper Code Never Completes
Post by: EgonOlsen on August 21, 2012, 08:54:25 am
I don't of any bugs. I've multiple test cases for using shadows in an AWTGLCanvas and they all work fine. I suggest to take the advanced example and port it to use AWT instead. If that works, try to spot the difference between it and what you are doing.
Title: Re: ShadowHelper Code Never Completes
Post by: AGP on September 02, 2012, 05:25:16 am
OK, I just got around to porting the AdvancedExample, per your suggestion. "Got here.0" gets printed, "Got here" does not (so we're back to the shadow code not completing). Gotta be a bug (or "issue") of some kind. Please run this for me and see for yourself.

Code: [Select]
import java.awt.*;
import java.awt.event.*;

import com.threed.jpct.*;
import com.threed.jpct.util.*;

import org.lwjgl.input.*;

public class AdvancedExample extends Frame implements WindowListener, IPaintListener {
     private static final long serialVersionUID = 1L;
     private static float PI = (float) Math.PI;

     private KeyMapper keyMapper = null;
     private MouseMapper mouseMapper = null;

     private FrameBuffer buffer = null;
     private World world = null;
     private World sky = null;
     private Object3D plane = null;
     private Object3D snork = null;
     private Object3D rock = null;
     private Object3D dome = null;
     private Light sun = null;

     private ShadowHelper sh = null;
     private Projector projector = null;

     private float xAngle = 0;

     private boolean forward = false;
     private boolean backward = false;
     private boolean up = false;
     private boolean down = false;
     private boolean left = false;
     private boolean right = false;

     private float ind = 0;
     private boolean doLoop = true;
     private int fps = 0;
     private long time = System.currentTimeMillis();
     private Ticker ticker = new Ticker(15);

     private Canvas glCanvas;

     public void windowClosing(WindowEvent e) {
if (e.getWindow() == this)
     doLoop = false;
     }
     public void windowClosed(WindowEvent e) {}
     public void windowOpened(WindowEvent e) {}
     public void windowActivated(WindowEvent e) {}
     public void windowDeactivated(WindowEvent e) {}
     public void windowIconified(WindowEvent e) {}
     public void windowDeiconified(WindowEvent e) {}

     public static void main(String[] args) throws Exception {
Config.glVerbose = true;
AdvancedExample cd = new AdvancedExample();
cd.init();
cd.gameLoop();
     }

     public AdvancedExample() {
Config.glAvoidTextureCopies = true;
Config.maxPolysVisible = 1000;
Config.glColorDepth = 24;
Config.glFullscreen = false;
Config.farPlane = 4000;
Config.glShadowZBias = 0.8f;
Config.lightMul = 1;
Config.collideOffset = 500;
Config.glTrilinear = true;
     }

     public void finishedPainting() {
fps++;
     }

     public void startPainting() {
     }

     private void init() throws Exception {
this.setTitle("AdvancedExample AwtGL Edition");
// Load textures
TextureManager tm = TextureManager.getInstance();
tm.addTexture("grass", new Texture("example/GrassSample2.jpg"));
tm.addTexture("disco", new Texture("example/disco.jpg"));
tm.addTexture("rock", new Texture("example/rock.jpg"));
tm.addTexture("normals", new Texture("example/normals.jpg"));
tm.addTexture("sky", new Texture("example/sky.jpg"));

// Initialize frame buffer
buffer = new FrameBuffer(800, 600, FrameBuffer.SAMPLINGMODE_NORMAL);
buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
glCanvas = buffer.enableGLCanvasRenderer();
this.add(glCanvas);
buffer.setPaintListener(this);

// Initialize worlds
world = new World();
sky = new World();
world.setAmbientLight(30, 30, 30);
sky.setAmbientLight(255, 255, 255);

world.getLights().setRGBScale(Lights.RGB_SCALE_2X);
sky.getLights().setRGBScale(Lights.RGB_SCALE_2X);

// Initialize mappers
keyMapper = new KeyMapper(glCanvas);
mouseMapper = new MouseMapper(buffer);
mouseMapper.hide();

// Load/create and setup objects
plane = Primitives.getPlane(20, 30);
plane.rotateX(PI / 2f);
plane.setSpecularLighting(true);
plane.setTexture("grass");
plane.setCollisionMode(Object3D.COLLISION_CHECK_OTHERS);

rock = Loader.load3DS("example/rock.3ds", 15f)[0];
rock.translate(0, 0, -90);
rock.rotateX(-PI / 2);
TextureInfo stoneTex = new TextureInfo(tm.getTextureID("rock"));
stoneTex.add(tm.getTextureID("normals"), TextureInfo.MODE_MODULATE);
rock.setTexture(stoneTex);
rock.setSpecularLighting(true);

snork = Loader.loadMD2("example/snork.md2", 0.8f);
snork.translate(0, -25, -50);
snork.setTexture("disco");

dome = Object3D.mergeAll(Loader.load3DS("example/dome.3ds", 2));
dome.build();
dome.rotateX(-PI / 2f);
dome.setTexture("sky");
dome.calcTextureWrap();
tileTexture(dome, 3);
dome.translate(plane.getTransformedCenter().calcSub(dome.getTransformedCenter()));
dome.setLighting(Object3D.LIGHTING_NO_LIGHTS);
dome.setAdditionalColor(Color.WHITE);

// Add objects to the worlds
world.addObject(plane);
world.addObject(snork);
world.addObject(rock);
sky.addObject(dome);

// Build all world's objects
world.buildAllObjects();

// Compile all objects for better performance
plane.compileAndStrip();
rock.compileAndStrip();
dome.compileAndStrip();

snork.compile(true, true, true, false, 2000);
snork.setCollisionMode(Object3D.COLLISION_CHECK_SELF);

// Deform the plane
Mesh planeMesh = plane.getMesh();
planeMesh.setVertexController(new Mod(), false);
planeMesh.applyVertexController();
planeMesh.removeVertexController();

// Initialize shadow helper
projector = new Projector();
projector.setFOV(1.5f);
projector.setYFOV(1.5f);
System.out.println("Got here. 0");
sh = new ShadowHelper(world, buffer, projector, 2048);
sh.setCullingMode(false);
sh.setAmbientLight(new Color(30, 30, 30));
sh.setLightMode(true);
sh.setBorder(1);

sh.addCaster(snork);
sh.addCaster(rock);
sh.addReceiver(plane);

// Setup dynamic light source
sun = new Light(world);
sun.setIntensity(250, 250, 250);
sun.setAttenuation(800);

// Setup shaders for the rock
String fragmentShader = Loader.loadTextFile("example/shader/fragmentshader.glsl");
String vertexShader = Loader.loadTextFile("example/shader/vertexshader.glsl");

GLSLShader shader = new GLSLShader(vertexShader, fragmentShader);
// shader.setShadowHelper(sh);
shader.setStaticUniform("colorMap", 0);
shader.setStaticUniform("normalMap", 1);
shader.setStaticUniform("invRadius", 0.0005f);
rock.setRenderHook(shader);

// Move camera
Camera cam = world.getCamera();
cam.moveCamera(Camera.CAMERA_MOVEOUT, 150);
cam.moveCamera(Camera.CAMERA_MOVEUP, 100);
cam.lookAt(plane.getTransformedCenter());
cam.setFOV(1.5f);
System.out.println("Got here.");
this.setSize(800, 600);
this.setVisible(true);
     }

private void pollControls() {
KeyState ks = null;
while ((ks = keyMapper.poll()) != KeyState.NONE) {
if (ks.getKeyCode() == KeyEvent.VK_ESCAPE) {
doLoop = false;
}

if (ks.getKeyCode() == KeyEvent.VK_UP) {
forward = ks.getState();
}

if (ks.getKeyCode() == KeyEvent.VK_DOWN) {
backward = ks.getState();
}

if (ks.getKeyCode() == KeyEvent.VK_LEFT) {
left = ks.getState();
}

if (ks.getKeyCode() == KeyEvent.VK_RIGHT) {
right = ks.getState();
}

if (ks.getKeyCode() == KeyEvent.VK_PAGE_UP) {
up = ks.getState();
}

if (ks.getKeyCode() == KeyEvent.VK_PAGE_DOWN) {
down = ks.getState();
}
}

if (org.lwjgl.opengl.Display.isCloseRequested()) {
doLoop = false;
}
}

private void move(long ticks) {

if (ticks == 0) {
return;
}

// Key controls

SimpleVector ellipsoid = new SimpleVector(5, 5, 5);

if (forward) {
world.checkCameraCollisionEllipsoid(Camera.CAMERA_MOVEIN,
ellipsoid, ticks, 5);
}

if (backward) {
world.checkCameraCollisionEllipsoid(Camera.CAMERA_MOVEOUT,
ellipsoid, ticks, 5);
}

if (left) {
world.checkCameraCollisionEllipsoid(Camera.CAMERA_MOVELEFT,
ellipsoid, ticks, 5);
}

if (right) {
world.checkCameraCollisionEllipsoid(Camera.CAMERA_MOVERIGHT,
ellipsoid, ticks, 5);
}

if (up) {
world.checkCameraCollisionEllipsoid(Camera.CAMERA_MOVEUP,
ellipsoid, ticks, 5);
}

if (down) {
world.checkCameraCollisionEllipsoid(Camera.CAMERA_MOVEDOWN,
ellipsoid, ticks, 5);
}

// mouse rotation

Matrix rot = world.getCamera().getBack();
int dx = mouseMapper.getDeltaX();
int dy = mouseMapper.getDeltaY();

float ts = 0.2f * ticks;
float tsy = ts;

if (dx != 0) {
ts = dx / 500f;
}
if (dy != 0) {
tsy = dy / 500f;
}

if (dx != 0) {
rot.rotateAxis(rot.getYAxis(), ts);
}

if ((dy > 0 && xAngle < Math.PI / 4.2)
|| (dy < 0 && xAngle > -Math.PI / 4.2)) {
rot.rotateX(tsy);
xAngle += tsy;
}

// Update the skydome

sky.getCamera().setBack(world.getCamera().getBack().cloneMatrix());
dome.rotateY(0.00005f * ticks);
}

     private void gameLoop() throws Exception {
SimpleVector pos = snork.getTransformedCenter();
SimpleVector offset = new SimpleVector(1, 0, -1).normalize();

long ticks = 0;

while (doLoop) {
ticks = ticker.getTicks();
if (ticks > 0) {
// animate the snork and the dome

animate(ticks);
offset.rotateY(0.007f * ticks);

// move the camera
pollControls();
move(ticks);
}

// update the projector for the shadow map
projector.lookAt(plane.getTransformedCenter());
projector.setPosition(pos);
projector.moveCamera(new SimpleVector(0, -1, 0), 200);
projector.moveCamera(offset, 215);
sun.setPosition(projector.getPosition());

// update the shadow map
sh.updateShadowMap();

// render the scene
buffer.clear();

buffer.setPaintListenerState(false);
sky.renderScene(buffer);
sky.draw(buffer);
buffer.setPaintListenerState(true);
sh.drawScene();
buffer.update();
buffer.displayGLOnly();
glCanvas.repaint();

// print out the fps to the console
if (System.currentTimeMillis() - time >= 1000) {
System.out.println(fps);
fps = 0;
time = System.currentTimeMillis();
}
}
buffer.dispose();
this.dispose();
System.exit(0);
     }

private void animate(long ticks) {
if (ticks > 0) {
float ft = (float) ticks;
ind += 0.02f * ft;
if (ind > 1) {
ind -= 1;
}
snork.animate(ind, 2);
snork.rotateY(-0.02f * ft);
snork.translate(0, -50, 0);
SimpleVector dir = snork.getXAxis();
dir.scalarMul(ft);
dir = snork.checkForCollisionEllipsoid(dir, new SimpleVector(5, 20, 5), 5);
snork.translate(dir);
dir = snork.checkForCollisionEllipsoid(new SimpleVector(0, 100, 0), new SimpleVector(5, 20, 5), 1);
snork.translate(dir);
}
}

private void tileTexture(Object3D obj, float tileFactor) {
PolygonManager pm = obj.getPolygonManager();

int end = pm.getMaxPolygonID();
for (int i = 0; i < end; i++) {
SimpleVector uv0 = pm.getTextureUV(i, 0);
SimpleVector uv1 = pm.getTextureUV(i, 1);
SimpleVector uv2 = pm.getTextureUV(i, 2);

uv0.scalarMul(tileFactor);
uv1.scalarMul(tileFactor);
uv2.scalarMul(tileFactor);

int id = pm.getPolygonTexture(i);

TextureInfo ti = new TextureInfo(id, uv0.x, uv0.y, uv1.x, uv1.y,
uv2.x, uv2.y);
pm.setPolygonTexture(i, ti);
}
}

     private static class MouseMapper {
private boolean hidden = false;
private int height = 0;

public MouseMapper(FrameBuffer buffer) {
height = buffer.getOutputHeight();
init();
}

public void hide() {
     if (!hidden) {
//HIDE CURSOR
hidden = true;
     }
}

public void show() {
     if (hidden) {
//UNHIDE CURSOR
hidden = false;
     }
}

public boolean isVisible() {
return !hidden;
}

public void destroy() {
}

public boolean buttonDown(int button) {
return false;
}

public int getMouseX() {
// return Mouse.getX();
     return 0;
}

public int getMouseY() {
// return height - Mouse.getY();
     return 0;
}

public int getDeltaX() {
     return 0;
}

public int getDeltaY() {
     return 0;
}

private void init() {

}
     }

private static class Mod extends GenericVertexController {
private static final long serialVersionUID = 1L;

public void apply() {
SimpleVector[] s = getSourceMesh();
SimpleVector[] d = getDestinationMesh();
for (int i = 0; i < s.length; i++) {
d[i].z = s[i].z
- (10f * ((float) Math.sin(s[i].x / 50f) + (float) Math.cos(s[i].y / 50f)));
d[i].x = s[i].x;
d[i].y = s[i].y;
}
}
}

private static class Ticker {

private int rate;
private long s2;

public static long getTime() {
return System.currentTimeMillis();
}

public Ticker(int tickrateMS) {
rate = tickrateMS;
s2 = Ticker.getTime();
}

public int getTicks() {
long i = Ticker.getTime();
if (i - s2 > rate) {
int ticks = (int) ((i - s2) / (long) rate);
s2 += (long) rate * ticks;
return ticks;
}
return 0;
}
}
}
Title: Re: ShadowHelper Code Never Completes
Post by: EgonOlsen on September 02, 2012, 08:08:54 pm
There's no issue, you just have the wrong order. Like i posted before:

What you are supposed to do:

  • enable the GLCanvasRenderer on the FrameBuffer
  • add the canvas to your frame/component
  • make your frame/component visible and active
  • setup your ShadowHelper

You have to make the component visible BEFORE setting up the ShadowHelper or otherwise, it will never terminate, because it waits for a drawing event that will never happen. This might feel clunky, but the design of LWJGL's Canvas enforces it.

Just take the setSize/setVisible-lines and move them right before you create the ShadowHelper. And remove the call to Display.isCloseRequested in addition...it doesn't work in a non-native window, because there is no Display being created.
Title: Re: ShadowHelper Code Never Completes
Post by: AGP on September 03, 2012, 01:30:43 am
OK, so it works and the shadows are visible. I'm thinking my world might be too small (I'm exporting the OBJ level at a scale of .06). Could that be it? If so, other than scaling everything up, is there a workaround?
Title: Re: ShadowHelper Code Never Completes
Post by: AGP on September 03, 2012, 02:24:26 am
When is the "VBO created" message printed? Could the lack of visible shadows come from the fact that the "VBO created" messages are happening after setupShadows()?
Title: Re: ShadowHelper Code Never Completes
Post by: EgonOlsen on September 03, 2012, 11:16:30 am
VBOs will be created when the mesh data gets uploaded to the GPU. It has nothing to do with shadows and you can even disable it in Config if you want to.
Title: Re: ShadowHelper Code Never Completes
Post by: AGP on September 03, 2012, 01:49:11 pm
What about the other part of my question (the size )?
Title: Re: ShadowHelper Code Never Completes
Post by: EgonOlsen on September 03, 2012, 05:52:04 pm
I'm not sure about the size....it might matter somehow but i don't think that it can cause shadows to disappear. Have you checked you far plane setting? Maybe it's to narrow so that the scenes gets clipped when viewed from the light source?
Title: Re: ShadowHelper Code Never Completes
Post by: AGP on September 16, 2012, 08:13:49 pm
Two things:
1) the following code works (it's the exact same code as is in the program where it doesn't). So is it possible that some models can't be shadow receivers (perhaps something about their normals)?
2) 2 new VisibilityLists are being created. You keep telling me it's about swallowing Exceptions, but it never was for me, and this almost always happens.

By the way, if instead of translating the cube by -3f on y I translate it by -1f, the shadow becomes VERY "edgy" (very large squares).

Code: [Select]
import java.awt.*;
import java.awt.event.*;
import com.threed.jpct.*;
import com.threed.jpct.util.*;

public class ShadowTest extends Frame implements WindowListener {
     private boolean keepGoing;
     private ShadowHelper sh;
     private Object3D ground, hero;
     private World theWorld;
     private FrameBuffer buffer;
     private Canvas glCanvas;
     private Projector projector;
     private Camera theCamera;
     private Light sun;
     public ShadowTest() {
this.setTitle("BR's");
theWorld = new World();
ground = Primitives.getPlane(10, 20f);
ground.rotateX((float)Math.PI*.5f);
hero = Primitives.getCube(5);
theWorld.addObject(ground);
theWorld.addObject(hero);
theWorld.buildAllObjects();
hero.translate(0, -3, 0);
buffer = new FrameBuffer(800, 600, FrameBuffer.SAMPLINGMODE_HARDWARE_ONLY);
buffer.disableRenderer(IRenderer.RENDERER_SOFTWARE);
glCanvas = buffer.enableGLCanvasRenderer();
theCamera = theWorld.getCamera();
theCamera.setPosition(hero.getTransformedCenter());
theCamera.moveCamera(Camera.CAMERA_MOVEOUT, 20f);
this.add(glCanvas);
this.addWindowListener(this);
this.setSize(800, 600);
this.setVisible(true);
setupShadows();
gameLoop();
     }
     private void setupShadows() {
Config.glDynamicBatchSize = 4000;
projector = new Projector();
projector.setFOV(1.5f);
projector.setYFOV(1.5f);
sh = new ShadowHelper(theWorld, buffer, projector, 1024);
sh.setCullingMode(false);
sh.setAmbientLight(new Color(55, 55, 55));
sh.setLightMode(true);
sh.setBorder(1);
sh.addCaster(hero);
sh.addReceiver(ground);
sun = new Light(theWorld);
sun.setIntensity(255, 255, 255);
sun.setAttenuation(800);//800
theCamera.setFOV(1.5f);
glCanvas.repaint();
super.paint(this.getGraphics());
System.out.println("\n\n\nFinished shadows. Initialized properly? "+sh.isInitialized() +"\n\n");
     }
     private void gameLoop() {
keepGoing = true;
while (keepGoing) {
     draw();
     Thread.yield();
}
buffer.dispose();
this.dispose();
System.exit(0);
     }
     private void draw() {
buffer.clear();

if (!doShadows()) {
     theWorld.renderScene(buffer);
     theWorld.draw(buffer);
}
buffer.update();
buffer.displayGLOnly();
glCanvas.repaint();
     }
     private boolean doShadows() {
if (sh == null)
     return false;
projector.lookAt(ground.getTransformedCenter());
SimpleVector position = hero.getTransformedCenter();
position.z += 40f;
projector.setPosition(position);//hero.getRoot().getTransformedCenter()
projector.moveCamera(new SimpleVector(0, -1, 0), 30);//200
sun.setPosition(projector.getPosition());
sh.updateShadowMap();
sh.drawScene();
return true;
     }

     public void windowClosing(WindowEvent e) {
if (e.getWindow() == this)
     keepGoing = false;
     }
     public void windowClosed(WindowEvent e) {}
     public void windowOpened(WindowEvent e) {}
     public void windowIconified(WindowEvent e) {}
     public void windowDeiconified(WindowEvent e) {}
     public void windowActivated(WindowEvent e) {}
     public void windowDeactivated(WindowEvent e) {}

     public static void main(String[] args) {
new ShadowTest();
     }
}
Title: Re: ShadowHelper Code Never Completes
Post by: EgonOlsen on September 16, 2012, 09:32:10 pm
Every model can be a shadow receiver. There's no relation to normals in any way. What is required is that the model has to be able to take the addional texture layer that the ShadowHelper adds to it, but for normal, single textures objects, this shouldn't be a problem. Are you sure that the position of the light in your non-working case is fine? Too far away and there won't be a shadow. The fact that it fest blocky in your example might be an indication for this. Try to lower the distance to see if that helps.
It's totally fine that additional visibility lists will be created when using the the ShadowHelper. The problem is when this happens every frame and that usually is the result of swallowing exceptions.
I'll take a look at your example, when i'm back home. I can't do much from here.
Title: Re: ShadowHelper Code Never Completes
Post by: AGP on September 16, 2012, 10:08:52 pm
I set both the light and the projector REALLY close just now to see whether I would get shadows and I still got none. I'm almost in the hero's face with the following code.

Code: [Select]
SimpleVector position = hero.get(0).getTransformedCenter();
position.z += 5f;
projector.setPosition(position);//hero.getRoot().getTransformedCenter()
projector.moveCamera(new SimpleVector(0, -1, 0), 3.75f);//200
Title: Re: ShadowHelper Code Never Completes
Post by: AGP on September 17, 2012, 04:17:04 am
Finally something to show for. I think it's a ShadowHelper bug because even this fraction of the shadow doesn't appear in most areas of the ground (the only receiver):

(http://ratto.co/ShadowProblem.jpg)
Title: Re: ShadowHelper Code Never Completes
Post by: EgonOlsen on September 22, 2012, 09:39:46 pm
I tried your box test case, but i'm not sure what it's about to tell me other than that test case works?! That the shadow gets edgy is totally normal, because you are looking at it from a very close distance at a very low angle...every unfiltered texture would look that way in that scene and the shadows won't be filtered, so the result is to be expected.

About your screen shot..well, you have to keep in mind that a view frustum will be created for the shadow map just like the one for the camera. If you are moving pretty close to something, that frustum doesn't much of the geometry that is close. And i think that this is what you see in the screen shot. Everything else is just out of the frustum. Try to increase the fov (watch the stupid minFov and maxFov settings...) in the Projector and the result should change. If it does, try to move the projector out step by step to see what happens then.
Title: Re: ShadowHelper Code Never Completes
Post by: AGP on September 22, 2012, 10:24:39 pm
I'm not sure to which test you're referring, but it's nothing recent and it certainly wasn't done after I saw this fraction of a shadow. I'll play with FOV and report my findings, but I don't think that's it (in my opinion it's related to the complexity and size of the floor).
Title: Re: ShadowHelper Code Never Completes
Post by: EgonOlsen on September 22, 2012, 10:33:41 pm
I'll play with FOV and report my findings, but I don't think that's it (in my opinion it's related to the complexity and size of the floor).
The shadow mapping doesn't care about complexity as long as all parts (if there are more than one) have been added as receivers. It might help to render the floor as wireframe in addition to see the actual polygons.
Title: Re: ShadowHelper Code Never Completes
Post by: AGP on September 22, 2012, 10:47:13 pm
Check this out. Setting minimum FOV to .02f helped, but didn't solve it. The further ahead I move, the less of the shadow there is. A few steps ahead of the second screen there's no shadow at all. But on another part of the ground (merged together with that one in Max), the shadow is complete again, until it disappears again. In total there are four parts of the floor, each behaving the same way.

(http://ratto.co/ShadowProblem2.jpg)
Title: Re: ShadowHelper Code Never Completes
Post by: EgonOlsen on September 22, 2012, 11:14:59 pm
Could you please render the ground's wireframe in addition? I would like to see if it happens on the borders of polygons or not.
Title: Re: ShadowHelper Code Never Completes
Post by: AGP on September 22, 2012, 11:35:47 pm
Here you go:

(http://ratto.co/ShadowWireframe.jpg)
Title: Re: ShadowHelper Code Never Completes
Post by: EgonOlsen on September 23, 2012, 12:00:29 am
Ok...i see no relation to the actual polygons...i'm out of ideas. I need some test case that reflects this problem properly to investigate it.
Title: Re: ShadowHelper Code Never Completes
Post by: AGP on September 23, 2012, 12:03:36 am
I'll send you the first test case with this ground model, then.
Title: Re: ShadowHelper Code Never Completes
Post by: EgonOlsen on September 23, 2012, 08:19:50 pm
The test case is missing the actual hero mesh, so i replaced it with the ninja from the Bones examples. It didn't work too well, because all i got to see was the sword and some funny looking ground object. However, i got this:

Code: [Select]
WARNING: You've exceeded the configured triangle limit for the visibility list. Consider adjusting Config.maxPolysVisible!

If you get that too, it explains a lot. Just do what the warning says and see if it helps. Or switch to compiled objects, which won't cause this problem anyway.
Title: Re: ShadowHelper Code Never Completes
Post by: AGP on September 23, 2012, 08:35:22 pm
Yeah, sorry, my program compiles the objects. If I'd known, I would have compiled them on the test case, but alas, that's not the problem. What happened when you compiled the ninja?
Title: Re: ShadowHelper Code Never Completes
Post by: EgonOlsen on September 23, 2012, 08:54:52 pm
Hard to tell...with this test case, i don't even see the ninja...just its sword hovering high above some strange looking thing that is supposed to be the ground. It's impossible to tell anything from this, i'm afraid. I'm not even sure what i'm looking at... ???
Title: Re: ShadowHelper Code Never Completes
Post by: AGP on September 23, 2012, 09:07:52 pm
I sent you both my character and the ground textures. Should help visualization.
Title: Re: ShadowHelper Code Never Completes
Post by: EgonOlsen on September 23, 2012, 10:14:19 pm
Yes, that helps. Now i can see the issue and know what happens here. It's caused by the fact that you are using the center of the ground as lookAt-point, i.e. as the center of the projector's view frustum. You then place the projector a little before/behind (i changed that in the test case to see any shadow) and above the hero. Depending on the angle between the ground plane (simplified to ease thinking...) and the lookAt-vector, the frustum doesn't cover the whole hero mesh. If that's not clear, try to make a simple drawing (it helped me).
If you want to use the shadows that way, either use some point before the hero as the lookAt point instead (like projector.lookAt(position);) or try to setup the projector in a way that it really acts like the sun would do, i.e. the frustum has to cover the whole ground mesh and the position never changes.
Title: Re: ShadowHelper Code Never Completes
Post by: AGP on September 23, 2012, 11:28:06 pm
I'm not sure whether I completely get it. Perhaps if you sent me your drawing?

On a separate question, what about Object3D.mergeAll breaks the collision tests? If I store the collision objects as multiple parts, collision works. But then, I have to have a loop for each gameloop iteration to set visibility on then off again. But if I mergeAll, collision stops working.
Title: Re: ShadowHelper Code Never Completes
Post by: EgonOlsen on September 24, 2012, 02:50:28 pm
Well...somehow like this:

(http://jpct.de/pix/abstract_art.png)

About merging: It has no effect on collision detection. Collision detection doesn't care about the source of the mesh it's working on. Make sure to enable collision detection for the resulting mesh (merging doesn't do this) and if you use octrees, calculate for the final mesh, not for the source meshes.
Title: Re: ShadowHelper Code Never Completes
Post by: AGP on September 24, 2012, 08:00:53 pm
I see your point, thank you. I will play with it. If the problem persists, I will report back.
Title: Re: ShadowHelper Code Never Completes
Post by: AGP on November 19, 2012, 05:45:09 pm
How do I make the shadows less blocky now? You mentioned it was supposed to be unfiltered or something, but the result of leaving the light static, while solving most of the getting-all-the character problem, is that the shadow is now a collection of fairly large squares.
Title: Re: ShadowHelper Code Never Completes
Post by: EgonOlsen on November 19, 2012, 08:59:56 pm
You have basically three options: