Renanse quake 3 map loader causing weird problems with shadow pass

http://www.youtube.com/watch?v=X_RbIhDcJW4


package org.vampiremmorpg.client;

import java.io.File;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

import org.vampiremmorpg.data.FpsWeaponModel;
import org.vampiremmorpg.data.MD5Model;
import org.vampiremmorpg.data.player.Player;
import org.vampiremmorpg.data.player.PlayerClass;
import org.vampiremmorpg.data.world.map.QuakeMap;

import com.jme.app.SimplePassGame;
import com.jme.input.KeyBindingManager;
import com.jme.input.KeyInput;
import com.jme.input.NodeHandler;
import com.jme.light.DirectionalLight;
import com.jme.light.PointLight;
import com.jme.math.Vector3f;
import com.jme.renderer.Camera;
import com.jme.renderer.ColorRGBA;
import com.jme.renderer.Renderer;
import com.jme.renderer.pass.RenderPass;
import com.jme.renderer.pass.ShadowedRenderPass;
import com.jme.scene.CameraNode;
import com.jme.scene.Spatial;
import com.jme.scene.Spatial.CullHint;
import com.jme.scene.shape.Disk;
import com.jmex.terrain.TerrainPage;
import com.jmex.terrain.util.FaultFractalHeightMap;

public class Game extends SimplePassGame {
   private static ResourceManager rm = ResourceManager.getInstance();

    private static ShadowedRenderPass sPass = new ShadowedRenderPass();
   private CameraNode camNode;
   private TerrainPage page;
   private QuakeMap map;
   private Player player;
   
   public Game()
   {
      stencilBits = 4;
      // Map
      {
         File mapModel = new File("data/qdata/pdmq3duel5.bsp");
         List<File> mapTexturedirectorys = new LinkedList<File>();
         mapTexturedirectorys.add(mapModel.getParentFile());
         map = new QuakeMap(mapModel, mapTexturedirectorys);
      }
      // Player
      {
         File playerFile = new File("data/model/player/fish/fish.md5mesh");
         File animationFile = new File("data/model/player/fish/fish.md5anim");
         File weaponFile = new File("data/model/weapon/kedr.md5mesh");
         
         List<File> playerTexturedirectorys = new LinkedList<File>();
         playerTexturedirectorys.add(playerFile.getParentFile());
         
         List<File> weaponTexturedirectorys = new LinkedList<File>();
         weaponTexturedirectorys.add(weaponFile.getParentFile());
         
         player = new Player(
               0,
               "Abraxas",
               100,
               122,
               100,
               122,
               new MD5Model("fish", playerFile, animationFile, playerTexturedirectorys),
               new PlayerClass(0, "vampire"),
               new FpsWeaponModel("kedr", weaponFile, null, weaponTexturedirectorys)
            );
      }
   }
   
    protected void simpleUpdate() {
       ArrayList<Camera> cams = new ArrayList<Camera>();
       cams.add(cam);
       
       map.update(cams);
       
       if (KeyBindingManager.getKeyBindingManager().isValidCommand(
                "toggle_shadows", false)) {
            sPass.setRenderShadows(!sPass.getRenderShadows());
        }
    }
   
