[osg-users] wrong vertex attribute values when using setPrimitiveSet(...)

2007-11-25 Thread Daniel Holz
hi everybody,

i implemented an algorithm which generates tracks, left behind by a car 
which drives on a terrain. the tracks are graphically represented by 
arbitrary primitiveSets (triangles, quads, polygons). to prevent the 
system from crashing when out of memory (driving for several hours, 
continously generating track polygons) i used the primitiveSetList in 
the osg::Geometry object like a queue, inserting newly created 
primitiveSets at position 0 (osg::Geometry::setPrimitiveSet(0, polygon)) 
when maxNumPolygons is reached. a simple queue.
everything worked fine, but when i decided to associate an array of 
vertex attributes with the vertices (storing the current frame number 
for each vertex which is created and using this information to create a 
fade out effect for the tracks in a vertex shader) i got wrong vertex 
attribute values when the polygon queue was filled. all the other values 
like texture coordinates, and vertex positions are fine.
in contrary when using no polygon queue (just pushing the new polygons 
into the vector) the vertex attribute values are correct.
could there be a problem with some kind of caching of the vertex 
attributes? i also use an array of texture coordinates with new values 
inserted every frame and the values are always correct. i don't get it.
perhaps somebody experienced a similar problem and can help me.

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


Re: [osg-users] Creating shapes using Geometry

2007-11-25 Thread Daniel Holz

hi,
the class DrawElementsUInt is defined in the file osg/PrimitiveSet.cpp.

hope this helps,
daniel

Renan Mendes wrote:

Hi, Jean-Sébastien.

 I've read the Tutorial and while compiling, there has been 
detected that I don't have the osg::DrawElementsUInt in my computer. 
Would you mind attaching this file in your next email. I really have 
no idea why it hasn't come along with the other library files...


Well, besides that I've got another question. In the 
above-mentioned tutorial, there is a part of the example code in which 
the programmer uses the DrawElementsUInt class to somehow unite the 
group of points for each face. Will I need to instantiate one object 
from DrawElementUInt for each of the awful lot of faces I have in our 
approximation of a sphere? Is the a simpler way to do that? And what 
about changing the color of the shape, does it have to be as laborious 
as it's taught in that Tutorial?


Thanks.

   Renan M Z Mendes


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



/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 
 *
 * This library is open source and may be redistributed and/or modified under  
 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 
 * (at your option) any later version.  The full license is in LICENSE file
 * included with this distribution, and on the openscenegraph.org website.
 * 
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
 * OpenSceneGraph Public License for more details.
*/
#include 
#include 
#include 
#include 

using namespace osg;

unsigned int PrimitiveSet::getNumPrimitives() const
{
switch(_mode)
{
case(POINTS): return getNumIndices();
case(LINES): return getNumIndices()/2;
case(TRIANGLES): return getNumIndices()/3;
case(QUADS): return getNumIndices()/4;
case(LINE_STRIP):
case(LINE_LOOP):
case(TRIANGLE_STRIP):
case(TRIANGLE_FAN):
case(QUAD_STRIP):
case(POLYGON): return 1;
}
return 0;
}

void DrawArrays::draw(State&, bool) const 
{
glDrawArrays(_mode,_first,_count);
}

void DrawArrays::accept(PrimitiveFunctor& functor) const
{
functor.drawArrays(_mode,_first,_count);
}

void DrawArrays::accept(PrimitiveIndexFunctor& functor) const
{
functor.drawArrays(_mode,_first,_count);
}

unsigned int DrawArrayLengths::getNumPrimitives() const
{
switch(_mode)
{
case(POINTS): return getNumIndices();
case(LINES): return getNumIndices()/2;
case(TRIANGLES): return getNumIndices()/3;
case(QUADS): return getNumIndices()/4;
case(LINE_STRIP):
case(LINE_LOOP):
case(TRIANGLE_STRIP):
case(TRIANGLE_FAN):
case(QUAD_STRIP):
case(POLYGON): return size();
}
return 0;
}

void DrawArrayLengths::draw(State&, bool) const
{
GLint first = _first;
for(vector_type::const_iterator itr=begin();
itr!=end();
++itr)
{
glDrawArrays(_mode,first,*itr);
first += *itr;
}
}

void DrawArrayLengths::accept(PrimitiveFunctor& functor) const
{
GLint first = _first;
for(vector_type::const_iterator itr=begin();
itr!=end();
++itr)
{
functor.drawArrays(_mode,first,*itr);
first += *itr;
}
}

void DrawArrayLengths::accept(PrimitiveIndexFunctor& functor) const
{
GLint first = _first;
for(vector_type::const_iterator itr=begin();
itr!=end();
++itr)
{
functor.drawArrays(_mode,first,*itr);
first += *itr;
}
}

unsigned int DrawArrayLengths::getNumIndices() const
{
unsigned int count = 0;
for(vector_type::const_iterator itr=begin();
itr!=end();
++itr)
{
count += *itr;
}
return count;
}

DrawElementsUByte::~DrawElementsUByte()
{
releaseGLObjects();
}

void DrawElementsUByte::draw(State& state, bool useVertexBufferObjects) const 
{
if (useVertexBufferObjects)
{
const ElementBufferObject* ebo = getElementBufferObject();
state.bindElementBufferObject(ebo);
if (ebo)
{
glDrawElements(_mode, size(), GL_UNSIGNED_BYTE, 
getElementBufferObjectOffset());
}
else
{
glDrawElements(_mode, size(), GL_UNSIGNED_BYTE, &front());
}
}
else 
{
glDrawElements(_mode, size(), GL_UNSIGNED_BYTE, &front());
}
}

void DrawElementsUByte::accept(PrimitiveFunctor& functor) const
{
if (!empty()) functor.drawElements(_mode,size(),&front());
}

