Text archives Help
- From: bigler@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r1346 - trunk/SwigInterface
- Date: Sun, 15 Apr 2007 21:26:06 -0600 (MDT)
Author: bigler
Date: Sun Apr 15 21:26:05 2007
New Revision: 1346
Modified:
trunk/SwigInterface/runmanta.py
Log:
Added addDebugRays function that reads in a file formatted with the
raytree stuff.
Added addFileInterface function.
Modified: trunk/SwigInterface/runmanta.py
==============================================================================
--- trunk/SwigInterface/runmanta.py (original)
+++ trunk/SwigInterface/runmanta.py Sun Apr 15 21:26:05 2007
@@ -2,6 +2,8 @@
global factory
+import string
+
def createDefaultScenePython():
scene = manta_new(Scene())
scene.setBackground(manta_new(ConstantBackground(ColorDB.getNamedColor("SkyBlue3").scaled(0.5))))
@@ -156,6 +158,44 @@
#
return scene
+def getVectorFromTokens(tokens, index):
+ return Vector(string.atof(tokens[index+1]),
+ string.atof(tokens[index+2]),
+ string.atof(tokens[index+3]))
+
+def addDebugRays(objs, infilename, radius, deadEndRayLength = 2):
+ materials = [manta_new(Lambertian(Color(RGBColor(1,0,0)))),
+ manta_new(Lambertian(Color(RGBColor(1,1,0)))),
+ manta_new(Lambertian(Color(RGBColor(0,1,0)))),
+ manta_new(Lambertian(Color(RGBColor(0,1,1)))),
+ manta_new(Lambertian(Color(RGBColor(0,0,1)))),
+ manta_new(Lambertian(Color(RGBColor(1,0,1))))]
+ infile = open(infilename, "rU")
+ # Now read the lines
+ lines = map( lambda x: string.strip(x, string.whitespace),
+ infile.readlines() )
+ infile.close()
+ # Loop over all the lines and pull out the relevant stuff
+ for l in lines[0:]:
+ tokens = l.split()
+ if ("raytree:" in tokens):
+ originIndex = tokens.index("origin")
+ origin = getVectorFromTokens(tokens, originIndex)
+ raydepth = string.atoi(tokens[tokens.index("depth")+1])
+ matl = materials[raydepth%len(materials)]
+ # Try and get the hitpos
+ if ("hitpos" in tokens):
+ print "Normal ray"
+ hitposIndex = tokens.index("hitpos")
+ hitpos = getVectorFromTokens(tokens, hitposIndex)
+ else:
+ print "Computing stub"
+ # Get the direction and compute a distance
+ directionIndex = tokens.index("direction")
+ direction = getVectorFromTokens(tokens, directionIndex)
+ hitpos = origin + (direction.normal() * deadEndRayLength)
+ objs.add(manta_new(Cylinder(matl, origin, hitpos, radius)))
+
def createTransparentShadowScene():
scene = manta_new(Scene())
scene.setBackground(manta_new(ConstantBackground(Color(RGBColor(0.5,
0.8, 0.9)))))
@@ -166,7 +206,7 @@
objs = Array1_ObjectP()
#
checker1 = manta_new(CheckerTexture_Color(Color(RGBColor(.6,.6,.6)),
- Color(RGBColor(0,0,0)),
+ Color(RGBColor(0.3,0.3,0.3)),
Vector(1,0,0),
Vector(0,1,0)))
groundmatl = manta_new(Lambertian(checker1))
@@ -176,15 +216,18 @@
#
lenscale = 2.5
glass = Color(RGBColor(pow(0.80, lenscale), pow(0.93, lenscale),
pow(0.87, lenscale)))
- transp_matl = manta_new(Dielectric(1, 1.01, glass))
+ transp_matl = manta_new(Dielectric(1.5, 1, glass))
print transp_matl
objs.add(manta_new(Cube(transp_matl,
Vector(-5, -2, 2.95 ),
- Vector(-1, 2, 3.05))))
+ Vector(-1, 2, 3.36))))
# objs.add(manta_new(Cube(manta_new(Dielectric(1.1, 1, glass)),
# Vector(-5, -2, 2.95 ),
# Vector(-1, 2, 3.05))))
+# objs.add(manta_new(Sphere(transp_matl,
+# Vector( -3, 0, 4.5), 0.5)))
+
ringmatl = manta_new(Lambertian(Color(RGBColor(.9, .3, .2))))
print ringmatl
r = .30
@@ -197,6 +240,7 @@
Vector(0, 0, 1),
inner_radius, r-inner_radius)))
+ #addDebugRays(objs, "raytree", 0.05)
# Create a BVH
world.add(manta_new(RealisticBvh(objs.get_objs(), objs.size())))
scene.setObject(world)
@@ -224,10 +268,12 @@
engine.changeNumWorkers(numworkers)
factory.selectImageType("rgba8")
factory.selectLoadBalancer("workqueue")
- factory.selectImageTraverser("tiled")
+ factory.selectImageTraverser("tiled(-square -tilesize 30x5)")
+# factory.selectImageTraverser("tiled")
factory.selectPixelSampler("singlesample")
#factory.selectPixelSampler("jittersample(-numberOfSamples 4)")
factory.selectRenderer("raytracer")
+ #factory.selectShadowAlgorithm("noshadows")
factory.selectShadowAlgorithm("hard(-attenuate)")
#factory.selectShadowAlgorithm("hard")
#
@@ -251,15 +297,22 @@
ui.startup()
engine.createChannel("null", camera, False, xres, yres)
+def addFileInterface(engine, camera, xres, yres):
+ ui = factory.createUserInterface("null")
+ ui.startup()
+ display = factory.createImageDisplay("file(-type tga -prefix runmanta)")
+ engine.createChannel(display, camera, False, xres, yres)
engine = setupDefaultEngine(1)
#defaultCamera = factory.createCamera("pinhole(-eye 3 3 2 -lookat 0 0 0.3
-up 0 0 1 -fov 60)")
#defaultCamera = factory.createCamera("pinhole(-eye 8 -18 8.5 -lookat -4.7
2.5 2.5 -up 0 0 1 -fov 15)")
defaultCamera = factory.createCamera("pinhole(-eye 8.3 -18 7 -lookat -4.7
2.5 3 -up 0 0 1 -fov 15)")
+#defaultCamera = factory.createCamera("pinhole( -eye 8.06072 -17.7429
8.73358 -lookat -4.98977 2.23422 2.74486 -up -0.0793095 0.0464671 0.995767
-fov 15 )")
addXInterface(engine, defaultCamera, 512, 512)
#addNullInterface(engine, defaultCamera, 512, 512)
+#addFileInterface(engine, defaultCamera, 512, 512)
# scene = createDefaultScene()
#scene = createDefaultScenePython()
- [MANTA] r1346 - trunk/SwigInterface, bigler, 04/15/2007
Archive powered by MHonArc 2.6.16.