• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# LSL_Types.Quaternion类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion的典型用法代码示例。如果您正苦于以下问题:C# OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion类的具体用法?C# OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion怎么用?C# OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion类属于命名空间,在下文中一共展示了OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: llSetVehicleRotationParam

        //CFK 9/28: Most, but not all of the underlying plumbing between here and the physics modules is in
        //CFK 9/28: so these are not complete yet.
        public void llSetVehicleRotationParam(int param, LSL_Rotation rot)
        {
            m_host.AddScriptLPS(1);

            if (!m_host.ParentGroup.IsDeleted)
            {
                m_host.ParentGroup.RootPart.SetVehicleRotationParam(param, Rot2Quaternion(rot));
            }
        }
开发者ID:OpenPlex-Sim,项目名称:opensim,代码行数:11,代码来源:LSL_Api.cs


示例2: llSetRot

        public void llSetRot(LSL_Rotation rot)
        {
            m_host.AddScriptLPS(1);

            // try to let this work as in SL...
            if (m_host.ParentID == 0)
            {
                // special case: If we are root, rotate complete SOG to new rotation
                SetRot(m_host, Rot2Quaternion(rot));
            }
            else
            {
                // we are a child. The rotation values will be set to the one of root modified by rot, as in SL. Don't ask.
                SceneObjectPart rootPart = m_host.ParentGroup.RootPart;
                if (rootPart != null) // better safe than sorry
                {
                    SetRot(m_host, rootPart.RotationOffset * Rot2Quaternion(rot));
                }
            }

            ScriptSleep(200);
        }
开发者ID:OpenPlex-Sim,项目名称:opensim,代码行数:22,代码来源:LSL_Api.cs


示例3: LSL_Vector

        // Xantor 29/apr/2008
        // converts a Quaternion to X,Y,Z axis rotations
        public LSL_Vector llRot2Axis(LSL_Rotation rot)
        {
            m_host.AddScriptLPS(1);
            double x,y,z;

            if (rot.s > 1) // normalization needed
            {
                double length = Math.Sqrt(rot.x * rot.x + rot.y * rot.y +
                        rot.z * rot.z + rot.s * rot.s);

                rot.x /= length;
                rot.y /= length;
                rot.z /= length;
                rot.s /= length;

            }

            // double angle = 2 * Math.Acos(rot.s);
            double s = Math.Sqrt(1 - rot.s * rot.s);
            if (s < 0.001)
            {
                x = 1;
                y = z = 0;
            }
            else
            {
                x = rot.x / s; // normalise axis
                y = rot.y / s;
                z = rot.z / s;
            }

            return new LSL_Vector(x,y,z);
        }
开发者ID:OpenPlex-Sim,项目名称:opensim,代码行数:35,代码来源:LSL_Api.cs


示例4: llSetLocalRot

 public void llSetLocalRot(LSL_Rotation rot)
 {
     m_host.AddScriptLPS(1);
     SetRot(m_host, Rot2Quaternion(rot));
     ScriptSleep(200);
 }
开发者ID:OpenPlex-Sim,项目名称:opensim,代码行数:6,代码来源:LSL_Api.cs


示例5: llRotTarget

 public LSL_Integer llRotTarget(LSL_Rotation rot, double error)
 {
     m_host.AddScriptLPS(1);
     return m_host.ParentGroup.registerRotTargetWaypoint(
         new Quaternion((float)rot.x, (float)rot.y, (float)rot.z, (float)rot.s), (float)error);
 }
开发者ID:OpenPlex-Sim,项目名称:opensim,代码行数:6,代码来源:LSL_Api.cs


示例6: llRot2Up

        public LSL_Vector llRot2Up(LSL_Rotation r)
        {
            m_host.AddScriptLPS(1);
            double x, y, z, m;

            m = r.x * r.x + r.y * r.y + r.z * r.z + r.s * r.s;
            // m is always greater than zero
            // if m is not equal to 1 then Rotation needs to be normalized
            if (Math.Abs(1.0 - m) > 0.000001) // allow a little slop here for calculation precision
            {
                m = 1.0 / Math.Sqrt(m);
                r.x *= m;
                r.y *= m;
                r.z *= m;
                r.s *= m;
            }

            // Fast Algebric Calculations instead of Vectors & Quaternions Product
            x = 2 * (r.x * r.z + r.y * r.s);
            y = 2 * (-r.x * r.s + r.y * r.z);
            z = -r.x * r.x - r.y * r.y + r.z * r.z + r.s * r.s;
            return (new LSL_Vector(x, y, z));
        }
