Trang chủ | Email | W2G.,JSC | Liên hệ-Góp ý | SearchWiki:


Quảng cáo



Tài liệu lập trình

3D Graphics - Đồ họa 3D

Xử lý ảnh

Sách điện tử

sửa SideBar

Attach:cubmap0.jpg ΔCubemap texture generation modes (REFLECTION_MAP and NORMAL_MAP) uses the normals to calculate the texture coordinates. It maps the texture as if it operates in eye-space coordinates. That means the positive Z face of the cube map will always face the camera. To use cube maps for reflection we can rotate the cube map so it appears to be maped in world space. To accomplish this we have to modify the texture matrix.
Attach:cubmap1.jpg ΔAttach:cubmap2.jpg Δ
Attach:cubmap3.jpg ΔHere is the cube map applied to a sphere with Tex Gen? mode set to REFLECTION_MAP. Since cube maps operate in eye space the +Z will always face the camera. To use cube maps for reflection we have to move the cube map to world space. This is done by setting the texture matrix to the inverse of the model-view matrix (translation part of MV ignored). Most available cube maps are made for Y-up worlds but OSG uses Z-up so we have to compesate for this if we intend to use cube maps with Y-up.
Attach:cubmap4.jpg ΔThe third thing we have to do is to compensate for the heritage cube maps have from Direct X?. In D 3 D? the texture coordinate 0,0 is in the upper-left corner while GL uses lower-left. This makes it look like each face of a cube map is upside-down. To correct this we can use the OSG function Image::flipVertical() on each face.
Attach:cubmap5.jpg ΔThe final result.

struct Tex Mat Cull Callback? : public osg::Node Callback {


   Tex Mat Cull Callback?(osg::Tex Mat& tm) :

   virtual void operator()(osg::Node* node, osg::Node Visitor* nv)
      osgUtil::Cull Visitor?* cv = dynamic_cast<:cullvisitor*>(nv);
      if (cv)
         const osg::Matrix& MV = cv->getModelViewMatrix();

         osg::Quat q;
         const osg::Matrix C = osg::Matrix::rotate( q.inverse() );
         const osg::Matrix R = osg::Matrix::rotate( osg::Vec3(0,0,1), osg::Vec3(0,1,0) );

         _texMat.setMatrix( C * R );


   osg::Tex Mat& _texMat;



Tài tiệu Open GL

Tài liệu OSG

Hình ảnh một số sản phẩm

vanmieu6.jpg: 800x500, 171k (December 01, 2011, at 10:13 AM)
BigC-3.jpg: 800x500, 65k (December 01, 2011, at 10:13 AM)
th_vsg_02.jpg: 200x150, 5k (December 01, 2011, at 10:13 AM)
th_vsg_09.jpg: 200x150, 31k (December 01, 2011, at 10:13 AM)
vanmieu4.jpg: 800x500, 160k (December 01, 2011, at 10:13 AM)
nhandan2.jpg: 800x600, 161k (December 01, 2011, at 10:13 AM)

sửa SideBar

Edit - History - Print - Recent Changes - Search
Page last modified on September 17, 2005, at 09:41 AM