# How to copy a cube by panda3D?

create a cube object and copy it to the right of the original cube , I don’t know how to implement? what function or class can do it?

``````cube2 = cube1.copyTo(render)
cube2.setPos(...)``````

thanks
I want to implement a funtion like mirror , Create a symmetric graphic with the x-axis or z-axis as a center，How can i do it?

Presuming that you already have a copy of the object (which I’ll just refer to as “copy”), to be used as the “reflection”, and as shown above:

Mirroring can be thought of as two operations:

1. Flipping the object to be mirrored over the axis of the mirror, so that it lies on the other side of the mirror, as far away from the mirror as was the original along a line running from the object to the mirror, meeting the latter at ninety degrees.

(Imaging standing in front of a mirror: your reflection appears to be standing just as far from the mirror as you, but on the opposite side, and directly across from you as you face the mirror.)

1. Reversing the object across that same mirror axis, so that the side that was facing the mirror still faces the mirror, without changing the direction in which the object is facing.

(Imagine standing in front of a mirror, with your left cheek facing it: in the mirror, your left cheek is still facing it, but is now facing to the right from your perspective; meanwhile, your nose points in the same direction both fo you and in the mirror.)

So, the general idea is this:

[*]Select the axis along which the mirror operations will take place (call it the “reflection axis”)–specifically, we want the axis that goes “into” (or “out of”) the mirror. For example, if the mirror is supposed to lie on the x-z plane, the axis that we want should be the y-axis.

To illustrate:

``````                       | <-- Mirror
|
|
Reflection --> []======|======= [] <-- Object
|      \Our axis
|
|``````

[list][/:m]
[
] Move “copy” to its position “behind” the mirror; if our “reflection axis” is one of the main axes–one of the x-, y- or z- axes, that is–then just negate the corresponding component of “copy”'s position (x becomes -x, etc.).
[/:m]
[
] Reverse “copy” along the “reflection axis”. Again, if the “reflection” axis is one of the main axes, we can simply negate “copy”'s scale on that axis (x-scale becomes -x-scale, etc.).
[/:m]
[
] Reversing the scale means that Panda will likely render “copy” as though it were inside-out, so we tell it to reverse the winding order for “copy”.

• I think that this can be done by calling “copy.setAttrib” and passing to it “CullFaceAttrib.makeReverse()” (presuming that no other CullFaceAttribs set above it in the scene graph interfere).
[/*:m][/list:u]