Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r1160 - trunk/SwigInterface


Chronological Thread 
  • From: abe@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r1160 - trunk/SwigInterface
  • Date: Mon, 7 Aug 2006 22:01:11 -0600 (MDT)

Author: abe
Date: Mon Aug  7 22:01:09 2006
New Revision: 1160

Added:
   trunk/SwigInterface/runwxmanta.py
      - copied unchanged from r1159, trunk/SwigInterface/runmanta.py
Modified:
   trunk/SwigInterface/CMakeLists.txt
   trunk/SwigInterface/runmanta.py
Log:


Realized that runmanta.py actually did something and was documented in
the wiki, reverted back to previous revision of it and moved new code
to runwxmanta.py
A    SwigInterface/runwxmanta.py
M    SwigInterface/runmanta.py

Modified build to recopy .py files to lib/ directory whenever they
change. Note that this requires that 'make' be invoked.
M    SwigInterface/CMakeLists.txt


Modified: trunk/SwigInterface/CMakeLists.txt
==============================================================================
--- trunk/SwigInterface/CMakeLists.txt  (original)
+++ trunk/SwigInterface/CMakeLists.txt  Mon Aug  7 22:01:09 2006
@@ -50,18 +50,35 @@
 
    # Copy the python object to the lib directory.
    ADD_CUSTOM_COMMAND(
-      TARGET _manta
       POST_BUILD
+      OUTPUT       ${PROJECT_BINARY_DIR}/lib/${PY_FILE}
+      # DEPENDS must match the source file that will change.
+      DEPENDS      ${CMAKE_CURRENT_SOURCE_DIR}/${PY_FILE}
       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}"
-                )
+      )  
+
+   ADD_CUSTOM_TARGET(
+      copy_${PY_FILE}
+      ALL
+      # DEPENDS Must match custom command OUTPUT.
+      DEPENDS ${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)
+PYTHON_POST_BUILD_COPY(runwxmanta.py)
 
 
 

Modified: trunk/SwigInterface/runmanta.py
==============================================================================
--- trunk/SwigInterface/runmanta.py     (original)
+++ trunk/SwigInterface/runmanta.py     Mon Aug  7 22:01:09 2006
@@ -1,52 +1,146 @@
+from manta import *
 
-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()
-
-
-
-
+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)




  • [MANTA] r1160 - trunk/SwigInterface, abe, 08/07/2006

Archive powered by MHonArc 2.6.16.

Top of page