Skybox/Terrain Problems

6 replies [Last post]
Offline
Joined: 05/26/2013

Hi, I am having some issues with a game I am making. I have all the bugs worked out except for the skybox and terrain not loading. The terrain is a blood red color when it should be using the sand1 pic from textures and the sky is just a plain white like nothing is there. I am using the same method of reading in those values as the zombie hunter math tutorial does, using an array and buffered reader. I have also tried to put the values in myself instead of terrain.setTexture(field[3]);. I had the same problem when trying to run the example code for zombie hunter math. Is there an import I'm missing?

Offline
Joined: 12/13/2010
This could be a version

This could be a version mismatch (which I thought I fixed... argh).

Could you post your Game.java file and the world.txt file?  That would help me in trying to solve the problem.

Thanks

 

Jason

Offline
Joined: 05/26/2013
 Ok here is my Game

 Ok here is my Game file

 

import env3d.advanced.EnvNode;

import env3d.advanced.EnvSkyRoom;

import env3d.advanced.EnvTerrain;

import env3d.util.Sysutil;

import org.lwjgl.input.Keyboard;

 

import java.io.*;

import java.net.*;

import java.util.*;

 

public class Game extends env3d.EnvApplet

{

    private EnvAdvanced env;

    private EnvTerrain terrain;

    

    private void setup()

    {                        

        env.setDefaultControl(false);

        // Load the game objects

        try {

            URL url = Sysutil.getURL("world.txt");

            BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));

 

            String line;

            while ((line = br.readLine()) != null) {

                String[] fields = line.split(",");

 

                if (fields[0].equalsIgnoreCase("skybox")) {

                    // The background

                    env.setRoom(new EnvSkyRoom("textures/skybox/default"));

                    //env.setRoom(new EnvSkyRoom(fields[1]));

                } else if (fields[0].equalsIgnoreCase("camera")) {

                    // The camera

                    env.setCameraXYZ(Double.parseDouble(fields[1]), Double.parseDouble(fields[2]), Double.parseDouble(fields[3]));

                    env.setCameraYaw(Double.parseDouble(fields[4]));

                    env.setCameraPitch(Double.parseDouble(fields[5]));

                } else if (fields[0].equalsIgnoreCase("terrain")) {

                    terrain = new EnvTerrain("textures/terrain/flat.png");

                    terrain.setTexture("textures/floor/sand1.png");

                    //terrain = new EnvTerrain(fields[1]);

                    //terrain.setTexture(fields[3]);

                    env.addObject(terrain);

                } else if (fields[0].equalsIgnoreCase("object")) {                    

                    GameObject n = (GameObject) Class.forName(fields[10]).newInstance();

                    n.setX(Double.parseDouble(fields[1]));

                    n.setY(Double.parseDouble(fields[2]));

                    n.setZ(Double.parseDouble(fields[3]));

                    n.setScale(Double.parseDouble(fields[4]));

                    n.setRotateX(Double.parseDouble(fields[5]));

                    n.setRotateY(Double.parseDouble(fields[6]));

                    n.setRotateZ(Double.parseDouble(fields[7]));

                    n.setTexture(fields[9]);

                    n.setModel(fields[8]);

                    n.setEnv(env);

                    env.addObject(n);

                }

 

            }

        } catch (Exception e) {

            e.printStackTrace();

        }

 

        

    }

 

    /**

     *

     */

    @Override

    public void play()

    {

        env = new EnvAdvanced();

        setup();

        

        // Disable the default env3d control

        env.setDefaultControl(false);        

        // Do not hide the mouse

        env.setMouseGrab(true);

        

        int transitionDelay = 150;                

        

        while (!env.getKeyDown(Keyboard.KEY_Q)) {           

            

            if (env.getKey() == Keyboard.KEY_ESCAPE) {

                env.setMouseGrab(!env.isMouseGrabbed());

            }

            

            if (!env.isMouseGrabbed()) {

                env.setDisplayStr("Game Paused.  Press ESCAPE to resume", 5, 470);

                env.advanceOneFrame();

                continue;

            } else {

                env.setDisplayStr("Press ESCAPE to pause game and release mouse, Press Q to quit, \n Health: " + env.getObject(Mage.class).getHealth(), 5, 470);

            }

            

            int aliveCerberus = 0;

            

            // Call move() on all GameObjects

            Iterator<GameObject> it = env.getObjects(GameObject.class).iterator();

            while (it.hasNext()) {

                GameObject o = it.next();

                o.move();

                if (o instanceof Cerberus && !((Cerberus)o).isDead()) {

                    aliveCerberus++;

                }

            }

            

            // All cerberus' are dead, reset level with higher difficulty

            if (aliveCerberus == 0) {

                transitionDelay--;

                env.setDisplayStr("Level Cleared!", 150, 300, 3, 1, 0, 0, 0.5);

                if (transitionDelay <= 0) {

                    env.setDisplayStr(null);

                    setup();              

                    transitionDelay = 150;

                }

            }

            

            // If Mage is dead, reset level

            if (env.getObject(Mage.class).getState() == Mage.DIE) {

                transitionDelay--;                

                env.setDisplayStr("F A I L", 100, 360, 10, 1, 0, 0, 0.5);

                if (env.getCameraPitch() > -80) {

                    env.setCameraPitch(env.getCameraPitch()-4);                    

                }

                

                env.setCameraXYZ(env.getCameraX(), env.getCameraY()+0.1, env.getCameraZ());

                

                if (transitionDelay <= 0) {

                    env.setDisplayStr(null);

                    setup();

                    transitionDelay = 150;

                }

            }            

            

            env.advanceOneFrame(30);

        }

        env.exit();

    }

    

    public static void main(String [] args) {

        Game game = new Game();

        System.out.println("How to Play \n Move the mouse to adjust the Camera \n W, A, S, D to move \n Space to shoot and C to swing sword.");

        game.play();

    }

}

 

