Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new landmarks renderers #218

Merged
merged 63 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
fbb5595
finish a points renderer prototype
mi-sts Mar 12, 2024
93e402e
codestyle
mi-sts Mar 12, 2024
5807ba2
small fixes
mi-sts Mar 12, 2024
1018ea8
separate the landmark renderer logic
mi-sts Mar 17, 2024
bd90f66
add point landmarks scale logic
mi-sts Mar 17, 2024
c9c855d
add random color realization
mi-sts Mar 17, 2024
8e4b57d
remove useless classes
mi-sts Mar 17, 2024
83d5043
codestyle
mi-sts Mar 17, 2024
9f5080e
add lines renderer prototype
mi-sts Mar 17, 2024
a585b9a
codestyle
mi-sts Mar 17, 2024
5d09382
small frames renderer bugfixes
mi-sts Mar 31, 2024
b2d4749
fix lines renderer bugs
mi-sts Mar 31, 2024
8e269cf
codestyle
mi-sts Mar 31, 2024
68bf495
add lines landmarks color logic
mi-sts Mar 31, 2024
73fa460
add lines landmarks width logic
mi-sts Mar 31, 2024
f32ff07
codestylw
mi-sts Mar 31, 2024
e3c663b
fixing plane renderer bugs
mi-sts Apr 7, 2024
d0b8839
fixing plane renderer bugs
mi-sts Apr 7, 2024
1c0e50f
fix planes drawing bugs
mi-sts Apr 8, 2024
e1724d7
fix unloaging frames bug
mi-sts Apr 8, 2024
c0de7e9
fix frames renderer bugs
mi-sts Apr 9, 2024
295950c
codestyle
mi-sts Apr 9, 2024
0a6322c
update scene tests
mi-sts Apr 9, 2024
3c6855a
codestyle
mi-sts Apr 9, 2024
c310a38
add non-planes layers hiding
mi-sts Apr 9, 2024
6cea96c
bind frames textures before drawing
mi-sts Apr 9, 2024
7004ec6
add spacing lines for frames
mi-sts Apr 10, 2024
8ce9ccc
codestyle
mi-sts Apr 10, 2024
edf9695
add layer click handlers and coordinates convertion logic
mi-sts Apr 17, 2024
5ec39d9
vectors conversion refactoring
mi-sts Apr 18, 2024
fff0bcc
add highlighting properties for landmarks
mi-sts Apr 18, 2024
63c6219
codestyle
mi-sts Apr 18, 2024
8613111
remove check depending on app pulses
mi-sts Apr 19, 2024
11d61d8
decrease frames spacing
mi-sts Apr 29, 2024
bd9bf01
add points and lines selection
mi-sts Apr 30, 2024
21e6816
codestyle
mi-sts Apr 30, 2024
541ce1a
change deprecated methods
mi-sts Apr 30, 2024
3d8cce5
update javafx version and revert other changes
mi-sts May 1, 2024
d8278ac
add color interpolation for highlighted landmarks
mi-sts May 1, 2024
55838fc
add a scene context menu
mi-sts May 1, 2024
8979edb
upgrade landmarks virtualization
mi-sts May 2, 2024
e472374
codestyle
mi-sts May 2, 2024
823feaa
fix planes landmarks virtualization bug
mi-sts May 2, 2024
5b15e27
add points associations renderer
mi-sts May 3, 2024
af5f007
add association ui
mi-sts May 4, 2024
f923796
add associations clearing ui
mi-sts May 4, 2024
c9b1448
codestyle
mi-sts May 4, 2024
eb9e63c
update adorner unit tests
mi-sts May 4, 2024
b67098b
improve lines rendering
mi-sts May 6, 2024
62c3c54
codestyle
mi-sts May 6, 2024
777c2d4
add planes selection
mi-sts May 18, 2024
3ee2b73
codestyle
mi-sts May 18, 2024
27f70f7
update unit tests
mi-sts May 18, 2024
b1c2f6b
improve associations and lines rendering
mi-sts May 19, 2024
a64ff44
codestyle
mi-sts May 19, 2024
91b51c1
codestyle
mi-sts May 19, 2024
b4e989b
fix small bugs
mi-sts May 19, 2024
41a0209
fix planes selection bug
mi-sts May 19, 2024
09327aa
update associations logic
mi-sts May 24, 2024
e6b643f
codestyle
mi-sts May 24, 2024
817dad3
delete useless file
mi-sts May 24, 2024
1df9f83
fix small bugs
mi-sts May 24, 2024
d997fe9
update tests
mi-sts May 24, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.gradle.internal.os.OperatingSystem

