コード例 #1
1
 public ExplosionOnSurface(MeshObject[] stages, Vector3 incRotationEarth)
 {
     Stages = stages;
     IncRotationEarth = incRotationEarth;
     CurrentStages = new List<int>();
     ExplosionsTurns = new List<Vector3>();
 }
コード例 #2
0
        ///////////////////////////////////////////

        public MeshObjectAnimationController(MeshObject meshObject, float blendingTime)
        {
            activeItemsAsReadOnly = new ReadOnlyCollection <AnimationItem>(activeItems);

            this.meshObject   = meshObject;
            this.blendingTime = blendingTime;
        }
コード例 #3
0
    public static MeshObject Circle(MeshObject parent = null)
    {
        if (parent == null)
        {
            parent = new MeshObject(MeshEdit.meshFilter);
        }
        List <Vertex> defaultVertices = new List <Vertex> {
        };
        int res = 24;

        for (int i = 1; i <= res; i++)
        {
            //float sinV = Mathf.Sin(1f * v / resV * Mathf.PI);
            float x = Mathf.Sin(1f * i / res * 2 * Mathf.PI); // * sinV;
            //float y = Mathf.Cos(1f * v / resV * Mathf.PI);
            float z = Mathf.Cos(1f * i / res * 2 * Mathf.PI); // * sinV;
            defaultVertices.Add(new Vertex(x, 0, z, parent));
        }
        List <Face> defaultFaces = new List <Face> {
            new Face(defaultVertices, parent)
        };

        parent.verts.AddRange(defaultVertices);
        parent.faces.AddRange(defaultFaces);

        parent.selVerts = new HashSet <Vertex>(defaultVertices);
        parent.selFaces = new HashSet <Face>(defaultFaces);

        return(parent);
    }
コード例 #4
0
    public static MeshObject Plane(MeshObject parent = null)
    {
        if (parent == null)
        {
            parent = new MeshObject(MeshEdit.meshFilter);
        }
        List <Vertex> defaultVertices = new List <Vertex>
        {
            new Vertex(-1, 0, -1, parent),
            new Vertex(-1, 0, 1, parent),
            new Vertex(1, 0, 1, parent),
            new Vertex(1, 0, -1, parent)
        };
        List <Face> defaultFaces = new List <Face>
        {
            new Face(defaultVertices, parent)
        };

        parent.verts.AddRange(defaultVertices);
        parent.faces.AddRange(defaultFaces);

        parent.selVerts = new HashSet <Vertex>(defaultVertices);
        parent.selFaces = new HashSet <Face>(defaultFaces);

        return(parent);
    }
コード例 #5
0
        public override MeshObject GetMesh()
        {
            var vertices = new Renderer.VertexDataStruct[]
            {
                new Renderer.VertexDataStruct()
                {
                    position = new Vector4(_ray.Position, 1),
                    color    = Vector4.One,
                },

                new Renderer.VertexDataStruct()
                {
                    position = new Vector4(_ray.Direction + _ray.Position, 1),
                    color    = Vector4.One,
                },
            };

            var indices = new uint[]
            {
                0,
                1,
            };

            var result = new MeshObject(
                DirectX3DGraphics.GetInstance(),
                vertices,
                indices,
                PrimitiveTopology.LineList,
                new Material(null, Vector3.Zero, Vector3.One, Vector3.One, Vector3.One, 1),
                true, "", false);

            return(result);
        }
コード例 #6
0
        public PhysicalObject Clone()
        {
            PhysicalObject po = (PhysicalObject)MemberwiseClone();

            po.visualSet = new List <VisualSetLOD>();
            po.Reset();
            for (int i = 0; i < visualSet.Count; i++)
            {
                VisualSetLOD l = new VisualSetLOD();
                l.LODdistance = visualSet[i].LODdistance;
                l.off_data    = visualSet[i].off_data;
                l.obj         = visualSet[i].obj.Clone();
                po.visualSet.Add(l);
                if (l.obj is MeshObject)
                {
                    MeshObject m = ((MeshObject)l.obj);
                    if (m.name != "Mesh")
                    {
                        po.Gao.name = "[PO] " + m.name;
                    }
                    m.gao.transform.parent = po.Gao.transform;
                }
            }
            if (collideMesh != null)
            {
                po.collideMesh = collideMesh.Clone();
                po.collideMesh.gao.transform.parent = po.Gao.transform;
            }
            MapLoader.Loader.physicalObjects.Add(po);
            return(po);
        }
コード例 #7
0
 public void UpdateVertices(Vector3[] vertices = null, Vector2[] uvs = null,
                            Color[] colors     = null)
 {
     if (!MeshObject)
     {
         throw new InvalidOperationException(
                   "Mesh is not generated yet. Call GenerateMesh() first.");
     }
     if (vertices != null)
     {
         MeshObject.vertices = vertices;
     }
     if (uvs != null)
     {
         MeshObject.uv = uvs;
     }
     if (colors != null)
     {
         MeshObject.colors = colors;
     }
     if (vertices != null)
     {
         MeshObject.RecalculateBounds();
         MeshObject.RecalculateNormals();
         MeshObject.RecalculateTangents();
     }
     if (vertices != null || uvs != null || colors != null)
     {
         MeshObject.UploadMeshData(!_dynamicMesh);
     }
 }
コード例 #8
0
        private void DestroyGeometry()
        {
            if (collisionBody != null)
            {
                collisionBody.Dispose();
                collisionBody = null;
            }

            if (sceneNode != null)
            {
                sceneNode.Dispose();
                sceneNode = null;
            }

            if (meshObject != null)
            {
                meshObject.Dispose();
                meshObject = null;
            }

            if (mesh != null)
            {
                mesh.Dispose();
                mesh = null;
            }
        }
コード例 #9
0
        static public void Grid(Light2D light, LightTilemapCollider2D id)
        {
            if (id.superTilemapEditor.maskTypeSTE != SuperTilemapEditorSupport.TilemapCollider2D.MaskType.Grid)
            {
                return;
            }

            Vector2    lightPosition = -light.transform.position;
            MeshObject tileMesh      = LightingTile.Rectangle.GetStaticMesh();

            GL.Color(Color.white);

            LightTilemapCollider.Base tilemapBase = id.GetCurrentTilemap();

            foreach (LightingTile tile in id.superTilemapEditor.mapTiles)
            {
                Vector2 tilePosition = tile.GetWorldPosition(tilemapBase);
                tilePosition += lightPosition;

                if (tile.NotInRange(tilePosition, light.size))
                {
                    continue;
                }

                GLExtended.DrawMeshPass(tileMesh, tilePosition, tile.worldScale, tile.worldRotation);
            }
        }
