Panda3d paged geometry?

Hm, if you don’t know what I mean by that, how do you know its not a problem :laughing:

By “caching” I meant all the trees using the same memory.

EDIT: No materials and textures:

So yeah, low framerate is caused by material/texture settings.
(the colors are random used for checking if batches were created properly)

Okay, so you said to remove the “ModelRoot” before flattening. Whats ‘ModelRoot’?

Uhm, it’s a special kind of ModelNode that is added at the top of every model loaded with loader.loadModel. By default, it tells the scene graph reducer not to flatten this node. If you want to merge multiple models together into one, you first need to tell Panda to clear the model nodes, or configure them to allow flattening.

OK, then.

This is offtopic, but if I procedurally generate an Actor with multiple geoms, I should create a parent node for them named “ModelRoot” so they wont get flattened?

Hm:

		for batch in self.batches:
			for ch in batch.getChildren():
				ch.find('**/ModelRoot').removeNode()
			batch.flattenStrong()
Assertion failed: _error_type != ET_not_found at line 914 of panda/src/pgraph/no
dePath.cxx
Traceback (most recent call last):
  File "main.py", line 18, in <module>
    trees = Trees()
  File "C:\Users\Me\Desktop\pandajungle\trees.py", line 87, in __init__
    ch.find('**/ModelRoot').removeNode()
AssertionError: _error_type != ET_not_found at line 914 of panda/src/pgraph/node
Path.cxx
Press any key to continue . . .

ch.list():

ModelRoot fir06_30.mesh.xml.egg T:(pos -2320 -2220 -199.504 hpr 84 0 0 scale 1.1
3281)
  GeomNode fir06_30 (2 geoms: S:(CullFaceAttrib))
  CollisionNode treeRay (1 solids) (hidden)
None

ModelRoot is the name of the class. The string name of the node is, I believe, the egg filename.

As I said various times before, you can simply call clearModelNodes() and Panda will do it for you.

I just tested it out and you shouldn’t have to do that.

batch.clearModelNodes()
batch.flattenStrong()

…should suffice. I’m guessing clearModelNodes does the same work behind the scenes…iterates through all children and removes the ModelRoot.

Edit: ninja’d!

I found only this one:

Okay missed that one. Sorry.

I want to add LODing now, but theres a problem with point sprites:
4shared.com/video/fnIJg2mA/tree.html
(sorry for the quality)

You should notice the small tree in the middle of the screen though. The thing is, it stays small and not prespective untill you rotate the camera around it for some time. Bug?

from direct.directbase.DirectStart import *
from pandac.PandaModules import *


# render the tree in another buffer and use it as a texture for the point sprites
spritebuffer = base.win.makeTextureBuffer("sprite buffer", 512, 512)
spriterender = NodePath("sprite render")
spritecam = base.makeCamera(spritebuffer)
spritecam.reparentTo(spriterender)
spritecam.setPos(0, -12, 0)
tree = loader.loadModel('media/trees2/fir06_30.mesh.xml.egg')
tree.reparentTo(spriterender)
tree.setScale(0.02)
tree.setR(180)

# make a point sprite nodepath and assign the above texture to it
array = GeomVertexArrayFormat()
array.addColumn(InternalName.make('vertex'), 3, Geom.NTFloat32, Geom.CPoint)
format = GeomVertexFormat()
format.addArray(array)
format = GeomVertexFormat.registerFormat(format)
vertexdata = GeomVertexData('sprite', format, Geom.UHStatic)
vertexwriter = GeomVertexWriter(vertexdata, 'vertex')
vertexwriter.addData3f(0,0,0)
prim = GeomPoints(Geom.UHStatic)
prim.addVertex(0)
prim.closePrimitive()
geom = Geom(vertexdata)
geom.addPrimitive(prim)
node = GeomNode('gnode')
node.addGeom(geom)

sprite = render.attachNewNode(node)
sprite.setTransparency(TransparencyAttrib.MDual)
sprite.setY(12)
sprite.setTexGen(TextureStage.getDefault(), TexGenAttrib.MPointSprite)
sprite.setTexture(spritebuffer.getTexture())
sprite.setRenderModeThickness(128)
sprite.setRenderModePerspective(True)


# environment
env = loader.loadModel('environment')
env.reparentTo(render)
env.setScale(50)
env.setZ(-20)
env.setColor(0.7,0.2,0.2,1)


run()

This problem is the same as this:
[A bug with sprites and setRenderModePerspective(True)?)

well im not in this case and its still there

There are occasionally driver bugs with perspective sprites. If you’re seeing a driver bug, you have to set:

hardware-point-sprites 0

but then you’re more limited in the number of sprites you can have before your performance degrades. But if this solves your rendering problem, it proves you have a driver bug and not a Panda bug.

David

Right.

But its not happening with particles. Why?

Honestly, I’ve long since given up on asking “why” a driver bug behaves in a particular way. I’ve seen everything, and only about half of it makes sense.

If you are seeing a driver bug, and it happens in some cases and not in others, I really can’t tell you why. But you’re more than welcome to research it further and see if you can determine what the difference is.

David

By my knowledge sprite particles work the same way, so i thought theres a small possibilty that panda itself doesnt do everything ‘right’ (maybe theres a workaround code for such bug in the particles sourcecode).

Yes, it’s certainly possible. I’m not aware of anything wrong in there, but you’re welcome to research it and let me know if you find anything. :slight_smile:

David

I can’t. I think most users here can’t, mostly because we don’t even know C++.

Pshaw. You just successfully constructed an animated character based on little to no documentation and a handful of sample code. You can’t tell me that C++ is beyond you. :slight_smile:

But even still, there might be no reason you need to delve into C++ to research this. The particle system doesn’t do anything other than create GeomPoints with the RenderModeAttrib set on them. If the particle system is rendering correctly, but your own points aren’t, then either something is different with the scene graph between these two cases, or the difference has nothing to do with Panda.

David

Well I asked tons of questions and I still dont have everything working correctly in that thread, and C++ isnt something you can learn in a weekend, so…

I can just make this assumption: the main difference is that particles are a single geom, but in another thread i also had everything as a single geom, so the only difference would be that the vertices in the particle system’s geom are “dynamic”. Ive already mentioned that the perspective mode is applied only after you view the sprite from different positions (move your camera around it). It is possible that as particle points are moving, they are rendered from different camera distances right after they are created, so we dont have time to notice how the perspective mode is applied a bit late.
Thats the only thing I can think of.

OK, since it seems like a driver bug, I moved along.

So how to make a sprite ,how to texture it properly and how to set the size properly?

From the above code I make a single sprite, then I use tree.copyTo(parent) to make corresponding sprites. It seems to work, but how would you measure the distance of the camera from the tree in the tree buffer? I would need to fit the tree model perfectly on the buffer texture. I could use the tree’s bounding box, but I dont know how exactly.

I then would need to scale the sprite to be the same size as the tree model. How? The size of a point sprite is set with setRenderModeThickness(), how does that relate with panda units used in 3d geometry?