/vofxel

:zap: Voxel model loader and editor for JavaFX

Primary LanguageJavaGNU General Public License v3.0GPL-3.0

Vo(fx)el

Vofxel is a Java library for loading, displaying and editing PLY files exported from MagicaVoxel into JavaFX, blazingly fast.

Installation

Maven

<repositories>
  <repository>
    <id>jitpack.io</id>
    <url>https://jitpack.io</url>
  </repository>
</repositories>
<dependency>
  <groupId>com.github.iAmGio</groupId>
  <artifactId>vofxel</artifactId>
  <version>v0.0.2</version>
</dependency>

Gradle

allprojects {
  repositories {
    maven { url 'https://jitpack.io' }
  }
}
dependencies {
  implementation 'com.github.iAmGio:vofxel:v0.0.2'
}

Getting started

Load model from file:

VoxelModel model = new VoxelModel();
root.getChildren().add(model);
model.load(getClass().getResourceAsStream("/file.ply"));

Note that the file must be exported using the cube mode from MagicaVoxel (or any other tool that supports this export mode):
Export

Create model from scratch:

VoxelModel model = new VoxelModel();
root.getChildren().add(model);
Cube cube1 = model.addCube();
cube1.setMaterial(new PhongMaterial(Color.RED));
cube1.moveZ(-10);
Cube cube2 = model.addCube();
cube2.setMaterial(new PhongMaterial(Color.BLUE));
cube2.moveX(-10);

Demo

A simple demonstration can be found here.

Result