Manta Interactive Ray Tracer Development Mailing List

Text archives Help


[MANTA] r289 - in trunk: Model/Textures scenes


Chronological Thread 
  • From: aek@sci.utah.edu
  • To: rtrt@sci.utah.edu
  • Subject: [MANTA] r289 - in trunk: Model/Textures scenes
  • Date: Wed, 11 May 2005 17:49:09 -0600 (MDT)

Author: aek
Date: Wed May 11 17:49:08 2005
New Revision: 289

Added:
   trunk/Model/Textures/WoodTexture.cc
   trunk/Model/Textures/WoodTexture.h
Modified:
   trunk/scenes/primtest.cc
Log:
Added a basic wood texture.  Nothing fancy, but it looks somewhat
wood-like.  Pass "-material wood" to primtest to see it.



Added: trunk/Model/Textures/WoodTexture.cc
==============================================================================
--- (empty file)
+++ trunk/Model/Textures/WoodTexture.cc Wed May 11 17:49:08 2005
@@ -0,0 +1,56 @@
+
+#include <Model/Textures/WoodTexture.h>
+#include <Interface/RayPacket.h>
+#include <Core/Geometry/Point.h>
+#include <Core/Geometry/Vector.h>
+#include <Core/Math/Noise.h>
+#include <Core/Math/MiscMath.h>
+
+namespace Manta {
+
+  template< class ValueType >
+  WoodTexture< ValueType >::WoodTexture(
+      ValueType const &value1,
+      ValueType const &value2,
+      double const scale,
+      double const rscale,
+      double const tscale,
+      double const sharpness,
+      int const octaves,
+      double const lacunarity,
+      double const gain )
+    : value1( value1 ),
+      value2( value2 ),
+      scale ( scale ),
+      rscale( rscale ),
+      tscale( tscale ),
+      sharpness( sharpness ),
+      octaves( octaves ),
+      lacunarity( lacunarity ),
+      gain( gain )
+  {
+  }
+  
+  template< class ValueType >
+  WoodTexture< ValueType >::~WoodTexture()
+  {
+  }
+
+  template< class ValueType >
+  void WoodTexture< ValueType >::mapValues(
+    RenderContext const &context,
+    RayPacket &rays,
+    ValueType results[] ) const
+  {
+    rays.computeTextureCoordinates3( context );
+    for( int i = 0; i < rays.getSize(); i++ ) {
+      RayPacket::Element &e = rays.get( i );
+      Point T = e.texCoords * scale;
+      double distance = sqrt( T.x() * T.x() + T.y() * T.y() ) * rscale;
+      double fbm = tscale * ScalarFBM( T, octaves, lacunarity, gain );
+      double value = 0.5 * cos( distance + fbm ) + 0.5;
+      results[ i ] = Interpolate( value2, value1, pow( value, sharpness ) );
+    }
+  }
+
+}

Added: trunk/Model/Textures/WoodTexture.h
==============================================================================
--- (empty file)
+++ trunk/Model/Textures/WoodTexture.h  Wed May 11 17:49:08 2005
@@ -0,0 +1,51 @@
+
+#ifndef Manta_Model_WoodTexture_h
+#define Manta_Model_WoodTexture_h
+
+#include <Interface/Texture.h>
+
+namespace Manta {
+  class RayPacket;
+  class RenderContext;
+  template< typename ValueType >
+  class WoodTexture : public Texture< ValueType > {
+    public:
+    WoodTexture(
+      ValueType const &value1,
+      ValueType const &value2,
+      double const scale,
+      double const rscale,
+      double const tscale,
+      double const sharpness,
+      int const octaves,
+      double const lacunarity,
+      double const gain );
+    virtual ~WoodTexture();
+    virtual void mapValues(
+      RenderContext const &context, 
+      RayPacket &rays,
+      ValueType results[] ) const;
+    private:
+    WoodTexture(
+      WoodTexture const & );
+    WoodTexture& operator=(
+      WoodTexture const & );
+    
+    ValueType value1;
+    ValueType value2;
+    double scale;
+    double rscale;
+    double tscale;
+    double sharpness;
+    int octaves;
+    double lacunarity;
+    double gain;
+  };
+}
+
+#ifdef __GNUG__
+// This should instead be a configure variable...
+#include <Model/Textures/WoodTexture.cc>
+#endif
+
+#endif

Modified: trunk/scenes/primtest.cc
==============================================================================
--- trunk/scenes/primtest.cc    (original)
+++ trunk/scenes/primtest.cc    Wed May 11 17:49:08 2005
@@ -29,6 +29,7 @@
 #include <Model/Textures/Constant.h>
 #include <Model/Textures/CheckerTexture.h>
 #include <Model/Textures/MarbleTexture.h>
+#include <Model/Textures/WoodTexture.h>
 #include <Core/Math/MinMax.h>
 #include <sgi_stl_warnings_off.h>
 #include <string>
@@ -123,6 +124,11 @@
                     new Constant<Color>(Color(RGB(.6,.6,.6))),
                     32,
                     new Constant<double>(0));
+  else if(material == "wood")
+    matl = new Lambertian(
+             new WoodTexture<Color>(
+               Color(RGB(0.32,0.25,0.21)), Color(RGB(0.41,0.35,0.3)), 
+               12.0, 20.0, 5.0, 5.0, 6, 2.0, 0.6 ) );
   else
     throw IllegalArgument("Unknown material type for primtest: "+material, 
0, args);
   Object* spinprim = 0;




  • [MANTA] r289 - in trunk: Model/Textures scenes, aek, 05/11/2005

Archive powered by MHonArc 2.6.16.

Top of page