Added mouse injection in the test script. Also added plane generation on the fly.
This commit is contained in:
parent
58ab7aa79a
commit
0e4f2324f5
1 changed files with 25 additions and 5 deletions
30
test.py
30
test.py
|
|
@ -10,28 +10,48 @@ from pandac.PandaModules import *
|
|||
|
||||
from jgui.surface.surface import *
|
||||
|
||||
Width, Height = 1024, 1024
|
||||
props = WindowProperties()
|
||||
props.setSize(1024,1024)
|
||||
base.setBackgroundColor(0.5,1,1,1)
|
||||
base.cam.setPos(0,-10,0)
|
||||
base.win.requestProperties(props)
|
||||
screen = loader.loadModel('/home/joey/Creationista/models/plane.egg.pz')
|
||||
c = CardMaker('plane')
|
||||
c.setFrame(-1, 1, 1, -1)
|
||||
c.setHasUvs(True)
|
||||
screen = render2d.attachNewNode(c.generate())
|
||||
#screen = loader.loadModel('plane')
|
||||
screen.setTransparency(TransparencyAttrib.MAlpha)
|
||||
screen.setTwoSided(True)
|
||||
screen.setScale(2)
|
||||
Width, Height = 1024, 1024
|
||||
#screen.setScale(2)
|
||||
|
||||
surf = Surface([Width, Height])
|
||||
|
||||
cairoTexture = Texture()
|
||||
cairoTexture.setXSize(Width)
|
||||
cairoTexture.setYSize(Height)
|
||||
cairoTexture.setFormat(cairoTexture.FRgba8)
|
||||
cairoTexture.setup2dTexture(Width, Height, Texture.CMDefault, Texture.FRgba32)
|
||||
cairoTexture.setup2dTexture(Width, Height, Texture.TUnsignedByte, Texture.FRgba32)
|
||||
|
||||
screen.setTexture(cairoTexture)
|
||||
screen.reparentTo(render2d)
|
||||
#screen.reparentTo(render2d)
|
||||
def move():
|
||||
print surf.root_window.children[0].position
|
||||
surf.root_window.children[0].position += [1, 1]
|
||||
def click():
|
||||
surf.root_window.injectMouseDown('mouse1')
|
||||
def up():
|
||||
surf.root_window.injectMouseUp('mouse1')
|
||||
base.accept('d-repeat', move)
|
||||
base.accept('mouse1', click)
|
||||
base.accept('mouse1-up', up)
|
||||
|
||||
def drawall(task):
|
||||
surf.draw()
|
||||
if base.mouseWatcherNode.hasMouse():
|
||||
x = base.win.getXSize() * (1 + base.mouseWatcherNode.getMouseX()) / 2
|
||||
y = base.win.getYSize() * (1 - base.mouseWatcherNode.getMouseY()) / 2
|
||||
surf.root_window.injectMousePosition([x, y])
|
||||
cairoTexture.setRamImage(surf.csurface.get_data())
|
||||
return task.cont
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue