[osg-users] [forum] How to get the normal of every triangle?

2018-04-19 Thread Bingqian Wang
Hi,

I know how can I get the vertex normal vector use NodeVisitor and 
Geometry->getNormalArray(),but how to get the  normal of every triangle?

Thank you very much!

Cheers,
Bingqian

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





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


[osg-users] Texture2DArray Internal Texture Format (OSG3.4.0)

2018-04-19 Thread Tim Whowantstoknow
Hi,

since I couldn't get 3.6.0 rc2 to run, I have been working with 3.4.0, so I'm 
not sure if this is happening in the current version.

I have been trying out Texture2DArrays and have loaded in 16 images, set them 
to a Texture2Array object and tried to display it. When calling frame the first 
time, I got some warnings:
"Warning: Texture2DArray::applyTexImage2DArray_subload(..) given image do have 
wrong dimension or internal format."
None of the loaded images is displayed as a texture.
I have debugged into the OSG Code to look for the error, and it turns out, that 
upon loading (a bmp file for every texture, all have the same width and 
height), the internal texture format of the images is set to 3 (which is GL_RGB 
at some point of the code), but the Texture2DArray internal format is 6407, 
which is also GL_RGB. 

I went on to set the image internal texture format to GL_RGB (which in this 
case is 6407) and now it works.

I'd add a minimal working example, but the forum seems to not let me do that, 
so sorry about that.

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





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


Re: [osg-users] [forum] How to get the normal of every triangle?

2018-04-19 Thread Voerman, L.
As the per primitive normal is not used by modern openGL, you probably will
have to calculate it yourself from the triangle vertices:
osg::Vec3 normal = (v1-v0)^(v2-v0);
normal.normalize();
Laurens.
ps.
I found your mail in my spam folder, probably due to the domain of your
mail adres and the very short message.
You might improve the answers you get by expanding your message by an
explanation of what you are trying to do, why you want to do that and what
the problem actually is.

On Mon, Mar 19, 2018 at 2:53 AM, Bingqian Wang <695186...@qq.com> wrote:

> Hi,
>
> I know how can I get the vertex normal vector use NodeVisitor and
> Geometry->getNormalArray(),but how to get the  normal of every triangle?
>
> Thank you very much!
>
> Cheers,
> Bingqian
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=73130#73130
>
>
>
>
>
> ___
> 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] Texture2DArray Internal Texture Format (OSG3.4.0)

2018-04-19 Thread Robert Osfield
Hi Tim,

It looks like some modern OpenGL drivers don't like the number of
components of texture being used as the internal texture format so
plugins that use this approach end up causing a problem.  In 3.6.0 we
did fix a few places where this was happen, off the top of my head I
don't recall if the bmp plugin was amongst those fixed.  W.r.t not
being able to attach files to the forum posts, this will be the case
for new posters, it's a mechanism required to prevent spammers from
abusing the forum.

More pressing an issue is what cause problems when you tried 3.6.0
rc2?  I fixed all the issues that were reported for the final 3.6.0,
there is chance that the issue you say has been fixed, but as you
don't provide any inform there is no way for me to know.  Could you
please explain the issue you saw.

Robert.

On 4 April 2018 at 11:35, Tim Whowantstoknow  wrote:
> Hi,
>
> since I couldn't get 3.6.0 rc2 to run, I have been working with 3.4.0, so I'm 
> not sure if this is happening in the current version.
>
> I have been trying out Texture2DArrays and have loaded in 16 images, set them 
> to a Texture2Array object and tried to display it. When calling frame the 
> first time, I got some warnings:
> "Warning: Texture2DArray::applyTexImage2DArray_subload(..) given image do 
> have wrong dimension or internal format."
> None of the loaded images is displayed as a texture.
> I have debugged into the OSG Code to look for the error, and it turns out, 
> that upon loading (a bmp file for every texture, all have the same width and 
> height), the internal texture format of the images is set to 3 (which is 
> GL_RGB at some point of the code), but the Texture2DArray internal format is 
> 6407, which is also GL_RGB.
>
> I went on to set the image internal texture format to GL_RGB (which in this 
> case is 6407) and now it works.
>
> I'd add a minimal working example, but the forum seems to not let me do that, 
> so sorry about that.
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=73253#73253
>
>
>
>
>
> ___
> 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] Memory problems in Windows/Visual Studio

2018-04-19 Thread Mark Jablin
Hi,

I'm just getting started with OpenSceneGraph and just working through some 
basic examples.  I'm running Windows 10 and using Visual Studio 17.  I'm 
building everything using x64.

The problem occurs any time I use a ref_ptr.  All the examples I've run work 
properly until exiting the application, when I get  a deallocation error.

I have attached my source code, the OSG debug output, and a screenshot of the 
error message.

It seems like I have a setting wrong or maybe missed something when I 
configured OSG when installing it.  Does anyone have any ideas about where to 
start debugging this?

Thank you!

Mark

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




Attachments: 
http://forum.openscenegraph.org//files/error_209.jpg
http://forum.openscenegraph.org//files/main_675.cpp
http://forum.openscenegraph.org//files/output_686.txt


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


Re: [osg-users] Memory problems in Windows/Visual Studio

