Add descriptions to demos
This commit is contained in:
@@ -8,6 +8,17 @@ import org.openrndr.math.Vector2
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.shape.Rectangle
|
||||
|
||||
/**
|
||||
* Demonstrates how to create various types of 3D meshes:
|
||||
* box, sphere, dodecahedron, cylinder, plane, cap and resolve.
|
||||
*
|
||||
* Two textures are used: one generative with gradients, and the second
|
||||
* one is an image loaded from disk. The horizontal mouse position is used
|
||||
* to select which of the two textures to use.
|
||||
*
|
||||
* The meshes are positioned in space using a 2D mesh, and displayed
|
||||
* rotating on the X and Y axes at different speeds.
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
|
||||
@@ -9,6 +9,21 @@ import org.openrndr.extra.camera.Orbital
|
||||
import org.openrndr.extra.meshgenerators.boxMesh
|
||||
import org.openrndr.math.Vector3
|
||||
|
||||
/**
|
||||
* Demonstrates how to create a 3D mesh box by specifying its width, height and depth.
|
||||
*
|
||||
* The `box` is a `VertexBuffer` and contains texture coordinates which can be
|
||||
* used to apply a texture to its faces.
|
||||
*
|
||||
* After creating the box, the program creates a texture with a gradient.
|
||||
* In it, the red component increases along the x-axis and the green component
|
||||
* along the y-axis.
|
||||
*
|
||||
* The scene is rendered with an interactive `Orbital` 3D camera.
|
||||
*
|
||||
* A shade style is used to apply the texture to the box.
|
||||
*
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
|
||||
@@ -9,6 +9,17 @@ import org.openrndr.extra.meshgenerators.buildTriangleMesh
|
||||
import org.openrndr.extra.meshgenerators.sphere
|
||||
import org.openrndr.math.Vector3
|
||||
|
||||
/**
|
||||
* Demonstrates how to use `buildTriangleMesh` to construct composite 3D meshes.
|
||||
*
|
||||
* A DSL allows specifying the color and transformations of each mesh, in this case,
|
||||
* of a sphere and a box.
|
||||
*
|
||||
* An interactive 3D Orbital camera is defined, specifying the location of its `eye` and
|
||||
* `lookAt` properties.
|
||||
*
|
||||
* A minimal shade style is used to simulate a uni-directional light pointing along the view Z axis.
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
|
||||
@@ -8,6 +8,9 @@ import org.openrndr.extra.meshgenerators.cylinder
|
||||
import org.openrndr.extra.meshgenerators.hemisphere
|
||||
import org.openrndr.math.Vector3
|
||||
|
||||
/**
|
||||
* Demonstrates the creation of a 3D mesh composed of two hemispheres, a cylinder and 12 legs.
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
|
||||
@@ -6,6 +6,16 @@ import org.openrndr.extra.camera.Orbital
|
||||
import org.openrndr.extra.meshgenerators.*
|
||||
import org.openrndr.math.Vector3
|
||||
|
||||
/**
|
||||
* Demonstrates the creation of a 3D mesh composed of two hemispheres, a cylinder and 12 legs.
|
||||
* Additionally, the body of the shape features 5 ridges on the sides
|
||||
* of the cylinder.
|
||||
*
|
||||
* The code reveals DSL keywords under `buildTriangleMesh`
|
||||
* affecting transformation matrices, for instance `isolated`, `translate` and `rotate`,
|
||||
* and mesh generating keywords like
|
||||
* `hemisphere`, `taperedCylinder` and `cylinder`.
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
|
||||
@@ -7,6 +7,11 @@ import org.openrndr.extra.meshgenerators.*
|
||||
import org.openrndr.math.Vector2
|
||||
import org.openrndr.math.Vector3
|
||||
|
||||
/**
|
||||
* Demonstrates the use of `buildTriangleMesh` to create
|
||||
* a composite 3D mesh and introduces a new mesh generating keyword:
|
||||
* `cap`.
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
|
||||
@@ -11,6 +11,12 @@ import org.openrndr.extra.meshgenerators.twist
|
||||
import org.openrndr.math.Vector3
|
||||
import org.openrndr.shape.Circle
|
||||
|
||||
/**
|
||||
* Demonstrates how to create a 3D grid of extruded shapes
|
||||
* (short cylinders), then applies three 3D twists to the
|
||||
* composition to deform it.
|
||||
*
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
|
||||
@@ -9,8 +9,11 @@ import org.openrndr.extra.noise.simplex
|
||||
import org.openrndr.math.Vector3
|
||||
|
||||
/**
|
||||
* Generates a grid of grids of boxes.
|
||||
* Interactive orbital camera.
|
||||
* Generates a grid of grids of 3D boxes using `buildTriangleMesh` and
|
||||
* renders them using an interactive orbital camera.
|
||||
*
|
||||
* The cubes ar colorized using a shade style that sets colors based
|
||||
* on vertex positions in space, converting XYZ coordinates into RGB colors.
|
||||
*
|
||||
*/
|
||||
fun main() = application {
|
||||
|
||||
@@ -10,6 +10,15 @@ import org.openrndr.extra.objloader.loadOBJMeshData
|
||||
import org.openrndr.math.Vector3
|
||||
import java.io.File
|
||||
|
||||
/**
|
||||
* Tangent and bitangent vectors are used in shader programs for tangent space normal mapping / lighting
|
||||
* and certain forms of displacement mapping.
|
||||
*
|
||||
* This demo shows:
|
||||
* - how to create a triangulated `MeshData`.
|
||||
* - how to estimate the tangents of this MeshData.
|
||||
* - How to use the tangent and bitangent attributes in GLSL code.
|
||||
*/
|
||||
fun main() = application {
|
||||
configure {
|
||||
width = 720
|
||||
@@ -29,12 +38,11 @@ fun main() = application {
|
||||
fragmentTransform = """
|
||||
vec3 viewTangent = (u_viewNormalMatrix * u_modelNormalMatrix * vec4(va_tangent, 0.0)).xyz;
|
||||
vec3 viewBitangent = (u_viewNormalMatrix * u_modelNormalMatrix * vec4(va_bitangent, 0.0)).xyz;
|
||||
float c = cos(100.0*dot(v_worldPosition, va_normal)) * 0.5 + 0.5;
|
||||
float c = cos(100.0 * dot(v_worldPosition, va_normal)) * 0.5 + 0.5;
|
||||
|
||||
//x_fill.rgb = normalize(viewTangent)*0.5+0.5;
|
||||
x_fill.rgb = vec3(c);
|
||||
""".trimIndent()
|
||||
|
||||
//x_fill.rgb = normalize(viewTangent) * 0.5 + 0.5;
|
||||
x_fill.rgb = vec3(c);
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
drawer.vertexBuffer(objVB, DrawPrimitive.TRIANGLES)
|
||||
|
||||
Reference in New Issue
Block a user