Voxvision  1
Creating and manipulating voxel octrees
Functions
cd.h File Reference

Collision detection. More...

#include "renderer.h"

Go to the source code of this file.

Functions

VOX_EXPORT struct vox_cdvox_make_cd ()
 Create collision detector. More...
 
VOX_EXPORT void vox_cd_attach_camera (struct vox_cd *cd, struct vox_camera *camera, float radius)
 Attach a camera to collision detector. More...
 
VOX_EXPORT void vox_cd_attach_context (struct vox_cd *cd, struct vox_rnd_ctx *ctx)
 Attach a renderer context to collision detector. More...
 
VOX_EXPORT void vox_cd_collide (struct vox_cd *cd)
 Perform collision detection. More...
 
VOX_EXPORT void vox_cd_gravity (struct vox_cd *cd, const vox_dot gravity)
 Add gravity to the world. More...
 

Detailed Description

Collision detection.

Function Documentation

◆ vox_cd_attach_camera()

VOX_EXPORT void vox_cd_attach_camera ( struct vox_cd cd,
struct vox_camera camera,
float  radius 
)

Attach a camera to collision detector.

A camera currently has a spherical body with supplied radius.

◆ vox_cd_attach_context()

VOX_EXPORT void vox_cd_attach_context ( struct vox_cd cd,
struct vox_rnd_ctx ctx 
)

Attach a renderer context to collision detector.

A whole scene contained in context will be tested for collisions.

◆ vox_cd_collide()

VOX_EXPORT void vox_cd_collide ( struct vox_cd cd)

Perform collision detection.

If any object which can move (currently, only the camera) collides with any another object, it will be moved to the last valid location.

◆ vox_cd_gravity()

VOX_EXPORT void vox_cd_gravity ( struct vox_cd cd,
const vox_dot  gravity 
)

Add gravity to the world.

Parameters
cda collision detection instance
gravitya gravity vector.

Each time vox_cd_collide() is called, all movable objects will be moved towards direction specified by gravity vector until they hit a hard ground.

Gravity vector of {0,0,0} turns off gravity.

◆ vox_make_cd()

VOX_EXPORT struct vox_cd* vox_make_cd ( )

Create collision detector.

You also need to attach objects (currently, camera and context as a whole scene) to collision detector to make it work.