I tested my compiler(VisualStudio2010sp1), and found that c++11 is not 
supported unfortunately.It seems that ... is the problem.Following is the 
output info:
 VOODOO=1:
 1>InitializeBuildStatus:
1>  ????????Debug\test111.unsuccessfulbuild?????? Touch ??????
1>ClCompile:
1>  1.cpp
1>e:\wuzc02\????\20131011\test111\test111\1.cpp(39): error C2332: ??class??: 
??????????
1>e:\wuzc02\????\20131011\test111\test111\1.cpp(39): error C2993: ????: 
????????????????<unnamed-tag>????????????
1>e:\wuzc02\????\20131011\test111\test111\1.cpp(39): error C2143: ???????? : 
??????,??(????...????????)
1>e:\wuzc02\????\20131011\test111\test111\1.cpp(40): error C2065: ??Args??: 
??????????????
1>          e:\wuzc02\????\20131011\test111\test111\1.cpp(40): 
?????????????????? ???? ????????SeqBinder<F,N,<unnamed-tag>>????????
1>e:\wuzc02\????\20131011\test111\test111\1.cpp(40): error C2143: ???????? : 
??????,??(????...????????)
1>e:\wuzc02\????\20131011\test111\test111\1.cpp(40): error C2143: ???????? : 
??????;??(????{????????)
1>e:\wuzc02\????\20131011\test111\test111\1.cpp(40): fatal error C1004: 
????????????????
1>
1>??????????

  
 VOODOO=0
 1>InitializeBuildStatus:
1>  ????????Debug\test111.unsuccessfulbuild?????? Touch ??????
1>ClCompile:
1>  1.cpp
1>e:\wuzc02\????\20131011\test111\test111\1.cpp(79): error C2143: ???????? : 
??????,??(????...????????)
1>e:\wuzc02\????\20131011\test111\test111\1.cpp(80): error C4430: 
?????????????? - ?????? int??????: C++ ?????????? int
1>e:\wuzc02\????\20131011\test111\test111\1.cpp(80): error C2143: ???????? : 
??????,??(????&????????)
1>e:\wuzc02\????\20131011\test111\test111\1.cpp(90): error C2143: ???????? : 
??????,??(????...????????)
1>e:\wuzc02\????\20131011\test111\test111\1.cpp(92): error C2065: ??Args??: 
??????????????
1>          e:\wuzc02\????\20131011\test111\test111\1.cpp(107): 
?????????????????? ???? ????????LHC<__formal>????????
1>e:\wuzc02\????\20131011\test111\test111\1.cpp(92): error C2143: ???????? : 
??????)??(????...????????)
1>e:\wuzc02\????\20131011\test111\test111\1.cpp(100): error C2065: ??Args??: 
??????????????
1>e:\wuzc02\????\20131011\test111\test111\1.cpp(100): error C2143: ???????? : 
??????,??(????...????????)
1>e:\wuzc02\????\20131011\test111\test111\1.cpp(100): error C2059: 
????????:??)??
1>e:\wuzc02\????\20131011\test111\test111\1.cpp(102): error C2143: ???????? : 
??????;??(????{????????)
1>e:\wuzc02\????\20131011\test111\test111\1.cpp(104): error C2143: ???????? : 
??????;??(????{????????)
1>e:\wuzc02\????\20131011\test111\test111\1.cpp(106): error C2143: ???????? : 
??????;??(????}????????)
1>e:\wuzc02\????\20131011\test111\test111\1.cpp(107): error C2143: ???????? : 
??????;??(????}????????)
1>e:\wuzc02\????\20131011\test111\test111\1.cpp(107): fatal error C1004: 
????????????????
1>
1>??????????
  
  ------------------
  Failure is the mother of success.
 Wu Zhicheng


  
  

 

 ------------------ Original ------------------
  From:  "Solkar Graphics";<sol...@freenet.de>;
 Date:  Sun, Jul 6, 2014 09:58 PM
 To:  "osg-users"<osg-users@lists.openscenegraph.org>; 
 
 Subject:  Re: [osg-users] how to get the real world coordinates(x, y,z) in 
shader

 

Very well.

Some preliminary remarks:


The sphere 
Code:
geode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(osg::Vec3d(0,0,0), 
6500000.0)));

 has a radius of 6.5E6, whereas your orthographic frustum  
Code:
node->setProjectionMatrix(osg::Matrix::ortho2D(0, 1600, 0, 900));

 is 3 magnitudes smaller along each axis. 
That would never fit around the whole sphere, but apparently, so see the sphere 
nevertheless That gives rise to the notion of some "mangling" being done behind 
the scenes.

Again the sphere
Code:
geode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(osg::Vec3d(0,0,0), 
6500000.0)));

 
It's at origin. as initially is world respective to cam coords

Code:
node->setViewMatrix(osg::Matrix::identity());

. cam would sit inside the sphere, if no mangling was done.

osgViewer::Viewer::run() 
http://trac.openscenegraph.org/projects/osg/browser/OpenSceneGraph/trunk/include/osgViewer/Viewer


>  /** Execute a main frame loop.
>   * Equivalent to while (!viewer.done()) viewer.frame();
>   * Also calls realize() if the viewer is not already realized,
>   * and installs trackball manipulator if one is not already assigned.
>   */
> 
and it's obvious that there is a manipulator installed, because the viewer is 
responsive to mouse events.
If you log the view matrix before the viewer.run() you get the identity matrix 
you set.
But If log dump the view matrix from within run(), e.g in your

Code:
UpdateUniformsCallback::operator()


you get

1   0   0   0
0   0   1   0
0  -1   0 -4.47409e+07 
0   0   0  1

thus world has been tilted by [pi/2,0,0] and shifted ~4.5E7  to the back.


That's it about the maths.
Now about the uniforms -  
you have to do 

Code:
pref->getState()->setUseModelViewAndProjectionUniforms(true);
pref->getState()->setUseVertexAttributeAliasing(false); // depands on the 
shader code



for all valid

Code:
osgViewer::ViewerBase::Contexts:.value_type pref;


 after the view has been realized once but before the run.

I will give you code for that after you'll have figured out your compiler's C++ 
support. 

Cheers,
Solkar
Code:




------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=60183#60183





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
.
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to