void DrawElementsUByte::accept(PrimitiveIndexFunctor& functor) const
{
if (!empty()

[osg-users] wrong vertex attributes in vertex shader

2007-11-26 Thread Daniel Holz
hi everybody,

i have a problem when reading the values of user-defined vertex 
attributes in the vertex shader.

THE SITUATION

i implemented an algorithm which generates tracks, left behind by a car 
which drives on a terrain.
the track of one wheel is logically represented in the following way:

1. an osg geometry:
- osg::ref_ptr trackGeom, carries the primitiveSetList 
consisting of arbitrary primitiveSets (triangles, quads, polygons), 
which are built from vertices in the associated vertex array (see below).

2. several binded arrays:
- osg::ref_ptr vertices :
...
trackGeom->setVertexArray(vertices.get());
...
- osg::ref_ptr colors :
...
trackGeom->setColorArray(colors.get());
trackGeom->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
...
- osg::ref_ptr texCoords :
...
trackGeom->setTexCoordArray(0, texCoords.get());
...

to prevent the system from crashing when out of memory (driving for 
several hours, continously generating track polygons) i used the object 
'trackGeom' like a queue:
inserting newly created primitiveSets at position 0 ( 
trackGeom->setPrimitiveSet(0,polygon) ) when maxNumPolygons is reached. 
a simple queue.

everything worked fine.

but then i decided to implement a fade out effect of the tracks, using 
my own vertex shader:

( the idea, for better understanding:
the idea was to associate a vertex attribute array with the vertex 
array, for each vertex storing the number of the frame in which it was 
created and obtain the 'relative frame age' of the vertex by comparing 
the number of the current frame with the number of the 'frame of 
creation'. the obtained 'relative frame age' is then used to calculate 
the alpha value of the vertex in the vertex shader. )

3. the associated vertex attribute array:
- osg::ref_ptr frameTime :
...
trackGeom->setVertexAttributeArray(9, frameTime.get());
trackGeom->setVertexAttribuBinding(9, osg::Geometry::BIND_PER_VERTEX);
...

THE PROBLEM

as soon as the polygon queue is filled i get wrong vertex attribute 
values, apparently. the other values like texture coordinates and color 
are fine.
in contrary when using NO polygon queue (just pushing the new polygons 
into 'trackGeom' with ...->addPrimitiveSet(polygon)) the vertex 
attribute values are correct.

could there be a problem with some kind of caching of the vertex attributes?
perhaps somebody experienced a similar problem and can help me.

thanks in advance,
daniel

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


Re: [osg-users] help: preload IVE models

2007-11-28 Thread Daniel Holz
hi han,

why don't you scale the texture permanently to sizes like 512x512?

cheers,
daniel

ZHOUXIAO HAN wrote:
>
>
> Hey experts,
>  
> Does anybody know how to preload IVE models? I have a large set of
> models in my app and it takes while to resize the textures before
> retendering. So i am wondering if i could preload all the models
> before rendering.
>  
> Thanks
>  
> Charles
>
>
> 
> Your smile counts. The more smiles you share, the more we donate. Join 
> in! 
> 
>
> ___
> 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


[osg-users] problems compiling osgCal with osg 2.2

2007-11-28 Thread Daniel Holz
hi everybody,

is there anybody who succeeded in compiling osgCal with osg 2.2 ?

i have the following problem when compiling it in msvc8:

1> \include\osgCal/SubMesh(50) : error C2259: 
'osgCal::SubMesh' : cannot instantiate abstract class
1>due to following members:
1>'void osg::Drawable::drawImplementation(osg::RenderInfo &) 
const' : is abstract
1> \osg\include\osg/Drawable(425) : see declaration of 
'osg::Drawable::drawImplementation'


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


Re: [osg-users] problems compiling osgCal with osg 2.2

2007-11-28 Thread Daniel Holz
hi,

ok, got it myself.
the argument of the method drawImplementation changed in osg 2.2 
compared to prior versions (don't know which one in particular).
in osgCal the method drawImplementation(osg::RenderInfo &renderInfo) 
should be overwritten but per default it is the method 
drawImplementation(osg::StateSet &state).

fixed it and it compiles now.

sorry for annoying the community :)

cheers,
daniel

Daniel Holz wrote:
> hi everybody,
>
> is there anybody who succeeded in compiling osgCal with osg 2.2 ?
>
> i have the following problem when compiling it in msvc8:
>
> 1> \include\osgCal/SubMesh(50) : error C2259: 
> 'osgCal::SubMesh' : cannot instantiate abstract class
> 1>due to following members:
> 1>'void osg::Drawable::drawImplementation(osg::RenderInfo &) 
> const' : is abstract
> 1> \osg\include\osg/Drawable(425) : see declaration of 
> 'osg::Drawable::drawImplementation'
>
>
> cheers,
> daniel
> ___
> 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


Re: [osg-users] 64-bit OSG

2007-11-29 Thread Daniel Holz
hi,

what are the benefits of using a 64bit build of osg. as far as i know at 
least the floating point precision is not higher than with 32bit, or am 
i wrong?

cheers,
daniel


Robert Osfield wrote:
> Hi Robert,
>
> The OSG support 64 bit builds on Irix, Solaris, Linux, and even
> Windows..  I'm not sure about FreeBSD, Aix and HP-UX but this probably
> suppport 64 bit as well.
>
> Robert.
>
> Robert.
>
> On Nov 28, 2007 12:22 PM, Robert Balfour <[EMAIL PROTECTED]> wrote:
>   
>> Does OSG support Windows 64-bit architectures, and if so has anyone been
>> using OSG in 64-bit MSWindows successfully?  Are there any pitfalls to
>> avoid?
>>
>> Thanks.
>>
>> Bob.
>> --
>> Robert E. Balfour, Ph.D.
>> Exec. V.P. & CTO,  BALFOUR Technologies LLC
>> 960 South Broadway, Suite 108, Hicksville NY 11801
>> Phone: (516)513-0030  Fax: (516)513-0027  email: [EMAIL PROTECTED]
>> ___
>> 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
>   

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


Re: [osg-users] problems compiling osgCal with osg 2.2

2007-11-30 Thread Daniel Holz
hi vladimir,

oh, right. thanks!
i trusted the "latest build" link which was pretty out of date :)

thanks for the hint!

cheers,
daniel

Vladimir Shabanov wrote:
> Seems that you use old version of osgCal. You can get more recent
> version from svn repository as described at
> http://osgcal.sourceforge.net/
>
> 2007/11/29, Daniel Holz <[EMAIL PROTECTED]>:
>   
>> hi,
>>
>> ok, got it myself.
>> the argument of the method drawImplementation changed in osg 2.2
>> compared to prior versions (don't know which one in particular).
>> in osgCal the method drawImplementation(osg::RenderInfo &renderInfo)
>> should be overwritten but per default it is the method
>> drawImplementation(osg::StateSet &state).
>>
>> fixed it and it compiles now.
>>
>> sorry for annoying the community :)
>>
>> cheers,
>> daniel
>>
>> Daniel Holz wrote:
>> 
>>> hi everybody,
>>>
>>> is there anybody who succeeded in compiling osgCal with osg 2.2 ?
>>>
>>> i have the following problem when compiling it in msvc8:
>>>
>>> 1> \include\osgCal/SubMesh(50) : error C2259:
>>> 'osgCal::SubMesh' : cannot instantiate abstract class
>>> 1>due to following members:
>>> 1>'void osg::Drawable::drawImplementation(osg::RenderInfo &)
>>> const' : is abstract
>>> 1> \osg\include\osg/Drawable(425) : see declaration of
>>> 'osg::Drawable::drawImplementation'
>>>
>>>
>>> cheers,
>>> daniel
>>> ___
>>> 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
>>
>> 
> ___
> 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


Re: [osg-users] Getting world coord bounding box

2007-12-01 Thread Daniel Holz
hi,

don't you have to multiply the matrix from the left side with the 
vector, like this:
M * x = x',
whereas M is your 'WorldCoordsMatrix', x is your local BBox vector and 
x' is the same in world coords.

hope this helps.

daniel

Siddharth Palaniappan wrote:
> Hi osg users,
>
> I'm currently using openscenegraph for my class project to simulate traffic. 
> I have a problem in that , i need to find collision detection between 
> consecutive cars and stop the car if  there is a collision.  I have followed 
> the osgExample- for animation. I have used an animationpath and 
> animationpathcallback and i have implemented my own spline interpolation for 
> the car to traverse on a spline. I tried to get the world coordinate of the 
> bounding box like this..
>
> * i have a class Vehicle that stores the node to which an openflight model is 
> read into.
>
> * the leaf node is the node having the vehicle, the parent node of this node 
> is a transformation node which has an animationpathcallback set to, and this 
> also has a parent node to initially set the location and orientation, (just 
> like in the osgExample animation).
>
> * i have a node visitor that traverses parents..so it goes from the current 
> node to the root concatenating all the world coordinates.
>
> * then i get the local bounding box of the node and get the minimum and 
> maximum and multiply the world coord matrix with these points to form a new 
> min and max point and create a new bounding box. I do this for every two node 
> to check the intersection of two consecutive nodes. 
>
>
> //getWorldCoords() - forwards to a nodevisitor to get world coords matrix.
> osg::Matrixd* WorldCoordsMatrix = getWorldCoords(this->m_Vehicle) ;
> osg::BoundingBox VehicleBBox ;
>
> VehicleBBox.expandBy(m_Vehicle->getBound()) ;
>
> //Convert the vehicle local coords to world coordinates.
> osg::Vec3f MinPt(VehicleBBox.xMin() , VehicleBBox.yMin() , 
> VehicleBBox.zMin()) ;
> osg::Vec3f MaxPt(VehicleBBox.xMax() , VehicleBBox.yMax() , 
> VehicleBBox.zMax()) ;
>
> osg::Vec3f NewMinPt , NewMaxPt ;
> NewMinPt = MinPt * (*WorldCoordsMatrix) ;
> NewMaxPt = MaxPt * (*WorldCoordsMatrix) ;
>
> this->m_VehicleBoundingBox = new osg::BoundingBox(NewMinPt , NewMaxPt) ;
>
> I am not getting correct results. I get that the bounding boxes dont 
> intersect at all or sometimes intersect at odd places. Please let me know if 
> i'm doing something stupid or if i my understanding of anything wrong. 
>
>
> Thank you,
>
> Yours Sincerely,
>
> Siddharth
>
>
>
>
>
>
>   
> 
> Never miss a thing.  Make Yahoo your home page. 
> http://www.yahoo.com/r/hs
> ___
> 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


Re: [osg-users] Getting world coord bounding box

2007-12-01 Thread Daniel Holz
hi siddharth,

i just started being confused reading the link you sent me when i got 
this new email of yours :)
if i am in a situation like this what i usually do is i draw what i 
can't see. in your case it is the bounding box PRIOR to your 
transformation to world coordinates and the one AFTER transforming. just 
render to boxes or render spheres in two different colors marking the 
positions of the corners.
i am sure, having something visually, you will be able to figure out the 
problem.