and here is my world.txt

 

camera,-11.755534172058105,1.7579584121704102,-10.021967887878418,142.4026336669922,0.7863386273384094

terrain,textures/terrain/flat.png,textures/terrain/alpha.png,textures/floor/sand1.png,textures/floor/sand1.png,textures/floor/sand1.png

object,-66.0,5.0,-60.0,5.199997425079346,0.0,0.0,0.0,models/mountain/mountains.obj,null,Mountain

object,-85.0,6.0,-41.0,9.099998474121094,0.0,270.0,0.0,models/mountain/mountains.obj,null,Mountain

object,-60.0,1.0,0.0,1.0,0.0,-90.0,0.0,models/cerberus/cerberus.obj,models/cerberus/cerberus_texture_0.png,Cerberus

object,-23.0,6.0,-44.0,9.099998474121094,0.0,360.0,0.0,models/mountain/mountains.obj,null,Mountain

object,-64.0,3.0,33.0,3.099999189376831,0.0,900.0,0.0,models/longHouse/LongHouse.obj,models/longHouse/HouseLong.png,LongHouse

object,-74.0,3.0,23.0,3.099999189376831,0.0,1170.0,0.0,models/longHouse/LongHouse.obj,models/longHouse/HouseLong.png,LongHouse

object,-37.0,3.0,38.0,3.099999189376831,0.0,1260.0,0.0,models/longHouse/LongHouse.obj,models/longHouse/HouseLong.png,LongHouse

object,-15.0,3.0,37.0,3.099999189376831,0.0,900.0,0.0,models/longHouse/LongHouse.obj,models/longHouse/HouseLong.png,LongHouse

object,-20.0,1.0,6.0,1.0,0.0,0.0,0.0,models/cerberus/cerberus.obj,models/cerberus/cerberus_texture_0.png,Cerberus

object,-15.0,1.0,-22.0,1.0,0.0,-90.0,0.0,models/cerberus/cerberus.obj,models/cerberus/cerberus_texture_0.png,Cerberus

object,9.0,3.0,-18.0,3.099999189376831,0.0,990.0,0.0,models/longHouse/LongHouse.obj,models/longHouse/HouseLong.png,LongHouse

