Problem when reopening a scene

feanor91

29-08-2008 08:28:07

Hello

I have a strange problem. Here, my sub init scen that load osm scene :


Public Function InitScene(ByVal Langue As String) As Boolean
If _showLoad Then
Langue = Langue.ToUpper
If Langue = "FR" Then
myfrminfo.lblInfo.Text = "Chargement de la scène en cours....Merci de patienter."
ElseIf Langue = "DE" Then
myfrminfo.lblInfo.Text = "Laden der aktuellen Szene.... Bitte sich gedulden."
ElseIf Langue = "ES" Then
myfrminfo.lblInfo.Text = "Carga de la escena corriente.... Gracias por tener paciencia."
ElseIf Langue = "IT" Then
myfrminfo.lblInfo.Text = "Caricando del palcoscenico in progresso....Grazie essere paziente."
ElseIf Langue = "PO" Then
myfrminfo.lblInfo.Text = "Carregando em desenvolvimento da fase....Lhe agradeça ser paciente."
Else
myfrminfo.lblInfo.Text = "Scene loading in progress....Please wait"
End If
myfrminfo.Show()
myfrminfo.Refresh()
End If
Try
'On initialise OGRE/ OGRE initialisation
_OgreRacine.Initialise(False)

'On crè la fenêtre, ici ce sera dans un contrôle, une picturebox / OGRE window creation, here in a control
Dim misc As NameValuePairList = New NameValuePairList
misc("externalWindowHandle") = _RenderWindowHandle.ToString
Dim const_list As Const_NameValuePairList = misc.ReadOnlyInstance
_RenderWindow = _OgreRacine.CreateRenderWindow("OgreWieport", 0, 0, False, const_list)

'On crés le ressource manager avec les ressources passées en paramètre dans la liste des ressources.
'Ressource manager creation withe ressources given in parameters in ressources list
'Par défaut, on prend le chemin de la scène / pth of the scene by default
ResourceGroupManager.Singleton.AddResourceLocation(System.IO.Path.GetDirectoryName(_SceneToLoad), "FileSystem", "General")

'On ajoute le répertoires OBJETS de l'application qui contient, entre autre, les axes
'adding objets path that contain such thing as axes for example
ResourceGroupManager.Singleton.AddResourceLocation(_StartupPath + "\Objets", "FileSystem", "General")

'et on parcourt la variable _RessourcesToLoad pour ajouter les ressources supplémentaires (répertoires ou fichiers zip)
'iteration of _RessourceToLoad to add other ressources (Directory or zip files)
Dim SplitRessource() As String
For i As Integer = 0 To _RessourcesToLoad.Count - 1
SplitRessource = _RessourcesToLoad(i).ToString.Split("|")
ResourceGroupManager.Singleton.AddResourceLocation(SplitRessource(0), SplitRessource(1), "General")
Next

'Fini, on initialise toutes les ressources / Initailisation of all ressources
ResourceGroupManager.Singleton.InitialiseAllResourceGroups()

'Dim toto As Mogre.LogManager = New Mogre.LogManager()
'toto.LogMessage(LogMessageLevel.LML_TRIVIAL, "test")

'On charge la scène OSM grâce à la dll oFusion / OSM scene loading with oFusion DLL
Scene = New OSMScene(_OgreSceneManager, _RenderWindow)
Scene.Initialize(_SceneToLoad)
Scene.CreateScene(_OgreSceneManager.RootSceneNode)

'création de la caméra / camera creation
If Scene.CameraList.Count > 0 Then
'Si la scene contient au moins une caméra, on sélectionne la première / if there is at least one cam in scene we select it
_OgreCamera = Scene.CameraList(0)
Else
'sinon, on en crè une par défaut / else we create one
_OgreCamera = Scene.SceneMgr.CreateCamera("CameraDefaut")
_OgreCamera.SetPosition(0, 0, 0)
_OgreCamera.SetDirection(0, 0, 0)
_OgreCamera.FOVy = CType(1, Mogre.Radian)
Dim camNode As SceneNode = _OgreSceneManager.CreateSceneNode("CameraDefaut")
camNode.AttachObject(_OgreCamera)

Dim CameraTarget As Mogre.SceneNode = _OgreSceneManager.CreateSceneNode("CameraDefaut.target")
CameraTarget.SetPosition(1000, 1000, 1000)
CameraTarget.SetDirection(0, 0, 0)
CameraTarget.SetScale(1, 1, 1)

'On crè le viewport / vieport creation
Dim ViewPort As Mogre.Viewport = _RenderWindow.AddViewport(_OgreCamera)
_OgreCamera.AspectRatio = ViewPort.ActualWidth / ViewPort.ActualHeight
End If
_OgreCamera.NearClipDistance = 5

InitialCamBodyOrient = _OgreCamera.Orientation
InitialCamBodyPos = _OgreCamera.Position

