home *** CD-ROM | disk | FTP | other *** search
- import trueSpace
- import string
-
- import win32ui
- import win32api
- import dialog
- import win32con
-
- def MakeDlgTemplate(title):
- style = win32con.DS_MODALFRAME | win32con.WS_POPUP | win32con.WS_VISIBLE | win32con.WS_CAPTION | win32con.WS_SYSMENU | win32con.DS_SETFONT
- cs = win32con.WS_CHILD | win32con.WS_VISIBLE
-
- # Window frame and title
- dlg = [ [title, (0, 0, 210, 100), style, None, (8, "MS Sans Serif")], ]
-
- # Primitive type label and text box
- dlg.append([130, "Primitive type: (Cube)", -1, (7, 9, 69, 9), cs | win32con.SS_LEFT])
- s = cs | win32con.WS_TABSTOP | win32con.WS_BORDER
-
- # Primitive properties and text boxes
- dlg.append([130, "Primitive Properties:", -1, (7, 22, 69, 9), cs | win32con.SS_LEFT])
- dlg.append([130, "Sections:", -1, (7, 35, 40, 9), cs | win32con.SS_LEFT])
- dlg.append([130, "X size:", -1, (7, 50, 40, 9), cs | win32con.SS_LEFT])
- dlg.append([130, "Y size:", -1, (7, 65, 40, 9), cs | win32con.SS_LEFT])
- dlg.append([130, "Z size:", -1, (7, 80, 40, 9), cs | win32con.SS_LEFT])
-
- # edit boxes
- s = cs | win32con.WS_TABSTOP | win32con.WS_BORDER
- dlg.append(['EDIT', None, win32ui.IDC_EDIT1, (60, 35, 60, 12), s])
- dlg.append(['EDIT', None, win32ui.IDC_EDIT2, (60, 50, 60, 12), s])
- dlg.append(['EDIT', None, win32ui.IDC_EDIT3, (60, 65, 60, 12), s])
- dlg.append(['EDIT', None, win32ui.IDC_EDIT4, (60, 80, 60, 12), s])
-
- # OK/Cancel Buttons
- s = cs | win32con.WS_TABSTOP
- dlg.append([128, "OK", win32con.IDOK, (150, 5, 50, 14), s | win32con.BS_DEFPUSHBUTTON])
- s = win32con.BS_PUSHBUTTON | s
- dlg.append([128, "Cancel", win32con.IDCANCEL, (150, 20, 50, 14), s])
- return dlg
-
- class CreateDlg(dialog.Dialog):
- Cancel = 0
- def __init__(self, title):
- dialog.Dialog.__init__(self, MakeDlgTemplate(title) )
- self.AddDDX(win32ui.IDC_EDIT1,'x')
- self.AddDDX(win32ui.IDC_EDIT2,'y')
- self.AddDDX(win32ui.IDC_EDIT3,'z')
- self.AddDDX(win32ui.IDC_EDIT4,'w')
- def OnCancel(self):
- self.Cancel = 1
- self._obj_.OnCancel()
-
- #####################################################################
- # Create dialog and read data/properties
- #####################################################################
- def GetData(title='Primitive Creation'):
- d = CreateDlg(title)
- d['x'] = "1"
- d['y'] = "2"
- d['z'] = "2"
- d['w'] = "2"
- d.DoModal()
- if d.Cancel:
- return (None, None, None, None)
- else:
- return (d['x'], d['y'], d['z'], d['w'] )
-
- #####################################################################
- #Object creation routines:
- #####################################################################
- #CreateCone(longitudes, latitudes, radius, height)
- #CreateCube(sections, x, y, z)
- #CreateCylinder(longitudes, latitudes, radius1, radius2, height)
- #CreatePlane(xsections, ysections)
- #CreateSphere(longitudes, latitudes, radius)
- #CreateTorus(longitudes, latitudes, inner-radius)
- #CreateLocalLight()
- #CreateInfiniteLight()
- #CreateSpotLight()
- #CreateCamera ()
-
- doc = trueSpace.GetActiveDocument()
-
- d1,d2,d3,d4 = GetData()
-
- if d1 == None:
- print "Cancelled...\n"
- else:
- x = string.atof(d1)
- y = string.atof(d2)
- z = string.atof(d3)
- w = string.atof(d4)
- doc.CreateCube(x, y, z, w) # create a new primitive
- doc.Draw() # redraw scene
- print "Primitive was created...\n"
-
-