It is currently Sat Aug 22, 2020 12:26 pm


All times are UTC




Post new topic Reply to topic  [ 11 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: OpenGL example
PostPosted: Sat May 30, 2009 3:33 am 

Joined: Sat May 30, 2009 3:28 am
Posts: 6
Hi,

I am interested in the source code you generously provided. I have built the source code and example using CMake. However, the example is based on qt which is difficult to install on my computer.

The previous posts mentioned that there was a glut based example. How could I get one?

Regards,
Jun


Top
Offline Profile  
Reply with quote  
 Post subject: Re: OpenGL example
PostPosted: Sat May 30, 2009 9:03 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Hi, yes, there is a previous OpenGL example written in GLUT. Checkout revision 781 from subversion and try building that. It's written againast an older version of the PolyVox library, of course.

Once that works, you can copy the GLUT project outside the PolyVox source tree and check it still works (you might need to fix some paths at this point...). Then you can update PolyVox to the latest version.

Lastly, use the Qt example in the latest PolyVox to modify your GLUT version with the new classnames, functions, etc. You should then have a GLUT example working with the latest PolyVox.

Let me know if you have any problems...


Top
Offline Profile  
Reply with quote  
 Post subject: Re: OpenGL example
PostPosted: Sat May 30, 2009 2:10 pm 

Joined: Sat May 30, 2009 3:28 am
Posts: 6
Thanks for your information. I have just downloaded it and run the demo.

I have two further questions.
1) Have you ever tried the direct point rendering, just as
glNormal3f();
glVertex3f;
My limited experience is that, after using the bilateral filtering for the normals, the direct point rendering looks much smoother for smooth surface like the sphere region in the demo. The drawback is that the sharp edge may be not very clear. And that's why I am looking for some approaches to translate from direct point rendering to mesh rendering.

2) Is there any interface in your code to save the generated mesh in popular file format such as .obj or wrml? The current appearance of the demo is not so good. So I am considering load the generated mesh in other software such as Deep view.

BTW, your documents is clear and helpful, thanks very much.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: OpenGL example
PostPosted: Sat May 30, 2009 4:00 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Jun wrote:
I have two further questions.
1) Have you ever tried the direct point rendering, just as
glNormal3f();
glVertex3f;
My limited experience is that, after using the bilateral filtering for the normals, the direct point rendering looks much smoother for smooth surface like the sphere region in the demo. The drawback is that the sharp edge may be not very clear. And that's why I am looking for some approaches to translate from direct point rendering to mesh rendering.


Unfortunatly I don't have any experience with Point-Based Rendering, though I'm aware it is an active research topic. However, I have fairly recently added a mesh smoothing function to the PolyVox Library. See IndexedSurfacePatch::smooth(). Also, you can use higher quality normals to improve the appearence. Search the source for CENTRAL_DIFFERENCE, SOBEL, etc. I have been able to achieve the following results.

Unsmoothed:
Image

Smoothed:
Image

Jun wrote:
2) Is there any interface in your code to save the generated mesh in popular file format such as .obj or wrml? The current appearance of the demo is not so good. So I am considering load the generated mesh in other software such as Deep view.


No, but you have acess to the triangle data so it wouldn't be difficult to add an exporter. .obj in particular is a very simple format. I wouldn't mind adding such an exporter to PolyVox though it would belong in 'Util' rather than 'Core'. I don't know when I'd get around to it though...

Jun wrote:
BTW, your documents is clear and helpful, thanks very much.


Great! I'm certainly intending to add a lot more in the way of documentation...


Top
Offline Profile  
Reply with quote  
 Post subject: Re: OpenGL example
PostPosted: Sun May 31, 2009 7:50 am 

Joined: Sat May 30, 2009 3:28 am
Posts: 6
Yep, the second image is much better.

I have followed your advice to implement a GLUT based demo using the latest version(873). However, after several modifications (detailed at the bottom), there remains a LNK error 2019
---------------------
error LNK2001: unresolved external symbol "__declspec(dllimport) void __cdecl PolyVox::extractReferenceSurface(class PolyVox::Volume<unsigned char> *,class PolyVox::Region,class PolyVox::IndexedSurfacePatch *)" (__imp_?extractReferenceSurface@PolyVox@@YAXPAV?$Volume@E@1@VRegion@1@PAVIndexedSurfacePatch@1@@Z)
----------------------

I tracked it and found it was caused by "extractReferenceSurface(&g_volData, Region(regLowerCorner, regUpperCorner), ispCurrent);" in main().

After comment it, there are no compile errors, but an unhandled exception arose in file xtree.

I also tried to build a simple demo using PolyVox from the beginning. Just creating a volume and extracting the surface. Resulting in the same LNK error. Of course, I have checked the link against .lib and put the .dll in the debug in both cases.

