Esempio n. 1
0
        public void RemoveFrame(int id)
        {
            var frame  = Frames[id];
            var parent = (xxFrame)frame.Parent;

            if (parent == null)
            {
                throw new Exception("The root frame can't be removed");
            }

            parent.RemoveChild(frame);

            Frames.Clear();
            Meshes.Clear();
            InitFrames(Parser.Frame);
        }
Esempio n. 2
0
        protected override void ReadMesh()
        {
            // Override internal mesh read method to fill the mesh list
            // with drawable meshes
            DrawableRoRsmMesh m = new DrawableRoRsmMesh(Reader, Version);

            if (m.IsValid == true)
            {
                m.SetUpVertices(mDevice);
                Meshes.Add(m);
            }
            else
            {
                // TODO: debug in valid meshes
            }
        }
Esempio n. 3
0
        public void ShaderChanged(string name, Shader shader)
        {
            if (ShaderName != name)
            {
                return;
            }
            this.shader = shader;
            if (ReferenceEquals(shader, null))
            {
                return;
            }
            Mesh mesh = Meshes.CreateCornellBox();

            geometry = VAOLoader.FromMesh(mesh, shader);
            bufferMaterials.Set(Meshes.CreateCornellBoxMaterial(), BufferUsageHint.StaticDraw);
        }
Esempio n. 4
0
 // Generate a mesh buffer
 public void GenerateMeshBuffer(NVRNode node)
 {
     node.FirstMesh = Meshes.Count;
     node.MeshCount = node.Meshes.Count;
     if (node.Children.Count == 0)
     {
         Meshes.AddRange(node.Meshes);
     }
     else
     {
         foreach (NVRNode child in node.Children)
         {
             GenerateMeshBuffer(child);
         }
     }
 }
Esempio n. 5
0
        public void ShaderChanged(string name, Shader shader)
        {
            if (ShaderName != name)
            {
                return;
            }
            if (ReferenceEquals(shader, null))
            {
                return;
            }
            var sphere    = Meshes.CreateSphere(1, 4);
            var envSphere = sphere.SwitchTriangleMeshWinding();

            envSphere.Add(sphere);
            geometry = VAOLoader.FromMesh(envSphere, shader);
        }
Esempio n. 6
0
        void AddFrame(xxFrame newFrame, int destParentId)
        {
            if (destParentId < 0)
            {
                Parser.Frame = newFrame;
            }
            else
            {
                Frames[destParentId].AddChild(newFrame);
            }

            Frames.Clear();
            Meshes.Clear();
            InitFrames(Parser.Frame);
            Changed = true;
        }