    protected void simpleInitGame() {
       rootNode.setRenderQueueMode(Renderer.QUEUE_OPAQUE);
       
       /** Assign key X to action "toggle_shadows". */
        KeyBindingManager.getKeyBindingManager().set("toggle_shadows", KeyInput.KEY_X);
       
       camNode = new CameraNode( "Camera Node", display.getRenderer().getCamera());
        input = new NodeHandler( camNode, 15f, 1 );
       
        rootNode.attachChild(map.load(display));
        try {
           rootNode.attachChild(player.getModel().load(display));
        } catch(Exception ex) {
           ex.printStackTrace();
        }
       
        try {
            setupTerrain();
            PointLight pl = new PointLight();
            pl.setEnabled(true);
            pl.setConstant(0);
            pl.setLocation(new Vector3f(1, 2, 0));
            pl.setShadowCaster(true);
           
            lightState.attach(pl);
            lightState.setGlobalAmbient(new ColorRGBA(0.6f, 0.6f, 0.6f, 1.0f));
           
           camNode.attachChild(player.getFpsWeaponModel().load(display));
           
           camNode.updateRenderState();

            rootNode.attachChild(camNode);           
           
            com.jme.scene.shape.Disk q1 = new Disk("Ortho Q1", 40, 40, 0.1f);
            //q1.setLocalTranslation(new Vector3f(100 + center.x, 100 + center.y, 0));
            q1.setZOrder(1);
            q1.setLocalTranslation(new Vector3f(1, 2f, 0));
            q1.setDefaultColor(ColorRGBA.white.clone());
            q1.setLightCombineMode(Spatial.LightCombineMode.Off);
            rootNode.attachChild(q1);
           
        } catch(Exception ex) {         
           ex.printStackTrace();
        }
       
        pManager.clearAll();
       
        sPass.add(page);
        sPass.add(map.getNode());
        sPass.add(player.getModel().getNode());
        sPass.add(player.getFpsWeaponModel().getNode());
        sPass.addOccluder(player.getModel().getNode());
        sPass.addOccluder(player.getFpsWeaponModel().getNode());
        sPass.setRenderShadows(true);
        sPass.setLightingMethod(ShadowedRenderPass.LightingMethod.Additive);
        pManager.add(sPass);
       
        RenderPass rPass = new RenderPass();
        rPass.add(statNode);
//        rPass.add(map.getNode());
        pManager.add(rPass);
    }
   
    protected void cameraPerspective() {
        cam.setFrustumPerspective(55.0f, (float) display.getWidth()/(float)display.getHeight(), .1f, 2000);
        cam.setParallelProjection(false);
        cam.update();
    }
   
    public static void main(String[] args) {
        try {
           Game test = new Game();
            test.setConfigShowMode(ConfigShowMode.AlwaysShow);
            test.start();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
           rm.deinit();
        }
    }
   
    private void setupTerrain() {
       DirectionalLight dr = new DirectionalLight();
        dr.setEnabled(true);
        dr.setDiffuse(new ColorRGBA(1.0f, 1.0f, 1.0f, 1.0f));
        dr.setAmbient(new ColorRGBA(.2f, .2f, .2f, .3f));
        dr.setDirection(new Vector3f(0.5f, -0.4f, 0).normalizeLocal());
        dr.setShadowCaster(true);

        PointLight pl = new PointLight();
        pl.setEnabled(true);
        pl.setDiffuse(new ColorRGBA(.7f, .7f, .7f, 1.0f));
        pl.setAmbient(new ColorRGBA(.25f, .25f, .25f, .25f));
        pl.setLocation(new Vector3f(0,500,0));
        pl.setShadowCaster(true);

        lightState.detachAll();
        lightState.attach(dr);
        lightState.attach(pl);
        FaultFractalHeightMap heightMap = new FaultFractalHeightMap(257, 32, 0,
                255, 0.55f);
        Vector3f terrainScale = new Vector3f(10, 1, 10);
        heightMap.setHeightScale(0.001f);
        page = new TerrainPage("Terrain", 33, heightMap.getSize(),
                terrainScale, heightMap.getHeightMap(), false);

        page.setDetailTexture(1, 16);
        page.setLocalTranslation(new Vector3f(1, -110, 0));
        rootNode.attachChild(page);

    }
}



In the video you can see my test running in the stripped down TestShadowPass class. It seems to me, that the textures are flipped to the back face with shadow pass on, the inner Textures are grey.  You can see me switch to different states the first ist shadowpass on then lightstate on and lightstate off.

@renanse
You should add a method like setGamma() to the Quake3Converter. There seems to be no way for me to set the gamma outside of the converter. changeGamma() is no help on that because i got no access to the lightmaps. ... or i am just a freakin retard...  ;). Do you have a svn or cvs up with your latest code?

i seriously need that quake map converter

(does it support bsp?)

I will post you my port to jme 2.0 of renanses map loader, when i am home from work. If you can't wait, you can search the forum for it, you will find a large topic about that. Yes it supports the binary bsp format, and inmap models too, but you always have to compile your map with the highest quality settings (i am using gtkradiant 1.4 for this. First compile bsp meta data then the highest setting available).



edit:



Ok here it is:



http://uploaded.to/?id=crqla0



You can use JMESimpleQuakeRenderer as sample

thx. (guess i need to port hhexen to jme 2.0)

If you wanna stick to jme 1.0 you can use the original version from renanse here:



http://www.jmonkeyengine.com/jmeforum/index.php?topic=2597.0