OpenSceneGraph Forum Forum Index OpenSceneGraph Forum
Official forum which mirrors the existent OSG mailing lists. Messages posted here are forwarded to the mailing list and vice versa.
 
   FAQFAQ    SearchSearch    MemberlistMemberlist    RulesRules    UsergroupsUsergroups    RegisterRegister 
 Mail2Forum SettingsMail2Forum Settings  ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
   AlbumAlbum  OpenSceneGraph IRC ChatOpenSceneGraph IRC Chat   SmartFeedSmartFeed 

Writing texture coordinates on a mesh without going through traversal code?

Goto page 1, 2, 3, 4, 5, 6, 7, 8, 9, 10  Next
 
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General
View previous topic :: View next topic  
Author Message
Rowley, Marlin R
Guest





PostPosted: Sat Apr 14, 2018 1:48 am    Post subject:
Writing texture coordinates on a mesh without going through traversal code?
Reply with quote

Hello!

I’m trying to generate my own texture coordinates (on-the-fly) by having a callback that runs when a piece of geometry intersects my object. So for example, I create a realworld frustum and when my frustum has a shader that’s bound to some arbitrary object in the world. When my frustum intersects this object, I would like to generate texture coordinates on this object based on how far or near I am to the frustum’s near/far planes (it’s perspective frustum). We had the following code for doing this:

void ViewshedOSG::updateTextureCoordinates()
{
// write the plane equation for all 3 planes
// that make up the camera view frustum. We can
// then access this from the shader to test whether
// we are in the frustum's volume or not.
osg::Matrixd projection = mCamera->getViewMatrix();
mTexGen->setPlanesFromMatrix(projection *
osg::Matrix::translate(1.0, 1.0, 1.0) *
osg::Matrix::scale(0.5f, 0.5f, 0.5f));

// Bring our models viewspace coordinates back
// into model space coordinate of the camera frustum
osg::RefMatrix * refMatrix = new osg::RefMatrix
(mCamera->getInverseViewMatrix() * *_cv->getModelViewMatrix());

// Copy the texture generator to the mesh where you
// can index it's coordinates from the ViewshedID
_cv->getRenderStage()->getPositionalStateContainer()->
addPositionedTextureAttribute
(mId, refMatrix, mTexGen.get());
}


However, this code was based on a cull visitor calling this function from a callback. I have my own callback and it’s not based on a visitor. Is there anyway to get the objects modelview matrix() without calling it from a cull visitor? Also only need to write the ‘addPositionedTextureAttribute’ on the geometry in order to access the coordinates through a shader.

I’m trying to keep this simple. Am I in the right direction?

Thanks,

-M
----------------------------------------
Marlin Rowley
Software Engineer, Staff

Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)

------------------
Post generated by Mail2Forum
Back to top
Rowley, Marlin R
Guest





PostPosted: Sat Apr 14, 2018 1:48 am    Post subject:
Writing texture coordinates on a mesh without going through traversal code?
Reply with quote

Hello!

I’m trying to generate my own texture coordinates (on-the-fly) by having a callback that runs when a piece of geometry intersects my object. So for example, I create a realworld frustum and when my frustum has a shader that’s bound to some arbitrary object in the world. When my frustum intersects this object, I would like to generate texture coordinates on this object based on how far or near I am to the frustum’s near/far planes (it’s perspective frustum). We had the following code for doing this:

void ViewshedOSG::updateTextureCoordinates()
{
// write the plane equation for all 3 planes
// that make up the camera view frustum. We can
// then access this from the shader to test whether
// we are in the frustum's volume or not.
osg::Matrixd projection = mCamera->getViewMatrix();
mTexGen->setPlanesFromMatrix(projection *
osg::Matrix::translate(1.0, 1.0, 1.0) *
osg::Matrix::scale(0.5f, 0.5f, 0.5f));

// Bring our models viewspace coordinates back
// into model space coordinate of the camera frustum
osg::RefMatrix * refMatrix = new osg::RefMatrix
(mCamera->getInverseViewMatrix() * *_cv->getModelViewMatrix());

// Copy the texture generator to the mesh where you
// can index it's coordinates from the ViewshedID
_cv->getRenderStage()->getPositionalStateContainer()->
addPositionedTextureAttribute
(mId, refMatrix, mTexGen.get());
}


