9b320ea7d0620b72c9e5eb24f582d29c8976745f
2 from panda3d
.core
import ClockObject
3 from ya2
.gameobject
import GfxColleague
4 from ya2
.engine
.particle
import Particle
5 from ya2
.lib
.p3d
.gfx
import P3dGfxMgr
, P3dAnimNode
, P3dAmbientLight
, \
10 AnimNode
= P3dAnimNode
11 AmbientLight
= P3dAmbientLight
12 Spotlight
= P3dSpotlight
15 class EngineGfx(GfxColleague
):
17 def __init__(self
, mediator
, model_path
, antialiasing
, shaders
, fps
, srgb
):
18 GfxColleague
.__init
__(self
, mediator
)
19 self
.gfx_mgr
= GfxMgr(model_path
, antialiasing
, shaders
, srgb
)
22 if fps
: self
.set_frame_rate(fps
)
23 # if self.mediator.cfg.gui_cfg.shaders and \
24 # self.eng.lib.version.startswith('1.10'):
29 self
.root
= self
.gfx_mgr
.root
.attach_node('world')
31 def clean(self
): self
.root
.remove_node()
33 def load_model(self
, filename
, callback
=None, anim
=None):
34 try: return self
.gfx_mgr
.load_model(filename
, callback
, anim
)
36 return self
.gfx_mgr
.load_model(filename
+ '.bam', callback
, anim
)
38 def set_toon(self
): self
.gfx_mgr
.set_toon()
40 def set_bloom(self
): self
.gfx_mgr
.set_bloom()
42 def print_stats(self
, two_d
=True, three_d
=True, analyze
=True, ls
=True):
43 self
.gfx_mgr
.print_stats(two_d
, three_d
, analyze
, ls
)
46 def set_frame_rate(fps
):
47 globalClock
.setMode(ClockObject
.MLimited
)
48 globalClock
.set_frame_rate(fps
)
52 def particle(parent
, texture
, color
=(1, 1, 1, 1), ampl
=pi
/6, ray
=.5,
53 rate
=.0001, gravity
=-.85, vel
=3.8, part_duration
=1.0,
54 autodestroy
=None, size
=10):
55 return Particle(parent
, texture
, color
, ampl
, ray
, rate
, gravity
, vel
,
56 part_duration
, autodestroy
, size
)