Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added custom settings to sample 4. sample 9 works again.

  • Loading branch information...
commit 491ed29dda6ab00e02f6903d84a15b8a2aeb00f0 1 parent 410916d
Jeremy Woertink authored
1  README.rdoc
View
@@ -37,7 +37,6 @@ The Nifty-gui must be implemented in Java (for now) to work. This requires takin
* Not tested in any other OS
* Nifty/JRuby example (sample 13a) throws nasty exception
* Rag-doll sample loads, but isn't useable
-* Sample 9 isn't working
* Sample 16 isn't working
== Contributing to waves
2  lib/samples/sample3.rb
View
@@ -1,5 +1,5 @@
=begin
- This sample takes 2 boxes, and makes them rotate at different speeds
+ This sample takes 2 boxes, and makes them rotate at different speeds.
You can use 'W' 'A' 'S' 'D' to move around. 'Q' and 'Z' allow you to move up and down.
=end
15 lib/samples/sample4.rb
View
@@ -1,10 +1,12 @@
=begin
This shows a normal blue box with fire coming out of the top. The camera can be moved like normal,
- but in this sample, the box can be moved left with "J" and right with "K" and rotated with space.
+ but in this sample, the box can be moved left with "J" and right with "K" and rotated with space.
+ It also shows an example of a custom load screen by editing the settings.
=end
java_import "com.jme3.app.SimpleApplication"
+java_import "com.jme3.system.AppSettings"
java_import "com.jme3.material.Material"
java_import "com.jme3.math.Vector3f"
java_import "com.jme3.scene.Geometry"
@@ -20,16 +22,21 @@
java_import "com.jme3.effect.ParticleMesh"
class Sample4 < SimpleApplication
- field_accessor :speed
- field_accessor :paused
+ field_accessor :speed, :paused
+ field_reader :settings
class << self
attr_accessor :running
end
def initialize
- $player = nil # I'm ashamed of this....
+ super #must call super for the settings to run. it's a JRuby thing
+ $player = nil # Use a global player object so it's accessible to the ControllerAnalog
self.class.running = true
+ config = AppSettings.new(true)
+ config.settings_dialog_image = File.join("assets", "Interface", "maze_craze_logo.png")
+ self.settings = config
+ self.show_settings = true
end
def simpleInitApp
57 lib/samples/sample9.rb
View
@@ -5,56 +5,61 @@
java_import "com.jme3.app.SimpleApplication"
java_import "com.jme3.material.Material"
+java_import "com.jme3.renderer.Camera"
java_import "com.jme3.terrain.geomipmap.TerrainLodControl"
java_import "com.jme3.terrain.heightmap.AbstractHeightMap"
java_import "com.jme3.terrain.geomipmap.TerrainQuad"
java_import "com.jme3.terrain.geomipmap.lodcalc.DistanceLodCalculator"
java_import "com.jme3.terrain.heightmap.HillHeightMap"
java_import "com.jme3.terrain.heightmap.ImageBasedHeightMap"
-java_import "com.jme3.texture.Texture" # ::WrapMode
-java_import "jme3tools.converters.ImageToAwt"
+java_import "com.jme3.texture.Texture"
+java_import "com.jme3.texture.Texture$WrapMode"
+#java_import "jme3tools.converters.ImageToAwt"
+java_import "java.util.ArrayList"
+java_import "java.util.List"
class Sample9 < SimpleApplication
field_accessor :flyCam
+
def simpleInitApp
begin
flyCam.move_speed = 50
-
- @mat_terrain = Material.new(asset_manager, File.join("Common", "MatDefs", "Terrain", "Terrain.j3md"))
- @mat_terrain.set_texture("Alpha", asset_manager.load_texture(File.join("Textures", "Terrain", "splat", "alphamap.png")))
-
+
+ mat_terrain = Material.new(asset_manager, File.join("Common", "MatDefs", "Terrain", "Terrain.j3md"))
+ mat_terrain.set_texture("Alpha", asset_manager.load_texture(File.join("Textures", "Terrain", "splat", "alphamap.png")))
+
grass = asset_manager.load_texture(File.join("Textures", "Terrain", "splat", "grass.jpg"))
- grass.wrap = Texture::WrapMode::Repeat
- @mat_terrain.set_texture("Tex1", grass)
- @mat_terrain.set_float("Tex1Scale", 64.0)
+ grass.wrap = WrapMode::Repeat
+ mat_terrain.set_texture("Tex1", grass)
+ mat_terrain.set_float("Tex1Scale", 64.0)
dirt = asset_manager.load_texture(File.join("Textures", "Terrain", "splat", "dirt.jpg"))
- dirt.wrap = Texture::WrapMode::Repeat
- @mat_terrain.set_texture("Tex2", dirt)
- @mat_terrain.set_float("Tex2Scale", 32.0)
-
+ dirt.wrap = WrapMode::Repeat
+ mat_terrain.set_texture("Tex2", dirt)
+ mat_terrain.set_float("Tex2Scale", 32.0)
+
rock = asset_manager.load_texture(File.join("Textures", "Terrain", "splat", "road.jpg"))
- rock.wrap = Texture::WrapMode::Repeat
- @mat_terrain.set_texture("Tex3", rock)
- @mat_terrain.set_float("Tex3Scale", 128.0)
-
+ rock.wrap = WrapMode::Repeat
+ mat_terrain.set_texture("Tex3", rock)
+ mat_terrain.set_float("Tex3Scale", 128.0)
+
height_map_image = asset_manager.load_texture(File.join("Textures", "Terrain", "splat", "mountains512.png"))
- heightmap = ImageBasedHeightMap.new(ImageToAwt.convert(height_map_image.image, false, true, 0))
+ heightmap = ImageBasedHeightMap.new(height_map_image.image)
heightmap.load
patch_size = 65
- @terrain = TerrainQuad.new("my terrain", patch_size, 513, heightmap.height_map)
- @terrain.material = @mat_terrain
- @terrain.set_local_translation(0, -100, 0)
- @terrain.set_local_scale(2.0, 1.0, 2.0)
+ terrain = TerrainQuad.new("my terrain", patch_size, 513, heightmap.height_map)
+ terrain.material = mat_terrain
+ terrain.set_local_translation(0, -100, 0)
+ terrain.set_local_scale(2.0, 1.0, 2.0)
- root_node.attach_child(@terrain)
- control = TerrainLodControl.new(@terrain, get_camera)
+ root_node.attach_child(terrain)
+ control = TerrainLodControl.new(terrain, get_camera)
# FAILS HERE....
#control.lod_calculator = DistanceLodCalculator.new(patch_size, 2.7)
- @terrain.add_control(control)
- puts "finish...."
+ terrain.add_control(control)
+ puts "\n\nfinish...\n\n"
rescue => e
puts "#{e}"
end
Please sign in to comment.
Something went wrong with that request. Please try again.