plugins {
kotlin("jvm") version "1.7.20"
id("org.openjfx.javafxplugin") version "0.0.10"
id("org.openjfx.javafxplugin") version "0.0.14"
id("org.jlleitschuh.gradle.ktlint") version "11.3.2"
id("application")
application
Expand Down
12 changes: 10 additions & 2 deletions src/main/kotlin/solve/constants/ResourcesPaths.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,16 @@ const val IconsGrid = "/icons/sidepanel/Grid.png"
const val IconsGridSelected = "/icons/sidepanel/GridSelected.png"

// Engine shaders.
const val ShadersDefaultVertexPath = "engine/shaders/default/default.vert"
const val ShadersDefaultFragmentPath = "engine/shaders/default/default.frag"
const val ShadersDefaultVertexPath = "engine/shaders/default/sprite.vert"
const val ShadersDefaultFragmentPath = "engine/shaders/default/sprite.frag"
const val ShadersFrameVertexPath = "engine/shaders/frame/frame.vert"
const val ShadersFrameGeometryPath = "engine/shaders/frame/frame.geom"
const val ShadersFrameFragmentPath = "engine/shaders/frame/frame.frag"
const val ShadersPointLandmarkVertexPath = "engine/shaders/landmark/point/point.vert"
const val ShadersPointLandmarkFragmentPath = "engine/shaders/landmark/point/point.frag"
const val ShadersLineLandmarkVertexPath = "engine/shaders/landmark/line/line.vert"
const val ShadersLineLandmarkFragmentPath = "engine/shaders/landmark/line/line.frag"
const val ShadersPlaneLandmarkVertexPath = "engine/shaders/landmark/plane/plane.vert"
const val ShadersPlaneLandmarkFragmentPath = "engine/shaders/landmark/plane/plane.frag"
const val ShadersPointAssociationVertexPath = "engine/shaders/association/point/point.vert"
const val ShadersPointAssociationFragmentPath = "engine/shaders/association/point/point.frag"
4 changes: 2 additions & 2 deletions src/main/kotlin/solve/main/splitpane/SidePanelSplitPane.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ class SidePanelSplitPane(
}

if (location == SidePanelLocation.Left && !isLeftSidePanelHidden) {
items.removeFirst()
items.removeAt(0)
isLeftSidePanelHidden = true
} else if (location == SidePanelLocation.Right && !isRightSidePanelHidden) {
items.removeLast()
items.removeAt(items.count() - 1)
isRightSidePanelHidden = true
} else {
return
Expand Down
3 changes: 1 addition & 2 deletions src/main/kotlin/solve/parsers/factories/PlaneFactory.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ object PlaneFactory : LandmarkFactory<StoragePlane, ScenePlane, PlaneLayerSettin
): ScenePlane = ScenePlane(
storageFormatLandmark.uid,
containingLayerSettings,
containingLayerState,
storageFormatLandmark.points
containingLayerState
)
}
80 changes: 48 additions & 32 deletions src/main/kotlin/solve/parsers/planes/ImagePlanesParser.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,37 +28,6 @@ object ImagePlanesParser : Parser<Plane> {
const val ColorBitsNumber = 8
const val BackgroundColor = 0

private fun convertSeparateToWholeRGB(r: UByte, g: UByte, b: UByte): Int =
(r.toInt() shl ColorBitsNumber * 2) + (g.toInt() shl ColorBitsNumber) + b.toInt()

private fun getPlanePixelColor(
pixelIndex: Int,
imageByteDataArray: ByteArray,
segmentsType: ColorSegmentsType
): Int {
val segmentsByteOffset = segmentsType.segmentsByteOffset

return convertSeparateToWholeRGB(
imageByteDataArray[pixelIndex + segmentsByteOffset + 2].toUByte(),
imageByteDataArray[pixelIndex + segmentsByteOffset + 1].toUByte(),
imageByteDataArray[pixelIndex + segmentsByteOffset].toUByte()
)
}

private fun getImageByteDataArray(image: BufferedImage) = (image.data.dataBuffer as DataBufferByte).data

private inline fun BufferedImage.forEachPixelColor(action: (index: Int, color: Int) -> Unit) {
val imageByteDataArray = getImageByteDataArray(this)
val colorSegmentsType: ColorSegmentsType =
ColorSegmentsType.getColorSegmentsType(colorModel.numComponents) ?: return
val colorComponentsNumber = colorSegmentsType.colorComponentsNumber

for (i in imageByteDataArray.indices step colorComponentsNumber) {
val pixelColor = getPlanePixelColor(i, imageByteDataArray, colorSegmentsType)
action(i / colorComponentsNumber, pixelColor)
}
}

override fun parse(filePath: String): List<Plane> {
val bufferedImage = loadBufferedImage(filePath) ?: return emptyList()

Expand All @@ -75,7 +44,7 @@ object ImagePlanesParser : Parser<Plane> {
}
}

return planePoints.keys.map { Plane(it, planePoints[it] ?: emptyList()) }
return planePoints.keys.map { Plane(it) }
}

