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


C# Entity.GetMesh方法代码示例

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


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

示例1: CreateActorDesc

        public ActorDesc CreateActorDesc(EntityWorldEntity entityNode, Entity entity, Vector3 position, Quaternion orientation, Vector3 scale)
        {
            ActorDesc actorDesc = new ActorDesc();
            actorDesc.GlobalPosition = position;
            actorDesc.GlobalOrientation = orientation.ToRotationMatrix();

            if (entityNode.CollisionMode == CollisionMode.ConvexHull || entityNode.CollisionMode == CollisionMode.TriangleMesh)
            {
                StaticMeshData meshData = new StaticMeshData(entity.GetMesh(), scale);

                if (entityNode.CollisionMode == CollisionMode.TriangleMesh)
                    actorDesc.Shapes.Add(Engine.Physics.CreateTriangleMesh(meshData));
                else
                    actorDesc.Shapes.Add(Engine.Physics.CreateConvexHull(meshData));
            }
            else
            {
                switch (entityNode.CollisionMode)
                {
                    case CollisionMode.BoundingBox:
                        actorDesc.Shapes.Add(new BoxShapeDesc(entity.BoundingBox.HalfSize * scale, entity.BoundingBox.Center * scale));
                        break;
                    case CollisionMode.BoundingSphere:
                        actorDesc.Shapes.Add(new SphereShapeDesc(Engine.MaxAxis(entity.BoundingBox.HalfSize), entity.BoundingBox.Center * scale));
                        break;
                    case CollisionMode.Shapes:
                        foreach (ShapeDesc shapeDesc in entityNode.Shapes)
                            actorDesc.Shapes.Add(shapeDesc);
                        break;
                    default:
                        throw new Exception(entityNode.CollisionMode.ToString() + " not implemented");
                }
            }

            return actorDesc;
        }
开发者ID:andyhebear,项目名称:glueeengine,代码行数:36,代码来源:PhysicsManager.cs

示例2: SetViewModel

        public List<String> SetViewModel(String _model)
        {
            String nameOnly = Path.GetFileNameWithoutExtension(_model);
            String filename = Path.GetFileName(_model);
            String modelDir = Path.GetDirectoryName(_model);

            AddResourcesDirectory(nameOnly, modelDir);

            if (sceneMgr.HasEntity(nameOnly))
                sceneMgr.DestroyEntity(nameOnly);

            modelEntity = sceneMgr.CreateEntity(nameOnly, filename, nameOnly);

            if (sceneMgr.HasSceneNode(MODEL_NODE))
                sceneMgr.DestroySceneNode(MODEL_NODE);

            modelNode = sceneMgr.RootSceneNode.CreateChildSceneNode(MODEL_NODE);
            modelNode.SetInitialState();

            modelNode.DetachAllObjects();
            modelNode.AttachObject(modelEntity);

            // check for material textures
            foreach (var subMesh in modelEntity.GetMesh().GetSubMeshIterator())
            {
                bool needsReload = false;
                var matPtr = (MaterialPtr)MaterialManager.Singleton.GetByName(subMesh.MaterialName);
                if (matPtr != null)
                {
                    foreach (var mtrPass in matPtr.GetTechnique(0).GetPassIterator())
                    {
                        foreach (var mtrTex in mtrPass.GetTextureUnitStateIterator())
                        {
                            if (mtrTex.IsTextureLoadFailing)
                            {
                                mtrTex.SetTextureName(mtrTex.TextureName.Replace(".png", ".dds"));
                                needsReload = true;
                            }
                        }
                    }
                }
                if (needsReload) matPtr.Reload();
            }

            //if (modelEntity.HasSkeleton)
            //{
            //    foreach (String skltFiles in Directory.GetFiles(modelDir, "*.skeleton"))
            //    {
            //        try
            //        {
            //            SkeletonPtr source = SkeletonManager.Singleton.Load(Path.GetFileName(skltFiles), "General");
            //            Skeleton.BoneHandleMap boneHandleMap = new Skeleton.BoneHandleMap();
            //            source._buildMapBoneByHandle(source, boneHandleMap);
            //            modelEntity.Skeleton._mergeSkeletonAnimations(source, boneHandleMap);
            //            modelEntity.Skeleton._refreshAnimationState(modelEntity.AllAnimationStates);
            //        }
            //        catch { }
            //    }
            //    modelEntity.DisplaySkeleton = true;
            //}

            SetInitialCamera(modelEntity, modelNode);

            if (sceneMgr.HasLight("SimpleLight"))
                sceneMgr.DestroyLight("SimpleLight");

            Light light = sceneMgr.CreateLight("SimpleLight");
            sceneMgr.RootSceneNode.AttachObject(light);
            light.DiffuseColour = new ColourValue(1f, 1f, 1f);
            light.Position = this.camera.Position;
            light.Direction = this.camera.Direction;

            return GetAnimationNames(modelEntity);
        }
开发者ID:realmzero,项目名称:RZModelViewer,代码行数:74,代码来源:OgreWindow.cs

