void AbstractContent::setRotation(double angle, Qt::Axis axis) { switch (axis) { case Qt::XAxis: if (m_xRotationAngle == angle) return; m_xRotationAngle = angle; break; case Qt::YAxis: if (m_yRotationAngle == angle) return; m_yRotationAngle = angle; break; case Qt::ZAxis: if (m_zRotationAngle == angle) return; m_zRotationAngle = angle; break; } applyRotations(); }
PositionF TBFE::getCameraPosition() { PositionF cameraOffset=camera_.getOffset()*20; PositionF cameraFollowOffset=camera_.getFollowOffset()*20; Quaternion cameraAngle=camera_.getAngle(); PositionF tempAngle=(applyRotations(cameraFollowOffset,cameraAngle)+cameraOffset); tempAngle=Main_Player->getPositionF()-tempAngle; return tempAngle*-1; };
void Exercise17::paintGL() { glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT); if(m_projMode == Perspective) applyRotations(); static const float red[] = {1.0f, 0.0f, 0.0f, 1.0f}; glMaterialfv(GL_FRONT, GL_DIFFUSE, red); m_threeDObject->drawHaloedLines(m_animationFrame); glPopMatrix(); }
bool AbstractContent::fromXml(QDomElement & pe) { // restore content properties QDomElement domElement; // Load image size saved in the rect node domElement = pe.firstChildElement("rect"); qreal x, y, w, h; x = domElement.firstChildElement("x").text().toDouble(); y = domElement.firstChildElement("y").text().toDouble(); w = domElement.firstChildElement("w").text().toDouble(); h = domElement.firstChildElement("h").text().toDouble(); resizeContents(QRect(x, y, w, h)); // Load position coordinates domElement = pe.firstChildElement("pos"); x = domElement.firstChildElement("x").text().toDouble(); y = domElement.firstChildElement("y").text().toDouble(); setPos(x, y); int zvalue = pe.firstChildElement("zvalue").text().toDouble(); setZValue(zvalue); bool visible = pe.firstChildElement("visible").text().toInt(); setVisible(visible); bool hasText = pe.firstChildElement("frame-text-enabled").text().toInt(); setFrameTextEnabled(hasText); if (hasText) { QString text = pe.firstChildElement("frame-text").text(); setFrameText(text); } quint32 frameClass = pe.firstChildElement("frame-class").text().toInt(); setFrame(frameClass ? FrameFactory::createFrame(frameClass) : 0); // restore transformation QDomElement te = pe.firstChildElement("transformation"); if (!te.isNull()) { m_xRotationAngle = te.attribute("xRot").toDouble(); m_yRotationAngle = te.attribute("yRot").toDouble(); m_zRotationAngle = te.attribute("zRot").toDouble(); applyRotations(); } domElement = pe.firstChildElement("mirror"); setMirrorEnabled(domElement.attribute("state").toInt()); return true; }
void S9FbxDrawer::draw(shared_ptr<FbxDrawable> drawable) { /// Draw Normally for (vector< shared_ptr<FbxMesh> >::iterator it = drawable->meshes.begin(); it != drawable->meshes.end(); it ++) { shared_ptr<FbxMesh> pMesh = *it; glPushMatrix(); glMultMatrixf(pMesh->offset); if (pMesh->mDeform) applyRotations(pMesh); if (pMesh->indicies.size() >0 ) { int matid = -1; int *ip = (int*)&pMesh->indicies.at(0); int texid = 0; int normid = 0; for (int i =0; i < pMesh->numtris; i++) { if (pMesh->matindicies.size() > 0) { matid = pMesh->matindicies[i]; if (matid >= 0) { if (drawable->materials[matid]->isTextured) { drawable->materials[matid]->tex.bind(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); } float r = drawable->materials[matid]->colour.x; float g = drawable->materials[matid]->colour.y; float b = drawable->materials[matid]->colour.z; glColor3f(r,g,b); /// \todo Full Materials For later // glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE, pDancer->mDancer.lMaterials[matid].glMat); } } glBegin(GL_TRIANGLES); int i0 = *ip; ++ip; int i1 = *ip; ++ip; int i2 = *ip; ++ip; if (i0 < pMesh->numverts && i1 < pMesh->numverts && i2 < pMesh->numverts) { Vec3d v0 = pMesh->vertices[i0]; Vec3d v1 = pMesh->vertices[i1]; Vec3d v2 = pMesh->vertices[i2]; if (pMesh->mDeform) { v0 = pMesh->skinvertices[i0]; v1 = pMesh->skinvertices[i1]; v2 = pMesh->skinvertices[i2]; } Vec3d n0 = pMesh->normals[normid]; Vec3d n1 = pMesh->normals[normid+1]; Vec3d n2 = pMesh->normals[normid+2]; if (pMesh->mDeform) { n0 = pMesh->skinnormals[normid]; n1 = pMesh->skinnormals[normid+1]; n2 = pMesh->skinnormals[normid+2]; } normid +=3; // Texture coords do not have indicies annoyingly! Vec2d tc0 = pMesh->texcoords[texid]; Vec2d tc1 = pMesh->texcoords[++texid]; Vec2d tc2 = pMesh->texcoords[++texid]; ++texid; glTexCoord2d(tc0.x, tc0.y); glNormal3d(n0.x,n0.y,n0.z); glVertex3d(v0.x, v0.y, v0.z); glTexCoord2d(tc1.x, tc1.y); glNormal3d(n1.x,n1.y,n1.z); glVertex3d(v1.x, v1.y, v1.z); glTexCoord2d(tc2.x, tc2.y); glNormal3d(n2.x,n2.y,n2.z); glVertex3d(v2.x, v2.y, v2.z); glEnd(); if (matid >= 0) { if (drawable->materials[matid]->isTextured) drawable->materials[matid]->tex.unbind(); } } } } glPopMatrix(); } }
void S9FbxDrawer::drawNormals(shared_ptr<FbxDrawable> drawable) { for (vector< shared_ptr<FbxMesh> >::iterator it = drawable->meshes.begin(); it != drawable->meshes.end(); it ++) { shared_ptr<FbxMesh> pMesh = *it; glPushMatrix(); glMultMatrixf(pMesh->offset); if (pMesh->mDeform) applyRotations(pMesh); if (pMesh->indicies.size() >0 ) { //int matid = -1; int *ip = (int*)&pMesh->indicies.at(0); for (int i =0; i < pMesh->numtris; i ++) { glBegin(GL_LINES); glColor3f(1.0, 0, 0); int i0 = *ip; ++ip; int i1 = *ip; ++ip; int i2 = *ip; ++ip; Vec3d v0 = pMesh->vertices[i0]; Vec3d v1 = pMesh->vertices[i1]; Vec3d v2 = pMesh->vertices[i2]; if (pMesh->mDeform) { v0 = pMesh->skinvertices[i0]; v1 = pMesh->skinvertices[i1]; v2 = pMesh->skinvertices[i2]; } Vec3d n0 = pMesh->normals[i0]; Vec3d n1 = pMesh->normals[i1]; Vec3d n2 = pMesh->normals[i2]; if (pMesh->mDeform) { n0 = pMesh->skinnormals[i0]; n1 = pMesh->skinnormals[i1]; n2 = pMesh->skinnormals[i2]; } n0 += v0; n1 += v1; n2 += v2; glVertex3f(v0.x, v0.y, v0.z); glVertex3f(n0.x, n0.y, n0.z); glVertex3f(v1.x, v1.y, v1.z); glVertex3f(n1.x, n1.y, n1.z); glVertex3f(v2.x, v2.y, v2.z); glVertex3f(n2.x, n2.y, n2.z); glEnd(); } glPopMatrix(); } } }