major problems here, anyone interested ?

Hi, I have some problems here.

I’m using Panda3D v1.2.1 and I want to use the dynamic cube map by executing makeCubeMap() function.
So I executed the dynamic cube mapping example provided in the manual.
I simply use my own geometry for the scene and keep the teapot for the shiny object.
But it generated error during the cameras assertion process.
Here is the errror message:

Assertion failed: (mask & PandaNode::get_overall_bit()).is_zero() at line 112 of
c:\temp\mkpr\panda3d-1.2.1\built\include\camera.I

This message occured for all cameras, that is 6 times.
Here is my import section:

from pandac.PandaModules import *
…(changing some config vars).
import direct.directbase.DirectStart
from direct.interval.IntervalGlobal import *
from direct.gui.DirectGui import *
from direct.showbase.DirectObject import *
from math import *
import sys

Where is actually the erronous part?
Is it in the module “camera.i” or within my scene?
I may miss some modules to import.
I didn’t supply the bitmask for the cameras, so every object should be visible to the cameras.


This is my 2nd problem:

  • Can we move the local pivot of a NodePath (lets name it ‘MYNODE’) ?
    I used to solve this problem by attaching a new NodePath (lets name it ‘NEWNODE’) on the MYNODE’s topmost parent , so it’s located at the topmost parent’s origin. And then I move NEWNODE to the center of MYNODE by calling :
    NEWNODE.setPos(MYNODE.getBounds().getCenter())

and then reparent MYNODE with respect to NEWNODE, so if I rotate NEWNODE, I get MYNODE rotated at it’s centerpoint.
It works well if I want to rotate MYNODE at it’s centerpoint, but how if I want to rotate it NOT at it’s centerpoint?

Lets say that now I want the centerpoint located at the center of MYNODE’s parent (lets name it ‘MYNODE-PARENT’, it’s not the topmost parent), and I set a simple 1 faced geometry as this node. Then I should proceed as the above solving, but now the boundingsphere is calculated for MYNODE-PARENT and its children too.
So, I call getInternalBound() to get the boundingsphere for MYNODE-PARENT only (without the chidren).
Function getInternalBound() is a property of PandaNode, so I call it this way:
NEWNODE.setPos(MYNODE-PARENT.node().getInternalBound().getCenter())

and the result was ‘isEmpty’ error, like there wasn’t any geometry on MYNODE-PARENT.
What is wrong?

The pivot point of every nodepath is kept in the nodepath, isn’t it?
How can I flush this pivot matrix to the nodepath’s translation matrix as addition and then the pivot matrix becomes zero matrix, so the pivot is located at the center and the previous pivot is considered as translation addition from the parent’s nodepath ?


This is my 3rd problem:

I tried to apply antialiasing to my scene, but I still don’t understand how I should type the antialias mode.
I read the reference about AntialiasAttrib and I found the modes are M_none, M_auto, M_point, M_line, M_polygon, etc.
When calling NodePath.setAntialias(mode,priority), the mode should appear like this :
MNone, MAuto, MPoint, MLine, MPolygon, or etc.

Is this correct ?

Please help me, thanks a lot.

Rule of thumb, when you have three questions that really are separate, it’s better to post three messages. That way, people can search the forums and find the one answer they need.


First question: cube maps and camera masks.

I forgot all about the cube camera mask problem! There’s a bug, and there’s a workaround.

The purpose of camera masks is to control which cameras can see which objects. That’s particularly useful with dynamic cubemaps. If you have a shiny car, for instance, you want to put the six cameras inside the car, and you don’t want the six cameras to see the car itself — you want them to see everything that’s around the car. You need camera masks for that.

The code to create these dynamic cubes assigns a camera mask, but it does so incorrectly. The temporary workaround is that you have to use the explicit bitmask parameter of the makeCubeMask function:

cubeCameraMask = BitMask32(1)

buffer = base.win.makeCubeMap(‘cubemap’,128,temp1,cubeCameraMask)

So now, you can say:

car.hide(cubeCameraMask)

and presto, the car is no longer visible to that camera.


Second question: antialiasing. The command you want is:

NodePath.setAntialias(AntialiasAttrib.MLine)


Third question: all that nodepath stuff. Honestly, I didn’t understand the question.

I can tell you this: objects always rotate around their origins. If you want something to rotate around some other pivot, you need to create dummy objects. So let’s say you want a character model (“guy”) to stand on the origin, but you want him to rotate around the Z-axis at (10,0,0). Do this:

pivot = render.attachNewNode(“mypivot”)
pivot.setPos(10,0,0)

guy = loader.loadModel(“dude”)
guy.reparentTo(pivot)
guy.setPos(-10,0,0)

So now the guy is at the origin, but he’s parented to an object which is at (10,0,0). So now you can rotate him around that axis.

just to be clear about Josh’s third answer:

you can rotate the guy around the new axis by calling

pivot.setHpr(h,p,r)

you can still pivot guy around his own origin with

guy.setHpr(h,p,r)

And to further clarify: getInternalBound() returns the computed bounding volume of the node itself. In your example, MYNODE-PARENT is (presumably) an ordinary PandaNode, or possibly some other kind of node like a ModelNode, but not a GeomNode–so it has no geometry of its own, and therefore it has no bounding volume of its own.

If you don’t know the center of your object, and getBounds() is the only way you have to determine its center, then you should call getBounds() before you parent any new nodes to it, and save that result. Node that you should use a form such as:


center = Point3(MYNODE-PARENT.getBounds().getCenter())

to make a copy of the result, since otherwise the center point is returned by reference, and if you later change the bounding volume (for instance, by parenting new objects to MYNODE-PARENT), the reference may become invalid.

David

Yeah, thanks guys, it’s all getting better now.