Skip to content

Instantly share code, notes, and snippets.

@cortical-iv
Created January 27, 2019 05:34
Show Gist options
  • Save cortical-iv/9fae50e2d4decb7059c1cc26f22b9f88 to your computer and use it in GitHub Desktop.
Save cortical-iv/9fae50e2d4decb7059c1cc26f22b9f88 to your computer and use it in GitHub Desktop.
tryying to get pixel2d to work
"""
panda3d learning
Exploring default scene graphs rooted with render, render2d, pixel2d
"""
from direct.showbase.ShowBase import ShowBase
from panda3d.core import Texture, CardMaker, NodePath #, PTAUchar,
import numpy as np
#Create random numpy array
size = 1024
texture = 255*np.ones((size, size), dtype = np.uint8) #make textures a power of 2
#texture = np.array(np.random.rand(512,512) * 255, dtype=np.uint8)
texture[1022:1023,:] = 0
texture[1000:1010,:] = 0 #horizontal black line
texture[250:260,:] = 120 #horizontal gray line
texture[:,250:260] = 230 #vertical light line
texture[:, 1020:1023] = 0
class MyApp(ShowBase):
def __init__(self):
ShowBase.__init__(self)
self.imageTexture = Texture("image")
self.imageTexture.setup2dTexture(size, size, Texture.T_unsigned_byte, Texture.F_luminance) #could give more params
self.imageTexture.setRamImage(texture)
cm = CardMaker('card')
#cm.setFrameFullscreenQuad()
self.card= NodePath(cm.generate())
self.card.setTexture(self.imageTexture)
#self.card.reparentTo(self.render2d) #this shows the image
self.card.reparentTo(self.pixel2d) #this shows nada....
self.cam.setPos(0, -4, 0) #this shouldnt do anything
app = MyApp()
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment