I need to implement octree textures as described here:
I’ve searched the forums and I’ve found something about eggoctree. I was wondering if that code would be useful for my purposes, or if I will have to write this specific octree from scratch.
From what I have understood by reading about octree textures, I need to generate an octree that surrounds a model, but the thing is that the octree must subdivide only in regions where the generated cubes contain model’s vertices, as this quote states (in section 37.1.1 Definition):
“the nodes that have the bunny’s surface inside them have been refined and empty nodes have been left as leaves.”
Will this be possible to accomplish by using the existing eggoctree?
I’ll explain myself a little better.
The effect I’m trying to implement is painting. That is having a 3D model and being able to paint it with a brush. I’ve been investigating a bit, and I’ve found that there a couple of methods for doing this. One of the methods is by using octree textures.
I need to create and octree that surrounds the model I want to paint. The octree’s nodes that have the model’s surface inside of them need to be refined until they became leaf nodes or until the maximum depth level is reached.
Once I have this octree, I will check for collisions between my brush, and the nodes of the octree, and in some way use those collisions to know where to paint.
I thought about creating my own OctreeNode and Octree classes. OctreeNode will have a bounding box, and will be responsible for creating it’s 8 children, and Octree will need a model in which to build the octree around.
The thing is that I’m kind of worried that by following this approach (using bounding boxes), later on, when I need to check for collisions between my brush and the octree nodes, my game will run too slow.
Has anyone tried to implement this effect, or something similar?
If using the existing eggoctree code is not the recommended approach, what path do you recommend me to take, in order to be able to build the octree and that collision checking is efficient?
Thank you very much!
Object painting has been done in panda before but not with the technique you’re describing above. I can’t really follow how Octree textures work but it might be faster/higher quality than the existing methods for painting in Panda.
The basic algorithm for texture painting in panda is discussed here in the original painting thread. It basically uses a special texture that you apply to your model so you can calculate the UV coordinates of a point on the screen. The limitations of this is that the scene must remain static while you’re painting.
I followed it up with shader assisted painting which automagically generates the texture and makes it possible to extract UV information while the scene is in motion. As far as I know the sate of the art for this type of texture painting in panda is my art exhibit app which lets multiple users paint on multiple objects. It might be difficult to test that app though since it requires controllers but the source code is open for anyone to mess around with.
Thank you very much for your answer!
I’ll look into this painting technique since it seems easier to accomplish than with octree textures.
What I don’t understand is that if modifying the texture directly implies that each time painting is done, the textures needs to be reloaded? Will that provide enough speed for a game?
What happens when the game loses focus, and texture memory is lost? When the game regains focus, the original painted areas remain painted?
Reloading a texture is slower than simply rendering an already-loaded texture, but it’s not that slow. Depending on your game design, it’s likely that you won’t even notice the cost for reloading it each time.
Panda will automatically keep the texture image resident in RAM (unless you ask it not to), and will use this cache to reload the textures if they are lost from video memory.