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.

Newcomers DBPro Corner / Keeping an object with the screen borders

Author
Message
Cpt Caveman
22
Years of Service
User Offline
Joined: 29th Aug 2002
Location: New Zealand
Posted: 1st Sep 2004 16:07
Im having trouble keeping an object with the screen borders, ie, it doesnt go off screen, but is dragged/pushed along by the screen of its scrolling right for example(or to tighten the limits the object can move on screen)

Ive tried everything from box collision(boxes on the screen borders that move with the camera following the object in screen and stop the object, works but drops the fps ), trying to limit the x positioning with using the object screen x command(no luck)

I cant scroll the landscape and have the object/camera static as then my collision stops working for the object moving/folowing the terrain.

So its really the camera moving right, and the object inscreen not allowed to go off the screen edge. Therefore being dragged along by the cameras screen viewpoint.

I have to have the camera always moving right, not the camera controlled by the user.

Ive run out of ideas, any help/advise would be greatly appreciated please, a small snippet with an object moving right as the camera scrolls right without the object leaving the screen.

So far Ive probably wasted 6 hours as theres probably some very easy solution

Thanks in advance
Arkheii
21
Years of Service
User Offline
Joined: 15th Jun 2003
Location: QC, Philippines
Posted: 1st Sep 2004 18:18
Oh damn, this is a question for trig whizzes...

Here's an idea though, if you are using DBP or DBC enhanced (DLL support)...

If you have the Nuclear Glory DLL (Check the program announcements board and look for it, then try or buy it...) which I don't have, you can do this by making a rectangular pyramid mesh and orientating (orienting, orientating...) it to the camera and hiding it, so as the camera rotates and moves around, it's as if there are 4 invisible walls along the edges of the camera. Your pyramid's faces "trace" the camera's "edges" for quite a distance. Enable sliding collision using the DLL, and every time an object moves out of the screen, it collides with the invisible pyramid, so it stays in the screen. But, if you change the camera's FOV, it would be a different matter, and you would have to modify your mesh...

It's a little vague, but if someone else understands this and is willing to post an image with a diagram or graphic explanation, it could help you.

There's a way to do this with some math, but I'm not gonna bother...

GameKit
21
Years of Service
User Offline
Joined: 6th Mar 2003
Location: USA, Staring Blankly at a Computer
Posted: 1st Sep 2004 23:35
Hmmm... I'm asuming you've already tried something like this?


If that doesn't work... you could try this "slightly" more complicated meathod...
Find the position of three Points Infront and to each side of the camera... lets call them point A,B, and C where A is the point directly ahead of the camera... Each "Point" should be positioned the same distance away from the camera and point B and C should be at 90* angles from the camera angle...(Still Following?)... Then check the distance [D=Sqrt((X1-X2)^2+(Y1-Y2)^2+(Z1-Z2)^2)] from each of the three points to the object that needs to stay inside the camera veiw and store them in three variables... DistA#,DistB#,DistC#... Then compare DistB# and DistC# with DistA#... If DistB#>DistA# and DistC#>DistA# then the object is within the camera view... If DistB#<DistA# and DistB#<DistC# then the object is outside the camera view and needs to be moved to the right... When Points A,B, and C are the same distance from the camera then the inscreen cutoff is at 45* on either side... moving point A closer to the camera will narrow the area the object can be within while positioning point A further away will widen the area...

Thats a mouthfull... I'll try to draw you a diagram...




Arkheii's meathod would work also, but you would have to get Nuclear Glory (Which I would get anyways... very usefull) and you would have to make a 3D triangular prisim model...

well... I hope I helped...

The computer isn't an addiction, its more of a mental and social dependancy.
Ron Erickson
Moderator
21
Years of Service
User Offline
Joined: 6th Dec 2002
Location: Pittsburgh, PA, USA
Posted: 2nd Sep 2004 02:11
EZrotate Enhanced has a feature to check the angle between any 3 points. You could easily use it to make sure that the object stays on the screen.

You would set the command up with the camera's position, then a point directly in front of the camera (also easy to find with EZrotate), then the position of the object. It will return the angle between your camera and the object. If the angle is greater than 45(90 is the default FOV cone), then the object off of the screen.
If you wanted to then keep the object on the screen as the camera rotates and moves, you could then use EZrotate to translate that point into offset distances from the camera. You can then rotate the camera however you wish and re-translate that point into a global coordinate (again easily with EZrotate).

If you are interested in using the plugin, I could write a snippet to show you how easy this would be.

WOLF

EZrotate!
Tokamak Physics Wrapper!
Cpt Caveman
22
Years of Service
User Offline
Joined: 29th Aug 2002
Location: New Zealand
Posted: 2nd Sep 2004 07:18
Thanks everyone,

Ive now tried using the various versions of the above code, except that camera alignment/distance method.

Attached is just a basic example of what Im trying to achieve, I want the ball to stay within the ghosted pillars which represent the borders/edges that the ball cannot go past

Im thing the NG collision is the best way to go as it does moving object on object collision, Im sure that s simple sliding collision method within DBPro would be good enough, the collision commands arent that bad I hope, its not very complicated

So its only really the x axis I want, not the Y or Z axis.

If someone could please help with a basic sliding collision solution that would be great, even though I know that NG collision will work I dont want to pay for it until I know Im going to make something decent. And I do know I can try the demo version too.

Login to post a reply

Server time is: 2024-09-22 22:18:25
Your offset time is: 2024-09-22 22:18:25