Text archives Help
- From: cgribble@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r1064 - in trunk: Core Core/Color Engine/Control Model/Materials Model/Primitives Model/Textures include
- Date: Tue, 16 May 2006 17:30:30 -0600 (MDT)
Author: cgribble
Date: Tue May 16 17:30:25 2006
New Revision: 1064
Added:
trunk/Core/Color/GrayTraits.h
Modified:
trunk/Core/CMakeLists.txt
trunk/Core/Color/ColorSpace.h
trunk/Core/Color/GrayColor.h
trunk/Engine/Control/DynPLTWorker.cc
trunk/Model/Materials/DynPLTMaterial.cc
trunk/Model/Primitives/DynPLTParticle.h
trunk/Model/Textures/DynPLT.cc
trunk/Model/Textures/DynPLT.h
trunk/Model/Textures/ImageTexture.h
trunk/include/MantaTypes.h.CMakeTemplate
Log:
include/MantaTypes.h.CMakeTemplate
Core/Color/GrayTraits.h
Core/Color/ColorSpace.h
Core/Color/GrayColor.h
Core/CMakeLists.txt
Added code for using GrayColor like RGBColor (typedef'ed to GrayValue);
necessary for doing things like ImageTexture<GrayValue>, etc.
Model/Materials/DynPLTMaterial.cc
Model/Textures/ImageTexture.h
Model/Textures/DynPLT.cc
Model/Textures/DynPLT.h
Added constructor to ImageTexture<ValueType> that simply allocates storage
for
the texture data; DynPLT now uses ImageTexture<GrayValue> for storing
luminance values (texture) and dilation information (inside)
Model/Primitives/DynPLTParticle.h
Added accessors to get particle's center and radius; made plt public and
mutable
Engine/Control/DynPLTWorker.cc
Added temporary code to let us know what the worker is up to; continue to
flesh
out texture generation loop
Modified: trunk/Core/CMakeLists.txt
==============================================================================
--- trunk/Core/CMakeLists.txt (original)
+++ trunk/Core/CMakeLists.txt Tue May 16 17:30:25 2006
@@ -6,6 +6,7 @@
Color/ColorSpace.h
Color/RGBColor.h
Color/RGBColor.cc
+ Color/GrayColor.h
Color/GrayColor.cc)
SET (CORE_SOURCES ${CORE_SOURCES}
Exceptions/BadPrimitive.h
Modified: trunk/Core/Color/ColorSpace.h
==============================================================================
--- trunk/Core/Color/ColorSpace.h (original)
+++ trunk/Core/Color/ColorSpace.h Tue May 16 17:30:25 2006
@@ -3,6 +3,7 @@
#define Manta_Core_ColorSpace_h
#include <Core/Color/GrayColor.h>
+#include <Core/Color/GrayTraits.h>
#include <Core/Color/RGBColor.h>
#include <Core/Color/RGBTraits.h>
#include <Core/Math/Expon.h>
Modified: trunk/Core/Color/GrayColor.h
==============================================================================
--- trunk/Core/Color/GrayColor.h (original)
+++ trunk/Core/Color/GrayColor.h Tue May 16 17:30:25 2006
@@ -9,8 +9,6 @@
namespace Manta {
class GrayColor {
public:
- typedef float ComponentType;
-
GrayColor()
{
}
Added: trunk/Core/Color/GrayTraits.h
==============================================================================
--- (empty file)
+++ trunk/Core/Color/GrayTraits.h Tue May 16 17:30:25 2006
@@ -0,0 +1,42 @@
+
+#ifndef Manta_Core_GrayTraits_h
+#define Manta_Core_GrayTraits_h
+
+#include <Core/Color/GrayColor.h>
+#include <Core/Color/Conversion.h>
+
+namespace Manta {
+ class GrayTraits {
+ public:
+ typedef float ComponentType;
+ enum {NumComponents = 1};
+
+ // Gray
+ static void convertFrom(ComponentType data, const GrayColor& gray) {
+ data = gray.grayValue();
+ }
+
+ template <class C> static void convertFrom(ComponentType data[3],
+ const C& color) {
+ GrayColor gray;
+ convertColor(gray, color);
+ data = gray.grayValue();
+ }
+
+ // Everything else
+ static void convertTo(GrayColor& gray, const ComponentType data) {
+ gray = GrayColor(data);
+ }
+
+ template <class C> static void convertTo(C& color, const ComponentType
data) {
+ GrayColor gray(data);
+ convertColor(color, gray);
+ }
+
+ static ComponentType luminance(const ComponentType data) {
+ return data;
+ }
+ };
+}
+
+#endif
Modified: trunk/Engine/Control/DynPLTWorker.cc
==============================================================================
--- trunk/Engine/Control/DynPLTWorker.cc (original)
+++ trunk/Engine/Control/DynPLTWorker.cc Tue May 16 17:30:25 2006
@@ -1,5 +1,6 @@
#include <Engine/Control/DynPLTWorker.h>
#include <Model/Primitives/DynPLTParticle.h>
+#include <Model/Textures/DynPLT.h>
#include <SCIRun/Core/Math/MiscMath.h>
using namespace Manta;
@@ -60,6 +61,12 @@
// Do nothing
}
+#define TEMPORARY 1
+#if TEMPORARY
+#include <iostream>
+#include <unistd.h>
+#endif
+
void DynPLTWorker::run(void)
{
const DynPLTParticle* particle;
@@ -67,15 +74,41 @@
if (particle->valid)
continue;
+#if TEMPORARY
+ unsigned int time=static_cast<unsigned int>(5*rng.gendrand());
+ std::cerr<<"DynPLTWorker["<<id<<"]::run - sleeping for "<<time<<"
seconds\n";
+ sleep(time);
+#endif
+
// Render particle's texture
- // grab next available texture from pool (TrivialAllocator-style?)
- //
- // for each texel (u, v)
+ // DynPLT* texture=new DynPLT();
+
+ Vector center=particle->getCenter();
+ Real radius=particle->getRadius();
+#if TEMPORARY
+ std::cerr<<"DynPLTWorker["<<id<<"]::run - particle(<"<<center<<">,
"<<radius
+ <<")\n";
+#endif
+
+ // for each texel
// for each sample in texel
- // grab randome 2D sample point in (u, v) space of texel
- // project point onto particle's surface --> x, y, z
- // set origin = center + radius*Vector(x, y, z)
- // set normal = Vector(x, y, z).normal()
+ // Vector2D point=sample_groups[texel][sample];
+ // Project sample point onto particle's surface
+ /*
+ // Range of 2*M_PI*(u + point.x)/width --> [0, 2*Pi]
+ Real phi=2*M_PI*((u + point.x()))*inv_width;
+
+ // Range of M_PI*(v + point.y)/height -->[0, Pi]
+ Real theta=M_PI*((v + point.y()))*inv_height;
+
+ Real x=cos(phi)*sin(theta);
+ Real z=sin(phi)*sin(theta);
+ Real y=cos(theta);
+
+ Vector origin=center + radius*Vector(x, y, z);
+ Vector normal=Vector(x, y, z).normal();
+ */
+ // XXX: how to handle this with ray packets?
// for (depth=0; depth<max_depth; ++depth)
// compte direct lighting at origin
// dir = generate random cosine-weighted direction on the
hemisphere
@@ -101,9 +134,9 @@
// end loop over texels
//
// if (dilate)
- // texture.dilate();
- //
- // particle.setDynPLT(texture);
+ // texture->dilate();
+
particle->valid=true;
+ // particle->plt=texture;
}
}
Modified: trunk/Model/Materials/DynPLTMaterial.cc
==============================================================================
--- trunk/Model/Materials/DynPLTMaterial.cc (original)
+++ trunk/Model/Materials/DynPLTMaterial.cc Tue May 16 17:30:25 2006
@@ -3,6 +3,7 @@
#include <Model/Materials/DynPLTMaterial.h>
#include <Model/Primitives/DynPLTParticle.h>
#include <Model/Textures/Constant.h>
+#include <Model/Textures/DynPLT.h>
#include <Interface/Light.h>
#include <Interface/LightSet.h>
#include <Interface/Primitive.h>
@@ -51,13 +52,15 @@
if (particle->valid) {
// Particle's texture is valid
- // const DynPLT* plt=particle->getDynPLT();
- for (int j=subPacket.begin(); j<subPacket.end(); ++j) {
- // query appropriate texel values in plt
- // bi-linearly interpolate texel values
- // set resulting color
+#if 0
+ Packet<GrayValue> luminance;
+ texture->mapValues(luminance, context, subPacket);
+ for (int j=subPacket.begin(); j<subPacket.end(); ++j)
+ rays.setColor(j, Color(luminance[j])));
+#else
+ for (int j=subPacket.begin(); j<subPacket.end(); ++j)
rays.setColor(j, Color(RGB(1, 0, 0)));
- }
+#endif
} else {
// Particle's texture is invalid
if (!particle->requested) {
Modified: trunk/Model/Primitives/DynPLTParticle.h
==============================================================================
--- trunk/Model/Primitives/DynPLTParticle.h (original)
+++ trunk/Model/Primitives/DynPLTParticle.h Tue May 16 17:30:25 2006
@@ -13,7 +13,7 @@
{
public:
DynPLTParticle(Material* material, const Vector& center, Real radius) :
- Sphere(material, center, radius), valid(false), requested(false)
+ Sphere(material, center, radius), valid(false), requested(false),
plt(0)
{
// Do nothing
}
@@ -23,21 +23,19 @@
// Do nothing
}
- const DynPLT* getDynPLT(void) const
+ const Vector& getCenter(void) const
{
- return plt;
+ return center;
}
- void setDynPLT(DynPLT* new_plt)
+ Real getRadius(void) const
{
- plt=new_plt;
+ return radius;
}
- mutable bool valid;
mutable bool requested;
-
- private:
- DynPLT* plt;
+ mutable bool valid;
+ mutable DynPLT* plt;
};
}
Modified: trunk/Model/Textures/DynPLT.cc
==============================================================================
--- trunk/Model/Textures/DynPLT.cc (original)
+++ trunk/Model/Textures/DynPLT.cc Tue May 16 17:30:25 2006
@@ -3,7 +3,19 @@
using namespace Manta;
-DynPLT::DynPLT(void)
+DynPLT::DynPLT(unsigned int res) :
+ texture(res, res), inside(res, res)
{
- // stub - do nothing
+ texture.setUEdgeBehavior(ImageTexture<GrayValue>::Wrap);
+ texture.setVEdgeBehavior(ImageTexture<GrayValue>::Wrap);
+ texture.setInterpolationMethod(ImageTexture<GrayValue>::Bilinear);
+
+ inside.setUEdgeBehavior(ImageTexture<GrayValue>::Wrap);
+ inside.setVEdgeBehavior(ImageTexture<GrayValue>::Wrap);
+ inside.setInterpolationMethod(ImageTexture<GrayValue>::Bilinear);
+}
+
+void dilate(void)
+{
+ // Do nothing
}
Modified: trunk/Model/Textures/DynPLT.h
==============================================================================
--- trunk/Model/Textures/DynPLT.h (original)
+++ trunk/Model/Textures/DynPLT.h Tue May 16 17:30:25 2006
@@ -2,20 +2,26 @@
#ifndef Manta_Texture_DynPLT_h
#define Manta_Texture_DynPLT_h
-// #include <Core/Color/GrayColor.h>
-// #include <Model/Textures/ImageTexture.h>
+#include <Core/Color/GrayColor.h>
+#include <Model/Textures/ImageTexture.h>
namespace Manta {
class DynPLT
{
public:
- DynPLT(void);
+ DynPLT(unsigned int res=16);
- private:
- // ImageTexture<GrayColor> texture;
- // ImageTexture<GrayColor> inside;
+ void mapValues(Packet<GrayValue>& results, const RenderContext& context,
+ RayPacket& rays) const
+ {
+ texture.mapValues(results, context, rays);
+ }
void dilate(void);
+
+ private:
+ ImageTexture<GrayValue> texture;
+ ImageTexture<GrayValue> inside;
};
}
Modified: trunk/Model/Textures/ImageTexture.h
==============================================================================
--- trunk/Model/Textures/ImageTexture.h (original)
+++ trunk/Model/Textures/ImageTexture.h Tue May 16 17:30:25 2006
@@ -78,6 +78,7 @@
class ImageTexture : public Texture< ValueType > {
public:
ImageTexture(const Image* image);
+ ImageTexture(unsigned int xres, unsigned int yres);
virtual ~ImageTexture() {}
virtual void mapValues(Packet<ValueType>& results,
@@ -225,6 +226,15 @@
}
template< class ValueType >
+ ImageTexture< ValueType >::ImageTexture(unsigned int xres, unsigned int
yres) :
+ scale(VectorT< ScalarType, 2 >(1, 1)),
+ interpolation_method(NearestNeighbor),
+ u_edge(Wrap), v_edge(Wrap)
+ {
+ texture.resize(xres, yres);
+ }
+
+ template< class ValueType >
void ImageTexture< ValueType >::mapValues(Packet<ValueType>& results,
const RenderContext& context,
RayPacket& rays) const
@@ -255,7 +265,7 @@
BL_edge_behavior(y, v_edge, yres, y_low, y_high, y_weight_high);
// Do the interpolation
- Color a, b;
+ ValueType a, b;
a = ( texture(x_low, y_low )*(1-x_weight_high) +
texture(x_high, y_low )* x_weight_high);
b = ( texture(x_low, y_high)*(1-x_weight_high) +
Modified: trunk/include/MantaTypes.h.CMakeTemplate
==============================================================================
--- trunk/include/MantaTypes.h.CMakeTemplate (original)
+++ trunk/include/MantaTypes.h.CMakeTemplate Tue May 16 17:30:25 2006
@@ -43,8 +43,10 @@
// function like ColorSpace::Mean do the right thing.
typedef ${MANTA_COLOR_COMPONENT} ColorComponent;
class RGBTraits;
+ class GrayTraits;
template<typename T> class ColorSpace;
typedef ColorSpace<RGBTraits> Color;
+ typedef ColorSpace<GrayTraits> GrayValue;
}
#endif
- [MANTA] r1064 - in trunk: Core Core/Color Engine/Control Model/Materials Model/Primitives Model/Textures include, cgribble, 05/16/2006
Archive powered by MHonArc 2.6.16.