本文整理汇总了C++中STVector3类的典型用法代码示例。如果您正苦于以下问题:C++ STVector3类的具体用法?C++ STVector3怎么用?C++ STVector3使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了STVector3类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetUpAndRight
void SetUpAndRight()
{
mRight = STVector3::Cross(mLookAt - mPosition, mUp);
mRight.Normalize();
mUp = STVector3::Cross(mRight, mLookAt - mPosition);
mUp.Normalize();
}
示例2: resetUp
void resetUp()
{
mUp = STVector3(0.f,1.f,0.f);
mRight = STVector3::Cross(mLookAt - mPosition, mUp);
mRight.Normalize();
mUp = STVector3::Cross(mRight, mLookAt - mPosition);
mUp.Normalize();
}
示例3: randomAngle
bool circleEmitter::addParticle(){
particle *newParticle;
float speed;
//Particle pool exists and max num particles not exceeded
if(e != NULL && *managerParticleList != NULL && e->particleCount < e->totalParticles && emitting){
newParticle = *managerParticleList;
*managerParticleList = (*managerParticleList)->next;
if(e->particleList != NULL){
e->particleList->prev = newParticle;
}
newParticle->next = e->particleList;
newParticle->prev = NULL;
e->particleList = newParticle;
float angle = randomAngle();
float radScalar = randDist();
newParticle->rand = radScalar;
newParticle->radius = radius * radScalar;
STVector3 point = STVector3(radius*radScalar*cosf(angle), 0, radius*radScalar*sinf(angle));
STVector3 straightUp = STVector3(0,1,0);
STVector3 circleDir = STVector3(e->dir.x, e->dir.y, e->dir.z);
STVector3 a = STVector3::Cross(straightUp, circleDir);
float w = sqrt(powf(straightUp.Length(), 2) * powf(circleDir.Length(), 2)) + STVector3::Dot(straightUp, circleDir);
Quaternion rotateCircle = Quaternion(w, a.x, a.y, a.z);
rotateCircle.Normalize();
STVector3 rotatedPoint = rotateCircle.rotate(point, rotateCircle);
newParticle->pos.x = rotatedPoint.x + e->pos.x;
newParticle->pos.y = rotatedPoint.y + e->pos.y;
newParticle->pos.z = rotatedPoint.z + e->pos.z;
/*
newParticle->pos.x = e->pos.x + radius*sinf(angle);
newParticle->pos.y = e->pos.y;
newParticle->pos.z = e->pos.z + radius*cosf(angle);
*/
newParticle->prevPos.x = 0;
newParticle->prevPos.y = 0;
newParticle->prevPos.z = 0;
newParticle->dir = e->dir + (e->dirVar*randDist());
speed = e->speed + (e->speed * randDist());
newParticle->dir.x *= speed;
newParticle->dir.y *= speed;
newParticle->dir.z *= speed;
newParticle->life = e->life + (int)((float)e->lifeVar * randDist());
newParticle->side = randDist();
e->particleCount++;
return true;
}
return false;
}
示例4: fmax
STColor3f DirectionalLight::sumTerm(Intersection inter, Material *material, Ray *viewingRay){
STVector3 incomingLight = -*direction;
incomingLight.Normalize();
STVector3 normal = inter.normal;
STVector3 view = -viewingRay->direction;
STColor3f diffuse = material->diff * (*color) * fmax(0.0, STVector3::Dot(incomingLight, normal));
STColor3f specular = material->spec * (*color) * pow(fmax(0, STVector3::Dot(view, Utils::reflectVector(normal, incomingLight))), material->shine);
return diffuse + specular;
}
示例5: distance
STVector3 distance(STVector3 A, STVector3 B, const STVector3 P, double *t)
{
STVector3 AB = B - A;
double ab_square = AB.Dot(AB, AB);
STVector3 AP = P - A;
double ap_dot_ab = AP.Dot(AP, AB);
*t = ap_dot_ab / ab_square;
STVector3 Q;
Q = A + AB * (*t);
return Q;
}
示例6: ZoomCamera
void ZoomCamera(float delta_y)
{
STVector3 direction = mLookAt - mPosition;
float magnitude = direction.Length();
direction.Normalize();
float zoom_rate = 0.1f*magnitude < 0.5f ? .1f*magnitude : .5f;
if(delta_y * zoom_rate + magnitude > 0)
{
mPosition += (delta_y * zoom_rate) * direction;
}
}
示例7: STMatrix4
/**Populates qMatrixes based on the planes surrounding each vertex
in the mesh m - Ankit*/
void QuadricErrorSimplification::generateQMatrices(STTriangleMesh* mesh){
STVector3 i, j, k;
STVector3 n;
float d = 0;
float area = 0;
STFace* f;
STVertex* vert;
for (size_t v = 0; v < mesh->mVertices.size(); ++v)
{
qMatrixes.push_back(new STMatrix4());
}
for (size_t v = 0; v < mesh->mVertices.size(); ++v)
{
//memset(m_vertices[v].m_Q, 0, 10 * sizeof(Float));
vert = mesh->mVertices[v];
//find all the faces that contain this vertex
for (size_t itT = 0; itT < mesh->mFaces.size(); ++itT)
{
f = mesh->mFaces[itT];
if (vertexEquals(f->v[0], vert) || vertexEquals(f->v[1], vert) || vertexEquals(f->v[2], vert)){
i = vertex2Vector3(f->v[0]);
j = vertex2Vector3(f->v[1]);
k = vertex2Vector3(f->v[2]);
n = STVector3::Cross(j - i, k - i);
area = n.Length();
n.Normalize();
d = -(STVector3::Dot(vertex2Vector3(mesh->mVertices[v]), n));
qMatrixes[v]->table[0][0] += area * (n.x * n.x);
qMatrixes[v]->table[0][1] += area * (n.x * n.y);
qMatrixes[v]->table[0][2] += area * (n.x * n.z);
qMatrixes[v]->table[0][3] += area * (n.x * d);
qMatrixes[v]->table[1][0] += area * (n.y * n.x);
qMatrixes[v]->table[1][1] += area * (n.y * n.y);
qMatrixes[v]->table[1][2] += area * (n.y * n.z);
qMatrixes[v]->table[1][3] += area * (n.y * d);
qMatrixes[v]->table[2][0] += area * (n.z * n.x);
qMatrixes[v]->table[2][1] += area * (n.z * n.y);
qMatrixes[v]->table[2][2] += area * (n.z * n.z);
qMatrixes[v]->table[2][3] += area * (n.z * d);
qMatrixes[v]->table[3][0] += area * (d * n.x);
qMatrixes[v]->table[3][1] += area * (d * n.y);
qMatrixes[v]->table[3][2] += area * (d * n.z);
qMatrixes[v]->table[3][3] += area * (d * d);
}
}
}
}
示例8: createOrthonormalBasis
void Camera::createOrthonormalBasis(const STPoint3& eye, const STVector3& up, const STPoint3& lookAt)
{
position = eye;
// Create orthonormal basis
STVector3 a = lookAt - eye;
STVector3 b = up;
a.Normalize();
w = a;
u = STVector3::Cross(b, w);
u.Normalize();
v = STVector3::Cross(w, u);
}
示例9: DrawManipulator
void DrawManipulator(void)
{
// color
RGBR_f colorRed(1, 0, 0, 1);
RGBR_f colorGreen(0, 1, 0, 1);
RGBR_f colorBlue(0, 0, 1, 1);
RGBR_f colorWhite(1,1,1,1);
RGBR_f colorMagenta(1.0f,0.3f,1.0f, 1.0f);
RGBR_f colorGrey(0.2f,0.2f,0.2f, 1.0f);
// a, y and z axis
STVector3 xaxis = STVector3::eX;
STVector3 yaxis = STVector3::eY;
STVector3 zaxis = STVector3::eZ;
// camera basis
STVector3 up = pScene->GetCamera()->Up();
STVector3 right = pScene->GetCamera()->Right();
STVector3 dir = pScene->GetCamera()->LookAt();
STVector3 front;
front = front.Cross(right, xaxis);
front.Normalize();
// camera plane
float colx[4] = {1, 0, 0, 1};
float coly[4] = {0, 1, 0, 1};
float colz[4] = {0, 0, 1, 1};
float colall[4] = {1, 1, 1, 1};
float fct = 0.05f;
float fct2 = 0.83f;
STMatrix4 curModelMatrix;
curModelMatrix.EncodeI();
//------------------------------------------------------------------------------
// TO DO: Proj3_4 OpenGL
// Update the matrix transformation for the manipulator geometry
// Update curModelMatrix
//------------------------------------------------------------------------------
curModelMatrix.EncodeS(0.1, 0.1, 0.1);
//-------------------------------------------------------------------------------
// screen projection
ViewProjectionScreenSpace(curModelMatrix);
STVector3 origin(0,0,0);
curModelMatrix.GetT(&origin.x, &origin.y, &origin.z);
if(pScene->CurrentManipMode() == LOCAL) {
xaxis.Transform(curModelMatrix);
yaxis.Transform(curModelMatrix);
zaxis.Transform(curModelMatrix);
xaxis.Normalize();
yaxis.Normalize();
zaxis.Normalize();
}
// Rotations
if((pScene->CurrentManipGeometryState() == AXIS_ALL) ||
(pScene->CurrentManipGeometryState() == AXIS_ROTATIONALL)) {
STVector3 X_UP;
STVector3 X_RIGHT;
STVector3 X_FRONT;
STVector3 X_UP_sc;
STVector3 X_RIGHT_sc;
STVector3 X_FRONT_sc;
STVector3 planenorm(pScene->GetCamera()->Position() - origin);
planenorm.Normalize();
STVector4 camplane = vector4(planenorm,0);
// duplicate
X_RIGHT = right * ScreenFactor();
X_UP = up * ScreenFactor();
if(pScene->CurrentManipMotion() == ROTATE_DUPLICATE)
DrawCircle(origin, colorWhite, X_RIGHT, X_UP);
else
DrawCircle(origin, colorGrey, X_RIGHT, X_UP);
// screen rot
X_UP_sc = up * 1.2f * ScreenFactor();
X_RIGHT_sc = right * 1.2f * ScreenFactor();
if(pScene->CurrentManipMotion() == ROTATE_SCREEN)
DrawCircle(origin, colorWhite, X_UP_sc, X_RIGHT_sc);
else
DrawCircle(origin, colorMagenta, X_UP_sc, X_RIGHT_sc);
// x rot
right.Cross(dir, xaxis);
right.Normalize();
front.Cross(right, xaxis);
front.Normalize();
//.........这里部分代码省略.........
示例10: CalcNormal
STVector3 Sphere::CalcNormal(STVector3 surface_pt, Ray unused){
STVector3 v = surface_pt - center;
v.Normalize();
return v;
}