Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r947 - in trunk: SwigInterface scenes


Chronological Thread 
  • From: bigler@sci.utah.edu
  • To: manta@sci.utah.edu
  • Subject: [MANTA] r947 - in trunk: SwigInterface scenes
  • Date: Tue, 21 Feb 2006 15:51:20 -0700 (MST)

Author: bigler
Date: Tue Feb 21 15:51:19 2006
New Revision: 947

Added:
   trunk/SwigInterface/python.cc
      - copied, changed from r946, trunk/scenes/python.cc
Removed:
   trunk/scenes/python-stub.cc
   trunk/scenes/python.cc
Modified:
   trunk/SwigInterface/CMakeLists.txt
   trunk/SwigInterface/manta.i
   trunk/SwigInterface/runmanta.py
   trunk/scenes/CMakeLists.txt
Log:

SwigInterface/CMakeLists.txt

  Compile scene_python moved from scenes/.

SwigInterface/manta.i

  Added NormalTexture and Flat includes

  Added WireframeTexture templates.

SwigInterface/python.cc

  Functional sample scene.

  Print out if the interpreter is initialized.

SwigInterface/runmanta.py

  Point -> Vector.

  Displays default scene instead of dielectric one.

scenes/CMakeLists.txt
scenes/python-stub.cc
scenes/python.cc

  scene_python moved to SwigInterface/.


Modified: trunk/SwigInterface/CMakeLists.txt
==============================================================================
--- trunk/SwigInterface/CMakeLists.txt  (original)
+++ trunk/SwigInterface/CMakeLists.txt  Tue Feb 21 15:51:19 2006
@@ -24,14 +24,35 @@
 
 SWIG_LINK_LIBRARIES(manta
   ${PYTHON_LIBRARIES}
-  Manta_Engine 
-  Manta_UserInterface 
-  Manta_Model 
-  Manta_Image 
-  Manta_Interface 
-  Manta_Core 
+  Manta_Engine
+  Manta_UserInterface
+  Manta_Model
+  Manta_Image
+  Manta_Interface
+  Manta_Core
   SCIRun_Core
   ${CMAKE_THREAD_LIBS_INIT}
-  ${OPENGL_LIBRARIES} 
-  ${X11_LIBRARIES} 
+  ${OPENGL_LIBRARIES}
+  ${X11_LIBRARIES}
+  util
   -lm)
+
+############################################################
+# 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 Tue Feb 21 15:51:19 2006
@@ -243,25 +243,31 @@
 #include <Model/Textures/Constant.h>
 #include <Model/Textures/CheckerTexture.h>
 #include <Model/Textures/ImageTexture.h>
+#include <Model/Textures/NormalTexture.h>
+#include <Model/Groups/KDTree.h>
 %}
 
 %include <Interface/Texture.h>
 %include <Model/Textures/Constant.h>
 %include <Model/Textures/CheckerTexture.h>
 %include <Model/Textures/ImageTexture.h>
+%include <Model/Textures/NormalTexture.h>
 
 namespace Manta {
   // Textures.  If you add a new texture like FunkyTexture<MagicType>,
   // you also need to add a template for Texture<MagicType> to reduce
   // warnings.
   %template(Texture_Color) Texture<Color>;
-  %template(CheckerTexture_Color) CheckerTexture<Color>;
   %template(Texture_Real) Texture<Manta::Real>;
-  %template(CheckerTexture_Real) CheckerTexture<Manta::Real>;
   %template(Texture_ColorComponent) Texture<Manta::ColorComponent>;
+
+  %template(CheckerTexture_Color) CheckerTexture<Color>;
+  %template(CheckerTexture_Real) CheckerTexture<Manta::Real>;
   %template(CheckerTexture_ColorComponent) 
CheckerTexture<Manta::ColorComponent>;
   %template(Constant_Color) Constant<Color>;
   %template(ImageTexture_Color) ImageTexture<Manta::Color>;
+  %template(WireframeTexture_Color) 
WireframeTexture<Manta::Kdtree::KDTree::ScratchPadInfo,Color>;
+  %template(WireframeTexture_ColorComponent) 
WireframeTexture<Manta::Kdtree::KDTree::ScratchPadInfo,Manta::ColorComponent>;
 }
 
 /////////////////////////////////////////////////////