However, this code was based on a cull visitor calling this function from a callback. I have my own callback and it’s not based on a visitor. Is there anyway to get the objects modelview matrix() without calling it from a cull visitor? Also only need to write the ‘addPositionedTextureAttribute’ on the geometry in order to access the coordinates through a shader.

I’m trying to keep this simple. Am I in the right direction?

Thanks,

-M
----------------------------------------
Marlin Rowley
Software Engineer, Staff

Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)

------------------
Post generated by Mail2Forum
Back to top
Rowley, Marlin R
Guest





PostPosted: Sat Apr 14, 2018 1:48 am    Post subject:
Writing texture coordinates on a mesh without going through traversal code?
Reply with quote

Hello!

I’m trying to generate my own texture coordinates (on-the-fly) by having a callback that runs when a piece of geometry intersects my object. So for example, I create a realworld frustum and when my frustum has a shader that’s bound to some arbitrary object in the world. When my frustum intersects this object, I would like to generate texture coordinates on this object based on how far or near I am to the frustum’s near/far planes (it’s perspective frustum). We had the following code for doing this:

void ViewshedOSG::updateTextureCoordinates()
{
// write the plane equation for all 3 planes
// that make up the camera view frustum. We can
// then access this from the shader to test whether
// we are in the frustum's volume or not.
osg::Matrixd projection = mCamera->getViewMatrix();
mTexGen->setPlanesFromMatrix(projection *
osg::Matrix::translate(1.0, 1.0, 1.0) *
osg::Matrix::scale(0.5f, 0.5f, 0.5f));

// Bring our models viewspace coordinates back
// into model space coordinate of the camera frustum
osg::RefMatrix * refMatrix = new osg::RefMatrix
(mCamera->getInverseViewMatrix() * *_cv->getModelViewMatrix());

// Copy the texture generator to the mesh where you
// can index it's coordinates from the ViewshedID
_cv->getRenderStage()->getPositionalStateContainer()->
addPositionedTextureAttribute
(mId, refMatrix, mTexGen.get());
}


However, this code was based on a cull visitor calling this function from a callback. I have my own callback and it’s not based on a visitor. Is there anyway to get the objects modelview matrix() without calling it from a cull visitor? Also only need to write the ‘addPositionedTextureAttribute’ on the geometry in order to access the coordinates through a shader.

I’m trying to keep this simple. Am I in the right direction?

Thanks,

-M
----------------------------------------
Marlin Rowley
Software Engineer, Staff

Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)

------------------
Post generated by Mail2Forum
Back to top
Rowley, Marlin R
Guest





PostPosted: Sat Apr 14, 2018 1:48 am    Post subject:
Writing texture coordinates on a mesh without going through traversal code?
Reply with quote

Hello!

I’m trying to generate my own texture coordinates (on-the-fly) by having a callback that runs when a piece of geometry intersects my object. So for example, I create a realworld frustum and when my frustum has a shader that’s bound to some arbitrary object in the world. When my frustum intersects this object, I would like to generate texture coordinates on this object based on how far or near I am to the frustum’s near/far planes (it’s perspective frustum). We had the following code for doing this:

void ViewshedOSG::updateTextureCoordinates()
{
// write the plane equation for all 3 planes
// that make up the camera view frustum. We can
// then access this from the shader to test whether
// we are in the frustum's volume or not.
osg::Matrixd projection = mCamera->getViewMatrix();
mTexGen->setPlanesFromMatrix(projection *
osg::Matrix::translate(1.0, 1.0, 1.0) *
osg::Matrix::scale(0.5f, 0.5f, 0.5f));

// Bring our models viewspace coordinates back
// into model space coordinate of the camera frustum
osg::RefMatrix * refMatrix = new osg::RefMatrix
(mCamera->getInverseViewMatrix() * *_cv->getModelViewMatrix());

// Copy the texture generator to the mesh where you
// can index it's coordinates from the ViewshedID
_cv->getRenderStage()->getPositionalStateContainer()->
addPositionedTextureAttribute
(mId, refMatrix, mTexGen.get());
}


