Jump to content
Joh

Voxelization of a model

Recommended Posts

Here my first code for voxelization, my target is create a navmesh and those code work quite good, but could be better.

Anyway i was testing it and i like the result! :)

post-702-0-81970400-1339486557_thumb.jpg

post-702-0-71598600-1339486570_thumb.jpg

post-702-0-26513500-1339486578_thumb.jpg

Share this post


Link to post
Share on other sites

smile.png Well i should create also my own cube implementation to let it usable.

Next step is to create a video with animation.

 

Or (better) using texture.

 

I'll see.

Share this post


Link to post
Share on other sites

Well i used leadwerks cube.. Also my target is just voxelize it (i don't really need to render) as i use it only to create a navmesh.

But i was thinking to implement also a render way and the performance it can (slightly) improved with other code.

Share this post


Link to post
Share on other sites

You could output that data to a 3D printer and a copy of it in real life. :)

Share this post


Link to post
Share on other sites

Joh, did you use CreateCube() each time or did you make 1 cube and use CopyEntity() on that cube because I think that helps with the FPS.

Share this post


Link to post
Share on other sites

CopyEntity but this model have more then 4000 triangles and cube are 0.1 scaled.. so there are a lot of them!

Share this post


Link to post
Share on other sites

Well exactly how this could help me?

I mean i CHOOSE to use leadwerks as in past this community gave me a lot, now i wanna create a commercial game with this engine.

Also my target is a real-time navmesh generator that will be used during the game, so i don't need static data or something else.

 

@Josh

Is it possible to have a callback ffrom the engine during the render?

Exactly when triangle are processed..

Share this post


Link to post
Share on other sites

I don't understand what you mean by triangles being processed. There are draw entity callbacks, but you can't override them with something else.

Share this post


Link to post
Share on other sites

make a shader , where you can write a position of the pixel in WorldViewProjection into rendertarget. Then, you can read rendertarget and set positions to all your boxes into right position :(

 

just a theory, lol

Share this post


Link to post
Share on other sites

Hey this is cool!

Could you make some kind of exporter for it that exports some kind of voxel map of this?

I mean just a binary file with inital height, witdth, depth and then the bits or as bytes(0 and 1 if there is a cube or not) would be enough.

i would love to load this into my blockmap.

Share this post


Link to post
Share on other sites

@Annixa an exporter is already ready. I'll upload it tomorrow.

 

@Wh1sp3r a good idea, i could try it. Creating a good voxel render code it will take some time anyway.

 

@Josh It will be amazing if i could have a callback when the engine renderize triangles. This is really usefull for the real time navmesh. As now my code spent something like 35 millisecs to check 5000 triangles, as i don't have directly access to the render source code i am checking all the triangles..

It will be faster if i will be able to skip this step with a callback.

Share this post


Link to post
Share on other sites

The engine doesn't ever deal with triangles in the rendering routine. It just tells the GPU which vertex buffer to draw.

 

In Leadwerks3D, it is possible to replace the rendering module with your own, so you could make a voxel ray-tracer without using my renderer at all.

Share this post


Link to post
Share on other sites

..actually, you should look for PolyVox library..it will voxelize mesh/cut off for you all unnecessary surfaces and pass it to renderer as a triangles..tested it and it works great with LE 2.x

Share this post


Link to post
Share on other sites

@Naughty Allen i know this lib, but if i use it i will lose the possibility to get fun doing this! smile.png

I know that feeling :)

Share this post


Link to post
Share on other sites

@Benton i used library many times, if you need to do a project you have limited amount of time.

But this is not my case, i do this for fun!

Share this post


Link to post
Share on other sites

I fully understand what Joh is saying. I also do this for fun, no more, no less.

 

Developers can have different goals. Some want to get things done as quickly as possible and care less about how. The main goal is to get things up working as fast a possible with as little effort as possible. I can fully understand the need for such an approach, specially if the output is going to be a commercial game giving some income. In that case, lib's that save time and effort is gold.

 

Then we have another type of developer like my self. I'm not into this to get an income or hit the world with something spectacular. All this is just for fun, a hobby. Of course I also want to get things done, but in my case I care more about how its done and less about the time it takes to get it done. I guess that Joh may belong to this group of developers as I do.

 

Both types of developers has their own justification and different methods, and that's a good thing. In my eyes there is no 'better' or 'worse' method of developing using lib's and third-party code. It all depends of what the intent is. So use lib's anytime you like to, or make your own if that's fun, as long as you are enjoying what you do.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...