Author: brownlee
Date: Mon Feb 25 10:06:58 2008
New Revision: 2114
Added:
trunk/Model/Primitives/PrimaryRaysOnly.cc
trunk/Model/Primitives/PrimaryRaysOnly.h
Modified:
trunk/Interface/Light.h
trunk/Model/Lights/PointLight.cc
trunk/Model/Lights/PointLight.h
trunk/Model/Primitives/CMakeLists.txt
trunk/SwigInterface/wxManta.py
trunk/UserInterface/XWindowUI.cc
trunk/UserInterface/XWindowUI.h
trunk/scenes/csafe/python/SceneInfo.py
trunk/scenes/csafe/python/csafe_demo.py
Log:
added visible lights, right now just implemented for pointlights. press l to toggle
Modified: trunk/Interface/Light.h
= = = = = = = = ======================================================================
--- trunk/Interface/Light.h (original)
+++ trunk/Interface/Light.h Mon Feb 25 10:06:58 2008
@@ -33,6 +33,8 @@
RayPacket& sourceRays) const = 0;
void readwrite(Archive* archive);
+ //! create a visible representation of the light
+ virtual Object* createRenderable() { return NULL; }
private:
// Lights may not be copied.
Light( const Light & );
Modified: trunk/Model/Lights/PointLight.cc
= = = = = = = = ======================================================================
--- trunk/Model/Lights/PointLight.cc (original)
+++ trunk/Model/Lights/PointLight.cc Mon Feb 25 10:06:58 2008
@@ -4,7 +4,11 @@
#include <Core/Persistent/MantaRTTI.h>
#include <Interface/InterfaceRTTI.h>
#include <MantaSSE.h>
-
+#include <Model/Primitives/Sphere.h>
+#include <Model/Primitives/PrimaryRaysOnly.h>
+#include <Model/Materials/CopyTextureMaterial.h>
+#include <iostream>
+using namespace std;
using namespace Manta;
PointLight::PointLight()
@@ -81,3 +85,9 @@
archive->readwrite("position", position);
archive->readwrite("color", color);
}
+
+Object* PointLight::createRenderable()
+{
+ //TODO: radius preset for now, but could be set from bounds of scene or something... -Carson
+ return new PrimaryRaysOnly(new Sphere(new CopyTextureMaterial(color), position, 0.5f));
+}
\ No newline at end of file
Modified: trunk/Model/Lights/PointLight.h
= = = = = = = = ======================================================================
--- trunk/Model/Lights/PointLight.h (original)
+++ trunk/Model/Lights/PointLight.h Mon Feb 25 10:06:58 2008
@@ -28,6 +28,7 @@
void setColor(Color new_c) { color = new_c; }
void readwrite(ArchiveElement* archive);
+ virtual Object* createRenderable();
private:
Vector position;
Color color;
Modified: trunk/Model/Primitives/CMakeLists.txt
= = = = = = = = ======================================================================
--- trunk/Model/Primitives/CMakeLists.txt (original)
+++ trunk/Model/Primitives/CMakeLists.txt Mon Feb 25 10:06:58 2008
@@ -32,6 +32,8 @@
Primitives/Parallelogram.h
Primitives/Plane.cc
Primitives/Plane.h
+ Primitives/PrimaryRaysOnly.cc
+ Primitives/PrimaryRaysOnly.h
Primitives/PrimitiveCommon.cc
Primitives/PrimitiveCommon.h
Primitives/QuadFacedHexahedron.cc
Added: trunk/Model/Primitives/PrimaryRaysOnly.cc
= = = = = = = = ======================================================================
--- (empty file)
+++ trunk/Model/Primitives/PrimaryRaysOnly.cc Mon Feb 25 10:06:58 2008
@@ -0,0 +1,41 @@
+/*
+ For more information, please see: http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005
+ Scientific Computing and Imaging Institue, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+#include <Model/Primitives/PrimaryRaysOnly.h>
+#include <Interface/RayPacket.h>
+#include <iostream>
+
+using namespace std;
+using namespace Manta;
+
+void PrimaryRaysOnly::intersect(const RenderContext& context,
+ RayPacket& rays) const
+{
+ if (rays.getFlag(RayPacket::ConstantEye))
+ prim->intersect(context, rays);
+}
Added: trunk/Model/Primitives/PrimaryRaysOnly.h
= = = = = = = = ======================================================================
--- (empty file)
+++ trunk/Model/Primitives/PrimaryRaysOnly.h Mon Feb 25 10:06:58 2008
@@ -0,0 +1,87 @@
+/*
+ For more information, please see: http://software.sci.utah.edu
+
+ The MIT License
+
+ Copyright (c) 2005
+ Scientific Computing and Imaging Institue, University of Utah
+
+ License for the specific language governing rights and limitations under
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+ DEALINGS IN THE SOFTWARE.
+*/
+
+#ifndef Manta_Model_PrimaryRaysOnly_h
+#define Manta_Model_PrimaryRaysOnly_h
+
+#include <Interface/Primitive.h>
+
+namespace Manta
+{
+
+/*!
+\class PrimaryRaysOnly
+\author Carson
+\brief only intersects with eyerays
+*/
+class PrimaryRaysOnly : public Primitive
+{
+public:
+ //! constructor
+ /*!
+ \param primitive to use for all functions, intersection method only called with eye rays
+ */
+ PrimaryRaysOnly(Primitive* p) { prim = p; }
+
+ virtual void preprocess(const PreprocessContext& c) { prim- >preprocess(c); }
+ //! intersection method (uses primitive from constructor)
+ /*!
+ \post calls intersect method of primitive if rays are from eye
+ */
+ virtual void intersect(const RenderContext& context,
+ RayPacket& rays) const;
+
+ virtual void computeNormal(const RenderContext& context,
+ RayPacket& rays) const { prim- >computeNormal(context, rays); }
+ virtual void computeGeometricNormal(const RenderContext& context,
+ RayPacket& rays) const { prim->computeGeometricNormal(context, rays); }
+
+ // Compute dPdu and dPdv (aka tangent vectors) - these are not
+ // normalized. Cross(dPdu, dPdv) = k*N where k is some scale
+ // factor. By default, we'll just construct a coordinate frame
+ // around the Normal so that the invariant is satisfied.
+ virtual void computeSurfaceDerivatives(const RenderContext& context,
+ RayPacket& rays) const { prim->computeSurfaceDerivatives(context, rays); }
+
+ virtual void setTexCoordMapper(const TexCoordMapper* new_tex) { prim->setTexCoordMapper(new_tex); };
+
+ virtual void getRandomPoints(Packet<Vector>& points,
+ Packet<Vector>& normals,
+ Packet<Real>& pdfs,
+ const RenderContext& context,
+ RayPacket& rays) { prim- >getRandomPoints(points, normals,pdfs,context,rays); }
+
+ virtual void computeBounds(const Manta::PreprocessContext& c, Manta::BBox& b) const { prim->computeBounds(c,b); }
+
+protected:
+ Primitive* prim;
+};
+
+}
+
+#endif
\ No newline at end of file
Modified: trunk/SwigInterface/wxManta.py
= = = = = = = = ======================================================================
--- trunk/SwigInterface/wxManta.py (original)
+++ trunk/SwigInterface/wxManta.py Mon Feb 25 10:06:58 2008
@@ -230,7 +230,7 @@
self.clearScreen()
def FrameReady(self):
- self.SetCurrent()
+ # self.SetCurrent()
self.opengl_display.displayImage(self.sync_display.getCurrentImage())
self.sync_display.doneRendering()
self.SwapBuffers()
@@ -464,7 +464,7 @@
## StartEngine
###########################################################################
def StartEngine(self):
- self.Show()
+ # self.Show()
self.engine.beginRendering(False)
###########################################################################
Modified: trunk/UserInterface/XWindowUI.cc
= = = = = = = = ======================================================================
--- trunk/UserInterface/XWindowUI.cc (original)
+++ trunk/UserInterface/XWindowUI.cc Mon Feb 25 10:06:58 2008
@@ -10,7 +10,10 @@
#include <Interface/XWindow.h>
#include <Interface/Scene.h>
#include <Interface/Object.h>
+#include <Interface/Light.h>
+#include <Interface/LightSet.h>
#include <Interface/RayPacket.h>
+#include <Model/Groups/Group.h>
#include <Engine/PixelSamplers/TimeViewSampler.h>
#include <Core/Exceptions/ErrnoException.h>
#include <Core/Exceptions/InternalError.h>
@@ -28,7 +31,6 @@
#include <unistd.h>
#include <sys/select.h>
-#include <iostream>
#include <sstream>
#include <functional>
#include <algorithm>
@@ -46,7 +48,6 @@
#define TOKEN_SHUTDOWN 3
using namespace Manta;
-using namespace std;
UserInterface* XWindowUI::create(const vector<string>& args,
MantaInterface *rtrt_interface)
@@ -122,6 +123,10 @@
rotate_speed = 2;
autoview_fov = 60;
trackball_radius = 0.8;
+
+ lightsVisible = false;
+ waitingToDeleteLights = false;
+ originalObject = NULL;
register_default_keys();
register_default_mouse();
@@ -493,6 +498,9 @@
register_key(0, XStringToKeysym("K"),
"write knots",
Callback::create(this, &XWindowUI::write_knots));
+ register_key(0, XStringToKeysym("l"),
+ "display lights",
+ Callback::create(this, &XWindowUI::lights));
register_key(0, XStringToKeysym("p"),
"increase/decrease number of processors",
Callback::create(this, &XWindowUI::prockey));
@@ -649,6 +657,47 @@
return;
path->writeKnots();
+}
+
+void XWindowUI::lights_helper(int, int)
+{
+ for (vector<Object*>::iterator itr = lightsRenderables.begin(); itr != lightsRenderables.end(); itr++)
+ delete *itr;
+ lightsRenderables.clear();
+ waitingToDeleteLights = false;
+}
+
+void XWindowUI::lights(unsigned int, unsigned long, int)
+{
+ if (waitingToDeleteLights)
+ return;
+ if (lightsVisible)
+ {
+ lightsVisible = false;
+ rtrt_interface->getScene()->setObject(originalObject);
+ //TODO: I don't delete the object itself as it contains the original object... does its destructor destroy its children?
+ rtrt_interface- >addOneShotCallback( MantaInterface::Relative, 2, Callback::create(this, &XWindowUI::lights_helper));
+ waitingToDeleteLights = true;
+ }
+ else
+ {
+ lightsVisible = true;
+ Scene* scene = rtrt_interface->getScene();
+ Group* group = new Group();
+ originalObject = scene->getObject();
+ group->add(originalObject);
+ LightSet* lights = scene->getLights();
+ for(unsigned int i = 0; i < lights->numLights(); i++)
+ {
+ Object* renderable =
lights->getLight(i)->createRenderable();
+ if (renderable != NULL)
+ {
+ group->add(renderable);
+ lightsRenderables.push_back(renderable);
+ }
+ }
+ scene->setObject(group);
+ }
}
void XWindowUI::animate(unsigned int, unsigned long, int channel)
Modified: trunk/UserInterface/XWindowUI.h
= = = = = = = = ======================================================================
--- trunk/UserInterface/XWindowUI.h (original)
+++ trunk/UserInterface/XWindowUI.h Mon Feb 25 10:06:58 2008
@@ -9,6 +9,7 @@
#include <Core/Thread/Runnable.h>
#include <Core/Thread/Mutex.h>
#include <Core/Thread/Semaphore.h>
+#include <Interface/Object.h>
#include <X11/Xlib.h>
#include <vector>
@@ -81,6 +82,8 @@
void next_bookmark(unsigned int, unsigned long, int);
void add_bookmark(unsigned int, unsigned long, int);
void add_knot(unsigned int, unsigned long, int);
+ void lights_helper(int, int);
+ void lights(unsigned int, unsigned long, int);
void write_knots(unsigned int, unsigned long, int);
void animate(unsigned int, unsigned long, int);
void reset_path(unsigned int, unsigned long, int);
@@ -169,7 +172,13 @@
// The image size
int width, height;
-
+
+ //for visible lights
+ vector<Object*> lightsRenderables;
+ Object* originalObject;
+ bool lightsVisible;
+ bool waitingToDeleteLights;
+
XWindowUI(const XWindowUI&);
XWindowUI& operator=(const XWindowUI&);
Modified: trunk/scenes/csafe/python/SceneInfo.py
= = = = = = = = ======================================================================
--- trunk/scenes/csafe/python/SceneInfo.py (original)
+++ trunk/scenes/csafe/python/SceneInfo.py Mon Feb 25 10:06:58 2008
@@ -21,3 +21,4 @@
self.lockFrames = False
self.loop = True
self.repeatLastFrame = 0.0
+ self.mantaFrame = None
Modified: trunk/scenes/csafe/python/csafe_demo.py
= = = = = = = = ======================================================================
--- trunk/scenes/csafe/python/csafe_demo.py (original)
+++ trunk/scenes/csafe/python/csafe_demo.py Mon Feb 25 10:06:58 2008
@@ -64,44 +64,44 @@
self.scene = SceneInfo.Scene()
#self.SetForegroundColour(wx.Colour(255,0,0))
self.SetBackgroundColour(self.scene.bgColor)
- menuBar = wx.MenuBar()
- menuFile = wx.Menu()
- menuFile.Append(101, "&About", "")
- menuFile.Append(102, "&Save", "")
- menuFile.Append(103, "Save As...", "")
- menuFile.Append(104, "Load", "")
- menuFile.Append(107, "Import NrrdList")
- menuFile.Append(108, "Export NrrdList")
- menuFile.Append(106, "Import Transfer Function")
- menuFile.Append(105, "Export Transfer Function")
- menuFile.Append(109, "&Quit", "")
- menuBar.Append(menuFile, "File")
-
- menuScene = wx.Menu()
- menuScene.Append(201, "&Add/Remove Files", "Add and remove Nrrd files to the scene")
- menuScene.Append(204, "Add &Histogram", "Add a histogram to the panel")
- menuScene.Append(202, "Scene Preferences")
- menuScene.Append(203, "&Generate")
- menuBar.Append(menuScene, "Scene")
-
- menuHelp = wx.Menu()
- menuBar.Append(menuHelp, "Help")
- self.SetMenuBar(menuBar)
-
- self.Bind(wx.EVT_MENU, self.Menu101, id=101)
- self.Bind(wx.EVT_MENU, self.Menu102, id=102)
- self.Bind(wx.EVT_MENU, self.Menu103, id=103)
- self.Bind(wx.EVT_MENU, self.Menu104, id=104)
- self.Bind(wx.EVT_MENU, self.Menu105, id=105)
- self.Bind(wx.EVT_MENU, self.Menu106, id=106)
- self.Bind(wx.EVT_MENU, self.Menu201, id=201)
- self.Bind(wx.EVT_MENU, self.Menu202, id=202)
- self.Bind(wx.EVT_MENU, self.Menu107, id=107)
- self.Bind(wx.EVT_MENU, self.Menu108, id=108)
- self.Bind(wx.EVT_MENU, self.Menu109, id=109)
- self.Bind(wx.EVT_MENU, self.Menu203, id=203)
- self.Bind(wx.EVT_MENU, self.Menu204, id=204)
- self.SetBackgroundColour(self.scene.bgColor)
+# menuBar = wx.MenuBar()
+# menuFile = wx.Menu()
+# menuFile.Append(101, "&About", "")
+# menuFile.Append(102, "&Save", "")
+# menuFile.Append(103, "Save As...", "")
+# menuFile.Append(104, "Load", "")
+# menuFile.Append(107, "Import NrrdList")
+# menuFile.Append(108, "Export NrrdList")
+# menuFile.Append(106, "Import Transfer Function")
+# menuFile.Append(105, "Export Transfer Function")
+# menuFile.Append(109, "&Quit", "")
+# menuBar.Append(menuFile, "File")
+#
+# menuScene = wx.Menu()
+# menuScene.Append(201, "&Add/Remove Files", "Add and remove Nrrd files to the scene")
+# menuScene.Append(204, "Add &Histogram", "Add a histogram to the panel")
+# menuScene.Append(202, "Scene Preferences")
+# menuScene.Append(203, "&Generate")
+# menuBar.Append(menuScene, "Scene")
+#
+# menuHelp = wx.Menu()
+# menuBar.Append(menuHelp, "Help")
+# self.SetMenuBar(menuBar)
+#
+# self.Bind(wx.EVT_MENU, self.Menu101, id=101)
+# self.Bind(wx.EVT_MENU, self.Menu102, id=102)
+# self.Bind(wx.EVT_MENU, self.Menu103, id=103)
+# self.Bind(wx.EVT_MENU, self.Menu104, id=104)
+# self.Bind(wx.EVT_MENU, self.Menu105, id=105)
+# self.Bind(wx.EVT_MENU, self.Menu106, id=106)
+# self.Bind(wx.EVT_MENU, self.Menu201, id=201)
+# self.Bind(wx.EVT_MENU, self.Menu202, id=202)
+# self.Bind(wx.EVT_MENU, self.Menu107, id=107)
+# self.Bind(wx.EVT_MENU, self.Menu108, id=108)
+# self.Bind(wx.EVT_MENU, self.Menu109, id=109)
+# self.Bind(wx.EVT_MENU, self.Menu203, id=203)
+# self.Bind(wx.EVT_MENU, self.Menu204, id=204)
+# self.SetBackgroundColour(self.scene.bgColor)
def Menu101(self, evt):
self.log.write("about")
@@ -124,6 +124,7 @@
Configuration.WriteConfiguration(self.scene, path)
def Menu104(self,evt):
+ self.SetFocus()
dlg = wx.FileDialog(self, message="Open file",
defaultDir=os.getcwd(),
defaultFile="",
@@ -180,6 +181,7 @@
################ Generate Scene #################
def Menu203(self, evt):
self.BuildScene()
+ self.scene.mantaFrame.StartEngine()
################ Add Histogram #################
def Menu204(self, evt):
@@ -277,6 +279,52 @@
self.visible = True
def InitializeScene(self,frame, engine):
+
+ self.scene.mantaFrame = frame
+ menuBar = frame.menuBar
+
+ menuFile = frame.file_menu
+ dialog_id = wx.NewId()
+ menuFile.Append(dialog_id, "&About", "")
+ self.Bind(wx.EVT_MENU, self.Menu101, id=dialog_id)
+ menuFile.Append(102, "&Save", "")
+ menuFile.Append(103, "Save As...", "")
+ dialog_id = wx.NewId()
+ menuFile.Append(dialog_id, "Load", "")
+ self.Bind(wx.EVT_MENU, self.Menu104, id=dialog_id)
+ menuFile.Append(107, "Import NrrdList")
+ menuFile.Append(108, "Export NrrdList")
+ menuFile.Append(106, "Import Transfer Function")
+ menuFile.Append(105, "Export Transfer Function")
+ menuFile.Append(109, "&Quit", "")
+ #menuBar.Append(menuFile, "File")
+
+ menuScene = wx.Menu()
+ menuScene.Append(201, "&Add/Remove Files", "Add and remove Nrrd files to the scene")
+ menuScene.Append(204, "Add &Histogram", "Add a histogram to the panel")
+ menuScene.Append(202, "Scene Preferences")
+ menuScene.Append(203, "&Generate")
+ menuBar.Append(menuScene, "Scene")
+
+ menuHelp = wx.Menu()
+ menuBar.Append(menuHelp, "Help")
+# self.SetMenuBar(menuBar)
+
+
+ self.Bind(wx.EVT_MENU, self.Menu102, id=102)
+ self.Bind(wx.EVT_MENU, self.Menu103, id=103)
+ self.Bind(wx.EVT_MENU, self.Menu105, id=105)
+ self.Bind(wx.EVT_MENU, self.Menu106, id=106)
+ self.Bind(wx.EVT_MENU, self.Menu201, id=201)
+ self.Bind(wx.EVT_MENU, self.Menu202, id=202)
+ self.Bind(wx.EVT_MENU, self.Menu107, id=107)
+ self.Bind(wx.EVT_MENU, self.Menu108, id=108)
+ self.Bind(wx.EVT_MENU, self.Menu109, id=109)
+ self.Bind(wx.EVT_MENU, self.Menu203, id=203)
+ self.Bind(wx.EVT_MENU, self.Menu204, id=204)
+ self.SetBackgroundColour(self.scene.bgColor)
+
+
# Create a scene object.
scene = manta_new(Scene())
eye = manta_new(Vector(0.340429, 0.161851, -0.441882))
@@ -458,6 +506,8 @@
vs.Add(hvs2,0,wx.ALIGN_BOTTOM|wx.ALIGN_CENTER)
#TODO: can't get the staticbox to friggin work with the buttons
# vs.Add( animCtrlSizer, 0, wx.ALIGN_CENTRE|wx.ALL, 5 )
+ if (self.scene.mantaFrame != None):
+ vs.Add(self.scene.mantaFrame.panel, 0,wx.ALIGN_BOTTOM)
self.Bind(wx.EVT_BUTTON, self.OnClickBack, self.backB)
@@ -494,9 +544,10 @@
self.test.forwardAnimation()
def initialize_scene( frame, engine ):
- frame = MyFrame(None, -1, "CSAFE Demo")
- frame.Show(True)
- frame.InitializeScene(frame, engine)
+ frame1 = MyFrame(None, -1, "CSAFE Demo")
+ frame1.Show(True)
+ frame1.InitializeScene(frame, engine)
+ frame1.LayoutWindow()
def usage():
@@ -516,7 +567,7 @@
###########################################################################
# Create the application.
app = wxManta.MantaApp( initialize_scene,
- num_workers, (512,512), False, None)
+ num_workers, (512,512), False, None, begin_rendering=False)
###########################################################################
Archive powered by MHonArc 2.6.16.