Re: [osg-users] Render normal vectors to image

2019-11-12 Thread Han Hu
Hi,

Thank you, Glenn! This is what I need!

Cheers,
Han

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





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


Re: [osg-users] Render normal vectors to image

2019-11-11 Thread Han Hu
Hi,

Thank you, Glenn.

Another less related question. My model is pagedlod in osgb format, which does 
not contain normal vectors. How can add callback functions, to dynamically 
calculate the normal vectors and attach it to the normal buffer, when loading?

Cheers,
Han

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





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


Re: [osg-users] Render normal vectors to image

2019-11-11 Thread Han Hu
Hi,

Thanks!

I can use osgUtil to compute the normal vectors on the fly. My question is how 
to render the per-vertex or per-triangles to the image, e.g. the color is the 
(x,y,z) of the normal vector, rather than the color of texture.

Cheers,
Han

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





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


[osg-users] Render normal vectors to image

2019-11-11 Thread Han Hu
Hi,

I would like to do offscreen rendering of a mesh.
Currently, I have suceeded to do this for both the color (RGB) and depth data 
using the built-in functions as below.

 
Code:


osg::ref_ptr rttImage = new osg::Image;
osg::ref_ptr depthImage = new osg::Image;

camera->attach(osg::Camera::COLOR_BUFFER, rttImage.get());
camera->attach(osg::Camera::DEPTH_BUFFER, depthImage.get());

rttImage->allocateImage(ATInfo.width, ATInfo.height, 1, GL_RGB, 
GL_UNSIGNED_BYTE);
depthImage->allocateImage(ATInfo.width, ATInfo.height, 1, 
GL_DEPTH_COMPONENT, GL_FLOAT);




But I also need to render the normal vectors to images too. I have googled this 
topic using native opengl, it seems that I have to write shaders for it. But my 
mesh are defined using the osgb plugin format, so I must implement in the osg.

I would like to know, is there an approach to do this in osg? Thanks!

Thank you!

Cheers,
Han

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





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


[osg-users] Render normal vectors to image

2019-11-11 Thread Han Hu
Hi,

I would like to do offscreen rendering of a mesh.
Currently, I have suceeded to do this for both the color (RGB) and depth data 
using the built-in functions as below.

 
Code:


osg::ref_ptr rttImage = new osg::Image;
osg::ref_ptr depthImage = new osg::Image;

camera->attach(osg::Camera::COLOR_BUFFER, rttImage.get());
camera->attach(osg::Camera::DEPTH_BUFFER, depthImage.get());

rttImage->allocateImage(ATInfo.width, ATInfo.height, 1, GL_RGB, 
GL_UNSIGNED_BYTE);
depthImage->allocateImage(ATInfo.width, ATInfo.height, 1, 
GL_DEPTH_COMPONENT, GL_FLOAT);




But I also need to render the normal vectors to images too. I have googled this 
topic using native opengl, it seems that I have to write shaders for it. But my 
mesh are defined using the osgb plugin format, so I must implement in the osg.

I would like to know, is there an approach to do this in osg? Thanks!

Thank you!

Cheers,
Han

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





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


[osg-users] Large scale point clouds rendering with PagedLOD

2019-03-08 Thread Han Hu
Hi,

I am now doing point clouds rendering (probably city-scale) using osg.

The point clouds are indexed using entwine (https://entwine.io/) to the ept 
format.
Basically, we know the bounding box of the entire scene, and the point clouds 
are saved to disk with the name D-x-y-z.laz, where D is the level of the octree 
and x,y,z are the coordinates in the octree. 

Each child level, in the octree, is strictly subdivided by 2.

In addition, the levels are drawn additively. For example, 0-0-0-0.laz is the 
root, when I want to also show it's sub level 1-0-0-0 1-1-0-0 1-1-1-0 1-0-1-0, 
the four childs and 0-0-0-0 are both draw.

So I have two questions,

(1) I want to convert the EPT format, to the pagedlod format and saved as osgb 
file, is it possible for pagedlod that both parent and it's child are both 
drawn?

(2) The laz file also contains other attributes, such as lables (interger), 
return number (interger), I also want to implement shaders to render color by 
different attribute, is it possible to save these attribute in osgb and 
correctly bind the vertext buffer to the same program location?

Thank you!

Cheers,
Han

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





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


Re: [osg-users] Backward compatibility of osgb file through Schema

2017-11-02 Thread Han Hu
Thanks anyway, this is in fact what I felt after looking into the code in the 
OutputStream code, because it seems that it changes some way to write data and 
add some new fields without version guard. 

I think the only way is to write my own write callback and set to the options 
parameter.

Han

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





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


Re: [osg-users] Backward compatibility of osgb file through Schema

2017-11-02 Thread Han Hu
Hi Robert,

My problem is that my osg version is osg 3.5.5, which I convert an obj file to 
osgb just by readRefNodeFile and writeNodeFile. But I am targeting to other 
software, which may use some lower version of osg.

I have tried osgconv in OSG 3.4.0 and the other software accept. So there seems 
to be some breaking compatibility change in the osgb format caused by either 
the osgdb_osg plugin or osgdb::OutputStream class.

Thank you!

Han

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





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


[osg-users] Backward compatibility of osgb file through Schema

2017-11-02 Thread Han Hu
Hi,

I am using a newer osg version to develop my software and I need to export the 
model in osgb file for other software, in an acient osg version.

I have googled that it is possible to control the compatibility through the 
SchemaFile. However, I have found little information on how to use it.

Is there an example or so on how to do this compatibility in osgb file?

Thank you!

Cheers,
Han

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





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


Re: [osg-users] Does osgb file has compatible issues with older osg versions?

2017-06-07 Thread Han Hu
Hi robbert,

Thank you for your reply.

I read the codes about osgDB::OutputStream and set/getFileVersion() method. 
Howere, the variable _domainVersionMap seems to record custom domains. My 
problem is not to serialize custom classes but to save data in old osgb format. 
I'm not sure if the method will solve the problem. Could you give me more tips?

Thank you wery much!


robertosfield wrote:
> Hi Han,
> 
> I'm not the original author of the serialzer so haven't tested it
> personally, but the osgDB::OutputStream class has a setFileVersion()
> method may allow you to specify the SO version which to limit the
> export to.  You'll need to use this class directly rather than rely
> upon the osg plugin to create and use this for you.
> 
> Robert.
> 
> On 6 June 2017 at 13:01, Han Hu <> wrote:
> 
> > Hi,
> > 
> > I have developed an triangle mesh editing software, the data edited are a 
> > pagedlod data in osgb format. And I have used the latest development 
> > release to save the output in osgb. The accompanying osgViewer is capable 
> > to open my exported data.
> > 
> > However, my target software to use my data is a commercial software, called 
> > skyline, it uses an older version of osg, the osg80 seen from the dll name. 
> > And it fails to open the exported data.
> > 
> > So my question is, if there is any issues with the osgb format that breaks 
> > the compatibility? If so, is there any options to export an compatible osgb 
> > format?
> > 
> > P.S. the input before my editing is both good to be open in my software and 
> > skyline.
> > 
> > Thank you!
> > 
> > Cheers,
> > Han
> > 
> > --
> > Read this topic online here:
> > http://forum.openscenegraph.org/viewtopic.php?p=71018#71018
> > 
> > 
> > 
> > 
> > 
> > ___
> > osg-users mailing list
> > 
> > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> > 
> ___
> osg-users mailing list
> 
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
> 
>  --
> Post generated by Mail2Forum


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





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


[osg-users] Does osgb file has compatible issues with older osg versions?

2017-06-06 Thread Han Hu
Hi,

I have developed an triangle mesh editing software, the data edited are a 
pagedlod data in osgb format. And I have used the latest development release to 
save the output in osgb. The accompanying osgViewer is capable to open my 
exported data. 

However, my target software to use my data is a commercial software, called 
skyline, it uses an older version of osg, the osg80 seen from the dll name. And 
it fails to open the exported data.

So my question is, if there is any issues with the osgb format that breaks the 
compatibility? If so, is there any options to export an compatible osgb format?

P.S. the input before my editing is both good to be open in my software and 
skyline. 

Thank you!

Cheers,
Han

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





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


Re: [osg-users] How to use frame buffer object in existing (not osg) window and pipeline.

2017-02-18 Thread Han Hu
Hi Robert,

Thanks for your suggestion, I understand  the bettter way is to use osg in all 
the pipeline. But the ugly fact is that I have to use existing pipeline and 
inject the view.frame() inside a fbo binding, and hope osg will draw the things 
onto the fbo texture and depth. Because I can't make others change to osg. 

And the reasons I have to inject osg into existing pipeline is that I have to 
load an pagelod data into the scene (some osgb data). And I have successfully 
do this in the viewerglut example. Otherwise I have to reinventing the big 
wheel .

Thank you!

Cheers,
Han

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





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


[osg-users] How to use frame buffer object in existing (not osg) window and pipeline.

2017-02-17 Thread Han Hu
Hi,

I know OSG viewer can render into other window as shown in the glutviewer and 
sdl viewer example. But I do not know how to use fbo for this kind of work. The 
following code describes my purpose.



Code:


osg::ref_ptr viewer;
/* The vierwer is properly set up for other window*/

FrameBufferObject fbo;
/* The fbo is properly initilize with color and depth texture attachment and 
bind to a FBO object. And the fbo class have access to the texture object and 
will be used for image based rendering technic*/

/* The rendering loop */
void draw()
{
// only repaint the whole scene when needed, because my scene is rather 
static and heavy, 
// draw fewer things 
if(dragging){
fbo.bind();
/* draw a fewer things into fbo*/
viewer.frame();
fbo.unbind();
}

/* Draw heavier things */
if(need_repaint)
{
fbo.bind();
viewer.frame();
fbo.unbind();
}

/* Do some post processing with fbo, e.g. eye dome lighting, which is  
a image based rendering techniqe */
{
/* filtering */
filter(fbo);
}

/* blit the fbo onto backbuffer */
fbo.blit();

swapbuffer();
}





So my question is how to do this kind of fbo processing in OSG, because after 
investigate osg framebufferobject, I find the logic is not like this and a 
little confuse to understand. 

Thank you!

Cheers,
Han

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





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


Re: [osg-users] writeNodeFile with texture infomation

2016-09-18 Thread Han Hu
I have figured out a solution. The steps are as the following, the core file 
for the solution lies in OutputStream::writeImage function.

1. To write a image (e.g., *.jpg) inside a file, we need the WRITE_INLINE_FILE 
mode, which is set by 

Code:

osgDB::Options options;
options.setOptionString("WriteImageHint=IncludeFile");
osgDB::writeNodeFile(*node, "out.osgb", );




2. The image has to be first write to disk and a proper search path is needed. 
A node visitor will do the image write correctly and the search path is set by

Code:
osgDB::setDataFilePathList(lists);



Cheers,
Han

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





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


[osg-users] writeNodeFile with texture infomation

2016-09-17 Thread Han Hu
Hi,

I am currently doing some preprocessing with textured meshes and save the 
output node to another file.

The input node is osgb and has texture information embedded. However after 
SmoothVisitor and using the writeNodeFile to another osgb file, the texture 
file is missing.

The same problem also exist using osgconv --smooth -O 
"WriteImageHint=IncludeFile" input output. But it can correctly create texture 
image using  -O "WriteImageHint=WriteOut".

I would like to ask that how can I also embed texture file inside the osgb node 
file? 

Thank you!

Cheers,
Han

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





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


[osg-users] PagedLOD in hooked context

2016-08-16 Thread Han Hu
Hi,

Here is my problem.

I am developing a plugin for a software, which the rendering is based on 
OpenGL. Because it does not have any API for custom rendering support, I hooked 
the SwapBuffer API of windows to my function (say h_SwapBuffer), that I know is 
called in every frame. And in h_SwapBuffer I can call the viewer.frame() to 
draw my things. And the viewer can be initilized using the EmbedGraphicsWindow 
using viewer->setUpViewerAsEmbeddedInWindow
 
And everything went well with traditional node.

But when I tried with the PagedLOD files, the node won't show correctly. I have 
debugged this, and find that the _databaseThreads in DatabasePager have started 
successfully and the _fileRequestQueue can also be successfully added.

Another thing is that, when I zoomed out, the most coarse node can show. When 
zooming in a little, this node will disappear, but finer nodes can not be 
shown, even if I have see they are added to the _fileRequestQueue.

Thank you!

Cheers,
Han

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





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


Re: [osg-users] hook osg into other window

2016-08-01 Thread Han Hu
Hi Sebastian ,

Sketchup doesn't have any API to allow render into its openGL context.

And thanks for your snippet on handling the HWND. But I think the real problem 
lies in that I do not have access to the render loop. So there is nowhere for 
me to place the viewer->frame() to render the stuffs.

At last thanks again.

Cheers,
Han

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





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


[osg-users] hook osg into other window

2016-07-31 Thread Han Hu
Hi,

Here is my problem.

I am writing a plugin for a 3D modeling software , sketchup, and going to draw 
some 3D things into the OpenGL context. But it does not have any Api for 
customizing the rendering. So I have to hook my rendering stuffs into its 
render loop, which I do not have access.

I can get the Windows handle HWND of the top window, maybe from that I can 
track to which window is doing rendering and the OpenGL context.

So here is my question,
1. If I get the HWND of the rendering window, can I draw additional things into 
it? Even if I do not have the access to the render loop, and start my own loop.
2. Another strategy, create another window and OpenGL context, that is overlaid 
on to existing window, but the overlay is transparent and do not interact with 
user.The new context only retrieves matrix from the existing one. 

Thank you!

Cheers,
Han

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





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