Java bindings for the GVOX voxel data library (https://github.com/GabeRundlett/gvox)
This project is not finished; The adapter api is not implemented yet It is also using preview features of the JDK that are subject to change at any time and therefore requires at least JDK 20.
- Authenticate GitHub Packages
- Add this to your pom.xml
- Add additional compiler arguments using this snippet
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.10.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgs>
<arg>--enable-preview</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
Check the gvox wiki for more detailed instructions. Here i only provide the java equivalent of the demo snippet
GvoxContext gvox_ctx = GVOX.create_context();
GvoxFileInputAdapterConfig i_config = new GvoxFileInputAdapterConfig() {{
filepath = "C:/Users/fabif/IdeaProjects/VoxelTracing/src/main/resources/models/menger.vox";
byteOffset = 0;
}};
GvoxColoredTextSerializeAdapterConfig s_config = new GvoxColoredTextSerializeAdapterConfig() {{
non_color_max_value = 255;
}};
System.out.println("Creating GVOX adapter contexts");
GvoxAdapterContext input_ctx = GVOX.create_adapter_context(gvox_ctx, Gvox.get_input_adapter(gvox_ctx, "file"), i_config);
GvoxAdapterContext output_ctx = GVOX.create_adapter_context(gvox_ctx, Gvox.get_output_adapter(gvox_ctx, "stdout"), null);
GvoxAdapterContext parse_ctx = GVOX.create_adapter_context(gvox_ctx, Gvox.get_parse_adapter(gvox_ctx, "magicavoxel"), null);
GvoxAdapterContext serialize_ctx = GVOX.create_adapter_context(gvox_ctx, Gvox.get_serialize_adapter(gvox_ctx, "colored_text"), s_config);
GvoxRegionRange range = new GvoxRegionRange(
new GvoxOffset3D(0, 0, 0),
new GvoxExtent3D(8, 8, 8)
);
System.out.println("Blitting region");
GVOX.blit_region(input_ctx, output_ctx, parse_ctx, serialize_ctx, range, List.of(
GvoxChannelBit.COLOR,
GvoxChannelBit.MATERIAL_ID,
GvoxChannelBit.ROUGHNESS,
GvoxChannelBit.TRANSPARENCY,
GvoxChannelBit.EMISSIVITY
));
System.out.println("Cleaning up");
GVOX.destroy_adapter_context(input_ctx);
GVOX.destroy_adapter_context(output_ctx);
GVOX.destroy_adapter_context(parse_ctx);
GVOX.destroy_adapter_context(serialize_ctx);
GVOX.destroy_context(gvox_ctx);
GVOX.close();