How to use the panda3d.core.Vec2 function in Panda3D

To help you get started, we’ve selected a few Panda3D examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github panda3d / panda3d / samples / gamepad / device_tester.py View on Github external
def create_menu_button(self, device):
        button = DirectButton(
            command=self.switch_to_panel,
            extraArgs=[device],
            text=device.name,
            text_scale=0.05,
            text_align=TextNode.ALeft,
            text_fg=VBase4(0.0, 0.0, 0.0, 1.0),
            text_pos=Vec2(0.01, base.a2dBottom / 10.0),
            relief=1,
            pad=Vec2(0.01, 0.01),
            frameColor=VBase4(0.8, 0.8, 0.8, 1.0),
            frameSize=VBase4(
                0.0,
                base.a2dLeft*-0.75 - 0.081,  # 0.08=Scrollbar, 0.001=inaccuracy
                base.a2dBottom / 5.0,
                0.0,
            ),
            parent=self.devices_frame.getCanvas(),
        )
        self.buttons[device] = button
github tobspr / RenderPipeline / rpplugins / smaa / jitters.py View on Github external
JITTERS = {

    "still": [
        Vec2(0.0, 0.0),
    ],

    "uniform2": [
        Vec2(-0.25, -0.25), # ll
        Vec2( 0.25,  0.25), # ur
    ],

    "uniform4": [
        Vec2(-0.25, -0.25), # ll
        Vec2( 0.25, -0.25), # lr
        Vec2( 0.25,  0.25), # ur
        Vec2(-0.25,  0.25), # ul
    ],

    "uniform4_helix": [
        Vec2(-0.25, -0.25), # ll  3  1
        Vec2( 0.25,  0.25), # ur   \/|
        Vec2( 0.25, -0.25), # lr   /\|
        Vec2(-0.25,  0.25), # ul  0  2
    ],

    "uniform4_double_helix": [
        Vec2(-0.25, -0.25), # ll  3  1
        Vec2( 0.25,  0.25), # ur   \/|
        Vec2( 0.25, -0.25), # lr   /\|
        Vec2(-0.25,  0.25), # ul  0  2
        Vec2(-0.25, -0.25), # ll  6--7
        Vec2( 0.25, -0.25), # lr   \
github tobspr / RenderPipeline / rpcore / gui / debugger.py View on Github external
def create_stats(self):
        """ Creates the stats overlay """
        self.overlay_node = Globals.base.aspect2d.attach_new_node("Overlay")
        self.debug_lines = []

        num_lines = 6 if self.advanced_info else 1
        for i in range(num_lines):
            self.debug_lines.append(TextNode(
                pos=Vec2(0, -i * 0.046), parent=self.overlay_node, align="right", color=Vec3(0.7, 1, 1)))
        self.debug_lines[0].color = Vec4(1, 1, 0, 1)
github tobspr / RenderPipeline / rpcore / gui / draggable_window.py View on Github external
def _get_mouse_pos(self):
        """ Internal helper function to get the mouse position, scaled by
        the context scale """
        mouse_x, mouse_y = (Globals.base.win.get_pointer(0).x,
                            Globals.base.win.get_pointer(0).y)
        return Vec2(mouse_x, mouse_y) * self._context_scale
github PiratesOnlineRewritten / Pirates-Online-Rewritten / pirates / seapatch / SeaPatchRoot.py View on Github external
def __init__(self):
        self.seaLevel = 0
        self.center = 0
        self.anchor = None
        self.overallSpeed = 0
        self.uvSpeed = Vec2(0, 0)
        self.thresfold = 0
        self.radius = 0
        self.uvScale = VBase2(0, 0)
        self.waveEnabled = 0
        self.high = VBase4(0, 0, 0, 0)
        self.mid = VBase4(0, 0, 0, 0)
        self.low = VBase4(0, 0, 0, 0)
github tobspr / RenderPipeline / Code / LightManager.py View on Github external
def _createDebugTexts(self):
        """ Creates a debug overlay if specified in the pipeline settings """
        self.lightsVisibleDebugText = None
        self.lightsUpdatedDebugText = None

        if self.pipeline.settings.displayDebugStats:
            self.lightsVisibleDebugText = FastText(pos=Vec2(
                Globals.base.getAspectRatio() - 0.1, 0.84), rightAligned=True, color=Vec3(1, 1, 0), size=0.03)
            self.lightsUpdatedDebugText = FastText(pos=Vec2(
                Globals.base.getAspectRatio() - 0.1, 0.8), rightAligned=True, color=Vec3(1, 1, 0), size=0.03)
github tobspr / RenderPipeline / Code / Water / GPUFFT.py View on Github external
pi = 3.141592653589793238462643383
        numIter = self.size / 2
        numK = 1
        resolutionFloat = float(self.size)
        for i in xrange(self.log2Size):
            start = 0
            end = 2 * numK
            for b in xrange(numIter):
                K = 0
                for k in xrange(start, end, 2):
                    fK = float(K)
                    fNumIter = float(numIter)
                    weightA = Vec2(
                        math.cos(2.0 * pi * fK * fNumIter / resolutionFloat),
                        -math.sin(2.0 * pi * fK * fNumIter / resolutionFloat))
                    weightB = Vec2(
                        -math.cos(2.0 * pi * fK * fNumIter / resolutionFloat),
                        math.sin(2.0 * pi * fK * fNumIter / resolutionFloat))
                    storage[i][k / 2] = weightA
                    storage[i][k / 2 + numK] = weightB
                    K += 1
                start += 4 * numK
                end = start + 2 * numK
            numIter = numIter >> 1
            numK = numK << 1
github panda3d / panda3d / samples / gamepad / mappingGUI.py View on Github external
)
        lbl.reparentTo(item)
        lbl.setTransparency(True)
        self.actionLabels[action] = lbl

        buttonScale = 0.15
        btn = DirectButton(
            text="Change",
            geom=self.buttonGeom,
            scale=buttonScale,
            text_scale=0.25,
            text_align=TextNode.ALeft,
            text_fg=VBase4(0.898, 0.839, 0.730, 1.0),
            text_pos=Vec2(-0.9, -0.085),
            relief=1,
            pad=Vec2(0.01, 0.01),
            frameColor=VBase4(0, 0, 0, 0),
            frameSize=VBase4(-1.0, 1.0, -0.25, 0.25),
            pos=(base.a2dRight-(0.898*buttonScale+0.3), 0, 0),
            pressEffect=False,
            command=self.changeMapping,
            extraArgs=[action])
        btn.setTransparency(True)
        btn.reparentTo(item)
        return item
github tobspr / RenderPipeline / Code / RenderingPipeline.py View on Github external
self.currentProjMatInv = PTALMatrix4f.emptyArray(1)
        self.lastMVP = PTALMatrix4f.emptyArray(1)
        self.currentMVP = PTALMatrix4f.emptyArray(1)
        self.frameIndex = PTAInt.emptyArray(1)
        self.frameDelta = PTAFloat.emptyArray(1)

        self.renderPassManager.registerStaticVariable("lastMVP", self.lastMVP)
        self.renderPassManager.registerStaticVariable("currentMVP", self.currentMVP)
        self.renderPassManager.registerStaticVariable("frameIndex", self.frameIndex)
        self.renderPassManager.registerStaticVariable("cameraPosition", self.cameraPosition)
        self.renderPassManager.registerStaticVariable("mainCam", self.showbase.cam)
        self.renderPassManager.registerStaticVariable("mainRender", self.showbase.render)
        self.renderPassManager.registerStaticVariable("frameDelta", self.frameDelta)
        self.renderPassManager.registerStaticVariable("currentViewMat", self.currentViewMat)
        self.renderPassManager.registerStaticVariable("currentProjMatInv", self.currentProjMatInv)
        self.renderPassManager.registerStaticVariable("zeroVec2", Vec2(0))
        self.renderPassManager.registerStaticVariable("zeroVec3", Vec3(0))
        self.renderPassManager.registerStaticVariable("zeroVec4", Vec4(0))

        self.transformMat = TransformState.makeMat(Mat4.convertMat(CSYupRight, CSZupRight))
github tobspr / RenderPipeline / Code / AntialiasingManager.py View on Github external
# When jittering is enabled, precompute the jitter offsets
        if self.jitter:

            # Compute how big a pixel is on screen
            aspect = float(self.pipeline.getSize().x) / float(self.pipeline.getSize().y)
            onePixelShift = Vec2(0.5 / float(self.pipeline.getSize().x), 
                0.5 / float(self.pipeline.getSize().y) / aspect) * self.pipeline.settings.jitterAmount

            # Annoying that Vec2 has no multliply-operator for non-floats
            multiplyVec2 = lambda a, b: Vec2(a.x*b.x, a.y*b.y)

            # Multiply the pixel size with the offsets to compute the final jitter
            self.jitterOffsets = [
                multiplyVec2(onePixelShift, Vec2(-0.25,  0.25)),
                multiplyVec2(onePixelShift, Vec2(0.25, -0.25))
            ]


        # Finally register the antialiasing pass
        self.pipeline.getRenderPassManager().registerPass(self.antialiasingPass)