Esempio n. 7
0
        private void Initialize()
        {
            if (Meshes == null)
            {
                Meshes = new Dictionary <int, Record>();
            }
            if (Mesh == null)
            {
                Mesh = new List <Record>();
            }

            foreach (var item in Mesh)
            {
                Meshes.Add(item.GetHashCode(), item);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Button Constructor
        /// </summary>
        /// <param name="X"></param>
        /// <param name="Y"></param>
        /// <param name="Width"></param>
        /// <param name="Height"></param>
        /// <param name="Color"></param>
        /// <param name="Text"></param>
        /// <param name="Font"></param>
        /// <param name="LineSpacing"></param>
        /// <param name="xOffset"></param>
        /// <param name="yOffset"></param>
        public Button(GUI gui, float X, float Y, float Width, float Height, Vector4 Color, string Text, Font Font, float LineSpacing = 1, float xOffset = 0, float yOffset = 0) : base(gui)
        {
            this.X      = X;
            this.Y      = Y;
            this.Width  = Width;
            this.Height = Height;
            this.Color  = Color;

            Meshes.Add(Quad.Rect().Compile());
            Update();

            //Text
            this.Text = new Text(gui, X, Y, new Vector4(1), Text, Font, Width, LineSpacing, xOffset, yOffset);
            Children.Add(this.Text);

            MultiShader_StrVal = GUI.Default_Element;
        }
Esempio n. 9
0
 private void MeshComboBox_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (manuallychangedmodel)
     {
         ObjMaterialComboBox.Items.Clear();
         manuallychangedmodel = false;
         Mesh Tempmesh = new Mesh();
         //List<string> matlist = new List<string>();
         string tempmat = String.Empty;
         string tempname = "TempNameDeleteMePlease";
         Tempmesh = Meshes.Load(tempname, MeshComboBox.GetItemText(MeshComboBox.SelectedItem));
         foreach (MeshPart msh in Tempmesh.Parts)
         {
             ObjMaterialComboBox.Items.Add("Checker");
         }
     }
 }
Esempio n. 10
0
        public MainVisual(IRenderState renderState, IContentLoader contentLoader)
        {
            this.renderState = renderState;
            shaderProgram    = contentLoader.Load <IShaderProgram>("lambert.*");
            //shaderPostProcess.Add(contentLoader.LoadPixelShader("swirl"));
            //shaderPostProcess.Add(contentLoader.LoadPixelShader("sepia"));
            //shaderPostProcess.Add(contentLoader.LoadPixelShader("vignet"));
            //shaderPostProcess.Add(contentLoader.LoadPixelShader("Ripple"));
            //shaderPostProcess.Add(contentLoader.LoadPixelShader("BadTV"));
            //shaderPostProcess.Add(contentLoader.LoadPixelShader("Blur"));
            shaderPostProcess.Add(contentLoader.LoadPixelShader("BloomGausPass1"));
            shaderPostProcess.Add(contentLoader.LoadPixelShader("BloomGausPass2"));

            var mesh = Meshes.CreateCornellBox(); //TODO: ATI seams to do VAO vertex attribute ordering different for each shader would need to create own VAO

            geometry = VAOLoader.FromMesh(mesh, shaderProgram);
        }
Esempio n. 11
0
 public bool TryAddMesh(Mesh mesh)
 {
     if ((mesh == null) || string.IsNullOrEmpty(mesh.Name) || Meshes.ContainsKey(mesh.Name))
     {
         return(false);
     }
     if (string.IsNullOrEmpty(mesh.Shader) || !Shaders.ContainsKey(mesh.Shader))
     {
         return(false);
     }
     if (!mesh.IsTrianglesCorrect())
     {
         return(false);
     }
     Meshes.Add(mesh.Name, mesh);
     return(true);
 }
Esempio n. 12
0
 public bool TryAddNode(Node node)
 {
     if ((node == null) || string.IsNullOrEmpty(node.Name) || Nodes.ContainsKey(node.Name))
     {
         return(false);
     }
     if (!string.IsNullOrEmpty(node.Mesh) && !Meshes.ContainsKey(node.Mesh))
     {
         return(false);
     }
     if (!string.IsNullOrEmpty(node.Parent) && !Nodes.ContainsKey(node.Parent))
     {
         return(false);
     }
     Nodes.Add(node.Name, node);
     return(true);
 }
Esempio n. 13
0
 public void ShaderChanged(string name, Shader shader)
 {
     if (ShaderPostProcessName == name)
     {
         shaderPostProcess = shader;                 //todo: ati seams to do VAO vertex attribute ordering different for each shader would need to create own vao
     }
     else if (ShaderName == name)
     {
         this.shader = shader;
         if (ReferenceEquals(shader, null))
         {
             return;
         }
         Mesh mesh = Meshes.CreateCornellBox();
         geometry = VAOLoader.FromMesh(mesh, shader);
     }
 }
        uint CreatePrefilteredMap(int frameBuffer, Matrix4x4 projection, Matrix4x4[] viewMatrices, uint cubeMap)
        {
            DefaultMesh cubeMesh            = Meshes.CreateCubeWithNormals();
            VAO         renderPrefilterCube = VAOLoader.FromMesh(cubeMesh, prefilterMapShader);
            int         texResX             = 128;
            int         texResY             = 128;

            int prefiltMap = CreateCubeMap(texResX, texResY);

            GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);
            GL.GenerateMipmap(GenerateMipmapTarget.TextureCubeMap);


            prefilterMapShader.Activate();

            SetSampler(prefilterMapShader.ProgramID, 0, "environmentMap", cubeMap, TextureTarget.TextureCubeMap);
            GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);


            prefilterMapShader.Uniform("projection", projection, true);
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, frameBuffer);
            int maxMipLvl = 5;

            for (int i = 0; i < maxMipLvl; i++)
            {
                float mipWidth  = texResX * (float)Math.Pow(0.5, i);
                float mipHeight = texResY * (float)Math.Pow(0.5, i);
                GL.Viewport(0, 0, (int)mipWidth, (int)mipHeight);

                float roughness = (float)i / (float)(maxMipLvl - 1.0);
                prefilterMapShader.Uniform("roughness", roughness);
                for (int j = 0; j < 6; j++)
                {
                    prefilterMapShader.Uniform("view", viewMatrices[j], true);
                    GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0,
                                            TextureTarget.TextureCubeMapPositiveX + j, prefiltMap, i);

                    GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
                    renderPrefilterCube.Draw();
                }
            }
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);

            return((uint)prefiltMap);
        }