コード例 #10
0
    void DrawCeil()
    {
        if (!capMode)
        {
            Vector3 offset, a, b, c, d;
            offset = new Vector3(-0.5f, 0, -0.5f) * scale;

            a = new Vector3(0, height * scale, 0);
            b = new Vector3(scale * size, height * scale, 0);
            c = new Vector3(0, height * scale, scale * size);
            d = new Vector3(scale * size, height * scale, scale * size);

            a += offset; b += offset; c += offset; d += offset;

            ceilMeshObject = new MeshObject(4 + 4 * 4, 2 * 3 + 3 * 2 * 4);
            ceilMeshObject.AddQuad(a, b, c, d);
            //ceilMeshObject.AddQuad(new Vector3(0, height, 0), new Vector3(1, height, 0), new Vector3(0, height, 1), new Vector3(1, height, scale));
        }
        else
        {
            grounds = new List <HallInfo>();
            GetGroundFromMap(true);
            ceilMeshObject = new MeshObject((grounds.Count * 4 + 4 * 4), grounds.Count * 2 * 3 + 3 * 2 * 4);
            AddCeilBorders();
            DrawGround(ref ceilMeshObject, height * scale);
        }
    }
コード例 #11
0
            /** MeshComponentWrapperから生成する */
            static public MeshObject generate(MeshComponentWrapper src)
            {
                var ret = new MeshObject()
                {
                    mesh   = src.mesh,
                    matLst = src.materials,
                    bones  = src.bones,

                    // ここ、不思議なんだけどどうやらスキンメッシュの場合は
                    // ヒエラルキを無視して自分自身のTransformのみを見て変形するようになっているっぽい。
                    // したがって、結合時にも自分自身の変換行列のみの影響を受けるようにする
                    l2wMtx =
                        src.bones.Length == 0 ? src.l2wMtx
                                        : MeshComponentWrapper.getLocalMtx(src.transform)
                };

                if (ret.mesh.subMeshCount < ret.matLst.Length)
                {
                    // マテリアルが必要より多く設定されている。
                    // この場合はマテリアルの一致判定は可能なため、正常な範囲にトリムするだけでOK。
                    // 逆にマテリアルが足りない場合はマテリアルの一致判定ができないため、
                    // 何もせずに流して後でエラーにする。
                    Array.Resize(ref ret.matLst, ret.mesh.subMeshCount);
                }
                return(ret);
            }
コード例 #12
0
        public override List <MeshObject> GetMeshes()
        {
            if (Meshes == null)
            {
                List <Polygon2> polygons = GetPolygonsLocal();

                if (polygons.Count > 0)
                {
                    Meshes = new List <MeshObject>();

                    foreach (Polygon2 poly in polygons)
                    {
                        if (poly.points.Length < 3)
                        {
                            continue;
                        }

                        Mesh mesh = PolygonTriangulator2.Triangulate(poly, Vector2.zero, Vector2.zero, PolygonTriangulator2.Triangulation.Advanced);

                        if (mesh)
                        {
                            MeshObject meshObject = MeshObject.Get(mesh);

                            if (meshObject != null)
                            {
                                Meshes.Add(meshObject);
                            }
                        }
                    }
                }
            }
            return(Meshes);
        }
コード例 #13
0
        private SsbhVertexAttribute[] ReadAttribute(MeshAttribute attr, int count, MeshObject meshObject)
        {
            if (attr == null)
            {
                return(new SsbhVertexAttribute[0]);
            }

            string attributeName = attr.AttributeStrings[0].Text;

            // TODO: There are optimizations possible for reading if the data is tighly packed.
            // The stride may not allow this.
            int offset = meshObject.VertexOffset;
            int stride = meshObject.Stride;

            if (attr.BufferIndex == 1)
            {
                offset = meshObject.VertexOffset2;
                stride = meshObject.Stride2;
            }

            SsbhVertexAttribute[] attributes = null;
            int attributeLength = GetAttributeComponentCount(attributeName);

            using (BinaryReader attributeBuffer = new BinaryReader(new MemoryStream(meshFile.VertexBuffers[attr.BufferIndex].Buffer)))
            {
                attributes = ReadAttribute(attr, count, attributeBuffer, offset, stride, attributeLength);
            }

            return(attributes);
        }
コード例 #14
0
        /// <summary>
        /// Returns the preview-meshes of the RhinoObject.
        /// TODO: Extend to handle sub-assigned materials returning a list of KV-pairs of meshes, materials.
        /// </summary>
        /// <param name="rhinoObject"></param>
        /// <returns></returns>
        public static Rhino.Geometry.Mesh[] GetMeshes(RhinoObject rhinoObject)
        {
            if (rhinoObject.ObjectType == ObjectType.Mesh)
            {
                MeshObject meshObj = rhinoObject as MeshObject;

                return(new Rhino.Geometry.Mesh[] { meshObj.MeshGeometry });
            }

            // Need to get a Mesh from the None-mesh object. Using the FastRenderMesh here. Could be made configurable.
            // First make sure the internal rhino mesh has been created
            rhinoObject.CreateMeshes(MeshType.Preview, MeshingParameters.FastRenderMesh, true);

            // Then get the internal rhino meshes
            Rhino.Geometry.Mesh[] meshes = rhinoObject.GetMeshes(MeshType.Preview);

            List <Rhino.Geometry.Mesh> validMeshes = new List <Mesh>();

            foreach (Rhino.Geometry.Mesh mesh in meshes)
            {
                if (MeshIsValidForExport(mesh))
                {
                    mesh.EnsurePrivateCopy();
                    validMeshes.Add(mesh);
                }
            }

            return(validMeshes.Count == 0 ? new Rhino.Geometry.Mesh[] { } : validMeshes.ToArray());
        }
コード例 #15
0
 public void Animate()
 {
     Sphere.Mesh.Move(-1 * SphereCenter);
     SphereCenter = MeshObject.RotateVector(SphereCenter, 0, -1 * MathF.PI / 32, 0);
     Sphere.Mesh.Move(SphereCenter);
     Cube.Mesh.Rotate(-1 * MathF.PI / 128, -1 * MathF.PI / 128, 0);
 }
コード例 #16
0
    private static IEnumerator WaitThenFinishRefresh(Mesh[] meshes, MeshObject[] meshObjects, int newMeshObjectCount, Vector3Int dimensions, Material material)
    {
        yield return(null);

        for (int i = 0; i < newMeshObjectCount; i++)
        {
            MeshObject meshObject = meshObjects[i];
            if (meshObject == null)
            {
                continue;
            }

            Mesh mesh = meshes[i];
            if (mesh == null)
            {
                Destroy(meshObjects[i].gameObject);
                continue;
            }

            meshObject.transform.name          = "MeshObject #" + i;
            meshObject.transform.localPosition = VoxelGrid.IndexToCoords(i, dimensions) * Bin.WIDTH;
            meshObject.SetMesh(meshes[i]);
            meshObject.SetMaterial(material);
        }
    }
