コード例 #1
0
 public static OgreResourceGroupManager getInstance()
 {
     if (instance == null)
     {
         instance = new OgreResourceGroupManager();
     }
     return(instance);
 }
コード例 #2
0
 /// <summary>
 /// This funciton will build the MovableObject and return it to this
 /// class so it can be configured with all of the MovableObject
 /// properties.
 /// </summary>
 /// <param name="element">The SceneNodeElement to add the definition to so it can be destroyed properly.</param>
 /// <param name="scene">The OgreSceneManager that will get the entity.</param>
 /// <param name="simObject">The SimObject that will get the entity.</param>
 /// <returns>The newly created MovableObject or null if there was an error.</returns>
 internal override MovableObjectContainer createActualProduct(OgreSceneManager scene, String baseName)
 {
     if (OgreResourceGroupManager.getInstance().findGroupContainingResource(meshName) != null)
     {
         Entity entity = scene.SceneManager.createEntity(baseName + Name, meshName);
         if (entity.hasSkeleton() && skeleton != null)
         {
             skeleton.initialzeSkeleton(entity.getSkeleton());
         }
         return(new EntityContainer(Name, entity));
     }
     else
     {
         Log.Default.sendMessage("Cannot create entity {0} because the mesh {1} cannot be found.", LogLevel.Warning, OgreInterface.PluginName, Name, meshName);
         return(null);
     }
 }
コード例 #3
0
        public UnifiedMaterialBuilder(VirtualTextureManager virtualTextureManager, CompressedTextureSupport textureFormat, ResourceManager liveResourceManager)
        {
            PixelFormat      otherFormat;
            PixelFormat      normalFormat;
            NormaMapReadMode normalMapReadMode = NormaMapReadMode.RG;

            switch (textureFormat)
            {
            case CompressedTextureSupport.DXT_BC4_BC5:
                textureFormatExtension       = ".dds";
                normalTextureFormatExtension = "_bc5.dds";
                normalMapReadMode            = NormaMapReadMode.RG;
                createOpacityTexture         = true;
                otherFormat  = PixelFormat.PF_DXT5;
                normalFormat = PixelFormat.PF_BC5_UNORM;
                break;

            case CompressedTextureSupport.DXT:
                textureFormatExtension       = ".dds";
                normalTextureFormatExtension = ".dds";
                normalMapReadMode            = NormaMapReadMode.AG;
                createOpacityTexture         = true;
                otherFormat  = PixelFormat.PF_DXT5;
                normalFormat = PixelFormat.PF_DXT5;
                break;

            default:
            case CompressedTextureSupport.None:
                textureFormatExtension       = PagedImage.FileExtension;
                normalTextureFormatExtension = PagedImage.FileExtension;
                normalMapReadMode            = NormaMapReadMode.RG;
                createOpacityTexture         = false;
                otherFormat  = PixelFormat.PF_A8R8G8B8;
                normalFormat = PixelFormat.PF_A8R8G8B8;
                break;
            }

            this.virtualTextureManager = virtualTextureManager;

            if (OgreInterface.Instance.RenderSystem.isShaderProfileSupported("hlsl"))
            {
                shaderFactory = new HlslUnifiedShaderFactory(liveResourceManager, normalMapReadMode, createOpacityTexture);
            }
            else if (OgreInterface.Instance.RenderSystem.isShaderProfileSupported("glsl"))
            {
                shaderFactory = new GlslUnifiedShaderFactory(liveResourceManager, normalMapReadMode, createOpacityTexture);
            }
            else if (OgreInterface.Instance.RenderSystem.isShaderProfileSupported("glsles"))
            {
                shaderFactory = new GlslesUnifiedShaderFactory(liveResourceManager, normalMapReadMode, createOpacityTexture);
            }
            else
            {
                throw new OgreException("Cannot create Unified Material Builder, device must support shader profiles hlsl, glsl, or glsles.");
            }

            diffuseTexture  = virtualTextureManager.createPhysicalTexture("Diffuse", otherFormat);
            normalTexture   = virtualTextureManager.createPhysicalTexture("NormalMap", normalFormat);
            specularTexture = virtualTextureManager.createPhysicalTexture("Specular", otherFormat);

            if (createOpacityTexture)
            {
                opacityTexture = virtualTextureManager.createPhysicalTexture("Opacity", otherFormat);
            }

            specialMaterialFuncs.Add("EyeOuter", createEyeOuterMaterial);
            specialMaterialFuncs.Add("ColorVertex", createColorVertexMaterial);

            OgreResourceGroupManager.getInstance().createResourceGroup(GroupName);

            MaterialPtr hiddenMaterial = MaterialManager.getInstance().create("HiddenMaterial", GroupName, false, null);

            setupHiddenMaterialPass(hiddenMaterial.Value.getTechnique(0).getPass(0), false, false);
            createdMaterials.Add(hiddenMaterial.Value, new MaterialInfo(hiddenMaterial.Value, null));
            builtInMaterials.Add(hiddenMaterial);

            //Delete stock resources
            MaterialManager.getInstance().remove("BaseWhite");
            MaterialManager.getInstance().remove("BaseWhiteNoLighting");
            MaterialManager.getInstance().remove("Ogre/Debug/AxesMat");

            //Rebuild with our materials
            var baseWhite = createFromDescription(new MaterialDescription()
            {
                Name = "BaseWhite"
            }, false);

            builtInMaterials.Add(baseWhite);

            var baseWhiteNoLighting = createFromDescription(new MaterialDescription()
            {
                Name = "BaseWhiteNoLighting"
            }, false);

            builtInMaterials.Add(baseWhiteNoLighting);

            MaterialPtr axesMat = MaterialManager.getInstance().create("Ogre/Debug/AxesMat", GroupName, false, null);

            axesMat.Value.setLightingEnabled(false);
            axesMat.Value.setSceneBlending(SceneBlendType.SBT_TRANSPARENT_ALPHA);
            axesMat.Value.setCullingMode(CullingMode.CULL_NONE);
            axesMat.Value.setDepthWriteEnabled(false);
            axesMat.Value.setDepthCheckEnabled(false);
            builtInMaterials.Add(axesMat);
            createdMaterials.Add(axesMat.Value, new MaterialInfo(axesMat.Value, null));
        }
コード例 #4
0
        /// <summary>
        /// This function will create any debug commands for the plugin and add them to the commands list.
        /// </summary>
        /// <param name="commands">A list of CommandManagers to add debug commands to.</param>
        public void createDebugCommands(List <CommandManager> commands)
        {
            CommandManager ogreDebugCommands = new CommandManager("Ogre");

            ogreDebugCommands.addCommand(new EngineCommand("addResourceLocation", "Add Ogre Resource Location", "Add a resource location to ogre.", new AddResourceLocation(OgreResourceGroupManager.getInstance().addResourceLocation)));
            ogreDebugCommands.addCommand(new EngineCommand("initializeResourceGroups", "Initialize Ogre Resources", "Initialize all added ogre resources.", new InitializeResourceGroups(OgreResourceGroupManager.getInstance().initializeAllResourceGroups)));
            commands.Add(ogreDebugCommands);
        }
コード例 #5
0
 internal OgreResourceManager(MaterialParserManager materialParser)
 {
     this.materialParser = materialParser;
     ogreResourceManager = OgreResourceGroupManager.getInstance();
     instance            = this;
 }