Esempio n. 15
0
        /// <summary>
        /// Create a new Gcmf object from the given .OBJ / .MTL object.
        /// </summary>
        /// <param name="modelObject">The object from which to create the Gcmf object.</param>
        /// <param name="textureIndexMapping">Correspondence between the textures defined in the model materials and .TPL texture indices.</param>
        public Gcmf(ObjMtlObject modelObject, Dictionary <Bitmap, int> modelTextureMapping)
            : this()
        {
            Dictionary <ObjMtlMaterial, int> modelMaterialMapping = new Dictionary <ObjMtlMaterial, int>();

            foreach (ObjMtlMaterial mat in modelObject.Meshes.Select(m => m.Material))
            {
                modelMaterialMapping.Add(mat, Materials.Count);
                Materials.Add(new GcmfMaterial(mat, modelTextureMapping));
            }

            foreach (ObjMtlMesh mesh in modelObject.Meshes)
            {
                Meshes.Add(new GcmfMesh(mesh, modelMaterialMapping));
            }

            UpdateBoundingSphere();
        }
Esempio n. 16
0
 public SceneDto ToDto()
 {
     return(new SceneDto
     {
         Id = Id,
         Name = Name,
         UnitOfMeasure = (Models.Uomtype)UnitOfMeasure,
         Units = Units,
         Materials = Materials.Select(x => x.ToDto()).ToList(),
         Cameras = Cameras.Select(x => x.ToDto()).ToList(),
         CurrentCamera = CurrentCamera?.Id,
         Lights = Lights.Select(x => x.ToDto()).ToList(),
         Textures = Textures.Select(x => x.ToDto()).ToList(),
         Meshes = Meshes.Select(x => x.ToDto()).ToList(),
         Skins = Skins.Select(x => x.ToDto()).ToList(),
         Root = Root.ToDto()
     });
 }
        public MainVisual(IRenderState renderState, IContentLoader contentLoader)
        {
            renderState.Set(new DepthTest(true));
            fboShadowMap.Texture.Filter = TextureFilterMode.Nearest;

            shaderProgram = contentLoader.Load <IShaderProgram>("shadowMap.*");
            var mesh   = Meshes.CreatePlane(10, 10, 10, 10);
            var sphere = Meshes.CreateSphere(0.5f, 2);

            sphere.SetConstantUV(new Vector2(0.5f, 0.5f));
            mesh.Add(sphere.Transform(Transformation.Translation(0, 2, -2)));
            mesh.Add(sphere.Transform(Transformation.Translation(0, 2, 0)));
            mesh.Add(sphere.Transform(Transformation.Translation(2, 2, -1)));
            geometry = VAOLoader.FromMesh(mesh, shaderProgram);

            shaderProgramDepth = contentLoader.Load <IShaderProgram>("depth.*");
            //todo: radeon cards created errors with geometry bound to one shader and used in other shaders because of binding id changes
        }
        IEnumerator LoadMeshes()
        {
            var meshImporter = new MeshImporter();

            for (int i = 0; i < GLTF.meshes.Count; ++i)
            {
                var meshContext       = meshImporter.ReadMesh(this, i);
                var meshWithMaterials = MeshImporter.BuildMesh(this, meshContext);
                var mesh = meshWithMaterials.Mesh;
                if (string.IsNullOrEmpty(mesh.name))
                {
                    mesh.name = string.Format("UniGLTF import#{0}", i);
                }
                Meshes.Add(meshWithMaterials);

                yield return(null);
            }
        }