However, this code was based on a cull visitor calling this function from a callback. I have my own callback and it’s not based on a visitor. Is there anyway to get the objects modelview matrix() without calling it from a cull visitor? Also only need to write the ‘addPositionedTextureAttribute’ on the geometry in order to access the coordinates through a shader.

I’m trying to keep this simple. Am I in the right direction?

Thanks,

-M
----------------------------------------
Marlin Rowley
Software Engineer, Staff

Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)

------------------
Post generated by Mail2Forum
Back to top
Rowley, Marlin R
Guest





PostPosted: Sat Apr 14, 2018 1:48 am    Post subject:
Writing texture coordinates on a mesh without going through traversal code?
Reply with quote

Hello!

I’m trying to generate my own texture coordinates (on-the-fly) by having a callback that runs when a piece of geometry intersects my object. So for example, I create a realworld frustum and when my frustum has a shader that’s bound to some arbitrary object in the world. When my frustum intersects this object, I would like to generate texture coordinates on this object based on how far or near I am to the frustum’s near/far planes (it’s perspective frustum). We had the following code for doing this:

void ViewshedOSG::updateTextureCoordinates()
{
// write the plane equation for all 3 planes
// that make up the camera view frustum. We can
// then access this from the shader to test whether
// we are in the frustum's volume or not.
osg::Matrixd projection = mCamera->getViewMatrix();
mTexGen->setPlanesFromMatrix(projection *
osg::Matrix::translate(1.0, 1.0, 1.0) *
osg::Matrix::scale(0.5f, 0.5f, 0.5f));

// Bring our models viewspace coordinates back
// into model space coordinate of the camera frustum
osg::RefMatrix * refMatrix = new osg::RefMatrix
(mCamera->getInverseViewMatrix() * *_cv->getModelViewMatrix());

// Copy the texture generator to the mesh where you
// can index it's coordinates from the ViewshedID
_cv->getRenderStage()->getPositionalStateContainer()->
addPositionedTextureAttribute
(mId, refMatrix, mTexGen.get());
}


However, this code was based on a cull visitor calling this function from a callback. I have my own callback and it’s not based on a visitor. Is there anyway to get the objects modelview matrix() without calling it from a cull visitor? Also only need to write the ‘addPositionedTextureAttribute’ on the geometry in order to access the coordinates through a shader.

I’m trying to keep this simple. Am I in the right direction?

Thanks,

-M
----------------------------------------
Marlin Rowley
Software Engineer, Staff

Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)

------------------
Post generated by Mail2Forum
Back to top
Rowley, Marlin R
Guest





PostPosted: Sat Apr 14, 2018 1:48 am    Post subject:
Writing texture coordinates on a mesh without going through traversal code?
Reply with quote

Hello!

I’m trying to generate my own texture coordinates (on-the-fly) by having a callback that runs when a piece of geometry intersects my object. So for example, I create a realworld frustum and when my frustum has a shader that’s bound to some arbitrary object in the world. When my frustum intersects this object, I would like to generate texture coordinates on this object based on how far or near I am to the frustum’s near/far planes (it’s perspective frustum). We had the following code for doing this:

void ViewshedOSG::updateTextureCoordinates()
{
// write the plane equation for all 3 planes
// that make up the camera view frustum. We can
// then access this from the shader to test whether
// we are in the frustum's volume or not.
osg::Matrixd projection = mCamera->getViewMatrix();
mTexGen->setPlanesFromMatrix(projection *
osg::Matrix::translate(1.0, 1.0, 1.0) *
osg::Matrix::scale(0.5f, 0.5f, 0.5f));

// Bring our models viewspace coordinates back
// into model space coordinate of the camera frustum
osg::RefMatrix * refMatrix = new osg::RefMatrix
(mCamera->getInverseViewMatrix() * *_cv->getModelViewMatrix());

// Copy the texture generator to the mesh where you
// can index it's coordinates from the ViewshedID
_cv->getRenderStage()->getPositionalStateContainer()->
addPositionedTextureAttribute
(mId, refMatrix, mTexGen.get());
}


