Exemplo n.º 1
0
 void draw(const Matrix4& transformation, SceneGraph::Camera3D& camera) override {
     _shader.setDiffuseColor(_color)
         .setTransformationMatrix(transformation*_primitiveTransformation)
         .setProjectionMatrix(camera.projectionMatrix())
         .setNormalMatrix(transformation.rotationScaling());
     _mesh.draw(_shader);
 }
Exemplo n.º 2
0
void Icosphere::draw(const Matrix4& transformationMatrix, SceneGraph::Camera3D& camera) {
    shader->setDiffuseColor(color)
        .setSpecularColor(Color3(1.0f))
        .setShininess(20)
        .setLightPosition({3.0f, -3.0f, 3.0f})
        .setTransformationMatrix(transformationMatrix)
        .setNormalMatrix(transformationMatrix.rotationScaling())
        .setProjectionMatrix(camera.projectionMatrix());

    mesh->draw(*shader);
}
Exemplo n.º 3
0
void CubeDrawable::draw(const Matrix4& transformationMatrix, SceneGraph::Camera3D& camera) {
    _shader.setDiffuseColor(_color)
        .setSpecularColor(Color3(1.0f))
        .setShininess(20)
        .setLightPosition(camera.cameraMatrix().transformPoint({3.0f, 3.0f, 3.0f}))
        .setTransformationMatrix(transformationMatrix)
        .setNormalMatrix(transformationMatrix.rotationScaling())
        .setProjectionMatrix(camera.projectionMatrix());

    _mesh.draw(_shader);
}
Exemplo n.º 4
0
void Reflector::draw(const Matrix4& transformationMatrix, SceneGraph::Camera3D& camera) {
    _shader->setTransformationMatrix(transformationMatrix)
        .setNormalMatrix(transformationMatrix.rotationScaling())
        .setProjectionMatrix(camera.projectionMatrix())
        .setReflectivity(2.0f)
        .setDiffuseColor(Color3(0.3f))
        .setCameraMatrix(static_cast<Object3D&>(camera.object()).absoluteTransformation().rotationScaling())
        .setTexture(*_texture)
        .setTarnishTexture(*_tarnishTexture);

    _sphere->draw(*_shader);
}
Exemplo n.º 5
0
void BulletExample::drawEvent() {
    GL::defaultFramebuffer.clear(GL::FramebufferClear::Color|GL::FramebufferClear::Depth);

    /* Housekeeping: remove any objects which are far away from the origin */
    for(Object3D* obj = _scene.children().first(); obj; )
    {
        Object3D* next = obj->nextSibling();
        if(obj->transformation().translation().dot() > 100*100)
            delete obj;

        obj = next;
    }

    /* Step bullet simulation */
    _bWorld.stepSimulation(_timeline.previousFrameDuration(), 5);

    /* Draw the cubes */
    if(_drawCubes) _camera->draw(_drawables);

    /* Debug draw. If drawing on top of cubes, avoid flickering by setting
       depth function to <= instead of just <. */
    if(_drawDebug) {
        if(_drawCubes)
            GL::Renderer::setDepthFunction(GL::Renderer::DepthFunction::LessOrEqual);

        _debugDraw.setTransformationProjectionMatrix(
            _camera->projectionMatrix()*_camera->cameraMatrix());
        _bWorld.debugDrawWorld();

        if(_drawCubes)
            GL::Renderer::setDepthFunction(GL::Renderer::DepthFunction::Less);
    }

    swapBuffers();
    _timeline.nextFrame();
    redraw();
}
Exemplo n.º 6
0
void CubeMap::draw(const Matrix4& transformationMatrix, SceneGraph::Camera3D& camera) {
    _shader->setTransformationProjectionMatrix(camera.projectionMatrix()*transformationMatrix)
        .setTexture(*_texture);

    _cube->draw(*_shader);
}
void ShadowReceiverDrawable::draw(const Matrix4& transformationMatrix, SceneGraph::Camera3D& camera) {
    _shader->setTransformationProjectionMatrix(camera.projectionMatrix()*transformationMatrix);
    _shader->setModelMatrix(object().transformationMatrix());

    _mesh->draw(*_shader);
}