problem with my own visualizer

Nov 23, 2010 at 9:37 PM

hi,

I was writing my physic bodies visualizer for this awesome engine and error occured:

 

my source:

 

    class PhysicVisualizer : SingleSurfaceComponent<PhysicVisualizerSurface>
    {


         public PhysicVisualizer (OxEngine engine, string domainName, bool ownedByDomain)
            : base(engine, domainName, ownedByDomain)
        {
            
// this coauses error:
 AddGarbage(surface = Engine.GetService<SurfaceFactory>().CreateSurface<PhysicVisualizerSurface>(this)); } protected override PhysicVisualizerSurface SurfaceHook { get { return surface; } } private readonly PhysicVisualizerSurface surface; }

 

and error:

System.NullReferenceException was unhandled
  Message="Odwołanie do obiektu nie zostało ustawione na wystąpienie obiektu."
  Source="Ox.Scene"
  StackTrace:
       w Ox.Scene.SurfaceNamespace.SurfaceFactory.CreateSurface[T](SceneComponent component)
       w Gra.Content.klasy.PhysicVisualizer..ctor(OxEngine engine, String domainName, Boolean ownedByDomain) w C:\Documents and Settings\Admin\Moje dokumenty\Visual Studio 2008\Projects\Gra\Gra\Content\klasy\PhysicVisualizer.cs:wiersz 21
       w Gra.GameScript.ZaladujGre() w C:\Documents and Settings\Admin\Moje dokumenty\Visual Studio 2008\Projects\Gra\Gra\GameScript.cs:wiersz 86
       w Gra.GameScript.<.ctor>b__0(Button x) w C:\Documents and Settings\Admin\Moje dokumenty\Visual Studio 2008\Projects\Gra\Gra\GameScript.cs:wiersz 42
       w Ox.Gui.Component.Button.HandleAffirmButton(InputType inputType)
       w Ox.Gui.Component.Button.this_AbstractAction(BaseGuiComponent sender, InputType inputType, AbstractEventType eventType)
       w Ox.Gui.Event.AbstractAction.Invoke(BaseGuiComponent sender, InputType inputType, AbstractEventType eventType)
       w Ox.Gui.Component.BaseGuiComponent.RaiseAbstractEvent(InputType inputType, AbstractEventType eventType)
       w Ox.Gui.Component.Button.HandleLeftMouse(InputType type)
       w Ox.Gui.Component.Button.this_MouseButtonAction(BaseGuiComponent sender, InputType type, MouseButton button, Vector2 mousePosition)
       w Ox.Gui.Event.MouseButtonAction.Invoke(BaseGuiComponent sender, InputType inputType, MouseButton button, Vector2 mousePosition)
       w Ox.Gui.Component.BaseGuiComponent.RaiseMouseButtonEvent(InputType inputType, MouseButton button, Vector2 mousePosition)
       w Ox.Gui.Component.BaseGuiComponent.this_MouseButtonAction(BaseGuiComponent sender, InputType type, MouseButton button, Vector2 mousePos)
       w Ox.Gui.Component.BaseGuiComponent.RaiseMouseButtonEvent(InputType inputType, MouseButton button, Vector2 mousePosition)
       w Ox.Gui.Event.MouseEventForwarder.UpdateSpecificButtonInput(Vector2 mousePosition, MouseButton button, ButtonState mouseButtonState)
       w Ox.Gui.Event.MouseEventForwarder.UpdateMouseInput()
       w Ox.Gui.Event.MouseEventForwarder.UpdateHook(GameTime gameTime)
       w Ox.Engine.Utility.OxUpdateable.Update(GameTime gameTime)
       w Ox.Gui.Event.EventForwarder.UpdateHook(GameTime gameTime)
       w Ox.Engine.Utility.OxUpdateable.Update(GameTime gameTime)
       w Ox.Gui.GuiSystem.UpdateEventForwarder(GameTime gameTime)
       w Ox.Gui.GuiSystem.Update(GameTime gameTime)
       w Ox.DefaultEngineNamespace.DefaultEngine.UpdateGuiSystem(GameTime gameTime)
       w Ox.DefaultEngineNamespace.DefaultEngine.PostUpdate(GameTime gameTime)
       w Ox.DefaultEngineNamespace.DefaultEngine.UpdateHook(GameTime gameTime)
       w Ox.Engine.OxEngine.Update(GameTime gameTime)
       w Gra.Program.Update(GameTime gameTime) w C:\Documents and Settings\Admin\Moje dokumenty\Visual Studio 2008\Projects\Gra\Gra\Program.cs:wiersz 65
       w Microsoft.Xna.Framework.Game.Tick()
       w Microsoft.Xna.Framework.Game.HostIdle(Object sender, EventArgs e)
       w Microsoft.Xna.Framework.GameHost.OnIdle()
       w Microsoft.Xna.Framework.WindowsGameHost.ApplicationIdle(Object sender, EventArgs e)
       w System.Windows.Forms.Application.ThreadContext.System.Windows.Forms.UnsafeNativeMethods.IMsoComponent.FDoIdle(Int32 grfidlef)
       w System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       w System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       w System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       w System.Windows.Forms.Application.Run(Form mainForm)
       w Microsoft.Xna.Framework.WindowsGameHost.Run()
       w Microsoft.Xna.Framework.Game.Run()
       w Gra.Program.Main(String[] args) w C:\Documents and Settings\Admin\Moje dokumenty\Visual Studio 2008\Projects\Gra\Gra\Program.cs:wiersz 76
  InnerException:

 

so, anybody knows, what's the problem?

whole progem compiles, and this shit happens when i'm launching scene and this visualizer, i don't know, but is possible that the surfacefactory does'nt exist(is null?)?

//i'm from poland so some words are in polish but the most important things are in english

Nov 24, 2010 at 6:34 PM

don't worry know, i'm not lazy. after learning solo to  highway star , i read the source code of Ox engine end found the reason of the error. so know i can draw whatever i want.

know my code is looking like:

 

   public  class PhysicVisualizer : SingleSurfaceComponent<PhysicVisualizerSurface>
    {

         public PhysicVisualizer (OxEngine engine, string domainName, bool ownedByDomain)
            : base(engine, domainName, ownedByDomain)
        {

             
             AddGarbage( surface = 
            new PhysicVisualizerSurface(engine, OxHelper.Cast<PhysicVisualizer>(this))

           );

        }


         protected override PhysicVisualizerSurface SurfaceHook { get { return surface; } }

         private readonly PhysicVisualizerSurface surface;
    }



Nobody is interested in this topic so i won't post the reason of the error.

But know i have an awesome physic bodies visualizeer! which is slow but helps me alot.