greenhouse
a creative coding toolkit for spatial interfaces

Thing

An object that resides in 3D space; by default, has no visible appearance.

  • Thing ()
  • SetGLColor ()
  • glVertex ()
  • DrawPoint ()
  • DrawTriangle ()
  • DrawQuad ()

Example

#include "Greenhouse.h"

class Drah  :  public  Thing
{ public:
  bool as_lines;

  Drah ()  :  Thing (), as_lines (false)
  { SlapOnFeld (); }

  void Blurt (BlurtEvent *e)
  { if (Utters (e, "l"))
      as_lines = ! as_lines;
    else if (Utters (e, "w"))
      IncRotation (WrangleRay (Feld () -> Over ()), -PI / 18);
    else if (Utters (e, "s"))
      IncRotation (WrangleRay (Feld () -> Over ()), PI / 18);
    else if (Utters (e, "a"))
      IncRotation (WrangleRay (Feld () -> Up ()), -PI / 18);
    else if (Utters (e, "d"))
      IncRotation (WrangleRay (Feld () -> Up ()), PI / 18);
  }

  void DrawSelf ()
  { SetGLColor (Color (0, 0, 1));
    DrawPoint (ZeroVect, 20.0);   // not in mm, but rasterized GL diameter
    SetGLColor (Color (1, 0, 0));
    DrawTriangle (ZeroVect, Vect (20, 0, 0), Vect (20, 20, 20), as_lines);
    SetGLColor (Color (0, 1, 0));
    DrawQuad (Vect (-10, -10, -10), Vect (-10, 0, 0), Vect (0, -10, 0),
              as_lines);

    SetGLColor (Color (1, 0, 1));
    glBegin (GL_LINE_LOOP);
    glVertex (Vect (20, 20, 20));
    glVertex (Vect (-20, 20, -10));
    glVertex (Vect (-20, -10, -10));
    glVertex (Vect (-20, -20, -10));
    glVertex (Vect (-10, -20, -10));
    glVertex (Vect (20, 0, 0));
    glEnd ();
  }
};

void Setup ()
{ Drah *d = new Drah ();
  d -> SetScale (2.0);
}