Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

Procedural Checker
#include <math.h>
#include "extensionmanager.h"
#include "textureextension.h"

class CproceduralChecker : public CtextureExtension
{
	DECLARE_EXTENSION_METHODS( "Checker", CproceduralChecker, 1 )
	unsigned int uRepeat, vRepeat;
public:
	CproceduralChecker()
	{
		getExtensionData()->createUInt( "repeatU", 10, 1, 10000 );
		getExtensionData()->createUInt( "repeatV", 10, 1, 10000 );
	}
	~CproceduralChecker()
	{
	}
	bool initialize()
	{
		getExtensionData()->getUInt( "repeatU", uRepeat );
		getExtensionData()->getUInt( "repeatV", vRepeat );
		return true;
	}
	bool getRGB( Crgb& rgb, real u, real v, const IntersectionInfo* intersectionInfo )
	{
		int pu = ( ( int )( uRepeat * fabs( u ) ) ) % 2;
		int pv = ( ( int )( vRepeat * fabs( v ) ) ) % 2;
		rgb.r *= pu ^ pv;
		rgb.g *= pu ^ pv;
		rgb.b *= pu ^ pv;
		return true;
	}
};
EXPORT_TEXTURE_EXTENSION( CproceduralChecker )
  • No labels