Crazy Star
Crazy Star
Posts

143

Following

66

Followers

72

Exploding infinitely

Joined on August 7, 2005, 1:09 AM Visited on May 28, 2019, 11:37 AM
Badges

Blog written in code

by Crazy Star


Posted on January 23, 2018 at 9:56 PM


I made a thing :D


void demo(
  G::LVL::Scene* scene,
  G::LVL::Model* tree,
  u8 recursion,
  G::vec3 pos, G::vec3 sca, G::vec3 spin
)
{
  tree->body.entity.origin = pos;
  tree->body.entity.volume = sca;
  tree->body.torque.velocity = spin;
  tree->body.torque.damping = 1.0f;
  if(recursion>0)
  {
    new (tree->children) G::LVL::Model[6];
    G::vec3 v[6] = {
      G::vec3(1.0f, 0.0f, 0.0f),
      G::vec3(0.0f, 1.0f, 0.0f),
      G::vec3(0.0f, 0.0f, 1.0f),
      G::vec3(-1.0f, 0.0f, 0.0f),
      G::vec3(0.0f, -1.0f, 0.0f),
      G::vec3(0.0f, 0.0f, -1.0f)
    };
    u32 b = 0;
    for( auto& it : tree->children )
    {
      init( &it, scene->memory, tree );
      add_cube( scene, &it );
      G::vec3 origin = v[b++];
      G::vec3 extend = origin;
      if(extend.x<0.0f) extend.x = -extend.x;
      if(extend.y<0.0f) extend.y = -extend.y;
      if(extend.z<0.0f) extend.z = -extend.z;
      demo(
        scene,
        &it,
        recursion-1,
        origin*1.5f,
        extend*0.1f+sca*0.5f,
        origin*0.008f
      );
    }
  }
}

Discuss <3