/**
 * Private internal method
 * 
 * Calculates the hit for a single spot of the sensor on a single Point.
 * 
 */
void GroundSensor::hitSingle(int x, int y, const QPointF &hitPoint, smReal weight)
{
    smReal hitValue = 0;
    QPointF sensorPosition = realWorldPosition(x,y);
    QLineF distance(hitPoint,sensorPosition);
    smReal weightedDistance = weight * smMath::normalCurve(distance.length());
    
    int pos = matrixPosition(x,y);
    matrix[pos] += scaleHit(weightedDistance);
    
    if (matrix[pos] > maxVal)
        matrix[pos] = maxVal;
}
/**
 * Draws a rappresentation of the sensor with the painter
 */
void GroundSensor::draw(QPainter& p)
{
    p.save();
    p.setPen(Qt::transparent);
    QColor color = QColor(255,255,255,255);
    color.setHsl(0,0,255);
    //color.setAlphaF(0.2);
    smReal pointDimX = paddingX/5;
    smReal pointDimY = paddingY/5;
    
    for (int x=0; x<cols; x++) {
        for (int y=0; y<rows; y++) {
            smReal weight = matrix[matrixPosition(x,y)];
            color.setHsv(0,weight,255);
            p.setBrush(color);
            QPointF center = realWorldPosition(x,y);
            p.drawEllipse(center,pointDimX,pointDimY);
        }
    }
    
    p.restore();
}
Beispiel #3
0
void Star::updateForCamera(const Camera* camera)
{
	m_v3f_pos_VS = matrixPosition(camera->getZeroViewMatrix() * glm::mat4(camera->getInvPosMatrix() * m_position->getMatrix()));
}