Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Some minor fixes to ship model generation.

  • Loading branch information...
commit 7163012b173cd65e94568119a3adb374fa419b24 1 parent a15595d
@zzorn authored
View
99 assets/config/blueplanets.json
@@ -13,12 +13,12 @@
"beanType": "AmbientLightConf",
"color": {
"beanType": "ColorConf",
- "hue": 0.0,
- "sat": 0.0,
- "lum": 0.0,
+ "hue": 0.6878049,
+ "sat": 0.124390244,
+ "lum": 0.25609756,
"alpha": 1.0
},
- "intensity": 7.4505806E-9
+ "intensity": 0.63414633
},
"directional1": {
"beanType": "DirectionalLightConf",
@@ -44,9 +44,9 @@
"alpha": 1.0
},
"intensity": 0.88135594,
- "x": 0.09927356,
- "y": -0.44309926,
- "z": 1.0
+ "x": -0.559322,
+ "y": -0.64648914,
+ "z": 0.9467312
},
"directional3": {
"beanType": "DirectionalLightConf",
@@ -65,9 +65,92 @@
},
"seed": 342,
"numBalls": 51,
+ "numShips": 20,
"xArea": 115.0,
"yArea": 100.0,
"zArea": 100.0,
+ "ship": {
+ "beanType": "ShipConf",
+ "seed": 40,
+ "material": {
+ "beanType": "MaterialConf",
+ "color": {
+ "beanType": "RandomColorConf",
+ "hue": 0.0,
+ "sat": 0.0,
+ "lum": 0.3874092,
+ "hueVariation": 0.1,
+ "satVariation": 0.1,
+ "lumVariation": 0.1
+ },
+ "ambientColor": {
+ "beanType": "RandomColorConf",
+ "hue": 0.0,
+ "sat": 0.0,
+ "lum": 0.37804878,
+ "hueVariation": 0.026634382,
+ "satVariation": 0.0036319613,
+ "lumVariation": 0.020581113
+ },
+ "specularColor": {
+ "beanType": "RandomColorConf",
+ "hue": 0.0,
+ "sat": 0.0,
+ "lum": 0.10653753,
+ "hueVariation": 0.1,
+ "satVariation": 0.1,
+ "lumVariation": 0.1
+ },
+ "shininess": 0.43583536,
+ "texture": "placeholder.png"
+ },
+ "core": {
+ "beanType": "Core",
+ "front": {
+ "beanType": "Shell",
+ "horizontalProfile": FlatProfile,
+ "verticalProfile": FlatProfile,
+ "detailAmount": 0.5
+ },
+ "back": {
+ "beanType": "Shell",
+ "horizontalProfile": FlatProfile,
+ "verticalProfile": FlatProfile,
+ "detailAmount": 0.5
+ },
+ "top": {
+ "beanType": "Shell",
+ "horizontalProfile": FlatProfile,
+ "verticalProfile": FlatProfile,
+ "detailAmount": 0.5
+ },
+ "bottom": {
+ "beanType": "Shell",
+ "horizontalProfile": FlatProfile,
+ "verticalProfile": FlatProfile,
+ "detailAmount": 0.5
+ },
+ "left": {
+ "beanType": "Shell",
+ "horizontalProfile": FlatProfile,
+ "verticalProfile": FlatProfile,
+ "detailAmount": 0.5
+ },
+ "right": {
+ "beanType": "Shell",
+ "horizontalProfile": FlatProfile,
+ "verticalProfile": FlatProfile,
+ "detailAmount": 0.5
+ },
+ "length": 53.0,
+ "width": 32.0,
+ "height": 12.0,
+ "widthScale": 0.70000005,
+ "heightScale": 0.5,
+ "verticalSlant": 1.0,
+ "horizontalSlant": 0.0
+ }
+ },
"ballAppearance": {
"beanType": "AppearanceConf",
"material": {
@@ -85,7 +168,7 @@
"beanType": "RandomColorConf",
"hue": 0.0,
"sat": 0.0,
- "lum": 0.0,
+ "lum": 0.090243906,
"hueVariation": 0.0,
"satVariation": 0.010895884,
"lumVariation": 0.0
View
6 src/main/scala/org/jmespike/conf/ConfParser.scala
@@ -6,6 +6,7 @@ import org.jmespike.shape.{SphereConf}
import org.jmespike.appearance.{MaterialConf, AppearanceConf}
import org.jmespike.lighting.{LightingConf, AmbientLightConf, DirectionalLightConf}
import org.jmespike.scene.TestScene
+import org.jmespike.shape.ships._
/**
* Something that can parse configuration files.
@@ -26,5 +27,10 @@ class ConfParser extends JsonBeanParser {
registerBeanType(classOf[DirectionalLightConf])
registerBeanType(classOf[AmbientLightConf])
registerBeanType(classOf[LightingConf])
+ registerBeanType(classOf[ShipConf])
+ registerBeanType(classOf[Core])
+ registerBeanType(classOf[Chassis])
+ registerBeanType(classOf[Shell])
+ registerBeanType(classOf[Engine])
}
View
17 src/main/scala/org/jmespike/scene/TestScene.scala
@@ -7,6 +7,7 @@ import simplex3d.math.float._
import org.jmespike.utils.VectorConversions._
import org.jmespike.lighting.{LightingConf, Lighting}
import org.jmespike.appearance.AppearanceConf
+import org.jmespike.shape.ships.ShipConf
/**
*
@@ -17,11 +18,14 @@ class TestScene() extends SceneFactory {
val seed = p('seed, 342)
val numBalls = p('numBalls, 50)
+ val numShips = p('numShips, 20)
val xArea = p('xArea, 100f)
val yArea = p('yArea, 100f)
val zArea = p('zArea, 100f)
+ val ship = p('ship, new ShipConf())
+
val ballAppearance = p('ballAppearance, new AppearanceConf)
def createScene: Spatial = {
@@ -43,6 +47,19 @@ class TestScene() extends SceneFactory {
root.attachChild(ball)
}
+ // Add some test ships
+ val ships = numShips()
+ for (i <- 0 until ships) {
+ val pos = Vec3((rng.nextGaussian * xArea()).toFloat,
+ (rng.nextGaussian * yArea()).toFloat,
+ (rng.nextGaussian * zArea()).toFloat)
+
+ val s = ship().createModel()
+ s.setLocalTranslation(pos)
+ root.attachChild(s)
+ }
+
+
root
}
View
8 src/main/scala/org/jmespike/shape/ships/ComponentBase.scala
@@ -17,10 +17,10 @@ case class ComponentBase(meshBuilder: MeshBuilder,
bottomLeft: Int,
bottomRight: Int) {
- private val topRightVertex = meshBuilder.vertex(topRight)
- private val topLeftVertex = meshBuilder.vertex(topLeft)
- private val bottomLeftVertex = meshBuilder.vertex(bottomLeft)
- private val bottomRightVertex = meshBuilder.vertex(bottomRight)
+ val topRightVertex : ConstVec3 = meshBuilder.vertex(topRight)
+ val topLeftVertex : ConstVec3 = meshBuilder.vertex(topLeft)
+ val bottomLeftVertex : ConstVec3 = meshBuilder.vertex(bottomLeft)
+ val bottomRightVertex : ConstVec3 = meshBuilder.vertex(bottomRight)
val baseCenter : ConstVec3 = 0.25f * (topRightVertex + topLeftVertex + bottomLeftVertex + bottomRightVertex)
View
16 src/main/scala/org/jmespike/shape/ships/Shell.scala
@@ -21,8 +21,20 @@ class Shell extends ShipComponent {
def buildMesh(style: ShipConf, base: ComponentBase) {
- // Simple solid hull
- base.meshBuilder.addQuad(base.topRight, base.topLeft, base.bottomLeft, base.bottomRight)
+ val meshBuilder = base.meshBuilder
+
+ // Simple solid hull with sharp corners
+
+ val tr = meshBuilder.addVertex(base.topRightVertex)
+ val tl = meshBuilder.addVertex(base.topLeftVertex)
+ val bl = meshBuilder.addVertex(base.bottomLeftVertex)
+ val br = meshBuilder.addVertex(base.bottomRightVertex)
+
+ meshBuilder.addQuad(tl, tr, br, bl)
+ meshBuilder.addQuad(base.topLeft, base.topRight, tr, tl)
+ meshBuilder.addQuad(base.bottomRight, base.topRight, tr, br)
+ meshBuilder.addQuad(base.bottomLeft, base.topLeft, tl, bl)
+ meshBuilder.addQuad(base.bottomRight, base.bottomLeft, bl, br)
}
}
View
7 src/main/scala/org/jmespike/shape/ships/ShipConf.scala
@@ -5,6 +5,7 @@ import org.jmespike.appearance.MaterialConf
import java.util.Random
import com.jme3.scene.{Geometry, Spatial}
import org.jmespike.utils.{XorShiftRandom, MeshBuilder}
+import com.jme3.bounding.BoundingBox
/**
* Generates ship shapes.
@@ -12,9 +13,7 @@ import org.jmespike.utils.{XorShiftRandom, MeshBuilder}
class ShipConf extends Conf {
val seed = p('seed, 42)
-
val material = p('material, new MaterialConf)
-
val core = p('core, new Core())
// TODO Graphical style etc?
@@ -33,6 +32,10 @@ class ShipConf extends Conf {
val geom = new Geometry("geometry", mesh)
geom.setMaterial(material().createMaterial(rng))
+
+ // Setup bounding volume
+ geom.setModelBound(new BoundingBox())
+
geom
}
Please sign in to comment.
Something went wrong with that request. Please try again.