It is currently Sat Aug 22, 2020 1:44 pm


All times are UTC




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: static Polyvox vertex and Index array class members
PostPosted: Sat Apr 28, 2012 6:45 pm 

Joined: Wed Jan 11, 2012 7:33 pm
Posts: 109
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!


Top
Offline Profile  
Reply with quote  
 Post subject: Re: static Polyvox vertex and Index array class members
PostPosted: Sat Apr 28, 2012 10:44 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: static Polyvox vertex and Index array class members
PostPosted: Sun Apr 29, 2012 4:02 am 

Joined: Wed Feb 29, 2012 12:35 am
Posts: 25
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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: static Polyvox vertex and Index array class members
PostPosted: Tue May 01, 2012 3:59 am 

Joined: Wed Jan 11, 2012 7:33 pm
Posts: 109
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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: static Polyvox vertex and Index array class members
PostPosted: Tue May 01, 2012 8:26 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: static Polyvox vertex and Index array class members
PostPosted: Wed May 02, 2012 12:41 am 

Joined: Wed Jan 11, 2012 7:33 pm
Posts: 109
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
screenshot05012012_100840314.gif [ 52.86 KiB | Viewed 4742 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
screenshot04282012_100840314.gif [ 180.52 KiB | Viewed 4742 times ]


Top
Offline Profile  
Reply with quote  
 Post subject: Re: static Polyvox vertex and Index array class members
PostPosted: Wed May 02, 2012 8:24 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
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?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: static Polyvox vertex and Index array class members
PostPosted: Wed May 02, 2012 10:33 pm 

Joined: Wed Jan 11, 2012 7:33 pm
Posts: 109
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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: static Polyvox vertex and Index array class members
PostPosted: Thu May 03, 2012 8:22 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
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.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: static Polyvox vertex and Index array class members
PostPosted: Thu May 03, 2012 1:29 pm 

Joined: Wed Jan 11, 2012 7:33 pm
Posts: 109
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.


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 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