void CamtransCamera::orientLook(const Vector4 &eye, const Vector4 &look, const Vector4 &up) { // @TODO: [CAMTRANS] Fill this in... m_n = look; m_n = m_n.getNormalized(); m_n *= (-1); m_n.unhomgenize(); REAL uProjection = m_n.dot( up ); m_v.x = up.x - uProjection*m_n.x; m_v.y = up.y - uProjection*m_n.y; m_v.z = up.z - uProjection*m_n.z; m_v = m_v.getNormalized(); m_v.unhomgenize(); m_u = m_v; m_u = m_v.cross(m_n); m_u.unhomgenize(); m_eyePosition = eye; m_lookAt = look; m_up = up; REAL lN = m_lookAt.getMagnitude(); m_lookAt /= lN; m_lookAt.unhomgenize(); m_up = m_v; m_up.unhomgenize(); updateModelViewMatrix(); updateProjectionMatrix(); }
void CamtransCamera::translate(const Vector4 &v) { // @TODO: [CAMTRANS] Fill this in... m_eyePosition = getTransMat( v )*m_eyePosition; updateModelViewMatrix(); }
void Projector::update() { if(!m_pkCamera) return; updateOrientation(); updateModelViewMatrix(); updateProjectionMatrix(); float16 kViewPrj = m_kModelViewMatrix * m_kProjectionMatrix; float16 kInvViewPrj = inverse(kViewPrj); findFrustumCorners(m_akFrustum, kInvViewPrj); m_uiIntersectionCount = findPlanarIntersections(m_akIntersections, m_akFrustum); if(m_uiIntersectionCount > 0) { m_kRange = findProjectedRange(m_uiIntersectionCount, m_akIntersections, kViewPrj); findProjectedCorners(m_akCorners, m_kRange, kInvViewPrj); updateRangeMatrix(m_kRange); m_bIsVisible = true; } else { m_bIsVisible = false; } }
/* Render::initialize: initialzie Render */ void Render::initialize() { m_width = 0; m_height = 0; m_trans = btVector3(0.0f, 0.0f, 0.0f); m_angle = btVector3(0.0f, 0.0f, 0.0f); updateRotationFromAngle(); m_distance = 100.0f; m_fovy = 16.0f; m_currentTrans = m_trans; m_currentRot = m_rot; m_currentDistance = m_distance; m_currentFovy = m_fovy; m_viewMoveTime = -1.0; m_viewControlledByMotion = false; m_transMatrix.setIdentity(); updateModelViewMatrix(); m_shadowMapInitialized = false; m_lightVec = btVector3(0.0f, 0.0f, 0.0f); m_shadowMapAutoViewEyePoint = btVector3(0.0f, 0.0f, 0.0f); m_shadowMapAutoViewRadius = 0.0f; m_depth = NULL; }
ObjectData::ObjectData() : position(glm::vec2(0.f, 0.f)) , rotationAngle(0.f) , hasUpdate(false) , visible(true) , anchorPoint(glm::vec2(0.5f, 0.5f)) , material(Hash(qui::Q2D::DEFAULT_MATERIAL).value) { updateModelViewMatrix(); }
void GlModel::updateModelMatrix() { // TODO verify the multiplication order. m_modelMatrix = Mat4::identity(); m_modelMatrix = m_modelMatrix * Mat4::translate(m_position); m_modelMatrix = m_modelMatrix * Mat4::rotateX(m_rotation.x) * Mat4::rotateY(m_rotation.y) * Mat4::rotateZ(m_rotation.z); m_modelMatrix = m_modelMatrix * Mat4::scale(m_scale); pushModelMatrix(); updateModelViewMatrix(); }
void CamtransCamera::rotateU(float degrees) { // @TODO: [CAMTRANS] Fill this in... REAL radians = degrees/180*M_PI; Matrix4x4 rot = Matrix4x4::identity(); if( !m_useQuaternion ) rot = getRotMat( m_eyePosition,m_u,-radians ); else rot = getRotMatFromQuaternion( m_eyePosition,m_u,-radians ); m_v = rot*m_v; m_n = rot*m_n; m_lookAt = rot*m_lookAt; m_up = rot*m_up; updateModelViewMatrix(); }
void MyGLCloudViewer::drawOBJ(ModelViewParams modelViewParams) { glEnable(GL_LIGHTING); glFrontFace(GL_CW); updateModelViewMatrix(modelViewParams); //glMultMatrixf(mat); //glMultMatrixf(mat); glmDraw(ARModel, GLM_SMOOTH | GLM_MATERIAL); glPopMatrix(); glDisable(GL_LIGHTING); glFrontFace(GL_CCW); }
/* Render::render: render all */ void Render::render(PMDObject *objs, short *order, int num, Stage *stage, bool useMMDLikeCartoon, bool useCartoonRendering, float lightIntensity, float *lightDirection, float *lightColor, bool useShadowMapping, int shadowMappingTextureSize, bool shadowMappingLightFirst, float shadowMappingSelfDensity, float shadowMappingFloorDensity, double ellapsedTimeForMove) { bool updated; /* update camera view matrices */ updated = updateDistance(ellapsedTimeForMove); updated |= updateTransRotMatrix(ellapsedTimeForMove); if (updated == true) updateModelViewMatrix(); if (updateFovy(ellapsedTimeForMove) == true) updateProjectionMatrix(); if (isViewMoving() == false) m_viewMoveTime = -1.0; if (useShadowMapping) renderSceneShadowMap(objs, order, num, stage, useMMDLikeCartoon, useCartoonRendering, lightIntensity, lightDirection, lightColor, shadowMappingTextureSize, shadowMappingLightFirst, shadowMappingSelfDensity); else renderScene(objs, order, num, stage, useMMDLikeCartoon, useCartoonRendering, lightIntensity, lightDirection, lightColor, shadowMappingFloorDensity); }
void GlModel::updateViewMatrix() { pushViewMatrix(); updateModelViewMatrix(); }