However, this code was based on a cull visitor calling this function from a callback. I have my own callback and it’s not based on a visitor. Is there anyway to get the objects modelview matrix() without calling it from a cull visitor? Also only need to write the ‘addPositionedTextureAttribute’ on the geometry in order to access the coordinates through a shader.

I’m trying to keep this simple. Am I in the right direction?

Thanks,

-M
----------------------------------------
Marlin Rowley
Software Engineer, Staff

Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)

------------------
Post generated by Mail2Forum
Back to top
Rowley, Marlin R
Guest





PostPosted: Sat Apr 14, 2018 1:48 am    Post subject:
Writing texture coordinates on a mesh without going through traversal code?
Reply with quote

Hello!

I’m trying to generate my own texture coordinates (on-the-fly) by having a callback that runs when a piece of geometry intersects my object. So for example, I create a realworld frustum and when my frustum has a shader that’s bound to some arbitrary object in the world. When my frustum intersects this object, I would like to generate texture coordinates on this object based on how far or near I am to the frustum’s near/far planes (it’s perspective frustum). We had the following code for doing this:

void ViewshedOSG::updateTextureCoordinates()
{
// write the plane equation for all 3 planes
// that make up the camera view frustum. We can
// then access this from the shader to test whether
// we are in the frustum's volume or not.
osg::Matrixd projection = mCamera->getViewMatrix();
mTexGen->setPlanesFromMatrix(projection *
osg::Matrix::translate(1.0, 1.0, 1.0) *
osg::Matrix::scale(0.5f, 0.5f, 0.5f));

// Bring our models viewspace coordinates back
// into model space coordinate of the camera frustum
osg::RefMatrix * refMatrix = new osg::RefMatrix
(mCamera->getInverseViewMatrix() * *_cv->getModelViewMatrix());

// Copy the texture generator to the mesh where you
// can index it's coordinates from the ViewshedID
_cv->getRenderStage()->getPositionalStateContainer()->
addPositionedTextureAttribute
(mId, refMatrix, mTexGen.get());
}


However, this code was based on a cull visitor calling this function from a callback. I have my own callback and it’s not based on a visitor. Is there anyway to get the objects modelview matrix() without calling it from a cull visitor? Also only need to write the ‘addPositionedTextureAttribute’ on the geometry in order to access the coordinates through a shader.

I’m trying to keep this simple. Am I in the right direction?

Thanks,

-M
----------------------------------------
Marlin Rowley
Software Engineer, Staff

Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)

------------------
Post generated by Mail2Forum
Back to top
Rowley, Marlin R
Guest





PostPosted: Sat Apr 14, 2018 1:48 am    Post subject:
Writing texture coordinates on a mesh without going through traversal code?
Reply with quote

Hello!

I’m trying to generate my own texture coordinates (on-the-fly) by having a callback that runs when a piece of geometry intersects my object. So for example, I create a realworld frustum and when my frustum has a shader that’s bound to some arbitrary object in the world. When my frustum intersects this object, I would like to generate texture coordinates on this object based on how far or near I am to the frustum’s near/far planes (it’s perspective frustum). We had the following code for doing this:

void ViewshedOSG::updateTextureCoordinates()
{
// write the plane equation for all 3 planes
// that make up the camera view frustum. We can
// then access this from the shader to test whether
// we are in the frustum's volume or not.
osg::Matrixd projection = mCamera->getViewMatrix();
mTexGen->setPlanesFromMatrix(projection *
osg::Matrix::translate(1.0, 1.0, 1.0) *
osg::Matrix::scale(0.5f, 0.5f, 0.5f));

// Bring our models viewspace coordinates back
// into model space coordinate of the camera frustum
osg::RefMatrix * refMatrix = new osg::RefMatrix
(mCamera->getInverseViewMatrix() * *_cv->getModelViewMatrix());

// Copy the texture generator to the mesh where you
// can index it's coordinates from the ViewshedID
_cv->getRenderStage()->getPositionalStateContainer()->
addPositionedTextureAttribute
(mId, refMatrix, mTexGen.get());
}