Esempio n. 19
0
        public MainVisual(IRenderContext renderContext, IContentLoader contentLoader)
        {
            renderContext.RenderState.Set(new DepthTest(true));
            renderContext.RenderState.Set(new FaceCullingModeState(FaceCullingMode.BACK_SIDE));

            var mesh = Meshes.CreatePlane(2, 2, 1024, 1024);

            var texHeightfield = contentLoader.Load <ITexture2D>("mountain_height");
            var bindings       = new TextureBinding[]
            {
                new TextureBinding("texHeightfield", texHeightfield),
                new TextureBinding("texColor", contentLoader.Load <ITexture2D>("mountain_color")),
                new TextureBinding("texStone", contentLoader.Load <ITexture2D>("stone")),
            };
            var shaderProgram = contentLoader.Load <IShaderProgram>("shader.*");

            mountain = new MeshVisual(mesh, shaderProgram, bindings);
        }
Esempio n. 20
0
        public Skybox(IContentLoader contentLoader, float size, string textureName)
        {
            _skyboxProgram = contentLoader.Load <IShaderProgram>("sky.*");

            ITexture2D[] textures = new ITexture2D[6];

            for (int i = 0; i < 6; i++)
            {
                textures[i] = contentLoader.Load <ITexture2D>(textureName + Endings[i]);
            }

            _cubeFbo = new CubeMapFBO(textures[0].Width);

            CreateMap(textures);

            var sphere = Meshes.CreateSphere(size).SwitchHandedness();

            _sphereGeometry = VAOLoader.FromMesh(sphere, _skyboxProgram);
        }
