Re: [osg-users] 2D orthographic view with panning and zooming

2014-06-18 Thread David Sellin
Hi,

If think if you set viewer-setCameraManipulator( 0 ) the view matrix won't be 
overwritten by any camera manipulator. I haven't tried it recently but I think 
that's how it works.

Otherwise maybe this could work:


Code:
while( !viewer-done() )
{

viewer-advance();
viewer-eventTraversal();
viewer-updateTraversal();

// Modify view matrix here

viewer-renderingTraversals();
}



Thank you!

Cheers,
David

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





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


Re: [osg-users] Calculating variables for setProjectionMatrixAsOrtho2D

2014-06-10 Thread David Sellin
Hi,

I made a small test application. Try it out if you want to and see it it works 
and does what you want.

Code:
int main( int argc, char **argv )
{
osg::Group *root = new osg::Group;

osg::Group *scene = GetScene(); // - Cows, planes and stuff

root-addChild( scene );

// Graphics Context and Traits
osg::ref_ptrosg::GraphicsContext::Traits traits = new 
osg::GraphicsContext::Traits;
traits-windowName = Test app;
traits-screenNum = 0;
traits-x = 0;
traits-y = 0;
traits-width = WIDTH;
traits-height = HEIGHT;
traits-windowDecoration = false;
traits-doubleBuffer = true;
traits-sharedContext = 0;
traits-samples = 8;
traits-useCursor = true;
traits-alpha = 1.0;
const std::string version( 3.1 );
traits-glContextVersion = version;

osg::ref_ptrosg::GraphicsContext gc = 
osg::GraphicsContext::createGraphicsContext( traits.get() );

// Viewer
osg::ref_ptrosgViewer::Viewer viewer = new osgViewer::Viewer();
viewer-getCamera()-setProjectionMatrixAsOrtho( -100, 100, -100, 100, 
-100, 100 );
viewer-getCamera()-setCullingMode( osg::CullSettings::NO_CULLING );
viewer-getCamera()-setComputeNearFarMode( 
osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR );
viewer-getCamera()-setGraphicsContext( gc.get() );
viewer-getCamera()-setViewport( new osg::Viewport( 0, 0, WIDTH, 
HEIGHT) );
viewer-setThreadingModel( osgViewer::ViewerBase::SingleThreaded );
viewer-setCameraManipulator( new osgGA::TrackballManipulator );
viewer-setSceneData( root );

viewer-realize();

while( !viewer-done() )
{
viewer-advance();
viewer-eventTraversal();
viewer-updateTraversal();
viewer-renderingTraversals();
}

return 0;
}



Thank you!

Cheers,
David

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





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


Re: [osg-users] Calculating variables for setProjectionMatrixAsOrtho2D

2014-06-09 Thread David Sellin
Hi,

Maybe it's your near far values. Your model might be placed in origo with 
bounds smaller than 1. And your near value starts at 1.

Try:
Code:
Viewer-getCamera()-setProjectionMatrixAsOrtho(bb.xMin(),bb.xMax(),bb.yMin(),bb.yMax(),-100,100);
 



Thank you!

Cheers,
David

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





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


[osg-users] Problem with fullscreen hiding dialog window

2013-03-13 Thread David Sellin
Hi,

I run my osg program in fullscreen mode by setting traits width height to the 
same as desktop, x and y position to 0 and disabling window decoration. This 
prevents my windows file input dialog to show (it opens behind the osg window 
and I need to alt+tab to it). It shows at top level when running in a smaller 
osg window that doesn't cover the the whole desktop.

Can I set the osg window options to have full screen specifications without the 
program going into fullscreen mode? Just having the window floating on top.

I use 
http://msdn.microsoft.com/en-us/library/windows/desktop/bb776913%28v=vs.85%29.aspx
 to open the file dialog on Windows 7 x64 and OSG version 3.1.3. Maybe there 
are better approaches to do this?

Thank you!

Cheers,
David

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





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


Re: [osg-users] Problem with fullscreen hiding dialog window

2013-03-13 Thread David Sellin
It doesn't seem to be a flag for that, not that I can see. But I don't have any 
experince of the windows api.

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





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


Re: [osg-users] Problem with fullscreen hiding dialog window

2013-03-13 Thread David Sellin
Here's the code which is basically the same as in the link in my initial post, 
slightly modified.



Code:

// Indices of file types
#define INDEX_COLLADA 1
#define INDEX_OPENSCENEGRAPH 2
#define INDEX_KEYHOLEMARKUPLANGUAGE 3
#define INDEX_ALLFILES 4

#define FILE_TYPE_MODELS 1
#define FILE_TYPE_IMAGES 2
#define FILE_TYPE_TERRAFORM 3

