Exemplo n.º 1
0
        public Button(Vector4 D, String M, String T, Callback C, Window P, Window window)
        {
            this.window = window;
            text        = T;

            x   = D.x;
            y   = D.y;
            w   = D.z;
            h   = D.w;
            mmn = M;
            mma = M;

            ResourcePtr ma = MaterialManager.Singleton.GetByName(mmn + ".active");

            if (ma != null)
            {
                mma += ".active";
            }
            ma = null;

            mO = P.mGUI.createOverlay(P.mO.Name + "b" +
                                      StringConverter.ToString(P.mGUI.bc++),
                                      new Vector2(x, y), new Vector2(w, h), M, "", false);

            mCP = P.mGUI.createOverlay(mO.Name + "c",
                                       new Vector2(GUI.OVERLAY_TITLE_MARGIN, (h - P.mGUI.mFontSize) / 2),
                                       new Vector2(w, h), "", T, false);

            P.mO.AddChild(mO);
            mO.Show();
            mO.AddChild(mCP);
            mCP.Show();
            callback = C;
        }
Exemplo n.º 2
0
 public ResourcePtr(ResourcePtr r) : this(OgrePINVOKE.new_ResourcePtr__SWIG_2(ResourcePtr.getCPtr(r)), true)
 {
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
        public override void OnInit()
        {
            base.OnInit();

            InputProcessor.UpdateActionBinding("Left", Key.D, Key.Left);
            InputProcessor.UpdateActionBinding("Right", Key.A, Key.Right);
            InputProcessor.UpdateActionBinding("Up", Key.W, Key.Up);
            InputProcessor.UpdateActionBinding("Down", Key.S, Key.Down);

            ResourcePtr Font = new ResourcePtr("font:Fonts/Work_Sans/WorkSans-Regular.ttf");

            Text = new Text("Hello World", Font.Get <Font>());
            Text.CharacterSize = 24;
            Text.FillColor     = Color.Red;


            World newWorld = LoadWorld(World.Get <WorldScript>());

            var actor = newWorld.CreateActor <Actor>(TestActor.Get <ActorScript>());

            actor.Location = new Vector3(100, 100, 0);

            Actor secondACtor = newWorld.CreateActor <Actor>(SecondActor.Get <ActorScript>());

            secondACtor.Location = new Vector3(500, 100, 0);
        }
Exemplo n.º 4
0
        /// <summary>
        /// initialize all resource groups in the resource configuration file
        /// </summary>
        private void InitializeResourceGroups()
        {
            TextureManager.Singleton.DefaultNumMipmaps             = 4;
            MeshManager.Singleton.PrepareAllMeshesForShadowVolumes = true;

            // for now, we just load all of the resource groups
            ResourceGroupManager.Singleton.InitialiseAllResourceGroups();

            // usually, though, we'll need to fine comb it a little more
            // InitializeResourceGroup allows us to load a single resource group,
            // rather than loading the entire set at once

            //load verdana font
            try {
                FontManager fontMgr = FontManager.Singleton;
                ResourcePtr font    = fontMgr.Create("Verdana", "General");
                font.SetParameter("type", "truetype");
                font.SetParameter("source", "verdana.ttf");
                font.SetParameter("size", "16");
                font.SetParameter("resolution", "96");
                font.Load();
                Console.Out.WriteLine("loaded, yo!");
            }
            catch (Exception e) {
                Util.Log("Unable to load verdana.ttf");
            }
        }
Exemplo n.º 5
0
        public static MaterialPtr CloneMaterial(String orgName, String cloneName)
        {
            if (MaterialManager.Singleton.ResourceExists(cloneName))
            {
                using (ResourcePtr res = MaterialManager.Singleton.GetByName(cloneName))
                    using (MaterialPtr matPtr = res)
                    {
                        if (matPtr.CompilationRequired)
                        {
                            matPtr.Compile();
                        }
                        return(matPtr);
                    }
            }


            using (ResourcePtr res = MaterialManager.Singleton.GetByName(orgName))
                using (MaterialPtr matPtr = res)
                {
                    if (matPtr.IsLoaded)
                    {
                        matPtr.Load();
                    }
                    if (matPtr.CompilationRequired)
                    {
                        matPtr.Compile();
                    }

                    return(matPtr.Clone(cloneName));
                }
        }
        public override object GetResource(ResourcePtr ptr, Stream stream)
        {
            using (TextReader Reader = new StreamReader(stream))
                using (JsonReader JReader = new JsonTextReader(Reader))
                {
                    MaterialScript ms = Activator.CreateInstance <MaterialScript>();
                    ms.JObject = JObject.Load(JReader);

                    //Validate that we have required shaders
                    if (ms.FragmentShader == null)
                    {
                        throw new WatertightLoadingFailureException(string.Format("Error loading material: {0}, missing $FragmentShader", ptr.ToString()));
                    }
                    if (ms.VertexShader == null)
                    {
                        throw new WatertightLoadingFailureException(string.Format("Error loading material: {0}, missing $VertexShader", ptr.ToString()));
                    }

                    Material Mat = IEngine.Instance.Renderer.MaterialFactory.Create(ms);

                    //Load the shaders
                    Mat._Shaders[Shader.Stage.Fragment] = GetShader(ms.FragmentShader, Shader.Stage.Fragment);
                    Mat._Shaders[Shader.Stage.Vertex]   = GetShader(ms.VertexShader, Shader.Stage.Vertex);

                    Mat.PostLoad();

                    return(Mat);
                }
        }
 public void _notifyResourceRemoved(ResourcePtr res)
 {
     OgrePINVOKE.ResourceGroupManager__notifyResourceRemoved(swigCPtr, ResourcePtr.getCPtr(res));
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 8
0
 public void remove(ResourcePtr r)
 {
     OgrePINVOKE.ResourceManager_remove__SWIG_0(swigCPtr, ResourcePtr.getCPtr(r));
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 9
0
 public override object GetResource(ResourcePtr Ptr, Stream stream)
 {
     using (MemoryStream s = new MemoryStream())
     {
         stream.CopyTo(s);
         return(new Font(s.ToArray()));
     }
 }
Exemplo n.º 10
0
 public virtual void resourcePrepareStarted(ResourcePtr resource)
 {
     OgrePINVOKE.ResourceGroupListener_resourcePrepareStarted(swigCPtr, ResourcePtr.getCPtr(resource));
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Exemplo n.º 11
0
 public override object GetResource(ResourcePtr ptr, Stream stream)
 {
     using (XmlReader xml = XmlReader.Create(stream))
     {
         TmxTileset Tileset = new TmxTileset(XDocument.Load(xml).Element("tileset"), ptr.FolderPath);
         return(Tileset);
     }
 }
Exemplo n.º 12
0
        public virtual ResourcePtr getByHandle(ulong handle)
        {
            ResourcePtr ret = new ResourcePtr(OgrePINVOKE.ResourceManager_getByHandle(swigCPtr, handle), true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 13
0
        public override ResourcePtr getResourceByName(string name)
        {
            ResourcePtr ret = new ResourcePtr(OgrePINVOKE.GpuProgramManager_getResourceByName__SWIG_2(swigCPtr, name), true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 14
0
 public override object GetResource(ResourcePtr Ptr, Stream stream)
 {
     using (TextReader Reader = new StreamReader(stream))
         using (JsonReader JReader = new JsonTextReader(Reader))
         {
             ObjectScript os = Activator.CreateInstance(ScriptType) as ObjectScript;
             os.JObject = JObject.Load(JReader);
             return(os);
         }
 }
Exemplo n.º 15
0
        public virtual ResourcePtr create(string name, string group, GpuProgramType gptype, string syntaxCode)
        {
            ResourcePtr ret = new ResourcePtr(OgrePINVOKE.GpuProgramManager_create__SWIG_2(swigCPtr, name, group, (int)gptype, syntaxCode), true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 16
0
        public ResourcePtr getResourceByName(string name, string group, bool preferHighLevelPrograms)
        {
            ResourcePtr ret = new ResourcePtr(OgrePINVOKE.GpuProgramManager_getResourceByName__SWIG_0(swigCPtr, name, group, preferHighLevelPrograms), true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 17
0
        public ResourcePtr createResource(string name, string group)
        {
            ResourcePtr ret = new ResourcePtr(OgrePINVOKE.ResourceManager_createResource__SWIG_3(swigCPtr, name, group), true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 18
0
        public ResourcePtr load(string name, string group, bool isManual)
        {
            ResourcePtr ret = new ResourcePtr(OgrePINVOKE.ResourceManager_load__SWIG_3(swigCPtr, name, group, isManual), true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 19
0
        public ResourcePtr createResource(string name, string group, bool isManual, ManualResourceLoader loader)
        {
            ResourcePtr ret = new ResourcePtr(OgrePINVOKE.ResourceManager_createResource__SWIG_1(swigCPtr, name, group, isManual, ManualResourceLoader.getCPtr(loader)), true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 20
0
        public ResourcePtr load(string name, string group, bool isManual, ManualResourceLoader loader, NameValuePairList loadParams)
        {
            ResourcePtr ret = new ResourcePtr(OgrePINVOKE.ResourceManager_load__SWIG_1(swigCPtr, name, group, isManual, ManualResourceLoader.getCPtr(loader), NameValuePairList.getCPtr(loadParams)), true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 21
0
        public virtual ResourcePtr getResourceByName(string name)
        {
            ResourcePtr ret = new ResourcePtr(OgrePINVOKE.ResourceManager_getResourceByName__SWIG_1(swigCPtr, name), true);

            if (OgrePINVOKE.SWIGPendingException.Pending)
            {
                throw OgrePINVOKE.SWIGPendingException.Retrieve();
            }
            return(ret);
        }
Exemplo n.º 22
0
        private void Load(string fontFileName, string fontRef, int size)
        {
            ResourcePtr font = FontManager.Singleton.Create(fontRef, ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME);

            font.SetParameter("type", "truetype");
            font.SetParameter("source", fontFileName);
            font.SetParameter("size", size.ToString());
            font.SetParameter("resolution", "96");
            font.Load();
        }
        private Shader GetShader(ResourcePtr ptr, Shader.Stage stage)
        {
            if (ptr.Loaded)
            {
                return(ptr.Get <Shader>());
            }
            Shader s = IEngine.Instance.Renderer.MaterialFactory.CreateShader(stage, FileSystem.GetFileStream(ptr));

            s.ShaderFormat = Shader.SPIRV;
            FileSystem.EmplaceInMemoryResource(ptr, s);

            return(s);
        }
Exemplo n.º 24
0
 protected void createEffectHeatVision()
 {
     /// Heat vision effect
     CompositorPtr comp4 = new CompositorPtr(ResourcePtr.getCPtr(CompositorManager.Instance.GetAsResourceManager().Create(
                                                                     "Heat Vision", ResourceGroupManager.DEFAULT_RESOURCE_GROUP_NAME)).Handle, false);
     CompositionTechnique t = comp4.Get().createTechnique();
     {
         CTTextureDefinition def = t.CreateTextureDefinition("scene");
         def.setWidth(256);
         def.setHeight(256);
         def.setFormat(OgreDotNet.PixelFormat.PF_R8G8B8);
     }
     {
         CTTextureDefinition def = t.CreateTextureDefinition("temp");
         def.setWidth(256);
         def.setHeight(256);
         def.setFormat(OgreDotNet.PixelFormat.PF_R8G8B8);
     }
     /// Render scene
     {
         CompositionTargetPass tp = t.createTargetPass();
         tp.setInputMode(CompositionTargetPass.InputMode.IM_PREVIOUS);
         tp.SetOutputName("scene");
     }
     /// Light to heat pass
     {
         CompositionTargetPass tp = t.createTargetPass();
         tp.setInputMode(CompositionTargetPass.InputMode.IM_NONE);
         tp.SetOutputName("temp");
         {
             CompositionPass pass = tp.createPass();
             pass.setType(CompositionPass.PassType.PT_RENDERQUAD);
             pass.setIdentifier(0xDEADBABE);                               /// Identify pass for use in listener
             pass.setMaterialName("Fury/HeatVision/LightToHeat");
             pass.setInput(0, "scene");
         }
     }
     /// Display result
     {
         CompositionTargetPass tp = t.getOutputTargetPass();
         tp.setInputMode(CompositionTargetPass.InputMode.IM_NONE);
         {
             CompositionPass pass = tp.createPass();
             pass.setType(CompositionPass.PassType.PT_RENDERQUAD);
             pass.setMaterialName("Fury/HeatVision/Blur");
             pass.setInput(0, "temp");
         }
     }
 }
Exemplo n.º 25
0
        protected void registerCompositors()
        {
            Viewport vp = mRenderWindow.GetViewport(0);

            mhvListener  = new HeatVisionListener();
            mhdrListener = new HDRListener();

            mCompositorSelectorViewManager = new ItemSelectorViewManager("CompositorSelectorWin");
            // tell view manager to notify us when an item changes selection state
            mCompositorSelectorViewManager.EventItemStateChanged += new ISVMItemStateChanged(ItemStateChanged);
            //iterate through Compositor Managers resources and add name keys ast Item selectors to Compositor selector view manager
            OgreDotNet.ResourceMapIteratorWrap resourceIterator =
                CompositorManager.Instance.GetAsResourceManager().getResourceIterator();

            // add all compositor resources to the view container
            while (resourceIterator.hasMoreElements())
            {
                ResourcePtr resource       = resourceIterator.getNext();
                string      compositorName = resource.GetName();
                // Don't add base Ogre/Scene compositor to view
                if (compositorName == "Ogre/Scene")
                {
                    continue;
                }

                mCompositorSelectorViewManager.addItemSelector(compositorName);
                int addPosition = -1;
                if (compositorName == "HDR")
                {
                    // HDR must be first in the chain
                    addPosition = 0;
                }
                CompositorInstance instance = CompositorManager.Instance.addCompositor(vp, compositorName, addPosition);
                CompositorManager.Instance.setCompositorEnabled(vp, compositorName, false);
                // special handling for Heat Vision which uses a listener
                if ((instance != null) && (compositorName == "Heat Vision"))
                {
                    instance.AddListener(mhvListener);
                }
                else if ((instance != null) && (compositorName == "HDR"))
                {
                    instance.AddListener(mhdrListener);
                    mhdrListener.notifyViewportSize(vp.GetActualWidth(), vp.GetActualHeight());
                    mhdrListener.notifyCompositor(instance);
                }
            }
        }
Exemplo n.º 26
0
        public unsafe void Replace3(byte[] bytes, string textureName)
        {
            using (ResourcePtr rpt = TextureManager.Singleton.GetByName(textureName))
            {
                using (TexturePtr texture = rpt)
                {
                    HardwarePixelBufferSharedPtr texBuffer = texture.GetBuffer();
                    texBuffer.Lock(HardwareBuffer.LockOptions.HBL_DISCARD);
                    PixelBox pb = texBuffer.CurrentLock;

                    Marshal.Copy(bytes, 0, pb.data, bytes.Length);

                    texBuffer.Unlock();
                    texBuffer.Dispose();
                }
            }
        }
Exemplo n.º 27
0
        private static unsafe void ConvertImageToTexture(Bitmap image, string textureName, Size size)
        {
            int width  = size.Width;
            int height = size.Height;

            using (ResourcePtr rpt = TextureManager.Singleton.GetByName(textureName))
            {
                using (TexturePtr texture = rpt)
                {
                    HardwarePixelBufferSharedPtr texBuffer = texture.GetBuffer();
                    texBuffer.Lock(HardwareBuffer.LockOptions.HBL_DISCARD);
                    PixelBox pb = texBuffer.CurrentLock;

                    System.Drawing.Imaging.BitmapData data = image.LockBits(new System.Drawing.Rectangle(0, 0, width, height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                    CopyMemory(pb.data, data.Scan0, (uint)(width * height * 4));
                    image.UnlockBits(data);

                    texBuffer.Unlock();
                    texBuffer.Dispose();
                }
            }
        }
Exemplo n.º 28
0
        } // mCP here if ...

        public TextInput(Vector4 D, String M, String V, uint L, Window P)
        {
            x      = D.x;
            y      = D.y;
            w      = D.z;
            h      = D.w;
            value  = V;
            mmn    = M;
            mme    = M;
            mma    = M;
            length = L;

            ResourcePtr ma = MaterialManager.Singleton.GetByName(mmn + ".active");

            if (ma != null)
            {
                mma += ".active";
            }
            ma = null;

            ma = MaterialManager.Singleton.GetByName(mmn + ".active.error");
            if (ma != null)
            {
                mme += ".active.error";
            }
            ma = null;

            mO = P.mGUI.createOverlay(P.mO.Name + "t" +
                                      StringConverter.ToString(P.mGUI.tc++),
                                      new Vector2(x, y), new Vector2(w, h), M, "", false);
            mCP = P.mGUI.createOverlay(mO.Name + "c",
                                       new Vector2(0, (h - P.mGUI.mFontSize) / 2),
                                       new Vector2(w, h), "", V, false);
            P.mO.AddChild(mO);
            mO.Show();
            mO.AddChild(mCP);
            mCP.Show();
        }
Exemplo n.º 29
0
            bool CacheRead(BlamLib.Blam.CacheFile c, out byte[] data)
            {
                data = null;

                ResourcePtr offset = GetOffset(0);
                int         size   = GetSize(0);

                var rsrc_cache = Program.Halo2.FromLocation(c as Halo2.CacheFile, offset);

                // the shared cache isn't loaded, break
                if (rsrc_cache == null)
                {
                    return(false);
                }

                // get the input stream we need
                IO.EndianReader er = rsrc_cache.InputStream;

                // read the bitmap
                er.Seek(offset.Offset);
                data = er.ReadBytes(size);

                return(true);
            }
Exemplo n.º 30
0
 void ResourceLoadStarted(ResourcePtr resource)
 {
     loadingCommentElement.Caption = resource.Name;
     window.Update();
 }
Exemplo n.º 31
0
 private void Singleton_ResourceLoadStarted(ResourcePtr resource)
 {
     _currentProcess += _resourceItemScalar;
     CallResourceItemLoaded(new ResourceLoadEventArgs(resource.Name, _currentProcess));
 }
Exemplo n.º 32
0
        public virtual object CreateInstance(Type NativeClass = null)
        {
            //If we have a parent script and a native class, instantiate the native class and apply all parent scripts.
            //If we have a Parent Script and No Native Class, walk up the chain until we find a Native Class (if no class, throw exception)
            //If we have No Parent Script and a Native Class, create the native class and apply this script.
            //If we have Neither Parent Script or Native Class, throw an exception.

            //Find the parent native class

            Type FoundNativeClass = FindNativeClass() ?? NativeClass;

            if (FoundNativeClass == null)
            {
                throw new MissingRequiredScriptFieldException(string.Format("{0} Has no {1} in any search path", ResourcePtr.ToString(), NativeClassName));
            }


            object o = Activator.CreateInstance(FoundNativeClass);

            if (o is IPostConstruct)
            {
                (o as IPostConstruct).PostConstruct();
            }
            ApplyToObject(o);

            return(o);
        }
Exemplo n.º 33
0
 void ResourceLoadStarted(ResourcePtr resource)
 {
     LoadingBarWindow.Dispatcher.BeginInvoke(System.Windows.Threading.DispatcherPriority.Normal, new Action(
             delegate()
             {
                 LoadingBarWindow.Caption = resource.Name;
             }
         )
     );
 }