Ejemplo n.º 1
0
void PerspectiveCamera::mouseDragged(CameraScratch &scratch, QMouseEvent *event)
{
    int xDiff = scratch.pickX - event->pos().x();
    int yDiff = scratch.pickY - event->pos().y();

    if (scratch.moveType == MoveType::ROTATING) {
        Vector3 origLook = eye() + lookDir();
        setYRot(yRot() + xDiff * 0.5f);
        setUpRot(upRot() + yDiff * -0.5f);

        // move eye to look at original focal point (Maya style)
        Vector3 lookAway = lookDir() * -1;
        setCenter(origLook + lookAway);
    }
    else if (scratch.moveType == MoveType::PANNING) {
        float panScale = 0.05f;

        Vector3 mUp = scratch.origUp * -1.0f * yDiff * panScale;
        Vector3 mLeft = scratch.origLeft * -1.0f * xDiff * panScale;

        setCenter(eye() + mUp + mLeft);
    } else if (scratch.moveType == MoveType::TRUCKING) {
        Point3 at = lookat();
        Vector3 l = lookDir() * -0.01f * yDiff;

        setCenter(l + center());
    }

    scratch.pickX = event->pos().x();
    scratch.pickY = event->pos().y();
}
Ejemplo n.º 2
0
void LLCoordFrame::lookAt(const LLVector3 &origin, const LLVector3 &point_of_interest, const LLVector3 &up_direction)
{
	setOrigin(origin);
	LLVector3 at(point_of_interest - origin);
	at.normVec();
	lookDir(at, up_direction);
}
Ejemplo n.º 3
0
void LLCoordFrame::lookAt(const LLVector3 &origin, const LLVector3 &point_of_interest)
{
	static LLVector3 up_direction(0.0f, 0.0f, 1.0f);

	setOrigin(origin);
	LLVector3 at(point_of_interest - origin);
	at.normVec();
	lookDir(at, up_direction);
}
Ejemplo n.º 4
0
LLCoordFrame::LLCoordFrame(const LLVector3 &origin, const LLVector3 &direction) :
	mOrigin(origin)
{
	lookDir(direction);
	
	if( !isFinite() )
	{
		reset();
		llwarns << "Non Finite in LLCoordFrame::LLCoordFrame()" << llendl;
	}
}
Ejemplo n.º 5
0
PerspectiveCamera::PerspectiveCamera() : Camera()
{
    resetLook();
    _center = Point3(4.0,2.0,4.0);
    _yRot = 225;
    _upRot = 45;
    _distance = _center.length();
    updateLook();
    _center = -lookDir();
    //updateLook();
    //moveType = MoveType::NOT_MOVING;
}
Ejemplo n.º 6
0
void SpotLight::prepare(Scene* scene)
{
#if 0
    /*
    Attribute castShadows = attributeByName("Casts Shadows");
    if (castShadows && castShadows->property("value").isValid()) {

    }
    */
    //Attribute position = ;
    //position.property("value").toFloat();
    QVector3D position = getBoundValue<QVector3D>(this, attributeByName("Position"));
    QVector3D lookat = position + lookDir();
    float coneAngle = PI * attributeByName("Cone Angle")->property("value").value<float>() / 180.0f;
    RtFloat intensity = attributeByName("Intensity")->property("value").value<float>();
    RtPoint from = { position.x(), position.y(), position.z() };
    RtPoint to = { lookat.x(), lookat.y(), lookat.z() };
    QColor color = attributeByName("Color")->property("value").value<QColor>();
    RtColor c = { color.redF(), color.greenF(), color.blueF() };

    bool castsShadow = attributeByName("Casts Shadows")->property("value").value<bool>();

    if (castsShadow)
    {
        QString shadowPath = QString(getenv("AQSIS_TEXTURE_PATH")).split(":")[0] + "/" + scene->assetName(this) + ".shd";
        char cShadowPath[1000];

        strcpy(cShadowPath, shadowPath.toStdString().c_str());

        char *shadowPaths[]= { cShadowPath, RI_NULL };
    //    float shadowBias = attributeByName("Shadow Bias")->property("value").value<float>();

//RiOption("shadow", "bias", (RtPointer)&shadowBias, RI_NULL);

  //      std::cout << "shadow bias: " << shadowBias << std::endl;
        RiDeclare("shadowname", "uniform string");
        RiLightSource("shadowspot", "from", from, "to", to, "intensity", &intensity, "coneangle", &coneAngle, "lightcolor", &c, "shadowname", shadowPaths, RI_NULL);
    }
    else
        RiLightSource("spotlight", "from", from, "to", to, "intensity", &intensity, "coneangle", &coneAngle, "lightcolor", &c, RI_NULL);

    //LightSource "shadowspot" 1 "intensity" 50 "from" [1 5 0] "to" [0 0 0]
    //                              "shadowname" ["spot1.tx"]
#endif
}
Ejemplo n.º 7
0
void LLCoordFrame::lookDir(const LLVector3 &xuv)
{
	static LLVector3 up_direction(0.0f, 0.0f, 1.0f);
	lookDir(xuv, up_direction);
}