Fixed the util class and Environment
This commit is contained in:
parent
cbd89ddb05
commit
1bc2424920
6 changed files with 44 additions and 50 deletions
|
|
@ -11,13 +11,13 @@
|
|||
<classpathentry kind="lib" path="lib/jme-font.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jme-gamestates.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jme-model.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jme-physics.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jme-physics.jar" sourcepath="C:/Users/Ziver/Documents/Programmering/Java/libs/jme/jME Physics 2/src"/>
|
||||
<classpathentry kind="lib" path="lib/jme-scene.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jme-swt.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jme-terrain.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jme-test.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jme-xml.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jme.jar"/>
|
||||
<classpathentry kind="lib" path="lib/jme.jar" sourcepath="C:/Users/Ziver/Documents/Programmering/Java/libs/jme/jme/src"/>
|
||||
<classpathentry kind="lib" path="lib/lwjgl_test.jar"/>
|
||||
<classpathentry kind="lib" path="lib/lwjgl_util_applet.jar"/>
|
||||
<classpathentry kind="lib" path="lib/lwjgl_util.jar"/>
|
||||
|
|
|
|||
|
|
@ -62,6 +62,6 @@ public class SpaceGame extends SimplePhysicsGame {
|
|||
}
|
||||
|
||||
public void simpleUpdate(){
|
||||
environment.setLocalTranslation(cam.getLocation());
|
||||
environment.update();
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.2 MiB After Width: | Height: | Size: 2.2 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 971 KiB After Width: | Height: | Size: 1.1 MiB |
63
src/sg/env/Environment.java
vendored
63
src/sg/env/Environment.java
vendored
|
|
@ -1,59 +1,38 @@
|
|||
package sg.env;
|
||||
|
||||
import sg.SpaceGame;
|
||||
import sg.util.SGUtil;
|
||||
|
||||
import com.jme.image.Texture;
|
||||
import com.jme.scene.Node;
|
||||
import com.jme.scene.Skybox;
|
||||
import com.jme.util.TextureManager;
|
||||
import com.jme.system.DisplaySystem;
|
||||
|
||||
public class Environment extends Node {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Skybox space;
|
||||
|
||||
public Environment(){
|
||||
buildSkyBox();
|
||||
}
|
||||
|
||||
private void buildSkyBox() {
|
||||
Skybox skybox = new Skybox("skybox", 500, 500, 500);
|
||||
Texture north = TextureManager.loadTexture(
|
||||
SpaceGame.class.getClassLoader().getResource(
|
||||
"sg/data/skybox/advanced/front.png"),
|
||||
Texture.MinificationFilter.BilinearNearestMipMap,
|
||||
Texture.MagnificationFilter.Bilinear);
|
||||
Texture south = TextureManager.loadTexture(
|
||||
SpaceGame.class.getClassLoader().getResource(
|
||||
"sg/data/skybox/advanced/rest.png"),
|
||||
Texture.MinificationFilter.BilinearNearestMipMap,
|
||||
Texture.MagnificationFilter.Bilinear);
|
||||
Texture east = TextureManager.loadTexture(
|
||||
SpaceGame.class.getClassLoader().getResource(
|
||||
"sg/data/skybox/advanced/rest.png"),
|
||||
Texture.MinificationFilter.BilinearNearestMipMap,
|
||||
Texture.MagnificationFilter.Bilinear);
|
||||
Texture west = TextureManager.loadTexture(
|
||||
SpaceGame.class.getClassLoader().getResource(
|
||||
"sg/data/skybox/advanced/rest.png"),
|
||||
Texture.MinificationFilter.BilinearNearestMipMap,
|
||||
Texture.MagnificationFilter.Bilinear);
|
||||
Texture up = TextureManager.loadTexture(
|
||||
SpaceGame.class.getClassLoader().getResource(
|
||||
"sg/data/skybox/advanced/rest.png"),
|
||||
Texture.MinificationFilter.BilinearNearestMipMap,
|
||||
Texture.MagnificationFilter.Bilinear);
|
||||
Texture down = TextureManager.loadTexture(
|
||||
SpaceGame.class.getClassLoader().getResource(
|
||||
"sg/data/skybox/advanced/rest.png"),
|
||||
Texture.MinificationFilter.BilinearNearestMipMap,
|
||||
Texture.MagnificationFilter.Bilinear);
|
||||
skybox.setTexture(Skybox.Face.North, north);
|
||||
skybox.setTexture(Skybox.Face.West, west);
|
||||
skybox.setTexture(Skybox.Face.South, south);
|
||||
skybox.setTexture(Skybox.Face.East, east);
|
||||
skybox.setTexture(Skybox.Face.Up, up);
|
||||
skybox.setTexture(Skybox.Face.Down, down);
|
||||
skybox.preloadTextures();
|
||||
skybox.updateRenderState();
|
||||
this.attachChild(skybox);
|
||||
space = new Skybox("space", 500, 500, 500);
|
||||
Texture north = SGUtil.loadTexture("sg/data/skybox/advanced/front.png");
|
||||
Texture rest = SGUtil.loadTexture("sg/data/skybox/advanced/rest.png");
|
||||
|
||||
space.setTexture(Skybox.Face.North, north);
|
||||
space.setTexture(Skybox.Face.West, rest);
|
||||
space.setTexture(Skybox.Face.South, rest);
|
||||
space.setTexture(Skybox.Face.East, rest);
|
||||
space.setTexture(Skybox.Face.Up, rest);
|
||||
space.setTexture(Skybox.Face.Down, rest);
|
||||
space.preloadTextures();
|
||||
space.updateRenderState();
|
||||
this.attachChild(space);
|
||||
}
|
||||
|
||||
public void update(){
|
||||
space.setLocalTranslation(DisplaySystem.getDisplaySystem().getRenderer().getCamera().getLocation());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,10 +8,10 @@ import java.net.URISyntaxException;
|
|||
import java.net.URL;
|
||||
|
||||
import com.jme.bounding.BoundingBox;
|
||||
import com.jme.image.Texture;
|
||||
import com.jme.scene.Node;
|
||||
import com.jme.scene.Spatial;
|
||||
import com.jme.scene.state.ZBufferState;
|
||||
import com.jme.system.DisplaySystem;
|
||||
import com.jme.util.TextureManager;
|
||||
import com.jme.util.export.binary.BinaryImporter;
|
||||
import com.jme.util.resource.ResourceLocatorTool;
|
||||
import com.jme.util.resource.SimpleResourceLocator;
|
||||
|
|
@ -29,12 +29,12 @@ import com.jmex.model.converters.ObjToJme;
|
|||
* @author Erick B Passos
|
||||
*
|
||||
*/
|
||||
public class Util {
|
||||
public class SGUtil {
|
||||
// So JME can find the model textures easily.
|
||||
private static URL textureSearchPath;
|
||||
|
||||
static {
|
||||
textureSearchPath = Util.class.getClassLoader().getResource("tancz/test/physics/vehicle/data/");
|
||||
textureSearchPath = SGUtil.class.getClassLoader().getResource("sg/data/");
|
||||
try {
|
||||
ResourceLocatorTool.addResourceLocator(ResourceLocatorTool.TYPE_TEXTURE, new SimpleResourceLocator(textureSearchPath));
|
||||
} catch (URISyntaxException e) {
|
||||
|
|
@ -85,15 +85,30 @@ public class Util {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads textures
|
||||
*
|
||||
* @param url is the path to the texture
|
||||
* @return an texture
|
||||
*/
|
||||
public static Texture loadTexture(String url){
|
||||
return TextureManager.loadTexture(
|
||||
FileFinder.findURL(url),
|
||||
Texture.MinificationFilter.BilinearNearestMipMap,
|
||||
Texture.MagnificationFilter.Bilinear);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper method to apply a ZBufferState to a node.
|
||||
* @param node
|
||||
*/
|
||||
/*
|
||||
public static void applyZBuffer(Node node) {
|
||||
ZBufferState zbuf = DisplaySystem.getDisplaySystem().getRenderer().createZBufferState();
|
||||
zbuf.setWritable(false);
|
||||
zbuf.setEnabled(true);
|
||||
zbuf.setFunction(ZBufferState.CF_LEQUAL);
|
||||
node.setRenderState(zbuf);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue