Пример #1
0
        public HeightMapRenderer(HeightMapMesh heightMap, AnimationUtilities.SkinnedEffect effect)
        {
            mMesh = heightMap;
            mEffect = effect;

            mUIConfigurer = null;
        }
Пример #2
0
        public WaterRenderer(Vector2 resolution, AnimationUtilities.SkinnedEffect effect)
        {
            mEffect = effect;
            mResolution = resolution;

            ResizeVertices();
            ResizeIndices();
            FillBuffers();

            mUIConfigurer = null;
        }
Пример #3
0
        public SkyBoxRenderer(AnimationUtilities.SkinnedEffect effect)
        {
            mEffect = effect;

            CreateBuffers();

            mNormalDepthConfigurer = null;
            mShadowMapConfigurer = null;
            mPickingConfigurer = null;
            mUIConfigurer = null;
            mOverlayConfigurer = null;
        }
Пример #4
0
 /// <summary>
 /// Sets up pipeline for executing shaders.
 /// </summary>
 private static void LoadShaders(ContentManager content)
 {
     mConfigurableShader = content.Load<Effect>("shaders/ConfigurableShader");
     mPostProcessShader = content.Load<Effect>("shaders/PostProcessing");
     mVertexBufferShader = new AnimationUtilities.SkinnedEffect(mConfigurableShader);
 }
Пример #5
0
        private static void LoadModels(ContentManager content)
        {
            DirectoryInfo dir = new DirectoryInfo(content.RootDirectory + "\\" + "models");
            if (!dir.Exists)
            {
                throw new DirectoryNotFoundException("Could not find models directory \n" + dir.FullName + "\nin content.");
            }

            DirectoryInfo[] subDirs = dir.GetDirectories();
            foreach (DirectoryInfo subDir in subDirs)
            {
                string subDirName = subDir.Name;

                FileInfo[] files = subDir.GetFiles("*.xnb");
                foreach (FileInfo file in files)
                {
                    try
                    {
                        string modelName = Path.GetFileNameWithoutExtension(file.Name);
                        bool isSkinned = false;

                        Model input = content.Load<Model>("models/" + subDirName + "/" + modelName);

                        foreach (ModelMesh mesh in input.Meshes)
                        {
                            foreach (ModelMeshPart part in mesh.MeshParts)
                            {
                                Microsoft.Xna.Framework.Graphics.SkinnedEffect skinnedEffect = part.Effect as Microsoft.Xna.Framework.Graphics.SkinnedEffect;
                                if (skinnedEffect != null)
                                {
                                    AnimationUtilities.SkinnedEffect newEffect = new AnimationUtilities.SkinnedEffect(mConfigurableShader);
                                    newEffect.CopyFromSkinnedEffect(skinnedEffect);

                                    part.Effect = newEffect;

                                    isSkinned = true;
                                }
                                else
                                {
                                    Microsoft.Xna.Framework.Graphics.BasicEffect basicEffect = part.Effect as Microsoft.Xna.Framework.Graphics.BasicEffect;
                                    if (basicEffect != null)
                                    {
                                        AnimationUtilities.SkinnedEffect newEffect = new AnimationUtilities.SkinnedEffect(mConfigurableShader);
                                        newEffect.CopyFromBasicEffect(basicEffect);

                                        part.Effect = newEffect;
                                    }
                                }
                            }
                        }

                        AddInanimateModel(modelName, new ModelRenderer(input));
                        if (isSkinned)
                        {
                            AddAnimateModel(modelName, new AnimateModelRenderer(input));
                        }
                    }
                    catch { }
                }

                // Parse Bone Orientation Tweak File and store in library.
                FileInfo[] tweakOrientationFiles = subDir.GetFiles("*.tweak");
                foreach (FileInfo file in tweakOrientationFiles)
                {
                    Dictionary<string, Matrix> tweakLibrary = new Dictionary<string, Matrix>();
                    TextReader tr = new StreamReader(file.DirectoryName + "\\" + file.Name);

                    int count = int.Parse(tr.ReadLine());
                    string blank = tr.ReadLine();

                    for (int i = 0; i < count; ++i)
                    {
                        Matrix tweakMatrix;
                        string boneName;
                        ParseTweakFile(tr, out boneName, out tweakMatrix);

                        tweakLibrary.Add(boneName, tweakMatrix);
                    }
                    tr.Close();

                    LookupAnimateModel(Path.GetFileNameWithoutExtension(file.Name)).BoneTweakLibrary = tweakLibrary;
                }
            }
        }