コード例 #17
0
 public MeshIntersectionResult(IIntersectionResult intersectionResult, MeshObject meshObject)
 {
     IntersectionDistance = intersectionResult.IntersectionDistance;
     Intersection         = intersectionResult.Intersection;
     Object         = meshObject;
     TriangleObject = intersectionResult.Object as TriangleObject;
 }
コード例 #18
0
    /// <summary>
    /// Update constantly checks and once main has completed update object properties and revert physics.
    /// </summary>
    static void Update()
    {
        if (written && !EditorApplication.isPlaying)
        {
            //Set bool to false
            written = false;
            Debug.Log("updating");

            allObjects = UnityEngine.Object.FindObjectsOfType <GameObject>();
            // Populate mesh list
            foreach (GameObject obj in allObjects)
            {
                MeshFilter mf = obj.GetComponent(typeof(MeshFilter)) as MeshFilter;
                if (mf != null)
                {
                    MeshObject mobj = new MeshObject(obj);
                    meshObjects.Add(mobj);
                }
            }

            read_and_update_positions();

            //Revert properties
            foreach (MeshObject obj in meshObjects)
            {
                obj.prepare_physics_for_game();
            }
        }
    }
コード例 #19
0
        void CreateThreads()
        {
            for (int n = 1; ; n++)
            {
                MapObjectAttachedObject startObject = GetFirstAttachedObjectByAlias(string.Format("thread{0}Start", n));
                MapObjectAttachedObject endObject   = GetFirstAttachedObjectByAlias(string.Format("thread{0}End", n));
                if (startObject == null || endObject == null)
                {
                    break;
                }

                MeshObject meshObject = SceneManager.Instance.CreateMeshObject("Base\\Simple Models\\Box.mesh");
                if (meshObject == null)
                {
                    break;
                }

                meshObject.SetMaterialNameForAllSubObjects("Black");
                meshObject.CastShadows = true;

                ThreadItem item = new ThreadItem();
                item.startObject = startObject;
                item.endObject   = endObject;
                item.meshObject  = meshObject;
                item.sceneNode   = new SceneNode();
                item.sceneNode.Attach(item.meshObject);

                MapObject.AssociateSceneNodeWithMapObject(item.sceneNode, this);

                threads.Add(item);
            }

            UpdateThreads();
        }
コード例 #20
0
 public EnemyProjectile(MeshObject meshObject, Vector3 direction, float speed, float damage, bool poison) : base(meshObject)
 {
     this.direction = Vector3.Normalize(direction);
     this.speed     = speed;
     this.damage    = damage;
     this.poison    = poison;
 }
コード例 #21
0
        public PhysicalObject Clone()
        {
            PhysicalObject po = (PhysicalObject)MemberwiseClone();

            po.visualSet = new VisualSetLOD[visualSet.Length];
            po.Reset();
            for (int i = 0; i < visualSet.Length; i++)
            {
                po.visualSet[i].LODdistance = visualSet[i].LODdistance;
                po.visualSet[i].obj         = visualSet[i].obj.Clone();
                if (po.visualSet[i].obj is MeshObject)
                {
                    MeshObject m = ((MeshObject)po.visualSet[i].obj);
                    m.Gao.transform.parent = po.Gao.transform;
                }
            }
            if (po.visualSet.Length > 1)
            {
                float bestLOD = po.visualSet.Min(v => v.LODdistance);
                foreach (VisualSetLOD lod in po.visualSet)
                {
                    if (lod.obj.Gao != null && lod.LODdistance != bestLOD)
                    {
                        lod.obj.Gao.SetActive(false);
                    }
                }
            }
            if (collideMesh != null)
            {
                po.collideMesh = collideMesh.Clone();
                po.collideMesh.Gao.transform.parent = po.Gao.transform;
            }
            return(po);
        }
コード例 #22
0
        void UpdateMainMeshObjectMaterial()
        {
            if (mainMeshObject == null)
            {
                return;
            }

            MeshObject meshObject = mainMeshObject.MeshObject;

            if (meshObject == null)
            {
                return;
            }

            //FPSMeshMaterialName
            if (fpsMeshMaterialNameEnabled && !string.IsNullOrEmpty(Type.FPSMeshMaterialName))
            {
                meshObject.SetMaterialNameForAllSubObjects(Type.FPSMeshMaterialName);
                return;
            }

            //default materials
            Mesh mesh = meshObject.Mesh;

            for (int n = 0; n < meshObject.SubObjects.Length; n++)
            {
                if (n < mesh.SubMeshes.Length)
                {
                    meshObject.SubObjects[n].MaterialName = mesh.SubMeshes[n].MaterialName;
                }
            }
        }
コード例 #23
0
ファイル: SaveLoad.cs プロジェクト: Jcparkyn/Modellr
    public static void ExportOBJ(MeshObject mesh)
    {
        MeshObjectSerializable meshCopy = new MeshObjectSerializable(mesh);
        //StreamWriter writer = new StreamWriter(filePath + ".obj", false);
        //writer.
        StringBuilder exportText = new StringBuilder();

        foreach (VertexSerializable vert in meshCopy.vertices)
        {
            string line = $"v {vert.pos.x} {vert.pos.y} {vert.pos.z}";
            exportText.AppendLine(line);
        }
        foreach (FaceSerializable face in meshCopy.faces)
        {
            string line = $"f";
            foreach (int index in face.verts)
            {
                line += " " + (index + 1);
            }
            exportText.AppendLine(line);
        }
        byte[] objBytes = ASCIIEncoding.ASCII.GetBytes(exportText.ToString());
        DownloadFile(objBytes, objBytes.Length, "model.obj");
        //writer.Close();
    }
コード例 #24
0
ファイル: SaveLoad.cs プロジェクト: Jcparkyn/Modellr
    //Constructor to convert MeshObject to MeshObjectSerializable
    public MeshObjectSerializable(MeshObject mesh)
    {
        Dictionary <Vertex, int> vertIndices = new Dictionary <Vertex, int>(mesh.verts.Count);

        for (int i = 0; i < mesh.verts.Count; i++)
        {
            vertIndices.Add(mesh.verts[i], i);
        }
        Dictionary <Face, int> faceIndices = new Dictionary <Face, int>(mesh.faces.Count);

        for (int i = 0; i < mesh.faces.Count; i++)
        {
            faceIndices.Add(mesh.faces[i], i);
        }

        vertices = mesh.verts.Select(vert => new VertexSerializable(vert)).ToList();
        selVerts = mesh.selVerts.Select(vert => vertIndices[vert]).ToArray();
        selFaces = mesh.selFaces.Select(face => faceIndices[face]).ToArray();

        faces = new List <FaceSerializable>(mesh.faces.Count);
        foreach (Face face in mesh.faces)
        {
            FaceSerializable newFace = new FaceSerializable();
            newFace.verts = new int[face.Verts.Count];
            for (int i = 0; i < face.Verts.Count; i++)
            {
                newFace.verts[i] = vertIndices[face.Verts[i]];
            }
            faces.Add(newFace);
        }
    }
