FPS370 - Changes from Alpha2 to Alpha3
Model Loading

The changes incorporated into alpha3 were to load a model into the fps370 application and use that model as the player map. The earlier versions used a teder map to build the floor tiles in the 3d arena. I was always intending on using the 2d map to build the 3d scene, but a student needed a model with textures loaded for the same purpose. This is the project I'm using to demonstrate various aspects of game programming.

This is the code used to load a model (from Fps370Panel.java).

//import com.mnstarfire.loaders3d.Loader3DS; 
import com.glyphein.j3d.loaders.milkshape.MS3DLoader; public Scene loadModel(String fname) { Scene theScene = null; // setup a file name "fileName" try { //Loader3DS loader = new Loader3DS(); // optional options to be used //loader.setLogging(true); // turns on writing a log file //loader.setDetail(7); // sets level of detail of report log //loader.setTextureLightingOn(); // turns on texture modulate mode //loader.setTexturePath("models"); // optional alternate path to find texture files // loader.noTextures(); // if you do not want to load textures //theScene = loader.load(fname); // milkshape loader File file = new java.io.File("./models/map2.ms3d"); if (file.getParent().length() > 0) // figure out the base path { Loader loader = new MS3DLoader(MS3DLoader.LOAD_ALL); loader.setBasePath(file.getParent() + java.io.File.separator); theScene = loader.load(file.getName()); //BranchGroup group = scene.getSceneGroup(); } } catch(FileNotFoundException fnf) { // Couldn't find the file you requested - deal with it! fnf.printStackTrace(); } return theScene; }

As you can see there are two different loaders being used here. The first attempt which is now commented out was using Wings3d and the starfire loader3ds. I saved the model as a 3ds file and loaded, but the textures were not showing. I turned on the loging and detal(7) and noted some exceptions trying to load the actual texture image files. I fixed all the exceptions by moving the texture image files directory around in the project. The textures still did not show. After a few days of this I gave up and tried a different 3d tool and loader. The milkshape modeling tool and the java3d loader. You will need to download both and place the MS3DLoader-1.0.8.jar in the fps370/lib/ext directory.

This is the code that calls the model loader. Please note a bug here. The loadModel method is being passed a file name of models/temple.3ds, but that name is ignored in the actual loadModel method. The model that is loaded is ./models/map2.ms3d. This is just a "shoe box" with textures patterned on the inside. The loadModel method returns a Scene object which we use to retrieve a BranchGroup from. That BranchGroup is added to bgMain (the main BranchGroup).

Scene sc = loadModel("models/temple.3ds");
// need to scale the model some, then slide it up and towards the origin<
bgMain.addChild(sc.getSceneGroup);

Those are basically the only changes and were a lot of work and testing. The next step is to add collision detection.

CPSC370 - Games Development
Chapman University
Instructor: W. Wood Harter
(c) copyright 2006 - W. Wood Harter - All Rights Reserved
Screen shots on banner (c) copyright their resprective owners