[osg-users] Serialization differences between ASCII and XML

2017-12-27 Thread Hartwig Wiesmann
Hi,

wrote a simple serialiser for the output of a range:


Code:

namespace
{
bool checkGeographicRange(osgPlanetCore::GeodeticData const&)
{
return true;
}

bool readGeographicRange(osgDB::InputStream& inputStream, 
osgPlanetCore::GeodeticData& geodeticData)
{
osgPlanetCore::GeographicRange geographicRange;


if (osgPlanetWrappers::readRange(inputStream,geographicRange))
{
geodeticData.setGeographicRange(geographicRange);
return true;
} /* if */
else
return false;
}

bool writeGeographicRange(osgDB::OutputStream& outputStream, 
osgPlanetCore::GeodeticData const& geodeticData)
{
outputStream << std::endl;
return 
osgPlanetWrappers::writeRange(outputStream,geodeticData.getGeographicRange());
}

} /* namespace */

template < typename Values >
bool readRange(osgDB::InputStream& inputStream, osgPlanetCore::Range< 
Values >& range)
{
inputStream >> inputStream.BEGIN_BRACKET;
inputStream >> inputStream.PROPERTY("FromValues") >> 
range.getFromValues();
inputStream >> inputStream.PROPERTY("TillValues") >> 
range.getTillValues();
inputStream >> inputStream.END_BRACKET;
return true;
}

template < typename Values >
bool writeRange(osgDB::OutputStream& outputStream, 
osgPlanetCore::Range< Values > const& range)
{
outputStream << outputStream.BEGIN_BRACKET << std::endl;
outputStream << outputStream.PROPERTY("FromValues") << 
range.getFromValues() << std::endl;
outputStream << outputStream.PROPERTY("TillValues") << 
range.getTillValues() << std::endl;
outputStream << outputStream.END_BRACKET << std::endl;
return true;
}





In a wrapper I call

Code:

ADD_USER_SERIALIZER(GeographicRange);




Basically serialisation should write / read two vectors indicating a lower and 
a higher limit of a geodetic range.

The ASCII output looks like:

GeographicRange 
{
FromValues -135 40.9799 -1 
TillValues -90 66.5133 1 
}

Which seems to be fine.

The XML output looks like:

  < FromValues attribute="-135 40.9799 -1" >
< TillValues attribute="-90 66.5133 1" >
 < /TillValues >
  < /FromValues >

Which is not really the same. Besides the fact that "GeographicRange" is gone 
completely.

How do I make the output of both versions the same?

Cheers,
Hartwig

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





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


Re: [osg-users] Normal Mapping using Dynamic Cubemap

2017-12-27 Thread Sebastian Messerschmidt


Hi Rômulo,

I already tried to describe the building-blocks for the way:

1. Render to FBO with MRT (see osgmultiplerendertargets example for 
this). The MRT/FBO-attachments should be your color, normal and depth.
You'll need to use a shader that writes the correct information to the 
correct buffers. That's all in the example. Basically that's deferred 
rendering's approach. An example by Michael Kapelko can be found here: [0].


2. Once you understand how to render to one FBO you can use your 
approach to render to the individual faces of your cubemap.


You need to learn the basics. Pasting source code might not attract a 
lot of attention, so please try to follow my hints before asking the 
question over and over.



[0] 
https://bitbucket.org/kornerr/osg-deferred-shading/src/5b8555059707?at=default



Cheers
Sebastian



Am 26.12.2017 um 18:17 schrieb Rômulo Cerqueira:

Hi Roberto and Sebastian,

sorry for my duplicated post. I need to render the depth/normal surface to 
texture of reflected objects by cube maps.

Until this moment, I got the depth data. Could you help me to get the normal 
data too (as single channel data). My current code follows below:

C++ code:

Code:

// OSG includes
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 
#include 

// C++ includes
#include 

#define SHADER_PATH_FRAG "normal_depth_map/shaders/normalDepthMap.frag"
#define SHADER_PATH_VERT "normal_depth_map/shaders/normalDepthMap.vert"

#define BOOST_TEST_MODULE "DynamicCubeMap_test"

using namespace osg;

unsigned int numTextures = 6;

enum TextureUnitTypes {
 TEXTURE_UNIT_DIFFUSE,
 TEXTURE_UNIT_NORMAL,
 TEXTURE_UNIT_CUBEMAP
};

osg::ref_ptr _create_scene() {
 osg::ref_ptr scene = new osg::Group;

 osg::ref_ptr geode = new osg::Geode;
 scene->addChild(geode.get());

 const float radius = 0.8f;
 const float height = 1.0f;
 osg::ref_ptr shape;

 // sphere
 shape = new osg::ShapeDrawable(new osg::Sphere(osg::Vec3(-3.0f, 0.0f, 
0.0f), radius));
 shape->setColor(osg::Vec4(0.6f, 0.8f, 0.8f, 1.0f));
 geode->addDrawable(shape.get());

 // box
 shape = new osg::ShapeDrawable(new osg::Box(osg::Vec3(3.0f, 0.0f, 0.0f), 2 
* radius));
 shape->setColor(osg::Vec4(0.4f, 0.9f, 0.3f, 1.0f));
 geode->addDrawable(shape.get());

 // cone
 shape = new osg::ShapeDrawable(new osg::Cylinder(osg::Vec3(0.0f, 0.0f, 
-3.0f), radius, height));
 shape->setColor(osg::Vec4(1.0f, 0.3f, 0.3f, 1.0f));
 geode->addDrawable(shape.get());

 // cylinder
 shape = new osg::ShapeDrawable(new osg::Box(osg::Vec3(0.0f, 0.0f, 3.0f), 
2* radius));
 shape->setColor(osg::Vec4(0.8f, 0.8f, 0.4f, 1.0f));
 geode->addDrawable(shape.get());

 return scene;
}