コード例 #25
0
        ///////////////////////////////////////////
        public MeshObjectAnimationController( MeshObject meshObject, float blendingTime )
        {
            activeItemsAsReadOnly = new ReadOnlyCollection<AnimationItem>( activeItems );

            this.meshObject = meshObject;
            this.blendingTime = blendingTime;
        }
コード例 #26
0
 public PlanetIndicator(MeshObject indicator, Vector2 pos)
 {
     Indicator = indicator;
     Rotate = true;
     Indicator.Pos = pos;
     Pos = pos;
     Indicator.AddTurn(new Vector3(0.4f, 0, 0));
 }
コード例 #27
0
        public Monster(MeshObject meshObject, float health, float damage) : base(meshObject)
        {
            this.health = health;
            this.damage = damage;

            behaviourState = BehaviourState.Idle;
            targetPosition = Position;
        }
コード例 #28
0
ファイル: GLExtended.cs プロジェクト: takdw00/Project_Empty
    public static void DrawMesh(MeshObject mesh, Vector3 position, Vector2 scale, float rotation)
    {
        GL.Begin(GL.TRIANGLES);

        DrawMeshPass(mesh, position, scale, rotation);

        GL.End();
    }
コード例 #29
0
ファイル: Face.cs プロジェクト: Jcparkyn/Modellr
 public Face(List <Vertex> v_, MeshObject parent_ = null)
 {
     if (parent_ == null)
     {
         parent_ = MeshEdit.selMesh;
     }
     Verts  = v_;
     parent = parent_;
 }
コード例 #30
0
        public override GameObject Load(BinaryReader reader)
        {
            MeshObject meshObject = MeshObject.Load(reader);
            Vector3    direction  = GameSave.ReadVector3(reader);
            float      speed      = reader.ReadSingle();
            float      damage     = reader.ReadSingle();

            return(new Projectile(meshObject, direction, speed, damage));
        }
コード例 #31
0
ファイル: NUMSHB_Node.cs プロジェクト: tateplayer/CrossMod
 private static void PrintAttributeInformation(MeshObject meshObject)
 {
     System.Diagnostics.Debug.WriteLine(meshObject.Name);
     foreach (var attribute in meshObject.Attributes)
     {
         System.Diagnostics.Debug.WriteLine($"{attribute.Name} {GetAttributeType(attribute)} Unk4: {attribute.Unk4_0} Unk5: {attribute.Unk5_0}");
     }
     System.Diagnostics.Debug.WriteLine("");
 }
コード例 #32
0
        public void ReplaceMesh(int factor = 6)
        {
            var sphereMesh = ProceduralSphere.GetSphereMesh(1f, 6);

            SphereCenter = new Vector3(0, 0, 3.5f);
            Sphere       = new MeshObject(sphereMesh, new OpaqueMaterial(1.2f, Color.Yellow, .8f, .5f));
            Sphere.Mesh.Move(SphereCenter);
            Scene.Objects[1] = Sphere;
        }
コード例 #33
0
ファイル: MeshCombiner.cs プロジェクト: Dracir/semicolon
 /// <summary>
 /// Creates MeshObject(s) from the passed MeshOutput(s).
 /// </summary>
 /// <returns>The created MeshObject(s).</returns>
 /// <param name="meshOutputs">The source MeshOutput(s) to use in creating the MeshObject(s).</param>
 /// <param name="instanceMaterials">If set to <c>true</c> materials will be instanced.</param>
 public MeshObject[] CreateMeshObjects(MeshOutput[] meshOutputs, bool instanceMaterials)
 {
     MeshObject[] meshObjects = new MeshObject[meshOutputs.Length];
     for (int i = 0; i < meshOutputs.Length; i++)
     {
         meshObjects [i] = CreateMeshObject(meshOutputs [i], instanceMaterials);
     }
     return(meshObjects);
 }
コード例 #34
0
ファイル: CaelumBaseMesh.cs プロジェクト: huytd/fosproject
        public override void Dispose()
        {
            base.Dispose();

            if (mMesh != null)
                mMesh.Dispose();

            mMesh = null;
        }
コード例 #35
0
ファイル: Planet.cs プロジェクト: GazarovVlad/TheGame
 //private bool placeOfRandomExplosion = true;
 public Planet(MeshObject earth, MeshObject clouds, Vector2 pos)
 {
     Planet2DRadius = Planet3DRadius * View.ConstCoef;
     Earth = earth;
     Clouds = clouds;
     Rotate = true;
     Pos = pos;
     //Pos = new Vector2(pos.X - PlanetRadius, pos.Y - PlanetRadius);
     Earth.Pos = Pos;
     Clouds.Pos = Pos;
     Explosions = new List<ExplosionOnSurface>();
     Craters = new List<CratersOnSurface>();
 }
コード例 #36
0
        protected override void OnBeginRenderLightmap(
			StaticLightingCalculationWorld.MeshObject meshObject, LightmapImage renderingImage )
        {
            lightmapMeshObject = meshObject;
            lightmapRenderingImage = renderingImage;
            lightmapBucketIndex = Vec2I.Zero;

            Vec2I textureSize = lightmapRenderingImage.Size;

            //generate lightmapTriangleMap
            {
                lightmapTriangleMap = new int[ textureSize.Y ][];
                for( int y = 0; y < textureSize.Y; y++ )
                {
                    lightmapTriangleMap[ y ] = new int[ textureSize.X ];
                    for( int x = 0; x < textureSize.X; x++ )
                        lightmapTriangleMap[ y ][ x ] = -1;
                }

                Mesh mesh = meshObject.Mesh;

                int triangleCount = mesh.Indices.Length / 3;
                for( int triangleIndex = 0; triangleIndex < triangleCount; triangleIndex++ )
                {
                    int index0 = mesh.Indices[ triangleIndex * 3 + 0 ];
                    int index1 = mesh.Indices[ triangleIndex * 3 + 1 ];
                    int index2 = mesh.Indices[ triangleIndex * 3 + 2 ];

                    Vec3 position0 = mesh.Positions[ index0 ];
                    Vec3 position1 = mesh.Positions[ index1 ];
                    Vec3 position2 = mesh.Positions[ index2 ];
                    if( MathUtils.IsDegenerateTriangle( position0, position1, position2 ) )
                        continue;

                    Vec2 texCoord0 = mesh.LightmapTexCoords[ index0 ];
                    Vec2 texCoord1 = mesh.LightmapTexCoords[ index1 ];
                    Vec2 texCoord2 = mesh.LightmapTexCoords[ index2 ];

                    Vec2I pixelIndex0 = GetPixelIndexByTexCoord( texCoord0 );
                    Vec2I pixelIndex1 = GetPixelIndexByTexCoord( texCoord1 );
                    Vec2I pixelIndex2 = GetPixelIndexByTexCoord( texCoord2 );

                    Geometry2D.FillTriangle( pixelIndex0, pixelIndex1, pixelIndex2,
                        new RectI( Vec2I.Zero, textureSize ), delegate( Vec2I point )
                        {
                            lightmapTriangleMap[ point.Y ][ point.X ] = triangleIndex;
                        } );
                }
            }
        }
