Volumes Of Fun http://www.volumesoffun.com/phpBB3/ |
|
static Polyvox vertex and Index array class members http://www.volumesoffun.com/phpBB3/viewtopic.php?f=14&t=390 |
Page 1 of 1 |
Author: | drwbns [ Sat Apr 28, 2012 6:45 pm ] |
Post subject: | static Polyvox vertex and Index array class members |
Hello, I'm trying to figure out what I need to do to be able to store the vertex and index arrays into a static class member. Currently, I have them writtem in my mesh building function like so - Code: const std::vector<PolyVox::PositionMaterialNormal>& vecVertices = mesh.getVertices(); const std::vector<uint32_t>& vecIndices = mesh.getIndices(); But I would like to access the 2 arrays from another class function. So how do I make them static members? and how do I call them? Thanks for any help! |
Author: | David Williams [ Sat Apr 28, 2012 10:44 pm ] |
Post subject: | Re: static Polyvox vertex and Index array class members |
So those variables are currently local to a particular function in a class, and you would like them to be accessible from another function of the same class? To do this they should be member functions of the class but not static members. Or you want them to be accessable from a different instance of the same class? In this case you could make them static but it would be a strange thing to do. Make sure you understand the difference between classes and objects/instances, and also how members and static members are different. |
Author: | xelons [ Sun Apr 29, 2012 4:02 am ] |
Post subject: | Re: static Polyvox vertex and Index array class members |
As David said, you cannot access static class members from another class, to achieve what you are trying to do maybe you can create a constructor for the first class, then create a pointer and access it's members through it. |
Author: | drwbns [ Tue May 01, 2012 3:59 am ] |
Post subject: | Re: static Polyvox vertex and Index array class members |
What I was trying to do was to have access to the verts and faces pulled from using the SurfaceExtractor function. I was having trouble getting that data from another function within the same class. I'll have to try making them just regular class members without using the static keyword. The reason why I wanted the verts and faces arrays was to diagnose a problem where the voxels werent being rendered correctly, so I wanted to print the number of verts and indexes and maybe their positions. So far I'm getting that there's 6 verts for a single voxel and 24 faces. The 6 verts seems correct, but 24 indices seems far too much for a single voxel. |
Author: | David Williams [ Tue May 01, 2012 8:26 am ] |
Post subject: | Re: static Polyvox vertex and Index array class members |
drwbns wrote: The 6 verts seems correct, but 24 indices seems far too much for a single voxel. Actually I'm suprised there aren't more indices. A single cube is rendered as 12 triangles, and each triangle consists of three indices. So I would have expected 36 indices I think. Is the solid voxel completely surrounded by empty space? This requirement of 36 indices can probably be reduced by making use of triangle strips but PolyVox doesn't do that at the moment. |
Author: | drwbns [ Wed May 02, 2012 12:41 am ] |
Post subject: | Re: static Polyvox vertex and Index array class members |
The voxel is completely surrounded by open space. Here's a screenshot from an above angle looking down at the voxel. Attachment: ![]() screenshot05012012_100840314.gif [ 52.86 KiB | Viewed 4744 times ] 1 voxel renders just fine, but once I add to it, it doesn't draw the voxels as they should be. Attachment: ![]() screenshot04282012_100840314.gif [ 180.52 KiB | Viewed 4744 times ] |
Author: | David Williams [ Wed May 02, 2012 8:24 am ] |
Post subject: | Re: static Polyvox vertex and Index array class members |
drwbns wrote: The voxel is completely surrounded by open space. Here's a screenshot from an above angle looking down at the voxel. Ah, right, your using the marching cubes surface extractor and not the cubic one. In that case there are 8 triangles each with 3 corners so the 24 indices is correct. drwbns wrote: ... but once I add to it... What did you add to it? It doesn't look like you just set another voxel to be solid. Are you breaking the mesh down into seperate regions at this point? It kind of looks like you have multiple regions but they are all displaying the same mesh data. Do you still have static members in your code? |
Author: | drwbns [ Wed May 02, 2012 10:33 pm ] |
Post subject: | Re: static Polyvox vertex and Index array class members |
I click and add or subtract voxels at a distance from the camera and create or update regions if they were hit. The regions are split by a hard coded cubic number. Such as (32 x 32 x 32). The mesh displaying code is the same as in my other topic here - viewtopic.php?f=14&t=387 It seems as though the updating of a region no longer works as it did with my old mesh displaying code. I just wanted to make sure the vertices and Indices were correct for a single voxel then go from there. One odd thing I notice is the vertex positions are really low numbers anywhere from 0 to 30, but not really any higher. |
Author: | David Williams [ Thu May 03, 2012 8:22 am ] |
Post subject: | Re: static Polyvox vertex and Index array class members |
drwbns wrote: One odd thing I notice is the vertex positions are really low numbers anywhere from 0 to 30, but not really any higher. This is correct, because the origin of the mesh data is always at the lower corner of the region you extract. For example, if you extract the region (100, 100, 100) to (150, 150, 150) then all the vertices will have a position between 0 and 50. However, you know that the region actually starts at (100, 100, 100) so you can set this as the position of your Ogre Node. |
Author: | drwbns [ Thu May 03, 2012 1:29 pm ] |
Post subject: | Re: static Polyvox vertex and Index array class members |
Ok, thanks for that info David, it looked like an offset so I wanted to be sure. I'll post back if or when I find the solution. |
Page 1 of 1 | All times are UTC |
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group http://www.phpbb.com/ |