'si on a décidé d'activer la gestion des collisions, on initialise Newton / if colision detection enable, Newton init
If _CollisionDetection Then
InitNewton(Langue)
End If

'initialisation de l'inputmanager MOIS / input manager initialisation
InitInputHandler()

If _LoadAxe Then
LoadAxe() 'Chargement et instanciation des axes / axes loading
End If

Catch ex As System.Runtime.InteropServices.SEHException
If _showLoad Then
myfrminfo.Hide()
myfrminfo.Dispose()
End If
'en cas d'erreur..../if error
If OgreException.IsThrown Then
MsgBox(OgreException.LastException.FullDescription, MsgBoxStyle.Critical, _
"Exeption OGRE!")
Return False
Else
MsgBox(ex.ToString, "Erreur")
Return False
End If
End Try
If _showLoad Then
myfrminfo.Hide()
myfrminfo.Dispose()
End If
Return True
End Function


On first time all works fine. But my soft open then close then reopen and so on the 3D window and on reopening it, I have nothing or application crash (even under debuger but not in debug, it crash like I have lauch it from OS).

I manage to do all thing works if I add this 2 lines :

Dim toto As Mogre.LogManager = New Mogre.LogManager()
toto.LogMessage(LogMessageLevel.LML_TRIVIAL, "test")


In fact, I think that I create a new log manager...But, I lost my original ogre.log created when root is created.

I use the loader in C# found on wiki.

Any idea

Lioric

29-08-2008 19:29:14

That doesnt seem to be an issue of loading the scenes, but as per your description it seem to be an initialiation issue in your application (as a singleton is not initialized)

You might find more details about this issue in the Ogre.log file created in your application folder

Could you post the debug trace of your application when this issue is experienced?

feanor91

29-08-2008 21:25:11

Here the log file on second open :