コード例 #37
0
        /// <summary>Overridden from <see cref="Engine.EntitySystem.Entity.OnPostCreate(Boolean)"/>.</summary>
        protected override void OnPostCreate( bool loaded )
        {
            base.OnPostCreate( loaded );

            //To find the first attached mesh
            foreach( MapObjectAttachedObject attachedObject in AttachedObjects )
            {
                MapObjectAttachedMesh attachedMesh = attachedObject as MapObjectAttachedMesh;
                if( attachedMesh != null )
                {
                    blinkMeshObject = attachedMesh.MeshObject;
                    break;
                }
            }

            //To save the original name of a material
            if( blinkMeshObject != null )
                originalMaterialName = blinkMeshObject.SubObjects[ 0 ].MaterialName;
        }
コード例 #38
0
ファイル: CaelumBaseMesh.cs プロジェクト: huytd/fosproject
        /// <summary>
        /// Creates the element in the world. It automatically
        /// sets up the mesh and the node.</summary>
        protected virtual void Initialise(RenderQueueGroupID renderGroup, string meshName, Vec3 scale, Vec3 rotation)
        {
            // Creates the mesh in the world
            mMesh = SceneManager.Instance.CreateMeshObject(meshName);
            mMesh.CastShadows = false;
            mMesh.RenderQueueGroup = renderGroup;

            // Attaches the mesh on a node
            if (mMesh.ParentSceneNode == null)
            {
                mNode = new SceneNode();
                mNode.Attach(mMesh);
            }
            else
                mNode = mMesh.ParentSceneNode;

            // Sets up the node (Position, Scale and Rotation)
            mNode.Position = Vec3.Zero;
            mNode.Scale = scale;
            mNode.Rotation *= CaelumUtils.GenerateQuat(CaelumUtils.XAxis, new Degree(rotation.X));
            mNode.Rotation *= CaelumUtils.GenerateQuat(CaelumUtils.YAxis, new Degree(rotation.Y));
            mNode.Rotation *= CaelumUtils.GenerateQuat(CaelumUtils.ZAxis, new Degree(rotation.Z));
        }
コード例 #39
0
ファイル: RTSGameWindow.cs プロジェクト: huytd/fosproject
        void ControlPanelButton_Click( EButton sender )
        {
            int index = int.Parse( sender.Name.Substring( "ControlPanelButton".Length ) );

            TaskTargetChooseIndex = -1;

            List<RTSUnitAI.UserControlPanelTask> tasks = GetControlTasks();

            if( tasks == null || index >= tasks.Count )
                return;
            if( !tasks[ index ].Enable )
                return;

            RTSUnitAI.Task.Types taskType = tasks[ index ].Task.Type;

            switch( taskType )
            {
            //Stop, SelfDestroy
            case RTSUnitAI.Task.Types.Stop:
            case RTSUnitAI.Task.Types.SelfDestroy:
                foreach( Unit unit in selectedUnits )
                {
                    RTSUnitAI intellect = unit.Intellect as RTSUnitAI;
                    if( intellect == null )
                        continue;

                    if( IsEnableTaskTypeInTasks( intellect.GetControlPanelTasks(), taskType ) )
                        intellect.DoTask( new RTSUnitAI.Task( taskType ), false );
                }
                break;

            //ProductUnit
            case RTSUnitAI.Task.Types.ProductUnit:
                foreach( Unit unit in selectedUnits )
                {
                    RTSBuildingAI intellect = unit.Intellect as RTSBuildingAI;
                    if( intellect == null )
                        continue;

                    if( IsEnableTaskTypeInTasks( intellect.GetControlPanelTasks(), taskType ) )
                        intellect.DoTask( new RTSUnitAI.Task( taskType, tasks[ index ].Task.EntityType ), false );
                }
                break;

            //Move, Attack, Repair
            case RTSUnitAI.Task.Types.Move:
            case RTSUnitAI.Task.Types.Attack:
            case RTSUnitAI.Task.Types.Repair:
                //do taskTargetChoose
                TaskTargetChooseIndex = index;
                break;

            //BuildBuilding
            case RTSUnitAI.Task.Types.BuildBuilding:
                if( selectedUnits.Count == 1 )
                {
                    Unit unit = selectedUnits[ 0 ];
                    RTSUnitAI intellect = unit.Intellect as RTSUnitAI;
                    if( intellect != null )
                    {
                        //do taskTargetChoose
                        TaskTargetChooseIndex = index;

                        taskTargetBuildingType = (RTSBuildingType)tasks[ index ].Task.EntityType;

                        string meshName = null;
                        {
                            foreach( MapObjectTypeAttachedObject typeAttachedObject in
                                taskTargetBuildingType.AttachedObjects )
                            {
                                MapObjectTypeAttachedMesh typeMeshAttachedObject = typeAttachedObject as
                                    MapObjectTypeAttachedMesh;
                                if( typeMeshAttachedObject != null )
                                {
                                    meshName = typeMeshAttachedObject.MeshName;
                                    break;
                                }
                            }
                        }

                        taskTargetBuildMeshObject = SceneManager.Instance.CreateMeshObject( meshName );
                        taskTargetBuildSceneNode = new SceneNode();
                        taskTargetBuildSceneNode.Attach( taskTargetBuildMeshObject );
                        taskTargetBuildSceneNode.Visible = false;
                    }
                }
                break;

            }
        }
