Text archives Help
- From: bigler@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r704 - in branches/itanium2: Model/Backgrounds Model/Lights Model/Materials scenes
- Date: Tue, 8 Nov 2005 15:49:20 -0700 (MST)
Author: bigler
Date: Tue Nov 8 15:49:19 2005
New Revision: 704
Modified:
branches/itanium2/Model/Backgrounds/TextureBackground.cc
branches/itanium2/Model/Backgrounds/TextureBackground.h
branches/itanium2/Model/Lights/HeadLight.h
branches/itanium2/Model/Materials/NormalMaterial.h
branches/itanium2/scenes/boeing777.cc
Log:
Model/Backgrounds/TextureBackground.cc
Model/Backgrounds/TextureBackground.h
Instead of trying to incorporate different kinds of transformations,
a TexCoordMapper* is kept. This is used to do the lookups if it is
defined.
TextureBackground now inherits from UniformMapper instead of
TexCoordMapper directly. Removed computeTexCoords3 as the same
functionality existed in UniformMapper::computeTexCoords3.
computeTexCoords2 now uses hitPosition instead of the direction like
a good little TexCoordMapper should.
Don't make a new RayPacket, but use the one that is passed in.
Copy the ray direction into the hitPosition of the RayPacket.
Model/Lights/HeadLight.h
Model/Materials/NormalMaterial.h
Added new line at the end of the file to get rid of the annoying
warning.
scenes/boeing777.cc
Updated to reflect the new TextureBackground API.
Modified: branches/itanium2/Model/Backgrounds/TextureBackground.cc
==============================================================================
--- branches/itanium2/Model/Backgrounds/TextureBackground.cc (original)
+++ branches/itanium2/Model/Backgrounds/TextureBackground.cc Tue Nov 8
15:49:19 2005
@@ -36,9 +36,13 @@
using namespace SCIRun;
TextureBackground::TextureBackground(const Texture<Color>* colortex,
- const Vector& up)
- : colortex(colortex), up(up.normal())
+ const TexCoordMapper* mapper_in)
+ : colortex(colortex)
{
+ if (mapper_in)
+ mapper = mapper_in;
+ else
+ mapper = this;
}
TextureBackground::~TextureBackground()
@@ -53,9 +57,10 @@
void TextureBackground::computeTexCoords2(const RenderContext&,
RayPacket& rays) const
{
+ rays.computeHitPositions();
for(int i = 0;i<rays.getSize();i++){
RayPacket::Element& e = rays.get(i);
- Vector n = e.ray.direction();
+ Point n = e.hitPosition;
Real angle = Clamp(n.z(), (Real)-1, (Real)1);
Real theta = Acos(angle);
Real phi = Atan2(n.x(), n.y());
@@ -63,44 +68,29 @@
Real y = theta*(Real)M_1_PI;
e.texCoords = Point(x, y, 0);
}
- rays.setFlag(RayPacket::HaveTexture2|RayPacket::HaveTexture3);
-}
-
-// Just map the normal to the texture coordinate
-void TextureBackground::computeTexCoords3(const RenderContext&,
- RayPacket& rays) const
-{
- for(int i = 0;i<rays.getSize();i++){
- RayPacket::Element& e = rays.get(i);
- e.texCoords = Point(e.ray.direction());
- }
- rays.setFlag(RayPacket::HaveTexture2|RayPacket::HaveTexture3);
}
void TextureBackground::shade(const RenderContext& context,
RayPacket& rays) const
{
- // Create a dummy RayPacket
- RayPacketData tdata;
- RayPacket bg_rays(tdata, rays.getSize(), rays.getDepth(),
- RayPacket::NormalizedDirections);
-
rays.normalizeDirections();
// Copy the ray directions and set the TexCoordMapper pointer back
// to this class for each ray.
for(int i=0;i<rays.getSize();i++){
- RayPacket::Element& source_e = rays.get(i);
- RayPacket::Element& bg_e = bg_rays.get(i);
- // Set the TexCoordMapper pointer to this class.
- bg_e.hitInfo.set_hit(0,0,0, this);
- // Copy the direction from the old ray to the new one.
- bg_e.ray.setDirection(source_e.ray.direction());
+ RayPacket::Element& e = rays.get(i);
+ // Set the TexCoordMapper pointer.
+ e.hitInfo.set_hit(0,0,0, mapper);
+ // Copy the direction from old ray to the new one.
+ e.hitPosition = Point(e.ray.direction());
}
+ // Tell the RayPacket that we have the hit positions since we just
+ // fed them in there.
+ rays.setFlag(RayPacket::HaveHitPositions);
// Now get the colors from the texture.
Color bg_color[RayPacket::MaxSize];
- colortex->mapValues(context, bg_rays, bg_color);
+ colortex->mapValues(context, rays, bg_color);
// Copy the colors over.
for(int i=0;i<rays.getSize();i++){
Modified: branches/itanium2/Model/Backgrounds/TextureBackground.h
==============================================================================
--- branches/itanium2/Model/Backgrounds/TextureBackground.h (original)
+++ branches/itanium2/Model/Backgrounds/TextureBackground.h Tue Nov 8
15:49:19 2005
@@ -34,16 +34,20 @@
#define Manta_Model_TextureBackground_h
#include <Interface/Background.h>
-#include <Interface/TexCoordMapper.h>
+#include <Model/TexCoordMappers/UniformMapper.h>
#include <Interface/Texture.h>
#include <Core/Color/Color.h>
#include <Core/Geometry/PointVector.h>
namespace Manta {
- class TextureBackground : public Background, public TexCoordMapper {
+ class TextureBackground : public Background, public UniformMapper {
public:
- TextureBackground(const Texture<Color>* colortex, const Vector& up);
+ // When mapper is 0 this class will be used as the mapper. I
+ // can't set the default value of the parameter to this without
+ // the compiler complaining about it.
+ TextureBackground(const Texture<Color>* colortex,
+ const TexCoordMapper* mapper = 0);
virtual ~TextureBackground();
// Interface to Background
@@ -53,14 +57,11 @@
// Interface to TexCoordMapper
virtual void computeTexCoords2(const RenderContext& context,
RayPacket& rays) const;
- virtual void computeTexCoords3(const RenderContext& context,
- RayPacket& rays) const;
private:
// This is the texture to be mapped
const Texture<Color>* colortex;
- // This was intented to be used to change the orientation of the
- // texture, but it isn't implemented yet.
- Vector up;
+ // This is the texture coordinate mapper
+ const TexCoordMapper* mapper;
};
}
Modified: branches/itanium2/Model/Lights/HeadLight.h
==============================================================================
--- branches/itanium2/Model/Lights/HeadLight.h (original)
+++ branches/itanium2/Model/Lights/HeadLight.h Tue Nov 8 15:49:19 2005
@@ -24,4 +24,4 @@
};
}
-#endif
\ No newline at end of file
+#endif
Modified: branches/itanium2/Model/Materials/NormalMaterial.h
==============================================================================
--- branches/itanium2/Model/Materials/NormalMaterial.h (original)
+++ branches/itanium2/Model/Materials/NormalMaterial.h Tue Nov 8 15:49:19
2005
@@ -15,4 +15,4 @@
};
};
-#endif
\ No newline at end of file
+#endif
Modified: branches/itanium2/scenes/boeing777.cc
==============================================================================
--- branches/itanium2/scenes/boeing777.cc (original)
+++ branches/itanium2/scenes/boeing777.cc Tue Nov 8 15:49:19 2005
@@ -257,8 +257,7 @@
(new MarbleTexture<Color>(Color(RGB(0.1,0.2,0.5)),
Color(RGB(0.7,0.8,1.0)),
1.0, 1.0, 15.0,
- 6, 2.0, 0.6 ),
- Vector(0,1,0)));
+ 6, 2.0, 0.6 )));
} else {
bg = new ConstantBackground( Color(RGB(0.8, 0.8, 0.8)) );
}
- [MANTA] r704 - in branches/itanium2: Model/Backgrounds Model/Lights Model/Materials scenes, bigler, 11/08/2005
Archive powered by MHonArc 2.6.16.