1 from panda3d
.core
import CullFaceAttrib
2 from panda3d
.bullet
import BulletBoxShape
, BulletRigidBodyNode
6 def __init__(self
, world
):
7 shape
= BulletBoxShape((.5, .5, .5))
8 self
.node
= BulletRigidBodyNode('box')
9 # self.node.set_mass(1) # static/dynamic
10 self
.node
.add_shape(shape
)
11 np
= render
.attach_new_node(self
.node
)
13 world
.attach_rigid_body(self
.node
)
14 model
= loader
.load_model('assets/gltf/box/box.gltf')
17 self
._set
_outline
_model
(np
)
19 def _set_outline_model(self
, np
):
20 self
._outline
_model
= loader
.load_model('assets/gltf/box/box.gltf')
21 clockw
= CullFaceAttrib
.MCullClockwise
22 self
._outline
_model
.set_attrib(CullFaceAttrib
.make(clockw
))
23 self
._outline
_model
.reparent_to(np
)
24 self
._outline
_model
.set_scale(-1.08, -1.08, -1.08)
25 self
._outline
_model
.set_light_off()
26 self
._outline
_model
.set_color(.4, .4, .4, 1)
27 self
._outline
_model
.set_color_scale(.4, .4, .4, 1)
28 self
._outline
_model
.hide()
30 def on_click(self
, hit
):
31 print(hit
.get_hit_pos())
33 def on_mouse_on(self
):
34 self
._outline
_model
.show()
36 def on_mouse_off(self
):
37 self
._outline
_model
.hide()