class CDialogEventHandler : public IFileDialogEvents,
public 
IFileDialogControlEvents
{
public:
// IUnknown methods
IFACEMETHODIMP QueryInterface(REFIID riid, void** ppv)
{
static const QITAB qit[] = {
QITABENT(CDialogEventHandler, IFileDialogEvents),
QITABENT(CDialogEventHandler, IFileDialogControlEvents),
{ 0 },
};
return QISearch(this, qit, riid, ppv);
}

IFACEMETHODIMP_(ULONG) AddRef()
{
return InterlockedIncrement(_cRef);
}

IFACEMETHODIMP_(ULONG) Release()
{
long cRef = InterlockedDecrement(_cRef);
if (!cRef)
delete this;
return cRef;
}

// IFileDialogEvents methods
IFACEMETHODIMP OnFileOk(IFileDialog *) { return S_OK; };
IFACEMETHODIMP OnFolderChange(IFileDialog *) { return S_OK; };
IFACEMETHODIMP OnFolderChanging(IFileDialog *, IShellItem *) { return 
S_OK; };
IFACEMETHODIMP OnHelp(IFileDialog *) { return S_OK; };
IFACEMETHODIMP OnSelectionChange(IFileDialog *) { return S_OK; };
IFACEMETHODIMP OnShareViolation(IFileDialog *, IShellItem *, 
FDE_SHAREVIOLATION_RESPONSE *) { return S_OK; };
IFACEMETHODIMP OnTypeChange(IFileDialog *pfd) { return S_OK; };
IFACEMETHODIMP OnOverwrite(IFileDialog *, IShellItem *, 
FDE_OVERWRITE_RESPONSE *) { return S_OK; };

// IFileDialogControlEvents methods
IFACEMETHODIMP OnItemSelected(IFileDialogCustomize *pfdc, DWORD 
dwIDCtl, DWORD dwIDItem) { return S_OK; };
IFACEMETHODIMP OnButtonClicked(IFileDialogCustomize *, DWORD) { return 
S_OK; };
IFACEMETHODIMP OnCheckButtonToggled(IFileDialogCustomize *, DWORD, 
BOOL) { return S_OK; };
IFACEMETHODIMP OnControlActivating(IFileDialogCustomize *, DWORD) { 
return S_OK; };

CDialogEventHandler() : _cRef(1) { };
private:
~CDialogEventHandler() { };
long _cRef;
};

// Instance creation helper
HRESULT CDialogEventHandler_CreateInstance(REFIID riid, void **ppv)
{
*ppv = NULL;
CDialogEventHandler *pDialogEventHandler = new (std::nothrow) 
CDialogEventHandler();
HRESULT hr = pDialogEventHandler ? S_OK : E_OUTOFMEMORY;
if (SUCCEEDED(hr))
{
hr = pDialogEventHandler-QueryInterface(riid, ppv);
pDialogEventHandler-Release();
}
return hr;
}