コード例 #40
0
        protected override void OnCreateScene( Mesh[] meshes, MeshObject[] meshObjects,
			Light[] lights, ColorValue shadowColor, bool calculateShadows )
        {
            //create separated physics scene
            physicsScene = PhysicsWorld.Instance.CreateScene( "Static Lighting" );

            //initialize contact group
            physicsScene.SpecialContactGroupsEnabled = true;
            physicsScene.SetupSpecialContactGroups( 1, 1, true );

            Dictionary<Mesh, string> meshPhysicsMeshNames = new Dictionary<Mesh, string>();

            //register physics custom mesh names
            foreach( Mesh mesh in meshes )
            {
                string customMeshName = PhysicsWorld.Instance.AddCustomMeshGeometry(
                    mesh.Positions, mesh.Indices, null, MeshShape.MeshTypes.TriangleMesh, 0, 0 );

                meshPhysicsMeshNames.Add( mesh, customMeshName );
            }

            //create bodies
            foreach( MeshObject meshObject in meshObjects )
            {
                Body body = physicsScene.CreateBody();
                body.Static = true;
                body.Position = meshObject.Position;
                body.Rotation = meshObject.Rotation;
                body.UserData = meshObject;

                MeshShape shape = body.CreateMeshShape();
                shape.ContactGroup = contactGroup;
                shape.MeshName = meshPhysicsMeshNames[ meshObject.Mesh ];
                shape.MeshScale = meshObject.Scale;

                body.PushedToWorld = true;
            }

            //lights
            {
                this.lights = new MyLight[ lights.Length ];
                for( int n = 0; n < lights.Length; n++ )
                {
                    Light light = lights[ n ];

                    MyLight myLight = null;

                    PointLight pointLight = light as PointLight;
                    if( pointLight != null )
                        myLight = new MyPointLight( pointLight );

                    SpotLight spotLight = light as SpotLight;
                    if( spotLight != null )
                        myLight = new MySpotLight( spotLight );

                    DirectionalLight directionalLight = light as DirectionalLight;
                    if( directionalLight != null )
                        myLight = new MyDirectionalLight( directionalLight );

                    if( myLight == null )
                        Log.Fatal( "SimpleStaticLightingCalculationWorld.OnCreateScene: not implemented light type." );

                    this.lights[ n ] = myLight;
                    this.lights[ n ].Initialize();
                }
            }

            this.shadowColor = shadowColor;
            this.calculateShadows = calculateShadows;
        }
コード例 #41
0
 protected override void OnEndRenderLightmap()
 {
     lightmapRenderingImage = null;
     lightmapMeshObject = null;
     lightmapBucketIndex = Vec2I.Zero;
 }
コード例 #42
0
ファイル: Tank.cs プロジェクト: whztt07/SDK
        void InitWheelsSkeletonAnimation()
        {
            MapObjectAttachedMesh attachedMesh = null;

            //find first attached mesh
            foreach( MapObjectAttachedObject attachedObject in AttachedObjects )
            {
                attachedMesh = attachedObject as MapObjectAttachedMesh;
                if( attachedMesh != null )
                    break;
            }

            if( attachedMesh == null )
                return;
            if( attachedMesh.MeshObject == null )
                return;
            if( attachedMesh.MeshObject.Skeleton == null )
                return;

            wheelsSkeletonAnimationMeshObject = attachedMesh.MeshObject;
            wheelsSkeletonAnimationMeshObject.AddToRenderQueue +=
                WheelsSkeletonAnimationMeshObject_AddToRenderQueue;
        }
コード例 #43
0
            private void CreateMeshObject()
            {
                meshObject = SceneManager.Instance.CreateMeshObject("Base\\Simple Models\\Box.mesh");
                if (meshObject != null)
                {
                    meshObject.SetMaterialNameForAllSubObjects("Red");

                    sceneNode = new SceneNode();
                    //sceneNode.Position = new Vec3( 0, 0, 1 );
                    sceneNode.Attach(meshObject);
                }
            }
コード例 #44
0
 void DestroyBackgroundImageMeshObject()
 {
     if( backgroundImageMeshObject != null )
     {
         backgroundImageMeshObject.Dispose();
         backgroundImageMeshObject = null;
         backgroundImageSceneNode.Dispose();
         backgroundImageSceneNode = null;
     }
 }
