Text archives Help
- From: bigler@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r370 - in swig: Core/Color Core/Geometry Interface Model/AmbientLights SwigInterface
- Date: Tue, 7 Jun 2005 21:28:15 -0600 (MDT)
Author: bigler
Date: Tue Jun 7 21:28:13 2005
New Revision: 370
Modified:
swig/Core/Color/ColorSpace.h
swig/Core/Geometry/PointVector.h
swig/Core/Geometry/Ray.h
swig/Interface/AmbientLight.h
swig/Interface/LightSet.cc
swig/Interface/LightSet.h
swig/Interface/RayPacket.h
swig/Interface/TValue.h
swig/Model/AmbientLights/ArcAmbient.cc
swig/Model/AmbientLights/ArcAmbient.h
swig/Model/AmbientLights/ConstantAmbient.cc
swig/Model/AmbientLights/ConstantAmbient.h
swig/SwigInterface/manta-run.py
swig/SwigInterface/manta.i
Log:
You can now generate the default scene in Python.
Core/Geometry/Ray.h
Core/Color/ColorSpace.h
Interface/TValue.h
Don't include operator= for SWIG. There isn't any support for
this operator.
Core/Geometry/PointVector.h
Don't compile the 2 parameter constructures for SWIG. It was
trying to instantiate both for 3 dimensional PointT's and
VectorT's. Don't include operator= for SWIG. Added the
__getitem__ function interface for Python.
SwigInterface/manta.i
Added a bunch of code, so that the default scene can be
generated in Python. Removed explicit defitions for
RTRTInterface. Just include the file now.
SwigInterface/manta-run.py
Import manta code into the global namespace. Generate the
scene geometry in Python. beginRendering uses True, so use
this file as a script.
Interface/AmbientLight.h
Interface/LightSet.cc
Interface/LightSet.h
Model/AmbientLights/ConstantAmbient.h
Model/AmbientLights/ArcAmbient.cc
Model/AmbientLights/ArcAmbient.h
Model/AmbientLights/ConstantAmbient.cc
Added printme function for debugging and inspection.
Interface/RayPacket.h
Can't use nested classes in SWIG. Therefore, Element
definition and functions that take Element as a parameter or
return an Element must be commented out for SWIG.
Modified: swig/Core/Color/ColorSpace.h
==============================================================================
--- swig/Core/Color/ColorSpace.h (original)
+++ swig/Core/Color/ColorSpace.h Tue Jun 7 21:28:13 2005
@@ -22,11 +22,13 @@
for(int i=0;i<3;i++)
data[i]=copy.data[i];
}
+#ifndef SWIG
ColorSpace& operator=(const ColorSpace<Traits> ©) {
for(int i=0;i<NumComponents;i++)
data[i] = copy.data[i];
return *this;
}
+#endif
~ColorSpace() {
}
Modified: swig/Core/Geometry/PointVector.h
==============================================================================
--- swig/Core/Geometry/PointVector.h (original)
+++ swig/Core/Geometry/PointVector.h Tue Jun 7 21:28:13 2005
@@ -15,10 +15,12 @@
public:
VectorT() {
}
+#ifndef SWIG
VectorT(T x, T y) {
typedef char unnamed[ Dim == 2 ? 1 : 0 ];
data[0] = x; data[1] = y;
}
+#endif
VectorT(T x, T y, T z) {
typedef char unnamed[ Dim == 3 ? 1 : 0 ];
data[0] = x; data[1] = y; data[2] = z;
@@ -34,11 +36,13 @@
data[i] = copy[i];
}
+#ifndef SWIG
VectorT<T, Dim>& operator=(const VectorT<T, Dim>& copy) {
for(int i=0;i<Dim;i++)
data[i] = copy.data[i];
return *this;
}
+#endif
~VectorT() {
}
@@ -54,12 +58,20 @@
typedef char unnamed[ Dim >= 3 ? 1 : 0 ];
return data[2];
}
+#ifndef SWIG
const T &operator[](int i) const {
return data[i];
}
T &operator[] ( int i ) {
return data[i];
}
+#else
+ %extend {
+ T& __getitem__( int i ) {
+ return self->operator[](i);
+ }
+ }
+#endif
VectorT<T, Dim> operator+(const VectorT<T, Dim>& v) const {
VectorT<T, Dim> result;
for(int i=0;i<Dim;i++)
@@ -221,10 +233,12 @@
PointT() {
}
+#ifndef SWIG
PointT(T x, T y) {
typedef char unnamed[ Dim == 2 ? 1 : 0 ];
data[0] = x; data[1] = y;
}
+#endif
PointT(T x, T y, T z) {
typedef char unnamed[ Dim == 3 ? 1 : 0 ];
data[0] = x; data[1] = y; data[2] = z;
@@ -239,12 +253,14 @@
for (int i=0;i<Dim;++i)
data[i] = copy[i];
}
-
+
+#ifndef SWIG
PointT<T, Dim>& operator=(const PointT<T, Dim>& copy) {
for(int i=0;i<Dim;i++)
data[i] = copy.data[i];
return *this;
}
+#endif
~PointT() {
}
@@ -259,12 +275,20 @@
typedef char unnamed[ Dim == 3 ? 1 : 0 ];
return data[2];
}
+#ifndef SWIG
T operator[](int i) const {
return data[i];
}
T &operator[](int i) {
return data[i];
}
+#else
+ %extend {
+ T& __getitem__( int i ) {
+ return self->operator[](i);
+ }
+ }
+#endif
VectorT<T, Dim> operator-(const PointT<T, Dim>& p) const {
VectorT<T, Dim> result;
Modified: swig/Core/Geometry/Ray.h
==============================================================================
--- swig/Core/Geometry/Ray.h (original)
+++ swig/Core/Geometry/Ray.h Tue Jun 7 21:28:13 2005
@@ -15,12 +15,14 @@
{
}
+#ifndef SWIG
Ray& operator=(const Ray& copy)
{
orig=copy.orig;
dir=copy.dir;
return *this;
}
+#endif
void set(const Point& origin, const Vector& direction)
{
Modified: swig/Interface/AmbientLight.h
==============================================================================
--- swig/Interface/AmbientLight.h (original)
+++ swig/Interface/AmbientLight.h Tue Jun 7 21:28:13 2005
@@ -14,6 +14,7 @@
virtual void preprocess(const PreprocessContext& context) = 0;
virtual void computeAmbient(const RenderContext& context, RayPacket&
rays) const = 0;
+ virtual void printme() const = 0;
private:
AmbientLight(const AmbientLight&);
AmbientLight& operator=(const AmbientLight&);
Modified: swig/Interface/LightSet.cc
==============================================================================
--- swig/Interface/LightSet.cc (original)
+++ swig/Interface/LightSet.cc Tue Jun 7 21:28:13 2005
@@ -3,7 +3,13 @@
#include <Interface/AmbientLight.h>
#include <Interface/Light.h>
#include <Core/Util/Assert.h>
+
+#include <sgi_stl_warnings_off.h>
+#include <iostream>
+#include <sgi_stl_warnings_on.h>
+
using namespace Manta;
+using namespace std;
LightSet* LightSet::merge(LightSet* l1, LightSet* l2)
{
@@ -24,8 +30,15 @@
{
// This won't work in many of the shadow algorithms
ASSERT(static_cast<int>(lights.size()) <= RayPacket::MaxSize);
- if(ambientLight)
- ambientLight->preprocess(context);
+ cerr << "LightSet::preprocess\n";
+ printme();
+ if(ambientLight){
+ AmbientLight* test = dynamic_cast<AmbientLight*>(ambientLight);
+ if (test)
+ ambientLight->preprocess(context);
+ else
+ cerr << "ambientLight is not an AmbientLight\n";
+ }
for(int i=0;i<static_cast<int>(lights.size());i++){
lights[i]->preprocess(context);
centers[i] = lights[i]->getCenter();
@@ -33,3 +46,12 @@
}
}
+void LightSet::printme() {
+ cerr << "ambientLight = "<<ambientLight<<"\n";
+ if (ambientLight) ambientLight->printme();
+ cerr << "Num lights = "<<lights.size()<<"\n";
+ for(int i = 0; i < static_cast<int>(lights.size()); i++) {
+ cerr << "lights["<<i<<"] = "<<lights[i]<<"\n";
+ // if (lights[i]) lights[i]->printme();
+ }
+}
Modified: swig/Interface/LightSet.h
==============================================================================
--- swig/Interface/LightSet.h (original)
+++ swig/Interface/LightSet.h Tue Jun 7 21:28:13 2005
@@ -53,6 +53,8 @@
void preprocess(const PreprocessContext&);
+ void printme();
+
Point centers[RayPacket::MaxSize];
Color colors[RayPacket::MaxSize];
private:
Modified: swig/Interface/RayPacket.h
==============================================================================
--- swig/Interface/RayPacket.h (original)
+++ swig/Interface/RayPacket.h Tue Jun 7 21:28:13 2005
@@ -63,6 +63,7 @@
size = newSize;
}
+#ifndef SWIG // SWIG doesn't support nested structs/classes.
struct Element {
Color localColor;
Color* color;
@@ -87,6 +88,8 @@
Element& get(int which) {
return data[which];
}
+#endif // SWIG
+
void setPixel(int which, int whichEye, double imageX, double imageY,
Color* color) {
data[which].color = color;
Modified: swig/Interface/TValue.h
==============================================================================
--- swig/Interface/TValue.h (original)
+++ swig/Interface/TValue.h Tue Jun 7 21:28:13 2005
@@ -15,11 +15,13 @@
{
}
+#ifndef SWIG
void operator=(const T& newvalue)
{
value = newvalue;
}
-
+#endif
+
operator T() const
{
return value;
Modified: swig/Model/AmbientLights/ArcAmbient.cc
==============================================================================
--- swig/Model/AmbientLights/ArcAmbient.cc (original)
+++ swig/Model/AmbientLights/ArcAmbient.cc Tue Jun 7 21:28:13 2005
@@ -1,7 +1,13 @@
#include <Model/AmbientLights/ArcAmbient.h>
#include <Interface/RayPacket.h>
+
+#include <sgi_stl_warnings_off.h>
+#include <iostream>
+#include <sgi_stl_warnings_on.h>
+
using namespace Manta;
+using namespace std;
ArcAmbient::ArcAmbient(const Color& cup, const Color& cdown,
const Vector& up)
@@ -35,4 +41,13 @@
}
rays.get(i).ambientLight = cup*w1 + cdown*w0;
}
+}
+
+void ArcAmbient::printme() const {
+ cerr << "-------- ArcAmbient ---------\n";
+// RGB cu(cup), cd(cdown);
+// cerr << "(cup, cdown) = ";
+// cerr << "("<<cu.r()<<", "<<cu.g()<<", "<<cu.b()<<"), ";
+// cerr << "("<<cd.r()<<", "<<cd.g()<<", "<<cd.b()<<")\n";
+ cerr << "up = "<<up<<"\n";
}
Modified: swig/Model/AmbientLights/ArcAmbient.h
==============================================================================
--- swig/Model/AmbientLights/ArcAmbient.h (original)
+++ swig/Model/AmbientLights/ArcAmbient.h Tue Jun 7 21:28:13 2005
@@ -16,6 +16,8 @@
virtual void preprocess(const PreprocessContext&);
virtual void computeAmbient(const RenderContext& context, RayPacket&
rays) const;
+
+ virtual void printme() const;
private:
Color cup;
Color cdown;
Modified: swig/Model/AmbientLights/ConstantAmbient.cc
==============================================================================
--- swig/Model/AmbientLights/ConstantAmbient.cc (original)
+++ swig/Model/AmbientLights/ConstantAmbient.cc Tue Jun 7 21:28:13 2005
@@ -2,7 +2,12 @@
#include <Model/AmbientLights/ConstantAmbient.h>
#include <Interface/RayPacket.h>
+#include <sgi_stl_warnings_off.h>
+#include <iostream>
+#include <sgi_stl_warnings_on.h>
+
using namespace Manta;
+using namespace std;
ConstantAmbient::ConstantAmbient(const Color& color)
: color(color)
@@ -24,3 +29,8 @@
rays.get(i).ambientLight = color;
}
+void ConstantAmbient::printme() const {
+ cerr << "-------- ConstantAmbient ---------\n";
+ // RGB c(color);
+ // cerr << "color = ("<<c.r()<<", "<<c.g()<<", "<<c.b()<<")\n";
+}
Modified: swig/Model/AmbientLights/ConstantAmbient.h
==============================================================================
--- swig/Model/AmbientLights/ConstantAmbient.h (original)
+++ swig/Model/AmbientLights/ConstantAmbient.h Tue Jun 7 21:28:13 2005
@@ -13,6 +13,8 @@
virtual void preprocess(const PreprocessContext&);
virtual void computeAmbient(const RenderContext& context, RayPacket&
rays) const;
+
+ virtual void printme() const;
private:
Color color;
};
Modified: swig/SwigInterface/manta-run.py
==============================================================================
--- swig/SwigInterface/manta-run.py (original)
+++ swig/SwigInterface/manta-run.py Tue Jun 7 21:28:13 2005
@@ -1,6 +1,6 @@
-import manta
+from manta import *
-engine = manta.createRTRT()
+engine = createRTRT()
engine.changeNumWorkers(1)
engine.selectImageType("rgba8")
engine.selectLoadBalancer("workqueue")
@@ -13,6 +13,57 @@
yres = 512
xinterface = engine.createUserInterface("X")
xinterface.startup()
-engine.createChannel("opengl", currentCamera, 0, xres, yres)
-engine.setScene(manta.createDefaultScene())
-engine.beginRendering(0)
+engine.createChannel("opengl", currentCamera, False, xres, yres)
+
+scene = Scene()
+bg = ConstantBackground(ColorDB.getNamedColor("SkyBlue3"))
+#bg = ConstantBackground(ColorDB.getNamedColor("green"))
+scene.setBackground(bg)
+red = Phong(Color(RGBColor(0.6, 0, 0)), Color(RGBColor(0.6,0.6,0.6)), 32,
0.4)
+checker1 = CheckerTexture_Color(Color(RGBColor(.6,.6,.6)),
+ Color(RGBColor(0,0,0)),
+ Vector(1,0,0),
+ Vector(0,1,0))
+constant_color1 = Constant_Color(Color(RGBColor(.6,.6,.6)))
+checker2 = CheckerTexture_Real(0.2, 0.5, Vector(1,0,0), Vector(0,1,0))
+plane_matl = Phong(checker1, constant_color1, 32, checker2)
+
+world = Group()
+floor = Parallelogram(plane_matl, Point(-20,-20,0),
+ Vector(40,0,0), Vector(0,40,0))
+uniformmap = UniformMapper()
+floor.setTexCoordMapper(uniformmap)
+world.add(floor)
+sphere = Sphere(red, Point(0,0,1.2), 1.0)
+world.add(sphere)
+scene.setObject(world)
+
+lights = LightSet()
+light1 = PointLight(Point(0,5,8), Color(RGBColor(.6,.1,.1)))
+light2 = PointLight(Point(5,0,8), Color(RGBColor(.1,.6,.1)))
+light3 = PointLight(Point(5,5,2), Color(RGBColor(.2,.2,.2)))
+lights.add(light1);
+lights.add(light2);
+lights.add(light3);
+ambientLight = ConstantAmbient(Color.black())
+ambientLight.thisown = 0
+lights.setAmbientLight(ambientLight)
+lights.printme()
+
+scene.setLights(lights);
+scene.getRenderParameters().maxDepth = 1;
+
+
+#engine.setScene(createDefaultScene())
+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)
Modified: swig/SwigInterface/manta.i
==============================================================================
--- swig/SwigInterface/manta.i (original)
+++ swig/SwigInterface/manta.i Tue Jun 7 21:28:13 2005
@@ -2,9 +2,24 @@
%module manta
%include "std_string.i"
%include "std_vector.i"
+
+%{
+#include <MantaTypes.h>
+#include <Core/Geometry/PointVector.h>
+%}
+
+%include <Core/Geometry/PointVector.h>
+
+namespace Manta {
+ %template(Point) PointT<Manta::Real, 3>;
+ %template(Vector) VectorT<Manta::Real, 3>;
+}
+
%{
#include <Interface/RTRTInterface.h>
#include <Interface/UserInterface.h>
+#include <Interface/RenderParameters.h>
+#include <Interface/Scene.h>
%}
namespace std {
@@ -17,54 +32,121 @@
%include <Interface/UserInterface.h>
+%include <Interface/RenderParameters.h>
+%include <Interface/Scene.h>
+
+%include <Interface/Callback.h>
+%include <Interface/CallbackHelpers.h>
+%include <Interface/Transaction.h>
+%include <Interface/TValue.h>
+
namespace Manta {
using namespace std;
class Camera;
- class Scene;
-
- class RTRTInterface {
- public:
- virtual int createChannel(const string& modespec, Camera* camera,
- bool stereo, int xres, int yres) = 0;
- virtual void changeResolution(int channel, int xres, int yres,
- bool changePipeline) = 0;
- virtual bool selectImageTraverser(const string& spec) = 0;
- virtual bool selectImageType(const string& spec) = 0;
- virtual bool selectLoadBalancer(const string& spec) = 0;
- virtual bool selectPixelSampler(const string& spec) = 0;
- virtual bool selectRenderer(const string& spec) = 0;
- virtual bool selectShadowAlgorithm(const string& spec) = 0;
- virtual bool addIdleMode(const string& spec) = 0;
- virtual Camera* createCamera(const string& spec) = 0;
- virtual UserInterface* createUserInterface(const string& spec) = 0;
-
- virtual listType listImageTraversers() const = 0;
- virtual listType listImageTypes() const = 0;
- virtual listType listLoadBalancers() const = 0;
- virtual listType listPixelSamplers() const = 0;
- virtual listType listRenderers() const = 0;
- virtual listType listShadowAlgorithms() const = 0;
- virtual listType listIdleModes() const = 0;
- virtual listType listCameras() const = 0;
- virtual listType listGroups() const = 0;
-
- // Scenes
- virtual bool haveScene() = 0;
- virtual void setScene(Scene* scene) = 0;
- virtual bool readScene(const string& sceneSpec) = 0;
- virtual void setScenePath(const string& path) = 0;
-
- // Workers
- virtual void changeNumWorkers(int new_num_procs) = 0;
-
- // Control
- virtual void beginRendering(bool blockUntilFinished) = 0;
- virtual void blockUntilFinished() = 0;
- virtual void finish() = 0;
- };
- RTRTInterface* createRTRT();
+ // %template(CallbackBase_2Data_int_int) CallbackBase_2Data<int, int>;
}
extern Manta::Scene* createDefaultScene();
+
+%include <Interface/RTRTInterface.h>
+
+/////////////////////////////////////////////////
+// Model stuff
+
+%{
+#include <MantaTypes.h>
+#include <Core/Color/RGBColor.h>
+#include <Core/Color/RGBTraits.h>
+#include <Core/Color/GrayColor.h>
+#include <Core/Color/Conversion.h>
+#include <Core/Color/ColorSpace.h>
+#include <Core/Color/ColorDB.h>
+%}
+
+%include <MantaTypes.h>
+%include <Core/Color/RGBColor.h>
+%include <Core/Color/RGBTraits.h>
+%include <Core/Color/GrayColor.h>
+%include <Core/Color/Conversion.h>
+%include <Core/Color/ColorSpace.h>
+%include <Core/Color/ColorDB.h>
+
+namespace Manta {
+ // typedef ColorSpace<RGBTraits> Color;
+ %template(Color) ColorSpace<RGBTraits>;
+}
+
+%{
+#include <Core/Geometry/Ray.h>
+#include <Interface/HitInfo.h>
+#include <Interface/RayPacket.h>
+#include <Interface/Context.h>
+#include <Interface/Object.h>
+#include <Interface/Primitive.h>
+#include <Interface/TexCoordMapper.h>
+#include <Interface/Light.h>
+#include <Interface/LightSet.h>
+%}
+
+%include <Core/Geometry/Ray.h>
+%include <Interface/HitInfo.h>
+%include <Interface/RayPacket.h>
+%include <Interface/Context.h>
+%include <Interface/Object.h>
+%include <Interface/Primitive.h>
+%include <Interface/TexCoordMapper.h>
+%include <Interface/Light.h>
+%include <Interface/LightSet.h>
+
+
+
+%{
+#include <Interface/AmbientLight.h>
+#include <Model/AmbientLights/ConstantAmbient.h>
+#include <Interface/Background.h>
+#include <Model/Backgrounds/ConstantBackground.h>
+#include <Model/Lights/PointLight.h>
+#include <Interface/Texture.h>
+#include <Model/Textures/Constant.h>
+#include <Model/Textures/CheckerTexture.h>
+#include <Interface/Material.h>
+#include <Model/Materials/LitMaterial.h>
+#include <Model/Materials/Phong.h>
+#include <Model/Groups/Group.h>
+#include <Model/Primitives/PrimitiveCommon.h>
+#include <Interface/TexCoordMapper.h>
+#include <Model/Primitives/Parallelogram.h>
+#include <Model/Primitives/Sphere.h>
+#include <Model/TexCoordMappers/UniformMapper.h>
+%}
+
+%include <Interface/AmbientLight.h>
+%include <Model/AmbientLights/ConstantAmbient.h>
+%include <Interface/Background.h>
+%include <Model/Backgrounds/ConstantBackground.h>
+%include <Model/Lights/PointLight.h>
+
+%include <Interface/Texture.h>
+%include <Model/Textures/Constant.h>
+%include <Model/Textures/CheckerTexture.h>
+%include <Interface/Material.h>
+%include <Model/Materials/LitMaterial.h>
+%include <Model/Materials/Phong.h>
+%include <Model/Groups/Group.h>
+%include <Model/Primitives/PrimitiveCommon.h>
+%include <Interface/TexCoordMapper.h>
+%include <Model/Primitives/Parallelogram.h>
+%include <Model/Primitives/Sphere.h>
+%include <Model/TexCoordMappers/UniformMapper.h>
+
+namespace Manta {
+ // Definition for CheckerTexture<Color>
+ %template(Texture_Color) Texture<Color>;
+ %template(CheckerTexture_Color) CheckerTexture<Color>;
+ %template(Texture_Real) Texture<Manta::Real>;
+ %template(CheckerTexture_Real) CheckerTexture<Manta::Real>;
+ %template(Constant_Color) Constant<Color>;
+}
+
- [MANTA] r370 - in swig: Core/Color Core/Geometry Interface Model/AmbientLights SwigInterface, bigler, 06/07/2005
Archive powered by MHonArc 2.6.16.