2018-04-19 Thread Robert Osfield
HI Mark,

This is pretty odd, ref_ptr<> is pretty well tested over the years
(it's not far off two decades old now :-)  and is widely used under
Windows and all other platforms by many thousands of developers.  So
there has to be something astray with your setup.   How did you
configure the OSG when you built it?

What happens when you don't use your LogFileHandler?

Also what version of the OSG are you using?

Does this happen when using standard OSG example like osgviewer?

Robert.

On 19 April 2018 at 16:20, Mark Jablin  wrote:
> Hi,
>
> I'm just getting started with OpenSceneGraph and just working through some 
> basic examples.  I'm running Windows 10 and using Visual Studio 17.  I'm 
> building everything using x64.
>
> The problem occurs any time I use a ref_ptr.  All the examples I've run work 
> properly until exiting the application, when I get  a deallocation error.
>
> I have attached my source code, the OSG debug output, and a screenshot of the 
> error message.
>
> It seems like I have a setting wrong or maybe missed something when I 
> configured OSG when installing it.  Does anyone have any ideas about where to 
> start debugging this?
>
> Thank you!
>
> Mark
>
> --
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=73445#73445
>
>
>
>
> Attachments:
> http://forum.openscenegraph.org//files/error_209.jpg
> http://forum.openscenegraph.org//files/main_675.cpp
> http://forum.openscenegraph.org//files/output_686.txt
>
>
> ___
> 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] Help on multitexturing..

2018-04-19 Thread Rowley, Marlin R
Hello,

I've been wracking my brain all day on trying to figure out how to do this with 
no clear examples found online.

I have this set of calls in my C++:

mGroupState = mBoundGeometry->getOrCreateStateSet();
  mGroupState->getOrCreateUniform("BaseTexSampler", 
osg::Uniform::SAMPLER_2D)->set(mBaseColor);
  mGroupState->getOrCreateUniform("BaseWeight", 
osg::Uniform::FLOAT)->set(mBaseWeight);
  mGroupState->setTextureAttributeAndModes(BASE_TEXTURE_UNIT, mBaseColor, 
osg::StateAttribute::ON);

I've bound this base texture to texture unit (BASE_TEXTURE_UNIT = 1).

Later in the code, I have this in another function if I create another layer 
with another texture:


mGroupState->getOrCreateUniform("TexLayerSampler0", 
osg::Uniform::SAMPLER_2D)->set(tex);

mGroupState->setTextureAttribute(BASE_TEXTURE_UNIT + 1, tex, 
osg::StateAttribute::ON);

Where I've created a second texture and want it to reside in texture unit 2.

However, in my shader code when indexing the TexLayerSampler0, I only get base 
texture.

finalColor = texture(TexLayerSampler0, LayeredTexCoords[0].st);

Which is wrong.  I'm stil trying to figure out OpenGL and how it works along 
with OSG so sorry for the inexperience.

-M


Marlin Rowley
Software Engineer, Staff
[cid:image002.jpg@01D39374.DEC5A2E0]
Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
marlin.r.row...@lmco.com

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


[osg-users] [build] Building OpenSceneGraph-3.6.0 on Windows 10 with VS2017

2018-04-19 Thread André Martins
Hi,
I would like to request some help since I've been unable to build the project 
using CMake and VS2017.
It's my first time building such a huge project and seems overwhelming at first.
I tried searching online, in the forum and in the openscenegraph website but 
none of the options worked...

What I've done:

Downloaded the source code from:
github .com/openscenegraph/OpenSceneGraph/tree/OpenSceneGraph-3.6.0

Downloaded dependencies from:
download.osgvisual .org/3rdParty_VS2017_v141_x64_V11_full.7z

CmakeSetup on Cmake 3.11.1:
Visual Studio 15 2014 Win64
Use default native compilers



Upon CMake Generation I edited CMAKE_INCLUDE_PATH and CMAKE_LIBRARY_PATH to 
match the dependencies include and lib folders, respectively.
I also updated SLD2_INCLUDE_DIR AND SDL2_LIBRARY_LIB sinca I had already 
compiled SDL2 previously.
Here's the output:



Code:
CMake Deprecation Warning at CMakeLists.txt:40 (cmake_policy):
  The OLD behavior for policy CMP0008 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


