예제 #1
0
float Noise::interpolateNoise(float x, float y)
{
	int wholePartX = (int) x; // Same as flooring.
	float fractionPartX = x - wholePartX;

	int wholePartY = (int) y;
	float fractionPartY = y - wholePartY;

	float v1 = nextFloat(wholePartX, wholePartY);
	float v2 = nextFloat(wholePartX + 1, wholePartY);
	float v3 = nextFloat(wholePartX, wholePartY + 1);
	float v4 = nextFloat(wholePartX + 1, wholePartY + 1);

	float i1 = InterpolateCubic(v1, v2, fractionPartX);
	float i2 = InterpolateCubic(v3, v4, fractionPartX);

	return InterpolateCubic(i1, i2, fractionPartY);
}
예제 #2
0
	Float next1D() {
		/* Skip over dimensions that were reserved to arrays */
		if (m_dimension >= m_arrayStartDim && m_dimension < m_arrayEndDim)
			m_dimension = m_arrayEndDim;
		if (m_dimension >= primeTableSize)
			Log(EError, "Lookup dimension exceeds the prime number table size! "
				"You may have to reduce the 'maxDepth' parameter of your integrator.");

		uint64_t index = m_offset + m_stride * m_sampleIndex;
		return nextFloat(index);
	}
예제 #3
0
	Point2 next2D() {
		/* Skip over dimensions that were reserved to arrays */
		if (m_dimension + 1 >= m_arrayStartDim && m_dimension < m_arrayEndDim)
			m_dimension = m_arrayEndDim;
		if (m_dimension + 1 >= primeTableSize)
			Log(EError, "Lookup dimension exceeds the prime number table size! "
				"You may have to reduce the 'maxDepth' parameter of your integrator.");

		uint64_t index = m_offset + m_stride * m_sampleIndex;

		Float value1, value2;
		if (m_dimension == 0) {
			value1 = nextFloat(index) * m_primePowers.x - m_pixelPosition.x;
			value2 = nextFloat(index) * m_primePowers.y - m_pixelPosition.y;
		} else {
			value1 = nextFloat(index);
			value2 = nextFloat(index);
		}

		return Point2(value1, value2);
	}
예제 #4
0
std::string TrampolineMgr::ArgumentWalker::next(char type)
{
    std::stringstream ss;
    void* ptr;

    if (type == 'u')
        ss << unsigned(nextInt());
    else if (type == 'i')
        ss << nextInt();
    else if (type == 'q')
        ss << nextLL();
    else if (type == 'f')
        ss << nextFloat();
    else if (type == 'd')
        ss << nextDouble();
    else if (type == 'p' || isupper(type))
        ss << nextPointer();
    else if (type == 'c')
        ss << char(nextInt());
    else if (type == 's')
    {
        const char* s = (const char*) nextPointer();
        ss << (void*)s;
        if (s)
            ss << " \"" << safeString(s) << '"';
    }
    else if (type == 'v')
        ss << "(void)";
    else
        ss << '?';

    if (isupper(type))
        m_pointers.push_back(std::make_pair(tolower(type), ptr));

    return ss.str();
}
예제 #5
0
파일: Random.cpp 프로젝트: zxwglzi/libcgt
float Random::nextFloatRange( float lo, float hi )
{
	float range = hi - lo;
	return( lo + range * nextFloat() );
}
예제 #6
0
파일: Random.cpp 프로젝트: zxwglzi/libcgt
Vector4f Random::nextVector4f()
{
	return Vector4f( nextFloat(), nextFloat(), nextFloat(), nextFloat() );
}