Text archives Help
- From: abe@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r1159 - trunk/SwigInterface
- Date: Mon, 7 Aug 2006 21:32:06 -0600 (MDT)
Author: abe
Date: Mon Aug 7 21:32:05 2006
New Revision: 1159
Modified:
trunk/SwigInterface/ (props changed)
trunk/SwigInterface/CMakeLists.txt
trunk/SwigInterface/manta.i
trunk/SwigInterface/runmanta.py
trunk/SwigInterface/wxManta.py
Log:
Modified directory to ignore .pyc files.
_M SwigInterface
Added post build copy to move everything into build_dir/lib. Note that
this script is only run on rebuild, so check your PYTHONPATH if you
modify the copy in the source tree.
M SwigInterface/CMakeLists.txt
Added glm code so triangle loading can be performed from python if you
are patient
M SwigInterface/manta.i
Modified wxManta.MantaApp so that a make_scene function may be passed
to it. Also added arguments for number of processors and resolution.
See wiki for updated usage.
M SwigInterface/wxManta.py
M SwigInterface/runmanta.py
Modified: trunk/SwigInterface/CMakeLists.txt
==============================================================================
--- trunk/SwigInterface/CMakeLists.txt (original)
+++ trunk/SwigInterface/CMakeLists.txt Mon Aug 7 21:32:05 2006
@@ -46,34 +46,22 @@
SWIG_LINK_LIBRARIES(pycallback ${PYTHON_LIBRARIES})
-# Copy the manta.py swig compiled object to the lib directory.
-ADD_CUSTOM_COMMAND(
- TARGET _manta
- POST_BUILD
- COMMAND ${CMAKE_COMMAND}
- ARGS -E copy ${CMAKE_CURRENT_SOURCE_DIR}/FloatSpin.py
- ${PROJECT_BINARY_DIR}/lib/FloatSpin.py
- COMMENT "Copying FloatSpin.py to ${PROJECT_BINARY_DIR}/lib/FloatSpin.py"
+MACRO(PYTHON_POST_BUILD_COPY PY_FILE)
+
+ # Copy the python object to the lib directory.
+ ADD_CUSTOM_COMMAND(
+ TARGET _manta
+ POST_BUILD
+ COMMAND ${CMAKE_COMMAND}
+ ARGS -E copy ${CMAKE_CURRENT_SOURCE_DIR}/${PY_FILE}
+ ${PROJECT_BINARY_DIR}/lib/${PY_FILE}
+ COMMENT "Copying ${PY_FILE} to ${PROJECT_BINARY_DIR}/lib/${PY_FILE}"
)
+ENDMACRO(PYTHON_POST_BUILD_COPY PY_FILE)
+
+PYTHON_POST_BUILD_COPY(FloatSpin.py)
+PYTHON_POST_BUILD_COPY(wxManta.py)
+PYTHON_POST_BUILD_COPY(runmanta.py)
-############################################################
-# Load a scene from a python script.
-SET(SCENE_PYTHON 0 CACHE BOOL "Load a scene from a python script..")
-IF(SCENE_PYTHON)
- # Add the source file or a stub.
- INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
-
- # Add the scene.
- ADD_LIBRARY(scene_python python.cc)
- TARGET_LINK_LIBRARIES(scene_python
- ${PYTHON_LIBRARIES}
- ${MANTA_TARGET_LINK_LIBRARIES}
- ${CMAKE_THREAD_LIBS_INIT}
- ${OPENGL_LIBRARIES}
- ${X11_LIBRARIES}
- util
- -lm
- )
-ENDIF(SCENE_PYTHON)
Modified: trunk/SwigInterface/manta.i
==============================================================================
--- trunk/SwigInterface/manta.i (original)
+++ trunk/SwigInterface/manta.i Mon Aug 7 21:32:05 2006
@@ -438,6 +438,14 @@
%include <Model/Groups/RealisticBvh.h>
/////////////////////////////////////////////////
+// GLM.
+%{
+#include <Model/Readers/glm/glm.h>
+%}
+
+%include <Model/Readers/glm/glm.h>
+
+/////////////////////////////////////////////////
// The Array Containers
%{
#include <SCIRun/Core/Containers/Array1.h>
Modified: trunk/SwigInterface/runmanta.py
==============================================================================
--- trunk/SwigInterface/runmanta.py (original)
+++ trunk/SwigInterface/runmanta.py Mon Aug 7 21:32:05 2006
@@ -1,146 +1,52 @@
-from manta import *
-def createDefaultScenePython():
- scene = manta_new(Scene())
-
scene.setBackground(manta_new(ConstantBackground(ColorDB.getNamedColor("SkyBlue3").scaled(0.5))))
- red = manta_new(Phong(Color(RGBColor(0.6, 0, 0)),
- Color(RGBColor(0.6,0.6,0.6)),
- 32, 0.4))
- checker1 = manta_new(CheckerTexture_Color(Color(RGBColor(.6,.6,.6)),
- Color(RGBColor(0,0,0)),
- Vector(1,0,0),
- Vector(0,1,0)))
- constant_color1 = manta_new(Constant_Color(Color(RGBColor(.6,.6,.6))))
- checker2 = manta_new(CheckerTexture_ColorComponent(0.2, 0.5,
Vector(1,0,0),
- Vector(0,1,0)))
- plane_matl = manta_new(Phong(checker1, constant_color1, 32, checker2))
- #
- world = manta_new(Group())
- floor = manta_new(Parallelogram(plane_matl, Vector(-20,-20,0),
- Vector(40,0,0), Vector(0,40,0)))
- uniformmap = manta_new(UniformMapper())
- floor.setTexCoordMapper(uniformmap)
- world.add(floor)
- world.add(manta_new(Sphere(red, Vector(0,0,1.2), 1.0)))
- scene.setObject(world)
- #
- lights = manta_new(LightSet())
- lights.add(manta_new(PointLight(Vector(0,5,8),
Color(RGBColor(.6,.1,.1)))))
- lights.add(manta_new(PointLight(Vector(5,0,8),
Color(RGBColor(.1,.6,.1)))))
- lights.add(manta_new(PointLight(Vector(5,5,2),
Color(RGBColor(.2,.2,.2)))))
- lights.setAmbientLight(manta_new(ConstantAmbient(Color.black())))
- print lights
- #
- scene.setLights(lights)
- scene.getRenderParameters().maxDepth = 5
- return scene
-
-def createDielectricTestScene():
- scene = manta_new(Scene())
- scene.setBackground(manta_new(ConstantBackground(Color(RGBColor(0.5,
0.8, 0.9)))))
- # world will be added to the scene
- world = manta_new(Group())
- # Collection of objects that will be put in the BVH.
- objs = Array1_ObjectP()
- # The gound plane
- groundmatl = manta_new(Lambertian(Color(RGBColor(0.95, 0.65, 0.35))))
- # We can't add the plane to objs, because it doesn't have a proper
- # bounding box.
- world.add(manta_new(Plane(groundmatl, Vector(0,0,1), Vector(0,0,2.5))))
- # Metal sphere
- ball_matl = manta_new(MetalMaterial(Color(RGBColor(0.8, 0.8, 0.8)), 100))
- objs.add(manta_new(Sphere(ball_matl, Vector(-6, 3.5, 3.5), 1.0)))
- #
- lenscale = 2.5
- glass = Color(RGBColor(pow(0.80, lenscale), pow(0.93, lenscale),
pow(0.87, lenscale)))
- for i in range(4):
- eta = 1 + i*0.5 + .05
- transp_matl = manta_new(Dielectric(eta, 1, glass))
-# transp_matl = manta_new(Lambertian(Color(RGBColor(0.3,0.1,0.1))))
- corner = Vector(i*1.3 - 4, -3, 2.5+1.e-4);
- size = Vector(0.20, 2.5, 1.4);
- objs.add(manta_new(Cube(transp_matl, corner, corner+size)))
- #
- # Line of rings
- ringmatl = manta_new(Lambertian(Color(RGBColor(.6, .6, .9))))
- r = .30
- inner_radius = r*0.5
- center = Vector(-6, 0, 2.5+r)
- offset = Vector(2.25*r, 0, 0);
- for i in range(9):
- objs.add(manta_new(Ring(ringmatl,
- center+offset*i,
- Vector(0.2, -1, -0.2),
- inner_radius, r-inner_radius)))
- #
- # Create a BVH
- world.add(manta_new(RealisticBvh(objs.get_objs(), objs.size())))
- scene.setObject(world)
- #
- lights = manta_new(LightSet())
- lights.add(manta_new(PointLight(Vector(20, 30, 100),
Color(RGBColor(.9,.9,.9)))))
- lights.add(manta_new(PointLight(Vector(-40, -30, 50),
Color(RGBColor(.3,.1,.1)))))
- lights.setAmbientLight(manta_new(ConstantAmbient(Color(RGBColor(.4, .4,
.4)))))
- print lights
- #
- scene.setLights(lights)
- scene.getRenderParameters().maxDepth = 25
- scene.getRenderParameters().importanceCutoff = 0.01
- #
- return scene
-
-
-def setupDefaultEngine(numworkers):
- engine = createManta()
- engine.changeNumWorkers(numworkers)
- engine.selectImageType("rgba8")
- engine.selectLoadBalancer("workqueue")
- engine.selectImageTraverser("tiled")
- engine.selectPixelSampler("singlesample")
- #engine.selectPixelSampler("jittersample(-numberOfSamples 4)")
- engine.selectRenderer("raytracer")
- engine.selectShadowAlgorithm("hard")
- #
- return engine
-
-def addXInterface(engine, camera, xres, yres):
- xinterface = engine.createUserInterface("X")
- xinterface.startup()
- args = vectorStr()
- ogl_display = manta_new(OpenGLDisplay(args))
- sync_display = manta_new(SyncDisplay(args))
- sync_display.setChild(ogl_display)
- sync_automator = manta_new(SyncFrameAutomator(engine, sync_display))
- sync_automator.startup()
- engine.createChannel(sync_display, camera, False, xres, yres)
-# engine.createChannel("opengl", camera, False, xres, yres)
-
-def addNullInterface(engine, camera, xres, yres):
- ui = engine.createUserInterface("null")
- ui.startup()
- engine.createChannel("null", camera, False, xres, yres)
-
-
-engine = setupDefaultEngine(2)
-
-defaultCamera = engine.createCamera("pinhole(-eye 3 3 2 -lookat 0 0 0.3 -up
0 0 1 -fov 60)")
-#defaultCamera = engine.createCamera("pinhole(-eye 8 -18 8.5 -lookat -4.7
2.5 2.5 -up 0 0 1 -fov 15)")
-
-addXInterface(engine, defaultCamera, 512, 512)
-#addNullInterface(engine, defaultCamera, 512, 512)
-
-# scene = createDefaultScene()
-scene = createDefaultScenePython()
-# scene = createDielectricTestScene()
-engine.setScene(scene)
-
-
-# if __name__ == "__main__":
-# engine.beginRendering(True)
-# else:
-# engine.beginRendering(False)
-
-# For running as a script
-engine.beginRendering(True)
-# For running within python
-#engine.beginRendering(False)
+import wxManta
+import getopt, sys
+
+def usage():
+ print "Usage: python test.py [options]"
+ print "Where options contains one or more of:"
+ print "-n --np=<threads>"
+
+def main():
+
+ # Default options.
+ num_workers = 1
+
+ # Parse command line options. Note these have to conform to getopt
+ # So -np would be parsed as -n <space> p. Use --np=<threads> instead.
+ try:
+ opts, args = getopt.getopt(sys.argv[1:], "n:", ["np="] )
+
+ except getopt.GetoptError:
+ usage()
+ sys.exit(2)
+
+ for o, a in opts:
+ if o in ("-n", "--np"):
+ try:
+ num_workers = int(a)
+ except ValueError:
+ usage()
+ sys.exit(2)
+
+ # Add additional command line args here.
+
+
+
###########################################################################
+ # Create the application.
+ app = wxManta.MantaApp( wxManta.createDefaultScenePython,
+ num_workers )
+
+
+
###########################################################################
+ # Perform any additional setup
+
+ # Start rendering.
+ app.MainLoop()
+
+if __name__ == "__main__":
+ main()
+
+
+
+
Modified: trunk/SwigInterface/wxManta.py
==============================================================================
--- trunk/SwigInterface/wxManta.py (original)
+++ trunk/SwigInterface/wxManta.py Mon Aug 7 21:32:05 2006
@@ -14,8 +14,6 @@
import FloatSpin as FS
-# Number of workers.
-numworkers = 1
# Determine frame resolution.
xres = 512
@@ -33,10 +31,12 @@
Color(RGBColor(0,0,0)),
Vector(1,0,0),
Vector(0,1,0)))
+
constant_color1 = manta_new(Constant_Color(Color(RGBColor(.6,.6,.6))))
checker2 = manta_new(CheckerTexture_ColorComponent(0.2, 0.5,
Vector(1,0,0),
Vector(0,1,0)))
- plane_matl = manta_new(Phong(checker1, constant_color1, 32, checker2))
+ # plane_matl = manta_new(Phong(checker1, constant_color1, 32, checker2))
+ plane_matl = manta_new(Lambertian(checker1))
#
world = manta_new(Group())
floor = manta_new(Parallelogram(plane_matl, Vector(-20,-20,0),
@@ -138,7 +138,11 @@
self.updateFramerate(framerate)
self.prev_time = current_time
-
+###############################################################################
+###############################################################################
+# LIGHT FRAME LIGHT FRAME LIGHT FRAME LIGHT FRAME
+###############################################################################
+###############################################################################
class LightFrame(wx.Frame):
def __init__(self, parent, engine):
wx.Frame.__init__(self, parent=parent, title="Lights")
@@ -258,9 +262,19 @@
self.engine.addTransaction("Light Color",
manta_new(createMantaTransaction(colorButton.light.setColor, cbArgs)))
+###############################################################################
+###############################################################################
+# MANTA FRAME MANTA FRAME MANTA FRAME MANTA FRAME
+###############################################################################
+###############################################################################
class MantaFrame(wx.Frame):
- def __init__(self, parent=None, title="Manta",
- renderSize=wx.Size(xres,yres)):
+ def __init__(self,
+ make_scene,
+ num_workers,
+ renderSize,
+ parent=None,
+ title="Manta"
+ ):
wx.Frame.__init__(self, parent=parent, title=title)
# Setup events
@@ -300,7 +314,7 @@
# Basic settings.
self.engine = createManta()
- self.engine.changeNumWorkers (numworkers)
+ self.engine.changeNumWorkers (num_workers)
self.engine.selectImageType ("rgba8")
self.engine.selectLoadBalancer ("workqueue")
self.engine.selectImageTraverser ("tiled")
@@ -345,7 +359,7 @@
use_stereo, xres, yres )
# Basic scene.
- self.engine.setScene( createDefaultScenePython() )
+ self.engine.setScene( make_scene() )
self.engine.beginRendering(False)
#######################################################################
@@ -462,6 +476,9 @@
## OnRightDown
###########################################################################
def OnRightDown( self, event ):
+
+
+
event.Skip()
###########################################################################
@@ -523,17 +540,18 @@
class MantaApp(wx.App) :
- def __init__(self, redirect=False, filename=None):
+ def __init__(self,
+ make_scene_ = createDefaultScenePython,
+ num_workers = 1,
+ renderSize = wx.Size(xres,yres),
+ redirect=False,
+ filename=None):
wx.App.__init__(self, redirect, filename)
-
###########################################################################
- ## OnInit
-
###########################################################################
- def OnInit(self) :
- frame = MantaFrame()
- frame.Show()
- return True
+ # Create a manta frame with the given make_scene function.
+ self.frame = MantaFrame( make_scene_, num_workers, renderSize )
+ self.frame.Show()
+
+
-app = MantaApp()
-app.MainLoop()
- [MANTA] r1159 - trunk/SwigInterface, abe, 08/07/2006
Archive powered by MHonArc 2.6.16.