Re: [osg-users] how do I make the light always hit the front of the camera?

2021-03-09 Thread newli...@gmail.com
Hi, Robert .
First of all, thank you for your interest and answer.

I'm rendering using osg::Light and osg::LightSource with a spotlight 
pointing down.

The exact position is set using light->setPosition()

The direction of the light is set with the code below.

 osg::vec3d world =world + osg::Vec3d(0.0, 0.0, -0.6)
 light->setDirection(-world)

However, if the camera's heading is rotated in the current implementation, 
the light currently being rendered in front is stopped at the position and 
only the camera rotates.

I want to rotate the position of the light along with the heading of the 
camera.
However, if you adjust the Direction value to rotate the position of the 
light, the rendered position will be distorted without rotating as desired.

So, I tried various things using the code below, but I didn't get the 
desired result.

osg::PositionAttitudeTransform *_pat = new osg::PositionAttitudeTransform();
osg::Quat ori =  osg::Quat(osg::DegreesToRadians(0.0), osg::Vec3(0, 1, 0)) *
osg::Quat(osg::DegreesToRadians(0.0), 
osg::Vec3(1, 0, 0)) *
osg::Quat(osg::DegreesToRadians(heading_value), 
osg::Vec3(0, 0, 1));
_pat->setAttitude(ori);

Is there a good way to adjust the position of the light like a camera?

2021년 3월 9일 화요일 오후 5시 12분 42초 UTC+9에 robert@gmail.com님이 작성:

> Hi ?
>
> You don't say how you are rendering your present lights so providing 
> guidance on how to adjust it isn't possible, you'll need to provide more 
> information about your render system and what it relies upon for 
> controlling the position and direction of the light.
>
> Also it's hard to understand what you mean.  Rotating something by 360 
> degrees takes it full circle and back to where it was originally - so this 
> bit makes no sense whatsoever.
>
> The light in the scene looks to be a spot light pointing downwards, 
> pointing that back towards the camera would be a 90 degree rotation, but 
> pointing a spotlight at the camera would be pretty odd.  Could you mean 
> something completely different from what you are saying?
>
> Robert.
>

-- 
You received this message because you are subscribed to the Google Groups 
"OpenSceneGraph Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osg-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/osg-users/00bcb4c9-824e-45bd-b993-375b01a44c81n%40googlegroups.com.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] Question about array binding

2021-03-09 Thread Robert Osfield
HI Werner,

I can't think of think of reason that would cause a problem.  It's quite a
while since I look at the associated code so it might be simply that I've
forgotten constraints.  Have a look at the
osg::Geometry::drawImplementation() to see if there is a constraint on
vertex attributes needing to be BIND_PER_VERTEX.

If you were using the VSG that I'd suggest running with Vulkan debug and
API layer as it's great for picking up errors.  Are there any OpenGL errors
being produced?

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


[osg-users] Question about array binding

2021-03-09 Thread Werner Modenbach
Hi all,

I was hunting a long time for some strange effect. I discovered the reason but 
have some understanding issues.
Why is Code 1 not working but code 2? I would prefer Code 1 because of less 
data.

Code 1) (my original code is not working)
        osg::ref_ptr osgVertexFlagsVector;

        osgVertexFlagsVector = new osg::IntArray(1);
        osgVertexFlagsVector->setBinding(osg::Array::BIND_OVERALL);
        _geometry->setVertexAttribArray(VERTEX_FLAGS_ATR_UNIT, 
osgVertexFlagsVector.get(), osg::Array::BIND_OVERALL);

        (*osgVertexFlagsVector)[0] = VERTEX_FLAG_VISIBLE;

Code 2) (this code is working)
        osg::ref_ptr osgVertexFlagsVector;

        osgVertexFlagsVector = new osg::IntArray(numVertices);
    osgVertexFlagsVector->setBinding(osg::Array::BIND_PER_VERTEX);
        _geometry->setVertexAttribArray(VERTEX_FLAGS_ATR_UNIT, 
osgVertexFlagsVector.get(), osg::Array::BIND_PER_VERTEX);

        for (auto i=0; i___
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 make the light always hit the front of the camera?

2021-03-09 Thread Robert Osfield
Hi ?

You don't say how you are rendering your present lights so providing
guidance on how to adjust it isn't possible, you'll need to provide more
information about your render system and what it relies upon for
controlling the position and direction of the light.

Also it's hard to understand what you mean.  Rotating something by 360
degrees takes it full circle and back to where it was originally - so this
bit makes no sense whatsoever.

The light in the scene looks to be a spot light pointing downwards,
pointing that back towards the camera would be a 90 degree rotation, but
pointing a spotlight at the camera would be pretty odd.  Could you mean
something completely different from what you are saying?

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