Could NOT find EGL (missing: EGL_LIBRARY EGL_INCLUDE_DIR) 
Checking windows version...
64 bit architecture detected
Could NOT find Freetype (missing: FREETYPE_LIBRARY) (found version "2.7.1")
Could NOT find Jasper (missing: JASPER_LIBRARIES JASPER_INCLUDE_DIR) 
Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
Trying to find DCMTK expecting DCMTKConfig.cmake
Trying to find DCMTK expecting DCMTKConfig.cmake - failed
Trying to find DCMTK relying on FindDCMTK.cmake
Please set DCMTK_DIR and re-run configure (missing: DCMTK_config_INCLUDE_DIR 
DCMTK_dcmdata_INCLUDE_DIR DCMTK_dcmimage_INCLUDE_DIR DCMTK_dcmimgle_INCLUDE_DIR 
DCMTK_dcmjpeg_INCLUDE_DIR DCMTK_dcmjpls_INCLUDE_DIR DCMTK_dcmnet_INCLUDE_DIR 
DCMTK_dcmpstat_INCLUDE_DIR DCMTK_dcmqrdb_INCLUDE_DIR DCMTK_dcmsign_INCLUDE_DIR 
DCMTK_dcmsr_INCLUDE_DIR DCMTK_dcmtls_INCLUDE_DIR DCMTK_ofstd_INCLUDE_DIR 
DCMTK_oflog_INCLUDE_DIR) 
Trying to find DCMTK relying on FindDCMTK.cmake - ok
Could NOT find GStreamer (missing: GSTREAMER_INCLUDE_DIRS GSTREAMER_LIBRARIES 
GSTREAMER_VERSION GSTREAMER_BASE_INCLUDE_DIRS GSTREAMER_BASE_LIBRARIES 
GSTREAMER_APP_INCLUDE_DIRS GSTREAMER_APP_LIBRARIES 
GSTREAMER_PBUTILS_INCLUDE_DIRS GSTREAMER_PBUTILS_LIBRARIES) 
Could NOT find SDL (missing: SDL_LIBRARY SDL_INCLUDE_DIR) 
Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
Configuring done
Generating done





After that I opened the solution on VS2017 and built ALL_BUILD

Heres the result:

Code:

1>-- Compilação iniciada: Projeto: ZERO_CHECK, Configuração: Debug x64 
--
2>-- Compilação iniciada: Projeto: osgDB, Configuração: Debug x64 --
2>ObjectWrapper.cpp
2>InputStream.cpp
2>OutputStream.cpp
2>Compressors.cpp
2>Archive.cpp
2>AuthenticationMap.cpp
2>Callbacks.cpp
2>ClassInterface.cpp
2>ConvertBase64.cpp
2>ConvertUTF.cpp
2>DatabasePager.cpp
2>DatabaseRevisions.cpp
2>DotOsgWrapper.cpp
2>DynamicLibrary.cpp
2>ExternalFileWriter.cpp
2>Field.cpp
2>FieldReader.cpp
2>FieldReaderIterator.cpp
2>FileCache.cpp
2>FileNameUtils.cpp
2>Gerando Código...
2>Compilando...
2>FileUtils.cpp
2>fstream.cpp
2>ImageOptions.cpp
2>ImagePager.cpp
2>Input.cpp
2>MimeTypes.cpp
2>ObjectCache.cpp
2>Output.cpp
2>Options.cpp
2>PluginQuery.cpp
2>ReaderWriter.cpp
2>ReadFile.cpp
2>Registry.cpp
2>SharedStateManager.cpp
2>StreamOperator.cpp
2>Version.cpp
2>WriteFile.cpp
2>XmlParser.cpp
2>Gerando Código...
2>   Criando biblioteca 
C:/Users/AFCM_/source/repos/OpenSceneGraph-OpenSceneGraph-3.6.0/OpenSceneGraph-OpenSceneGraph-3.6.0/build/lib/osgDBd.lib
 e objeto 
C:/Users/AFCM_/source/repos/OpenSceneGraph-OpenSceneGraph-3.6.0/OpenSceneGraph-OpenSceneGraph-3.6.0/build/lib/osgDBd.exp
2>osgDB.vcxproj -> 
C:\Users\AFCM_\source\repos\OpenSceneGraph-OpenSceneGraph-3.6.0\OpenSceneGraph-OpenSceneGraph-3.6.0\build\bin\osg156-osgDBd.dll
3>-- Compilação iniciada: Projeto: osgText, Configuração: Debug x64 --
4>-- Compilação iniciada: Projeto: osgGA, Configuração: Debug x64 --
5>-- Compilação iniciada: Projeto: osgFX, Configuração: Debug x64 --
6>-- Compilação iniciada: Projeto: osgParticle, Configuração: Debug x64 
--
7>-- Compilação iniciada: Projeto: osgShadow, Configuração: Debug x64 --
8>-- Compilação iniciada: Projeto: osgTerrain, Configuração: Debug x64 
--
9>-- Compilação iniciada: Projeto: Plugins trk, Configuração: Debug x64 
--
10>-- Compilação iniciada: Projeto: Plugins vtf, Configuração: Debug x64 
--
5>   Criando biblioteca 
C:/Users/AFCM_/source/repos/OpenSceneGraph-OpenSceneGraph-3.6.0/OpenSceneGraph-OpenSceneGraph-3.6.0/build/lib/osgFXd.lib
 e objeto 

Re: [osg-users] Help on multitexturing..

2018-04-19 Thread Robert Osfield
Hi Marlin,

The sampler value should be an int, so you shouldn't pass a texture pointer
to your setting of the TexLayerSampler0 second sampler.  Perhaps this was
just a copy and paste error.

As a general note, normally one would assign a base texture on texture unit
0 rather than 1.

Robert.



On 19 April 2018 at 19:06, Rowley, Marlin R 
wrote:

> Hello,
>
>
>
> I’ve been wracking my brain all day on trying to figure out how to do this
> with no clear examples found online.
>
>
>
> I have this set of calls in my C++:
>
>
>
> mGroupState = mBoundGeometry->getOrCreateStateSet();
>
>   mGroupState->getOrCreateUniform("BaseTexSampler", osg::Uniform::
> SAMPLER_2D)->set(mBaseColor);
>
>   mGroupState->getOrCreateUniform("BaseWeight", osg::Uniform::FLOAT)->
> set(mBaseWeight);
>
>   mGroupState->setTextureAttributeAndModes(BASE_TEXTURE_UNIT,
> mBaseColor, osg::StateAttribute::ON);
>
>
>
> I’ve bound this base texture to texture unit (BASE_TEXTURE_UNIT = 1).
>
>
>
> Later in the code, I have this in another function if I create another
> layer with another texture:
>
>
>
> mGroupState->getOrCreateUniform("TexLayerSampler0", 
> osg::Uniform::SAMPLER_2D)->set(tex);
>
> mGroupState->setTextureAttribute(BASE_TEXTURE_UNIT + 1, tex, 
> osg::StateAttribute::ON);
>
>
>
> Where I’ve created a second texture and want it to reside in texture unit
> 2.
>
>
>
> However, in my shader code when indexing the TexLayerSampler0, I only get
> base texture.
>
>
>
> finalColor = texture(TexLayerSampler0, LayeredTexCoords[0].st);
>
>
>
> Which is wrong.  I’m stil trying to figure out OpenGL and how it works
> along with OSG so sorry for the inexperience.
>
>
>
> -M
>
>
>
> 
>
> Marlin Rowley
>
> Software Engineer, Staff
>
> [image: cid:image002.jpg@01D39374.DEC5A2E0]
>
> *Missiles and Fire Control*
>
> 972-603-1931 (office)
>
> 214-926-0622 (mobile)
>
> marlin.r.row...@lmco.com
>
>
>
> ___
> 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] Memory problems in Windows/Visual Studio

2018-04-19 Thread Mark Jablin
Robert,

Well, now I'm totally confused about how I convinced myself that it was the 
ref_ptr that was causing the problem, as removing the LogFileHandler solves the 
problem.  

I'll see if I can figure out what's going on there.  Thanks for the help! 

Mark

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





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


Re: [osg-users] 'fatal error C1128: number of sections exceeded object file format limit' under MSVC2015

2018-04-19 Thread Robert Osfield
Hi Jason,

On 18 April 2018 at 20:59, Jason Beverage  wrote:
> I'm compiling the master in debug with MSVC 2015 and running into this issue
> again:
> http://forum.openscenegraph.org/viewtopic.php?t=16012&start=0&postdays=0&postorder=asc&highlight=
>
> This time it's with Geode.obj
>
> I've added /bigobj just to get it building here locally.  Not sure if there
> is anything else we can take out of the headers to slim it down or not.
>
> This is my first time seeing this issue so I'm not 100% sure if it's a good
> idea to just enable /bigobj all the time or not.

I don't have any VisualStudio expertise so have to defer to Windows
devs as how best to guide the build with VisualStudio.  So if you feel
adding /bigobj is required then submit a PR to add this.

What are the cons about enabling /bigobj?

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


Re: [osg-users] Memory problems in Windows/Visual Studio

2018-04-19 Thread Robert Osfield
Hi Mark,

On 19 April 2018 at 20:08, Mark Jablin  wrote:
> Well, now I'm totally confused about how I convinced myself that it was the 
> ref_ptr that was causing the problem, as removing the LogFileHandler solves 
> the problem.
>
> I'll see if I can figure out what's going on there.  Thanks for the help!

Could you share the LogFileHandler implementation?  This might enable
others to test a complete application and spot the cause of the
problem.

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


Re: [osg-users] Memory problems in Windows/Visual Studio

2018-04-19 Thread Robert Osfield
Hi Mark,

One thing you could try with your application is to replace the line:


  return viewer.run();

With


  int result = viewer.run();
  osg::setNotifyHandler(0);
  return result;

Robert.


On 19 April 2018 at 20:15, Robert Osfield  wrote:
> Hi Mark,
>
> On 19 April 2018 at 20:08, Mark Jablin  wrote:
>> Well, now I'm totally confused about how I convinced myself that it was the 
>> ref_ptr that was causing the problem, as removing the LogFileHandler solves 
>> the problem.
>>
>> I'll see if I can figure out what's going on there.  Thanks for the help!
>
> Could you share the LogFileHandler implementation?  This might enable
> others to test a complete application and spot the cause of the
> problem.
>
> Robert.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] EXTERNAL: Re: Help on multitexturing..

2018-04-19 Thread Rowley, Marlin R
I thought the sampler value was a pointer to a texture?

I set the texture unit to 1 because we’ll need the base texture unit 0 later 
on.  My goal is to turn on up to 10 texture units and blend them all together.

To be more clear, he is some more code:

mGroupState = mBoundGeometry->getOrCreateStateSet();
  mGroupState->getOrCreateUniform("BaseTexSampler", 
osg::Uniform::SAMPLER_2D)->set(mBaseColor.get());
  mGroupState->getOrCreateUniform("BaseWeight", 
osg::Uniform::FLOAT)->set(mBaseWeight);
  mGroupState->setTextureAttributeAndModes(BASE_TEXTURE_UNIT, mBaseColor, 
osg::StateAttribute::ON);