override fun extractUIDs(filePath: String): List<Long> {
Expand All @@ -92,4 +61,51 @@ object ImagePlanesParser : Parser<Plane> {

return uids.toList()
}

fun getPixelColor(filePath: String, pixelPosition: Point): Int? {
val bufferedImage = loadBufferedImage(filePath) ?: return null

return bufferedImage.getPixelColor(pixelPosition)
}

private fun convertSeparateToWholeRGB(r: UByte, g: UByte, b: UByte): Int =
(r.toInt() shl ColorBitsNumber * 2) + (g.toInt() shl ColorBitsNumber) + b.toInt()

private fun getImageByteDataPixelColor(
pixelIndex: Int,
imageByteDataArray: ByteArray,
segmentsType: ColorSegmentsType
): Int {
val segmentsByteOffset = segmentsType.segmentsByteOffset

return convertSeparateToWholeRGB(
imageByteDataArray[pixelIndex + segmentsByteOffset + 2].toUByte(),
imageByteDataArray[pixelIndex + segmentsByteOffset + 1].toUByte(),
imageByteDataArray[pixelIndex + segmentsByteOffset].toUByte()
)
}

private fun getImageByteDataArray(image: BufferedImage) = (image.data.dataBuffer as DataBufferByte).data

private inline fun BufferedImage.forEachPixelColor(action: (index: Int, color: Int) -> Unit) {
val imageByteDataArray = getImageByteDataArray(this)
val colorSegmentsType: ColorSegmentsType =
ColorSegmentsType.getColorSegmentsType(colorModel.numComponents) ?: return
val colorComponentsNumber = colorSegmentsType.colorComponentsNumber

for (i in imageByteDataArray.indices step colorComponentsNumber) {
val pixelColor = getImageByteDataPixelColor(i, imageByteDataArray, colorSegmentsType)
action(i / colorComponentsNumber, pixelColor)
}
}

private fun BufferedImage.getPixelColor(pixelPosition: Point): Int? {
val imageByteDataArray = getImageByteDataArray(this)
val colorSegmentsType: ColorSegmentsType =
ColorSegmentsType.getColorSegmentsType(colorModel.numComponents) ?: return null
val colorComponentsNumber = colorSegmentsType.colorComponentsNumber
val pixelFirstComponentIndex = (pixelPosition.y * this.width + pixelPosition.x) * colorComponentsNumber

return getImageByteDataPixelColor(pixelFirstComponentIndex, imageByteDataArray, colorSegmentsType)
}
}
4 changes: 1 addition & 3 deletions src/main/kotlin/solve/parsers/structures/Plane.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
package solve.parsers.structures

import solve.scene.model.Point

data class Plane(val uid: Long, val points: List<Point>)
data class Plane(val uid: Long)
19 changes: 15 additions & 4 deletions src/main/kotlin/solve/rendering/canvas/OpenGLCanvas.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,22 @@ import com.huskerdev.openglfx.events.GLReshapeEvent
import com.huskerdev.openglfx.lwjgl.LWJGLExecutor
import org.joml.Vector2i
import org.lwjgl.opengl.GL.createCapabilities
import org.lwjgl.opengl.GL11.GL_ALPHA_TEST
import org.lwjgl.opengl.GL11.GL_BLEND
import org.lwjgl.opengl.GL11.GL_COLOR_BUFFER_BIT
import org.lwjgl.opengl.GL11.GL_DEPTH_BUFFER_BIT
import org.lwjgl.opengl.GL11.GL_DEPTH_TEST
import org.lwjgl.opengl.GL11.GL_LEQUAL
import org.lwjgl.opengl.GL11.GL_ONE_MINUS_SRC_ALPHA
import org.lwjgl.opengl.GL11.GL_PROJECTION
import org.lwjgl.opengl.GL11.GL_SRC_ALPHA
import org.lwjgl.opengl.GL11.glBlendFunc
import org.lwjgl.opengl.GL11.glClear
import org.lwjgl.opengl.GL11.glDepthFunc
import org.lwjgl.opengl.GL11.glEnable
import org.lwjgl.opengl.GL11.glLoadIdentity
import org.lwjgl.opengl.GL11.glMatrixMode
import org.lwjgl.opengl.GL13.GL_MULTISAMPLE
import solve.rendering.engine.Window
import solve.rendering.engine.utils.minus
import solve.rendering.engine.utils.plus
Expand All @@ -33,10 +39,17 @@ abstract class OpenGLCanvas {
canvas.animator = GLCanvasAnimator(OpenGLCanvasFPS)
}

open fun onInit() { }

open fun onDraw(deltaTime: Float) { }

open fun onInit() {
glEnable(GL_ALPHA_TEST)
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA)
glEnable(GL_BLEND)
glEnable(GL_DEPTH_TEST)
glEnable(GL_MULTISAMPLE)
glDepthFunc(GL_LEQUAL)
}

open fun onDispose() { }

protected fun initializeCanvasEvents() {
Expand All @@ -55,8 +68,6 @@ abstract class OpenGLCanvas {
}

private fun render(event: GLRenderEvent) {
glEnable(GL_DEPTH_TEST)
glDepthFunc(GL_LEQUAL)
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT)

onDraw(event.delta.toFloat())
Expand Down
Loading
Loading