Looking at the origin in 3D (REALbasic games Mailinglist archive)
Back to the thread list
Previous thread: [ANN] Quesa Wrappers v0.6.2f (RB3D Extensions)
Next thread: Timer fixed in RB2007r1
| Looking at the origin in 3D |
| Date: 04.01.07 18:32 (Thu, 4 Jan 2007 11:32:25 -0600 (CST)) |
| From: tornado athenet.net |
|
The user can move the camera around my object in a circle but it always
views in the same direction. I want the camera to always be facing the object which happens to be at the origin. The radius of the circle is 750. This is the code for the camera movement: Zangle*ngle+.1//a property as double Rb3DSpace1.Camera.Position.X{3DSpace1.Camera.Position.X//this line is not strictly necessary buy I keep it here for consistency Rb3DSpace1.Camera.Position.Y50*(Sin(Zangle))) Rb3DSpace1.Camera.Position.Zw50*(Cos(Zangle))) After that I want the camera to point towards the origin. What would be even better is if the user could click and drag their mouse on the RB3DSpace to move the camera. I need to keep the object stationary to test for loctions. Any suggections would be great. Thanks! _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html> |
| Re: Looking at the origin in 3D |
| Date: 04.01.07 20:50 (Thu, 4 Jan 2007 13:50:04 -0600) |
| From: David Grogono |
|
Hi -
I hadn't seen your post on the games list before replying on the getting started list. It sounds like that other reply may be unneeded if you figure out how to allow the user to move the camera. One fairly simple way I have used does something like this when xDelta and yDelta are how far the user moved the mouse: Rb3DSpace1.camera.Position aew Vector3D(0,0,0) Rb3DSpace1.camera.Yaw -.01*xDelta Rb3DSpace1.camera.Pitch .01*yDelta Rb3DSpace1.camera.MoveForward -100 Rb3DSpace1.update Obviously you would need to adjust the various numbers to get the responsiveness you want. Best regards, David On Jan 4, 2007, at 11:32 AM, <email address removed> wrote: > The user can move the camera around my object in a circle but it > always > views in the same direction. I want the camera to always be facing the > object which happens to be at the origin. The radius of the circle > is 750. > > This is the code for the camera movement: > Zangleongle+.1//a property as double > Rb3DSpace1.Camera.Position.Xk3DSpace1.Camera.Position.X//this > line > is not strictly necessary buy I keep it here for consistency > Rb3DSpace1.Camera.Position.Y?50*(Sin(Zangle))) > Rb3DSpace1.Camera.Position.Zg50*(Cos(Zangle))) > > After that I want the camera to point towards the origin. > > What would be even better is if the user could click and drag their > mouse > on the RB3DSpace to move the camera. > > I need to keep the object stationary to test for loctions. > > Any suggections would be great. > > Thanks! > > _______________________________________________ > Unsubscribe or switch delivery mode: > <http://www.realsoftware.com/support/listmanager/> > Search the archives of this list here: > <http://support.realsoftware.com/listarchives/lists.html> _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html> |
| Re: Looking at the origin in 3D |
| Date: 04.01.07 21:05 (Thu, 4 Jan 2007 15:05:46 -0500) |
| From: Frank Condello |
|
On 4-Jan-07, at 12:32 PM, <email address removed> wrote:
> The user can move the camera around my object in a circle but it > always > views in the same direction. I want the camera to always be facing the > object which happens to be at the origin. The radius of the circle > is 750. IIRC, there's a few orbit/point-at examples in Joe's 3D FAQ: <http:// www.strout.net/info/coding/rb/intro.html> Frank. <http://developer.chaoticbox.com/> <http://macgameblog.com/> _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html> |
| Re: Looking at the origin in 3D |
| Date: 04.01.07 23:57 (Thu, 4 Jan 2007 14:57:39 -0800) |
| From: Craig M. |
|
> The user can move the camera around my object in a circle but it always
> views in the same direction. I want the camera to always be facing the > object which happens to be at the origin. The radius of the circle is > 750. > > After that I want the camera to point towards the origin. I believe there is an example of this in the language reference somewhere. Look under rb3dspace, it might be there. > > What would be even better is if the user could click and drag their > mouse > on the RB3DSpace to move the camera. This can be done in several ways. First you need to implement mouse down (and record the click location, X and Y) and in it return true. Then mouse drag will fire, where you capture the change in X and Y to apply some rotation. Something more advanced and scalable can be done by projecting the click onto the X,Y plain (Well, really the plain which is parallel to the screen and involves the origin) of the space and using that. I have some code for doing that, but everything is all rotated strange so Z is vertical and Y is horizontal. This only works for one camera rotation about the origin because its intended for use with a rotating object. Code: Function ScreenXToSpaceX(X As integer) As Double Dim mX,XFOV,sXMax, sX As Double mXh(Space.Width/2) If Space.Width<Space.Height then XFOVoace.FieldOfView else XFOVsace.FieldOfView*(Space.Width/Space.Height) End If XFOV/OV/(180/Pi) sXMaxn(XFOV/2)*Space.Camera.Position.X sX=x/(Space.Width/2))*sXMax sX.+Space.Camera.Position.Y Return sX End Function Another option would be to add the camera to a group, centered at the origin and rotate the group. > > I need to keep the object stationary to test for loctions. I don't know the full context so this might not apply, but you could move the object and use worldToObjectTransform or ObjectToWorldTransform on the location vectors. > > Any suggections would be great. Good luck! _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html> |
| Re: Looking at the origin in 3D |
| Date: 05.01.07 08:57 (Thu, 4 Jan 2007 23:57:08 -0800) |
| From: Lars Jensen |
|
> I want the camera to always be facing the
> object which happens to be at the origin. Yesterday on the Getting Started list I gave you a link to a 3D FAQ and told you that it would answer your question. Did you look at it? Here it is again: http://www.strout.net/info/coding/rb/intro.html lj _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html> |
| Re: Looking at the origin in 3D |
| Date: 05.01.07 14:31 (Fri, 5 Jan 2007 07:31:18 -0600 (CST)) |
| From: tornado athenet.net |
|
Yes I did, but I want to get around the problem that when the camera is on
the opposite side of the object (compared to the start), the arrow left and right keys reverse because the camera is upside down. >> I want the camera to always be facing the >> object which happens to be at the origin. > > Yesterday on the Getting Started list I gave you a link to a 3D FAQ > and told you that it would answer your question. Did you look at it? > Here it is again: > > http://www.strout.net/info/coding/rb/intro.html > > lj > _______________________________________________ > Unsubscribe or switch delivery mode: > <http://www.realsoftware.com/support/listmanager/> > Search the archives of this list here: > <http://support.realsoftware.com/listarchives/lists.html> _______________________________________________ Unsubscribe or switch delivery mode: <http://www.realsoftware.com/support/listmanager/> Search the archives of this list here: <http://support.realsoftware.com/listarchives/lists.html> |
Links
MBS Realbasic Plugins - Pfarrgemeinde St. Arnulf Nickenich