22:20:06: Creating resource group General
22:20:06: Creating resource group Internal
22:20:06: Creating resource group Autodetect
22:20:06: SceneManagerFactory for type 'DefaultSceneManager' registered.
22:20:06: Registering ResourceManager for type Material
22:20:06: Registering ResourceManager for type Mesh
22:20:06: Registering ResourceManager for type Skeleton
22:20:06: MovableObjectFactory for type 'ParticleSystem' registered.
22:20:06: OverlayElementFactory for type Panel registered.
22:20:06: OverlayElementFactory for type BorderPanel registered.
22:20:06: OverlayElementFactory for type TextArea registered.
22:20:06: Registering ResourceManager for type Font
22:20:06: ArchiveFactory for archive type FileSystem registered.
22:20:06: ArchiveFactory for archive type Zip registered.
22:20:06: FreeImage version: 3.10.0
22:20:06: This program uses FreeImage, a free, open source image library supporting all common bitmap formats. See http://freeimage.sourceforge.net for details
22:20:06: Supported formats: bmp,ico,jpg,jif,jpeg,jpe,jng,koa,iff,lbm,mng,pbm,pbm,pcd,pcx,pgm,pgm,png,ppm,ppm,ras,tga,targa,tif,tiff,wap,wbmp,wbm,psd,cut,xbm,xpm,gif,hdr,g3,sgi,exr,j2k,j2c,jp2
22:20:06: DDS codec registering
22:20:06: Registering ResourceManager for type HighLevelGpuProgram
22:20:06: Registering ResourceManager for type Compositor
22:20:06: MovableObjectFactory for type 'Entity' registered.
22:20:06: MovableObjectFactory for type 'Light' registered.
22:20:06: MovableObjectFactory for type 'BillboardSet' registered.
22:20:06: MovableObjectFactory for type 'ManualObject' registered.
22:20:06: MovableObjectFactory for type 'BillboardChain' registered.
22:20:06: MovableObjectFactory for type 'RibbonTrail' registered.
22:20:06: Loading library .\Plugins\RenderSystem_Direct3D9
22:20:06: Installing plugin: D3D9 RenderSystem
22:20:06: D3D9 : Direct3D9 Rendering Subsystem created.
22:20:06: D3D9: Driver Detection Starts
22:20:06: D3D9: Driver Detection Ends
22:20:06: Plugin successfully installed
22:20:06: Loading library .\Plugins\RenderSystem_GL
22:20:06: Installing plugin: GL RenderSystem
22:20:06: OpenGL Rendering Subsystem created.
22:20:06: Plugin successfully installed
22:20:06: *-*-* OGRE Initialising
22:20:06: *-*-* Version 1.4.8 (Eihort)
22:20:06: D3D9 : RenderSystem Option: Allow NVPerfHUD = No
22:20:06: D3D9 : RenderSystem Option: Anti aliasing = None
22:20:06: D3D9 : RenderSystem Option: Floating-point mode = Fastest
22:20:06: D3D9 : RenderSystem Option: Full Screen = Yes
22:20:06: D3D9 : RenderSystem Option: Rendering Device = NVIDIA GeForce 7600 GT
22:20:06: D3D9 : RenderSystem Option: VSync = No
22:20:06: D3D9 : RenderSystem Option: Video Mode = 800 x 600 @ 32-bit colour
22:20:06: CPU Identifier & Features
22:20:06: -------------------------
22:20:06: * CPU ID: GenuineIntel: Intel(R) Core(TM)2 CPU 6300 @ 1.86GHz
22:20:06: * SSE: yes
22:20:06: * SSE2: yes
22:20:06: * SSE3: yes
22:20:06: * MMX: yes
22:20:06: * MMXEXT: yes
22:20:06: * 3DNOW: no
22:20:06: * 3DNOWEXT: no
22:20:06: * CMOV: yes
22:20:06: * TSC: yes
22:20:06: * FPU: yes
22:20:06: * PRO: yes
22:20:06: * HT: no
22:20:06: -------------------------
22:20:06: D3D9 : Subsystem Initialising
22:20:06: ***************************************
22:20:06: *** D3D9 : Subsystem Initialised OK ***
22:20:06: ***************************************
22:20:06: D3D9RenderSystem::createRenderWindow "OgreWieport", 0x0 windowed miscParams: externalWindowHandle=722850
22:20:06: D3D9 : Created D3D9 Rendering Window 'OgreWieport' : 421x343, 32bpp
22:20:06: D3D9 : WARNING - disabling VSync in windowed mode can cause timing issues at lower frame rates, turn VSync on if you observe this problem.
22:20:06: Registering ResourceManager for type Texture
22:20:06: Registering ResourceManager for type GpuProgram
22:20:06: D3D9: Vertex texture format supported - PF_FLOAT32_RGB
22:20:06: D3D9: Vertex texture format supported - PF_FLOAT32_RGBA
22:20:06: D3D9: Vertex texture format supported - PF_FLOAT32_R
22:20:06: RenderSystem capabilities
22:20:06: -------------------------
22:20:06: * Hardware generation of mipmaps: yes
22:20:06: * Texture blending: yes
22:20:06: * Anisotropic texture filtering: yes
22:20:06: * Dot product texture operation: yes
22:20:06: * Cube mapping: yes
22:20:06: * Hardware stencil buffer: yes
22:20:06: - Stencil depth: 8
22:20:06: - Two sided stencil support: yes
22:20:06: - Wrap stencil values: yes
22:20:06: * Hardware vertex / index buffers: yes
22:20:06: * Vertex programs: yes
22:20:06: - Max vertex program version: vs_3_0
22:20:06: * Fragment programs: yes
22:20:06: - Max fragment program version: ps_3_0
22:20:06: * Texture Compression: yes
22:20:06: - DXT: yes
22:20:06: - VTC: no
22:20:06: * Scissor Rectangle: yes
22:20:06: * Hardware Occlusion Query: yes
22:20:06: * User clip planes: yes
22:20:06: * VET_UBYTE4 vertex element type: yes
22:20:06: * Infinite far plane projection: yes
22:20:06: * Hardware render-to-texture: yes
22:20:06: * Floating point textures: yes
22:20:06: * Non-power-of-two textures: yes
22:20:06: * Volume textures: yes
22:20:06: * Multiple Render Targets: 4
22:20:06: * Point Sprites: yes
22:20:06: * Extended point parameters: yes
22:20:06: * Max Point Size: 8192
22:20:06: * Vertex texture fetch: yes
22:20:06: - Max vertex textures: 4
22:20:06: - Vertex textures shared: no
22:20:06: ResourceBackgroundQueue - threading disabled
22:20:06: Particle Renderer Type 'billboard' registered
22:20:06: Added resource location 'M:\Kiteswap-3D\KiteSwap\bin\Debug\Objets\Kites' of type 'FileSystem' to resource group 'General'
22:20:06: Added resource location 'M:\Kiteswap-3D\KiteSwap\bin\Debug\Objets' of type 'FileSystem' to resource group 'General'
22:20:06: Added resource location 'M:\Kiteswap-3D\KiteSwap\bin\Debug\Objets\Kites\Kites.zip' of type 'Zip' to resource group 'General'
22:20:06: Parsing scripts for resource group Autodetect
22:20:06: Finished parsing scripts for resource group Autodetect
22:20:06: Parsing scripts for resource group General
22:20:07: Parsing script kites.material
22:20:07: Finished parsing scripts for resource group General
22:20:07: Parsing scripts for resource group Internal
22:20:07: Finished parsing scripts for resource group Internal


it crashe on

Scene.Initialize(_SceneToLoad)


And if I trace the initialize function, it crash here :

LogManager.Singleton.LogMessage("********************************");


It is for that reason that I create a new logmanager.

feanor91

01-09-2008 19:25:58

Well

I manage to solve the problem by commenting out all call to logmanager. I is idiot, but it works.