예제 #1
0
            void Renderer2D::drawListOfTriangleSets(const vector<hesperia::decorator::models::TriangleSet> &listOfTriangleSets, const hesperia::data::environment::Point3 &position, const hesperia::data::environment::Point3 &rotation) {
                vector<TriangleSet>::const_iterator it = listOfTriangleSets.begin();
                while (it != listOfTriangleSets.end()) {
                    if ((*it).m_vertices.size() > 0) {
                        setColor((*it).m_material.getDiffuse());
                        setLineWidth(1.0);

                        // Fix inside OBJ-Wavefront-Models (OBJXArchive) (rotated 90°)!
                        vector<Point3> vertices = (*it).m_vertices;
                        vector<Point3> rotatedVertices;
                        vector<Point3>::iterator jt = vertices.begin();
                        while (jt != vertices.end()) {
                            Point3 p = (*jt).rotateX(cartesian::Constants::PI/2.0);

                            p.rotateX(rotation.getX());
                            p.rotateY(rotation.getY());
                            p.rotateZ(rotation.getZ());
                            p += position;

                            rotatedVertices.push_back(p);
                            jt++;
                        }

                        drawPolyLine(rotatedVertices);
                    }
                    it++;
                }
            }
예제 #2
0
        Point3 Transformation::transformInversely(const Point3 &coordinate, const Position &position) const {
            Point3 cc = coordinate;

            // Rotate the coordinate.
            cc.rotateX(-1 * position.getRotation().getX());
            cc.rotateY(-1 * position.getRotation().getY());
            cc.rotateZ(-1 * position.getRotation().getZ());

            // Translate the coordinate.
            cc -= position.getPosition();

            return cc;
        }
예제 #3
0
            void Renderer2D::drawTriangleSet(const TriangleSet &ts, const Point3 &position, const Point3 &rotation) {
                vector<Point3> points;
                vector<Point3>::const_iterator it = ts.m_vertices.begin();
                while (it != ts.m_vertices.end()) {
                    Point3 p = (*it);
                    p.rotateX(rotation.getX());
                    p.rotateY(rotation.getY());
                    p.rotateZ(rotation.getZ());

                    p += position;

                    points.push_back(p);

                    it++;
                }

                drawPolyLine(points);
            }
예제 #4
0
void ScenarioRenderer::visitPointModel(PointModel &pointModel) {
    Lock l(m_scenarioRendererMutex);
    if (m_renderer != NULL) {
        if ( (pointModel.getLane() != NULL) && (pointModel.getLane()->getRoad() != NULL) && (pointModel.getLane()->getRoad()->getLayer() != NULL) ) {
            const vector<IDVertex3> &listOfVertices = pointModel.getListOfIdentifiableVertices();
            const uint32_t SIZE = listOfVertices.size();
            if (SIZE > 1) {
                m_renderer->beginPainting();
                for (uint32_t i = 0; i < (SIZE-1); i++) {
                    // Get to adjacent vertices, determine direction, construct orthogonal direction
                    Point3 ptA = listOfVertices.at(i);
                    ptA.setZ(pointModel.getLane()->getRoad()->getLayer()->getHeight());

                    Point3 ptB = listOfVertices.at(i+1);
                    ptB.setZ(pointModel.getLane()->getRoad()->getLayer()->getHeight());

                    // Label Waypoints.
                    stringstream namePtA;
                    namePtA << pointModel.getLane()->getRoad()->getLayer()->getID() << "." << pointModel.getLane()->getRoad()->getID() << "." << pointModel.getLane()->getID() << "." << listOfVertices.at(i).getID();
                    m_renderer->setColor(Point3(0.7, 0.7, 0.7));
                    m_renderer->drawText(ptA, namePtA.str());

                    stringstream namePtB;
                    namePtB << pointModel.getLane()->getRoad()->getLayer()->getID() << "." << pointModel.getLane()->getRoad()->getID() << "." << pointModel.getLane()->getID() << "." << listOfVertices.at(i+1).getID();
                    m_renderer->setColor(Point3(0.7, 0.7, 0.7));
                    m_renderer->drawText(ptB, namePtB.str());

                    m_renderer->setColor(Point3(1, 0, 0));
                    m_renderer->setPointWidth(5);
                    m_renderer->drawPoint(ptA);
                    m_renderer->drawPoint(ptB);

                    Point3 colorSkeleton(0.2, 0.2, 0.2);
                    m_renderer->setColor(colorSkeleton);
                    m_renderer->setLineWidth(1);
                    m_renderer->drawLine(ptA, ptB);

                    const double halfWidth = pointModel.getLaneAttribute().getWidth() / 2.0;
                    if (halfWidth > 1) {
                        Point3 orthonormalDirection = (ptB - ptA);
                        orthonormalDirection.normalizeXY();
                        orthonormalDirection.setZ(0);
                        orthonormalDirection.rotateZ(cartesian::Constants::PI/2.0);

                        Point3 colorLeftMarking;
                        switch (pointModel.getLaneAttribute().getLeftLaneMarking()) {
                        case LaneAttribute::SOLID_YELLOW:
                        case LaneAttribute::DOUBLE_YELLOW:
                            colorLeftMarking = Point3(1, 1, 0);
                            break;

                        case LaneAttribute::BROKEN_WHITE:
                        case LaneAttribute::SOLID_WHITE:
                            colorLeftMarking = Point3(1, 1, 1);
                            break;

                        case LaneAttribute::UNDEFINED:
                        case LaneAttribute::CROSSWALK:
                            colorLeftMarking = Point3(0.3, 0.3, 0.3);
                            break;
                        }
                        Point3 leftLanePtA = ptA + (orthonormalDirection * halfWidth);
                        Point3 leftLanePtB = ptB + (orthonormalDirection * halfWidth);

                        m_renderer->setColor(colorLeftMarking);
                        m_renderer->setLineWidth(5);
                        m_renderer->drawLine(leftLanePtA, leftLanePtB);

                        // Draw right lane marking.
                        Point3 colorRightMarking;
                        switch (pointModel.getLaneAttribute().getRightLaneMarking()) {
                        case LaneAttribute::SOLID_YELLOW:
                        case LaneAttribute::DOUBLE_YELLOW:
                            colorRightMarking = Point3(1, 1, 0);
                            break;

                        case LaneAttribute::BROKEN_WHITE:
                        case LaneAttribute::SOLID_WHITE:
                            colorRightMarking = Point3(1, 1, 1);
                            break;

                        case LaneAttribute::UNDEFINED:
                        case LaneAttribute::CROSSWALK:
                            colorRightMarking = Point3(0.3, 0.3, 0.3);
                            break;
                        }
                        Point3 rightLanePtA = ptA - (orthonormalDirection * halfWidth);
                        Point3 rightLanePtB = ptB - (orthonormalDirection * halfWidth);

                        m_renderer->setColor(colorRightMarking);
                        m_renderer->setLineWidth(5);
                        m_renderer->drawLine(rightLanePtA, rightLanePtB);
                    }
                }
                m_renderer->endPainting();
            }
        }
    }
}