コード例 #1
0
 public void AddNewBoid(Boid boid)
 {
     //return;
     try
     {
         SceneNode boidNode = base.sceneMgr.RootSceneNode.CreateChildSceneNode("Node" + count);
         //Entity boidEntity = base.sceneMgr.CreateEntity("Boid"+count, "myBoid_" + boid.Color);
         //boidNode.AttachObject(boidEntity);
         ManualObject boidObj = BoidMesh.CreateBoidObject("Boid" + count, base.sceneMgr, boid.Color);
         boidNode.AttachObject(boidObj);
         boidNodesList.Add(boidNode);
         MoveBoid(boidNode, boid);
         count++;
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
コード例 #2
0
ファイル: BoidsSample.cs プロジェクト: superliujian/Sxta
 public void AddNewBoid(Boid boid)
 {
     //return;
     try
     {
         SceneNode boidNode = base.sceneMgr.RootSceneNode.CreateChildSceneNode("Node" + count);
         //Entity boidEntity = base.sceneMgr.CreateEntity("Boid"+count, "myBoid_" + boid.Color);
         //boidNode.AttachObject(boidEntity);
         ManualObject boidObj = BoidMesh.CreateBoidObject("Boid" + count, base.sceneMgr, boid.Color);
         boidNode.AttachObject(boidObj);
         boidNodesList.Add(boidNode);
         MoveBoid(boidNode, boid);
         count++;
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
     }
 }
コード例 #3
0
        /// <summary>
        /// Boid movement is a rotation and a translation, which use
        /// the current boid velocity and position.
        /// </summary>
        private void MoveBoid(SceneNode boidNode, Boid b)
        {
            boidNode.Position = b.Position;
            Vector3 direction = b.Velocity;

            direction.Normalise();
            // Test for opposite vectors
            float d = 1.0f + Vector3.UNIT_Z.DotProduct(direction);

            if (System.Math.Abs(d) < 0.00001)
            {
                // Diametrically opposed vectors
                Quaternion orientation = new Quaternion();
                orientation.FromAxes(Vector3.NEGATIVE_UNIT_X,
                                     Vector3.UNIT_Y,
                                     Vector3.NEGATIVE_UNIT_Z);
                boidNode.Orientation = orientation;
            }
            else
            {
                boidNode.Orientation =
                    Vector3.UNIT_Z.GetRotationTo(direction);
            }
        }
コード例 #4
0
ファイル: BoidsSample.cs プロジェクト: superliujian/Sxta
 /// <summary>
 /// Boid movement is a rotation and a translation, which use
 /// the current boid velocity and position.
 /// </summary>
 private void MoveBoid(SceneNode boidNode, Boid b)
 {
     boidNode.Position = b.Position;
     Vector3 direction = b.Velocity;
     direction.Normalise();
     // Test for opposite vectors
     float d = 1.0f + Vector3.UNIT_Z.DotProduct(direction);
     if (System.Math.Abs(d) < 0.00001)
     {
         // Diametrically opposed vectors
         Quaternion orientation = new Quaternion();
         orientation.FromAxes(Vector3.NEGATIVE_UNIT_X,
                              Vector3.UNIT_Y,
                              Vector3.NEGATIVE_UNIT_Z);
         boidNode.Orientation = orientation;
     }
     else
     {
         boidNode.Orientation =
             Vector3.UNIT_Z.GetRotationTo(direction);
     }
 }