cheers,
daniel

Siddharth Palaniappan wrote:
> Hi Daniel,
>
> Sorry for the misunderstanding...yes you're right, it has to be done on the 
> left side. But i still dont get any valid results. Can you suggest how i can 
> test if the world coordinates of the box after multiplication is correct or 
> not?
>
> Thank you,
>
> Siddharth
>
> - Original Message 
> From: Siddharth Palaniappan <[EMAIL PROTECTED]>
> To: OpenSceneGraph Users 
> Sent: Saturday, December 1, 2007 2:41:19 PM
> Subject: Re: [osg-users] Getting world coord bounding box
>
>
> Hi daniel,
>
> I read thru this at the osg site :
>
> http://www.openscenegraph.org/projects/osg/wiki/Support/Maths/MatrixTransformations
>
> In the end , robert says ways are defined ... i initially multiplied
>  the matrix on the left side. But after reading this i changed it...am i
>  wrong ?
>
> Siddharth
>
> - Original Message 
> From: Daniel Holz <[EMAIL PROTECTED]>
> To: OpenSceneGraph Users 
> Sent: Saturday, December 1, 2007 2:35:52 PM
> Subject: Re: [osg-users] Getting world coord bounding box
>
>
> hi,
>
> don't you have to multiply the matrix from the left side with the 
> vector, like this:
> M * x = x',
> whereas M is your 'WorldCoordsMatrix', x is your local BBox vector and 
> x' is the same in world coords.
>
> hope this helps.
>
> daniel
>
> Siddharth Palaniappan wrote:
>   
>> Hi osg users,
>>
>> I'm currently using openscenegraph for my class project to simulate
>> 
>  traffic. I have a problem in that , i need to find collision detection
>  between consecutive cars and stop the car if  there is a collision.  I
>  have followed the osgExample- for animation. I have used an
>  animationpath and animationpathcallback and i have implemented my own
>  spline
>  interpolation for the car to traverse on a spline. I tried to get the
>  world
>  coordinate of the bounding box like this..
>   
>> * i have a class Vehicle that stores the node to which an openflight
>> 
>  model is read into.
>   
>> * the leaf node is the node having the vehicle, the parent node of
>> 
>  this node is a transformation node which has an animationpathcallback
>  set
>  to, and this also has a parent node to initially set the location and
>  orientation, (just like in the osgExample animation).
>   
>> * i have a node visitor that traverses parents..so it goes from the
>> 
>  current node to the root concatenating all the world coordinates.
>   
>> * then i get the local bounding box of the node and get the minimum
>> 
>  and maximum and multiply the world coord matrix with these points to
>  form a new min and max point and create a new bounding box. I do this
>  for
>  every two node to check the intersection of two consecutive nodes. 
>   
>> //getWorldCoords() - forwards to a nodevisitor to get world
>> 
>  coords matrix.
>   
>> osg::Matrixd* WorldCoordsMatrix = getWorldCoords(this->m_Vehicle)
>> 
>  ;
>   
>> osg::BoundingBox VehicleBBox ;
>>
>> VehicleBBox.expandBy(m_Vehicle->getBound()) ;
>>
>> //Convert the vehicle local coords to world coordinates.
>> osg::Vec3f MinPt(VehicleBBox.xMin() , VehicleBBox.yMin() ,
>> 
>  VehicleBBox.zMin()) ;
>   
>> osg::Vec3f MaxPt(VehicleBBox.xMax() , VehicleBBox.yMax() ,
>> 
>  VehicleBBox.zMax()) ;
>   
>> osg::Vec3f NewMinPt , NewMaxPt ;
>> NewMinPt = MinPt * (*WorldCoordsMatrix) ;
>> NewMaxPt = MaxPt * (*WorldCoordsMatrix) ;
>>
>> this->m_VehicleBoundingBox = new osg::BoundingBox(NewMinPt ,
>> 
>  NewMaxPt) ;
>   
>> I am not getting correct results. I get that the bounding boxes dont
>> 
>  intersect at all or sometimes intersect at odd places. Please let me
>  know if i'm doing something stupid or if i my understanding of
>  anything
>  wrong. 
>   
>> Thank you,
>>
>> Yours Sincerely,
>>
>> Siddharth
>>
>>
>>
>>
>>
>>
>>

