-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from vitrivr/feature/3d-objects
Feature/3d objects
- Loading branch information
Showing
7 changed files
with
186 additions
and
2 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
16 changes: 16 additions & 0 deletions
16
...ne-core/src/main/kotlin/org/vitrivr/engine/core/model/content/impl/InMemoryMeshContent.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,16 @@ | ||
package org.vitrivr.engine.core.model.content.impl | ||
|
||
import org.vitrivr.engine.core.model.content.element.ImageContent | ||
import org.vitrivr.engine.core.model.content.element.Model3DContent | ||
import org.vitrivr.engine.core.model.mesh.Model3D | ||
import java.awt.image.BufferedImage | ||
|
||
/** | ||
* A naive in-memory implementation of the [ImageContent] interface. | ||
* | ||
* Warning: Usage of [InMemoryMeshContent] may lead to out-of-memory situations in large extraction pipelines. | ||
* | ||
* @author Luca Rossetto. | ||
* @version 1.0.0 | ||
*/ | ||
data class InMemoryMeshContent(override val content: Model3D) : Model3DContent |
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 |
---|---|---|
@@ -1,5 +1,7 @@ | ||
plugins { | ||
id 'maven-publish' | ||
id 'org.jetbrains.kotlin.plugin.serialization' version "$version_kotlin" | ||
id 'signing' | ||
} | ||
|
||
project.ext.lwjglVersion = "3.3.3" | ||
|
@@ -75,4 +77,75 @@ dependencies { | |
runtimeOnly "org.lwjgl:lwjgl-stb::$lwjglNatives" | ||
if (lwjglNatives == "natives-macos" || lwjglNatives == "natives-macos-arm64") runtimeOnly "org.lwjgl:lwjgl-vulkan::$lwjglNatives" | ||
|
||
} | ||
|
||
dependencies { | ||
api project(':vitrivr-engine-core') | ||
} | ||
|
||
/* Publication of vitrivr engine query to Maven Central. */ | ||
publishing { | ||
publications { | ||
mavenJava(MavenPublication) { | ||
groupId = 'org.vitrivr' | ||
artifactId = 'vitrivr-engine-plugin-m3d' | ||
version = System.getenv().getOrDefault("MAVEN_PUBLICATION_VERSION", version.toString()) | ||
from components.java | ||
pom { | ||
name = 'vitrivr Engine Base' | ||
description = 'Shared based components of the vitrivr multimedia retrieval engine (e.g., database connection, features).' | ||
url = 'https://github.com/vitrivr/vitrivr-engine/' | ||
licenses { | ||
license { | ||
name = 'MIT License' | ||
} | ||
} | ||
developers { | ||
developer { | ||
id = 'ppanopticon' | ||
name = 'Ralph Gasser' | ||
email = '[email protected]' | ||
} | ||
developer { | ||
id = 'lucaro' | ||
name = 'Luca Rossetto' | ||
email = '[email protected]' | ||
} | ||
developer { | ||
id = 'net-cscience-raphael' | ||
name = 'Raphael Waltensül' | ||
email = '[email protected]' | ||
} | ||
developer { | ||
id = 'rahelarnold98' | ||
name = 'Rahel Arnold' | ||
email = '[email protected]' | ||
} | ||
developer { | ||
id = 'faberf' | ||
name = 'Fynn Faber' | ||
email = '[email protected]' | ||
} | ||
} | ||
scm { | ||
connection = 'scm:git:https://github.com/vitrivr/vitrivr-engine.git' | ||
url = 'https://github.com/vitrivr/vitrivr-engine/' | ||
} | ||
} | ||
} | ||
} | ||
repositories { | ||
repositories { | ||
maven { | ||
def releasesRepoUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' | ||
def snapshotsRepoUrl = 'https://oss.sonatype.org/content/repositories/snapshots/' | ||
name = "OSSRH" | ||
url = version.endsWith('SNAPSHOT') ? snapshotsRepoUrl : releasesRepoUrl | ||
credentials { | ||
username = System.getenv("MAVEN_USERNAME") | ||
password = System.getenv("MAVEN_PASSWORD") | ||
} | ||
} | ||
} | ||
} | ||
} |
80 changes: 80 additions & 0 deletions
80
vitrivr-engine-plugin-m3d/src/main/kotlin/org/vitrivr/engine/model3d/decoder/MeshDecoder.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,80 @@ | ||
package org.vitrivr.engine.model3d.decoder | ||
|
||
import io.github.oshai.kotlinlogging.KLogger | ||
import io.github.oshai.kotlinlogging.KotlinLogging | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.flow.Flow | ||
import kotlinx.coroutines.flow.filter | ||
import kotlinx.coroutines.flow.mapNotNull | ||
import org.vitrivr.engine.core.context.IndexContext | ||
import org.vitrivr.engine.core.model.content.decorators.SourcedContent | ||
import org.vitrivr.engine.core.model.content.element.Model3DContent | ||
import org.vitrivr.engine.core.operators.ingest.Decoder | ||
import org.vitrivr.engine.core.operators.ingest.DecoderFactory | ||
import org.vitrivr.engine.core.operators.ingest.Enumerator | ||
import org.vitrivr.engine.core.source.MediaType | ||
import org.vitrivr.engine.core.source.Source | ||
import org.vitrivr.engine.model3d.ModelHandler | ||
import java.io.IOException | ||
|
||
/** | ||
* A [Decoder] that can decode [MeshDecoder] from a [Source] of [MediaType.OBJ] or [MediaType.GLTF]. | ||
* | ||
* @author Rahel Arnold | ||
* @version 1.0.0 | ||
*/ | ||
class MeshDecoder : DecoderFactory { | ||
|
||
/** | ||
* Creates a new [Decoder] instance from this [Model3DDecoder]. | ||
* | ||
* @param input The input [Enumerator]. | ||
* @param context The [IndexContext] to use. | ||
* @param parameters Optional set of parameters. | ||
*/ | ||
override fun newOperator(input: Enumerator, context: IndexContext, parameters: Map<String, String>): Decoder = | ||
Instance(input, context) | ||
|
||
/** | ||
* The [Decoder] returned by this [MeshDecoder]. | ||
*/ | ||
private class Instance(override val input: Enumerator, private val context: IndexContext) : Decoder { | ||
|
||
/** [KLogger] instance. */ | ||
private val logger: KLogger = KotlinLogging.logger {} | ||
|
||
/** | ||
* Converts this [MeshDecoder] to a [Flow] of [Content] elements. | ||
* | ||
* Produces [MeshDecoder] elements. | ||
* | ||
* @param scope The [CoroutineScope] used for conversion. | ||
* @return [Flow] of [Content] | ||
*/ | ||
override fun toFlow(scope: CoroutineScope): Flow<Model3DContent> = this.input.toFlow(scope).filter { | ||
it.type == MediaType.MESH | ||
}.mapNotNull { source -> | ||
logger.info { "Decoding source ${source.name} (${source.sourceId})" } | ||
try { | ||
val handler = ModelHandler() | ||
val model = source.newInputStream().use { | ||
this.context.contentFactory.newMeshContent(handler.loadModel(source.sourceId.toString(), source.name.substringAfterLast("."))) | ||
} | ||
MeshDecoderWithSource(model, source) | ||
} catch (e: IOException) { | ||
logger.error(e) { "Failed to decode 3D model from $source due to an IO exception." } | ||
null | ||
} | ||
} | ||
|
||
|
||
/** | ||
* An internal class that represents a single 3D model associated with a [Source]. | ||
* | ||
* @see MeshDecoder | ||
* @see SourcedContent | ||
*/ | ||
class MeshDecoderWithSource(model: Model3DContent, override val source: Source) : | ||
Model3DContent by model, SourcedContent | ||
} | ||
} |