This sets the base texture unit 1 to be bound to the mBaseColor (which is a 
osg::ref_ptr) created before the function call.

Then, I do this right afterwards:

if (mNumLayers)
  {
int indx = 0;
  osg::ref_ptr tex = mTextureMap[indx];// iter->second;
mGroupState->getOrCreateUniform("TexLayerSampler0", 
osg::Uniform::SAMPLER_2D)->set(tex.get());
mGroupState->setTextureAttributeAndModes(BASE_TEXTURE_UNIT + 1, 
tex, osg::StateAttribute::OVERRIDE);
  }

Here I get the texture from a std::map.  And then I set the sampler to be bound 
to the texture.  I then bind the texture unit 2 to the texture.

-M


Marlin Rowley
Software Engineer, Staff
[cid:image002.jpg@01D39374.DEC5A2E0]
Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
marlin.r.row...@lmco.com

From: osg-users [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf 
Of Robert Osfield
Sent: Thursday, April 19, 2018 2:05 PM
To: OpenSceneGraph Users 
Subject: EXTERNAL: Re: [osg-users] Help on multitexturing..

Hi Marlin,
The sampler value should be an int, so you shouldn't pass a texture pointer to 
your setting of the TexLayerSampler0 second sampler.  Perhaps this was just a 
copy and paste error.
As a general note, normally one would assign a base texture on texture unit 0 
rather than 1.

Robert.


On 19 April 2018 at 19:06, Rowley, Marlin R 
mailto:marlin.r.row...@lmco.com>> wrote:
Hello,

I’ve been wracking my brain all day on trying to figure out how to do this with 
no clear examples found online.

I have this set of calls in my C++:

mGroupState = mBoundGeometry->getOrCreateStateSet();
  mGroupState->getOrCreateUniform("BaseTexSampler", 
osg::Uniform::SAMPLER_2D)->set(mBaseColor);
  mGroupState->getOrCreateUniform("BaseWeight", 
osg::Uniform::FLOAT)->set(mBaseWeight);
  mGroupState->setTextureAttributeAndModes(BASE_TEXTURE_UNIT, mBaseColor, 
osg::StateAttribute::ON);

I’ve bound this base texture to texture unit (BASE_TEXTURE_UNIT = 1).

Later in the code, I have this in another function if I create another layer 
with another texture:


mGroupState->getOrCreateUniform("TexLayerSampler0", 
osg::Uniform::SAMPLER_2D)->set(tex);

mGroupState->setTextureAttribute(BASE_TEXTURE_UNIT + 1, tex, 
osg::StateAttribute::ON);

Where I’ve created a second texture and want it to reside in texture unit 2.

However, in my shader code when indexing the TexLayerSampler0, I only get base 
texture.

finalColor = texture(TexLayerSampler0, LayeredTexCoords[0].st);

Which is wrong.  I’m stil trying to figure out OpenGL and how it works along 
with OSG so sorry for the inexperience.

-M


Marlin Rowley
Software Engineer, Staff
[cid:image002.jpg@01D39374.DEC5A2E0]
Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
marlin.r.row...@lmco.com


___
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] Memory problems in Windows/Visual Studio

2018-04-19 Thread Mark Jablin
Robert,

That doesn't solve the problem. 

My log file handler:


Code:
class LogFileHandler : public osg::NotifyHandler
{
public:
   LogFileHandler(const std::string& file)
   {
  m_log.open(file.c_str());
   }
   virtual ~LogFileHandler() { m_log.close(); }
   virtual void notify(osg::NotifySeverity severity,
  const char* msg)
   {
  m_log << msg;
   }
protected:
   std::ofstream m_log;
};



I took that out of OpenSceneGraph 3.0 Beginner's Guide.

I'm using OSG 3.4.1.

Thanks for your help.

Mark

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





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


Re: [osg-users] EXTERNAL: Re: EXTERNAL: Re: Help on multitexturing..

2018-04-19 Thread Rowley, Marlin R
Robert,

Changing the sampler_2d to an (int) doesn’t seem to fix the problem.  I still 
get a black texture in the scene.

Here is my updated code:

mGroupState->getOrCreateUniform("MySecondSampler", 
osg::Uniform::SAMPLER_2D)->set(BASE_TEXTURE_UNIT + 1);
mGroupState->setTextureAttributeAndModes(BASE_TEXTURE_UNIT + 1, 
mSecondColor, osg::StateAttribute::OVERRIDE);

I want to write this second texture to unit 2.  (base_texture_unit = 1 + 1).  I 
still get a black object.


Marlin Rowley
Software Engineer, Staff
[cid:image002.jpg@01D39374.DEC5A2E0]
Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
marlin.r.row...@lmco.com