开发者ID:OpenPlex-Sim,项目名称:opensim,代码行数:23,代码来源:LSL_Api.cs


示例7: llRezAtRoot

        public void llRezAtRoot(string inventory, LSL_Vector pos, LSL_Vector vel, LSL_Rotation rot, int param)
        {
            m_host.AddScriptLPS(1);

            Util.FireAndForget(delegate (object x)
            {
                if (Double.IsNaN(rot.x) || Double.IsNaN(rot.y) || Double.IsNaN(rot.z) || Double.IsNaN(rot.s))
                    return;
                float dist = (float)llVecDist(llGetPos(), pos);

                if (dist > m_ScriptDistanceFactor * 10.0f)
                    return;

                //Clone is thread-safe
                TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone();

                foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory)
                {
                    if (inv.Value.Name == inventory)
                    {
                        // make sure we're an object.
                        if (inv.Value.InvType != (int)InventoryType.Object)
                        {
                            llSay(0, "Unable to create requested object. Object is missing from database.");
                            return;
                        }

                        Vector3 llpos = new Vector3((float)pos.x, (float)pos.y, (float)pos.z);
                        Vector3 llvel = new Vector3((float)vel.x, (float)vel.y, (float)vel.z);

                        // need the magnitude later
                        // float velmag = (float)Util.GetMagnitude(llvel);

                        SceneObjectGroup new_group = World.RezObject(m_host, inv.Value, llpos, Rot2Quaternion(rot), llvel, param);

                        // If either of these are null, then there was an unknown error.
                        if (new_group == null)
                            continue;

                        // objects rezzed with this method are die_at_edge by default.
                        new_group.RootPart.SetDieAtEdge(true);

                        new_group.ResumeScripts();

                        m_ScriptEngine.PostObjectEvent(m_host.LocalId, new EventParams(
                                "object_rez", new Object[] {
                                new LSL_String(
                                new_group.RootPart.UUID.ToString()) },
                                new DetectParams[0]));

                        float groupmass = new_group.GetMass();

                        PhysicsActor pa = new_group.RootPart.PhysActor;

                        if (pa != null && pa.IsPhysical && llvel != Vector3.Zero)
                        {
                            //Recoil.
                            llApplyImpulse(new LSL_Vector(llvel.X * groupmass, llvel.Y * groupmass, llvel.Z * groupmass), 0);
                        }
                        // Variable script delay? (see (http://wiki.secondlife.com/wiki/LSL_Delay)
                        return;
                    }
                }

                llSay(0, "Could not find object " + inventory);
            });

            //ScriptSleep((int)((groupmass * velmag) / 10));
            ScriptSleep(100);
        }
开发者ID:OpenPlex-Sim,项目名称:opensim,代码行数:70,代码来源:LSL_Api.cs


示例8: SitTarget

        protected void SitTarget(SceneObjectPart part, LSL_Vector offset, LSL_Rotation rot)
        {
            // LSL quaternions can normalize to 0, normal Quaternions can't.
            if (rot.s == 0 && rot.x == 0 && rot.y == 0 && rot.z == 0)
                rot.z = 1; // ZERO_ROTATION = 0,0,0,1

            part.SitTargetPosition = new Vector3((float)offset.x, (float)offset.y, (float)offset.z);
            part.SitTargetOrientation = Rot2Quaternion(rot);
            part.ParentGroup.HasGroupChanged = true;
        }
开发者ID:OpenPlex-Sim,项目名称:opensim,代码行数:10,代码来源:LSL_Api.cs


示例9: Rot2Quaternion

 // convert a LSL_Rotation to a Quaternion
 public static Quaternion Rot2Quaternion(LSL_Rotation r)
 {
     Quaternion q = new Quaternion((float)r.x, (float)r.y, (float)r.z, (float)r.s);
     q.Normalize();
     return q;
 }
开发者ID:OpenPlex-Sim,项目名称:opensim,代码行数:7,代码来源:LSL_Api.cs


示例10: llRotLookAt

        public void llRotLookAt(LSL_Rotation target, double strength, double damping)
        {
            m_host.AddScriptLPS(1);
            
            // Per discussion with Melanie, for non-physical objects llLookAt appears to simply
            // set the rotation of the object, copy that behavior
            PhysicsActor pa = m_host.PhysActor;

            if (strength == 0 || pa == null || !pa.IsPhysical)
            {
                llSetLocalRot(target);
            }
            else
            {
                m_host.RotLookAt(Rot2Quaternion(target), (float)strength, (float)damping);
            }
        }
开发者ID:OpenPlex-Sim,项目名称:opensim,代码行数:17,代码来源:LSL_Api.cs