However, this code was based on a cull visitor calling this function from a callback. I have my own callback and it’s not based on a visitor. Is there anyway to get the objects modelview matrix() without calling it from a cull visitor? Also only need to write the ‘addPositionedTextureAttribute’ on the geometry in order to access the coordinates through a shader.

I’m trying to keep this simple. Am I in the right direction?

Thanks,

-M
----------------------------------------
Marlin Rowley
Software Engineer, Staff

Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)

------------------
Post generated by Mail2Forum
Back to top
Rowley, Marlin R
Guest





PostPosted: Sat Apr 14, 2018 1:48 am    Post subject:
Writing texture coordinates on a mesh without going through traversal code?
Reply with quote

Hello!

I’m trying to generate my own texture coordinates (on-the-fly) by having a callback that runs when a piece of geometry intersects my object. So for example, I create a realworld frustum and when my frustum has a shader that’s bound to some arbitrary object in the world. When my frustum intersects this object, I would like to generate texture coordinates on this object based on how far or near I am to the frustum’s near/far planes (it’s perspective frustum). We had the following code for doing this:

void ViewshedOSG::updateTextureCoordinates()
{
// write the plane equation for all 3 planes
// that make up the camera view frustum. We can
// then access this from the shader to test whether
// we are in the frustum's volume or not.
osg::Matrixd projection = mCamera->getViewMatrix();
mTexGen->setPlanesFromMatrix(projection *
osg::Matrix::translate(1.0, 1.0, 1.0) *
osg::Matrix::scale(0.5f, 0.5f, 0.5f));

// Bring our models viewspace coordinates back
// into model space coordinate of the camera frustum
osg::RefMatrix * refMatrix = new osg::RefMatrix
(mCamera->getInverseViewMatrix() * *_cv->getModelViewMatrix());

// Copy the texture generator to the mesh where you
// can index it's coordinates from the ViewshedID
_cv->getRenderStage()->getPositionalStateContainer()->
addPositionedTextureAttribute
(mId, refMatrix, mTexGen.get());
}


However, this code was based on a cull visitor calling this function from a callback. I have my own callback and it’s not based on a visitor. Is there anyway to get the objects modelview matrix() without calling it from a cull visitor? Also only need to write the ‘addPositionedTextureAttribute’ on the geometry in order to access the coordinates through a shader.

I’m trying to keep this simple. Am I in the right direction?

Thanks,

-M
----------------------------------------
Marlin Rowley
Software Engineer, Staff

Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)

------------------
Post generated by Mail2Forum
Back to top
Rowley, Marlin R
Guest





PostPosted: Sat Apr 14, 2018 1:48 am    Post subject:
Writing texture coordinates on a mesh without going through traversal code?
Reply with quote

Hello!

I’m trying to generate my own texture coordinates (on-the-fly) by having a callback that runs when a piece of geometry intersects my object. So for example, I create a realworld frustum and when my frustum has a shader that’s bound to some arbitrary object in the world. When my frustum intersects this object, I would like to generate texture coordinates on this object based on how far or near I am to the frustum’s near/far planes (it’s perspective frustum). We had the following code for doing this:

void ViewshedOSG::updateTextureCoordinates()
{
// write the plane equation for all 3 planes
// that make up the camera view frustum. We can
// then access this from the shader to test whether
// we are in the frustum's volume or not.
osg::Matrixd projection = mCamera->getViewMatrix();
mTexGen->setPlanesFromMatrix(projection *
osg::Matrix::translate(1.0, 1.0, 1.0) *
osg::Matrix::scale(0.5f, 0.5f, 0.5f));

// Bring our models viewspace coordinates back
// into model space coordinate of the camera frustum
osg::RefMatrix * refMatrix = new osg::RefMatrix
(mCamera->getInverseViewMatrix() * *_cv->getModelViewMatrix());

// Copy the texture generator to the mesh where you
// can index it's coordinates from the ViewshedID
_cv->getRenderStage()->getPositionalStateContainer()->
addPositionedTextureAttribute
(mId, refMatrix, mTexGen.get());
}