Re: [osg-users] Getting world coord bounding box

2007-12-02 Thread Daniel Holz
hi,

i can't tell you much about AnimationPath objects since i never used 
them but a short glimpse on the api reference tells me that you can 
easily get a transformation matrix for any point in time of the running 
animation by using the method osg::AnimationPath::getMatrix(...).
(cf. 
http://www.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a01017.html)

another way is using a ControlPoint in your TimeControlPointMap:
osg::AnimationPath::ControlPoint::getMatrix(...)
(cf. 
http://www.openscenegraph.org/documentation/OpenSceneGraphReferenceDocs/a01018.html)

anyway, since you control the hierarchy of the scenegraph you don't need 
a nodevisitor to find the transform of the vehicle in world cords. you 
KNOW how the transformations are done:

your scenegraph probably looks like this:

'rootNode'
|
osg::MatrixTransform 'vehicleAnimationX' (with 
vehicleNode->setUpdateCallback(new osg::AnimationPathCallback(...))
|
'vehicleX'

...whereas X refers to one of your vehicles in the scene, meaning that 
you have ONE osg::MatrixTransform node for each vehicle.

then for every time step you obtain your world transform matrix for 
vehicle X by multiplying all the matrices of the scenegraph nodes 
"bottom-up" and "right-to-left" like this:

transform of  'rootNode' * transform of 'vehicleAnimationX' * transform 
of 'vehicleX'

probably the rootNode transformation is the identity and the vehicle has 
no transform node at all so that the transformation in world coords is 
simply the transformation of 'vehicleAnimation'!

i hope this helps.
if not, try looking at this example: 
http://osgcvs.no-ip.com/osgarchiver/archives/February2005/0270.html

cheers,
daniel

Siddharth Palaniappan wrote:
> Hi Daniel,
>
> I tried out a seperate code example and it did work. But i couldnt get
>  it working for my project. Like i previously mentioned i needed to get
>  the world coordinates of the boundingboxes of the loaded openflight
>  models and if the bounding boxes intersected , i wanted to stop the
>  vehicle on the animation path. The world coordinates matrix that i receive
>  each time, seems to be correct as i checked the position of the
>  ControlPointMap by using the write() in the AnimationPath class. I am now 
> trying
>  to manually get the worldcoordinates and keep altering a geode and
>  attach it to the root node to see if the transformation made to the local
>  coordinates do infact match. 
>
> Is there any code snippet around that tells how to get the world
>  coordinates  for a model on an  AnimationPath? To get the world coordinates
>  this is what i did - 
>
> class getWorldCoordOfNodeVisitor : public osg::NodeVisitor 
> {
> public:
>getWorldCoordOfNodeVisitor():
>   osg::NodeVisitor(NodeVisitor::TRAVERSE_PARENTS), done(false)
>   {
>  wcMatrix= new osg::Matrixd() ;
>   }
>   virtual void apply(osg::Node &node)
>   {
>  if (!done)
>  {
> if ( 0 == node.getNumParents() ) // no parents
> {
>wcMatrix->set(
>  osg::computeLocalToWorld(this->getNodePath()) ) ;
>done = true ;
> }
> traverse(node) ;
>  }
>   }
>   osg::Matrixd* giveUpDaMat() 
>   {
>  return wcMatrix ;
>   }
> private:
>bool done ;
>osg::Matrix* wcMatrix ;
> } ;
>
> osg::Matrixd* getWorldCoords( osg::Node* node) 
> {
>getWorldCoordOfNodeVisitor* ncv = new getWorldCoordOfNodeVisitor() ;
>if (node && ncv)
>{
>   node->accept(*ncv) ;
>   return ncv->giveUpDaMat() ;
>}
>else
>{
>   return NULL ;
>}
> } 
>
> I have two MatrixTransform node above my vehicle model node. And i use
>  this to get the World Coord transfomation matrix. The first/topmost
>  transformation node is a static node to set the initial position and its
>  child node is another transformation matrix which has an
>  AnimationPathCallback set to(which moves the vehicle on a spline). 
>
> I also see that the animationpathcallback has an update function. Now , does 
> the animationpathcallback automatically update my TransformMatrix to which i 
> have set this as a callback?
>
> Do you think the workflow is correct? Am i missing anything? ANy
>  suggestions?
>
> Thanks for your help...
>
> Siddharth
>
>
>
> - Original Message ----
> From: Siddharth Palaniappan <[EMAIL PROTECTED]>
> To: OpenSceneGraph Users 
> Sent: Saturday, December 1, 2007 2:56:27 PM
> Subject: Re: [osg-users] Getting world coord bounding box
>
>
> Hi daniel,
>
> Yes thats a good idea..I w

Re: [osg-users] Creating shapes using Geometry

2007-12-02 Thread Daniel Holz
hi renan,

i think he meant that you should look at the examples included in the 
osg package.
quote:

"[..]and the examples that come with the OSG  
are a treasure trove of code and information."


cheers,
daniel

Renan Mendes wrote:
> Hey, Jean-Sébastien.
>
> Now I'm asking for that example code you've offered me, if that still 
> stands...  I haven't tried hard enough, to be honest, but I sure have 
> no extra time to deal with this properly right now. Not to mention the 
> guy I work with, which is breathing down my neck... I would appreciate 
> that favor very much.
>
> Thanks.
>
> Renan M Z Mendes
> 
>
> ___
> 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


Re: [osg-users] Creator vs 3D Studo Max

2007-12-05 Thread Daniel Holz
hi,

first of all: the words modeling and creator should not appear in the 
same sentence :). probably you can use creator for cad tasks but thats 
all. the texturing tools are quite ok though...
i would go with a combination of both. using 3dsmax for the model and 
creator to compose everything in a nice hierarchy.
that's all i can say for now.

cheers,
daniel


Loong Hin wrote:
> Hi,
>
> I've a flight simulator project running on OSG 2.2 whereby we need to model a 
> geo-specific airport.
>
> We will need features like creating the airport lighting system, geo-specific 
> buildings, multiple LODs.
>
> We are considering whether to use Multigen Creator or 3D Studio Max to do the 
> job, any advice? Thanks a lot
>
>
> ___
> 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


Re: [osg-users] Two viewer problem

2007-12-06 Thread Daniel Holz
Hi Sashidhar,

some weeks ago somebody had the same problem.
here his mail and the last response:

Hi,

try this:
in groups.google.com

search for this:
osg-users ralph kern screenshot

in google.com
osg-users "Taking a screenshot with"

cheers
jp

maruti borker wrote:
  

> > Can anbody point me to the older mails atleast  :( 
> > 
> > Waiting in anticipation
> > 
> > On Nov 28, 2007 3:06 PM, maruti borker <[EMAIL PROTECTED] 
> > > wrote:
> > 
> > 
> > Hi all ,
> >   I know this question has been asked again and again . But
> > i am sorry i wasnt able to find the previous mails in the archive  
> :(  .
> >   What i want to do is when a user presses some key he
> > should see some 3-4 screenshots of some specific nodes .
> >   So basically i am thinking of doing the following :-
> >-> Set up some dummy cameras
> >-> Bring them near the node ( at some distance )
> >-> Take screenshots and write them in some directory
> >-> Load the images and use it as a texture to a plane
> >-> Display it to the user
> > 
> > So what i did was i took a seperate viewer , and put the scene-data
> > of the viewer to be the node .And then attached a slave camera to
> > the viewer and took a screenshot . But it gave a black image as
> > output .I tried doing frame() too , but that changed the window on
> > which i was working on and also gave a black output. Can somebody
> > help me out ??
> > 
> > And is there a way by which i can just use dummy cameras instead of
> > dummy viewers to take a screenshot ?
> > And how should i place the camera near the node ?
> > 
> > Thanx a lot in advance
> > 
> > -- 
> > Maruti Borker
> > IIIT Hyderabad
> > Website:- http://students.iiit.ac.in/~maruti
> > 
> > Blog:- http://marutiborker.wordpress.com
> >  
> > 
> > 
> > 
> > 
> > -- 
> > --
> > Maruti Borker
> > IIIT Hyderabad
> > Website:- http://students.iiit.ac.in/~maruti 
> > 
> > Blog:- http://marutiborker.wordpress.com
> > 
> > 
> > 
> > 
> > ___
> > osg-users mailing list
> > osg-users@lists.openscenegraph.org
> > 
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> 

  

hope this helps!

cheers,
daniel


Sashidhar Guntury wrote:
> Hi!
>
>  I have this viewer running and on pressing a button, I need 
> to generate an image of the scene as seen from a different angle and 
> position without using the original viewer or changing the viewer 
> position and orientation. How is it possible?
>
>  thanks!
>
> yours
> Sashidhar
> 
>
> ___
> 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


Re: [osg-users] Creator vs 3D Studo Max

2007-12-10 Thread Daniel Holz
Hi Robert,

the points you and others mention are valid, and perhaps I was being too
harsh in my first posting. Both products have their strengths and Creator is
well suited to airport modeling and has unique capabilities for vis-sim
that 3dsmax does not offer.

Cheers,
Daniel

Robert Weldon wrote:
> Daniel
>
> I think you are missing something here. Creator and 3dsmax are both 
> useful. 3dsmax is used  more in gaming and design, but Creator is 
> superior for real-time simulation applications.3dsMax just doesn't 
> have the same focus. E.g., look at airport modeling: Creator has many 
> features that make it an  excellent solution for easily modeling 
> airport models that are detailed and accurate. There is a whole lot of 
> functionality to create accurate lighting systems and geospecific 
> runways automatically from DAFIF data, LODS, etc. There are wizards to 
> make this easy, and I find the interfaces both cleaner and easier to 
> access.
>
> And, as you seem to agree in your second pointt, you can't beat the 
> hierarchical and .flt support in Creator.
>
> robert.
>> hi,
>>
>> first of all: the words modeling and creator should not appear in the 
>> same sentence :). probably you can use creator for cad tasks but thats 
>> all. the texturing tools are quite ok though...
>> i would go with a combination of both. using 3dsmax for the model and 
>> creator to compose everything in a nice hierarchy.
>> that's all i can say for now.
>>
>> cheers,
>> daniel
>>
>>
>> Loong Hin wrote:
>>   
>>> Hi,
>>>
>>> I've a flight simulator project running on OSG 2.2 whereby we need to model 
>>> a geo-specific airport.
>>>
>>> We will need features like creating the airport lighting system, 
>>> geo-specific buildings, multiple LODs.
>>>
>>> We are considering whether to use Multigen Creator or 3D Studio Max to do 
>>> the job, any advice? Thanks a lot
>>>
>>>
>>> ___
>>> 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
>>
>>   
>
> 
>
> ___
> 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


Re: [osg-users] Shader Vertex Problems

2007-12-10 Thread Daniel Holz
Hi Michael,

try using a osg::vec2 instead of a float for your "vertex_shader_attribute".
Recently I had a similar problem. I received wrong values when 
associating a vertex attribute array of floats with a vertex array and 
trying to read the floats in the shader.
Using a vec2 instead and just reading the first component 
(vertex_shader_attribute.x) resolved the issue.

Hope this helps,
Daniel

Schmidt, Michael M wrote:
> Hi,
>  
> I'm getting odd behavior with a vertex shader.  The following 
> pseudo-code snippets do not produce the same results.  Can anyone tell 
> me why?
>  
> Program 1:
>
> //Outside the shader, set a shader attribute to negative offset.
> vertex_shader_attribute = -offset;
> ...
> //Then in the shader, set temp to the attribute.
> temp = vertex_shader_attribute;
>  
>
> Program 2:
>
> //Outside the shader, set a shader attribute to the vertex x minus
> an offset
> vertex_shader_attribute = vertex.x - offset;
> ...
> //Then in the shader, set temp to attribute minus gl_Vertex x.
> temp = vertex_shader_attribute - gl_Vertex.x;
>
>  
> The "temp" should be set to -offset in both cases, but I'm not seeing 
> the same behavior in my app.  The "temp" value is the only thing that 
> changes between programs.
>  
> Is gl_Vertex equal to the vertex passed into geom->setVertexArray()?
>  
> Thanks,
> Mike
> 
>
> ___
> 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


[osg-users] GL_DEPTH_COMPONENT data not clamped to [0, 1] when doing osg::Image::readPixels(...)

2009-03-03 Thread Daniel Holz

Hi everyone,

I am trying to store the Z-Buffer of a subgraph of my scene in an 
osg::Image for later processing,
but the values I obtain are not as expected in the range [0,1] but 
appear to be integer values starting at 0 and going up to about 200.
I am writing the depth buffer to the osg::Image by using 
image->readPixels(0, 0, width, height, GL_DEPTH_COMPONENT, GL_FLOAT);

The osg code which is executed is:

   void Image::readPixels(int x,int y,int width,int height,GLenum 
format,GLenum type)

   {
   allocateImage(width,height,1,format,type);

   glPixelStorei(GL_PACK_ALIGNMENT,_packing);

   glReadPixels(x,y,width,height,format,type,_data);
   }

And according to the OpenGL reference manual 
(http://www.opengl.org/sdk/docs/man/xhtml/glReadPixels.xml) the values 
written to the buffer "_data" should be of type float and in the range 
[0,1] which they are not for me.


I am wondering if I am doing something wrong.
In the following I posted a short version of my implementation, which is 
based on the osgprerender example.


First I set up a render to texture pass:
   ...
   // texture to render to
   osg::Texture* texture = 0;
   osg::Texture2D* texture2D = new osg::Texture2D;
   texture2D->setTextureSize(tex_width, tex_height);
   texture2D->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
   texture2D->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
   // set up texture for z-buffer values
   texture2D->setInternalFormat(GL_DEPTH_COMPONENT);
   texture = texture2D;

   // attach an image to the texture.
   // this allows us to modify the image data before it is being 
rendered to the quad

   osg::Image* image = new osg::Image;
   texture2D->setImage(image);
   ...

Then I create a second camera as copy of the main camera which renders 
to the above texture.


   ...
   // obtain main camera
   osg::Camera* pCamera = ...
   osg::Camera* pCamCopy = new osg::Camera;
   // set update callback to update the copied camera's view and 
projection matrix
   pCamCopy->setPreDrawCallback(new UpdateCamCallback(pCamera)); // 
just keeps the copied and the main camera aligned
  
   // set the clear mask. -> just the depth buffer is cleared.

   pCamCopy->setClearMask(GL_DEPTH_BUFFER_BIT);
   // set the color mask. -> since we do not want any color information 
to be written we can set all bits to zero.

   pCamCopy->setColorMask(new osg::ColorMask(0,0,0,0));
  
   // set up projection.

   pCamCopy->setProjectionMatrix(pCamera->getProjectionMatrix());
   // set view
   pCamCopy->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
   pCamCopy->setViewMatrix(pCamera->getViewMatrix());
   // set viewport
   pCamCopy->setViewport(0,0,tex_width,tex_height);

   // set the camera to render before the main camera.
   pCamCopy->setRenderOrder(osg::Camera::PRE_RENDER);
   // tell the camera to use OpenGL frame buffer object where supported.
   
pCamCopy->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);

   // attach the texture and use it as the depth buffer
   pCamCopy->attach(osg::Camera::DEPTH_BUFFER, texture);

   // add sub graph to camera for rendering
   pCamCopy->addChild(subGraph);
   // add camera to scene
   pRoot->addChild(pCamCopy)

Finally I set a post draw callback to the copied camera, where the post 
processing of the depth buffer should be performed.
There I call osg::Image::readPixels(...) to copy the depth buffer data 
from the gpu to the image but the obtained data does not seem to be correct.
  
   // set post processing callback
   pCamCopy->setPostDrawCallback(new FilterImageCallback(image, 
tex_width, tex_height));


The Code for the callback is as follows:

struct FilterImageCallback : osg::Camera::DrawCallback
{
   FilterImageCallback(osg::Image* pImage, int width, int height)
   :   m_pImage(pImage),
   m_width(width),
   m_height(height)
   {}
  
   void operator () (osg::RenderInfo& renderInfo) const

   {
   m_pImage->readPixels(0, 0, m_width, m_height, 
GL_DEPTH_COMPONENT, GL_FLOAT);


   // apply post processing here:

   // test: obtain first pixel's z value and convert to float.
   float z = (float) (m_pImage->data())[0];
   // Problem: z-value is not in range [0, 1] but appears to be 
0,1,2, etc. It is 0 for areas where the z-buffer is clear, i.e. z-value 
corresponds to "infinity".

   }

private:
   osg::Image* m_pImage;
   int m_width;
   int m_height;
};

I can't find the mistake.
Any help is much appreciated!

Cheers and Thank you
Daniel




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


[osg-users] Can't write to ALPHA component with custom fragment shader in RTT pass

2009-03-08 Thread Daniel Holz

Hi everyone,

I have trouble with a render to texture pass, where I try to write to 
the RGB and ALPHA components of an attached RGBA texture in a custom 
fragment shader.
Writing to the RGB components works, but gl_FragColor.a = ... does not 
have any effect at all. The ALPHA component will always result in the 
clear color's alpha component.
Also trying to do gl_FragColor = vec4(...,...,...,...) sets the RGB 
values correctly but the ALPHA stays the same.


I am setting up my texture to render to as follows:

  osg::Texture2D texture2D = new osg::Texture2D;
  texture2D->setTextureSize(screen_width, screen_height);
  texture2D->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
  texture2D->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
  texture2D->setBorderColor(osg::Vec4(1.0,1.0,1.0,1.0));
  texture2D->setWrap(osg::Texture2D::WRAP_S, 
osg::Texture2D::CLAMP_TO_BORDER);
  texture2D->setWrap(osg::Texture2D::WRAP_T, 
osg::Texture2D::CLAMP_TO_BORDER);

  texture2D->setInternalFormat(GL_RGBA32F_ARB);

I am rendering to a screen aligned quad (osg::Geode* quadGeode) where I 
activate GL_BLEND (I thought this might be necessary to actually be able 
to write to gl_FragColor.a in the fragment shader):

   osg::Geode* quadGeode = ... create screen aligned quad here ...
  osg::StateSet* stateset = quadGeode->getOrCreateStateSet();
  // deactivate lighting for faster processing
  stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
  // activate blending to be able to write to gl_FragColor.a
  stateset->setMode(GL_BLEND, osg::StateAttribute::ON);

And the camera is set up as follows:

  osg::Camera* pCamPass = new osg::Camera;
  pCamPass->setClearMask(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  pCamPass->setColorMask(new osg::ColorMask(1,1,1,1));
  pCamPass->setClearColor(osg::Vec4(1.0,1.0,1.0,1.0));
  pCamPass->setViewport(0, 0, screen_width, screen_height);
  pCamPass->setReferenceFrame(osg::Camera::ABSOLUTE_RF);
  pCamPass->setProjectionMatrixAsOrtho2D(0,1,0,1);
  pCamPass->setViewMatrix(osg::Matrix::identity());
  // tell the camera to use OpenGL frame buffer object where supported.
  
pCamPass->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);

  // attach the texture to render to
  pCamPass->attach(osg::Camera::COLOR_BUFFER, texture2D);
  // add screen aligned quad for rendering
  pCamPass->addChild(quadGeode);

Does anybody have any clue what could be going wrong here?
Any help is much appreciated.

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


[osg-users] How do I access the Z-Buffer content from the last render pass

2009-03-08 Thread Daniel Holz

Hi osg-users,

is it possible to access the Z-Buffer content from a render pass 1 in 
the shaders during a second render pass 2 if I do not clear the Z-Buffer 
content in pass 1?


In my project I render my scene in pass 1 and set the clear mask for 
pass 2 to "0", hence not clearing neither the color nor the depth buffer:

   pCamPass2->setClearMask(0);

Now, how do I read out the Z-Buffer content of the gpu for a given pixel 
in the fragment shader of pass2?

Trying to read from gl_FragDepth did not work.

Any suggestions?

Cheers
Daniel

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


Re: [osg-users] Can't write to ALPHA component with custom fragment shader in RTT pass

2009-03-09 Thread Daniel Holz

Hi Joseba,

I use FBOs but the problem is that in the beginning of my application it 
says "RenderStage::runCameraSetUp(), FBO setup failed, FBO status= 
0x8cd6". Could this be the problem? And what is the reason for that?


Could you tell me which internal format you where using and which issues 
you were talking about?


Thanks
Daniel

Joseba wrote:

Hi,
I had some similar problem sometime ago and i solved it changing the internal 
format of the texture for the RTT. I also had some issues using FRAME_BUFFERS 
instead of FBOs, but you are already using them.

Regards,

J.

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





___
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


Re: [osg-users] Can't write to ALPHA component with custom fragment shader in RTT pass

2009-03-09 Thread Daniel Holz

Hi,

I just want to make sure that we do not misunderstand each other:
The problem is not to make a fragment invisible (the discard statement 
in fact works for that pretty well) but to simply store normalized data 
([0,1]) as the alpha component of my RGBA texture by using 
gl_FragColor.a = ... . But whatever value I pass in, it is ignored.


In fact I found out that I CAN write to the alpha value IF I use 
texture2D->setInternalFormat(GL_RGBA) but this would give me normalized 
values not just for the alpha component but also for the RGB components 
and that's not what I want. I need 32 bit floats PER component and NOT 
normalized because I want to store world space positions in RGB. That's 
why I decided to use GL_RGBA32F_ARB as internal format.


This decision was motivated by the following behavior of 
osg::Texture2D::setInternalFormat():


In setInternalFormat() the method computeInternalFormatType() is called 
which sets the "internal format type" to GL_FLOAT for the given 
"internal format" GL_RGBA32F_ARB:


   setInternalFormat(GL_RGBA32F_ARB);
   ==> computeInternalFormatType() gives GL_FLOAT as a result.

If I use the "internal format" GL_RGBA the method 
computeInternalFormatType() computes the "internal format type" NORMALIZED:


   setInternalFormat(GL_RGBA);
   ==> computeInternalFormatType() gives NORMALIZED as a result.

So how do I get to write to the alpha if its not normalized?

Cheers
Daniel

Joseba wrote:

Hi,
I had some similar problem sometime ago and i solved it changing the internal 
format of the texture for the RTT. I also had some issues using FRAME_BUFFERS 
instead of FBOs, but you are already using them.

Regards,

J.

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





___
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


Re: [osg-users] Can't write to ALPHA component with custom fragment shader in RTT pass

2009-03-11 Thread Daniel Holz
Thanks for all your help. It directed me to the solution!

For other users who face the same problem:

The setting to obtain a RGBA texture with 32Bit floats per component which one 
can write unclamped values to is as follows:


Code:

osg::Texture2D texture2D = new osg::Texture2D;
texture2D->setTextureSize(screen_width, screen_height);
texture2D->setFilter(osg::Texture2D::MIN_FILTER,osg::Texture2D::LINEAR);
texture2D->setFilter(osg::Texture2D::MAG_FILTER,osg::Texture2D::LINEAR);
texture2D->setInternalFormat(GL_RGBA32F_ARB);
texture2D->setSourceFormat(GL_RGBA); // we need to set the source format to 
GL_RGBA. otherwise the values will be clamped to [0,1].
// Note: use gl_FragData[0..n] to write to texture in fragment shader. 
otherwise data is clamped.

osg::Camera* camera = ...
camera->pCamPass->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT);
camera->attach(osg::Camera::BufferComponent(osg::Camera::COLOR_BUFFER0), 
texture2D);




Just watch out that you write to the texture using gl_FragData[0] (in this 
example) instead of gl_FragColor if you want the values to be passed in the 
texture in an unclamped fashion.

Have fun!

Daniel

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





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


[osg-users] Can I render to a texture AND to the screen in one pass?

2009-03-11 Thread Daniel Holz
Hi everyone,

what I want is to obtain the z-Buffer content from a previous render pass 
(pass1) where I render my scene and use it in a subsequent render pass (pass2). 
Of course I would like to avoid doing pass1 twice, first to render to the 
screen and second to render the z-buffer to a texture since I would render my 
complete scene twice. That's is an overhead that I would like to avoid.

Now the question:

Would it be possible to render the main scene (pass1) in two COLOR_BUFFERS,
COLOR_BUFFER0 and COLOR_BUFFER1 at the same time?

Then one could set up the camera so that the screen is attached to 
COLOR_BUFFER0 and a texture 'zBufferContent' is attached to COLOR_BUFFER1.
How do I do that?

In this case, having multiple render targets, one needs to set up the camera to 
using FBOs 
(camera->setRenderTargetImplementation(osg::Camera::FRAME_BUFFER_OBJECT)) since 
pixel buffers to not support multiple render targets.

Then, in the fragment shader, one can write to gl_FragData[0] the usual screen 
color information and pass gl_FragDepth to gl_FragData[1] (gl_FragData[1] = 
gl_FragDepth), hence obtaining the texture which contains the z-Buffer content.

Would this work?

Regards,
Daniel

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





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


Re: [osg-users] Setting alpha channel in Frag Shader does not work.

2009-03-13 Thread Daniel Holz
Try attaching a texture to the COLOR_BUFFER0 instead of an image directly.
That's what worked for me.

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





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


[osg-users] How do I obtain calculated zNear / zFar from an osg::Camera ?

2009-03-13 Thread Daniel Holz
Hi everyone,

I am using a camera whose zNear / zFar is calculated automatically and I need 
to obtain the zNear / zFar values in the camera's PreRenderCallback.
Just trying to use the function camera->getProjectionMatrixAsPerspective(fovy, 
aspect, zNear, zFar);
always gives me the initial near far plane (0.99 and ) and not the 
automatically computed one (at least zFar should be quite small since my scene 
is just about 5x5x5 units large).

How do I do it correctly?

Regards
Daniel

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





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


Re: [osg-users] How do I obtain calculated zNear / zFar from an osg::Camera ?

2009-03-13 Thread Daniel Holz
An update:

I forgot to say that I am rendering to a texture.

So basically what I do is the following:

Code:

osg::Camera* camera = new osg::Camera;
...
camera->setComputeNearFarMode(osg::CullSettings::COMPUTE_NEAR_FAR_USING_BOUNDING_VOLUMES);
...
camera->attach( , texture);




When stepping through my application I noticed that for this camera no culling 
is performed. This is why the zNear / zFar is not changed.

Now my new question:
Is it possible to have automatic near / far plane computation for a render to 
texture pass somehow?

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





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


Re: [osg-users] Setting alpha channel in Frag Shader does not work.

2009-03-19 Thread Daniel Holz
I suppose you are writing the data in a texture with gl_FragColor = vec4(..., 
depth).
What exactly are you doing with the data that you write afterwards, or how do 
you actually obtain your point cloud?

If for example you take the position vec4(..., depth) (which is a world space 
position?) and you would project it on the image plane by doing 
PROJECTIONMATRIX * MODELVIEWMATRIX * vec4(..., depth) then, if depth is not 
equals 1.0 you get a completely different projection on the screen after doing 
the perspective division.

Remember: your world space positions are specified in the homogenous coordinate 
system, meaning that a world space position (x,y,z) is represented by 
(x,y,z,1). If you want to project a world space position on the image plane it 
needs to have the w component (the 4th one) set to 1, since that's where the 
effect of perspective foreshortening is kind of "stored" after multiplication 
with the projection matrix.
The perspective division (dividing the x,y,z component by the resulting w 
component) then actually performs the projection.

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





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


Re: [osg-users] Setting alpha channel in Frag Shader does not work.

2009-03-19 Thread Daniel Holz
For the alpha channel look here: 
http://forum.openscenegraph.org/viewtopic.php?t=1776

I posted the solution to my problem (similar to yours) at the end of the thread.

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





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