grid 'n' pivot

grid.py

``````# dhochegger 2008
# !!! never draw diagonal axis to make a grid!!!! lol

from pandac.PandaModules import *
from direct.directtools.DirectGeometry import LineNodePath
import direct.directbase.DirectStart
from pandac.PandaModules import Point3,Vec3,Vec4
import pivot

raws1unit = 20
rawsHALFunit = 100
d = 0
X1 = 10
X2 = -10
Y1 = 10
Y2 = -10

axis = LineNodePath(render,'axis',4,Vec4(.2,.2,.2,.2))

x1 = (0,Y2,0)
x2 = (0,Y1,0)

x3 = (X2,0,0)
x4 = (X1,0,0)

axis.drawLines([[x1,x2],[x3,x4]])
axis.create()

q1 = (X1,Y1,0)
q2 = (X1,Y2,0)

q3 = (q2)
q4 = (X2,Y2,0)

q5 = (q4)
q6 = (X2,Y1,0)

q7= (q6)
q8 = (X1,Y1,0)

for l in range (raws1unit-1):
d+= 1
l1 = (X2+d,Y1,0)
l2 = (X2+d,Y2,0)

l3 = (X2,Y1-d,0)
l4 = (X1,Y1-d,0)

linesX.drawLines([[l1,l2],[l3,l4]])
linesX.create()

for l in range (rawsHALFunit):
d-=.2
lx1 = (X2+1+d,Y1,0)
lx2 = (X2+1+d,Y2,0)

lx3 = (X2,Y1-1-d,0)
lx4 = (X1,Y1-1-d,0)

linesXX.drawLines([[lx1,lx2],[lx3,lx4]])
linesXX.create()

run() ``````

pivot 3d axis
pivot.py

``````#pivot 3d axis dhochegger 2008

from pandac.PandaModules import *
from direct.directtools.DirectGeometry import LineNodePath
import direct.directbase.DirectStart
from pandac.PandaModules import Point3,Vec3,Vec4
#set the Pivot trans in X
global PX
PX = 10
#set the Pivot trans in Y
global PY
PY = 1
#set the Pivot trans in Z
global PZ
PZ = 1.5
global length
lengthX = PX + 1.5
lengthY = PY + 1.5
lengthZ = PZ + 1.5
global q1
q1 = PX + .5
global q2
q2 = -q1

arrowLENGHT = PX +.2

arrowXx1 = PY + .08
arrowXx2 = PY - .08
arrowXz2 = PX + 1.3

arrowYx1 = PX + .08
arrowYx2 = PX - .08
arrowYz2 = PY + 1.3

arrowZx1 = PX + .08
arrowZx2 = PX - .08
arrowZz2 = PZ + 1.3

PIVarX = LineNodePath(render,'pivotX',3,Vec4(1,0,0,1))
PIVarY = LineNodePath(render,'pivotY',3,Vec4(0,1,1,1))
PIVarZ = LineNodePath(render,'pivotZ',3,Vec4(1,1,0,1))

PIVOThandler = LineNodePath(render,'handler',2,Vec4(1,0,1,1))

arrowX1 = (lengthX,PY,PZ)
arrowX2 = (arrowXz2,arrowXx1,PZ)
arrowX3 = (arrowXz2,arrowXx2,PZ)

arrowY1 = (PX,lengthY,PZ)
arrowY2 = (arrowYx1,arrowYz2,PZ)
arrowY3 = (arrowYx2,arrowYz2,PZ)

arrowZ1 = (PX,PY,lengthZ)
arrowZ2 = (arrowZx1,PY,arrowZz2)
arrowZ3 = (arrowZx2,PY,arrowZz2)

PIVarX.drawLines([[(PX,PY,PZ),(lengthX,PY,PZ)],[arrowX1,arrowX2],[arrowX1,arrowX3]])
PIVarY.drawLines([[(PX,PY,PZ),(PX,lengthY,PZ)],[arrowY1,arrowY2],[arrowY1,arrowY3]])
PIVarZ.drawLines([[(PX,PY,PZ),(PX,PY,lengthZ)],[arrowZ1,arrowZ2],[arrowZ1,arrowZ3]])

PIVOThandler.drawLines([[(PX,PY,PZ),(PX+0.5,PY,PZ)],[(PX+.5,PY,PZ),(PX,PY+.5,PZ)],[(PX,PY+.5,PZ),(PX,PY,PZ)]])

PIVarX.create()
PIVarY.create()
PIVarZ.create()
PIVOThandler.create()

