Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Volume node is scaled by the dimensions of the volume. Example: To move a sub node to the position of the voxel at (20,120,49), set its local position to (20,120,49)../gradlew buildgradlew.bat build./gradlew TexturedCubeExamplegradlew.bat TexturedCubeExamplegit clone https://github.com/scenerygraphics/scenery.gitgit clone [email protected]:scenerygraphics/scenery.gitclass Pyramid: Mesh("Pyramid of Cheops") {}class Pyramid: Mesh("Pyramid of Giza") {
private val a = Vector3f(-1f, 0f, 1f)
private val b = Vector3f(-1f, 0f, -1f)
private val c = Vector3f(1f, 0f, 1f)
private val d = Vector3f(1f, 0f, -1f)
private val e = Vector3f(0f, 1.5f, 0f)
}class Pyramid: Mesh("Pyramid of Giza") {
private val a = Vector3f(-1f, 0f, 1f)
private val b = Vector3f(-1f, 0f, -1f)
private val c = Vector3f(1f, 0f, 1f)
private val d = Vector3f(1f, 0f, -1f)
private val e = Vector3f(0f, 1.5f, 0f)
//indentation for didactic purposes
val triangleList = listOf( a, c, b,
b, c, d,
e, a, b,
a, e, c,
e, d, c,
d, e, b)
}class Pyramid: Mesh("Pyramid of Giza") {
private val a = Vector3f(-1f, 0f, 1f)
private val b = Vector3f(-1f, 0f, -1f)
private val c = Vector3f(1f, 0f, 1f)
private val d = Vector3f(1f, 0f, -1f)
private val e = Vector3f(0f, 1.5f, 0f)
//indentation for didactic purposes
val triangleList = listOf( a, c, b,
b, c, d,
e, a, b,
a, e, c,
e, d, c,
d, e, b)
init {
vertices = BufferUtils.allocateFloat(triangleList.size * 3)
triangleList.forEach {
vertices.put(it.toFloatArray())
}
//flip the buffer so the algorithm below works properly
vertices.flip()
//fill with texture coordinates if you like to
texcoords = BufferUtils.allocateFloat(triangleList.size * 2)
recalculateNormals()
}
}open class OrientedBoundingBox(val n: Node, val min: Vector3f, val max: Vector3f)val someNode = ThisIsSomeNodeClass()
val boundingBox = node.getMaximumBoundingBox()BoundingBox.getBoundingSphere()val erythrocyte = Mesh()
erythrocyte.readFromOBJ(Mesh::class.java.getResource("models/erythrocyte.obj").file)
erythrocyte.material = ShaderMaterial.fromFiles("DefaultDeferredInstanced.vert", "DefaultDeferred.frag")
erythrocyte.material.ambient = GLVector(0.1f, 0.0f, 0.0f)
erythrocyte.material.diffuse = GLVector(0.9f, 0.0f, 0.02f)
erythrocyte.material.specular = GLVector(0.05f, 0f, 0f)
erythrocyte.material.metallic = 0.01f
erythrocyte.material.roughness = 0.9f
erythrocyte.name = "Erythrocyte_Master"
erythrocyte.instancedProperties["ModelMatrix"] = { erythrocyte.model }
scene.addChild(erythrocyte)

var instancedProperties = LinkedHashMap<String, () -> Any>()scene.addChild(container)val helloClick = object : ClickBehaviour {
val output = "Hello World"
override fun click(x: Int, y: Int) {
logger.info(output + "at $x and $y")
}
}inputHandler?.addBehaviour("hello_click", helloClick)inputHandler?.addKeyBinding("hello_click", "button1")inputHandler?.addKeyBinding("hello_click", "M")//This is the node we use to store our instances of the object
val container = Node("Cell Container")
val erythrocytes = (0 until 40).map {
val v = Mesh()
v.name = "erythrocyte_$it"
v.instancedProperties["ModelMatrix"] = { v.world }
v.metadata["axis"] = GLVector(sin(0.1 * it).toFloat(), -cos(0.1 * it).toFloat(), sin(1.0f*it)*cos(1.0f*it)).normalized
v.parent = container
//This part is only important for visualization; it makes the cells floating in space
val scale = Random.randomFromRange(0.5f, 1.2f)
v.scale = GLVector(scale, scale, scale)
v.position = Random.randomVectorFromRange(3, -positionRange, positionRange)
v.rotation.setFromEuler(
Random.randomFromRange(0.01f, 0.9f),
Random.randomFromRange(0.01f, 0.9f),
Random.randomFromRange(0.01f, 0.9f)
)
v
}
// Here comes the important part: we add all the objects created to the
// instances list of the master erythrocyte.
erythrocyte.instances.addAll(erythrocytes)volumeManager.shaderProperties["lineColor"] = Vector3f(0.5f)uniform vec3 lineColor;val durationBinding = measureTimeMillis {
renderStacksStates
// sort by classname, so we get MultiResolutionStack3Ds first,
// then simple stacks
.sortedBy { it.javaClass.simpleName }
.forEachIndexed { i, state ->
// ...
currentProg.setCustomUniformForVolume(i, "slicingPlane", Vector3f(1f))
// ...
}
}with(myNode) {
spatial {
position = Vector3f(0.0f, 0.0f, 5.0f)
rotation = Quaternionf(0.0f, 0.0f, 0.0f, 1.0f)
scale = Vector3f(2.0f, 1.0f, 1.0f)
}
}

