private static void CreateEntitiesWhichNotSynchronizedViaNetwork()
        {
            //ground
            {
                //create materials from the code
                ShaderBaseMaterial[] materials = new ShaderBaseMaterial[7];
                {
                    for (int n = 0; n < materials.Length; n++)
                    {
                        string materialName = HighLevelMaterialManager.Instance.GetUniqueMaterialName(
                            "ExampleOfProceduralMapCreation_Ground");
                        ShaderBaseMaterial material = (ShaderBaseMaterial)HighLevelMaterialManager.Instance.CreateMaterial(
                            materialName, "ShaderBaseMaterial");
                        material.Diffuse1Map.Texture = string.Format("Types\\Vegetation\\Trees\\Textures\\Bark{0}A.dds", n + 1);
                        material.NormalMap.Texture = string.Format("Types\\Vegetation\\Trees\\Textures\\Bark{0}A_N.dds", n + 1);
                        material.SpecularColor = new ColorValue(1, 1, 1);
                        material.SpecularMap.Texture = string.Format("Types\\Vegetation\\Trees\\Textures\\Bark{0}A_S.dds", n + 1);
                        material.PostCreate();

                        materials[n] = material;
                    }
                }

                //create objects with collision body
                EngineRandom random = new EngineRandom(0);
                for (float y = -35; y < 35; y += 5)
                {
                    for (float x = -35; x < 35; x += 2.5f)
                    {
                        StaticMesh staticMesh = (StaticMesh)Entities.Instance.Create("StaticMesh", Map.Instance);
                        staticMesh.MeshName = "Base\\Simple Models\\Box.mesh";

                        ShaderBaseMaterial material = materials[random.Next(0, 6)];
                        staticMesh.ForceMaterial = material.Name;//"DarkGray";

                        staticMesh.Position = new Vec3(x, y, -1.0f);
                        staticMesh.Scale = new Vec3(2.5f, 5, 2);
                        staticMesh.CastDynamicShadows = false;
                        staticMesh.PostCreate();
                    }
                }
            }

            //SkyBox
            {
                Entity skyBox = Entities.Instance.Create("SkyBox", Map.Instance);
                skyBox.PostCreate();
            }

            //Light
            {
                Light light = (Light)Entities.Instance.Create("Light", Map.Instance);
                light.LightType = RenderLightType.Directional;
                light.SpecularColor = new ColorValue(1, 1, 1);
                light.Position = new Vec3(0, 0, 10);
                light.Rotation = new Angles(120, 50, 330).ToQuat();
                light.PostCreate();
            }
        }
Exemple #2
0
 internal DiffuseMapItem( ShaderBaseMaterial owner )
     : base(owner)
 {
 }
Exemple #3
0
 //
 internal MapItem( ShaderBaseMaterial owner )
 {
     this.owner = owner;
     transform = new TransformItem( this );
 }
Exemple #4
0
        private void CreateDecal()
        {
            Bounds bounds = Bounds.Cleared;
            foreach (Vertex vertex in vertices)
                bounds.Add(vertex.position);

            VertexData vertexData = new VertexData();
            IndexData indexData = new IndexData();

            //init vertexData
            VertexDeclaration declaration = 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.Float3, VertexElementSemantic.Tangent);

            VertexBufferBinding bufferBinding = vertexData.VertexBufferBinding;
            HardwareVertexBuffer vertexBuffer = HardwareBufferManager.Instance.CreateVertexBuffer(
                44, vertices.Length, HardwareBuffer.Usage.StaticWriteOnly);
            bufferBinding.SetBinding(0, vertexBuffer, true);
            vertexData.VertexCount = vertices.Length;

            //init indexData
            Trace.Assert(vertices.Length < 65536, "Decal: vertices.Length < 65536");

            HardwareIndexBuffer indexBuffer = HardwareBufferManager.Instance.CreateIndexBuffer(
                HardwareIndexBuffer.IndexType._16Bit, indices.Length,
                HardwareBuffer.Usage.StaticWriteOnly);
            indexData.SetIndexBuffer(indexBuffer, true);
            indexData.IndexCount = indices.Length;

            //init material
            Material material = null;

            shaderBaseMaterial = HighLevelMaterialManager.Instance.
                GetMaterialByName(sourceMaterialName) as ShaderBaseMaterial;
            //only default shader technique for ShaderBase material
            if (shaderBaseMaterial != null && !shaderBaseMaterial.IsDefaultTechniqueCreated())
                shaderBaseMaterial = null;

            if (shaderBaseMaterial != null)
            {
                //ShaderBase material
                material = shaderBaseMaterial.BaseMaterial;
            }
            else
            {
                //standard material or fallback ShaderBase technique
                Material sourceMaterial = MaterialManager.Instance.GetByName(sourceMaterialName);
                if (sourceMaterial != null)
                {
                    //clone standard material
                    clonedStandardMaterial = MaterialManager.Instance.Clone(sourceMaterial,
                        MaterialManager.Instance.GetUniqueName(sourceMaterialName + "_Cloned"));
                    material = clonedStandardMaterial;
                }
            }

            staticMeshObject = SceneManager.Instance.CreateStaticMeshObject(bounds + Position,
                Position, Quat.Identity, new Vec3(1, 1, 1), true, material, vertexData, indexData, true);
            staticMeshObject.AddToRenderQueue += StaticMeshObject_AddToRenderQueue;

            UpdateBuffers();
        }