However, this code was based on a cull visitor calling this function from a callback. I have my own callback and it’s not based on a visitor. Is there anyway to get the objects modelview matrix() without calling it from a cull visitor? Also only need to write the ‘addPositionedTextureAttribute’ on the geometry in order to access the coordinates through a shader.

I’m trying to keep this simple. Am I in the right direction?

Thanks,

-M
----------------------------------------
Marlin Rowley
Software Engineer, Staff

Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)

------------------
Post generated by Mail2Forum
Back to top
Rowley, Marlin R
Guest





PostPosted: Sat Apr 14, 2018 1:48 am    Post subject:
Writing texture coordinates on a mesh without going through traversal code?
Reply with quote

Hello!

I’m trying to generate my own texture coordinates (on-the-fly) by having a callback that runs when a piece of geometry intersects my object. So for example, I create a realworld frustum and when my frustum has a shader that’s bound to some arbitrary object in the world. When my frustum intersects this object, I would like to generate texture coordinates on this object based on how far or near I am to the frustum’s near/far planes (it’s perspective frustum). We had the following code for doing this:

void ViewshedOSG::updateTextureCoordinates()
{
// write the plane equation for all 3 planes
// that make up the camera view frustum. We can
// then access this from the shader to test whether
// we are in the frustum's volume or not.
osg::Matrixd projection = mCamera->getViewMatrix();
mTexGen->setPlanesFromMatrix(projection *
osg::Matrix::translate(1.0, 1.0, 1.0) *
osg::Matrix::scale(0.5f, 0.5f, 0.5f));

// Bring our models viewspace coordinates back
// into model space coordinate of the camera frustum
osg::RefMatrix * refMatrix = new osg::RefMatrix
(mCamera->getInverseViewMatrix() * *_cv->getModelViewMatrix());

// Copy the texture generator to the mesh where you
// can index it's coordinates from the ViewshedID
_cv->getRenderStage()->getPositionalStateContainer()->
addPositionedTextureAttribute
(mId, refMatrix, mTexGen.get());
}


However, this code was based on a cull visitor calling this function from a callback. I have my own callback and it’s not based on a visitor. Is there anyway to get the objects modelview matrix() without calling it from a cull visitor? Also only need to write the ‘addPositionedTextureAttribute’ on the geometry in order to access the coordinates through a shader.

I’m trying to keep this simple. Am I in the right direction?

Thanks,

-M
----------------------------------------
Marlin Rowley
Software Engineer, Staff

Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)

------------------
Post generated by Mail2Forum
Back to top
Rowley, Marlin R
Guest





PostPosted: Sat Apr 14, 2018 1:48 am    Post subject:
Writing texture coordinates on a mesh without going through traversal code?
Reply with quote

Hello!

I’m trying to generate my own texture coordinates (on-the-fly) by having a callback that runs when a piece of geometry intersects my object. So for example, I create a realworld frustum and when my frustum has a shader that’s bound to some arbitrary object in the world. When my frustum intersects this object, I would like to generate texture coordinates on this object based on how far or near I am to the frustum’s near/far planes (it’s perspective frustum). We had the following code for doing this:

void ViewshedOSG::updateTextureCoordinates()
{
// write the plane equation for all 3 planes
// that make up the camera view frustum. We can
// then access this from the shader to test whether
// we are in the frustum's volume or not.
osg::Matrixd projection = mCamera->getViewMatrix();
mTexGen->setPlanesFromMatrix(projection *
osg::Matrix::translate(1.0, 1.0, 1.0) *
osg::Matrix::scale(0.5f, 0.5f, 0.5f));

// Bring our models viewspace coordinates back
// into model space coordinate of the camera frustum
osg::RefMatrix * refMatrix = new osg::RefMatrix
(mCamera->getInverseViewMatrix() * *_cv->getModelViewMatrix());

// Copy the texture generator to the mesh where you
// can index it's coordinates from the ViewshedID
_cv->getRenderStage()->getPositionalStateContainer()->
addPositionedTextureAttribute
(mId, refMatrix, mTexGen.get());
}


