本文整理汇总了C++中PV3D::getX方法的典型用法代码示例。如果您正苦于以下问题:C++ PV3D::getX方法的具体用法?C++ PV3D::getX怎么用?C++ PV3D::getX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PV3D
的用法示例。
在下文中一共展示了PV3D::getX方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: choqueCoche
void choqueCoche(){
PV3D* pCoche = escena->coche->mt->getPos();
for (int i = 0; i < escena->numFarolas; i++){
Farola* f = escena->farolas[i];
PV3D* pFarola = f->mt->getPos();
if((abs(pCoche->getX()-pFarola->getX()) < 6) &&
(abs(pCoche->getZ()-pFarola->getZ()) < 3) &&
!f->caida){
f->mt->rota(90,0,0,1);
f->caida = true;
if(i == escena->numFarolas/2)
glDisable(GL_LIGHT1);
}
}
for (int i = 0; i < escena->numTrees; i++){
Tree* t = escena->trees[i];
PV3D* pTree = t->mt->getPos();
if((abs(pCoche->getX()-pTree->getX()) < 6)
&& (abs(pCoche->getZ()-pTree->getZ()) < 3) &&
!t->caido){
t->mt->rota(90,0,0,1);
t->caido = true;
}
}
// if(abs(pCoche->getX()) > escena->escenaSize/2
// || (abs(pCoche->getZ()) > escena->escenaSize/2)){
// escena->coche->mt->traslada(new PV3D(0,0,0,1));
// cam->setLookAt(new PV3D(5,5,5,1), escena->coche->mt->getPos());
// glutPostRedisplay();
// }
}
示例2: matrizNBTC
Matr Matr::matrizNBTC(float t){
//Calcular los valores c, c' y c''
PV3D aux = PV3D();
PV3D* c = aux.calculaValorFormula(t);
PV3D* cc = aux.calculaValorPrimDerivada(t);
PV3D* ccc = aux.calculaValorSegDerivada(t);
//Calcular T, B y N
PV3D* T = aux.calculaT(cc);
PV3D* B = aux.calculaB(cc, ccc);
PV3D* N = aux.calculaN();
//Recorro por columnas
float data[alto][ancho];
data[0][0] = N->getX();
data[1][0] = N->getY();
data[2][0] = N->getZ();
data[3][0] = 0;
data[0][1] = B->getX();
data[1][1] = B->getY();
data[2][1] = B->getZ();
data[3][1] = 0;
data[0][2] = T->getX();
data[1][2] = T->getY();
data[2][2] = T->getZ();
data[3][2] = 0;
data[0][3] = c->getX();
data[1][3] = c->getY();
data[2][3] = c->getZ();
data[3][3] = 1;
return Matr(data);
}
示例3: calculoVectorNormalPorNewell
PV3D* Malla::calculoVectorNormalPorNewell(Cara C){
PV3D* n = new PV3D(0, 0, 0, 0);
for (int i = 0; i < C.getNumeroVertices(); i++){
PV3D* vertActual = vertice[C.getIndiceVertice(i)];
PV3D* vertSiguiente = vertice[C.getIndiceVertice((i + 1) % C.getNumeroVertices())];
n->setX(n->getX() + ((vertActual->getY() - vertSiguiente->getY())*(vertActual->getZ() + vertSiguiente->getZ())));
n->setY(n->getY() + ((vertActual->getZ() - vertSiguiente->getZ())*(vertActual->getX() + vertSiguiente->getX()))); // Z * X
n->setZ(n->getZ() + ((vertActual->getX() - vertSiguiente->getX())*(vertActual->getY() + vertSiguiente->getY()))); // X * Y
}
return n->normaliza();
}
示例4: vectorNormalNewell
PV3D* Malla::vectorNormalNewell(Cara* c){
PV3D* n = new PV3D();
for(int i=0; i<c->getNumVertices(); i++){
PV3D* vertActual = vertice[c->getIndiceVerticeK(i)];
PV3D* vertSig = vertice[c->getIndiceVerticeK((i+1) % c->getNumVertices())];
n->setX(n->getX() + ((vertActual->getY() - vertSig->getY()) * (vertActual->getZ() + vertSig->getZ())));
n->setY(n->getY() + ((vertActual->getZ() - vertSig->getZ()) * (vertActual->getX() + vertSig->getX())));
n->setZ(n->getZ() + ((vertActual->getX() - vertSig->getX()) * (vertActual->getY() + vertSig->getY())));
}
return n->normaliza();
}
示例5: vNormal
void MontanaRusa::crearMalla4(){
//INICIAR MALLA
//Tama�os de los arrays
numVertices = nQ*nPuntosPerfil;
numCaras = (nQ - 1)*(nPuntosPerfil); // (nQ-1)= num de rodajas
numNormales = numCaras; //una normal por cara
//Creaci�n de los arrays
vertice = new PV3D*[numVertices];
normal = new PV3D*[numNormales];
cara = new Cara*[numCaras];
//CREAR VERTICES
//transformar: perfil => cortes
GLfloat t = 0;
GLfloat inc = (2)*PI / (nQ - 1);
for (int i = 0; i < nQ; i++){//numero de cortes
PV3D* n = vNormal(i*inc); //t = i*inc
PV3D* b = vBinormal(i*inc);
PV3D* tg = vTangente(i*inc);
for (int j = 0; j < nPuntosPerfil; j++){//recorrer perfil i
GLfloat x = n->getX()*perfil[j]->getX() + b->getX()*perfil[j]->getY() + tg->getX()*perfil[j]->getZ() + curva(t)->getX();
GLfloat y = n->getY()*perfil[j]->getX() + b->getY()*perfil[j]->getY() + tg->getY()*perfil[j]->getZ() + curva(t)->getY();
GLfloat z = n->getZ()*perfil[j]->getX() + b->getZ()*perfil[j]->getY() + tg->getZ()*perfil[j]->getZ() + curva(t)->getZ();
vertice[i* nPuntosPerfil + j] = new PV3D(x, y, z, 1);//vertice j del perfil i
}
t += inc;
}
//CREAR CARAS Y NORMALES
int indiceCara = 0;
for (int i = 0; i<nQ - 1; i++){ //unir el perfil i-�simo con el (i+1)%n-�simo
for (int j = 0; j<nPuntosPerfil; j++) { //esquina inferior-izquierda de una cara
int indice = i*nPuntosPerfil + j; //vertice j del perfil i
VerticeNormal** vn = new VerticeNormal*[4];
vn[0] = new VerticeNormal(indice, indiceCara);
vn[1] = new VerticeNormal((indice + nPuntosPerfil) % numVertices, indiceCara);
vn[2] = new VerticeNormal((indice + 1 + nPuntosPerfil) % numVertices, indiceCara);
vn[3] = new VerticeNormal(indice + 1, indiceCara);
cara[indiceCara] = new Cara(4, vn);
PV3D* n = calculoVectorNormalPorNewell(cara[indiceCara]); //Newell
normal[indiceCara] = n;
indiceCara++;
} //for
} //for
}
示例6: buildSceneObjects
void buildSceneObjects() {
//Cámara
PV3D* eye = new PV3D(eyeX, eyeY, eyeZ, 1);
PV3D* look = new PV3D(lookX, lookY, lookZ, 0);
PV3D* up = new PV3D(upX, upY, upZ, 0);
cam = new Camara(eye, look, up, xRight, xLeft, yTop, yBot,N,F);
escena = new Escena(200.0);
carDir = NONE;
angleDoor = 0;
//Farola light position
PV3D* pFarola = escena->farolas[escena->numFarolas/2]->mt->getPos();
p1[0] = pFarola->getX(); p1[1] = pFarola->getY()+15; p1[2] = pFarola->getZ(); p1[3] = 1.0;
//Car Lights Position
PV3D* luz1 = escena->coche->faro1->mt->getPos();
p2[0] = luz1->getX()-1;p2[1] = luz1->getY(); p2[2]= luz1->getZ(); p2[3]= 1.0;
PV3D* luz2 = escena->coche->faro2->mt->getPos();
p3[0] = luz2->getX()-1;p3[1] = luz2->getY(); p3[2]= luz2->getZ(); p3[3]= 1.0;
dir2[0] = -1.0; dir2[1] = 0.0; dir2[2] = 0.0;
cam->setLookAt(new PV3D(0,0,0,0), escena->coche->mt->getPos());
}
示例7: Cubo
Tablero::Tablero(int largo, int alto, int ancho)
{
_largo = largo;
_alto = alto;
_ancho = ancho;
_numCubos = _largo * _alto * _ancho;
for (int i = 0; i < _numCubos; i++) {
this->addObjeto(new Cubo());
hijos[i]->color->setColor(0.2, 0.2, 0.2);
}
//comienza pintando al principio de la carretara
PV3D* p = new PV3D(_largo / 2, 0, 1, 1);
int numCubo = 0;
for (int x = 0; x < _largo; x++) {
for (int y = 0; y < _alto; y++) {
for (int z = 0; z < _ancho; z++) {
hijos[numCubo]->mt->traslada(p);
p->setZ(p->getZ()+1);
numCubo++;
}
p->setZ(p->getZ()-_ancho);
if(_alto > 1)
p->setY(p->getY()+1);
}
if(_alto > 1)
p->setY(p->getY()-_alto);
p->setX(p->getX()-1);
}
}
示例8: buildSceneObjects
void buildSceneObjects() {
//objects
mr = new MontanaRusa(1,15,90);
mr1 = new MontanaRusa(0.95,15, 90);
PV3D * p = mr->curva(0);
PV3D * v = mr->vTangente(0);
PV3D * n = mr->vNormal(0);
// Camera parameters
GLdouble eyeX = p->getX(), eyeY = p->getY(), eyeZ = p->getZ();//eyeX=100.0, eyeY=100.0, eyeZ=100.0;
GLdouble lookX = eyeX + v->getX(), lookY = eyeY + v->getY(), lookZ = eyeZ + v->getZ();
GLdouble upX= n->getX(), upY = n->getY(), upZ = n->getZ();//0, upY=1, upZ=0;
cam = new Camara(new PV3D(eyeX, eyeY, eyeZ, 1), new PV3D(lookX, lookY, lookZ, 1), new PV3D(upX, upY, upZ, 0));//lookAt & projection
}
示例9: calculoNormalNewell
PV3D* Malla::calculoNormalNewell(Cara* c){
GLdouble nx = 0.0;
GLdouble ny = 0.0;
GLdouble nz = 0.0;
PV3D* verticeActual = NULL;
PV3D* verticeSig = NULL;
int nV = c->getNumVertices();
for(int i = 0; i < nV;i++){
verticeActual = vertices[c->getIndice(i)->get_indiceVertice()];
verticeSig = vertices[c->getIndice((i+1)%nV)->get_indiceVertice()];
nx += (verticeActual->getY()-verticeSig->getY())*(verticeActual->getZ()+verticeSig->getZ());
ny += (verticeActual->getZ()-verticeSig->getZ())*(verticeActual->getX()+verticeSig->getX());
nz += (verticeActual->getX()-verticeSig->getX())*(verticeActual->getY()+verticeSig->getY());
}
PV3D* n = new PV3D(nx,ny,nz,0);
n->normalizar();
return n;
}
示例10: modifCam
void modifCam() {
//GLdouble eyeX = 100.0, eyeY = 100.0, eyeZ = 100.0;
//GLdouble lookX = 0.0, lookY = 0.0, lookZ = 0.0;
//GLdouble upX = 0, upY = 1, upZ = 0;
PV3D * p = mr->curva(t);
PV3D * v = mr->vTangente(t);
PV3D * n = mr->vNormal(t);
// Camera parameters
GLdouble eyeX = p->getX(), eyeY = p->getY(), eyeZ = p->getZ();//eyeX=100.0, eyeY=100.0, eyeZ=100.0;
GLdouble lookX = eyeX + v->getX(), lookY = eyeY + v->getY(), lookZ = eyeZ + v->getZ();
GLdouble upX = n->getX(), upY = n->getY(), upZ = n->getZ();//0, upY = 1, upZ = 0;
cout << "Camara ---------------------------------------------" << t << endl;
cout << "\teye: " << eyeX << " " << eyeY << " " << eyeZ << endl;
cam->setEyeLookUp(new PV3D(eyeX, eyeY, eyeZ, 1), new PV3D(lookX, lookY, lookZ, 1), new PV3D(upX, upY, upZ, 0));
}
示例11: dibujaCoche
void MontanaRusa::dibujaCoche(){
GLfloat movimiento = coche->getMovimiento();
PV3D* T = primeraDerivada(movimiento);
T->normaliza();
PV3D* B = primeraDerivada(movimiento)->productoVectorial(segundaDerivada(movimiento));
B->normaliza();
PV3D* N = B->productoVectorial(T);
PV3D* C = funcion(movimiento);
GLfloat m[] = { N->getX(), N->getY(), N->getZ(), N->isPoint(),
B->getX(), B->getY(), B->getZ(), B->isPoint(),
T->getX(), T->getY(), T->getZ(), T->isPoint(),
C->getX(), C->getY(), C->getZ(), C->isPoint()};
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glMultMatrixf(m);
coche->dibuja();
glPopMatrix();
}
示例12: prodVect
PV3D Matr::prodVect(PV3D vect){
float vectArray[4] = {vect.getX(), vect.getY(), vect.getZ(), vect.getPV()};
float vectResult[4];
for(int i=0; i<ancho; i++){
vectResult[i] = 0.0;
for (int k=0; k<alto; k++){
vectResult[i] += this->data[i][k] * vectArray[k];
}
}
return PV3D(vectResult[0], vectResult[1], vectResult[2], vectResult[3]);
}
示例13: dibuja
void Malla::dibuja(){
if (this->rotateAngleX != 0 || this->rotateAngleY != 0 || this->rotateAngleZ != 0){
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glRotatef(this->rotateAngleX, 1, 0, 0);
glRotatef(this->rotateAngleY, 0, 1, 0);
glRotatef(this->rotateAngleZ, 0, 0, 1);
}
for (int i = 0; i<numCaras; i++) {
glLineWidth(1.0);
glColor3f(cara[i]->getRed(), cara[i]->getGreen(), cara[i]->getBlue());
if (this->displayModel == 1){
glBegin(GL_POLYGON);
}
else if(this->displayModel == 0){
glBegin(GL_LINE_LOOP);
}
for (int j = 0; j < cara[i]->getNumeroVertices(); j++) {
int iN = cara[i]->getIndiceNormal(j);
int iV = cara[i]->getIndiceVertice(j);
glNormal3f(normal[iN]->getX(), normal[iN]->getY(), normal[iN]->getZ());
//Si hubiera coordenadas de textura, aquí se suministrarían
//las coordenadas de textura del vértice j con glTexCoor2f(…);
glVertex3f(vertice[iV]->getX(), vertice[iV]->getY(), vertice[iV]->getZ());
}
glEnd();
if (this->showN){
PV3D* centro = getCentroDeCara(*cara[i]);
glBegin(GL_LINES);
glColor3f(1.0 - cara[i]->getRed(), 1.0 - cara[i]->getGreen(), 1.0 - cara[i]->getBlue());
glVertex3f(centro->getX(), centro->getY(), centro->getZ());
glVertex3f(centro->getX() + normal[cara[i]->getIndiceNormal(0)]->getX(),
centro->getY() + normal[cara[i]->getIndiceNormal(0)]->getY(),
centro->getZ() + normal[cara[i]->getIndiceNormal(0)]->getZ());
glEnd();
}
}
if (this->rotateAngleX != 0 || this->rotateAngleY != 0 || this->rotateAngleZ != 0){
glPopMatrix();
}
}
示例14: key
//.........这里部分代码省略.........
case '4': //Lateral
camera.lateral();
break;
case '5': //Frontal
camera.frontal();
break;
case '6': //Cenital
camera.cenital();
break;
case '7': //Esquina
camera.esquina();
break;
case 'o': //Ortogonal
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(xLeft, xRight, yBot, yTop, N, F);
break;
case 'p': //Perspectiva
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45, 1, N, F);
break;
case 'l': //Oblicua
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
d.normaliza();
if(d.getZ() != 0.0 && (d.getX() != 0 || d.getY() != 0 || d.getZ() != 1)){
GLfloat m[16] = {
1, 0, 0, 0,
0, 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
};
m[8] = -(d.getX()) / d.getZ();
m[9] = -(d.getY()) / d.getZ();
m[12] = -N * (d.getX() / d.getZ());
m[13] = -N * (d.getY() / d.getZ());
glOrtho(xLeft, xRight, yBot, yTop, N, F);
glMultMatrixf(m);
}
break;
case 'y': //Trasladar escena
escena->traslacionEscena(1, 0, 0);
break;
case 'h':
escena->traslacionEscena(-1, 0, 0);
break;
case 'g': //Escalacion escena
escena->escalacionEscena(1, 2, 1);
break;
case 'b':
escena->escalacionEscena(1, 0.5, 1);
break;
case '8': //Rotacion escena
escena->rotacionEscena(2,0,1,0);