HRESULT basicFileOpen(std::wstring foundPath, int fileTypes )
{
// CoCreate the File Open Dialog object.
IFileDialog *pfd = NULL;
HRESULT hr = CoCreateInstance(CLSID_FileOpenDialog, 
  NULL, 
  CLSCTX_INPROC_SERVER, 
  IID_PPV_ARGS(pfd));


pfd-SetTitle( LUrban Explorer - Open );


const COMDLG_FILTERSPEC modelSaveTypes[] =
{
{LCOLLADA (*.dae), L*.dae},
{LOpenSceneGraph (*.osg; *.osgb), L*.osg;*.osgb},
{LKeyhole Markup Language (*.kmz), L*.kmz},
{LAll Files (*.*), L*.*}
};

const COMDLG_FILTERSPEC imageSaveTypes[] =
{
{LPNG (*.png), L*.png},
{LJPG (*.jpg), L*.jpg},
{LAll Files (*.*), L*.*}
};

const COMDLG_FILTERSPEC terraformSaveTypes[] =
{
{LTFI (*.terraformImage), L*.terraformImage},
{LAll Files (*.*), L*.*}
};

if (SUCCEEDED(hr))
{
// Create an event handling object, and hook it up to 
the dialog.
IFileDialogEvents *pfde = NULL;
hr = 
CDialogEventHandler_CreateInstance(IID_PPV_ARGS(pfde));
if (SUCCEEDED(hr))
{
// Hook up the event handler.
DWORD dwCookie;
hr = pfd-Advise(pfde, dwCookie);
if (SUCCEEDED(hr))
 

Re: [osg-users] Uniform arrays not working for me using Visual Studio 2010

2012-10-29 Thread David Sellin
Version 3.1.3 worked! Thank you everyone for your help.

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





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


[osg-users] Uniform arrays not working for me using Visual Studio 2010

2012-10-24 Thread David Sellin
Hi,

I ported my program from mingw and Code Blocks to Visual Studio 2010 Express 
and found that I couldn't get uniform arrays to work. Has anyone experienced 
this? I'm new to Visual Studio so I might have missed something.

I made a small test program that works on my old system but not on my new 
system:
(sorry for the weird symbols and that the include dirs fell off)


Code:

#include osg/Group
#include osgDB/ReadFile
#include osgViewer/Viewer
#include osgGA/TrackballManipulator

int main( int argc, char **argv )
{
osg::setNotifyLevel( osg::WARN );

osg::Group *root = new osg::Group;

std::string url = cow.osg;
osg::Node* modelNode = osgDB::readNodeFile( url );

//setup shaders
osg::Shader *vertshader = new osg::Shader( osg::Shader::VERTEX );
vertshader-loadShaderSourceFromFile( uniformarray.vert );
osg::Shader *fragshader = new osg::Shader( osg::Shader::FRAGMENT );
fragshader-loadShaderSourceFromFile( uniformarray.frag );
osg::Program *shaderprog = new osg::Program();
shaderprog-addShader( vertshader );
shaderprog-addShader( fragshader );
modelNode-getOrCreateStateSet()-setAttributeAndModes( shaderprog );

// Array uniform
osg::Uniform *arrayUFM = new osg::Uniform( osg::Uniform::FLOAT, array, 2 
);
arrayUFM-setElement( 0, 0.5f );
arrayUFM-setElement( 1, 1.0f );
modelNode-getOrCreateStateSet()-addUniform( arrayUFM );

root-addChild( modelNode );

// Graphics Context and Traits
osg::ref_ptrosg::GraphicsContext::Traits traits = new 
osg::GraphicsContext::Traits;
traits-x = 10;
traits-y = 10;
traits-width = 800;
traits-height = 600;
traits-doubleBuffer = true;
const std::string version( 3.1 );
traits-glContextVersion = version;

osg::ref_ptrosg::GraphicsContext gc = 
osg::GraphicsContext::createGraphicsContext( traits.get() );

// Viewer
osg::ref_ptrosgViewer::Viewer viewer = new osgViewer::Viewer();
viewer-getCamera()-setGraphicsContext( gc.get() );
viewer-getCamera()-setViewport( new osg::Viewport( 0, 0, traits-width, 
traits-height ) );
viewer-setSceneData( root );
viewer-setCameraManipulator( new osgGA::TrackballManipulator() );

viewer-run();

return 0;
}




Vertex shader:

Code:

#version 140 

uniform mat4 osg_ModelViewProjectionMatrix; 

in vec4 osg_Vertex; 

void main() 
{
  gl_Position = osg_ModelViewProjectionMatrix * osg_Vertex; 
};




Fragment shader using the array:

Code:

#version 140 

uniform float array[2];

out vec4 fragData;

void main() 
{
  fragData = vec4( 1.0, array[0], array[1], 1.0 ); 
}




Old system:
OSG 3.0 (revision 12753)
MinGW and Code Blocks
NVIDIA GEFORCE 260
WIN 7

New system
OSG 3.0.1 (stable release)
Visual C++ 2010 Express
NVIDIA GEFORCE 680
WIN 7

Thank you!

Cheers,
David[/code]

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





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


Re: [osg-users] Problem DatabasePager, setTargetFrameRate and setMaximumNumOfObjectsToCompilePerFrame with osg 2.9.11

2011-06-18 Thread David Sellin
Hi,

DanDan, what graphics card do you use? I've experienced the same problem when 
running my application with NVIDIA Quadro FX cards (4800 and 5800), but never 
with GeForce cards. Unfortunately, I have very limited debugging possibilities 
on the deployment system where this problem occurs. There's one machine (out of 
11) not having this problem and it uses a GeForce card instead of a Quadro. 
Also, my development machines use GeForce cards and works fine too.

If you solve anything, please let me know! I'll do the same.

Thank you!

Cheers,
David

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





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


Re: [osg-users] Multiple UV-sets

2010-11-30 Thread David Sellin
Ok, found it. Simply the unit parameter in
voidsetTexCoordArray (unsigned int unit, Array *)

I will continue to look for the problem in the COLLADA-plugin

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





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


[osg-users] Multiple UV-sets

2010-11-29 Thread David Sellin
Hi,

Is it possible to have more than 1 UV-set assigned to a geometry?
I loaded a COLLADA-file, exported from Maya, with osgviewer but all textures 
use the first UV-set.

Thank you!

Cheers,
David

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





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


Re: [osg-users] DatabasePager random crash

2010-05-25 Thread David Sellin
Ok, I'll upgrade as soon as possible then.

Thank you!

Cheers,
David

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





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


[osg-users] DatabasePager random crash

2010-05-23 Thread David Sellin
Hi,

I have a program that uses a paged database for rendering a terrain. It works 
great on my own computer using Windows 7 and compiling with mingw.
But when running it on the deployment environment that uses windows XP machines 
(with high quality hardware) it crashes randomly.
I get a windows error message, the program continues, but the database paging 
stops.

It feels like the poor threading capabilities of windows XP could be the 
problem. There is a lot of settings that can be investigated in the 
DatabasePager class, and wonder which ones that could make a difference?

Has anyone experienced anything similar?

I use OSG 2.9.6, and am not able to upgrade to a later version at this point. 
Unfortunately, I have limited access and debugging possibilities to the 
environment where the problem occurs.

Thank you!

Cheers,
David

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





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


Re: [osg-users] Mouse movement to control camera yaw and pitch

2010-02-28 Thread David Sellin
I think the FRAME event is detected when no other input is.

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





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