28
28
from direct .interval .IntervalGlobal import Sequence
29
29
30
30
from util3d .cube import makeCube
31
+ from util3d .cameratex import CameraTexture , CameraCard
31
32
32
33
if "help" in sys .argv :
33
34
print ("""Command Line Arguments:
@@ -190,6 +191,12 @@ def __init__(self):
190
191
191
192
self .textNp = self .render .attachNewNode ("TextNodes" )
192
193
194
+ self .updateCamera = True
195
+ self .cameraCard = CameraCard (self .render )
196
+ self .cameraCard .setScale (Vec3 (- 16 , 1 , 9 ) * 4 )
197
+ self .cameraCard .setTwoSided (True )
198
+ self .cameraCard .setPos ((8 * 4 , 22 , - 4.5 * 4 ))
199
+
193
200
light = makeLight (1 )
194
201
lightNp = render .attachNewNode (light )
195
202
lightNp .setPos (24 , - 30 , 12 )
@@ -229,6 +236,7 @@ def __init__(self):
229
236
self .accept ('c' , self .oobe )
230
237
self .accept ('g' , self .toggleGravity )
231
238
self .accept ('p' , self .pause )
239
+ self .accept ('b' , self .toggleCameraBg )
232
240
233
241
def debugNodes (self ):
234
242
print ("\n " .join (["{}\t Gravity: {}\t Linear: {}\t Angular: {}" .format (
@@ -258,10 +266,17 @@ def toggleGravity(self):
258
266
self .world .setGravity ((0 , 0 , 5 ))
259
267
print ("New Gravity: " , self .world .getGravity ())
260
268
269
+ def toggleCameraBg (self ):
270
+ if self .cameraCard .parent :
271
+ self .cameraCard .detachNode ()
272
+ else :
273
+ self .cameraCard .reparentTo (self .render )
274
+
261
275
def update (self , task ):
262
276
msg = self .queue .get ()
263
277
processed = 0
264
278
while msg :
279
+ print (msg )
265
280
if msg ["action" ] == "leave" :
266
281
self .launchers [msg ["client_id" ]].destroy ()
267
282
del self .launchers [msg ["client_id" ]]
@@ -276,6 +291,9 @@ def update(self, task):
276
291
else :
277
292
msg = None
278
293
294
+ self .updateCamera = not self .updateCamera
295
+ self .updateCamera and self .cameraCard .update ()
296
+
279
297
dt = globalClock .getDt ()
280
298
if not self .paused :
281
299
self .world .doPhysics (dt )
@@ -349,5 +367,6 @@ def addText(self, value, pos=Point3(0, 0, 0)):
349
367
text .setPos (pos )
350
368
return text
351
369
352
- app = TextApp ()
353
- app .run ()
370
+ if __name__ == "__main__" :
371
+ app = TextApp ()
372
+ app .run ()
0 commit comments