-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
23 changed files
with
473 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
orx-expression-evaluator-typed/src/jvmTest/kotlin/typed/TestTypedCompiledExpression.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
package org.openrndr.extra.mesh.generators | ||
|
||
import org.openrndr.extra.mesh.* | ||
import org.openrndr.math.Vector2 | ||
import org.openrndr.math.Vector3 | ||
|
||
class MeshBuilder { | ||
val vertexData = MutableVertexData() | ||
val polygons = mutableListOf<IndexedPolygon>() | ||
val mesh = MutableMeshData(vertexData, polygons) | ||
} | ||
|
||
fun box(): MeshData { | ||
|
||
val positions = listOf( | ||
Vector3(-0.5, -0.5, -0.5), | ||
Vector3(0.5, -0.5, -0.5), | ||
Vector3(-0.5, 0.5, -0.5), | ||
Vector3(0.5, 0.5, -0.5), | ||
|
||
Vector3(-0.5, -0.5, 0.5), | ||
Vector3(0.5, -0.5, 0.5), | ||
Vector3(-0.5, 0.5, 0.5), | ||
Vector3(0.5, 0.5, 0.5), | ||
) | ||
|
||
val textureCoords = listOf( | ||
Vector2(0.0, 0.0), | ||
Vector2(1.0, 0.0), | ||
Vector2(0.0, 1.0), | ||
Vector2(1.0, 1.0), | ||
) | ||
|
||
val normals = listOf( | ||
Vector3(-1.0, 0.0, 0.0), | ||
Vector3(1.0, 0.0, 0.0), | ||
Vector3(0.0, -1.0, 0.0), | ||
Vector3(0.0, 1.0, 0.0), | ||
Vector3(0.0, 0.0, -1.0), | ||
Vector3(0.0, 0.0, 1.0) | ||
) | ||
|
||
val polygons = listOf( | ||
// -x | ||
IndexedPolygon( | ||
positions = listOf(0, 2, 4, 6), | ||
textureCoords = listOf(0, 1, 3, 2), | ||
colors = emptyList(), | ||
normals = listOf(0, 0, 0, 0), | ||
tangents = listOf(5, 5, 5, 5), | ||
bitangents = listOf(3, 3, 3, 3) | ||
), | ||
// +x | ||
IndexedPolygon( | ||
positions = listOf(1, 3, 5, 7), | ||
textureCoords = listOf(0, 1, 3, 2), | ||
colors = emptyList(), | ||
normals = listOf(1, 1, 1, 1), | ||
tangents = listOf(4, 4, 4, 4), | ||
bitangents = listOf(3, 3, 3, 3) | ||
) | ||
) | ||
return MeshData( | ||
VertexData( | ||
positions = positions, | ||
textureCoords = textureCoords, | ||
normals = normals, | ||
tangents = normals, | ||
bitangents = normals | ||
), polygons | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
orx-mesh-generators/src/jvmDemo/kotlin/tangents/DemoTangents01.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package tangents | ||
|
||
import org.openrndr.application | ||
import org.openrndr.draw.DrawPrimitive | ||
import org.openrndr.draw.shadeStyle | ||
import org.openrndr.extra.camera.Orbital | ||
import org.openrndr.extra.mesh.toVertexBuffer | ||
import org.openrndr.extra.meshgenerators.tangents.estimateTangents | ||
import org.openrndr.extra.objloader.loadOBJMeshData | ||
import org.openrndr.math.Vector3 | ||
import java.io.File | ||
|
||
fun main() = application { | ||
program { | ||
val obj = loadOBJMeshData(File("demo-data/obj-models/suzanne/Suzanne.obj")).toMeshData().triangulate() | ||
val tangentObj = obj.estimateTangents() | ||
|
||
val objVB = tangentObj.toVertexBuffer() | ||
|
||
extend(Orbital()) { | ||
eye = Vector3(0.0, 0.0, 2.0) | ||
} | ||
extend { | ||
drawer.shadeStyle = shadeStyle { | ||
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; | ||
//x_fill.rgb = normalize(viewTangent)*0.5+0.5; | ||
x_fill.rgb = vec3(c); | ||
""".trimIndent() | ||
|
||
} | ||
|
||
drawer.vertexBuffer(objVB, DrawPrimitive.TRIANGLES) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import org.openrndr.application | ||
import org.openrndr.draw.DrawPrimitive | ||
import org.openrndr.draw.isolated | ||
import org.openrndr.draw.shadeStyle | ||
import org.openrndr.extra.camera.Orbital | ||
import org.openrndr.extra.mesh.noise.hash | ||
import org.openrndr.extra.objloader.loadOBJMeshData | ||
import org.openrndr.extra.mesh.noise.uniform | ||
import org.openrndr.extra.meshgenerators.sphereMesh | ||
import org.openrndr.math.Vector3 | ||
import java.io.File | ||
import kotlin.math.cos | ||
import kotlin.random.Random | ||
|
||
/** | ||
* Demonstrate uniform point on mesh generation using hash functions | ||
*/ | ||
fun main() { | ||
application { | ||
configure { | ||
width = 720 | ||
height = 720 | ||
} | ||
program { | ||
val mesh = loadOBJMeshData(File("demo-data/obj-models/suzanne/Suzanne.obj")).toMeshData() | ||
|
||
val sphere = sphereMesh(radius = 0.01) | ||
extend(Orbital()) { | ||
eye = Vector3(0.0, 0.0, 2.0) | ||
} | ||
extend { | ||
|
||
val points = mesh.hash((1000 + (cos(seconds)*0.5+0.5)*9000).toInt(), 808, (seconds*10000).toInt()) | ||
|
||
|
||
drawer.shadeStyle = shadeStyle { | ||
fragmentTransform = "x_fill = vec4(v_viewNormal*0.5+0.5, 1.0);" | ||
} | ||
for (point in points) { | ||
drawer.isolated { | ||
drawer.translate(point) | ||
drawer.vertexBuffer(sphere, DrawPrimitive.TRIANGLES) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.