Blog written in code

Posted by Crazy Star on Jan. 23, 2018, 3:56 p.m.

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

Comments

Alert Games 1 year, 8 months ago

Insanity

Crazy Star 1 year, 7 months ago

Craziness :D

samuraikill 1 year, 7 months ago

That's really trippy :D Cool looking too.

Copyright 2019 64Digits.