osg::NodePath createReflector() {
 Geode* node = new Geode;
 const float radius = 0.8f;
 ref_ptr hints = new TessellationHints;
 hints->setDetailRatio(2.0f);
 ShapeDrawable* shape = new ShapeDrawable(new Sphere(Vec3(0.0f, 0.0f, 
0.0f), radius * 1.5f), hints.get());
 shape->setColor(Vec4(0.8f, 0.8f, 0.8f, 1.0f));
 node->addDrawable(shape);

 osg::NodePath nodeList;
 nodeList.push_back(node);

 return nodeList;
}

class UpdateCameraAndTexGenCallback : public osg::NodeCallback
{
 public:

 typedef std::vector< osg::ref_ptr >  CameraList;

 UpdateCameraAndTexGenCallback(osg::NodePath& reflectorNodePath, 
CameraList& Cameras):
 _reflectorNodePath(reflectorNodePath),
 _Cameras(Cameras)
 {
 }

 virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
 {
 // first update subgraph to make sure objects are all moved into 
position
 traverse(node,nv);

 // compute the position of the center of the reflector subgraph
 osg::Matrixd worldToLocal = 
osg::computeWorldToLocal(_reflectorNodePath);
 osg::BoundingSphere bs = _reflectorNodePath.back()->getBound();
 osg::Vec3 position = bs.center();

 typedef std::pair ImageData;
 const ImageData id[] =
 {
 ImageData( osg::Vec3( 1,  0,  0), osg::Vec3( 0, -1,  0) ), // 
+X
 ImageData( osg::Vec3(-1,  0,  0), osg::Vec3( 0, -1,  0) ), // 
-X
 ImageData( osg::Vec3( 0,  1,  0), osg::Vec3( 0,  0,  1) ), // 
+Y
 ImageData( osg::Vec3( 0, -1,  0), osg::Vec3( 0,  0, -1) ), // 
-Y
 ImageData( osg::Vec3( 0,  0,  1), osg::Vec3( 0, -1,  0) ), // 
+Z
 ImageData( osg::Vec3( 0,  0, -1), osg::Vec3( 0, -1,  0) )  // 
-Z
 };

 for(unsigned int i = 0; i < 6 && i < _Cameras.size(); ++i) {
 osg::Matrix localOffset;
 
localOffset.makeLookAt(position,position+id[i].first,id[i].second);

 osg::Matrix viewMatrix = worldToLocal*localOffset;

   

[osg-users] [build] Building OpenSceneGraph Windows

2017-12-27 Thread Stefan Waldegger
Hi,

this is my first post here and I have already searched in this Forum and on 
google but I did not get the answer which is handling my problem.

So I have read a lot about OSG in the internet and no I want to give it a try.
I have downloaded OSG 3.4.1 from the official homepage.

Then I unzipped it and put it to a convinient place and had a look into it. I 
found the sourcecode and some makefiles in the folder.

>From my experiences using Ubuntu and other Unix distibutions I know how easy 
>this normally is, just call make and a big batch is being executed and voila, 
>all the .so and .a files are here and everybody is happy.

But now I am on windows. Windows 10 to be honest.

I am using Code::Blocks as IDE and MinGW compiler. Downloaded with MinGW_get. 
So it is not that comes with Code::Blocks.

Also I downloaded CMake for windows with the Gui.
Then I started the CMake gui and on the first glance it all looked very easy. 

I entered the path of OSG as source and the same path as destnation, clicked on 
configure, chose MinGW as compiler, clicked ok.

Aaaand then. Like 20 messageboxes are popping up in seria telling me that dll 
files are missing libisl-15.dll, libmingwex-0.dll, libiconv-2.dll, 
libgmp-10.dll,  and much more. And naturally CMake finishes wihtout having 
done anything in the end.

It is this messagebox wich comes when you want to try to sart a program the the 
dll is missing. But the funny thing is, when I look in the MinGW\bin folder, 
all the dlls are there. It is also the first time I am using CMake in windows, 
so I dont have any experience here.

Do you know this issue, is there a solution?

Thank you all for your support in advance.

Merry Christmas

Cheers,
Stefan

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





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


[osg-users] how to get the VertexArray of the Group Node

2017-12-27 Thread Mouming Ning
Hi,

I have an osgb data. It has several levels,which are PagedLOD,Group and Geode. 
Now I want to get the vertex data of the PagedNode and Group Node ,anyone know 
the solution??

Please ~~

Thank you!

Cheers,
Mouming

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





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