However, this code was based on a cull visitor calling this function from a callback. I have my own callback and it’s not based on a visitor. Is there anyway to get the objects modelview matrix() without calling it from a cull visitor? Also only need to write the ‘addPositionedTextureAttribute’ on the geometry in order to access the coordinates through a shader.

I’m trying to keep this simple. Am I in the right direction?

Thanks,

-M
----------------------------------------
Marlin Rowley
Software Engineer, Staff

Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)

------------------
Post generated by Mail2Forum
Back to top
Rowley, Marlin R
Guest





PostPosted: Sat Apr 14, 2018 1:48 am    Post subject:
Writing texture coordinates on a mesh without going through traversal code?
Reply with quote

Hello!

I’m trying to generate my own texture coordinates (on-the-fly) by having a callback that runs when a piece of geometry intersects my object. So for example, I create a realworld frustum and when my frustum has a shader that’s bound to some arbitrary object in the world. When my frustum intersects this object, I would like to generate texture coordinates on this object based on how far or near I am to the frustum’s near/far planes (it’s perspective frustum). We had the following code for doing this:

void ViewshedOSG::updateTextureCoordinates()
{
// write the plane equation for all 3 planes
// that make up the camera view frustum. We can
// then access this from the shader to test whether
// we are in the frustum's volume or not.
osg::Matrixd projection = mCamera->getViewMatrix();
mTexGen->setPlanesFromMatrix(projection *
osg::Matrix::translate(1.0, 1.0, 1.0) *
osg::Matrix::scale(0.5f, 0.5f, 0.5f));

// Bring our models viewspace coordinates back
// into model space coordinate of the camera frustum
osg::RefMatrix * refMatrix = new osg::RefMatrix
(mCamera->getInverseViewMatrix() * *_cv->getModelViewMatrix());

// Copy the texture generator to the mesh where you
// can index it's coordinates from the ViewshedID
_cv->getRenderStage()->getPositionalStateContainer()->
addPositionedTextureAttribute
(mId, refMatrix, mTexGen.get());
}


However, this code was based on a cull visitor calling this function from a callback. I have my own callback and it’s not based on a visitor. Is there anyway to get the objects modelview matrix() without calling it from a cull visitor? Also only need to write the ‘addPositionedTextureAttribute’ on the geometry in order to access the coordinates through a shader.

I’m trying to keep this simple. Am I in the right direction?

Thanks,

-M
----------------------------------------
Marlin Rowley
Software Engineer, Staff

Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)

------------------
Post generated by Mail2Forum
Back to top
Rowley, Marlin R
Guest





PostPosted: Sat Apr 14, 2018 1:48 am    Post subject:
Writing texture coordinates on a mesh without going through traversal code?
Reply with quote

Hello!

I’m trying to generate my own texture coordinates (on-the-fly) by having a callback that runs when a piece of geometry intersects my object. So for example, I create a realworld frustum and when my frustum has a shader that’s bound to some arbitrary object in the world. When my frustum intersects this object, I would like to generate texture coordinates on this object based on how far or near I am to the frustum’s near/far planes (it’s perspective frustum). We had the following code for doing this:

void ViewshedOSG::updateTextureCoordinates()
{
// write the plane equation for all 3 planes
// that make up the camera view frustum. We can
// then access this from the shader to test whether
// we are in the frustum's volume or not.
osg::Matrixd projection = mCamera->getViewMatrix();
mTexGen->setPlanesFromMatrix(projection *
osg::Matrix::translate(1.0, 1.0, 1.0) *
osg::Matrix::scale(0.5f, 0.5f, 0.5f));

// Bring our models viewspace coordinates back
// into model space coordinate of the camera frustum
osg::RefMatrix * refMatrix = new osg::RefMatrix
(mCamera->getInverseViewMatrix() * *_cv->getModelViewMatrix());

// Copy the texture generator to the mesh where you
// can index it's coordinates from the ViewshedID
_cv->getRenderStage()->getPositionalStateContainer()->
addPositionedTextureAttribute
(mId, refMatrix, mTexGen.get());
}


