本文整理汇总了C#中IrrlichtNETCP.Vector3D.Normalize方法的典型用法代码示例。如果您正苦于以下问题:C# Vector3D.Normalize方法的具体用法?C# Vector3D.Normalize怎么用?C# Vector3D.Normalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IrrlichtNETCP.Vector3D
的用法示例。
在下文中一共展示了Vector3D.Normalize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetPlane
public void SetPlane(Vector3D point1, Vector3D point2, Vector3D point3)
{
Normal = (point2 - point1).CrossProduct(point3 - point1);
Normal.Normalize();
RecalculateD(point1);
}
示例2: ShaderEvent
public override void ShaderEvent(IrrlichtNETCP.MaterialRendererServices services, int userData)
{
if (updateOnce)
{
return;
}
else
{
updateOnce = true;
}
if (Reference.Viewer.SkyQuality == Viewer.ShaderLevelType.High)
{
Matrix4 worldViewProj = Reference.VideoDriver.GetTransform(TransformationState.Projection);
worldViewProj *= Reference.VideoDriver.GetTransform(TransformationState.View);
worldViewProj *= Reference.VideoDriver.GetTransform(TransformationState.World);
services.SetVertexShaderConstant("WVPMatrix", worldViewProj.ToShader());
}
Vector3D camPos, camPosXZ;
camPosXZ = camPos = new Vector3D(Reference.Viewer.Camera.Position.X, Reference.Viewer.Camera.Position.Y, Reference.Viewer.Camera.Position.Z);
camPosXZ.Y = 0f;
//// Sun position calculation
SkyMaths.AltAzAngles sunAngles = SkyMaths.CalculateSunPosition(julianDay + (float)worldTime.TimeOfDay.TotalDays, LATITUDE);
sunPosition = SkyMaths.MoveAroundPoint(camPosXZ, 12500f, sunAngles.azimuth, -sunAngles.altitude);
if (sunNode != null)
sunNode.Position = sunPosition * 0.4f;
//// Moon position (approximate inverse of the sun, l0lz.)
moonPosition = sunPosition;
moonPosition.X *= -1.0f;
moonPosition.Y *= -1.0f;
moonPosition.Z *= -1.0f;
moonPosition = moonPosition.Normalize();
if (moonNode != null)
moonNode.Position = moonPosition * 9000.0f;
// Set the sun normalized vector and the sunTheta to the shader
Vector3D sunNormedPos = new Vector3D();
sunNormedPos = sunPosition - camPosXZ;
sunNormedPos = sunNormedPos.Normalize();
float sunTheta = SkyMaths.VectorToTheta(sunNormedPos);
// Sun lightning direction
Vector3D sunDirection = new Vector3D();
sunDirection = sunPosition - camPosXZ;
sunDirection = sunDirection.Normalize();
// Stars and moon opacity
moonIntensity = SkyMaths.Saturate(SkyMaths.Lerp(sunAngles.altitude, 0f, SUN_SET)) * 0.95f;
moonIntensity += 0.05f;
// A hack to kill the orange tones in the nightsky
float darkness = 1f - (moonIntensity - 0.05f);
// Calculate the constant matrices
SkyMaths.xyYColor _zenithColors = SkyMaths.SkyZenithColor(turbidity, sunTheta);
Vector3D _zenithColorsVector = new Vector3D(_zenithColors.x, _zenithColors.y, _zenithColors.Y);
SkyMaths.xyYCoeffs _distribCoeffs = SkyMaths.DistributionCoefficients(turbidity);
if (Reference.Viewer.SkyQuality == Viewer.ShaderLevelType.High)
{
services.SetVertexShaderConstant("SunTheta", sunTheta);
services.SetVertexShaderConstant("SunVector", sunNormedPos.ToShader());
services.SetVertexShaderConstant("NightDarkness", darkness);
services.SetVertexShaderConstant("ZenithColor", _zenithColorsVector.ToShader());
for (int i = 0; i < 5; i++)
{
services.SetVertexShaderConstant("_xDistribCoeffs[" + i + "]", _distribCoeffs.x[i]);
services.SetVertexShaderConstant("_yDistribCoeffs[" + i + "]", _distribCoeffs.y[i]);
services.SetVertexShaderConstant("_YDistribCoeffs[" + i + "]", _distribCoeffs.Y[i]);
}
// Set the adaptative luminance and gamma corrections
float gamma = 1f / (1.6f + (turbidity - 2f) * 0.1f);
services.SetVertexShaderConstant("InvGammaCorrection", 1.5f * gamma);
services.SetVertexShaderConstant("InvPowLumFactor", gamma);
services.SetVertexShaderConstant("InvNegMaxLum", -1.25f / SkyMaths.MaximumLuminance(turbidity, sunTheta, _zenithColors, _distribCoeffs));
float calcAlpha = ((12 - 1) * 60 * 60 + (60 - 1) * 60 + 60) - ((worldTime.Hour - 1) * 60 * 60 + (worldTime.Minute - 1) * 60 + worldTime.Second);
calcAlpha = 1 - Math.Abs(calcAlpha) / cloudChangeSec;
calcAlpha = Util.Clamp<float>(calcAlpha, 0, 1);
calcAlpha = calcAlpha * calcAlpha;
float minAlpha = 0.05f;
calcAlpha = (calcAlpha * 1.5f) + minAlpha;
calcAlpha = Util.Clamp<float>(calcAlpha, 0, 1);
services.SetPixelShaderConstant("CloudAlpha", calcAlpha);
services.SetPixelShaderConstant("BlendingRate", 0);
}
// Clouds coloring
float[] atmoCol = SkyMaths.AtmosphereColor(turbidity, sunTheta, _zenithColors, _distribCoeffs);
Vector3D atmoColVec = new Vector3D(atmoCol[0], atmoCol[1], atmoCol[2]);
float dayState = SkyMaths.Saturate(SkyMaths.Lerp(sunAngles.altitude, (float)(Math.PI * 1f / (6f - turbidity / 2f)), SUN_RISE));
// Sun lightning intensity
//.........这里部分代码省略.........