@@ -273,6 +279,7 @@
 #include <Model/Materials/Lambertian.h>
 #include <Model/Materials/MetalMaterial.h>
 #include <Model/Materials/Dielectric.h>
+#include <Model/Materials/Flat.h>
 #include <Model/Groups/Group.h>
 #include <Model/Primitives/PrimitiveCommon.h>
 #include <Interface/TexCoordMapper.h>
@@ -291,6 +298,7 @@
 %include <Model/Materials/Lambertian.h>
 %include <Model/Materials/MetalMaterial.h>
 %include <Model/Materials/Dielectric.h>
+%include <Model/Materials/Flat.h>
 %include <Model/Groups/Group.h>
 %include <Model/Primitives/PrimitiveCommon.h>
 %include <Interface/TexCoordMapper.h>

Copied: trunk/SwigInterface/python.cc (from r946, trunk/scenes/python.cc)
==============================================================================
--- trunk/scenes/python.cc      (original)
+++ trunk/SwigInterface/python.cc       Tue Feb 21 15:51:19 2006
@@ -35,6 +35,7 @@
 #include <Core/Util/Args.h>
 
 #include <string>
+#include <iostream>
 
 using namespace SCIRun;
 using namespace Manta;
@@ -42,25 +43,35 @@
 #include <Python.h>
 
 /*
-  # Example python scene file.
-  from manta import *
 
-  def make_scene(prefix):
-    print "In python function make_scene: " + prefix + "\n";
+# Example python scene file.
+from manta import *
 
-    # Create a material.
-    material = manta_new( Flat( NormalTexture() ) );
+def make_scene(prefix):
+    print "In python function make_scene: " + prefix + "\n";
 
     # Create the scene.
     scene = manta_new( Scene() );
+    
scene.setBackground(manta_new(ConstantBackground(ColorDB.getNamedColor("SkyBlue3").scaled(0.5))))
+
+    # Create a material.
+    material = manta_new( Flat( manta_new( NormalTexture() ) ) );
 
     # Add the sphere.
-    scene.setObject( manta_new( Sphere( material,
+    world = manta_new(Group())
+    world.add(manta_new( Sphere( material,
                                         Vector( 0, 0, 0 ),
-                                        1.0 ) ) );
-    # Add empty light set.
-    scene.setLights( manta_new( LightSet() ) );
-    
+                                        1.0 ) ) )
+    scene.setObject( world )
+
+    # Add light set.
+    lights = manta_new( LightSet() )
+    lights.add(manta_new(PointLight(Vector(20, 30, 100), 
Color(RGBColor(.9,.9,.9)))))
+    lights.setAmbientLight(manta_new(ConstantAmbient(Color.black())))
+    scene.setLights( lights );
+
+    scene.getRenderParameters().maxDepth = 5
+
     return scene;
 
  */
@@ -106,6 +117,11 @@
   PyObject *pArgs, *pValue;
 
   Py_Initialize();
+  if (Py_IsInitialized()) {
+    std::cerr << "python is initialize\n";
+  } else {
+    std::cerr << "python is not initialize\n";
+  }
   pName = PyString_FromString( file_name.c_str() );
   /* Error checking of pName left out */
 

Modified: trunk/SwigInterface/runmanta.py
==============================================================================
--- trunk/SwigInterface/runmanta.py     (original)
+++ trunk/SwigInterface/runmanta.py     Tue Feb 21 15:51:19 2006
@@ -16,18 +16,18 @@
     plane_matl = manta_new(Phong(checker1, constant_color1, 32, checker2))
 
     world = manta_new(Group())
