Example #1
0
    void paint (Graphics& g) override
    {
        // (Our component is opaque, so we must completely fill the background with a solid colour)
        g.fillAll (Colours::black);

        g.setColour (Colours::white);
        const int fishLength = 15;

        Path spinePath;

        for (int i = 0; i < fishLength; ++i)
        {
            const float radius = 100 + 10 * std::sin (getFrameCounter() * 0.1f + i * 0.5f);

            Point<float> p (getWidth()  / 2.0f + 1.5f * radius * std::sin (getFrameCounter() * 0.02f + i * 0.12f),
                            getHeight() / 2.0f + 1.0f * radius * std::cos (getFrameCounter() * 0.04f + i * 0.12f));

            // draw the circles along the fish
            g.fillEllipse (p.x - i, p.y - i, 2.0f + 2.0f * i, 2.0f + 2.0f * i);

            if (i == 0)
                spinePath.startNewSubPath (p);  // if this is the first point, start a new path..
            else
                spinePath.lineTo (p);           // ...otherwise add the next point
        }

        // draw an outline around the path that we have created
        g.strokePath (spinePath, PathStrokeType (4.0f));
    }
Example #2
0
    Matrix3D<float> getViewMatrix() const
    {
        Matrix3D<float> viewMatrix (Vector3D<float> (0.0f, 0.0f, -10.0f));
        Matrix3D<float> rotationMatrix
            = viewMatrix.rotated (Vector3D<float> (-0.3f, 5.0f * std::sin (getFrameCounter() * 0.01f), 0.0f));

        return rotationMatrix * viewMatrix;
    }
Example #3
0
    Matrix3D<float> getViewMatrix() const
    {
        // The viewMatrix will be used to modify the vertex coordinates in order
        // to transform object coordinates as viewed-by-camera (or eye) coordinates.
        // Standard x,y,z values are used. Obviously the z value used here will have
        // to be in the range near side < z < far side as defined by the frustum used
        // in the projection matrix (see getProjectionMatrix() above).
        Matrix3D<float> viewMatrix (Vector3D<float> (0.0f, 0.0f, -50.0f));
        
        // The rotation matrix will be applied on each frame.
        // The vector passed here contains the Euler angle values for each axis
        // The empiric values used as params will create a slight but constant tilting
        // on the x-axis, a periodic rotation on the y-axis and no rotation on the
        // z-axis.
        Matrix3D<float> rotationMatrix
            = createRotationMatrix (Vector3D<float> (-0.3f, 5.0f * std::sin (getFrameCounter() * 0.01f), 0.0f));

        return rotationMatrix * viewMatrix;
    }
Example #4
0
void EventsManager::waitForNextFrame() {
    _mouseClicked = false;
    _mouseReleased = false;
    _mouseButtons = 0;

    bool mouseClicked = false;
    bool mouseReleased = false;
    int mouseButtons = 0;

    uint32 frameCtr = getFrameCounter();
    while (!_vm->shouldQuit() && frameCtr == _frameCounter) {
        delay(1);

        mouseClicked |= _mouseClicked;
        mouseReleased |= _mouseReleased;
        mouseButtons |= _mouseButtons;
    }

    _mouseClicked = mouseClicked;
    _mouseReleased = mouseReleased;
    _mouseButtons = mouseButtons;
    _mouseMoved |= _mouseClicked || _mouseReleased;
}