two cameras, permitted?
two cameras, permitted?
I set up a camera and made it active, I do a lot of transformations on it, and its pointer reference is passed around a lot. I just tried adding a new cam for debug reasons. I put it way up above the scene and set it to look down. I added an event so I could switch active cams, and when I do this I get access violations. It seems the data from the active cam is erased when I switch to another. Does this sound normal?
The idea here is to watch the cam from above. Of course there is a mesh that shows where the cam is, as it follows it around. Is this not the way to achieve this?
The idea here is to watch the cam from above. Of course there is a mesh that shows where the cam is, as it follows it around. Is this not the way to achieve this?
You can switch cameras, but you have to be a little careful.
First if you just add a new camera with addCameraSceneNode then the old active camera will be removed unless you keep an own pointer to it which has grab()'ed it once more. So maybe you forgot that. If you have pointers to cameras they need to grab() it.
addCameraSceneNode always replaces the active camera (which isn't really nice by Irrlicht and should probably be changed...). Because of that it sometimes is also necessary to getActiveCamera first, grab that pointer and setActiveCamera back afterwards (and droping the pointer again).
First if you just add a new camera with addCameraSceneNode then the old active camera will be removed unless you keep an own pointer to it which has grab()'ed it once more. So maybe you forgot that. If you have pointers to cameras they need to grab() it.
addCameraSceneNode always replaces the active camera (which isn't really nice by Irrlicht and should probably be changed...). Because of that it sometimes is also necessary to getActiveCamera first, grab that pointer and setActiveCamera back afterwards (and droping the pointer again).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
I'm fairly certain that this is not right. The active camera should have a reference count of 2, and any other camera in the scene would have a reference count of 1. Unless, of course, the user has grab()'d them.CuteAlien wrote:if you just add a new camera with addCameraSceneNode then the old active camera will be removed unless you keep an own pointer to it which has grab()'ed it once more. So maybe you forgot that. If you have pointers to cameras they need to grab() it.
Travis
*sigh* complete fail from me. It's certainly as you say and I have no idea what I was thinking when I wrote that.vitek wrote:I'm fairly certain that this is not right. The active camera should have a reference count of 2, and any other camera in the scene would have a reference count of 1. Unless, of course, the user has grab()'d them.CuteAlien wrote:if you just add a new camera with addCameraSceneNode then the old active camera will be removed unless you keep an own pointer to it which has grab()'ed it once more. So maybe you forgot that. If you have pointers to cameras they need to grab() it.
Travis
About the only correct thing I wrote above was that addCameraSceneNode does indeed replace the active camera, but as vitek wrote it's certainly also referenced additionally by the scenegraph.
Sorry.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
not correct, it doesn't replace the camera, but it creates a new one and makes it active, the 1st one is still there, but inactive, so no replacement...CuteAlien wrote:About the only correct thing I wrote above was that addCameraSceneNode does indeed replace the active camera
also I don't think you need to grab the 1st camera (or any other) !?!?!
I never grabed a camera and always could switch between several cameras I created in the same scene...
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:

http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
Yes that's what I mean. Only thing it does is change (not replace) the active camera.Acki wrote:not correct, it doesn't replace the camera, but it creates a new one and makes it active, the 1st one is still there, but inactive, so no replacement... ;)CuteAlien wrote:About the only correct thing I wrote above was that addCameraSceneNode does indeed replace the active camera
also I don't think you need to grab the 1st camera (or any other) !?!?! :shock:
I never grabed a camera and always could switch between several cameras I created in the same scene... ;)
So forget about my original message - it was just wrong. You shouldn't need that grab() & drop() stuff here at all (though it's certainly always clean doing that if you keep pointers around).
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
grab() raises the counter and drop() decreases the counter. when drop() has been called and the counter is (then) zero, the object gets deleted.
Generated Documentation for BlindSide's irrNetLite.
"When I heard birds chirping, I knew I didn't have much time left before my mind would go." - clinko
"When I heard birds chirping, I knew I didn't have much time left before my mind would go." - clinko
-
rooly
- Posts: 224
- Joined: Tue Oct 25, 2005 4:32 pm
- Location: Louisiana, USA, backwater country
- Contact:
ulao, grab() and drop() are a simple form of automatic memory management. It saves the user from needing to call 'new' and 'delete' on Irrlicht objects (not that you can anyway since they are all virtual)
When banks compete, you win.
When ISPs compete, you win.
When electronics retailers compete, you win.
When governments compete...you get drafted.
When ISPs compete, you win.
When electronics retailers compete, you win.
When governments compete...you get drafted.
Hey Rooly. Would it be safe to say its not necessary, but rather "proper" to use grab for every irr object? For example most of the time when you see a newly created device, you dont see the device grab'd. Same goes with most of the other examples.rooly wrote:ulao, grab() and drop() are a simple form of automatic memory management. It saves the user from needing to call 'new' and 'delete' on Irrlicht objects (not that you can anyway since they are all virtual)
If you don't need another reference to the object, there is really no point in using grab(). You should only use it when you need it.ulao wrote:Hey Rooly. Would it be safe to say its not necessary, but rather "proper" to use grab for every irr object? For example most of the time when you see a newly created device, you dont see the device grab'd. Same goes with most of the other examples.rooly wrote:ulao, grab() and drop() are a simple form of automatic memory management. It saves the user from needing to call 'new' and 'delete' on Irrlicht objects (not that you can anyway since they are all virtual)
- The glory days.and remember that functions starting with create (e.g. createDevice) need to be droped when not needed any longer... 
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:

http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java