def test_cullfaceattrib_compare(): clockwise1 = CullFaceAttrib.make() clockwise2 = CullFaceAttrib.make() reverse1 = CullFaceAttrib.make_reverse() reverse2 = CullFaceAttrib.make_reverse() assert clockwise1.compare_to(clockwise2) == 0 assert clockwise2.compare_to(clockwise1) == 0 assert reverse1.compare_to(reverse2) == 0 assert reverse2.compare_to(reverse1) == 0 assert reverse1.compare_to(clockwise1) != 0 assert clockwise1.compare_to(reverse1) != 0 assert reverse1.compare_to(clockwise1) == -clockwise1.compare_to(reverse1)
def create(self): winprops = WindowProperties.size(self.size, self.size) props = FrameBufferProperties() props.setRgbColor(0) props.setAlphaBits(0) props.setDepthBits(1) self.buffer = base.graphicsEngine.makeOutput( base.pipe, "shadowsBuffer", -2, props, winprops, GraphicsPipe.BFRefuseWindow, base.win.getGsg(), base.win) if not self.buffer: print("Video driver cannot create an offscreen buffer.") return self.depthmap = Texture() self.buffer.addRenderTexture(self.depthmap, GraphicsOutput.RTMBindOrCopy, GraphicsOutput.RTPDepthStencil) self.depthmap.setMinfilter(Texture.FTShadow) self.depthmap.setMagfilter(Texture.FTShadow) self.depthmap.setBorderColor(LColor(1, 1, 1, 1)) self.depthmap.setWrapU(Texture.WMBorderColor) self.depthmap.setWrapV(Texture.WMBorderColor) self.cam = base.makeCamera(self.buffer, lens=OrthographicLens()) self.cam.reparent_to(render) self.node = self.cam.node() self.node.setInitialState( RenderState.make( CullFaceAttrib.make_reverse(), ColorWriteAttrib.make(ColorWriteAttrib.M_none), )) self.node.setScene(render) if settings.debug_shadow_frustum: self.node.showFrustum()
def append_mesh(self, root_path, name, mesh_path, scale=None, frame=None, no_cache=None): """Append a mesh node to the group. Arguments: root_path {str} -- path to the group's root node name {str} -- node name within a group mesh_path {str} -- path to the mesh file on disk Keyword Arguments: scale {Vec3} -- mesh scale (default: {None}) frame {tuple} -- local frame position and quaternion (default: {None}) no_cache {bool} -- use cache to load a model (default: {None}) """ mesh = self.loader.loadModel(mesh_path, noCache=no_cache) if mesh_path.lower().endswith('.dae'): # converting from Y-up to Z-up axes when import from dae mesh.set_mat(Mat4.yToZUpMat()) if scale is not None: mesh.set_scale(Vec3(*scale)) if sum([s < 0 for s in scale]) % 2 != 0: # reverse the cull order in case of negative scale values mesh.set_attrib(CullFaceAttrib.make_reverse()) self.append_node(root_path, name, mesh, frame)