Scene Graph Content

Is there a way…code wise, to check if a certain element is attached to or detached from, the scene?

Example: One migth want to know if a AppleTree1 is attached to the scene or not.

Python code example please.

I won’t get into panda and c++ until there’s seriously good API docs on it.

I have another Question…

If you call NodePath.detachNode() and detach an object that was reparented to a flattened object, and then you reparent the object to another object that was flattened, later… Do you have to call flattenStrong() all over again?

You can check render.isAncestorOf(yournode) to see if it’s part of the scene graph.

In the ideal case, flattenStrong will let your subnode cease to exist, so you aren’t supposed to detach it. Flattening means merging it into a single node, so any children will not exist any more.

If this doesn’t happen for some reason (e.g. if the subnode is a ModelNode), then the answer depends on what exactly you want to do. If you set a new transform on the parent node and you want it to propagate down to the vertices, then yes.

But to be frank, your question doesn’t make too much sense. Perhaps you’re using flattenStrong() when you’re not intending to use it, or you do not fully understand the implications of using it.

So far I haven’t had any issues detaching a model from another one, where a flattenStrong() has been called. Re-attaching that same model back to the piece it was originally attached to does not cause any issues either.

What I don’t know is, thus the reason for the question, when re-attaching…does the model become as one again? Example: You attach ModelChair to ModelTable then call a flattenStrong(), so now it’s all one model. You decide you want to detach the ModelChair from render, so you call ModelChair.detachNode();

At some point later, you decide you need the ModelChair back in the scene and back as apart of the ModelTable, so you call ModelChair.reparentTo(ModelTable).

Will the ModelChair and ModelTable act as one flattened Node again?

Like rdb already said to you, I guess you didn’t even successfully flattened the nodes…
I bet on: try running clearModelNodes() on your NodePath before the flattenStrong() operation, and you will see that detaching one single part of the model will not be possible anymore, (hence the rdb quote).

You can run analyze() on the model to get more information.

If that’s the case then I guess you can’t use this Method:

Model = load.loader("Model/Path")
ModPath = render.attachNewNode("MyModel")
Model.getChildren().reparentTo(ModPath)

According to the Manual that was suppose to do the same thing as clearModelNodes()…guess not.

I went back and used clearModelNodes() and then used analyze to see if the number of nodes did in fact get smaller… No avail.

I’m doing everything “by the book”, but I guess I will never be able to use flattenStrong() correctly then.

The funny thing is…before I tried to use flattenStrong(), my frame rate was working harder. When I used flattenStrong() I did gain a big speed boost…but according to this post, I can’t possible be doing it right for some reason…so where the speed boost came from… Who knows.

:cry:

I’m an Epic Failure…

Hey man!

The speed boost maybe came from the flatten of chair and table apart. Don’t know how you modeled it. Even if you couldn’t merge this models together for some reason (like if ur models had different textures), I guess you still can gain something from the flatten operation.

I think u could tell us what the analyze returns, with and without calling flattenStrong().

[size=75]
And sorry if my last answer sounded a little rude (wasn’t my intention, I’m not a native english speaker). [/size]
[size=59]So, no need to be ironic (if, as a non-native listener, I understood well the sense of ur words)[/size]

Different Textures… Giving a guess based on that quote, I would assume that Models must have a lot of things in common in order for flattenStrong() to work correctly. Other wise the only thing that get flattened is each individual Model.

Correct?

As for the Model.analyze thing… It returns the same thing no matter if I call flatten or not; I’m guessing it’s because the Models have different names, textures, materials, etc.

So, as expected, you wasn’t flatten it successfully…
Yes, the model must share the same texture to get flattened. And You can have different names for models (was a joke?)

You can try a lot of different things now…

  • Put the same texture in the texture tag of the egg file to see if u can flatten the models now… (although them will look strange - just for test).
  • You can use egg-palettize to get both texture in a single one, if that was the problem.
  • You can tell us why you want to flatten them…
  • You can take a look at RigidBodyCombiner, that isn’t so agressive as flattenStrong, letting you even transform (move, rotate, hide, dettach etc.) your models… Maybe a good option for you, although it’s more useful for lots of itens… (You still didn’t mention what’s your goal)

Is egg-palettize a setting in the config.prc? If so, is it a true or false? If not, is it “dot synax?”

My goal is to simply send less static geometry down the graphics pipeline.

My models have just about different everything, but even with that said…according to your statements…the different textures is what’s causing the issue.

As for the rigid body container one… I tried using that with an Actor, since an Actor has animated vertices…but was not successful, which is no surprise if I couldn’t get flattenStrong() to work.

Looks like egg-palettize is run from the CMD. What are the commands?

I’m guessing you can manipulate model files individually…

Even though my app’s frame rate is over 60, I would love to see the 267 node count drop down majorly.