void Doom3GroupNode::evaluateTransform() { if (getType() == TRANSFORM_PRIMITIVE) { const Quaternion& rotation = getRotation(); const Vector3& scale = getScale(); _d3Group.translate( getTranslation(), rotation != Quaternion::Identity(), // FALSE for identity rotations scale != c_scale_identity // FALSE for identity scales ); _d3Group.rotate(rotation); _d3Group.scale(scale); // Transform curve control points in primitive mode Matrix4 transformation = calculateTransform(); _nurbsEditInstance.transform(transformation, false); _catmullRomEditInstance.transform(transformation, false); } else { // Transform the components only transformComponents(calculateTransform()); } // Trigger a recalculation of the curve's controlpoints _d3Group.m_curveNURBS.curveChanged(); _d3Group.m_curveCatmullRom.curveChanged(); }
void Node::visit(const Matrix4& newTransformMatrix, bool parentTransformDirty, const LayerPtr& currentLayer) { if (parentTransformDirty) { updateTransform(newTransformMatrix); } if (transformDirty) { calculateTransform(); } if (currentLayer) { for (const NodePtr& child : children) { if (child->isVisible()) { if (child->isGlobalOrder()) { currentLayer->addGlobalNode(child); } child->visit(transform, updateChildrenTransform, currentLayer); } } } updateChildrenTransform = false; }
void RubberSheet::apply(shared_ptr<OsmMap>& map) { shared_ptr<OGRSpatialReference> oldSrs = _projection; calculateTransform(map); _projection = oldSrs; applyTransform(map); }
void RCViewableTransform::setFocalPoint(const Eks::Vector3D &aim) { Eks::Transform t = transform(); transform = calculateTransform(t.translation(), aim, upVector()); focalDistance = (aim - t.translation()).norm(); transform = t; }
const Matrix4& Node::getTransform() const { if (transformDirty) { calculateTransform(); } return transform; }
void BrushInstance::evaluateTransform () { Matrix4 matrix(calculateTransform()); if (getType() == TRANSFORM_PRIMITIVE) { m_brush.transform(matrix); } else { transformComponents(matrix); } }
bool EditorChunkBinding::load( DataSectionPtr pSection ) { bool ok = this->EditorChunkSubstance<ChunkBinding>::load( pSection ); if (this->from()) { calculateTransform(true); } return ok; }
std::pair<vec3, vec3> Triangle::getBoundingBoxDimensions() { calculateTransform(); vec3 min, max; for (int i = 0; i < 3; i++) { float max_coord = std::max(std::max(_t_vertices[0][i], _t_vertices[1][i]), _t_vertices[2][i]); float min_coord = std::min(std::min(_t_vertices[0][i], _t_vertices[1][i]), _t_vertices[2][i]); max[i] = max_coord; min[i] = min_coord; } return std::make_pair(min, max); }
void Node::calculateInverseTransform() const { if (transformDirty) { calculateTransform(); } inverseTransform = transform; inverseTransform.invert(); inverseTransformDirty = false; }
void evaluateTransform() { if(getType() == TRANSFORM_PRIMITIVE) { m_contained.translate(getTranslation()); m_contained.rotate(getRotation()); } else { transformComponents(calculateTransform()); } }
void Doom3GroupNode::evaluateTransform() { if (getType() == TRANSFORM_PRIMITIVE) { m_contained.translate( getTranslation(), getRotation() != c_quaternion_identity // FALSE for identity rotations ); m_contained.rotate(getRotation()); // Transform curve control points in primitive mode Matrix4 transformation = calculateTransform(); m_curveNURBS.transform(transformation, false); m_curveCatmullRom.transform(transformation, false); } else { // Transform the components only transformComponents(calculateTransform()); } // Trigger a recalculation of the curve's controlpoints m_contained.m_curveNURBS.curveChanged(); m_contained.m_curveCatmullRom.curveChanged(); }
const Matrix4& Node::getInverseTransform() const { if (transformDirty) { calculateTransform(); } if (inverseTransformDirty) { calculateInverseTransform(); } return inverseTransform; }
std::pair<bool,vec3> Triangle::intersect(const vec3& origin, const vec3& direction) { calculateTransform(); vec3 p0 = _t_vertices[0], p1 = _t_vertices[1], p2 = _t_vertices[2]; vec3 normal = glm::normalize(glm::cross(p1 - p0, p2 - p0)); GLfloat t = glm::dot((p0 - origin), normal)/glm::dot(direction, normal); if (t >= 0) { vec3 ray = origin + direction * t; bool hit = glm::dot(glm::cross(p1 - p0, ray - p0), normal) >= 0 && glm::dot(glm::cross(p2 - p1, ray - p1), normal) >= 0 && glm::dot(glm::cross(p0 - p2, ray - p2), normal) >= 0; return std::make_pair(hit, ray); } else { return std::make_pair(false, direction); } }
vec3 Triangle::getNormal(const vec3& intersect) { if (!transformed) { calculateTransform(); } vec3 normal; if (_type == tri) { normal = _t_normals[0]; } else { vec3 temp1 = (_t_normals[0] * (intersect.y - _t_vertices[1].y) + _t_normals[1] * (_t_vertices[0].y - intersect.y))/(_t_vertices[0].y - _t_vertices[1].y); vec3 temp2 = (_t_normals[0] * (intersect.y - _t_vertices[2].y) + _t_normals[2] * (_t_vertices[0].y - intersect.y))/(_t_vertices[0].y - _t_vertices[2].y); normal = (temp1 * (temp2.x - intersect.x) + temp2 * (intersect.x - temp1.x))/(temp2.x - temp1.x); vec4 homo_normal = glm::normalize(vec4(normal.x, normal.y, normal.z, 0) * glm::transpose(glm::inverse(transform))); normal = glm::normalize(glm::vec3(homo_normal.x, homo_normal.y, homo_normal.z)); } return normal; }
Kamikaze::Kamikaze() : Asteroid() { score = 100; damage = 20; health = 1; mesh = new ObjGeometry("geometry/ship.obj"); color = Eigen::Vector3f(0.7,0.0,0.2); velocity = Eigen::Vector3f(0, 0, 0); scale = Eigen::Vector3f(1.2, 1.2, 1.2); //BS INIT calculateTransform(); bs = new BoundingSphere(this); bs->update(mesh); bs->transform(&transM, scale[1]); }
void Node::draw(const LayerPtr& currentLayer) { if (transformDirty) { calculateTransform(); } if (currentLayer) { if (currentLayer->getCamera()) { graphics::Color drawColor(color.r, color.g, color.b, static_cast<uint8_t>(color.a * opacity)); for (const DrawablePtr& drawable : drawables) { if (drawable->isVisible()) { drawable->draw(currentLayer->getCamera()->getViewProjection(), transform, drawColor); } } } } }