def __eggifyverts(self, eprim, evpool, vlist): for vertex in vlist: ixyz = vertex['v'] vinfo = self.points[ixyz - 1] vxyz, _ = vinfo ev = EggVertex() ev.setPos(Point3D(vxyz[0], vxyz[1], vxyz[2])) iuv = vertex['vt'] if iuv is not None: vuv = self.uvs[iuv - 1] ev.setUv(Point2D(vuv[0], vuv[1])) inormal = vertex['vn'] if inormal is not None: vn = self.normals[inormal - 1] ev.setNormal(Vec3D(vn[0], vn[1], vn[2])) evpool.addVertex(ev) eprim.addVertex(ev) return self
def test_vec3_str(): assert str(Vec3F(2, 3, 1)) == "LVector3f(2, 3, 1)" assert str(Vec3D(2, 3, 1)) == "LVector3d(2, 3, 1)"
def __init__(self, width, height, isFullscreen, title): ShowBase.__init__(self) #======================================================================= # Set window properties. #======================================================================= win_props = WindowProperties(self.win.getProperties()) win_props.setTitle(title) win_props.setFullscreen(isFullscreen) win_props.setSize(width, height) self.win.requestProperties(win_props) # Apply the property changes. self.graphicsEngine.openWindows() #======================================================================= # Scene related fields. #======================================================================= self.sceneNP = None ''' Main scene node path. There can be only one scene at any given time. ''' #======================================================================= # Actor related fields. #======================================================================= self.actorNP = {} ''' Dictionary of actor node paths keyed with the actor name.Internal use only. ''' self.actorOINP = None ''' Actor of interest node path. There can be only one actor of interest at any given time. ''' self.actorOIName = None ''' Actor of interest name. There can be only one actor of interest at any given time. ''' self.actorOIMoveDir = 0 ''' Actor of interest movement direction indicator. Forward is 1, reverse is -1, and stop is 0. ''' self.actorOITurnDir = 0 ''' Actor of interest turn direction indicator. Left is 1, right is -1, and no turn is 0. ''' self.actorOIMoveSpeed = 3 ''' Actor of interest translational speed. Distance units per second. ''' self.actorOITurnSpeed = 30 ''' Actor of interest rotational speed. Degrees per second. ''' self.actorOILocation = Vec3D.zero() ''' Actor of interest's location coordinates after the last frame. ''' self.actorOIVelocity = Vec3D.zero() ''' Actor of interest's velocity vector after the last frame. ''' #======================================================================= # Camera related fields. #======================================================================= self.cameraNP = {} ''' Dictionary of camera node paths keyed with the camera name. ''' # Add the showbase camera as 'default'. self.cameraNP['default'] = self.cam #======================================================================= # Illumination related fields #======================================================================= self.lightNP = {} ''' Dictionary of light node paths keyed with the light name. ''' self.goalNP = {} ''' Dictionary of goal node paths keyed with the goal name. ''' #======================================================================= # Display region related fields. #======================================================================= self.displayRegion = {} ''' Dictionary of display regions keyed with the display region name. ''' self.displayRegionOI = None ''' Display region of interest. Any action related to display regions will be applied to the current display region of interest. ''' self.displayRegionOIName = None ''' Display region of interest name. Any action related to display regions will be applied to the current display region of interest. ''' # Add the display region associated with the default showbase camera. self.displayRegion['default'] = self.camNode.getDisplayRegion(0) self.displayRegion['default'].setSort(1) self.accept('control-`', self.setDisplayRegionOfInterest, ['default']) # Current display region of interest is the 'default' one. self.displayRegionOI = self.displayRegion['default'] self.displayRegionOIName = 'default' #======================================================================= # AI related fields. #======================================================================= self.AIWorld = AIWorld(self.render) self.AICharacter = {} #======================================================================= # Trace file related fields. #======================================================================= self.traceFile = None '''Handle to the trace file.''' self.traceMessage = '' '''Message to be written to the trace file.''' self.onScreenHelpNP = None '''Text node path holding the on screen help information.''' #======================================================================= # Other fields. #======================================================================= self.clock = globalClock '''Exposes Panda3D's GlobalClock.''' self.userDialog = OnscreenText(text='', bg=(0,0,0,.6), fg=(.8,0,0,1), mayChange=True) self.userDialogTask = None self.isNotifyUser = True # We do not need the default mouse controls. self.disableMouse() # We do not need the default camera. self.cam.node().setActive(False) # Make sure a clean exit from the application when requested. atexit.register(self.exitfunc) # Default collision traverser. self.cTrav = CollisionTraverser() #======================================================================= # On screen help setup. #======================================================================= OSHelp_str = '\nHELP\n' text_font = self.loader.loadFont('cmtt12', spaceAdvance=.52) self.onScreenHelpNP = OnscreenText(text=OSHelp_str, font=text_font, style=1, fg=(1,1,1,1), bg=(0,0,0,.6), align=TextNode.ALeft, scale=.05, mayChange=True) self.onScreenHelpNP.reparentTo(self.a2dTopLeft) self.onScreenHelpNP.hide() #======================================================================= # Keyboard control related fields and default settings. #======================================================================= self.keyMap = {} '''Dictionary of keyboard controls keyed with the action name.''' self.setActorOIActionKey('forward', 'arrow_up') self.setActorOIActionKey('reverse', 'arrow_down') self.setActorOIActionKey('turn left', 'arrow_left') self.setActorOIActionKey('turn right', 'arrow_right') self.addHotKey('t', 'toggle pip', self.toggleDisplayRegion, []) self.addHotKey('f1', 'help', self.toggleOnScreenHelp, []) self.addHotKey('escape', 'quit', self.shutDown, [])