コード例 #45
0
        private unsafe void UpdateGeometry()
        {
            DestroyGeometry();

            Curve positionCurve = GetPositionCurve();

            Curve radiusCurve = null;
            {
                bool existsSpecialRadius = false;
                foreach (MapCurvePoint point in Points)
                {
                    RenderableCurvePoint point2 = point as RenderableCurvePoint;
                    if (point2 != null && point2.OverrideRadius >= 0)
                    {
                        existsSpecialRadius = true;
                        break;
                    }
                }

                if (existsSpecialRadius)
                {
                    switch (radiusCurveType)
                    {
                        case RadiusCurveTypes.UniformCubicSpline:
                            radiusCurve = new UniformCubicSpline();
                            break;

                        case RadiusCurveTypes.Bezier:
                            radiusCurve = new BezierCurve();
                            break;

                        case RadiusCurveTypes.Line:
                            radiusCurve = new LineCurve();
                            break;
                    }

                    for (int n = 0; n < Points.Count; n++)
                    {
                        MapCurvePoint point = Points[n];

                        if (!point.Editor_IsExcludedFromWorld())
                        {
                            float rad = radius;
                            RenderableCurvePoint renderableCurvePoint = point as RenderableCurvePoint;
                            if (renderableCurvePoint != null && renderableCurvePoint.OverrideRadius >= 0)
                                rad = renderableCurvePoint.OverrideRadius;
                            radiusCurve.AddValue(point.Time, new Vec3(rad, 0, 0));
                        }
                    }
                }
            }

            //create mesh
            Vertex[] vertices = null;
            int[] indices = null;
            if (positionCurve != null && positionCurve.Values.Count > 1 && Points.Count >= 2)
            {
                Vec3 positionOffset = -Position;

                int steps = (Points.Count - 1) * pathSteps + 1;
                int vertexCount = steps * (shapeSegments + 1);
                int indexCount = (steps - 1) * shapeSegments * 2 * 3;

                vertices = new Vertex[vertexCount];
                indices = new int[indexCount];

                //fill data
                {
                    int currentVertex = 0;
                    int currentIndex = 0;
                    float currentDistance = 0;
                    Vec3 lastPosition = Vec3.Zero;
                    Quat lastRot = Quat.Identity;

                    for (int nStep = 0; nStep < steps; nStep++)
                    {
                        int startStepVertexIndex = currentVertex;

                        float coefficient = (float)nStep / (float)(steps - 1);
                        Vec3 pos = CalculateCurvePointByCoefficient(coefficient) + positionOffset;

                        Quat rot;
                        {
                            Vec3 v = CalculateCurvePointByCoefficient(coefficient + .3f / (float)(steps - 1)) -
                                CalculateCurvePointByCoefficient(coefficient);
                            if (v != Vec3.Zero)
                                rot = Quat.FromDirectionZAxisUp(v.GetNormalize());
                            else
                                rot = lastRot;
                        }

                        if (nStep != 0)
                            currentDistance += (pos - lastPosition).Length();

                        float rad;
                        if (radiusCurve != null)
                        {
                            Range range = new Range(radiusCurve.Times[0], radiusCurve.Times[radiusCurve.Times.Count - 1]);
                            float t = range.Minimum + (range.Maximum - range.Minimum) * coefficient;
                            rad = radiusCurve.CalculateValueByTime(t).X;
                        }
                        else
                            rad = radius;

                        for (int nSegment = 0; nSegment < shapeSegments + 1; nSegment++)
                        {
                            float rotateCoefficient = ((float)nSegment / (float)(shapeSegments));
                            float angle = rotateCoefficient * MathFunctions.PI * 2;
                            Vec3 p = pos + rot * new Vec3(0, MathFunctions.Cos(angle) * rad, MathFunctions.Sin(angle) * rad);

                            Vertex vertex = new Vertex();
                            vertex.position = p;
                            Vec3 pp = p - pos;
                            if (pp != Vec3.Zero)
                                vertex.normal = pp.GetNormalize();
                            else
                                vertex.normal = Vec3.XAxis;
                            //vertex.normal = ( p - pos ).GetNormalize();
                            vertex.texCoord = new Vec2(currentDistance * textureCoordinatesTilesPerMeter, rotateCoefficient + .25f);
                            vertex.tangent = new Vec4(rot.GetForward(), 1);
                            vertices[currentVertex++] = vertex;
                        }

                        if (nStep < steps - 1)
                        {
                            for (int nSegment = 0; nSegment < shapeSegments; nSegment++)
                            {
                                indices[currentIndex++] = startStepVertexIndex + nSegment;
                                indices[currentIndex++] = startStepVertexIndex + nSegment + 1;
                                indices[currentIndex++] = startStepVertexIndex + nSegment + 1 + shapeSegments + 1;
                                indices[currentIndex++] = startStepVertexIndex + nSegment + 1 + shapeSegments + 1;
                                indices[currentIndex++] = startStepVertexIndex + nSegment + shapeSegments + 1;
                                indices[currentIndex++] = startStepVertexIndex + nSegment;
                            }
                        }

                        lastPosition = pos;
                        lastRot = rot;
                    }
                    if (currentVertex != vertexCount)
                        Log.Fatal("RenderableCurve: UpdateRenderingGeometry: currentVertex != vertexCount.");
                    if (currentIndex != indexCount)
                        Log.Fatal("RenderableCurve: UpdateRenderingGeometry: currentIndex != indexCount.");
                }

                if (vertices.Length != 0 && indices.Length != 0)
                {
                    //create mesh
                    string meshName = MeshManager.Instance.GetUniqueName(
                        string.Format("__RenderableCurve_{0}_{1}", Name, uniqueMeshIdentifier));
                    uniqueMeshIdentifier++;
                    //string meshName = MeshManager.Instance.GetUniqueName( string.Format( "__RenderableCurve_{0}", Name ) );
                    mesh = MeshManager.Instance.CreateManual(meshName);
                    SubMesh subMesh = mesh.CreateSubMesh();
                    subMesh.UseSharedVertices = false;

                    //init vertexData
                    VertexDeclaration declaration = subMesh.VertexData.VertexDeclaration;
                    declaration.AddElement(0, 0, VertexElementType.Float3, VertexElementSemantic.Position);
                    declaration.AddElement(0, 12, VertexElementType.Float3, VertexElementSemantic.Normal);
                    declaration.AddElement(0, 24, VertexElementType.Float2, VertexElementSemantic.TextureCoordinates, 0);
                    declaration.AddElement(0, 32, VertexElementType.Float4, VertexElementSemantic.Tangent, 0);

                    fixed (Vertex* pVertices = vertices)
                    {
                        subMesh.VertexData = VertexData.CreateFromArray(declaration, (IntPtr)pVertices,
                            vertices.Length * Marshal.SizeOf(typeof(Vertex)));
                    }
                    subMesh.IndexData = IndexData.CreateFromArray(indices, 0, indices.Length, false);

                    //set material
                    subMesh.MaterialName = materialName;

                    //set mesh gabarites
                    Bounds bounds = Bounds.Cleared;
                    foreach (Vertex vertex in vertices)
                        bounds.Add(vertex.position);
                    mesh.SetBoundsAndRadius(bounds, bounds.GetRadius());
                }
            }

            //create MeshObject, SceneNode
            if (mesh != null)
            {
                meshObject = SceneManager.Instance.CreateMeshObject(mesh.Name);
                if (meshObject != null)
                {
                    meshObject.SetMaterialNameForAllSubObjects(materialName);
                    meshObject.CastShadows = true;

                    sceneNode = new SceneNode();
                    sceneNode.Attach(meshObject);
                    //apply offset
                    sceneNode.Position = Position;
                    MapObject.AssociateSceneNodeWithMapObject(sceneNode, this);
                }
            }

            //create collision body
            if (mesh != null && collision)
            {
                Vec3[] positions = new Vec3[vertices.Length];
                for (int n = 0; n < vertices.Length; n++)
                    positions[n] = vertices[n].position;
                string meshPhysicsMeshName = PhysicsWorld.Instance.AddCustomMeshGeometry(positions, indices, null,
                    MeshShape.MeshTypes.TriangleMesh, 0, 0);

                collisionBody = PhysicsWorld.Instance.CreateBody();
                collisionBody.Static = true;
                collisionBody._InternalUserData = this;
                collisionBody.Position = Position;

                MeshShape shape = collisionBody.CreateMeshShape();
                shape.MeshName = meshPhysicsMeshName;
                shape.MaterialName = CollisionMaterialName;
                shape.ContactGroup = (int)ContactGroup.Collision;
                //shape.VehicleDrivableSurface = collisionVehicleDrivableSurface;

                collisionBody.PushedToWorld = true;
            }

            needUpdate = false;
        }
コード例 #46
0
ファイル: Planet.cs プロジェクト: GazarovVlad/TheGame
 public void LoadCraters(Device device, string pathToObject, string pathDirToTextures)
 {
     string[] fileNames = GetSupportedFilesInDir(pathDirToTextures);
     MeshObject[] craters = new MeshObject[fileNames.Length];
     for (int i = 0; i < fileNames.Length; i++)
     {
         craters[i] = MeshLoader.LoadMesh(device, pathToObject, fileNames[i]);
         craters[i].Pos = Pos;
     }
     for (int i = 0; i < craters.Length; i++)
         Craters.Add(new CratersOnSurface(craters[i], new Vector3(IncRotationEarth, 0.0f, 0.0f)));
     //AddExplosion(1, 1);
 }
コード例 #47
0
        void DestroyPlane()
        {
            DestroyReflectionTexture();

            if( sceneNode != null )
            {
                sceneNode.Dispose();
                sceneNode = null;
            }
            if( meshObject != null )
            {
                meshObject.Dispose();
                meshObject = null;
            }
            if( meshPlane != null )
            {
                meshPlane.Dispose();
                meshPlane = null;
            }

            if( material != null )
            {
                material.Dispose();
                material = null;
            }
        }