``````

Nice! I think I can use this soon.

whoah, thanks! I can really use this in my editor.

wow thats balsam for my soul, i started with panda just a short time ago

next im going to build in that you are able to change interactive the grid size.

grid.py

``````# grid v0.01 dhochegger 2008

from pandac.PandaModules import *
from direct.directtools.DirectGeometry import LineNodePath
import direct.directbase.DirectStart
from pandac.PandaModules import Point3,Vec3,Vec4
from direct.showbase import DirectObject
import pivot
import gridFIELD

raws1unit = 20
rawsHALFunit = 100

X1 = 10
X2 = -10
Y1 = 10
Y2 = -10

linesX = LineNodePath(render,'lines1',2,Vec4(.3,.3,.3,0))
linesXXX = LineNodePath(render,'lines1',.4,Vec4(.35,.35,.35,0))
axis = LineNodePath(render,'axis',4,Vec4(.2,.2,.2,0))

x1 = (0,Y2,0)
x2 = (0,Y1,0)

x3 = (X2,0,0)
x4 = (X1,0,0)

axis.drawLines([[x1,x2],[x3,x4]])
axis.create()

q1 = (X1,Y1,0)
q2 = (X1,Y2,0)

q3 = (q2)
q4 = (X2,Y2,0)

q5 = (q4)
q6 = (X2,Y1,0)

q7= (q6)
q8 = (X1,Y1,0)

class gridPAINTER(DirectObject.DirectObject):
def __init__(self):

d = 0
for l in range (raws1unit-1):
lO = len(gridFIELD.output)
lO1 = lO - 1
global field
field1 = gridFIELD.output[lO1]
field = float(field1)
print field
d+= field
l1 = (X2+d,Y1,0)
l2 = (X2+d,Y2,0)

l3 = (X2,Y1-d,0)
l4 = (X1,Y1-d,0)

linesX.drawLines([[l1,l2],[l3,l4]])
linesX.create()

print gridFIELD.output

global keyMap
keyMap = {"ent":0,"clear":0}
self.accept("enter", self.Keys, ["ent",1])
self.accept("enter-up", self.Keys, ["ent",0])
self.accept("space", self.Keys, ["clear",1])
self.accept("space-up", self.Keys, ["clear",0])

def Keys(self, key, value):
keyMap[key] = value

lO = len(gridFIELD.output)
lO1 = lO - 1
global field
field1 = gridFIELD.output[lO1]
field = float(field1)

if field <= .1:
raws = field*2000
field = .1

if field > .2 and field < .4:
field = .2
raws = field*500

if field >= .4 and field <= .6:
field = .5
raws = field*80

if field >= .4 and field < 1:
print "grid to big - it must be valued between 1 - .1"
field = .5
raws = field*80

if field == 1:
print "grid is already on that state"
field = 0
raws = 0

if keyMap["ent"]:
if field < .1:
print "grid to small - it must be valued between 1 - .1"
else:
dd = 0
for l in range (raws):
print field
dd+= field
l1 = (X2+dd,Y1,0)
l2 = (X2+dd,Y2,0)

l3 = (X2,Y1-dd,0)
l4 = (X1,Y1-dd,0)

linesXXX.drawLines([[l1,l2],[l3,l4]])
linesXXX.create()
gp = gridPAINTER()
run() ``````

pivot.py

``````#pivot 3d axis dhochegger 2008

from pandac.PandaModules import *
from direct.directtools.DirectGeometry import LineNodePath
import direct.directbase.DirectStart
from pandac.PandaModules import Point3,Vec3,Vec4
#set the Pivot trans in X
global PX
PX = 10
#set the Pivot trans in Y
global PY
PY = 1
#set the Pivot trans in Z
global PZ
PZ = 1.5
global length
lengthX = PX + 1.5
lengthY = PY + 1.5
lengthZ = PZ + 1.5
global q1
q1 = PX + .5
global q2
q2 = -q1

arrowLENGHT = PX +.2

arrowXx1 = PY + .08
arrowXx2 = PY - .08
arrowXz2 = PX + 1.3

arrowYx1 = PX + .08
arrowYx2 = PX - .08
arrowYz2 = PY + 1.3

arrowZx1 = PX + .08
arrowZx2 = PX - .08
arrowZz2 = PZ + 1.3

PIVarX = LineNodePath(render,'pivotX',3,Vec4(1,0,0,1))
PIVarY = LineNodePath(render,'pivotY',3,Vec4(0,1,1,1))
PIVarZ = LineNodePath(render,'pivotZ',3,Vec4(1,1,0,1))

