3DCoat Core API
The 3DCoat API documentation.
Loading...
Searching...
No Matches
coat::SphericalCollision Class Reference

The class intended to place spheres in space and identify if there are spheres around. It is important for random objects generating and avoiding self-intersection of objects. More...

#include <CoreAPI.h>

Public Member Functions

 SphericalCollision (float cellsize)
 create the collision space
 
void setUnit (float u)
 set the cell size, the cell space should be empty
 
void clear ()
 remove all spheres
 
int addSphere (const vec3 &p, float radius)
 add the sphere into the space
 
vec3 collides (const vec3 &p, float radius)
 check if sphere intersects other spheres in the space
 
vec4 sphere (int idx)
 get the sphere parameters by index
 

Detailed Description

The class intended to place spheres in space and identify if there are spheres around. It is important for random objects generating and avoiding self-intersection of objects.

Examples
TreesGenerator.cpp.

Constructor & Destructor Documentation

◆ SphericalCollision()

coat::SphericalCollision::SphericalCollision ( float cellsize)

create the collision space

Parameters
cellsizethe cell size that should be approximately around the average sphere size

Member Function Documentation

◆ addSphere()

int coat::SphericalCollision::addSphere ( const vec3 & p,
float radius )

add the sphere into the space

Parameters
pthe position
radiusthe radius
Returns
the sphere index, you may refer it later using the spher(index) function
Examples
TreesGenerator.cpp.

◆ collides()

vec3 coat::SphericalCollision::collides ( const vec3 & p,
float radius )

check if sphere intersects other spheres in the space

Parameters
pposition
radiusradius
Returns
the repelling force, it is zero if no collision happened.
Examples
TreesGenerator.cpp.

◆ setUnit()

void coat::SphericalCollision::setUnit ( float u)

set the cell size, the cell space should be empty

Parameters
uthe cell size that should be approximately around the average sphere size

◆ sphere()

vec4 coat::SphericalCollision::sphere ( int idx)

get the sphere parameters by index

Parameters
idxthe sphere index (previously returned by addSphere)
Returns
the position (xyz) and radius (w) as vec4

The documentation for this class was generated from the following file: