vec3 vec3::operator+=(vec3 rhs) { return vec3( m_vec[0] + rhs.x(), m_vec[1] + rhs.y(), m_vec[2] + rhs.z()); }
vec3 vec3::operator-(vec3 rhs) { return vec3( m_vec[0] - rhs.x(), m_vec[1] - rhs.y(), m_vec[2] - rhs.z()); }
vec3 vec3::cross(vec3 &rhs) { return vec3( m_vec[1] * rhs.z() - m_vec[2] * rhs.y(), m_vec[2] * rhs.x() - m_vec[0] * rhs.z(), m_vec[0] * rhs.y() - m_vec[1] * rhs.x()); }
bool vec3::operator==(vec3 rhs) { return(m_vec[0] == rhs.x() && m_vec[1] == rhs.y() && m_vec[2] == rhs.z()); }
void SceneIdeasPrivate::draw() { viewFromSpline_.getCurrentVec(currentTime_, viewFrom_); viewToSpline_.getCurrentVec(currentTime_, viewTo_); lightPosSpline_.getCurrentVec(currentTime_, lightPos_); logoPosSpline_.getCurrentVec(currentTime_, logoPos_); logoRotSpline_.getCurrentVec(currentTime_, logoRot_); // Tell the logo its new position logo_.setPosition(logoPos_); vec4 lp4(lightPos_.x(), lightPos_.y(), lightPos_.z(), 0.0); // // SHADOW // modelview_.loadIdentity(); modelview_.lookAt(viewFrom_.x(), viewFrom_.y(), viewFrom_.z(), viewTo_.x(), viewTo_.y(), viewTo_.z(), 0.0, 1.0, 0.0); float pca(0.0); if (viewFrom_.y() > 0.0) { table_.draw(modelview_, projection_, lightPos_, logoPos_, currentTime_, pca); } glEnable(GL_CULL_FACE); glDisable(GL_DEPTH_TEST); if (logoPos_.y() < 0.0) { // Set the color assuming we're still under the table. uvec3 flatColor(128 / 2, 102 / 2, 179 / 2); if (logoPos_.y() > -0.33) { // We're emerging from the table float c(1.0 - logoPos_.y() / -0.33); pca /= 4.0; flatColor.x(static_cast<unsigned int>(128.0 * (1.0 - c) * 0.5 + 255.0 * pca * c)); flatColor.y(static_cast<unsigned int>(102.0 * (1.0 - c) * 0.5 + 255.0 * pca * c)); flatColor.z(static_cast<unsigned int>(179.0 * (1.0 - c) * 0.5 + 200.0 * pca * c)); } modelview_.push(); modelview_.scale(0.04, 0.0, 0.04); modelview_.rotate(-90.0, 1.0, 0.0, 0.0); modelview_.rotate(0.1 * static_cast<int>(10.0 * logoRot_.z()), 0.0, 0.0, 1.0); modelview_.rotate(0.1 * static_cast<int>(10.0 * logoRot_.y()), 0.0, 1.0, 0.0); modelview_.rotate(0.1 * static_cast<int>(10.0 * logoRot_.x()), 1.0, 0.0, 0.0); modelview_.rotate(0.1 * 353, 1.0, 0.0, 0.0); modelview_.rotate(0.1 * 450, 0.0, 1.0, 0.0); logo_.draw(modelview_, projection_, lightPositions_[0], SGILogo::LOGO_FLAT, flatColor); modelview_.pop(); } if (logoPos_.y() > 0.0) { modelview_.push(); modelview_.translate(lightPos_.x(), lightPos_.y(), lightPos_.z()); mat4 tv; tv[3][1] = -1.0; tv[3][3] = 0.0; tv[0][0] = tv[1][1] = tv[2][2] = lightPos_.y(); modelview_ *= tv; modelview_.translate(-lightPos_.x() + logoPos_.x(), -lightPos_.y() + logoPos_.y(), -lightPos_.z() + logoPos_.z()); modelview_.scale(0.04, 0.04, 0.04); modelview_.rotate(-90.0, 1.0, 0.0, 0.0); modelview_.rotate(0.1 * static_cast<int>(10.0 * logoRot_.z()), 0.0, 0.0, 1.0); modelview_.rotate(0.1 * static_cast<int>(10.0 * logoRot_.y()), 0.0, 1.0, 0.0); modelview_.rotate(0.1 * static_cast<int>(10.0 * logoRot_.x()), 1.0, 0.0, 0.0); modelview_.rotate(35.3, 1.0, 0.0, 0.0); modelview_.rotate(45.0, 0.0, 1.0, 0.0); logo_.draw(modelview_, projection_, lightPositions_[0], SGILogo::LOGO_SHADOW); modelview_.pop(); } // // DONE SHADOW // glEnable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); modelview_.loadIdentity(); modelview_.lookAt(viewFrom_.x(), viewFrom_.y(), viewFrom_.z(), viewTo_.x(), viewTo_.y(), viewTo_.z(), 0.0, 1.0, 0.0); modelview_.push(); modelview_.translate(lightPos_.x(), lightPos_.y(), lightPos_.z()); modelview_.scale(0.1, 0.1, 0.1); float x(lightPos_.x() - logoPos_.x()); float y(lightPos_.y() - logoPos_.y()); float z(lightPos_.z() - logoPos_.z()); double a3(0.0); if (x != 0.0) { a3 = -atan2(z, x) * 10.0 * 180.0 / M_PI; } double a4(-atan2(sqrt(x * x + z * z), y) * 10.0 * 180.0 / M_PI); modelview_.rotate(0.1 * static_cast<int>(a3), 0.0, 1.0, 0.0); modelview_.rotate(0.1 * static_cast<int>(a4), 0.0, 0.0, 1.0); modelview_.rotate(-90.0, 1.0, 0.0, 0.0); lamp_.draw(modelview_, projection_, lightPositions_); modelview_.pop(); lightPositions_[0] = modelview_.getCurrent() * lp4; if (logoPos_.y() > -0.33) { modelview_.push(); modelview_.translate(logoPos_.x(), logoPos_.y(), logoPos_.z()); modelview_.scale(0.04, 0.04, 0.04); modelview_.rotate(-90.0, 1.0, 0.0, 0.0); modelview_.rotate(0.1 * static_cast<int>(10.0 * logoRot_.z()), 0.0, 0.0, 1.0); modelview_.rotate(0.1 * static_cast<int>(10.0 * logoRot_.y()), 0.0, 1.0, 0.0); modelview_.rotate(0.1 * static_cast<int>(10.0 * logoRot_.x()), 1.0, 0.0, 0.0); modelview_.rotate(35.3, 1.0, 0.0, 0.0); modelview_.rotate(45.0, 0.0, 1.0, 0.0); logo_.draw(modelview_, projection_, lightPositions_[0], SGILogo::LOGO_NORMAL); modelview_.pop(); } if (viewFrom_.y() < 0.0) { table_.drawUnder(modelview_, projection_); } }
float vec3::dot(vec3 &rhs) { return (m_vec[0] * rhs.x() + m_vec[1] * rhs.y() + m_vec[2] * rhs.z()); }
vec3 UnitConverter::lengthFromAngstroms(vec3 position) { return vec3(UnitConverter::lengthFromAngstroms(position.x()), UnitConverter::lengthFromAngstroms(position.y()), UnitConverter::lengthFromAngstroms(position.z())); }
vec3 tangent_space_to_world_space(const vec3& v, const vec3& nrm) { const vec3& t1 = perpendicular(nrm); const vec3& t2 = cross(nrm, t1); return (v.x() * t1 + v.y() * t2 + v.z() * nrm).normalized(); }
vec3 UnitConverter::velocityFromSI(vec3 velocity) { return vec3(UnitConverter::velocityFromSI(velocity.x()), UnitConverter::velocityFromSI(velocity.y()), UnitConverter::velocityFromSI(velocity.z())); }
vec3 UnitConverter::lengthToSI(vec3 position) { return vec3(UnitConverter::lengthToSI(position.x()), UnitConverter::lengthToSI(position.y()), UnitConverter::lengthToSI(position.z())); }
/*! Initializes vec3 class by copying the values of \a v . */ coordinates::coordinates(vec3 v) : vec3(v.x(), v.y(), v.z()) { }
/** \brief Accessor. * * \return Maximum y coordinate. */ T y2() const { return m_pnt_max.y(); }
/** \brief Accessor. * * \return Maximum y coordinate. */ T& y2() { return m_pnt_max.y(); }
/** \brief Accessor. * * \return Minimum y coordinate. */ T y1() const { return m_pnt_min.y(); }
/** \brief Accessor. * * \return Minimum y coordinate. */ T& y1() { return m_pnt_min.y(); }