PIVOThandler = LineNodePath(render,'handler',2,Vec4(1,0,1,1))

arrowX1 = (lengthX,PY,PZ)
arrowX2 = (arrowXz2,arrowXx1,PZ)
arrowX3 = (arrowXz2,arrowXx2,PZ)

arrowY1 = (PX,lengthY,PZ)
arrowY2 = (arrowYx1,arrowYz2,PZ)
arrowY3 = (arrowYx2,arrowYz2,PZ)

arrowZ1 = (PX,PY,lengthZ)
arrowZ2 = (arrowZx1,PY,arrowZz2)
arrowZ3 = (arrowZx2,PY,arrowZz2)

PIVarX.drawLines([[(PX,PY,PZ),(lengthX,PY,PZ)],[arrowX1,arrowX2],[arrowX1,arrowX3]])
PIVarY.drawLines([[(PX,PY,PZ),(PX,lengthY,PZ)],[arrowY1,arrowY2],[arrowY1,arrowY3]])
PIVarZ.drawLines([[(PX,PY,PZ),(PX,PY,lengthZ)],[arrowZ1,arrowZ2],[arrowZ1,arrowZ3]])

PIVOThandler.drawLines([[(PX,PY,PZ),(PX+0.5,PY,PZ)],[(PX+.5,PY,PZ),(PX,PY+.5,PZ)],[(PX,PY+.5,PZ),(PX,PY,PZ)]])

PIVarX.create()
PIVarY.create()
PIVarZ.create()
PIVOThandler.create() ``````

gridFIELD.py

``````import direct.directbase.DirectStart
from direct.gui.OnscreenText import OnscreenText
from direct.gui.DirectGui import *
from pandac.PandaModules import *
from direct.directtools.DirectGeometry import LineNodePath
from direct.gui.OnscreenText import OnscreenText
import buttonsGRID

global output
output = [1]

textObject = OnscreenText(text = "gridUNITS", pos = (-1.23, .94), scale = 0.04,fg = (0,0,0,.8))
textObject.setTransparency(TransparencyAttrib.MAlpha)

line = LineNodePath(render2d,'line',2,Vec4(.3,.3,.3,0))
line.drawLines([[(-.76,0,1),(-.76,0,-1)]])
line.create()

def react(input):

output.append(input)
print output

def clear():
gU.enterText('')

gU = DirectEntry(text = "",scale = .05,width = 5,command=react,rolloverSound = "",
initialText="GridUNIT->", numLines = 1,focus=0,focusInCommand=clear,
clickSound = "")
gU.setColorScale(.6,.7,.6,.4)
gU.setTransparency(TransparencyAttrib.MAlpha)

gU.setPos(-1.3,0,.86)``````

buttonsGRID.py

``````#dhochegger 2008
import direct.directbase.DirectStart
from direct.showbase import DirectObject
from direct.gui.DirectGui import *
from pandac.PandaModules import Point3,Vec3,Vec4
from direct.interval.LerpInterval import LerpFunc
from direct.interval.IntervalGlobal import *
import sys
count = 8
class buttons (DirectObject.DirectObject):
def __init__ (self):
XX = 0
for x in range(count):
XX += .1
button = DirectButton(text = ("button"), command = self.button, scale = (.08, .05, .05),rolloverSound = "", relief = None)
button.setColorScale(0,0,0,.6)
button.setTransparency(1)
button.setPos(-1.18, 0,  .85-XX)
def button (self):
print "..."
b = buttons()``````

[/img]

its really the best way to learn python Â´n panda, be getting into those challenges in this forum…

thx alot

so now i can place the pivot by using the mouse…

type into the text field units between .1 .2 .5 and accept with enter

``````# grid v0.03 dhochegger 2008

from pandac.PandaModules import *
from direct.directtools.DirectGeometry import LineNodePath
import direct.directbase.DirectStart
from pandac.PandaModules import Point3,Vec3,Vec4
from direct.showbase import DirectObject
from pandac.PandaModules import NodePathCollection
import pivot
import gridFIELD
import buttonsGRID

raws1unit = 20
rawsHALFunit = 100

X1 = 10
X2 = -10
Y1 = 10
Y2 = -10

linesX = LineNodePath(render,'lines1',2,Vec4(.3,.3,.3,0))
linesXXX = LineNodePath(render,'lines1',.4,Vec4(.35,.35,.35,0))
axis = LineNodePath(render,'axis',4,Vec4(.2,.2,.2,0))

