How can I constrain a 3D object to the screen?

Previous topic - Next topic

Slydog

I created a dynamic 3d object in code for my game's title. 
(It's made from my maze drawing routines to look like a maze in the shape of my title)

I want this title model to move around (maybe based on touch or device tilting) the 3d world space.
It will move left / right / up / down, plus zoom in and out, rotate, etc (not decided exactly what yet).
Basically it will wander around inside a virtual 3d box.

Is there a way to tell if the entire model is within the view range (ie, can you see it)?
That way I can detect when it goes a bit out of view and change the direction to 'bounce' it back into view.
I can hard code this perhaps with trial and error, but constantly rotating it changes it's x/y screen edge boundaries so I wont know precisely when it goes off screen.

Here's a screen of how it looks now, it's tilted a bit to show what I mean.

[attachment deleted by admin]
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

mentalthink

HI Slydog, I dont´ stay sure if I understood well your quesion?¿.

If you want kwno if the object is into the focal camera, only are the position of the objects realtive to the camera, it´s like make it in 2D, but the camera always hace the x positive and negative, and the Y is the same.

Sory if not it´s the question.  :zzz:

Slydog

After thinking about it a bit more, I think it would be easiest (through trial and error) to just find the bounding four 3D corner vectors when it's at the closest position to the camera. 

When it gets further away from the camera it'll still use those bounds ignoring the z depth, but it will not get as close to the screen edge since it's further along the z axis.  Picture the bounding box to be a cube, I was originally trying to get it to be a 3d trapezoid / cone type bounding shape.

This shouldn't be a problem visually.  And I really don't mind if it's rotating around and part of it goes off screen for a moment, before it bounces back.

Thanks.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]