Example #1
0
Point4::type Point4::DotProduct(Vector4 const& v) const
{
    return (m_elements[0] * v.X())
           + (m_elements[1] * v.Y())
           + (m_elements[2] * v.Z())
           + (m_elements[3] * v.W());
}
Example #2
0
	void Shader::SetVector4(std::string name, Vector4 value)
	{
		int uloc = SIG_FindUniform(name);
		if (uloc != -1) {
			glUniform4fARB(uloc, value.X(), value.Y(), value.Z(), value.W());
		} else {
			SIG_LOG("Could not find uniform \"" << name << "\"");
		}
	}
Example #3
0
void LightRenderNode::renderInternal() {
	Quaternion* orientation;
	Vector3 unitVector;
	Vector3 rotated;
	Vector4 vLightPosition;
	Vector4 vLightDirection;
	Vector3* pos;
	
	GLuint lightNum = GL_LIGHT0 + getAndIncLightNumber();
	
	switch(lightType) {
		case LIGHT_DIRECTIONAL:
			orientation = owner->getTransform()->getOrientation();
			unitVector = Vector3(0.0f,0.0f,1.0f);	
			rotated = orientation->Rotate(unitVector);
			
			vLightDirection.X() = -rotated.X();
			vLightDirection.Y() = -rotated.Y();
			vLightDirection.Z() = -rotated.Z();
			vLightDirection.W() = 0.0f;
			
			glEnable(lightNum);
			glLightfv(lightNum, GL_POSITION, (float*)&vLightDirection);
			break;
		case LIGHT_POINT:
			pos = owner->getTransform()->getPosition();
			vLightPosition.X() = pos->X();
			vLightPosition.Y() = pos->Y();
			vLightPosition.Z() = pos->Z();
			vLightPosition.W() = 1.0f;
			
			glEnable(lightNum);
			glLightfv(lightNum, GL_POSITION, (float*)&vLightPosition);
			break;
		case LIGHT_SPOT:
			pos = owner->getTransform()->getPosition();
			orientation = owner->getTransform()->getOrientation();
			unitVector = Vector3(0.0f,0.0f,1.0f);	
			rotated = orientation->Rotate(unitVector);
			
			vLightPosition.X() = pos->X();
			vLightPosition.Y() = pos->Y();
			vLightPosition.Z() = pos->Z();
			vLightPosition.W() = 1.0f;
			
			orientation = owner->getTransform()->getOrientation();
			unitVector = Vector3(0.0f,0.0f,1.0f);	
			rotated = orientation->Rotate(unitVector);
			
			vLightDirection.X() = rotated.X();
			vLightDirection.Y() = rotated.Y();
			vLightDirection.Z() = rotated.Z();
			vLightDirection.W() = 0.0f;
			
			glEnable(lightNum);
			glLightf(lightNum, GL_SPOT_CUTOFF, 45.0);
			glLightfv(lightNum, GL_POSITION, (float*)&vLightPosition);
			glLightfv(lightNum, GL_SPOT_DIRECTION, (float*)&vLightDirection);
			break;
	}
	
	glLightfv(lightNum, GL_AMBIENT, (float*)&ambient);
	glLightfv(lightNum, GL_DIFFUSE, (float*)&diffuse);
	glLightfv(lightNum, GL_SPECULAR, (float*)&specular);
}