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 Professional Discussion / Having an object fly towards the screen

Author
Message
anwserman
15
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 28th Jul 2011 14:36
Hey everyone,
I'm wondering how I can take a 3D object and fly it towards the screen. I'm not confused about how to actually move the object - I'm just sure how to figure out the destination coordinates.

My app is currently being rendered in a 1280x720 window. When enabled, I'd like to objects to fly from their current position towards the bottom-left corner of the screen. However, to figure out where 'the bottom-left corner of the screen' in the 3D world would require manipulating the camera and it's current orientation/settings >_>

Another idea I came up with was casting an extremely long ray to the back and the left of my character, but this method seems imprecise.
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 28th Jul 2011 14:51
I would take the camera, store it's position and angle, then turn it left 90 degrees, pitch it down 40 degrees (or therabouts), and move it forward by enough to put it in the bottom corner. Store that location, then put the camera back at it's previous location and orientation.

Then, to make something fly towards it, just point the object at that bottom left location, and move the object forward.

Might be a little messy, but it would avoid a lot of complicated math. One other option would be to make a cube, then offset the base limb (0) to -10,-6,0 - and position and rotate that object with the camera. Then you'd have a nice way to debug the corner position, and use the limb position to move objects towards. Hiding the cube once your happy with the corner location of course.

Health, Ammo, and bacon and eggs!
anwserman
15
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 28th Jul 2011 15:06
Ok.... horrible bad pseuodocode here


This is all I'd have to do? GENIUS =)
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 28th Jul 2011 15:12
Yeah, that should do it. That's what I'd do at least, I prefer to avoid complex math.

Once you've updated the dummy cube position and angle, use LIMB POSITION X(obj,limb) etc to get the 3D world position.

Health, Ammo, and bacon and eggs!
BMacZero
20
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 29th Jul 2011 01:24
What about running the PICK SCREEN command on 0, SCREEN HEIGHT() with a short distance? I guess it depends on the specifics of what you want to do - do you want the object to just fly past the player on the bottom left, or fly up to the screen at the bottom left?

The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 29th Jul 2011 01:36
Quote: "One other option would be to make a cube, then offset the base limb (0) to -10,-6,0 - and position and rotate that object with the camera. Then you'd have a nice way to debug the corner position, and use the limb position to move objects towards."

Yeah, I would do something simular. Just make a simple model, like two cubes. One cube for the model, and one for the 'target'. Then glue the target cube as a child of the player cube. The model would then have two limbs. It would be easy to point your models to 'fly' to the 'target' limb. And the 'target' limb would always follow the player, and always remain to the bottom left of the player.

Cheers

Login to post a reply

Server time is: 2026-07-10 10:42:41
Your offset time is: 2026-07-10 10:42:41