Skip to content

Commit

Permalink
Merge branch 'feature/3d-objects'
Browse files Browse the repository at this point in the history
# Conflicts:
#	vitrivr-engine-plugin-features/src/main/kotlin/org/vitrivr/engine/base/features/external/implementations/clip/CLIP.kt
#	vitrivr-engine-plugin-features/src/main/kotlin/org/vitrivr/engine/base/features/external/implementations/dino/DINO.kt
#	vitrivr-engine-server/src/main/kotlin/org/vitrivr/engine/server/api/rest/handlers/Query.kt
  • Loading branch information
Ralph Gasser committed Feb 2, 2024
2 parents 28588b2 + 8e80c17 commit f34e7c0
Show file tree
Hide file tree
Showing 73 changed files with 9,905 additions and 132 deletions.
18 changes: 14 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,12 @@ subprojects {
jvmTarget = "17"
}
}

kotlin {

tasks.withType(Test).configureEach {
useJUnitPlatform()
}

kotlin {
jvmToolchain(17)
}

Expand All @@ -82,8 +86,8 @@ subprojects {
implementation group: 'com.github.ben-manes.caffeine', name: 'caffeine', version: version_caffeine

/* Logging */
implementation group: 'io.github.oshai', name: 'kotlin-logging-jvm', version: version_kotlinlogging
implementation group: 'org.slf4j', name: 'slf4j-api', version: version_slf4j
implementation group: 'io.github.oshai', name: 'kotlin-logging-jvm', version: version_kotlinlogging
implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: version_log4j2
implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: version_log4j2
implementation group: 'org.apache.logging.log4j', name: 'log4j-slf4j2-impl', version: version_log4j2
Expand All @@ -92,7 +96,13 @@ subprojects {
implementation group: 'org.jetbrains.kotlin', name: 'kotlin-stdlib', version: version_kotlin
implementation group: 'org.jetbrains.kotlin', name: 'kotlin-reflect', version: version_kotlin
implementation group: 'org.jetbrains.kotlinx', name: 'kotlinx-coroutines-core', version: version_kotlinx_coroutines
implementation group: 'org.jetbrains.kotlinx', name:'kotlinx-serialization-json', version: '1.6.0'
implementation group: 'org.jetbrains.kotlinx', name:'kotlinx-serialization-json', version: version_kotlinx_serialization

/* JUnit 5 */
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-api', version: version_junit
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-engine', version: version_junit
testImplementation group: 'org.junit.jupiter', name: 'junit-jupiter-params', version: version_junit
testImplementation group: 'org.junit.platform', name: 'junit-platform-commons', version: version_junit_platform
}
}

Expand Down
8 changes: 7 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,16 +1,22 @@
version_caffeine=3.1.8
version_clikt=4.2.0
version_commonsmath3=3.6.1
version_cottontaildb=0.16.1
version_jackson_kotlin=2.15.2
version_javacv=1.5.9
version_javalin=5.6.3
version_jline=3.23.0
version_junit=5.10.1
version_junit_platform=1.10.1
version_grpc=1.60.0
version_kotlin=1.9.21
version_kotlinx_coroutines=1.7.3
version_kotlinx_serialization=1.6.2
version_kotlinlogging = 5.1.0
version_log4j2=2.20.0
version_picnic=0.7.0
version_protobuf=3.25.1
version_scrimage=4.1.1
version_slf4j=2.0.9
version_slf4j=2.0.9
version_jogl=2.3.2
version_joml=1.9.25
2 changes: 2 additions & 0 deletions settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ include 'vitrivr-engine-query'
include 'vitrivr-engine-server'
include 'vitrivr-engine-plugin-cottontaildb'
include 'vitrivr-engine-plugin-features'
include 'vitrivr-engine-plugin-m3d'

3 changes: 2 additions & 1 deletion vitrivr-engine-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ plugins {
}

dependencies {

/** JOML dependencies for 3D mesh support. */
implementation group: 'org.joml', name: 'joml', version: version_joml
}

/* Publication of vitrivr engine core to Maven Central. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,10 @@ class FileSourceMetadata : Analyser<ContentElement<*>, FileSourceMetadataDescrip
/**
* Generates a prototypical [FileSourceMetadataDescriptor] for this [FileSourceMetadata].
*
* @param field The [Schema.Field] to create the prototype for.
* @return [FileSourceMetadataDescriptor]
*/
override fun prototype() = FileSourceMetadataDescriptor(UUID.randomUUID(), UUID.randomUUID(), "", 0, true)
override fun prototype(field: Schema.Field<*, *>) = FileSourceMetadataDescriptor(UUID.randomUUID(), UUID.randomUUID(), "", 0, true)

/**
* Generates and returns a new [FileSourceMetadataExtractor] for the provided [Schema.Field].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import org.vitrivr.engine.core.operators.retrieve.Retriever
import java.util.*

/**
* Implementation of the [VideoSourceMetadata] [Analyser], which derives metadata information from [Retr]
* Implementation of the [VideoSourceMetadata] [Analyser], which derives metadata information from a [Retrievable].
*
* @author Ralph Gasser
* @version 1.0.0
Expand All @@ -28,9 +28,10 @@ class VideoSourceMetadata : Analyser<ContentElement<*>, VideoSourceMetadataDescr
/**
* Generates a prototypical [FileSourceMetadataDescriptor] for this [FileSourceMetadata].
*
* @param field The [Schema.Field] to create the prototype for.
* @return [FileSourceMetadataDescriptor]
*/
override fun prototype() = VideoSourceMetadataDescriptor.PROTOTYPE
override fun prototype(field: Schema.Field<*, *>) = VideoSourceMetadataDescriptor.PROTOTYPE

/**
* Generates and returns a new [FileSourceMetadataExtractor] for the provided [Schema.Field].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ class TemporalMetadata : Analyser<ContentElement<*>, TemporalMetadataDescriptor>
/**
* Generates a prototypical [TemporalMetadataDescriptor] for this [FileSourceMetadata].
*
* @param field The [Schema.Field] to create the prototype for.
* @return [FloatVectorDescriptor]
*/
override fun prototype() = TemporalMetadataDescriptor(UUID.randomUUID(), UUID.randomUUID(), 0, 0, true)
override fun prototype(field: Schema.Field<*, *>) = TemporalMetadataDescriptor(UUID.randomUUID(), UUID.randomUUID(), 0, 0, true)

/**
* Generates and returns a new [FileSourceMetadataExtractor] for the provided [Schema.Field].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import java.util.*
class MediaDimensions : Analyser<ContentElement<*>, MediaDimensionsDescriptor> {
override val contentClasses = setOf(ContentElement::class)
override val descriptorClass = MediaDimensionsDescriptor::class
override fun prototype() = MediaDimensionsDescriptor(UUID.randomUUID(), UUID.randomUUID(), 0, 0, true)
override fun prototype(field: Schema.Field<*,*>) = MediaDimensionsDescriptor(UUID.randomUUID(), UUID.randomUUID(), 0, 0, true)


override fun newRetrieverForContent(field: Schema.Field<ContentElement<*>, MediaDimensionsDescriptor>, content: Collection<ContentElement<*>>, context: QueryContext): Retriever<ContentElement<*>, MediaDimensionsDescriptor> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import java.util.*
class VideoDuration : Analyser<ContentElement<*>, FloatDescriptor> {
override val contentClasses = setOf(ContentElement::class)
override val descriptorClass = FloatDescriptor::class
override fun prototype() = FloatDescriptor(UUID.randomUUID(), UUID.randomUUID(),transient = true, value=.0f)
override fun prototype(field: Schema.Field<*,*>) = FloatDescriptor(UUID.randomUUID(), UUID.randomUUID(),transient = true, value=.0f)
override fun newRetrieverForContent(field: Schema.Field<ContentElement<*>, FloatDescriptor>, content: Collection<ContentElement<*>>, context: QueryContext): Retriever<ContentElement<*>, FloatDescriptor> {
TODO("Not yet implemented")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import java.util.*
class VideoFPS : Analyser<ContentElement<*>, FloatDescriptor> {
override val contentClasses = setOf(ContentElement::class)
override val descriptorClass = FloatDescriptor::class
override fun prototype() = FloatDescriptor(UUID.randomUUID(), UUID.randomUUID(),transient = true, value=.0f)
override fun prototype(field: Schema.Field<*,*>) = FloatDescriptor(UUID.randomUUID(), UUID.randomUUID(),transient = true, value=.0f)
override fun newRetrieverForContent(field: Schema.Field<ContentElement<*>, FloatDescriptor>, content: Collection<ContentElement<*>>, context: QueryContext): Retriever<ContentElement<*>, FloatDescriptor> {
TODO("Not yet implemented")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.vitrivr.engine.core.model.content.element

import org.vitrivr.engine.core.model.mesh.Model3D

/**
* A 3D [ContentElement].
*
* @author Rahel Arnold
* @version 1.0.0
*/
interface Model3DContent: ContentElement<Model3D>
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
package org.vitrivr.engine.core.model.mesh

import org.apache.logging.log4j.LogManager
import org.joml.Matrix4f
import org.joml.Quaternionf
import org.joml.Vector3f

/**
* An Entity in the context of a [Model3D] describes a position and scale of a model in the scene.
* The Entity is composed of a model matrix that is used to transform the model in the scene.
* The model matrix is calculated from the position, rotation and scale of the entity.
* The Entity influences how the model is rendered in the scene.
* It does not change the mesh of the model.
* Neither does it change the viewpoint of the camera.
*/
class Entity(
/**
* ID of entity.
*/
private val id: String,
/**
* ID of associated model.
*/
private val modelId: String
) {
private val LOGGER = LogManager.getLogger()

/**
* Model matrix of entity.
* Used to transform the model in the scene.
* Calculated from position, rotation and scale.
*/
private val modelMatrix: Matrix4f = Matrix4f()

/**
* Position of entity.
*/
private val position: Vector3f = Vector3f()

/**
* Rotation of entity.
*/
private val rotation: Quaternionf = Quaternionf()

/**
* Scale of entity.
*/
private var scale: Float = 1f

/**
* Constructs a new Entity.
* Defines an associated model and an id.
* With associated model one is able to add new transformations to the Scene [GLScene.addEntity].
*
* @param id ID of entity.
* @param modelId ID of associated model.
*/
init {
this.updateModelMatrix()
}

/**
* @return Unique ID of entity.
*/
fun getId(): String {
return this.id
}

/**
* @return ID of the associated model.
*/
fun getModelId(): String {
return this.modelId
}

/**
* @return Model matrix of entity, describes a rigid transformation of the Model.
*/
fun getModelMatrix(): Matrix4f {
return this.modelMatrix
}

/**
* Translation values, contained in the ModelMatrix
* @return Translate position of entity in x, y, z.
*/
fun getPosition(): Vector3f {
return this.position
}

/**
* Rotation values, contained in the ModelMatrix
* @return Rotation around x,y,z axes as a quaternion.
*/
fun getRotation(): Quaternionf {
return this.rotation
}

/**
* Scale value, contained in the ModelMatrix
* Scales the associated model. 1.0f is no scaling.
* @return Scale value.
*/
fun getScale(): Float {
return this.scale
}

/**
* Sets the as a translation vector from the origin.
* @param x X coordinate of position.
* @param y Y coordinate of position.
* @param z Z coordinate of position.
*/
fun setPosition(x: Float, y: Float, z: Float) {
this.position.set(x, y, z)
}

/**
* Sets translation vector from the origin.
* @param position Position of entity.
*/
fun setPosition(position: Vector3f) {
this.position.set(position)
}

/**
* Sets the rotation of the entity.
* @param x X coordinate of axis.
* @param y Y coordinate of axis.
* @param z Z coordinate of axis.
* @param angle Angle of rotation.
*/
fun setRotation(x: Float, y: Float, z: Float, angle: Float) {
this.rotation.setAngleAxis(angle, x, y, z)
}

/**
* Sets the rotation of the entity.
* @param axis Axis of rotation.
* @param angle Angle of rotation.
*/
fun setRotation(axis: Vector3f, angle: Float) {
rotation.fromAxisAngleRad(axis, angle)
}

/**
* Sets the scale of the entity.
* set to 1 for no scaling.
* @param scale Scale of entity.
*/
fun setScale(scale: Float) {
this.scale = scale
}

/**
* Updates the model matrix of the entity.
* @implSpec This has to be called after any transformation.
*/
private fun updateModelMatrix() {
this.modelMatrix.translationRotateScale(this.position, this.rotation, this.scale)
}

/**
* Closes the entity.
* Sets the position, rotation to zero and scale to 1.
*/
fun close() {
this.position.zero()
this.rotation.identity()
this.scale = 1f
this.updateModelMatrix()
LOGGER.trace("Entity {} closed", this.id)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package org.vitrivr.engine.core.model.mesh

import org.joml.Vector3f

/**
*
*/
interface IModel {
/** The identifier of this [IModel] within the scene. */
val id: String

/**
* Adds an entity to the model.
* @param entity Entity to be added.
*/
fun addEntity(entity: Entity)

/**
* Returns a list of all entities that are associated with this model.
*
* @return List of [Entity] objects.
*/
fun getEntities(): List<Entity>

/**
* Returns a list of all materials that are associated with this model.
*
* @return List of [Material] objects.
*/
fun getMaterials(): List<Material>

/**
* Returns a list of all vertex normals that are associated with this model.
*
* @return List of [Vector3f].
*/
fun getAllNormals(): List<Vector3f>
}
Loading

0 comments on commit f34e7c0

Please sign in to comment.