-    floor = manta_new(Parallelogram(plane_matl, Point(-20,-20,0),
+    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, Point(0,0,1.2), 1.0)))
+    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(Point(0,5,8), 
Color(RGBColor(.6,.1,.1)))))
-    lights.add(manta_new(PointLight(Point(5,0,8), 
Color(RGBColor(.1,.6,.1)))))
-    lights.add(manta_new(PointLight(Point(5,5,2), 
Color(RGBColor(.2,.2,.2)))))
+    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
 
@@ -46,11 +46,11 @@
     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), Point(0,0,2.5))))
+    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, Point(-6, 3.5, 3.5), 1.0)))
+    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)))
@@ -58,7 +58,7 @@
         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 = Point(i*1.3 - 4, -3, 2.5+1.e-4);
+        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)))
 
@@ -66,7 +66,7 @@
     ringmatl = manta_new(Lambertian(Color(RGBColor(.6, .6, .9))))
     r = .30
     inner_radius = r*0.5
-    center = Point(-6, 0, 2.5+r)
+    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,
@@ -79,8 +79,8 @@
     scene.setObject(world)
 
     lights = manta_new(LightSet())
-    lights.add(manta_new(PointLight(Point(20, 30, 100), 
Color(RGBColor(.9,.9,.9)))))
-    lights.add(manta_new(PointLight(Point(-40, -30, 50), 
Color(RGBColor(.3,.1,.1)))))
+    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
 
@@ -100,8 +100,8 @@
 #engine.selectPixelSampler("jittersample(-numberOfSamples 4)")
 engine.selectRenderer("raytracer")
 engine.selectShadowAlgorithm("hard")
-#currentCamera = engine.createCamera("pinhole(-eye 3 3 2 -lookat 0 0 0.3 -up 
0 0 1 -fov 60)")
-currentCamera = engine.createCamera("pinhole(-eye 8 -18 8.5 -lookat -4.7 2.5 
2.5 -up 0 0 1 -fov 15)")
+currentCamera = engine.createCamera("pinhole(-eye 3 3 2 -lookat 0 0 0.3 -up 
0 0 1 -fov 60)")
+#currentCamera = engine.createCamera("pinhole(-eye 8 -18 8.5 -lookat -4.7 
2.5 2.5 -up 0 0 1 -fov 15)")
 xres = 512
 yres = 512
 xinterface = engine.createUserInterface("X")
@@ -110,8 +110,8 @@
 
 
 #engine.setScene(createDefaultScene())
-#engine.setScene(createDefaultScenePython())
-engine.setScene(createDielectricTestScene())
+engine.setScene(createDefaultScenePython())
+#engine.setScene(createDielectricTestScene())
 
 
 # if __name__ == "__main__":

Modified: trunk/scenes/CMakeLists.txt
==============================================================================
--- trunk/scenes/CMakeLists.txt (original)
+++ trunk/scenes/CMakeLists.txt Tue Feb 21 15:51:19 2006
@@ -72,24 +72,3 @@
    TARGET_LINK_LIBRARIES(scene_objviewer ${MANTA_SCENE_LINK})
 ENDIF(SCENE_OBJVIEWER)
 
-############################################################
-# 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.
-  IF(SWIG_FOUND)
-    SET (SCENE_PYTHON_SOURCES ${CORE_SOURCES}
-      python.cc)
-    INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
-
-    # Add the scene.
-    ADD_LIBRARY(scene_python python.cc)
-    TARGET_LINK_LIBRARIES(scene_python ${MANTA_SCENE_LINK})
-    TARGET_LINK_LIBRARIES(scene_python ${PYTHON_LIBRARY} util )
-
-  # Otherwise add a stub
-  ELSE (SWIG_FOUND)
-    SET (SCENE_PYTHON_SOURCES ${CORE_SOURCES}
-      python-stub.cc)
-  ENDIF(SWIG_FOUND)
-ENDIF(SCENE_PYTHON)




  • [MANTA] r947 - in trunk: SwigInterface scenes, bigler, 02/21/2006

Archive powered by MHonArc 2.6.16.

Top of page