Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Hiding glued objects problem

Author
Message
Hangar18
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 23rd Jan 2009 02:38 Edited at: 23rd Jan 2009 02:41
Glued objects appear to be detaching themselves from the parent upon a) hiding the parent and b) the parent not being "in screen" and I'm struggling to a) understand why and b) fix it

An overview of my code is as follows:

1) Check to see if there are 10 ships in the galaxy (e.g. has 1 recently jumped or been destroyed). Lets say ship 6 (also object 6) isnt there.

2) If no then gosub load new ship (as object 6)
2a) now also load a turret as say object 16 and glue it to object 6, positioning as necessary to the right spot on object 6)
2b) randomly position object 6 in the universe

3) Do a check for all ships being "in screen" in the universe. If not then hide object (to improve FPS performance).

Now, as this is a top-down game, object 6 will almost certainly be hidden at this point (unless by sheer fluke its random positioning is "in screen"). However if I fly to the position where I positioned object 16 (which should have been with respect to bject 6), I will find the turret detached. I.e. If I glue object 16 to 6 then position object 16 at 1,3,2 say, but travel to the universe at position 1,3,2, I will find the turret (detached). The Turret should have been positioned a 1,3,2 relative to object 6's position.

Now the really strange thing is this. I set up a debugging functionality so that if I press 6 it will immediately position object 6 into screen next to my ship. Upon doing this, the detached turret immediately disappears from where it was and reappears in its correct place on object 6 (the main ship) which I think this happens as soon as step 3 runs.

Can anyone tell me what might be going on with DB?

Cheers.
Latch
19
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 23rd Jan 2009 03:58
Here's an explanation I'm making up off the top of my head, but it makes sense to me as I write it!

I think it has to do with object offsets that tie back to their transform matrices. When you glue an object to another object, it is positioned in world coordinates according to where it's parent object is and it is offset by it's own local coordinates. You've already seen this behavior, that's how you're able to place a turret offset from the ship. The glued object and the parent object are then rendered together.

When the parent is hidden, the rendering for the parent is stopped but the rendering for the glued object is not. The transformation information is updated so the parent can have a virtual new position (this is how collision detection with the parent can occur even though it's invisible), but since it is not rendered, the visual position of it and it's glued object do not update. When the parent becomes visible again, it's rendering information is updated and thus the glued object's rendering is also updated.

There are many alternatives. A simple one might be to hide object 16 also if object 6 is hidden or off screen.

Another option is to add the turret as a limb instead of gluing it.

You can also position the turret and offset it without gluing it and control it's position and orientation based on the position of object 6.

You could even have multiple models with different weapons already added as part of the model and load and delete the models as you need them.

These are just a few options off of the top of my head.

Enjoy your day.
Hangar18
19
Years of Service
User Offline
Joined: 13th Mar 2007
Location:
Posted: 27th Jan 2009 02:25 Edited at: 27th Jan 2009 02:26
Brilliant - thanks Latch. You've come to the rescue yet again!

Login to post a reply

Server time is: 2026-07-05 11:53:10
Your offset time is: 2026-07-05 11:53:10