Changeset 5953 for OpenSceneGraph/trunk/examples/osgmovie/osgmovie.cpp
 Timestamp:
 01/10/07 11:40:12 (8 years ago)
 Files:

 1 modified
Legend:
 Unmodified
 Added
 Removed

OpenSceneGraph/trunk/examples/osgmovie/osgmovie.cpp
r5951 r5953 119 119 120 120 osgViewer::View* view = dynamic_cast<osgViewer::View*>(&aa); 121 osg::notify(osg::NOTICE)<<"osgmovie  view = "<<view<<std::endl;122 121 osgUtil::LineSegmentIntersector::Intersections intersections; 123 if (view && view>computeIntersections(ea.getX(), ea.getY(), nv>getNodePath().back(), intersections)) 124 { 125 #if 1 126 osg::notify(osg::NOTICE)<<"osgmovie  Vertex interpolation not implemented yet"<<std::endl; 127 #else 122 if (view && view>computeIntersections(ea.getX(), ea.getY(), nv>getNodePath(), intersections)) 123 { 124 128 125 // use the nearest intersection 129 126 const osgUtil::LineSegmentIntersector::Intersection& intersection = *(intersections.begin()); … … 134 131 { 135 132 // get the vertex indices. 136 const osgUtil::LineSegmentIntersector::Intersection::IndexList& vil = intersection.indexList; 137 138 if (vil.size()==3) 133 const osgUtil::LineSegmentIntersector::Intersection::IndexList& indices = intersection.indexList; 134 const osgUtil::LineSegmentIntersector::Intersection::RatioList& ratios = intersection.ratioList; 135 136 if (indices.size()==3 && ratios.size()==3) 139 137 { 140 int i1 = vil[0]; 141 int i2 = vil[1]; 142 int i3 = vil[2]; 143 osg::Vec3 v1 = (*vertices)[i1]; 144 osg::Vec3 v2 = (*vertices)[i2]; 145 osg::Vec3 v3 = (*vertices)[i3]; 146 osg::Vec3 v = intersection.localIntersectionPoint; 147 148 osg::Vec3 p1 = intersection.getLocalLineSegment()>start(); 149 osg::Vec3 p2 = intersection.getLocalLineSegment()>end(); 150 151 osg::Vec3 p12 = p1p2; 152 osg::Vec3 v13 = v1v3; 153 osg::Vec3 v23 = v2v3; 154 osg::Vec3 p1v3 = p1v3; 155 156 osg::Matrix matrix(p12.x(), v13.x(), v23.x(), 0.0, 157 p12.y(), v13.y(), v23.y(), 0.0, 158 p12.z(), v13.z(), v23.z(), 0.0, 159 0.0, 0.0, 0.0, 1.0); 160 161 osg::Matrix inverse; 162 inverse.invert(matrix); 163 164 osg::Vec3 ratio = inverse*p1v3; 165 166 // extract the baricentric coordinates. 167 float r1 = ratio.y(); 168 float r2 = ratio.z(); 169 float r3 = 1.0fr1r2; 138 unsigned int i1 = indices[0]; 139 unsigned int i2 = indices[1]; 140 unsigned int i3 = indices[2]; 141 142 float r1 = ratios[0]; 143 float r2 = ratios[1]; 144 float r3 = ratios[2]; 170 145 171 146 osg::Array* texcoords = (geometry>getNumTexCoordArrays()>0) ? geometry>getTexCoordArray(0) : 0; … … 189 164 190 165 } 191 #endif192 166 } 193 167 else