From: osg-users [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf 
Of Rowley, Marlin R (US)
Sent: Thursday, April 19, 2018 2:30 PM
To: OpenSceneGraph Users 
Subject: EXTERNAL: Re: [osg-users] EXTERNAL: Re: Help on multitexturing..

I thought the sampler value was a pointer to a texture?

I set the texture unit to 1 because we’ll need the base texture unit 0 later 
on.  My goal is to turn on up to 10 texture units and blend them all together.

To be more clear, he is some more code:

mGroupState = mBoundGeometry->getOrCreateStateSet();
  mGroupState->getOrCreateUniform("BaseTexSampler", 
osg::Uniform::SAMPLER_2D)->set(mBaseColor.get());
  mGroupState->getOrCreateUniform("BaseWeight", 
osg::Uniform::FLOAT)->set(mBaseWeight);
  mGroupState->setTextureAttributeAndModes(BASE_TEXTURE_UNIT, mBaseColor, 
osg::StateAttribute::ON);

This sets the base texture unit 1 to be bound to the mBaseColor (which is a 
osg::ref_ptr) created before the function call.

Then, I do this right afterwards:

if (mNumLayers)
  {
int indx = 0;
  osg::ref_ptr tex = mTextureMap[indx];// iter->second;
mGroupState->getOrCreateUniform("TexLayerSampler0", 
osg::Uniform::SAMPLER_2D)->set(tex.get());
mGroupState->setTextureAttributeAndModes(BASE_TEXTURE_UNIT + 1, 
tex, osg::StateAttribute::OVERRIDE);
  }

Here I get the texture from a std::map.  And then I set the sampler to be bound 
to the texture.  I then bind the texture unit 2 to the texture.

-M


Marlin Rowley
Software Engineer, Staff
[cid:image002.jpg@01D39374.DEC5A2E0]
Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
marlin.r.row...@lmco.com

From: osg-users [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf 
Of Robert Osfield
Sent: Thursday, April 19, 2018 2:05 PM
To: OpenSceneGraph Users 
mailto:osg-users@lists.openscenegraph.org>>
Subject: EXTERNAL: Re: [osg-users] Help on multitexturing..

Hi Marlin,
The sampler value should be an int, so you shouldn't pass a texture pointer to 
your setting of the TexLayerSampler0 second sampler.  Perhaps this was just a 
copy and paste error.
As a general note, normally one would assign a base texture on texture unit 0 
rather than 1.

Robert.


On 19 April 2018 at 19:06, Rowley, Marlin R 
mailto:marlin.r.row...@lmco.com>> wrote:
Hello,

I’ve been wracking my brain all day on trying to figure out how to do this with 
no clear examples found online.

I have this set of calls in my C++:

mGroupState = mBoundGeometry->getOrCreateStateSet();
  mGroupState->getOrCreateUniform("BaseTexSampler", 
osg::Uniform::SAMPLER_2D)->set(mBaseColor);
  mGroupState->getOrCreateUniform("BaseWeight", 
osg::Uniform::FLOAT)->set(mBaseWeight);
  mGroupState->setTextureAttributeAndModes(BASE_TEXTURE_UNIT, mBaseColor, 
osg::StateAttribute::ON);

I’ve bound this base texture to texture unit (BASE_TEXTURE_UNIT = 1).

Later in the code, I have this in another function if I create another layer 
with another texture:


mGroupState->getOrCreateUniform("TexLayerSampler0", 
osg::Uniform::SAMPLER_2D)->set(tex);

mGroupState->setTextureAttribute(BASE_TEXTURE_UNIT + 1, tex, 
osg::StateAttribute::ON);

Where I’ve created a second texture and want it to reside in texture unit 2.

However, in my shader code when indexing the TexLayerSampler0, I only get base 
texture.

finalColor = texture(TexLayerSampler0, LayeredTexCoords[0].st);

Which is wrong.  I’m stil trying to figure out OpenGL and how it works along 
with OSG so sorry for the inexperience.

-M


Marlin Rowley
Software Engineer, Staff
[cid:image002.jpg@01D39374.DEC5A2E0]
Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
marlin.r.row...@lmco.com


___
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

Re: [osg-users] 'fatal error C1128: number of sections exceeded object file format limit' under MSVC2015

2018-04-19 Thread sam
Hi Robert,

Enabling -bigobj just changes the address space for obj files. The default
is 2^16 and /bigobj will enable 2^32. The only con that I'm aware of is
linker's that shipped prior to Visual C++ 2005 cannot read .obj files that
were produced with /bigobj.

https://msdn.microsoft.com/en-us/library/ms173499.aspx

Looks like most of the projects now force it on in CMAKE.

Thanks, Sam



On Thu, Apr 19, 2018 at 1:14 PM, Robert Osfield 
wrote:

> Hi Jason,
>
> On 18 April 2018 at 20:59, Jason Beverage  wrote:
> > I'm compiling the master in debug with MSVC 2015 and running into this
> issue
> > again:
> > http://forum.openscenegraph.org/viewtopic.php?t=16012&;
> start=0&postdays=0&postorder=asc&highlight=
> >
> > This time it's with Geode.obj
> >
> > I've added /bigobj just to get it building here locally.  Not sure if
> there
> > is anything else we can take out of the headers to slim it down or not.
> >
> > This is my first time seeing this issue so I'm not 100% sure if it's a
> good
> > idea to just enable /bigobj all the time or not.
>
> I don't have any VisualStudio expertise so have to defer to Windows
> devs as how best to guide the build with VisualStudio.  So if you feel
> adding /bigobj is required then submit a PR to add this.
>
> What are the cons about enabling /bigobj?
>
> Robert.
> ___
> 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] EXTERNAL: Re: EXTERNAL: Re: EXTERNAL: Re: Help on multitexturing..

2018-04-19 Thread Rowley, Marlin R
Robert,

I’ve investigated further and believe I’ve found the problem but not sure how 
to fix it.

I have a constructor for a layered texture class where I pass it an image as 
the base layer.  I set the texture mode and create a texture in this 
constructor for the base class.  I also assign BASE_TEXTURE_UNIT to the 
sampler2D as an id to bind the texture to it for the shader (thanks for this..).

I run a function called updateShaders() (which I’ve sent snippets of code for) 
at the bottom of my constructor class.  If I access this base sampler texture 
in the shader, I get what I expect on the geometry.

Now, when I call a function to create a layer for this layered class (i.e. 
createLayer(some image, weight, etc..)) from the application, I create a 
texture from this function and I run the updateShaders() function again binding 
the BASE_TEXTURE_UNIT + 1 to my second sampler node and trying to bind it to 
the texture I just created.  THIS is what’s NOT working properly.  When I run 
GPUPerf debugger, I see that the texture unit is assigned the correct #2, but 
the BoundID isn’t equal to the unit number.  So when I sample from the texture 
in the shader, it’s just black because it can’t see this new binding (assume no 
blending in the shader just an overwrite).

To test this, I reconfigured my constructor to take 2 images instead of 1 image 
for the base and I forego the call to createLayer() in my application.  Sure 
enough, the binding is properly set.  Am I missing some kind of callback that 
should force a rebind when I call updateShaders()?

-M


Marlin Rowley
Software Engineer, Staff
[cid:image002.jpg@01D39374.DEC5A2E0]
Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
marlin.r.row...@lmco.com

From: osg-users [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf 
Of Rowley, Marlin R (US)
Sent: Thursday, April 19, 2018 3:25 PM
To: OpenSceneGraph Users 
Subject: EXTERNAL: Re: [osg-users] EXTERNAL: Re: EXTERNAL: Re: Help on 
multitexturing..

Robert,

Changing the sampler_2d to an (int) doesn’t seem to fix the problem.  I still 
get a black texture in the scene.

Here is my updated code:

mGroupState->getOrCreateUniform("MySecondSampler", 
osg::Uniform::SAMPLER_2D)->set(BASE_TEXTURE_UNIT + 1);
mGroupState->setTextureAttributeAndModes(BASE_TEXTURE_UNIT + 1, 
mSecondColor, osg::StateAttribute::OVERRIDE);

I want to write this second texture to unit 2.  (base_texture_unit = 1 + 1).  I 
still get a black object.


Marlin Rowley
Software Engineer, Staff
[cid:image002.jpg@01D39374.DEC5A2E0]
Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
marlin.r.row...@lmco.com

From: osg-users [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf 
Of Rowley, Marlin R (US)
Sent: Thursday, April 19, 2018 2:30 PM
To: OpenSceneGraph Users 
mailto:osg-users@lists.openscenegraph.org>>
Subject: EXTERNAL: Re: [osg-users] EXTERNAL: Re: Help on multitexturing..

I thought the sampler value was a pointer to a texture?

I set the texture unit to 1 because we’ll need the base texture unit 0 later 
on.  My goal is to turn on up to 10 texture units and blend them all together.

To be more clear, he is some more code:

mGroupState = mBoundGeometry->getOrCreateStateSet();
  mGroupState->getOrCreateUniform("BaseTexSampler", 
osg::Uniform::SAMPLER_2D)->set(mBaseColor.get());
  mGroupState->getOrCreateUniform("BaseWeight", 
osg::Uniform::FLOAT)->set(mBaseWeight);
  mGroupState->setTextureAttributeAndModes(BASE_TEXTURE_UNIT, mBaseColor, 
osg::StateAttribute::ON);

This sets the base texture unit 1 to be bound to the mBaseColor (which is a 
osg::ref_ptr) created before the function call.

Then, I do this right afterwards:

if (mNumLayers)
  {
int indx = 0;
  osg::ref_ptr tex = mTextureMap[indx];// iter->second;
mGroupState->getOrCreateUniform("TexLayerSampler0", 
osg::Uniform::SAMPLER_2D)->set(tex.get());
mGroupState->setTextureAttributeAndModes(BASE_TEXTURE_UNIT + 1, 
tex, osg::StateAttribute::OVERRIDE);
  }

Here I get the texture from a std::map.  And then I set the sampler to be bound 
to the texture.  I then bind the texture unit 2 to the texture.

-M


Marlin Rowley
Software Engineer, Staff
[cid:image002.jpg@01D39374.DEC5A2E0]
Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
marlin.r.row...@lmco.com

From: osg-users [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf 
Of Robert Osfield
Sent: Thursday, April 19, 2018 2:05 PM
To: OpenSceneGraph Users 
mailto:osg-users@lists.openscenegraph.org>>
Subject: EXTERNAL: Re: [osg-users] Help on multitexturing..

Hi Marlin,
The sampler value should be an int, so you shouldn't pass a texture pointer to 
your setting of the 

Re: [osg-users] EXTERNAL: Re: EXTERNAL: Re: EXTERNAL: Re: EXTERNAL: Re: Help on multitexturing..

2018-04-19 Thread Rowley, Marlin R
Robert,

This problem has been solved.

Answer:


  1.  Passing strings to set a uniform name will NOT automatically convert 
numbers to strings (i.e. getOrCreateUniform(“some_string” + 4, … ) will not 
work.  It must be converted first. (i.e. getOrCreateUniform(“some_string” + 
std::to_string(4), … )
  2.  You can NOT index an array when setting a uniform’s value (i.e. 
uniform->set(num_array[0])).. It needs to be copied first (i.e. int x = 
num_array[0]; uniform->set(x);

Hope this helps others who are getting their feet wet with OSG.

Cheers,

-M


Marlin Rowley
Software Engineer, Staff
[cid:image002.jpg@01D39374.DEC5A2E0]
Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
marlin.r.row...@lmco.com

From: osg-users [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf 
Of Rowley, Marlin R (US)
Sent: Thursday, April 19, 2018 3:54 PM
To: OpenSceneGraph Users 
Subject: EXTERNAL: Re: [osg-users] EXTERNAL: Re: EXTERNAL: Re: EXTERNAL: Re: 
Help on multitexturing..

Robert,

I’ve investigated further and believe I’ve found the problem but not sure how 
to fix it.

I have a constructor for a layered texture class where I pass it an image as 
the base layer.  I set the texture mode and create a texture in this 
constructor for the base class.  I also assign BASE_TEXTURE_UNIT to the 
sampler2D as an id to bind the texture to it for the shader (thanks for this..).

I run a function called updateShaders() (which I’ve sent snippets of code for) 
at the bottom of my constructor class.  If I access this base sampler texture 
in the shader, I get what I expect on the geometry.

Now, when I call a function to create a layer for this layered class (i.e. 
createLayer(some image, weight, etc..)) from the application, I create a 
texture from this function and I run the updateShaders() function again binding 
the BASE_TEXTURE_UNIT + 1 to my second sampler node and trying to bind it to 
the texture I just created.  THIS is what’s NOT working properly.  When I run 
GPUPerf debugger, I see that the texture unit is assigned the correct #2, but 
the BoundID isn’t equal to the unit number.  So when I sample from the texture 
in the shader, it’s just black because it can’t see this new binding (assume no 
blending in the shader just an overwrite).

To test this, I reconfigured my constructor to take 2 images instead of 1 image 
for the base and I forego the call to createLayer() in my application.  Sure 
enough, the binding is properly set.  Am I missing some kind of callback that 
should force a rebind when I call updateShaders()?

-M


Marlin Rowley
Software Engineer, Staff
[cid:image002.jpg@01D39374.DEC5A2E0]
Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
marlin.r.row...@lmco.com

From: osg-users [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf 
Of Rowley, Marlin R (US)
Sent: Thursday, April 19, 2018 3:25 PM
To: OpenSceneGraph Users 
mailto:osg-users@lists.openscenegraph.org>>
Subject: EXTERNAL: Re: [osg-users] EXTERNAL: Re: EXTERNAL: Re: Help on 
multitexturing..

Robert,

Changing the sampler_2d to an (int) doesn’t seem to fix the problem.  I still 
get a black texture in the scene.

Here is my updated code:

mGroupState->getOrCreateUniform("MySecondSampler", 
osg::Uniform::SAMPLER_2D)->set(BASE_TEXTURE_UNIT + 1);
mGroupState->setTextureAttributeAndModes(BASE_TEXTURE_UNIT + 1, 
mSecondColor, osg::StateAttribute::OVERRIDE);

I want to write this second texture to unit 2.  (base_texture_unit = 1 + 1).  I 
still get a black object.


Marlin Rowley
Software Engineer, Staff
[cid:image002.jpg@01D39374.DEC5A2E0]
Missiles and Fire Control
972-603-1931 (office)
214-926-0622 (mobile)
marlin.r.row...@lmco.com

From: osg-users [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf 
Of Rowley, Marlin R (US)
Sent: Thursday, April 19, 2018 2:30 PM
To: OpenSceneGraph Users 
mailto:osg-users@lists.openscenegraph.org>>
Subject: EXTERNAL: Re: [osg-users] EXTERNAL: Re: Help on multitexturing..

I thought the sampler value was a pointer to a texture?

I set the texture unit to 1 because we’ll need the base texture unit 0 later 
on.  My goal is to turn on up to 10 texture units and blend them all together.

To be more clear, he is some more code:

mGroupState = mBoundGeometry->getOrCreateStateSet();
  mGroupState->getOrCreateUniform("BaseTexSampler", 
osg::Uniform::SAMPLER_2D)->set(mBaseColor.get());
  mGroupState->getOrCreateUniform("BaseWeight", 
osg::Uniform::FLOAT)->set(mBaseWeight);
  mGroupState->setTextureAttributeAndModes(BASE_TEXTURE_UNIT, mBaseColor, 
osg::StateAttribute::ON);

This sets the base texture unit 1 to be bound to the mBaseColor (which is a 
osg::ref_ptr) created before the function call.

Then, I do this right afterwar