However, this code was based on a cull visitor calling this function from a callback. I have my own callback and it’s not based on a visitor. Is there anyway to get the objects modelview matrix() without calling it from a cull visitor? Also only need to write the ‘addPositionedTextureAttribute’ on the geometry in order to access the coordinates through a shader.

I’m trying to keep this simple. Am I in the right direction?

Thanks,

-M
----------------------------------------
Marlin Rowley
Software Engineer, Staff

Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)

------------------
Post generated by Mail2Forum
Back to top
Rowley, Marlin R
Guest





PostPosted: Sat Apr 14, 2018 1:48 am    Post subject:
Writing texture coordinates on a mesh without going through traversal code?
Reply with quote

Hello!

I’m trying to generate my own texture coordinates (on-the-fly) by having a callback that runs when a piece of geometry intersects my object. So for example, I create a realworld frustum and when my frustum has a shader that’s bound to some arbitrary object in the world. When my frustum intersects this object, I would like to generate texture coordinates on this object based on how far or near I am to the frustum’s near/far planes (it’s perspective frustum). We had the following code for doing this:

void ViewshedOSG::updateTextureCoordinates()
{
// write the plane equation for all 3 planes
// that make up the camera view frustum. We can
// then access this from the shader to test whether
// we are in the frustum's volume or not.
osg::Matrixd projection = mCamera->getViewMatrix();
mTexGen->setPlanesFromMatrix(projection *
osg::Matrix::translate(1.0, 1.0, 1.0) *
osg::Matrix::scale(0.5f, 0.5f, 0.5f));

// Bring our models viewspace coordinates back
// into model space coordinate of the camera frustum
osg::RefMatrix * refMatrix = new osg::RefMatrix
(mCamera->getInverseViewMatrix() * *_cv->getModelViewMatrix());

// Copy the texture generator to the mesh where you
// can index it's coordinates from the ViewshedID
_cv->getRenderStage()->getPositionalStateContainer()->
addPositionedTextureAttribute
(mId, refMatrix, mTexGen.get());
}


However, this code was based on a cull visitor calling this function from a callback. I have my own callback and it’s not based on a visitor. Is there anyway to get the objects modelview matrix() without calling it from a cull visitor? Also only need to write the ‘addPositionedTextureAttribute’ on the geometry in order to access the coordinates through a shader.

I’m trying to keep this simple. Am I in the right direction?

Thanks,

-M
----------------------------------------
Marlin Rowley
Software Engineer, Staff

Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
(
Only registered users can see emails on this board!
Get registred or enter the forums!
)

------------------
Post generated by Mail2Forum
Back to top
Display posts from previous:   
Post new topic   Reply to topic    OpenSceneGraph Forum Forum Index -> General All times are GMT
Goto page 1, 2, 3, 4, 5, 6, 7, 8, 9, 10  Next
Page 1 of 10

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum

Similar Topics
Topic Author Forum Replies Posted
No new posts minor change: move assumeSizedInterna... mp3butcher General 8 Wed Aug 15, 2018 10:07 pm View latest post
No new posts Minor change proposal : Blacklist usa... mp3butcher General 14 Mon Aug 13, 2018 1:42 pm View latest post
No new posts New glTexStorage code is disrupting F... gwaldron General 10 Thu Aug 09, 2018 8:27 pm View latest post
No new posts Load an obj file and mapping a given ... aaa3d General 3 Mon Aug 06, 2018 2:27 pm View latest post
No new posts Load OSG trimesh to ODE: Read Vertice... TKoller General 2 Fri Jul 20, 2018 3:06 pm View latest post


Board Security Anti Bot Question MOD - phpBB MOD against Spam Bots
Powered by phpBB © 2001, 2005 phpBB Group
Protected by Anti-Spam ACP