x1 = (0,Y2,0)
x2 = (0,Y1,0)

x3 = (X2,0,0)
x4 = (X1,0,0)

axis.drawLines([[x1,x2],[x3,x4]])
axis.create()

q1 = (X1,Y1,0)
q2 = (X1,Y2,0)

q3 = (q2)
q4 = (X2,Y2,0)

q5 = (q4)
q6 = (X2,Y1,0)

q7= (q6)
q8 = (X1,Y1,0)

class gridPAINTER(DirectObject.DirectObject):
def __init__(self):

d = 0
for l in range (raws1unit-1):
lO = len(gridFIELD.output)
lO1 = lO - 1
global field
field1 = gridFIELD.output[lO1]
field = float(field1)
print field
d+= field
l1 = (X2+d,Y1,0)
l2 = (X2+d,Y2,0)

l3 = (X2,Y1-d,0)
l4 = (X1,Y1-d,0)

linesX.drawLines([[l1,l2],[l3,l4]])
linesX.create()

print gridFIELD.output

global keyMap
keyMap = {"ent":0,"clear":0}
self.accept("enter", self.Keys, ["ent",1])
self.accept("enter-up", self.Keys, ["ent",0])
self.accept("space", self.Keys, ["clear",1])
self.accept("space-up", self.Keys, ["clear",0])

def Keys(self, key, value):
keyMap[key] = value

lO = len(gridFIELD.output)
lO1 = lO - 1
global field
field1 = gridFIELD.output[lO1]
field = float(field1)

if field <= .1:
global raws
raws = field*2000
field = .1

if field > .2 and field < .4:
global raws
field = .2
raws = field*500

if field >= .4 and field <= .6:
global raws
field = .5
raws = field*80

if field >= .4 and field < 1:
print "grid to big - it must be valued between 1 - .1"
global raws
field = .5
raws = field*80

if field == 1:
print "grid is already on that state"
global raws
field = 0
raws = 0

if keyMap["ent"]:
linesXXX.detachNode()
global linesXXX
linesXXX = LineNodePath(render,'lines1',.4,Vec4(.35,.35,.35,0))
if field < .1:
print "grid to small - it must be valued between 1 - .1"
else:
dd = 0
for l in range (raws):
print field
dd+= field
l1 = (X2+dd,Y1,0)
l2 = (X2+dd,Y2,0)

l3 = (X2,Y1-dd,0)
l4 = (X1,Y1-dd,0)

linesXXX.drawLines([[l1,l2],[l3,l4]])
linesXXX.create()

gp = gridPAINTER()
run()``````

im working on a modelviewer with convert functions and some other helpfully stuff (batch management and so on). when its done i will upload the source here.

btw python and panda rocks!

greetz
dirk

Looks like its coming along good

This happens to be the exact kind of editor I need in the Tactical RPG im working on

wow thx that you like it

ditus:

I am sorry if this question seems obvious. But I have been watching this thread and I am not sure what your grid.py script and the other scripts you have posted can be used for.

It seems to me that they will give the panda3d programmer the location of specific points in the panda “World” so that you do not have to guess at placement of model coordinates in your program code. Is this correct. In any case just from the look of the screen shots this looks useful to me now that the scene editor is no longer in panda.

Very useful indeed, now that the sceneEditor is gone.

“sceneEditor is gone” - have any one every used it? … silence
Have any one every try to use it? yes me!
Did it work? no … well it did load and you could load your models inside it move them around … but the interface! aahahahah … no it did not work - it functioned.

Its good some one is doing some thing to replace that mistake of history.

Alright Treeform, This would be the wrong place to talk about that but if you insist, I have used the sceneEditor for along time. Just because I haven’t posted in the last 2 years Ive been programming with P3D doesn’t mean that I have never used the sceneEditor (Actully alot of the users have). I am also very glad that it is gone, I just wanted to know why they would take it out. sceneEditor did what it was programmed to do, now we can advance further past that and maybe replace it with something better for a change.

!!! stop!!!

im just building a tool, where you can check your models and changing some model options (texture, coordinates, setting some trigger points and so on…) and generating some code! that was the idea behind.

greetz
dirk

so, i build some nice things like dragable menu windows, i was thinking that will give them whole look such more style, than static menus

sceneEDITOR - a mistake of the history? im sure someone isnt able to work with, but im sure its a smart tool!

what makes me think that we need for someone soon the red door

take a look on IT CROWD one of my fav. tv show