Esempio n. 21
0
        private void GenerateVoronoi(int sizeX, int sizeY, Vector3 scale)
        {
            Random rand = new Random(345546);

            float RandFloat() => (float)rand.NextDouble();

            float[,] heights   = new float[sizeX + 2, sizeY + 2];
            Vector2[,] centers = new Vector2[sizeX + 2, sizeY + 2];

            for (int x = 0; x < sizeX + 2; x++)
            {
                for (int y = 0; y < sizeY + 2; y++)
                {
                    heights[x, y] = RandFloat() * scale.Y;
                    centers[x, y] = new Vector2((RandFloat() + x - ((sizeX + 2)) / 2) * scale.X, (RandFloat() + y - ((sizeY + 2) / 2)) * scale.Z);
                }
            }

            for (int x = 1; x < sizeX + 1; x++)
            {
                for (int y = 1; y < sizeY + 1; y++)
                {
                    List <Vector2> neighbors = new List <Vector2>()
                    {
                        centers[x - 1, y - 1],
                        centers[x - 1, y],
                        centers[x - 1, y + 1],
                        centers[x, y - 1],
                        centers[x, y + 1],
                        centers[x + 1, y - 1],
                        centers[x + 1, y],
                        centers[x + 1, y + 1]
                    };

                    GenerateVoronoiTower(centers[x, y], neighbors, heights[x, y]);
                }
            }

            DefaultMesh plane = Meshes.CreatePlane(sizeX * scale.X, sizeY * scale.Z, 1, 1);

            plane.TexCoord.Clear();
            Mesh.Add(plane);
        }
        uint CreateEnvironmentMap(int frameBuffer, Matrix4x4 projection, Matrix4x4[] viewMatrices, ITexture2D sphereTexture)
        {
            int         fbCubeWidht       = 512;
            int         fbCubeHeight      = 512;
            DefaultMesh cubeMesh          = Meshes.CreateCubeWithNormals();
            VAO         renderCubeMapCube = VAOLoader.FromMesh(cubeMesh, cubeProjectionShader);

            //Cubemap
            int envCubeMap = CreateCubeMap(fbCubeWidht, fbCubeHeight);

            GL.TexParameter(TextureTarget.TextureCubeMap, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.LinearMipmapLinear);
            //FBO

            GL.BindFramebuffer(FramebufferTarget.Framebuffer, frameBuffer);
            //GL.FramebufferTexture(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0, TextureTarget.TextureCubeMap, envCubeMap, 0);

            //Render into Cubemap
            //Setting up shader
            cubeProjectionShader.Activate();
            cubeProjectionShader.Uniform("projection", projection, true);

            SetSampler(cubeProjectionShader.ProgramID, 0, "equirectangularMap", sphereTexture);
            GL.Viewport(0, 0, fbCubeWidht, fbCubeHeight);
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, frameBuffer);
            //GL.DrawBuffer(DrawBufferMode.ColorAttachment0);
            for (int i = 0; i < 6; i++)
            {
                cubeProjectionShader.Uniform("view", viewMatrices[i], true);

                GL.FramebufferTexture2D(FramebufferTarget.Framebuffer, FramebufferAttachment.ColorAttachment0,
                                        TextureTarget.TextureCubeMapPositiveX + i, envCubeMap, 0);

                GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);

                renderCubeMapCube.Draw();
            }
            GL.BindTexture(TextureTarget.TextureCubeMap, envCubeMap);
            GL.GenerateMipmap(GenerateMipmapTarget.TextureCubeMap);

            GL.BindFramebuffer(FramebufferTarget.Framebuffer, 0);
            DeactivateTexture(0);
            return((uint)envCubeMap);
        }
        public ParticleSystem(DeferredRenderer renderer, IContentLoader contentLoader)
        {
            random = new Random();
            //Rendering
            this.renderer      = renderer;
            deferredRenderable = new Renderable();
            var            plane    = Meshes.CreatePlane(1, 1, 1, 1).Transform(Transformation.Rotation(-90, Axis.X));
            IShaderProgram shader   = renderer.GetShader(DeferredRenderer.DrawableType.particleMesh);
            VAO            planeVao = renderer.GetDrawable(plane, DeferredRenderer.DrawableType.particleMesh);

            deferredRenderable.SetDeferredGeometryMesh(planeVao, shader);
            ITexture2D defaultAlpha = contentLoader.Load <ITexture2D>("particleDefault.png");

            deferredRenderable.SetAlbedoTexture(defaultAlpha);
            deferredRenderable.SetAlphaMap(defaultAlpha);
            deferredRenderable.faceCullingMode = FaceCullingMode.NONE;
            VAO            shadowPlaneVao = renderer.GetDrawable(plane, DeferredRenderer.DrawableType.particleShadowLightView);
            IShaderProgram shadowShader   = renderer.GetShader(DeferredRenderer.DrawableType.particleShadowLightView);

            shadowRenderable = new Renderable();
            shadowRenderable.SetDeferredGeometryMesh(shadowPlaneVao, shadowShader);
            shadowRenderable.SetAlbedoTexture(defaultAlpha);
            shadowRenderable.SetAlphaMap(defaultAlpha);
            shadowRenderable.faceCullingMode = FaceCullingMode.NONE;
            //ParticleSystemSetup
            globalModules       = new List <ParticleModule>();
            perParticleModules  = new List <ParticleModule>();
            particleColor       = new Range3D(new Vector3(1, 1, 1));
            keepScaleRatio      = true;
            scaleAspect         = new AspectRatio3D(AspectRatio3D.Axis.XAxis, 1);
            particlePoolList    = new List <Particle>();
            spawnedParticleList = new List <Particle>();
            particleRemoveList  = new List <Particle>();
            SetMaxParticles(100);
            spawnArea           = new Range3D(new Vector3(-0.1f, 0, -0.1f), new Vector3(0.1f, 0, 0.1f));
            spawnScale          = new Range3D(new Vector3(0f, 0f, 0f), new Vector3(1f, 1f, 1f));
            spawnAcceleration   = new Range3D(new Vector3(0, 0.1f, 0), new Vector3(0, 5f, 0));
            spawnIntervallRange = new Range(0f, 1f);
            spawnIntervall      = spawnIntervallRange.GetRandomValue(random);
            spawnRate           = new Range(1, 1);
            lifeTimeRange       = new Range(10.0f);
        }
