Fix problem in UV coord generation of plane meshes

This commit is contained in:
Edwin Jakobs
2020-04-06 19:13:49 +02:00
parent 185c02176f
commit 0de7426017
4 changed files with 150 additions and 89 deletions

View File

@@ -20,16 +20,26 @@ project.ext {
spekVersion = "2.0.10" spekVersion = "2.0.10"
libfreenectVersion = "0.5.7-1.5.2" libfreenectVersion = "0.5.7-1.5.2"
gsonVersion = "2.8.6" gsonVersion = "2.8.6"
}
}
switch (org.gradle.internal.os.OperatingSystem.current()) {
case org.gradle.internal.os.OperatingSystem.WINDOWS:
project.ext.openrndrOS = "windows"
break
case org.gradle.internal.os.OperatingSystem.LINUX:
project.ext.openrndrOS = "linux-x64"
break
case org.gradle.internal.os.OperatingSystem.MAC_OS:
project.ext.openrndrOS = "macos"
break
}
dokka { dokka {
moduleName = "$rootProject.name" moduleName = "$rootProject.name"
outputDirectory = "$buildDir/docs" outputDirectory = "$buildDir/docs"
outputFormat = "html" outputFormat = "html"
includes = ['Module.md'] includes = ['Module.md']
sourceDirs = files(subprojects.collect { p -> new File(p.projectDir, "/src/main/kotlin") }) sourceDirs = files(subprojects.collect { p -> new File(p.projectDir, "/src/main/kotlin") })
} }
allprojects { allprojects {
apply plugin: 'idea' apply plugin: 'idea'
@@ -72,13 +82,11 @@ allprojects {
runtimeOnly "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion" runtimeOnly "org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion"
} }
java { java {
sourceCompatibility = JavaVersion.VERSION_1_8 sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8
} }
javadoc { javadoc {
options.addBooleanOption 'Xdoclint:none', true options.addBooleanOption 'Xdoclint:none', true
} }

View File

@@ -0,0 +1,18 @@
sourceSets {
demo {
java {
srcDirs = ["src/demo/kotlin"]
compileClasspath += main.getCompileClasspath()
runtimeClasspath += main.getRuntimeClasspath()
}
}
}
dependencies {
demoImplementation(project(":orx-camera"))
demoImplementation("org.openrndr:openrndr-core:$openrndrVersion")
demoRuntimeOnly("org.openrndr:openrndr-gl3:$openrndrVersion")
demoRuntimeOnly("org.openrndr:openrndr-gl3-natives-$openrndrOS:$openrndrVersion")
demoImplementation(sourceSets.getByName("main").output)
}

View File

@@ -0,0 +1,35 @@
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.DrawPrimitive
import org.openrndr.draw.colorBuffer
import org.openrndr.draw.shadeStyle
import org.openrndr.extras.camera.Orbital
import org.openrndr.extras.meshgenerators.boxMesh
fun main() {
application {
program {
val box = boxMesh(1.0, 1.0, 1.0)
val texture = colorBuffer(256, 256)
val s = texture.shadow
for (y in 0 until 256) {
for (x in 0 until 256) {
s[x, y] = ColorRGBa(x/256.0, y/256.0, 0.0, 1.0)
}
}
s.upload()
extend(Orbital())
extend {
drawer.background(ColorRGBa.PINK)
drawer.shadeStyle = shadeStyle {
fragmentTransform = """
x_fill = texture(p_texture, va_texCoord0.xy);
""".trimIndent()
parameter("texture", texture)
}
drawer.vertexBuffer(box, DrawPrimitive.TRIANGLES)
}
}
}
}

View File

@@ -57,7 +57,7 @@ fun generatePlane(center: Vector3,
val corner = center - forward.normalized * (height*0.5) - right.normalized * (width * 0.5) val corner = center - forward.normalized * (height*0.5) - right.normalized * (width * 0.5)
val step = Vector2(1.0 / width, 1.0 / height) val step = Vector2(1.0 / widthSegments, 1.0 / heightSegments)
for (v in 0 until heightSegments) { for (v in 0 until heightSegments) {
for (u in 0 until widthSegments) { for (u in 0 until widthSegments) {