Giter Site home page Giter Site logo

alrikg / jme3-bullet-vhacd Goto Github PK

View Code? Open in Web Editor NEW

This project forked from riccardobl/jme3-bullet-vhacd

0.0 0.0 0.0 26 KB

This is a library that uses java bindings for Khaled Mamou's V-HACD to decompose concave meshes into hull-shapes in jmonkey engine.

Home Page: https://jmonkeystore.com/b23bd74f-e315-4c3b-b66c-b090d9232356

License: Other

Java 92.58% Shell 7.42%

jme3-bullet-vhacd's Introduction

JME3 V-HACD Collision Shape Factory

This is a library that uses java bindings for Khaled Mamou's V-HACD to decompose concave meshes into hull-shapes in jmonkey engine.

Requirements

java 1.7+

Installation

Gradle

plugins {
    id "io.github.0ffz.github-packages" version "1.2.1"
}

repositories {
    mavenCentral()
    maven githubPackage.invoke("riccardobl")
}

dependencies {
    compile 'wf.frk:jme3-bullet-vhacd:1.0.5'
}

This library relies on vhacd native bindings whose build is currently available for 64 and 32 bit versions of Linux and Windows and for osx.

Usage

VHACDParameters p=new VHACDParameters();
// p.set.....

VHACDCollisionShapeFactory factory=new VHACDCollisionShapeFactory(p);		
CompoundCollisionShape cs=factory.create(Spatial);

The resulting CollisionShape can be used and serialized as a usual. See TestSimple.java and TestFunny.java for the full example.


The process of building collision shapes could be quite slow, to overcome this you can use one of the following approaches

Pregeneration and serialization

The generated shape is a common CompoundCollisionShape made of HullCollisionShapes this means it can be saved and loaded with jmonkeyengine.

This method has a further benefit: the shape can be generated by the developer and then loaded withing a project that doesn't need to include this library. This comes quite handy when you are targeting platforms that are not supported by this library.

Caching

The library can also do transparent caching.

To do this, you just need to add an implementation of Caching to the VHACDCollisionShapeFactory with

((VHACDCollisionShapeFactory)factory).cachingQueue().add(Caching)

Multiple Caching systems can be added to the queue, when one fails to provide the cache, the next one is used.

There are few built-in Caching implementations:

VolatileByMeshCaching

This provides a minimal in-memory caching based on mesh objects.

With this, when you call VHACDCollisionShapeFactory.create on a mesh or spatial for which the collision shape has already been generated with the same parameters, a cached version may be returned.

The shapes leave the cache when their original mesh has been GCed or when the application is restarted.

((VHACDCollisionShapeFactory)factory).cachingQueue().add(new VolatileByMeshCaching());

PersistentByBuffersCaching

This is a more advanced system that provides persistent caching on memory and disk, based on the content of the the original mesh.

It must be create by passing the path of the cache folder to the constructor

PersistentByBuffersCaching caching=new PersistentByBuffersCaching("app/cache/");
((VHACDCollisionShapeFactory)factory).cachingQueue().add(caching);

(The / will be automatically replaced with the File.separator)

You can optionally set an indicative maximum ammount of memory that can be used for the in-memory caching with:

caching.setMaxMemoryInMB(10);

By default the limit is 32MB. A negative number means unlimited and 0 means "no in-memory cache (= cache provided always from the disk)".

The cache will be swapped from disk to memory automatically and will be kept across executions, installations and can also be shipped with the software.

License

Everything in this repo, as well as V-HACD and V-HACD-bindings, is released under BSD 3-clause license.

jme3-bullet-vhacd's People

Contributors

riccardobl avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.