Esempio n. 24
0
        private void DrawSprings(DxRenderContext renderContext, Cell cell, SimParams parameters, float normalizer)
        {
            SlimDX.Direct3D11.Device device = DeviceContext.Device;
            DxMesh tube = parameters.GetValue(SimParameter.Int.Spring_Type) == 0
            ? Meshes.GetMesh("rod") : Meshes.GetMesh("spring");

            SetMesh(device, tube);

            var prevMode = DeviceContext.Device.ImmediateContext.InputAssembler.PrimitiveTopology;

            PrimitiveTopology[] modes = { PrimitiveTopology.LineList, PrimitiveTopology.TriangleList };

            for (int j = 0; j < modes.Length; j++)
            {
                DeviceContext.Device.ImmediateContext.InputAssembler.PrimitiveTopology = modes[j];

                foreach (ChromosomePair pair in cell.ChromosomePairs)
                {
                    Spring spring = pair.Spring;
                    if (spring != null)
                    {
                        SpringStyle springStyle = renderContext.StyleAspect.Resolve <SpringStyle>(spring);
                        ConstBuffer.Material = springStyle.Spring;
                        float  scale     = (float)spring.Length * normalizer;
                        Matrix transform = Matrix.Scaling((float)springStyle.Width, (float)springStyle.Width, scale);

                        transform *= RotationVectors(new Vector3(0, 0, -1),
                                                     new Vector3((float)(spring.RightJoint.X - spring.LeftJoint.X),
                                                                 (float)(spring.RightJoint.Y - spring.LeftJoint.Y),
                                                                 (float)(spring.RightJoint.Z - spring.LeftJoint.Z)));
                        transform *= Matrix.Translation((float)spring.LeftJoint.X * normalizer,
                                                        (float)spring.LeftJoint.Y * normalizer,
                                                        (float)spring.LeftJoint.Z * normalizer);

                        ConstBuffer.World = Matrix.Transpose(transform);
                        SetBuffer(device, ConstBuffer);
                        DrawMesh(device, tube);
                    }
                }
            }
            DeviceContext.Device.ImmediateContext.InputAssembler.PrimitiveTopology = prevMode;
        }
Esempio n. 25
0
        public void AddNewRecord(BgActor actor, IFile obj, RomVersion version)
        {
            try
            {
                var record = new Record(actor, obj, version);

                if (Meshes.ContainsKey(record.GetHashCode()))
                {
                    Meshes[record.GetHashCode()].Merge(record);
                }
                else
                {
                    Meshes.Add(record.GetHashCode(), record);
                }
            }
            catch
            {
                Console.WriteLine("UNRECORDED");
            }
        }
Esempio n. 26
0
        public MeshDescription GetMeshDescription(string name)
        {
            if (name == null)
            {
                name = string.Empty;
            }

            // Search for mesh description by name.
            var meshDescription = Meshes.FirstOrDefault(m => m.Name.Equals(name, StringComparison.OrdinalIgnoreCase));

            if (meshDescription != null)
            {
                return(meshDescription);
            }

            // Search for mesh description without a name. Use as fallback.
            meshDescription = Meshes.FirstOrDefault(m => string.IsNullOrEmpty(m.Name));

            return(meshDescription);
        }
Esempio n. 27
0
        private void UpdateGeometry(Shader shader)
        {
            Mesh mesh = Meshes.CreateSphere(0.03f, 2);

            geometry = VAOLoader.FromMesh(mesh, shader);

            //per instance attributes
            var          rnd               = new Random(12);
            Func <float> Rnd01             = () => (float)rnd.NextDouble();
            Func <float> RndCoord          = () => (Rnd01() - 0.5f) * 2.0f;
            var          instancePositions = new Vector3[instanceCount];

            for (int i = 0; i < instanceCount; ++i)
            {
                instancePositions[i] = new Vector3(RndCoord(), RndCoord(), RndCoord());
            }
            geometry.SetAttribute(shader.GetAttributeLocation("instancePosition"), instancePositions, VertexAttribPointerType.Float, 3, true);

            //todo students: add per instance attribute speed here
        }
