Text archives Help
- From: "Solomon Boulos" <boulos@cs.utah.edu>
- To: manta@sci.utah.edu
- Subject: [Manta] r2255 - trunk/Model/Textures
- Date: Wed, 7 May 2008 17:37:46 -0600 (MDT)
Author: boulos
Date: Wed May 7 17:37:42 2008
New Revision: 2255
Added:
trunk/Model/Textures/WireframeTexture.cc
trunk/Model/Textures/WireframeTexture.h
Modified:
trunk/Model/Textures/CMakeLists.txt
trunk/Model/Textures/CheckerTexture.h
Log:
Model/Textures/CMakeLists.txt
Model/Textures/CheckerTexture.h
Model/Textures/WireframeTexture.cc
Model/Textures/WireframeTexture.h
Adding a Wireframe Texture that assumes your texture coordinates
correspond to the barycentric values you want to visualize.
Also leaving a note about why CheckerTexture uses an array of
ValueType values[2] instead of two separate ones (template and
default constructor reasons)
Modified: trunk/Model/Textures/CMakeLists.txt
==============================================================================
--- trunk/Model/Textures/CMakeLists.txt (original)
+++ trunk/Model/Textures/CMakeLists.txt Wed May 7 17:37:42 2008
@@ -22,6 +22,8 @@
Textures/TexCoordTexture.cc
Textures/TexCoordTexture.h
Textures/ValueColormap.h
+ Textures/WireframeTexture.cc
+ Textures/WireframeTexture.h
Textures/WoodTexture.cc
Textures/WoodTexture.h
)
Modified: trunk/Model/Textures/CheckerTexture.h
==============================================================================
--- trunk/Model/Textures/CheckerTexture.h (original)
+++ trunk/Model/Textures/CheckerTexture.h Wed May 7 17:37:42 2008
@@ -18,8 +18,8 @@
public:
CheckerTexture();
CheckerTexture(const ValueType& value1,
- const ValueType& value2,
- const Vector& v1, const Vector& v2);
+ const ValueType& value2,
+ const Vector& v1, const Vector& v2);
virtual ~CheckerTexture();
virtual void mapValues(Packet<ValueType>&, const RenderContext& context,
RayPacket& rays) const;
@@ -28,6 +28,10 @@
CheckerTexture(const CheckerTexture&);
CheckerTexture& operator=(const CheckerTexture&);
+ // NOTE(boulos): This has to be an array so that the default
+ // constructor (which has to be defined for the Persistent stuff)
+ // for Color(ComponentType) isn't called (because that's
+ // protected) so we get a confusing error.
ValueType values[2];
Vector v1;
Vector v2;
@@ -41,9 +45,9 @@
template<class ValueType>
CheckerTexture<ValueType>::CheckerTexture(const ValueType& value1,
- const ValueType& value2,
- const Vector& v1,
- const Vector& v2)
+ const ValueType& value2,
+ const Vector& v1,
+ const Vector& v2)
: v1(v1), v2(v2)
{
values[0] = value1;
@@ -53,7 +57,7 @@
else
need_w = true;
}
-
+
template<class ValueType>
void CheckerTexture<ValueType>::mapValues(Packet<ValueType>& results,
const RenderContext& context,
Added: trunk/Model/Textures/WireframeTexture.cc
==============================================================================
--- (empty file)
+++ trunk/Model/Textures/WireframeTexture.cc Wed May 7 17:37:42 2008
@@ -0,0 +1,5 @@
+
+#include <Model/Textures/WireframeTexture.h>
+// TODO(boulos): Put SSE optimized versions for Colors here.
+
+
Added: trunk/Model/Textures/WireframeTexture.h
==============================================================================
--- (empty file)
+++ trunk/Model/Textures/WireframeTexture.h Wed May 7 17:37:42 2008
@@ -0,0 +1,113 @@
+
+#ifndef Manta_Model_WireframeTexture_h
+#define Manta_Model_WireframeTexture_h
+
+#include <Interface/Texture.h>
+#include <Core/Color/Color.h>
+#include <Core/Geometry/Vector.h>
+#include <Core/Persistent/ArchiveElement.h>
+#include <Interface/InterfaceRTTI.h>
+#include <Interface/RayPacket.h>
+#include <MantaSSE.h>
+
+namespace Manta {
+ class RayPacket;
+ class RenderContext;
+ template<typename ValueType>
+ class WireframeTexture : public Texture<ValueType> {
+ public:
+ WireframeTexture();
+ WireframeTexture(const ValueType& border,
+ const ValueType& interior,
+ float border_width);
+ virtual ~WireframeTexture();
+
+ virtual void mapValues(Packet<ValueType>&, const RenderContext& context,
RayPacket& rays) const;
+ void readwrite(ArchiveElement* archive);
+ private:
+ WireframeTexture(const WireframeTexture&);
+ WireframeTexture& operator=(const WireframeTexture&);
+
+ ValueType values[2]; // NOTE(boulos): This is because
+ // Color(ComponentType) is not allowable, so
+ // we don't want default constructors run.
+ float border_width;
+ };
+
+ template<class ValueType>
+ WireframeTexture<ValueType>::WireframeTexture()
+ {
+ }
+
+ template<class ValueType>
+ WireframeTexture<ValueType>::WireframeTexture(const ValueType& border,
+ const ValueType& interior,
+ float border_width)
+ : border_width(border_width)
+ {
+ values[0] = border;
+ values[1] = interior;
+ }
+
+ template<class ValueType>
+ void WireframeTexture<ValueType>::mapValues(Packet<ValueType>& results,
+ const RenderContext& context,
+ RayPacket& rays) const
+ {
+ rays.computeTextureCoordinates2(context);
+
+ for(int i=rays.begin();i<rays.end();i++){
+ float u = rays.getTexCoords(i)[0];
+ float v = rays.getTexCoords(i)[1];
+ float w = 1.f - u - v;
+
+ // Object space border check (can also do projected size)
+ bool u_border = (u < .5f * border_width || (1-u) < .5f * border_width);
+ bool v_border = (v < .5f * border_width || (1-v) < .5f * border_width);
+ bool w_border = (w < .5f * border_width || (1-w) < .5f * border_width);
+ bool border = u_border || v_border || w_border;
+ if (border) {
+ results.set(i, values[0]);
+ } else {
+ results.set(i, values[1]);
+ }
+ }
+ }
+
+ template<class ValueType>
+ class MantaRTTI<WireframeTexture<ValueType> > : public
MantaRTTI_DerivedClass<WireframeTexture<ValueType>, Texture<ValueType> >,
public MantaRTTI_ConcreteClass<WireframeTexture<ValueType> >, public
MantaRTTI_readwriteMethod<WireframeTexture<ValueType> > {
+ public:
+ static std::string getPublicClassname() {
+ return
"WireframeTexture<"+MantaRTTI<ValueType>::getPublicClassname()+">";
+ }
+ class Initializer {
+ public:
+ Initializer() {
+ MantaRTTI<WireframeTexture<ValueType> >::registerClass();
+ }
+ void forceinit() {
+ }
+ };
+ static Initializer init;
+ };
+
+ template<class ValueType>
+ typename MantaRTTI<WireframeTexture<ValueType> >::Initializer
MantaRTTI<WireframeTexture<ValueType> >::init;
+
+ template<class ValueType>
+ void WireframeTexture<ValueType>::readwrite(ArchiveElement* archive)
+ {
+ archive->readwrite("border", values[0]);
+ archive->readwrite("interior", values[1]);
+ archive->readwrite("border_width", border_width);
+ }
+
+ template<class ValueType>
+ WireframeTexture<ValueType>::~WireframeTexture()
+ {
+ MantaRTTI<WireframeTexture<ValueType> >::init.forceinit();
+ }
+}
+
+
+#endif
- [Manta] r2255 - trunk/Model/Textures, Solomon Boulos, 05/07/2008
Archive powered by MHonArc 2.6.16.