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


All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Voxel type
PostPosted: Sun Apr 15, 2012 3:53 pm 

Joined: Wed Feb 29, 2012 12:35 am
Posts: 25
Greetings everyone,

I'm a little bit confused about the voxel types and would like some help regarding this matter.
What I'm trying to do is the following: let's say I have set a voxel at a location x, y, z, I would like to assign a type for that specific voxel, let's say the type is an int value, so It would be a voxel at x, y, z location with let's say 1 as an int value assigned to it. The purpose of this is to be able to set a per voxel propriety like grass, dirt etc.

So is there an already made implementation into polyvox that allow us to do the following? Like defining an enumeration from let's say 0 to 10, with 0 assigned to grass, 1 assigned to rock and so on, then once we set a voxel we can have the option to specify a type ranging from 0 to 10 for example and save it with that specific voxel, so later on we can access that type and assign whatever propriety we want to that voxel.

I hope my explanation was clear enough :) thanks.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Voxel type
PostPosted: Sun Apr 15, 2012 4:23 pm 
User avatar

Joined: Wed Jan 26, 2011 3:20 pm
Posts: 203
Location: Germany
not sure if i got it right.

you want to set a type (e.g. "grass", "earth") and then, depending on the type set some other value? ("grass" -> "green", "brown", "earth" -> "good soil", "stony")
or do you simply want to set a voxel to an enum?

if it is the latter, that is already possible. just create your enum

Code:
enum MyMaterial
{
  mmAir,
  mmEarth,
  mmGrass,
  mmWater
};

and use PolyVox::Material8.

Code:
volume.SetVoxelAt(x, y, z, PolyVox::Material8(mmEarth));


if it is the first one, you will need your own Material implementation (which is not all that difficult to implement)


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Voxel type
PostPosted: Sun Apr 15, 2012 5:53 pm 

Joined: Wed Feb 29, 2012 12:35 am
Posts: 25
ker wrote:
not sure if i got it right.

you want to set a type (e.g. "grass", "earth") and then, depending on the type set some other value? ("grass" -> "green", "brown", "earth" -> "good soil", "stony")
or do you simply want to set a voxel to an enum?

if it is the latter, that is already possible. just create your enum

Code:
enum MyMaterial
{
  mmAir,
  mmEarth,
  mmGrass,
  mmWater
};

and use PolyVox::Material8.

Code:
volume.SetVoxelAt(x, y, z, PolyVox::Material8(mmEarth));


if it is the first one, you will need your own Material implementation (which is not all that difficult to implement)


Thanks Ker, that's what I needed, actually I kinda need this for the two reasons you stated above, my terrain is textured using an auto texture system, it takes the y normal of the voxel surfaces and then depending on the angle value from 0 to 1 it assign a texture, the problem with this implementation is that if I try to add trees for example they will get the same auto texturing. Now if I assign a type to some voxels I can exclude it from my auto texturing process and apply the desired texture and proprieties that I want :)

EDIT:
Code:
volume.SetVoxelAt(x, y, z, PolyVox::Material8(mmEarth));

SetVoxelAt, isn't the last parameter controlling the density of the voxel?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Voxel type
PostPosted: Sun Apr 15, 2012 7:34 pm 
User avatar

Joined: Wed Jan 26, 2011 3:20 pm
Posts: 203
Location: Germany
xelons wrote:
SetVoxelAt, isn't the last parameter controlling the density of the voxel?


nope, it is controlling the voxel itself. you will assign the whole voxel.
You can use any c++ object as a voxel type.
so for your case you'll have to create one that has a field for material and one for variation.
you best copy the Material class and add whatever extra stuff you need.


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 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