Example #1
0
void Camera::move(float elapsedMsecs)
{
    // Quit if the camera is not moving in any direction
    if(!_movementFlags)
        return;

    const bool front= _movementFlags & (1 << Front);
    const bool right= _movementFlags & (1 << Right);
    const bool back = _movementFlags & (1 << Back );
    const bool left = _movementFlags & (1 << Left );

    const QVector3D lookDir= lookVector();

    // For left/right sidestep, rotate the XZ projection of lookDir
    QVector3D sideStep(0, 0, 0);
    if(right xor left) {
        QTransform transform;
        transform.rotate(90.0f * (right-left));
        const QPointF rotated= transform.map(QPointF(lookDir.x(), lookDir.z()));
        sideStep= QVector3D(rotated.x(), 0, rotated.y()).normalized();
    }
    const QVector3D moveDir= ((front-back) * lookDir + sideStep).normalized();

    _position += elapsedMsecs/1e6d * _moveSpeed * moveDir;

    updateViewMatrix();
}
Example #2
0
void QedGroupControl::step(QmcTime::Packet *packet)
{
    double stepPosition = QedApp::timevalToSeconds(packet->position);

    console->post(QedApp::DebugProtocol,
	"GroupControl::step: stepping to time %.2f, delta=%.2f, state=%s",
	stepPosition, my.realDelta, timeState());

    if ((packet->source == QmcTime::ArchiveSource &&
	((packet->state == QmcTime::ForwardState &&
		my.timeState != ForwardState) ||
	 (packet->state == QmcTime::BackwardState &&
		my.timeState != BackwardState))) ||
	 sideStep(stepPosition, my.realPosition, my.realDelta))
	return adjustWorldView(packet, false);

    my.pmtimeState = packet->state;
    my.position = packet->position;
    my.realPosition = stepPosition;

    adjustStep(packet);
    fetch();

    if (isActive(packet))
	newButtonState(packet->state, packet->mode, isRecording(packet));
}
Example #3
0
//
// Fetch all metric values across all gadgets, and also update the
// unified time axis.
//
void
GroupControl::step(QmcTime::Packet *packet)
{
    double stepPosition = __pmtimevalToReal(&packet->position);

    console->post(PmChart::DebugProtocol,
	"GroupControl::step: stepping to time %.2f, delta=%.2f, state=%s",
	stepPosition, my.realDelta, timeState());

    if ((packet->source == QmcTime::ArchiveSource &&
	((packet->state == QmcTime::ForwardState &&
		my.timeState != ForwardState) ||
	 (packet->state == QmcTime::BackwardState &&
		my.timeState != BackwardState))) ||
	 sideStep(stepPosition, my.realPosition, my.realDelta))
	return adjustWorldView(packet, false);

    my.pmtimeState = packet->state;
    my.position = packet->position;
    my.realPosition = stepPosition;

    int last = my.samples - 1;
    if (packet->state == QmcTime::ForwardState) { // left-to-right (all but 1st)
	if (my.samples > 1)
	    memmove(&my.timeData[1], &my.timeData[0], sizeof(double) * last);
	my.timeData[0] = my.realPosition;
    }
    else if (packet->state == QmcTime::BackwardState) { // right-to-left
	if (my.samples > 1)
	    memmove(&my.timeData[0], &my.timeData[1], sizeof(double) * last);
	my.timeData[last] = my.realPosition - torange(my.delta, last);
    }

    fetch();

    bool active = isActive(packet);
    if (isActive(packet))
	newButtonState(packet->state, packet->mode, pmchart->isTabRecording());
    refreshGadgets(active);
}