Forum Index
SUBSIM Forum Search

The Web's #1 BBS for all submarine and naval simulations!
[ SUBSIM Review ] [ SUBSIM STORE ]
Current Forum | Archives 2002-2003 |

Keeping the camera on board

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.     Forum Index -> Indie Subsims
View previous topic :: View next topic  
Author Message
Chad



Joined: 13 Jun 2004
Posts: 152

PostPosted: Tue Mar 22, 2005 11:21 pm    Post subject: Keeping the camera on board Reply with quote

Ok, this might be a simple question for you advanced programmers out there, but how do I keep thh camera on board the model? Lets say my model is level, and here's my code for that..

level = LoadMesh("sub2.3ds")
ScaleMesh level,.7,.7,.7
RotateEntity level,-90,0,0
PositionEntity level,0,-2.5,0

And I want a transparent cube around my model so the player can't fall off the ship into the sea Smile

Another question is how to set up physics for the speeds and stuff, so say I want to have the boat in Ahead Standard, which will move at 3 units a second, how can I program this so then it's the model and the camera is unaffected and stays on the model? (another reason for asking the above question)

Thanks,
Chad
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Deamon



Joined: 30 Apr 2002
Posts: 2302
Location: Germany

PostPosted: Wed Mar 23, 2005 1:55 am    Post subject: Re: Keeping the camera on board Reply with quote

Chad wrote:
Ok, this might be a simple question for you advanced programmers out there, but how do I keep thh camera on board the model?


EntityParent yourCamerName,yourModelName <-- Now the camera will be always positioned relative to your model.

Quote:

And I want a transparent cube around my model so the player can't fall off the ship into the sea Smile


Well, click on help(that's what it is for) scroll down to "3D Category" to Global: then click on collision. There you will finde enough examples.

Quote:

Another question is how to set up physics for the speeds and stuff, so say I want to have the boat in Ahead Standard, which will move at 3 units a second, how can I program this so then it's the model and the camera is unaffected and stays on the model? (another reason for asking the above question)



; Vehicle controlls
Function StearSub()

;Turn sub
If KeyDown(f_point)
ty#=ty#+.1 ; Turn right
Else If KeyDown(point)
ty#=ty#-.1 ; Turn left
Else If KeyDown(m)
ty#=0 ; Rudder midship
End If

;Set speed
If KeyDown(2)
mz#=0 ; All stop
Else If KeyDown(3)
mz#=.4 ; All ahead full
Else If KeyDown(4)
mz#=.8 ; All ahead full
Else If KeyDown(5)
mz#=mz#+8 ; All ahead full


End If

;ty#=ty#+1

;RotateEntity U31,tx,ty,tz
;TurnEntity U31,tx,1,tz

End Function

; Function to move the vehicle

Function MoveSub()

MoveEntity U31,mx,my,mz
TurnEntity U31,tx,ty,tz

End Function

You have to write a game loop like this for example:

;------------ Main loop

Global FPS#=50

Include "Functions.bb"

Repeat

ProcessInput()
UpdateOcean()
MoveSub()

; FPS calculation and syncronization
oldTime#=MilliSecs()

UpdateWorld
RenderWorld

newTime#=MilliSecs()

elapsedTime#=newTime#-oldTime#

sstring$=FPS-elapsedTime

While elapsedTime < FPS

newTime#=MilliSecs()
elapsedTime#=newTime#-oldTime#

Wend

If h=5 Then

sstring1$=sstring$
h%=0

End If

Text 0,0,sstring1$

h%=h+1

Flip

Until KeyHit(1)

I syncronize the game to a curtain FPS count. It updates once in a curtain time. In this way my sub moves steadily only a curtain distance in a curtain time. If you don't want to syncronize your game to a curtain fps then you must extend your function that moves the vehicle, so that it takes in account the speed setting and the time that passed since the last update.

Deamon
Back to top
View user's profile Send private message Visit poster's website
Chad



Joined: 13 Jun 2004
Posts: 152

PostPosted: Fri Mar 25, 2005 8:04 pm    Post subject: Reply with quote

Thanks deamon, but I'm still having some probs.. I'll play around with it some though tonight and see what i can come up with.

;one of the big problems is when I run the program it says 'Function can only appear once' and yadada it drives me insane sometimes Mad
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Deamon



Joined: 30 Apr 2002
Posts: 2302
Location: Germany

PostPosted: Fri Mar 25, 2005 10:58 pm    Post subject: Reply with quote

Chad wrote:

;one of the big problems is when I run the program it says 'Function can only appear once'


Hmm, never encountered this problem. Show me you code. Have you splited your code up in several files ?

Quote:

yadada


What ?

Deamon
Back to top
View user's profile Send private message Visit poster's website
Chad



Joined: 13 Jun 2004
Posts: 152

PostPosted: Sat Mar 26, 2005 11:09 pm    Post subject: Reply with quote

Ok, I've gotten rid of all the errors, however the buttons do not work.

Looking at the functions I can't see what the problem is.

BTW, yadada means the same as etc, I was just being lazy.
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Deamon



Joined: 30 Apr 2002
Posts: 2302
Location: Germany

PostPosted: Sun Mar 27, 2005 4:43 am    Post subject: Reply with quote

Chad wrote:
Ok, I've gotten rid of all the errors, however the buttons do not work.

Looking at the functions I can't see what the problem is.


Whitch buttons ?

Deamon
Back to top
View user's profile Send private message Visit poster's website
Chad



Joined: 13 Jun 2004
Posts: 152

PostPosted: Mon Mar 28, 2005 12:12 am    Post subject: Reply with quote

The buttons for stearing and speed settings for the sub.
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Deamon



Joined: 30 Apr 2002
Posts: 2302
Location: Germany

PostPosted: Mon Mar 28, 2005 5:44 am    Post subject: Reply with quote

Will you sort it out or do you need help ?

Deamon
Back to top
View user's profile Send private message Visit poster's website
Chad



Joined: 13 Jun 2004
Posts: 152

PostPosted: Wed Mar 30, 2005 5:09 am    Post subject: Reply with quote

I'm going to try to sort it out..

I'll let you know if I need help Yep
Back to top
View user's profile Send private message Send e-mail Visit poster's website MSN Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.     Forum Index -> Indie Subsims All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group