Code Search for Developers
 
 
  

ModelLoading3ds.java from Riot in Emerald city at Krugle


Show ModelLoading3ds.java syntax highlighted

/*
 * Copyright (C) 2001-2005 Pleasant nightmare studio
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
package skunkworks;

import java.net.URL;
import java.net.MalformedURLException;
import java.io.*;
import java.util.logging.Level;

import com.jme.app.SimpleGame;
import com.jme.scene.Node;
import com.jme.util.LoggingSystem;
import com.jmex.model.XMLparser.BinaryToXML;
import com.jmex.model.XMLparser.JmeBinaryReader;
import com.jmex.model.XMLparser.Converters.FormatConverter;
import com.jmex.model.XMLparser.Converters.MaxToJme;


/**
 * @author ShivesH
 * @version 1.0
 * @since 2007.02.10 18:09:02
 */
public class ModelLoading3ds extends SimpleGame{
	
	public static void main(String[] args) {
		ModelLoading3ds app = new ModelLoading3ds();
		app.setDialogBehaviour(SimpleGame.ALWAYS_SHOW_PROPS_DIALOG);
//		Turn the logger off so we can see the XML later on
		LoggingSystem.getLogger().setLevel(Level.OFF);
		app.start();
	}
	protected void simpleInitGame() {
//		Point to a URL of my model
        URL	model= null;
        try {
            model = new File("concept-art/models/3dsModels/kocka.3ds").toURI().toURL();
        } catch (MalformedURLException e) {
            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
        }
//		Create something to convert .obj format to .jme
		FormatConverter converter=new MaxToJme();
//		This byte array will hold my .jme file
		ByteArrayOutputStream BO=new ByteArrayOutputStream();
//		This will read the .jme format and convert it into a scene graph
		JmeBinaryReader jbr=new JmeBinaryReader();
//		Use this to visualize the .3ds file in XML
		BinaryToXML btx=new BinaryToXML();
		try {
//			Use the format converter to convert .3ds to .jme
			converter.convert(model.openStream(), BO);
//			Send the .jme binary to System.out as XML 
			btx.sendBinarytoXML(new ByteArrayInputStream(BO.toByteArray()),new
					OutputStreamWriter(System.out));
//			Tell the binary reader to use bounding boxes instead of bounding spheres
			jbr.setProperty("bound","box");
//			Load the binary .jme format into a scene graph
			Node loadedModel=jbr.loadBinaryFormat(new ByteArrayInputStream(BO.toByteArray()));
//			shrink this baby down some
//			loadedModel.setLocalScale(1f);
//			Put her on the scene graph
			rootNode.attachChild(loadedModel);
		} catch (IOException e) { // Just in case anything happens
			System.out.println("Damn exceptions!" + e);
			e.printStackTrace();
			System.exit(0);
		} 
	}
}




See more files for this project here

Riot in Emerald city

Cyberpunk third-person 2100. noir RPG thriller using JMonkey. Its going to be mix between Bloodnet, Neuromancer, DeusEx in gameplay, with pieces of Uplink and many other mini-games for dealing with variety of tasks (lockpicking, hacking...)

Project homepage: http://sourceforge.net/projects/riot-in-ecity
Programming language(s): Java,XML
License: other

  computer/
    NetworkingTest.java
    ShellTest.java
    StorageBuilderTest.java
    StorageParserTest.java
    UserBuilderTest.java
  coned/
    ConceptFrameTest.java
    DeserializerTest.java
    SerializerTest.java
    SerializingTestsCommons.java
    SimpleWrite.java
  juryrig/
    BombEntity.java
    Digipad.java
    Explosive.java
    MakingOfProximityBomb.java
    ShortrangeUltrasonicRadar.java
  room/
    OurGameRoomDoors.java
  ActionMenuTest.java
  ActionMenuTestGame.java
  ActionQuadTest.java
  ApartmentBuilderTest.java
  ArgSplit.java
  AtmDigipadTest.java
  AtmTest.java
  BoundaryBoxViewport.java
  CamerasInRoomSimpleGame.java
  ColladaAnimation.java
  ComputerTest.java
  ConsoleGameTest.java
  DummyAction.java
  InputHandling.java
  InteractionTest.java
  InventoryTest.java
  Md5Animation.java
  ModelLoading3ds.java
  ScreenTest.java
  SkunkworkUtils.java
  SquareRoomTest.java
  TelescreenTest.java
  TestColladaLoading.java
  TexturedBox.java
  ZOrderTest.java