コード例 #48
0
 public CratersOnSurface(MeshObject crater, Vector3 incRotationEarth)
 {
     Crater = crater;
     IncRotationEarth = incRotationEarth;
     CratersTurns = new List<Vector3>();
 }
コード例 #49
0
ファイル: AddonDockingForm.cs プロジェクト: whztt07/SDK
		void DestroyMeshObject()
		{
			if( meshObject != null )
			{
				sceneNode.Detach( meshObject );
				sceneNode.Dispose();
				sceneNode = null;
				meshObject.Dispose();
				meshObject = null;
			}
		}
コード例 #50
0
ファイル: Tank.cs プロジェクト: whztt07/SDK
 void ShutdownWheelsSkeletonAnimation()
 {
     wheelsSkeletonAnimationMeshObject = null;
 }
コード例 #51
0
		void CreatePlane()
		{
			DestroyPlane();

			string meshName;

			if( !string.IsNullOrEmpty( customMesh ) )
			{
				meshName = customMesh;
			}
			else
			{
				meshName = MeshManager.Instance.GetUniqueName( "WaterPlane" );

				Vec2 tile;
				if( fixedPipelineMapTiling != 0 )
					tile = size / fixedPipelineMapTiling;
				else
					tile = new Vec2( 0, 0 );

				meshPlane = MeshManager.Instance.CreatePlane( meshName, new Plane( new Vec3( 0, 0, 1 ), 0 ),
					size, segments, true, 1, tile, new Vec3( 0, 1, 0 ) );
			}

			//create material
			string materialName = MaterialManager.Instance.GetUniqueName( "_GeneratedWaterPlane" );
			material = (WaterPlaneHighLevelMaterial)HighLevelMaterialManager.Instance.
				CreateMaterial( materialName, "WaterPlaneHighLevelMaterial" );
			material.Init( this );
			material.UpdateBaseMaterial();

			meshObject = SceneManager.Instance.CreateMeshObject( meshName );
			if( meshObject != null )
			{
				meshObject.SetMaterialNameForAllSubObjects( material.Name );
				meshObject.RenderQueueGroup = renderQueueGroup;

				sceneNode = new SceneNode();
				sceneNode.Position = position;
				sceneNode.Visible = Visible;
				sceneNode.AllowSceneManagementCulling = false;
				sceneNode.Attach( meshObject );
			}

			needUpdatePlane = false;
		}
コード例 #52
0
        void CreateBackgroundImageMeshObject()
        {
            backgroundImageMeshObject = SceneManager.Instance.CreateMeshObject(
                "JigsawPuzzleGame\\BackgroundImage.mesh" );

            if( backgroundImageMeshObject != null )
            {
                backgroundImageSceneNode = new SceneNode();
                backgroundImageSceneNode.Attach( backgroundImageMeshObject );
            }
        }
コード例 #53
0
        private void DestroyGeometry()
        {
            if (collisionBody != null)
            {
                collisionBody.Dispose();
                collisionBody = null;
            }

            if (sceneNode != null)
            {
                sceneNode.Dispose();
                sceneNode = null;
            }

            if (meshObject != null)
            {
                meshObject.Dispose();
                meshObject = null;
            }

            if (mesh != null)
            {
                mesh.Dispose();
                mesh = null;
            }
        }
コード例 #54
0
 public void AddMeshObject(MeshObject obj)
 {
     MeshesToRender.Add(obj);
 }
コード例 #55
0
ファイル: Planet.cs プロジェクト: GazarovVlad/TheGame
 public void LoadExplosion(Device device, string pathToObject, string pathDirToTextures)
 {
     string[] fileNames = GetSupportedFilesInDir(pathDirToTextures);
     MeshObject[] stages = new MeshObject[fileNames.Length];
     for (int i = 0; i < fileNames.Length; i++)
     {
         stages[i] = MeshLoader.LoadMesh(device, pathToObject, fileNames[i]);
         stages[i].Pos = Pos;
     }
     ExplosionOnSurface exp = new ExplosionOnSurface(stages, new Vector3(IncRotationEarth, 0.0f, 0.0f));
     Explosions.Add(exp);
 }
コード例 #56
0
        void CreatePlane()
        {
            if( RenderSystem.Instance.IsDeviceLost() )
                return;

            DestroyPlane();

            Viewport defaultViewport = RendererWorld.Instance.DefaultViewport;

            if( RenderSystem.Instance.HasShaderModel2() &&
                RenderSystem.Instance.Capabilities.UserClipPlanes &&
                ReflectionLevel != ReflectionLevels.None )
            {
                CreateReflectionTexture();
            }

            string meshName = MeshManager.Instance.GetUniqueName( "WaterPlane" );

            Vec2 tile;
            if( fixedPipelineMapTiling != 0 )
                tile = size / fixedPipelineMapTiling;
            else
                tile = new Vec2( 0, 0 );

            meshPlane = MeshManager.Instance.CreatePlane( meshName, new Plane( new Vec3( 0, 0, 1 ), 0 ),
                size, segments, true, 1, tile, new Vec3( 0, 1, 0 ) );

            //create material
            string materialName = MaterialManager.Instance.GetUniqueName( "_GeneratedWaterPlane" );
            material = (WaterPlaneHighLevelMaterial)HighLevelMaterialManager.Instance.
                CreateMaterial( materialName, "WaterPlaneHighLevelMaterial" );
            material.Init( this );
            material.UpdateBaseMaterial();

            //change material of mesh
            foreach( SubMesh subMesh in meshPlane.SubMeshes )
                subMesh.MaterialName = material.Name;

            meshObject = SceneManager.Instance.CreateMeshObject( meshName );
            meshObject.RenderQueueGroup = renderQueueGroup;

            sceneNode = new SceneNode();
            sceneNode.Attach( meshObject );
            sceneNode.Position = position;
            sceneNode.Visible = Visible;

            needUpdatePlane = false;
        }
コード例 #57
0
ファイル: AddonDockingForm.cs プロジェクト: whztt07/SDK
		void CreateMeshObject()
		{
			DestroyMeshObject();

			meshObject = SceneManager.Instance.CreateMeshObject( "Base\\Simple Models\\Cylinder.mesh" );
			if( meshObject != null )
			{
				meshObject.SetMaterialNameForAllSubObjects( "Red" );

				sceneNode = new SceneNode();
				sceneNode.Visible = false;
				sceneNode.Position = new Vec3( 5, 0, 0 );
				sceneNode.Rotation = new Angles( 50, 50, 50 ).ToQuat();
				sceneNode.Attach( meshObject );
			}
		}