How to use
In this section we're focused on how you can make the plugin working, and how to make rigid bodies on the scene.
Last updated
In this section we're focused on how you can make the plugin working, and how to make rigid bodies on the scene.
Last updated
Before you can use the plugin you must do the following steps (we assume you already have a working ApertusVR on your computer, if you do not, check out our guide here).
If ApertusVR is ready to use, make sure that the bullet library is installed through ApertusVR's cmake system. For this the APE_PLUGINS_BulletPhysics variable's checkbox must be checked in before generating, as you can see on the picture below:
If you watch the cmake gui carefully, you may notice that there's also two variable related to physics: APE_PLUGIN_PhysicsSimulationScene, and APE_SAMPLES_PhysicsSimulation. If you want to examine the samples, you need this two variable checked in too. Else you can try it in your own sample, after made one. To learn about making a sample, please read the following guide:
At this point we assume, that Bullet is deployed within ApertusVR, and you have a working sample. The next milestone is to get Bullet plugin usable in your sample. To reach this level of magnificence, please follow these five steps:
Open your sample's config folder at: \ApertusVR\samples\MySample.
Open the folder's of the config you attend to use with bullet plugin (\ApertusVR\samples\MySample\config\myconfig).
Open the CMakeLists.txt file you find in the folder and add the apeBulletPhysicsPlugin.json to set
property, and save it.
Open the apeCore.json file in the same folder, and add the "apeBulletPhysicsPlugin"
in the "plugins"
attribute, and save it.
Open CMake gui, and click on the Generate button.
Now if everything is in order, you have a working sample with the Bullet plugin attached to it. For the most cases, when using ApertusVR we are designing our scene in a plugin too (sometimes with help of the SceneMakerMacro). Therefore we need a plugin to put our scene in it. If you aren't familiar with creating plugins for ApertusVR, please check this short guide, to became a professional plugin maker.
Hopefully when you've reached these lines, you have a sample with BulletPhysicsPlugin, and you also attached a plugin wich will contain the scene elements. Hence we can start to discuss how to use plugin on your scene. For this part, we presume that you're experienced with nodes and geometries in ApertusVR. If this isn't right, you can always check the related parts of the documentation:
The entity what is used by BulletPhysicsPlugin is somewhat similar to these two. ApertusVR has an entity called RIGIDBODY
, which is responsible for positioning and orienting our geometry's node according to the laws of physics. We will discuss more detail about the RIGIDBODY
entity in the Features section, for now it's enough that we know, it exists.
The following code sample shows, how you can create RIGIDBODY
for a specific geometry, wich in that case is a box (GEOMETRY_BOX
).
Let's get through what we've done here. We made a node called boxNode
, and immediately made a box geometry too. With this two entity, we have every necessary objects to make our rigid body. You can create it anyway, but it's not a big surprise that rigid bodies are only working properly if these two are attached to it.
After reading this, you must be capable of making rigid bodies for primitve objects. However we don't always want to play only with boxes and spheres, or cones, do we? So now we'll move onto creating something more interesting than that.
For this cause we have an other plugin called apeAssimpAssetLoaderPlugin. This plugin provides support for wide range of mesh files, i.e. .gltf, .obj, or .stl. What is more great about this is that you can configure it easily by a json file, just like you do it with the other plugins. Thus you have a neat way for attaching rigid bodies to your geometry. You can inclue the Assimp plugin on the same way as the other plugins, so we assume that it doesn't make a big deal to handle it. Once you have Assimp in your sample, you can add the rigid body in the json file. The next code sample shows you, how to do it.
As you see, it couldn't be more simple, just set a "physics"
property, and you're done with it. However you may noticed some other properties within the physics property. Those aren't necessary for creating the body, but we'll discuss them later in the Features section. Sometimes it occours that the user only wants a geometry without any physics properties attached to it. In that case just simply don't set any "physics"
property in the asset's config, and then Bullet doesn't get any request for making body for you.
This is the end of the section about using the plugin, now you must be capable of making rigid bodies and attach it to your scene, even if it's a complex mesh geometry. We can move onto the next level: configuring the BulletPhysics plugin.