示例3: LoadModelElements

        /// <summary>
        /// This method loads the nodes and entities needed by the compound model
        /// </summary>
        protected override void LoadModelElements()
        {
            hullGroup = mSceneMgr.CreateSceneNode();
            wheelGroup = mSceneMgr.CreateSceneNode();
            gunGroup = mSceneMgr.CreateSceneNode();

            mainHull = mSceneMgr.CreateSceneNode();
            hullEntity = mSceneMgr.CreateEntity("Main.mesh");
            hullEntity.GetMesh().BuildEdgeList();

            sphere = mSceneMgr.CreateSceneNode();
            sphereEntity = mSceneMgr.CreateEntity("Sphere.mesh");
            sphereEntity.GetMesh().BuildEdgeList();

            powerCells = mSceneMgr.CreateSceneNode();
            powerCellsEntity = mSceneMgr.CreateEntity("PowerCells.mesh");
            powerCellsEntity.GetMesh().BuildEdgeList();

            model = mSceneMgr.CreateSceneNode();

            float radius = 50;
            model.Position += radius * Vector3.UNIT_Y;
            hullGroup.Position -= radius * Vector3.UNIT_Y;

            physObj = new PhysObj(radius, "PlayerModel", 0.1f, 0.21f, 0.1f);
            physObj.SceneNode = model;
            physObj.Position = model.Position;
            physObj.AddForceToList(new WeightForce(physObj.InvMass));
            physObj.AddForceToList(new FrictionForce(physObj));
            Physics.AddPhysObj(physObj);
        }
开发者ID:Bobbylon5,项目名称:Mogre14,代码行数:34,代码来源:PlayerModel.cs

示例4: FillData

        public void FillData(string _filename, ref Entity _entity)
        {
            filename = _filename;
              entity = _entity;
              components = new List<ModelComponent>();

              ModelComponent m;
              Pass p;
              String foundPath = "";
              FileInfoListPtr fileInfos;
              FileInfoList.Iterator it;

              Mesh.Const_SubMeshNameMap map = entity.GetMesh().GetSubMeshNameMap();
              for (uint i = 0; i < map.Count; i++)
              {
            for (Mesh.Const_SubMeshNameMap.ConstIterator start = map.Begin();
              start != map.End(); start++)
            {
              if (start.Value == i)
              {
            // Name
            m = new ModelComponent(start.Key);

            // SubEntity
            m.SubEntity = entity.GetSubEntity(start.Key);

            // Type (Button, Joystick, Body?)
            if(start.Key.Contains("Button") ||
              start.Key.Contains("Plunger") ||
              start.Key.Contains("Cylinder"))
              m.Type = FragmentType.BUTTON;
            else if(start.Key.Contains("Balltop") ||
              start.Key.Contains("Shaft") ||
              start.Key.Contains("Dust"))
              m.Type = FragmentType.JOYSTICK;
            else
              m.Type = FragmentType.MODEL;

            //m.Parent =;

            // Texture
            p = m.SubEntity.GetMaterial().GetBestTechnique().GetPass(0);
            if(p.NumTextureUnitStates > 0)
            {
              // Set the texture
              m.Texture = TextureManager.Singleton.GetByName(p.GetTextureUnitState(0).TextureName);
              // Get a bitmap version to display
              foundPath = m.Texture.Name;
              fileInfos = ResourceGroupManager.Singleton.FindResourceFileInfo("General", foundPath );
              it = fileInfos.Begin();
              if(it != fileInfos.End())
                 foundPath = it.Value.archive.Name + "/" + foundPath;
              else
                 foundPath = "";
              m.TextureImage = new Bitmap(foundPath);
            }
            else
            {
              m.Texture = null;
              // TODO: Put in a no texture image
              m.TextureImage = null;
            }

            // Color
            m.Color = Color.White;

            components.Add(m);
            break;
              }
            }
              }
        }
开发者ID:aczarno,项目名称:StickMagik,代码行数:72,代码来源:ArcadeStickData.cs

示例5: LoadModel

            public bool LoadModel(string modelPath)
            {
                mainStick = sceneMgr.CreateEntity("Stick", modelPath);
                mainStick.CastShadows = true;
                SceneNode node = sceneMgr.RootSceneNode.CreateChildSceneNode("StickNode");
                node.AttachObject(mainStick);
                node.Position = new Mogre.Vector3(0, 10, 0);
                //node.Rotate(Mogre.Vector3.UNIT_X, Mogre.Math.PI);
                //node.Rotate(Mogre.Vector3.UNIT_Y, Mogre.Math.PI);

                ArcadeStickData.Instance.FillData(modelPath, ref mainStick);
                Mesh.Const_SubMeshNameMap map = mainStick.GetMesh().GetSubMeshNameMap();
                ModelComponent frag;
                for (uint i = 0; i < map.Count; i++)
                {
                  for (Mesh.Const_SubMeshNameMap.ConstIterator start = map.Begin();
                start != map.End(); start++)
                  {
                if (start.Value == i)
                {
                  frag = new ModelComponent(start.Key);
                  Messenger<ModelComponent>.Broadcast("AddFragment", frag);
                  break;
                }
                  }

                }
                return true;
            }
开发者ID:aczarno,项目名称:StickMagik,代码行数:29,代码来源:OgreForm.cs


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