Add test fractal usage to main
This commit is contained in:
parent
513c306555
commit
1b7c7f0b54
86
src/main.cpp
86
src/main.cpp
@ -1,5 +1,11 @@
|
|||||||
|
#include <cmath>
|
||||||
|
|
||||||
#include <tonc.h>
|
#include <tonc.h>
|
||||||
#include <mtl/log.hpp>
|
#include <mtl/log.hpp>
|
||||||
|
#include <etl/vector.h>
|
||||||
|
#include <mtl/exception.hpp>
|
||||||
|
|
||||||
|
#include "fractal.hpp"
|
||||||
|
|
||||||
using namespace mtl;
|
using namespace mtl;
|
||||||
|
|
||||||
@ -8,6 +14,86 @@ int main(void) {
|
|||||||
|
|
||||||
log::debug << "Hello world!" << mtl::endl;
|
log::debug << "Hello world!" << mtl::endl;
|
||||||
|
|
||||||
|
fractal::generator_t gen;
|
||||||
|
|
||||||
|
try {
|
||||||
|
fractal::token_id_t walk_petal_length = gen.add_token(fractal::token_type_e::walk, 8);
|
||||||
|
fractal::token_id_t walk_petal_side = gen.add_token(fractal::token_type_e::walk, 4);
|
||||||
|
|
||||||
|
fractal::token_id_t rotate_axiom = gen.add_token(fractal::token_type_e::rotate, M_PI_2);
|
||||||
|
fractal::token_id_t rotate_petal = gen.add_token(fractal::token_type_e::rotate, M_PI_2);
|
||||||
|
fractal::token_id_t rotate_branchr = gen.add_token(fractal::token_type_e::rotate, -M_PI_4);
|
||||||
|
fractal::token_id_t rotate_branchl = gen.add_token(fractal::token_type_e::rotate, +M_PI_4);
|
||||||
|
|
||||||
|
fractal::token_id_t generate_seed = gen.add_token(fractal::token_type_e::generate);
|
||||||
|
fractal::token_id_t generate_petal = gen.add_token(fractal::token_type_e::generate);
|
||||||
|
fractal::token_id_t generate_branchr = gen.add_token(fractal::token_type_e::generate);
|
||||||
|
fractal::token_id_t generate_branchl = gen.add_token(fractal::token_type_e::generate);
|
||||||
|
fractal::token_id_t generate_mark = gen.add_token(fractal::token_type_e::generate);
|
||||||
|
|
||||||
|
log::info << "Added tokens" << endl;
|
||||||
|
|
||||||
|
constexpr uint32_t axiom_factor = 4;
|
||||||
|
constexpr uint32_t branchr_factor = 1;
|
||||||
|
constexpr uint32_t branchl_factor = 1;
|
||||||
|
|
||||||
|
etl::vector axiom_characteristic{generate_seed, rotate_axiom};
|
||||||
|
fractal::group_id_t group_axiom = gen.add_group_characteristic(axiom_factor, axiom_characteristic);
|
||||||
|
|
||||||
|
etl::vector seed_characteristic{generate_petal, generate_branchl, generate_branchr};
|
||||||
|
fractal::group_id_t group_seed = gen.add_group_characteristic(seed_characteristic);
|
||||||
|
|
||||||
|
etl::vector petal_characteristic{generate_mark, walk_petal_length, generate_mark, rotate_petal, walk_petal_side, generate_mark};
|
||||||
|
fractal::group_id_t group_petal = gen.add_group_characteristic(petal_characteristic);
|
||||||
|
|
||||||
|
etl::vector branchl_characteristic{rotate_branchl, generate_seed};
|
||||||
|
fractal::group_id_t group_branchl = gen.add_group_characteristic(branchl_factor, branchl_characteristic);
|
||||||
|
|
||||||
|
etl::vector branchr_characteristic{rotate_branchr, generate_seed};
|
||||||
|
fractal::group_id_t group_branchr = gen.add_group_characteristic(branchr_factor, branchr_characteristic);
|
||||||
|
|
||||||
|
log::info << "Added group characteristics" << endl;
|
||||||
|
|
||||||
|
etl::vector<etl::pair<fractal::group_id_t, uint32_t>, 1> axiom_weights{{group_axiom, 1}};
|
||||||
|
fractal::weighted_group_id_t wgroup_axiom = gen.add_weighted_group(axiom_weights);
|
||||||
|
|
||||||
|
fractal::weighted_group_id_t wgroup_seed = gen.add_weighted_group(group_seed);
|
||||||
|
fractal::weighted_group_id_t wgroup_petal = gen.add_weighted_group(group_petal);
|
||||||
|
fractal::weighted_group_id_t wgroup_branchl = gen.add_weighted_group(group_branchl);
|
||||||
|
fractal::weighted_group_id_t wgroup_branchr = gen.add_weighted_group(group_branchr);
|
||||||
|
|
||||||
|
log::info << "Added weighted groups" << endl;
|
||||||
|
|
||||||
|
gen.add_basic_branch_rule(generate_seed, wgroup_seed);
|
||||||
|
gen.add_basic_branch_rule(generate_petal, wgroup_petal);
|
||||||
|
gen.add_basic_branch_rule(generate_branchl, wgroup_branchl);
|
||||||
|
gen.add_basic_branch_rule(generate_branchr, wgroup_branchr);
|
||||||
|
gen.add_marking_branch_rule(generate_mark, 1);
|
||||||
|
|
||||||
|
log::info << "Added branch rules" << endl;
|
||||||
|
|
||||||
|
gen.set_axiom(wgroup_axiom);
|
||||||
|
|
||||||
|
log::info << "Successfully added generator values" << endl;
|
||||||
|
} catch(const mtl::exception&) {
|
||||||
|
log::info << "Failed to create generator, caught exception" << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*gen.preprocess();
|
||||||
|
|
||||||
|
constexpr uint32_t num_generations = 3;
|
||||||
|
constexpr size_t max_markers = 128;
|
||||||
|
|
||||||
|
etl::vector<fractal::marker_t, max_markers> markers;
|
||||||
|
for (size_t i = 0; i < num_generations; ++i) {
|
||||||
|
markers.clear();
|
||||||
|
|
||||||
|
gen.step_generation(markers);
|
||||||
|
|
||||||
|
//draw_triangles(markers);
|
||||||
|
}*/
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
vid_vsync();
|
vid_vsync();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user