My environment is VC2005. I modified the GLUT_781 version as follows.
---------------------------------------------------------
1 Replace the .lib and .dll created by v781 with v873
2 Change the inlude path of the project
3 modify the #include... in the .h and .cpp (delete "PolyVoxCore/")
4 replace uint8 with uint8_t, uint16 with uint16_t, uint32 with uint32_t
5 replace getSideLength() with getWidth(), getHeight(), getDepth() respectively in Shapes.cpp
6 replace with g_volData.getSideLength() with g_uVolumeSideLength in main.cpp
7 replace Volume<uint8_t> g_volData(g_uVolumeSideLength) with Volume<uint8_t> g_volData(g_uVolumeSideLength, g_uVolumeSideLength, g_uVolumeSideLength) in main.cpp
8 isp.m_v3dRegionPosition with isp.m_Region.getLowerCorner() in OpenGLVertexBufferObjectSupport.cpp


Top
Offline Profile  
Reply with quote  
 Post subject: Re: OpenGL example
PostPosted: Sun May 31, 2009 8:57 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Ah, right, the extractReferenceSurface() function is old code. In fact, everything in SurfaceExtractors.h, FastSurfaceExtractor.h, and DecimatedSurfaceExtractor.h will probably be removed soon. It is being replaced by a single class in SurfaceExtractor.h (note the spelling difference between SurfaceExtractor.h and SurfaceExtractors.h).

Look at the new OpenGLWidget for an example of how it should work, but it's something like:
Code:
SurfaceExtractor surfaceExtractor(*volData);
surfaceExtractor.setLodLevel(0);
POLYVOX_SHARED_PTR<IndexedSurfacePatch> isp = surfaceExtractor.extractSurfaceForRegion(PolyVox::Region(regLowerCorner, regUpperCorner));


Note that it now returns a shared pointer to the data which it creates itself, whereas previously you had to create the IndexedSurfacePatch yourself and pass in the pointer to it. So if you are storing the resulting IndexedSurfacePatches (rather than just sending then to the graphics card and then deleting them) then you will need to store these shared pointers instead.

[Edit:] I just removed the old surface extractors from SVN. So if you update, they will be gone.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: OpenGL example
PostPosted: Sun May 31, 2009 11:51 am 

Joined: Sat May 30, 2009 3:28 am
Posts: 6
Thanks. I have fixed it. :)


Top
Offline Profile  
Reply with quote  
 Post subject: Re: OpenGL example
PostPosted: Sun May 31, 2009 12:37 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Great! Just let me know if you have any more questions.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: OpenGL example
PostPosted: Tue Jun 02, 2009 3:08 am 

Joined: Sat May 30, 2009 3:28 am
Posts: 6
Thanks for your help. And as your source code is easy for integration, I'm almost done with transferring the rendering in my work from point-based to mesh-based.

I have some suggestions for further improvements.
1) the invisible surface can be avoided to improve the efficiency. In the current codes, the voxels are identified with different indexes. All the boundaries between different material is constructed. However, to my point of view, only boundary between empty voxel (indexed with 0) with solid voxel should be constructed. Because other boundaries is invisible, there is no need to construct them.

2) Can the flaws (circled in the fig attached ) be removed? I suppose this is caused by the division of the subvolume. Maybe it is difficult in the algorithm view. Anyway, it does not cause not much bad effect.

Thanks again for your help.


Attachments:
smooth.png
smooth.png [ 67.93 KiB | Viewed 6621 times ]
Top
Offline Profile  
Reply with quote  
 Post subject: Re: OpenGL example
PostPosted: Tue Jun 02, 2009 7:50 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Jun wrote:
1) the invisible surface can be avoided to improve the efficiency. In the current codes, the voxels are identified with different indexes. All the boundaries between different material is constructed. However, to my point of view, only boundary between empty voxel (indexed with 0) with solid voxel should be constructed. Because other boundaries is invisible, there is no need to construct them.


I think I already do this - it was certainly my intention. The following code:
Code:
if (v000 == 0) iCubeIndex |= 1;
if (v100 == 0) iCubeIndex |= 2;
if (v010 == 0) iCubeIndex |= 4;
if (v110 == 0) iCubeIndex |= 8;
if (v001 == 0) iCubeIndex |= 16;
if (v101 == 0) iCubeIndex |= 32;
if (v011 == 0) iCubeIndex |= 64;
if (v111 == 0) iCubeIndex |= 128;


Compares the 8 corners of each cell to 0, and makes no distinction between other values. But if you have some reason to believe that invisible surfaces are still being generated then let me know, and I will look into it (that could be a big performance problem).

Jun wrote:
2) Can the flaws (circled in the fig attached ) be removed? I suppose this is caused by the division of the subvolume. Maybe it is difficult in the algorithm view. Anyway, it does not cause not much bad effect.


It appears the flaws come from the IndexedSurfacePatch::smooth() function, rather than the initial surface extraction (note that the flaw is missing in the first of the two pictures I posted above). It might be fixable, but it's not that high priority for me. Try changing the 'amount' parameter which is passed to that function?


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 7 guests


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 post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net