void ofxAlembic::IXform::updateWithTimeInternal(double time, Imath::M44f& transform) { ISampleSelector ss(time, ISampleSelector::kNearIndex); M44f mat; M44d m = m_xform.getSchema().getValue(ss).getMatrix(); double *src = m.getValue(); float *dst = mat.getValue(); for (int i = 0; i < 16; i++) dst[i] = src[i]; transform = mat * transform; for (int i = 0; i < 16; i++) { xform.local_matrix.getPtr()[i] = mat.getValue()[i]; xform.global_matrix.getPtr()[i] = transform.getValue()[i]; } }
void ViewportGadget::SelectionScope::begin( const ViewportGadget *viewportGadget, const Imath::Box2f &rasterRegion, const Imath::M44f &transform, IECoreGL::Selector::Mode mode ) { V2f viewport = viewportGadget->getViewport(); Box2f ndcRegion( rasterRegion.min / viewport, rasterRegion.max / viewport ); IECoreGL::ToGLConverterPtr converter = new IECoreGL::ToGLCameraConverter( const_cast<CameraController &>( viewportGadget->m_cameraController ).getCamera() ); IECoreGL::CameraPtr camera = staticPointerCast<IECoreGL::Camera>( converter->convert() ); /// \todo It would be better to base this on whether we have a depth buffer or not, but /// we don't have access to that information right now. m_depthSort = camera->isInstanceOf( IECoreGL::PerspectiveCamera::staticTypeId() ); camera->render( 0 ); glClearColor( 0.3f, 0.3f, 0.3f, 0.0f ); glClearDepth( 1.0f ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); m_selector = SelectorPtr( new IECoreGL::Selector( ndcRegion, mode, m_selection ) ); glPushMatrix(); glMultMatrixf( transform.getValue() ); }
void SkeletonPrimitive::render( const State *state, IECore::TypeId style ) const { Imath::V3f from_vec(0.0, 0.0, 1.0), up(0.0, 1.0, 0.0); JointPrimitive jointPrimitive( m_jointsRadius, 1.0 ); // loop over global transforms for (unsigned int i=0; i<m_globalMatrices->readable().size(); i++) { Imath::M44f child_mtx; unsigned int numChildren = m_childrenIds[i].size(); if (numChildren > 0) { for (unsigned int j=0; j< numChildren; j++ ) { child_mtx = m_globalMatrices->readable()[ m_childrenIds[i][j] ]; Imath::V3f aim_vec = child_mtx.translation() - m_globalMatrices->readable()[i].translation(); float bone_length = aim_vec.length(); jointPrimitive.setLength( bone_length ); Imath::V3f up_vec = up*m_globalMatrices->readable()[i] - m_globalMatrices->readable()[i].translation(); Imath::M44f bone_mtx = Imath::rotationMatrixWithUpDir( from_vec, aim_vec.normalize(), up_vec ); Imath::M44f bone_offset_mtx; bone_offset_mtx.translate( m_globalMatrices->readable()[i].translation() ); // draw the jointPrimitive glPushMatrix(); glMultMatrixf( bone_offset_mtx.getValue() ); glMultMatrixf( bone_mtx.getValue() ); jointPrimitive.render( state, style ); glPopMatrix(); } } else { // a Null or Locator shape when the joint has no children glPushMatrix(); Imath::M44f mat = m_globalMatrices->readable()[i]; Imath::removeScaling(mat, false); glMultMatrixf( mat.getValue() ); glBegin( GL_LINES ); glVertex3f(-m_jointsRadius, 0.0, 0.0); glVertex3f( m_jointsRadius, 0.0, 0.0); glEnd(); glBegin( GL_LINES ); glVertex3f(0.0, -m_jointsRadius, 0.0); glVertex3f(0.0, m_jointsRadius, 0.0); glEnd(); glBegin( GL_LINES ); glVertex3f(0.0, 0.0, -m_jointsRadius); glVertex3f(0.0, 0.0, m_jointsRadius); glEnd(); glPopMatrix(); } if ( m_jointsAxis == true) { float l = m_jointsRadius*3.0; //// draw the axis lines for debug porpose ///// glPushMatrix(); Imath::M44f matNoSCale = m_globalMatrices->readable()[i]; Imath::removeScaling(matNoSCale, false); glMultMatrixf( matNoSCale.getValue() ); ///// store the current color and lighting mode ///// GLboolean light; float color[4]; glGetBooleanv(GL_LIGHTING, &light); glGetFloatv(GL_CURRENT_COLOR, color); glDisable(GL_LIGHTING); glBegin( GL_LINES ); glColor3ub(255, 0, 0); glVertex3f(0.0, 0.0, 0.0); glVertex3f(l, 0.0, 0.0); glEnd(); glBegin( GL_LINES ); glColor3ub(0, 255, 0); glVertex3f(0.0, 0.0, 0.0); glVertex3f(0.0, l, 0.0); glEnd(); glBegin( GL_LINES ); glColor3ub(0, 0, 255); glVertex3f(0.0, 0.0, 0.0); glVertex3f(0.0, 0.0, l); glEnd(); //// restore the color and the lighting modo to their initial state ///// glColor4f(color[0], color[1], color[2], color[3]); if (light==true) { glEnable(GL_LIGHTING); } glPopMatrix(); } } }
void ImmediateRendererImplementation::concatTransform( const Imath::M44f &matrix ) { glMultMatrixf( matrix.getValue() ); }