Esempio n. 28
0
        public FMDL(NodeBase node, BFRES bfres, Model model) : base()
        {
            NodeUI   = node;
            Model    = model;
            Skeleton = new FSKL(model.Skeleton);

            foreach (var shape in model.Shapes.Values)
            {
                Meshes.Add(new FSHP(bfres.ResFile, (FSKL)Skeleton, this, shape));
            }
            foreach (var mat in model.Materials.Values)
            {
                Materials.Add(new FMAT(bfres, this, model, mat));
            }

            foreach (FSHP shape in Meshes)
            {
                shape.Material = (FMAT)Materials[shape.Shape.MaterialIndex];
            }
        }
        /// <summary>
        /// Called, when the new propeller entity
        /// </summary>
        /// <param name="device">The graphics device on which the entity is displayed</param>
        /// <param name="physicsEngine">The physics engine handling the entity physics</param>
        public override void Initialize(xnagfx.GraphicsDevice device, PhysicsEngine physicsEngine)
        {
            try
            {
                InitError = string.Empty;

                AddsShapeToParent = true;

                base.Initialize(device, physicsEngine);

                // Set the mesh for the propeller
                State.Assets.Mesh = PROPELLER_MESH_FILE;
                MeshScale         = new Vector3(0.01f, 0.01f, 0.01f);
                MeshRotation      = new Vector3(0.0f, (float)(Globals.RandomGenerator.NextDouble() * 1000.0), 0.0f);

                // TODO Transparente Propeller-Texture ab gewisser Drehgeschwindigkeit
                //HeightFieldShapeProperties hf = new HeightFieldShapeProperties("height field", 2, 0.02f, 2, 0.02f, 0, 0, 1, 1);
                //hf.HeightSamples = new HeightFieldSample[hf.RowCount * hf.ColumnCount];
                //for (int i = 0; i < hf.HeightSamples.Length; i++)
                //    hf.HeightSamples[i] = new HeightFieldSample();
                //Shape _particlePlane = new Shape(hf);
                //_particlePlane.State.Name = "Propeller plane";
                //Meshes.Add(SimulationEngine.ResourceCache.CreateMesh(device, _particlePlane.State));
                //Meshes[0].Textures[0] = SimulationEngine.ResourceCache.CreateTextureFromFile(device, "A-Eye/prop_rot.png");

                if (Parent == null)
                {
                    throw new Exception("This entity must be a child of another entity.");
                }

                // Add to parent
                propellerShape = new BoxShape(propellerShapeProperties);
                Meshes.Add(SimulationEngine.ResourceCache.CreateMeshFromFile(device, State.Assets.Mesh));
                propellerVisualMesh = Parent.AddShapeToPhysicsEntity(propellerShape, null);
            }
            catch (Exception ex)
            {
                HasBeenInitialized = false;
                InitError          = ex.ToString();
            }
        }
Esempio n. 30
0
        public Particle(int w, int h)
        {
            W = w;
            H = h;
            Mesh3D mesh = new Mesh3D(12, 4);

            Vector3 p1 = new Vector3(-w / 2, -h / 2, 0);
            Vector3 p2 = new Vector3(w / 2, -h / 2, 0);
            Vector3 p3 = new Vector3(w / 2, h / 2, 0);
            Vector3 p4 = new Vector3(-w / 2, h / 2, 0);

            Vector2 uv1 = new Vector2(0, 0);
            Vector2 uv2 = new Vector2(1, 0);
            Vector2 uv3 = new Vector2(1, 1);
            Vector2 uv4 = new Vector2(0, 1);

            Vector3 z = Vector3.Zero;

            mesh.SetVertex(0, p1, z, z, z, uv1);
            mesh.SetVertex(1, p2, z, z, z, uv2);
            mesh.SetVertex(2, p3, z, z, z, uv3);
            mesh.SetVertex(3, p4, z, z, z, uv4);

            mesh.SetIndex(0, 0);
            mesh.SetIndex(1, 1);
            mesh.SetIndex(2, 2);
            mesh.SetIndex(3, 2);
            mesh.SetIndex(4, 3);
            mesh.SetIndex(5, 0);

            mesh.SetIndex(6, 2);
            mesh.SetIndex(7, 1);
            mesh.SetIndex(8, 0);
            mesh.SetIndex(9, 0);
            mesh.SetIndex(10, 3);
            mesh.SetIndex(11, 2);

            mesh.Final();

            Meshes.Add(mesh);
        }
Esempio n. 31
0
		public UvMorph[] script;	// UVモーフのスクリプト配列
		
		public UvMorphPack(Meshes[] i = null, Vector2[] s = null, UvMorph[] c = null) {meshes = i; source = s; script = c;}
Esempio n. 32
0
		public VertexMorph[] script;			// 頂点モーフのスクリプト配列
		
		public VertexMorphPack(Meshes[] i = null, Vector3[] s = null, VertexMorph[] c = null) {meshes = i; source = s; script = c;}
Esempio n. 33
0
		public MaterialMorph[] script;							// 材質モーフのスクリプト配列
		
		public MaterialMorphPack(Meshes[] i = null, MaterialMorph.MaterialMorphParameter[] s = null, MaterialMorph[] c = null) {meshes = i; source = s; script = c;}