示例11: modInvokeL

        public LSL_List modInvokeL(string fname, params object[] parms)
        {
            Type returntype = m_comms.LookupReturnType(fname);
            if (returntype != typeof(object[]))
                MODError(String.Format("return type mismatch for {0}",fname));

            object[] result = (object[])modInvoke(fname,parms);
            object[] llist = new object[result.Length];
            for (int i = 0; i < result.Length; i++)
            {
                if (result[i] is string)
                {
                    llist[i] = new LSL_String((string)result[i]);
                }
                else if (result[i] is int)
                {
                    llist[i] = new LSL_Integer((int)result[i]);
                }
                else if (result[i] is float)
                {
                    llist[i] = new LSL_Float((float)result[i]);
                }
                else if (result[i] is UUID)
                {
                    llist[i] = new LSL_Key(result[i].ToString());
                }
                else if (result[i] is OpenMetaverse.Vector3)
                {
                    OpenMetaverse.Vector3 vresult = (OpenMetaverse.Vector3)result[i];
                    llist[i] = new LSL_Vector(vresult.X, vresult.Y, vresult.Z);
                }
                else if (result[i] is OpenMetaverse.Quaternion)
                {
                    OpenMetaverse.Quaternion qresult = (OpenMetaverse.Quaternion)result[i];
                    llist[i] = new LSL_Rotation(qresult.X, qresult.Y, qresult.Z, qresult.W);
                }
                else
                {
                    MODError(String.Format("unknown list element {1} returned by {0}", fname, result[i].GetType().Name));
                }
            }

            return new LSL_List(llist);
        }
开发者ID:p07r0457,项目名称:opensim,代码行数:44,代码来源:MOD_Api.cs


示例12: llRotLookAt

 public void llRotLookAt(LSL_Rotation target, double strength, double damping)
 {
     m_LSL_Functions.llRotLookAt(target, strength, damping);
 }
开发者ID:p07r0457,项目名称:opensim,代码行数:4,代码来源:LSL_Stub.cs


示例13: DropAttachmentAt

        protected void DropAttachmentAt(bool checkPerms, LSL_Vector pos, LSL_Rotation rot)
        {
            if (checkPerms && ShoutErrorOnLackingOwnerPerms(ScriptBaseClass.PERMISSION_ATTACH, "Cannot drop attachment"))
            {
                return;
            }

            IAttachmentsModule attachmentsModule = m_ScriptEngine.World.AttachmentsModule;
            ScenePresence sp = attachmentsModule == null ? null : m_host.ParentGroup.Scene.GetScenePresence(m_host.ParentGroup.OwnerID);

            if (attachmentsModule != null && sp != null)
            {
                attachmentsModule.DetachSingleAttachmentToGround(sp, m_host.ParentGroup.LocalId, pos, rot);
            }
        }
开发者ID:nebadon2025,项目名称:opensimulator,代码行数:15,代码来源:OSSL_Api.cs


示例14: osForceDropAttachmentAt

        public void osForceDropAttachmentAt(LSL_Vector pos, LSL_Rotation rot)
        {
            CheckThreatLevel(ThreatLevel.High, "osForceDropAttachmentAt");
            m_host.AddScriptLPS(1);

            DropAttachmentAt(false, pos, rot);
        }
开发者ID:nebadon2025,项目名称:opensimulator,代码行数:7,代码来源:OSSL_Api.cs


示例15: llSitTarget

 public void llSitTarget(LSL_Vector offset, LSL_Rotation rot)
 {
     m_host.AddScriptLPS(1);
     SitTarget(m_host, offset, rot);
 }
开发者ID:OpenPlex-Sim,项目名称:opensim,代码行数:5,代码来源:LSL_Api.cs


