feanor91
29-08-2008 08:28:07
Hello
I have a strange problem. Here, my sub init scen that load osm scene :
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 :
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
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