Ejemplo n.º 1
0
 //  Runs once per render loop; where we provide input to shaders
 void AssignShaderInputs ()
   { Vect viewloc = Feld () -> Camera () -> ViewLoc ();
     SetShaderUniform ("fog_radius", GLOBE_RADIUS);
     SetShaderUniform ("system_distance", Loc () . DistFrom (viewloc));
     SetShaderUniform ("feld_size", Diag (Feld ()));
     SetShaderUniform ("camera_position", viewloc);
   }
Ejemplo n.º 2
0
 void Blurt (BlurtEvent *e)
   { int64 translation_amount = 40;
     if (Utters (e, "w"))
       { IncTranslation (translation_amount * 2.0 * Feld () -> Norm ()); }
     else if (Utters (e, "s"))
       { IncTranslation (-translation_amount * 2.0 * Feld () -> Norm ()); }
   }
Ejemplo n.º 3
0
 void PointingMove (PointingEvent *e)
   { //  Drag the object
     if (IsHeeding (e))
       { IncRotation (WrangleRay (Feld () -> Up ()),
                      IntersectionDiff (e, Loc ()) . x / 200);
         IncRotation (WrangleRay (Feld () -> Over ()),
                      - IntersectionDiff (e, Loc ()) . y / 200);
       }
   }
    void DrawSelf ()
    {   // draw line
        SetGLColor (Color (1, 1, 1));
        glLineWidth(2.0);
        glBegin (GL_LINES);
        glVertex (Vect (0, 0, 0));
        glVertex (vertex);
        glEnd ();

        // draw bar (DrawQuad draws from the bottom left corner)
        DrawQuad (Vect (-Feld () -> Width () / 2, Feld () -> Height () / 2 - h, 0), Vect (m, 0, 0), Vect (0, h, 0));
    }
Ejemplo n.º 5
0
  void UpdateLabel (PointingEvent *e, Str text, Vect loc)
    { //  We want one label per event source (mouse pointer,
      //  wiimote, etc.)  Ensure this source has a label.
      Text *label = labels . Get (e -> Provenance ());
      if (! label)
        { label = new Text ("");
          label -> SetObliviousness (true);
          label -> SetFontSize (Feld () -> Width () / 100.0);
          labels . Put (e -> Provenance (), label);
        }

      label -> SetString (text);
      label -> SetTranslation (loc
                                + ((2.0 + label -> Width () / 2.0)
                                   * Feld () -> Over ())
                                + 10.0 * Feld () -> Norm ());
    }
Ejemplo n.º 6
0
void Setup ()
{   Brain *brain = new Brain ("data/brain.txt");
    brain -> LoadShaders ("shaders/brain.vert", "shaders/brain.frag");
    Vect center = brain -> Center ();
    brain -> SetTranslation (Feld () -> Loc () -
                             Vect(center.x, center.y, 1000.0));
    brain -> RotationAnimateSine (center + Vect (0, 1, 0), 180.0, 10.0);
}
 Mover ()  :  Sketch ()
 { width = 8.0;
   velocity = Vect (0, 0, 0);
   top_speed = 3.0;
   
   // store feld dimenions and orientation
   SpaceFeld *f = Feld ();
   loc = f -> Loc ();
   over = f -> Over ();
   up = f -> Up ();
   norm = f -> Norm ();
   wid = f -> Width ();
   hei = f -> Height ();
   
   SlapOnFeld ();
   
   // draw
   SetStroked (false);
   SetFillColor (Color (1, 1, 1));
   DrawEllipse (Vect (0, 0, 0), width, width);
 }
Ejemplo n.º 8
0
 void FingerMove (PointingEvent *e)
   { IncRotation (WrangleRay (Feld () -> Up ()),
                  (e -> PhysOrigin () . x - e -> PrevOrigin () . x) / 250);
     IncRotation (WrangleRay (Feld () -> Over ()),
                  -(e -> PhysOrigin () . y - e -> PrevOrigin () . y) / 250);
   }