示例16: llRotBetween

 public LSL_Rotation llRotBetween(LSL_Vector a, LSL_Vector b)
 {
     //A and B should both be normalized
     m_host.AddScriptLPS(1);
     LSL_Rotation rotBetween;
     // Check for zero vectors. If either is zero, return zero rotation. Otherwise,
     // continue calculation.
     if (a == new LSL_Vector(0.0f, 0.0f, 0.0f) || b == new LSL_Vector(0.0f, 0.0f, 0.0f))
     {
         rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
     }
     else
     {
         a = LSL_Vector.Norm(a);
         b = LSL_Vector.Norm(b);
         double dotProduct = LSL_Vector.Dot(a, b);
         // There are two degenerate cases possible. These are for vectors 180 or
         // 0 degrees apart. These have to be detected and handled individually.
         //
         // Check for vectors 180 degrees apart.
         // A dot product of -1 would mean the angle between vectors is 180 degrees.
         if (dotProduct < -0.9999999f)
         {
             // First assume X axis is orthogonal to the vectors.
             LSL_Vector orthoVector = new LSL_Vector(1.0f, 0.0f, 0.0f);
             orthoVector = orthoVector - a * (a.x / LSL_Vector.Dot(a, a));
             // Check for near zero vector. A very small non-zero number here will create
             // a rotation in an undesired direction.
             if (LSL_Vector.Mag(orthoVector) > 0.0001)
             {
                 rotBetween = new LSL_Rotation(orthoVector.x, orthoVector.y, orthoVector.z, 0.0f);
             }
             // If the magnitude of the vector was near zero, then assume the X axis is not
             // orthogonal and use the Z axis instead.
             else
             {
                 // Set 180 z rotation.
                 rotBetween = new LSL_Rotation(0.0f, 0.0f, 1.0f, 0.0f);
             }
         }
         // Check for parallel vectors.
         // A dot product of 1 would mean the angle between vectors is 0 degrees.
         else if (dotProduct > 0.9999999f)
         {
             // Set zero rotation.
             rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
         }
         else
         {
             // All special checks have been performed so get the axis of rotation.
             LSL_Vector crossProduct = LSL_Vector.Cross(a, b);
             // Quarternion s value is the length of the unit vector + dot product.
             double qs = 1.0 + dotProduct;
             rotBetween = new LSL_Rotation(crossProduct.x, crossProduct.y, crossProduct.z, qs);
             // Normalize the rotation.
             double mag = LSL_Rotation.Mag(rotBetween);
             // We shouldn't have to worry about a divide by zero here. The qs value will be
             // non-zero because we already know if we're here, then the dotProduct is not -1 so
             // qs will not be zero. Also, we've already handled the input vectors being zero so the
             // crossProduct vector should also not be zero.
             rotBetween.x = rotBetween.x / mag;
             rotBetween.y = rotBetween.y / mag;
             rotBetween.z = rotBetween.z / mag;
             rotBetween.s = rotBetween.s / mag;
             // Check for undefined values and set zero rotation if any found. This code might not actually be required
             // any longer since zero vectors are checked for at the top.
             if (Double.IsNaN(rotBetween.x) || Double.IsNaN(rotBetween.y) || Double.IsNaN(rotBetween.z) || Double.IsNaN(rotBetween.s))
             {
                 rotBetween = new LSL_Rotation(0.0f, 0.0f, 0.0f, 1.0f);
             }
         }
     }
     return rotBetween;
 }
开发者ID:OpenPlex-Sim,项目名称:opensim,代码行数:74,代码来源:LSL_Api.cs


示例17: llAngleBetween

        // jcochran 5/jan/2012
        public LSL_Float llAngleBetween(LSL_Rotation a, LSL_Rotation b)
        {
            m_host.AddScriptLPS(1);

            double aa = (a.x * a.x + a.y * a.y + a.z * a.z + a.s * a.s);
            double bb = (b.x * b.x + b.y * b.y + b.z * b.z + b.s * b.s);
            double aa_bb = aa * bb;
            if (aa_bb == 0) return 0.0;
            double ab = (a.x * b.x + a.y * b.y + a.z * b.z + a.s * b.s);
            double quotient = (ab * ab) / aa_bb;
            if (quotient >= 1.0) return 0.0;
            return Math.Acos(2 * quotient - 1);
        }
开发者ID:OpenPlex-Sim,项目名称:opensim,代码行数:14,代码来源:LSL_Api.cs


示例18: llAngleBetween

 public LSL_Float llAngleBetween(LSL_Rotation a, LSL_Rotation b)
 {
     return m_LSL_Functions.llAngleBetween(a, b);
 }
开发者ID:p07r0457,项目名称:opensim,代码行数:4,代码来源:LSL_Stub.cs


示例19: llSitTarget

 public void llSitTarget(LSL_Vector offset, LSL_Rotation rot)
 {
     m_LSL_Functions.llSitTarget(offset, rot);
 }
开发者ID:p07r0457,项目名称:opensim,代码行数:4,代码来源:LSL_Stub.cs


示例20: llLinkSitTarget

 public void llLinkSitTarget(LSL_Integer link, LSL_Vector offset, LSL_Rotation rot)
 {
     m_LSL_Functions.llLinkSitTarget(link, offset, rot);
 }
开发者ID:p07r0457,项目名称:opensim,代码行数:4,代码来源:LSL_Stub.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# LSL_Types.Vector3类代码示例发布时间:2022-05-24
下一篇:
C# LSL_Types.LSLString类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap