當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。