object,-1.0,7.0,-34.0,9.099998474121094,0.0,450.0,0.0,models/mountain/mountains.obj,null,Mountain

object,-9.0,1.0,10.0,1.0,0.0,270.0,0.0,models/cerberus/cerberus.obj,models/cerberus/cerberus_texture_0.png,Cerberus

object,-51.0,3.0,39.0,3.099999189376831,0.0,1260.0,0.0,models/longHouse/LongHouse.obj,models/longHouse/HouseLong.png,LongHouse

object,-53.0,9.0,-75.0,9.099998474121094,0.0,180.0,0.0,models/mountain/mountains.obj,null,Mountain

object,-54.0,1.0,-5.0,1.0,0.0,-90.0,0.0,models/cerberus/cerberus.obj,models/cerberus/cerberus_texture_0.png,Cerberus

object,-9.0,1.0,1.0,1.0,0.0,270.0,0.0,models/cerberus/cerberus.obj,models/cerberus/cerberus_texture_0.png,Cerberus

object,-78.0,9.0,-65.0,9.099998474121094,0.0,180.0,0.0,models/mountain/mountains.obj,null,Mountain

object,10.0,3.0,10.0,3.099999189376831,0.0,990.0,0.0,models/longHouse/LongHouse.obj,models/longHouse/HouseLong.png,LongHouse

object,-40.0,9.0,-67.0,9.099998474121094,0.0,180.0,0.0,models/mountain/mountains.obj,null,Mountain

object,-18.0,1.0,11.0,1.0,0.0,360.0,0.0,models/cerberus/cerberus.obj,models/cerberus/cerberus_texture_0.png,Cerberus

object,-12.0,1.0,11.0,1.0,0.0,270.0,0.0,models/cerberus/cerberus.obj,models/cerberus/cerberus_texture_0.png,Cerberus

object,-76.0,9.0,-52.0,9.099998474121094,0.0,180.0,0.0,models/mountain/mountains.obj,null,Mountain

object,-23.0,1.0,-18.0,1.0,0.0,-90.0,0.0,models/cerberus/cerberus.obj,models/cerberus/cerberus_texture_0.png,Cerberus

object,0.0,3.0,35.0,3.099999189376831,0.0,900.0,0.0,models/longHouse/LongHouse.obj,models/longHouse/HouseLong.png,LongHouse

object,-56.0,1.0,5.0,1.0,0.0,-90.0,0.0,models/cerberus/cerberus.obj,models/cerberus/cerberus_texture_0.png,Cerberus

object,9.0,3.0,-4.0,3.099999189376831,0.0,990.0,0.0,models/longHouse/LongHouse.obj,models/longHouse/HouseLong.png,LongHouse

object,-6.0,1.0,24.0,1.0,0.0,360.0,0.0,models/cerberus/cerberus.obj,models/cerberus/cerberus_texture_0.png,Cerberus

object,-77.0,3.0,-5.0,3.099999189376831,0.0,90.0,0.0,models/longHouse/LongHouse.obj,models/longHouse/HouseLong.png,LongHouse

object,-25.0,1.0,-8.0,1.0,0.0,-90.0,0.0,models/cerberus/cerberus.obj,models/cerberus/cerberus_texture_0.png,Cerberus

object,-45.0,3.0,-17.0,3.099999189376831,0.0,630.0,0.0,models/longHouse/LongHouse.obj,models/longHouse/HouseLong.png,LongHouse

object,-76.0,3.0,9.0,3.099999189376831,0.0,1170.0,0.0,models/longHouse/LongHouse.obj,models/longHouse/HouseLong.png,LongHouse

object,-16.0,7.0,-53.0,9.099998474121094,0.0,360.0,0.0,models/mountain/mountains.obj,null,Mountain

object,-3.0,8.0,-42.0,9.099998474121094,0.0,540.0,0.0,models/mountain/mountains.obj,null,Mountain

