当前位置: 首页>>代码示例>>C++>>正文


C++ Vector4::Dot方法代码示例

本文整理汇总了C++中Vector4::Dot方法的典型用法代码示例。如果您正苦于以下问题:C++ Vector4::Dot方法的具体用法?C++ Vector4::Dot怎么用?C++ Vector4::Dot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vector4的用法示例。


在下文中一共展示了Vector4::Dot方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetPointLightOnPoint

Vector4 LightInfo::GetPointLightOnPoint(const Vector4& _cameraSpacePoint, const Vector4& _point, const Vector4& _normal, int _lightIndex, const Vector4& _diffuse, const Vector4& _specular) {
	// Get the difference in position from the light and the point.
	Vector4 diff = GetPointLights()[_lightIndex].GetPosition() - _point;
	Vector4 lightDirection = diff;

	// The distance
	float distance = diff.Length();
					
	// The direction
	diff.Normalize();

	// The attenuation
	float attenuation = GetPointLights()[_lightIndex].GetAttenuation(distance);
			
	// Diffuse lighting.
	Vector4 pointColor = GetPointLights()[_lightIndex].GetIntensity() 
								* diff.Dot(_normal)
									* attenuation
										* _diffuse;
	pointColor.Clamp();

	// Specular
	// We get the half angle between the camera and the direction to the camera.
	Vector4 halfAngle = lightDirection + _cameraSpacePoint;
	halfAngle.Normalize();

	Vector4 specular = _specular * powf(halfAngle.Dot(_normal), 10) * attenuation;
	specular.Clamp();
	pointColor += specular;

	return pointColor;
}
开发者ID:bombpersons,项目名称:Dokuro3D,代码行数:32,代码来源:LightInfo.cpp

示例2: ComputePoint

Vector3 ComputePoint(float32_t param, const Vector3& a, const Vector3& b, const Vector3& c, const Vector3& d, const CurveGenerator::Type type )
{
    Vector4 v = ComputeParam( param, type );
    const Matrix4& curveBasis = ComputeBasis( type );

    Vector4 x (a.x, b.x, c.x, d.x);
    x = curveBasis * x;

    Vector4 y (a.y, b.y, c.y, d.y);
    y = curveBasis * y;

    Vector4 z (a.z, b.z, c.z, d.z);
    z = curveBasis * z;

    return Vector3 (v.Dot(x), v.Dot(y), v.Dot(z));
}
开发者ID:,项目名称:,代码行数:16,代码来源:

示例3: GetDirectionalLightOnPoint

/* Get the light value for a point in space */
Vector4 LightInfo::GetDirectionalLightOnPoint(const Vector4& _cameraSpacePoint, const Vector4& _normal, int _lightIndex, const Vector4& _diffuse, const Vector4& _specular) {
	Vector4 directionalColor = GetDirectionalLights()[_lightIndex].GetIntensity() * GetDirectionalLights()[_lightIndex].GetDirection().Dot(_normal) * _diffuse;
	directionalColor.Clamp();

	// Specular
	Vector4 halfAngle  = GetDirectionalLights()[_lightIndex].GetDirection() + _cameraSpacePoint;
	halfAngle.Normalize();
	Vector4 specular = _specular * powf(halfAngle.Dot(_normal), 100) * GetDirectionalLights()[_lightIndex].GetIntensity();
	specular.Clamp();
	directionalColor += specular;

	return directionalColor;
}
开发者ID:bombpersons,项目名称:Dokuro3D,代码行数:14,代码来源:LightInfo.cpp

示例4: GetSpotLightOnPoint

// Get the spot light info on a point.
Vector4 LightInfo::GetSpotLightOnPoint(const Vector4& _cameraSpacePoint, const Vector4& _point, const Vector4& _normal, int _lightIndex, const Vector4& _diffuse, const Vector4& _specular) {
	// Get the difference in position from the light and the point.
	Vector4 diff = GetSpotLights()[_lightIndex].GetPosition() - _point;
	Vector4 lightDirection = diff;

	// The distance
	float distance = diff.Length();
					
	// The direction
	diff.Normalize();

	// Calculate the spot light values
	float spotLightValue = diff.Dot(GetSpotLights()[_lightIndex].GetDirection() * -1);
	if (spotLightValue > 0.2f)
		return Vector4(0, 0, 0, 0);
	float smoothing = GetSpotLights()[_lightIndex].SmoothStep(diff.Dot(_normal));

	// The attenuation
	float attenuation = GetSpotLights()[_lightIndex].GetAttenuation(distance);
			
	// Diffuse lighting.
	Vector4 pointColor = GetSpotLights()[_lightIndex].GetIntensity() 
								* diff.Dot(_normal)
									* attenuation
										* _diffuse
											* spotLightValue;

	// Specular
	// We get the half angle between the camera and the direction to the camera.
	Vector4 halfAngle = lightDirection + _cameraSpacePoint;
	halfAngle.Normalize();

	pointColor += _specular * powf(halfAngle.Dot(_normal), 10) * attenuation;

	return pointColor;	
}
开发者ID:bombpersons,项目名称:Dokuro3D,代码行数:37,代码来源:LightInfo.cpp


注:本文中的Vector4::Dot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。