Exemple #1
0
        private float animateArrestingWire(SceneNode arrestingWire, float targetWorldXPos)
        {
            float     lastH;
            SceneNode lWire = (SceneNode)arrestingWire.GetChild(0);
            SceneNode rWire = (SceneNode)arrestingWire.GetChild(1);
            SceneNode temp;

            // fix zamienione nody
            if (rWire.Name.StartsWith(name + "_LArrestingWire"))
            {
                temp  = lWire;
                lWire = rWire;
                rWire = temp;
            }

            lastH = lWire._getDerivedPosition().x - targetWorldXPos;
            Radian alpha  = Math.ATan(lastH / (0.5f * arrestingWiresSpan)); // k¹t wychylenia kawalkow liny
            float  length = lastH / Math.Sin(alpha);                        // dlugosc liny

            lWire.Orientation  = new Quaternion(Math.HALF_PI, Vector3.UNIT_X);
            lWire.Orientation *= new Quaternion(Math.HALF_PI, Vector3.UNIT_Z);
            lWire.Orientation *= new Quaternion(alpha, Vector3.NEGATIVE_UNIT_Z);
            lWire.SetScale(1, length, 1);

            rWire.Orientation  = new Quaternion(Math.HALF_PI, Vector3.UNIT_X);
            rWire.Orientation *= new Quaternion(Math.HALF_PI, Vector3.NEGATIVE_UNIT_Z);
            rWire.Orientation *= new Quaternion(alpha, Vector3.UNIT_Z);
            rWire.SetScale(1, length, 1);

            return(lastH);
        }
 //--------------------------------------------------------------
 public void modify()
 {
     if (mInputTriangleBuffer == null)
     {
         OGRE_EXCEPT("Exception::ERR_INVALID_STATE", "Input triangle buffer must be set", "__FUNCTION__");
     }
     ;
     //for (List<TriangleBuffer.Vertex>.Enumerator it = mInputTriangleBuffer.getVertices().begin(); it != mInputTriangleBuffer.getVertices().end(); ++it)
     foreach (var it in mInputTriangleBuffer.getVertices())
     {
         Vector3 v   = it.mPosition.NormalisedCopy;
         Vector2 vxz = new Vector2(v.x, v.z);
         it.mUV.x = Utils.angleTo(Vector2.UNIT_X, vxz).ValueRadians / Math.TWO_PI;
         it.mUV.y = (Math.ATan(v.y / vxz.Length).ValueRadians + Math.HALF_PI) / Math.PI;
     }
 }
        //--------------------------------------------------------------
        public void modify()
        {
            if (mInputTriangleBuffer == null)
            {
                OGRE_EXCEPT("Exception::ERR_INVALID_STATE", "Input triangle buffer must be set", "__FUNCTION__");
            }
            if (mHeight <= 0f)
            {
                OGRE_EXCEPT("Exception::ERR_INVALID_STATE", "Height must be strictly positive", "__FUNCTION__");
            }
            if (mRadius <= 0f)
            {
                OGRE_EXCEPT("Exception::ERR_INVALID_STATE", "Radius must be strictly positive", "__FUNCTION__");
            }
            ;

            float angleThreshold = Math.ATan(mHeight / mRadius).ValueRadians;

            //for (List<TriangleBuffer.Vertex>.Enumerator it = mInputTriangleBuffer.getVertices().begin(); it != mInputTriangleBuffer.getVertices().end(); ++it)
            foreach (var it in mInputTriangleBuffer.getVertices())
            {
                Vector2 nxz   = new Vector2(it.mNormal.x, it.mNormal.z);
                float   alpha = (Math.ATan(it.mNormal.y / nxz.Length).ValueRadians + Math.HALF_PI);
                if (Math.Abs(alpha) > angleThreshold)
                {
                    Vector2 vxz = new Vector2(it.mPosition.x, it.mPosition.z);
                    it.mUV = vxz / mRadius;
                }
                else
                {
                    Vector2 vxz = new Vector2(it.mPosition.x, it.mPosition.z);
                    it.mUV.x = Utils.angleTo(Vector2.UNIT_X, vxz).ValueRadians / Math.TWO_PI;
                    it.mUV.y = it.mPosition.y / mHeight - 0.5f;
                }
            }
        }