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


C# Vector3.Normalized方法代码示例

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


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

示例1: Spotlight

 //Spotlight constructor, takes a position Vector, a color Vector, a direction Vector and 
 public Spotlight(Vector3 position, Vector3 color, Vector3 direction, float minDot)
 {
     pos = position;
     this.color = color;
     D = direction.Normalized();
     this.minDot = minDot;
 }
开发者ID:Fortunos,项目名称:CVAlexLeestemaker,代码行数:8,代码来源:Light.cs

示例2: Ray

 public Ray(Vector3 origin, Vector3 direction)
 {
     Origin = origin;
     Direction = direction.Normalized();
 }
开发者ID:CryZe,项目名称:WindEditor2,代码行数:5,代码来源:Ray.cs

示例3: hits

        public Primitive objectHit; //The primitive the ray hits (if applicable).

        public Ray(Vector3 Origin, Vector3 Direction, float length)
        {
            O = Origin;
            D = Direction.Normalized();
            l = length;
        }
开发者ID:Fortunos,项目名称:CVAlexLeestemaker,代码行数:8,代码来源:Ray.cs

示例4: ConstraintLookAt

    public void ConstraintLookAt(Vector3 targetAbsRef, Vector3 upRelRef, Vector3 constraintAxisSelect)
    {

        Vector3 targetRelRef;

        if (IsChild)
            targetRelRef = Geometric.Quaternion_Rotate(_parentModel.Orientation.Inverted(), targetAbsRef);
        else
            targetRelRef = targetAbsRef;

        if (constraintAxisSelect.X != 0)
            targetRelRef.X = 0;
        else if (constraintAxisSelect.Y != 0)
            targetRelRef.Y = 0;
        else if (constraintAxisSelect.Z != 0)
            targetRelRef.Z = 0;

        //Vector v1 = new Vector3(0, 0, -1);
        //Vector moveV = _staticModel.Position - vector;
        //Vector v2 = moveV.RotateBy(_staticModel.Orientation.W, 0, 1, 0);

        /*Vector forward = lookAt.Normalized();
        Vector right = Vector::Cross(up.Normalized(), forward);
        Vector up = Vector::Cross(forward, right);*/
        Vector3 forward;
        if (IsChild)
        {
            //Normalizing target and transforming it to local system
            forward = targetRelRef.Normalized() - _parentModel.Position;
        }
        else
        {
            //Normalizing target.. local system is the same as world system
            forward = targetRelRef.Normalized();
        }
        //Normalizing upVector (we are assuming it is expressed in local system)
        Vector3 eye = _position.Normalized();
        Vector3 up = upRelRef.Normalized();

        //Insert manual imprecision to avoid singularity
        if (Vector3.Dot(forward, up) == 1)
        {
            forward.X += 0.001f;
            forward.Y += 0.001f;
            forward.Z += 0.001f;
        }

        //float angle = (float)Math.Acos( Vector3.Dot(current,targetAbsRef) );
        //Vector3 rotAxis = Vector3.CrossProduct(current, forward).Normalized();
        //Vector3 right = Vector3.CrossProduct(forward, up);

        Matrix4 lookAt_result = Matrix4.LookAt(eye.X, eye.Y, eye.Z, forward.X, forward.Y, forward.Z, up.X, up.Y, up.Z);
        Matrix3 targetRelOrientation_matrix = new Matrix3(lookAt_result);
        Quaternion targetRelOrientation_quaternion = Quaternion.FromMatrix(targetRelOrientation_matrix);

        /*
        Quaternion targetRelOrientation_quaternion = new Quaternion();
        targetRelOrientation_quaternion.W = (float)Math.Sqrt((double)(1.0f + right.X + up.Y + forward.Z)) * 0.5f;
        float w4_recip = 1.0f / (4.0f * targetRelOrientation_quaternion.W);
        targetRelOrientation_quaternion.X = (forward.Y - up.Z) * w4_recip;
        targetRelOrientation_quaternion.Y = (right.Z - forward.X) * w4_recip;
        targetRelOrientation_quaternion.Z = (up.X - right.Y) * w4_recip;
        */

        _orientation = targetRelOrientation_quaternion;

    }
开发者ID:fakkoweb,项目名称:AsTKoids,代码行数:67,代码来源:StaticModel.cs


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