#include <CoreAPI.h>
public:
SpheresGenerator() {
numSpheres = 200;
FigureRadius = 30;
FigureRadiusVariation = 0.1;
SpheresRadius = 10;
SpheresRadiusVariation = 0.5;
}
int numSpheres;
float FigureRadius;
float FigureRadiusVariation;
float SpheresRadius;
float SpheresRadiusVariation;
SERIALIZE() {
SLIDER(numSpheres, "numSpheres", 1, 1000);
FSLIDER(FigureRadius, "FigureRadius", 1, 100, 1, false);
FSLIDER(FigureRadiusVariation, "FigureRadiusVariation", 0, 1, 100, false);
FSLIDER(SpheresRadius, "SpheresRadius", 1, 100, 1, false);
FSLIDER(SpheresRadiusVariation, "SpheresRadiusVariation", 0, 1, 100, false);
}
float random(float value, float variation) {
return value * (1.0f + variation * rand() / 32768.0f);
}
void generate() {
m.
Read(
"data/Samples/Sphere.obj");
auto volume = current.
Volume();
volume.toVoxels();
for (int i = 0; i < numSpheres; i++) {
coat::mat4 transform = coat::mat4::Scaling(random(SpheresRadius, SpheresRadiusVariation));
transform *= coat::mat4::Translation(coat::vec3::RandNormal() * random(FigureRadius, FigureRadiusVariation));
}
}
};
EXPORT
int main() {
SpheresGenerator sg;
sg.ReadFromFile("data/Temp/Spheres.json");
sg.WriteToFile("data/Temp/Spheres.json");
sg.generate();
};
return 0;
}
Use this class for build a class for UI or serialization. see class_reg.h for details about the class...
Definition BaseClass.h:91
The mesh reference.
Definition CoreAPI.h:418
bool Read(const char *name)
Load the mesh from the file.
SceneElement addChild(const char *name) const
add the child element of the same nature
static SceneElement sculptRoot()
get the root of all sculpt objects
the rich dialog. You may customize it, show your custom parameters and custom buttons.
Definition CoreAPI.h:3821
dialog & params(BaseClass *params)
The important core feature. BaseClass allows to create the custom controls in the dialog....
dialog & ok()
add Ok button
dialog & cancel()
add Cancel button
int show()
Show the dialog. This is usually the last command in the chain.
static void step(int count=1)
perform rendering cycles
static void progressBarInWindowHeader(float stage, float max_stage, const char *message)
Show the progress bar only in the 3DCoat's window header.
static void toRoom(const char *name, bool Force=false)
switch to the room
@ BOOL_ADD
boolean add
Definition CoreAPI.h:91
comms::cMat4 mat4
4x4 float matrix, see the cMat4
Definition CoreAPI.h:59