val toggleProteins = object : GamepadClickBehaviour {
override fun click(p0: Int, p1: Int) {
// finds the currently active protein, un-highlights it
activeProtein.children.forEach {
if(it is BoundingGrid) {
it.gridColor = Vector3f(0.0f, 0.0f, 0.0f)
}
}
// selects the new active protein
activeProtein = if(activeProtein.name == "2zzm") {
scene.find("4yvj") as Mesh
} else {
scene.find("2zzm") as Mesh
}
// highlights the newly active protein
activeProtein.children.forEach {
if(it is BoundingGrid) {
it.gridColor = Vector3f(1.0f, 0.0f, 0.0f)
}
}
}
}inputHandler += (toggleProteins
called "toggle_proteins"
boundTo GamepadButton.PovRight)inputHandler -= "toggle_proteins"inputHandler -= "gamepad_camera_control"
inputHandler += (GamepadRotationControl(
listOf(Component.Identifier.Axis.RX,
Component.Identifier.Axis.RY), 0.03f) { activeProtein }
called "protein_rotation"
boundTo GamepadButton.AlwaysActive)inputHandler += (GamepadMovementControl(listOf(Component.Identifier.Axis.Z), { cam })
called "vertical_movement"
boundTo GamepadButton.AlwaysActive)v.spatial().scale = Vector3f(3.0f, 10.0f, 1.0f)
System.out.println("v.model: " + v.spatial().model)
// Output (Matrix is not immediately updated and is still unity):
// 1.000E+0 0.000E+0 0.000E+0 0.000E+0
// 0.000E+0 1.000E+0 0.000E+0 0.000E+0
// 0.000E+0 0.000E+0 1.000E+0 0.000E+0
// 0.000E+0 0.000E+0 0.000E+0 1.000E+0v.spatial().position = Vector3f(-3.0f, 10.0f, 0.0f)
v.spatial().updateWorld()
System.out.println("v.model: " + v.spatial().model)
// Output (Matrix is updated to what's expected, if updated immediately):
// 3.000E+0 0.000E+0 0.000E+0 0.000E+0
// 0.000E+0 1.000E+1 0.000E+0 0.000E+0
// 0.000E+0 0.000E+0 1.000E+0 0.000E+0
// 0.000E+0 0.000E+0 0.000E+0 1.000E+0val profiler = Remotery()
hub.add(profiler)final Profiler profiler = new Remotery();
hub.add(profiler);val profiler = hub.get<Profiler>()
profiler?.begin("MyProfilingPoint")
// do stuff
profiler?.end()final Profiler profiler = hub.get<Profiler>();
if(profiler == null) {
System.out.err("Could not get profiler :(");
System.exit(1);
}
profiler.begin("MyMarker");
// do stuff
profiler.end();


scenery.BackchannelPort6041Settings(val settingsName: String = "VolumeFile") - the file path is taken from the VM parameter "-DVolumeFile=$path$" of each individual application

How to run scenery-based applications on a distributed setup, such as a CAVE or PowerWall.
name: CAVE example configuration
description: Multi-screen configuration, demoing a 4-sided CAVE environment
screenWidth: 2560
screenHeight: 1600
screens:
front:
match:
type: Property
value: front
lowerLeft: -1.92, 0.00, 1.92
lowerRight: 1.92, 0.00, 1.92
upperLeft: -1.92, 2.40, 1.92
left:
match:
type: Property
value: left
lowerLeft: -1.92, 0.00, -1.92
lowerRight: -1.92, 0.00, 1.92
upperLeft: -1.92, 2.40, -1.92
right:
match:
type: Property
value: right
lowerLeft: 1.92, 0.00, 1.92
lowerRight: 1.92, 0.00, -1.92
upperLeft: 1.92, 2.40, 1.92
floor:
match:
type: Property
value: floor
lowerLeft: -1.92, 0.00, -0.48
lowerRight: 1.92, 0.00, -0.48
upperLeft: -1.92, 0.00, 1.92