object,-109.0,13.0,-22.0,13.100013732910156,0.0,270.0,0.0,models/mountain/mountains.obj,null,Mountain

object,-59.0,3.0,-34.0,3.099999189376831,0.0,540.0,0.0,models/longHouse/LongHouse.obj,models/longHouse/HouseLong.png,LongHouse

object,-36.0,1.0,29.0,1.0,0.0,90.0,0.0,models/cerberus/cerberus.obj,models/cerberus/cerberus_texture_0.png,Cerberus

object,-37.0,1.0,23.0,1.0,0.0,90.0,0.0,models/cerberus/cerberus.obj,models/cerberus/cerberus_texture_0.png,Cerberus

object,-5.0,1.0,-1.0,1.0,0.0,270.0,0.0,models/cerberus/cerberus.obj,models/cerberus/cerberus_texture_0.png,Cerberus

object,-81.0,9.0,-80.0,9.099998474121094,0.0,-90.0,0.0,models/mountain/mountains.obj,null,Mountain

object,-44.0,3.0,16.0,3.099999189376831,0.0,450.0,0.0,models/longHouse/LongHouse.obj,models/longHouse/HouseLong.png,LongHouse

object,-31.0,8.0,-67.0,9.099998474121094,0.0,540.0,0.0,models/mountain/mountains.obj,null,Mountain

object,-39.0,9.0,-89.0,9.099998474121094,0.0,90.0,0.0,models/mountain/mountains.obj,null,Mountain

object,-30.0,1.0,-11.0,1.0,0.0,0.0,0.0,models/cerberus/cerberus.obj,models/cerberus/cerberus_texture_0.png,Cerberus

object,-45.0,3.0,-3.0,3.099999189376831,0.0,630.0,0.0,models/longHouse/LongHouse.obj,models/longHouse/HouseLong.png,LongHouse

object,-22.0,12.0,46.0,13.100013732910156,0.0,720.0,0.0,models/mountain/mountains.obj,null,Mountain

object,-14.0,1.0,-8.0,1.0,0.0,270.0,0.0,models/hunter/player.obj,models/mage/Mage.png,Mage

object,-76.0,3.0,-21.0,3.099999189376831,0.0,450.0,0.0,models/longHouse/LongHouse.obj,models/longHouse/HouseLong.png,LongHouse

object,-15.0,1.0,20.0,1.0,0.0,360.0,0.0,models/cerberus/cerberus.obj,models/cerberus/cerberus_texture_0.png,Cerberus

object,-113.0,12.0,2.0,13.100013732910156,0.0,270.0,0.0,models/mountain/mountains.obj,null,Mountain

object,-41.0,1.0,-40.0,1.0,0.0,-90.0,0.0,models/cerberus/cerberus.obj,models/cerberus/cerberus_texture_0.png,Cerberus

object,-60.0,8.0,-61.0,9.099998474121094,0.0,540.0,0.0,models/mountain/mountains.obj,null,Mountain

object,-32.0,1.0,13.0,1.0,0.0,90.0,0.0,models/cerberus/cerberus.obj,models/cerberus/cerberus_texture_0.png,Cerberus

object,10.0,3.0,24.0,3.099999189376831,0.0,990.0,0.0,models/longHouse/LongHouse.obj,models/longHouse/HouseLong.png,LongHouse

object,-29.0,1.0,28.0,1.0,0.0,180.0,0.0,models/cerberus/cerberus.obj,models/cerberus/cerberus_texture_0.png,Cerberus

 

thanks for the help :) 

Offline
Joined: 12/13/2010
May I ask what kind of

May I ask what kind of machine you are using?  In particular, I need to know the specfic graphics card that you have.

 

Thanks

 

Jason

Offline
Joined: 05/26/2013
 I'm using a cheap windows 7

 I'm using a cheap windows 7 starter dell inspiron mini 1018. It has intel atom processor and a intel media graphics acellerator 3150

Offline
Joined: 12/13/2010
That is the problem!  The

That is the problem!  The 3150 does not support shaders and therefore cannot display the terrain and skybox properly.  

 

Jason