Jump to content
Sign in to follow this  
BLSmith2112

Rotating Camera Script...

Recommended Posts

I started to read snyper's intro guide to camera scripting. I must say he did a really good job up until about page 12 (rotate.sqs).

1. He never said: The rotate.sqs file included in the download is what I am now going to be refering to.

2. He never said that the bit about rotate.sqs was merely line of code linking the script testcam.sqs.

3. The "tutorial" rotate.sqs makes NO SENCE.

Quote[/b] ]

; GENERIC OBJECT ROTATION SCRIPT 1.2

; developed by snYpir. assistance from Wozza. if u make any changes, plz

; email morpj97@hn.ozemail.com.au

; this script is used to rotate any object around a fixed point. you can specify

; how far the object rotates in degrees. this script can also be used for camera

control (the

; camera will focus on whatever object it is being rotated around)

; rotation can be done around a moving object no problem. The original height value

will be

; used always. If you want to rotate around a helicopter, and the helicopter takes

off,

; the object rotating around will always stay at it's original height relative to

the

; helicopter

; the 'movement interval' (speed of rotation) is totally dependant on the angle

that will

; be rotated. So if you are rotating 1080 degrees, a movement interval of 1 will

move the

; rotating object much faster than an object that is only rotating 360 degrees. You

will

; need to use trial and error to get the speed you want

; note that the object will rotate from whatever position it is at when this script

is

; called. You will have to move the object into the start position prior to calling

; this script

; CHANGES IN 1.1

; - u can now rotate anti-clockwise by specifying a negative angle to rotate

; - u can now rotate indefinatley by specifying an angle to rotate of 0

; - u can make 'rotateexited' equal to true outside the script and the script

; will exit

; CHANGES IN 1.2

; - doesn't effect calling scripts at all (the old version required setpos in the

; calling script which sucked). but now you must use yourcamname = newcamobj in

; the calling script post-rotation

; PARAMETERS

; - the name of the object to be moved

; - the name of the object that the object will rotate around. can be a moving

; object.

; - the movement interval. 1 is very fast. 0.1 is very slow.

; - how far to rotate in degrees (can be > 360). negative to rotate anti-clockwise.

; zero to rotate indefinatley.

; - true/false value - true if we are moving a camera object, else false

; GLOBAL VARIABLES

; rotateexited - false if this script is running, otherwise true. to be used to

; halt another script's execution until this one is finished.

; also used to force this script to exit - simply make true from

; outside the script

; newcamobj - the name of the camera object post rotation. you will need to

; realign your camera object (in the calling script) with this

; global variable once the script is complete

; EXAMPLES

; rotate 'chopper' around 'player' for 360 degrees

; [chopper,player,0.25,360,false] exec "rotate.sqs"

; rotate 'camera' around 'player' for 90 degrees. we are rotating a

; camera object

; [chopper,player,0.25,360,true] exec "rotate.sqs"

; VALUES U CAN CHANGE

; object being move forced to face movement direction if true (makes no difference

; if you are moving a camera object)

_setdirection = true

; if you want to rotate anti-clockwise for an indefinite rotation make this true

_indefanticlockwise = false

; mess with this script at your own risk!!!!!

; set script defaults

_pause = 0

_camera = false Thought he said camera = true? (Above)

rotateexited = false

; name of object to move What is the name of the object? What if you don't want to remove anything?

_obj = _this select 0

; fixed object that we will rotate around where do you insert "object/name" of thing to rotate around

_fixedObj = _this select 1

; get the movement interval for the object Where do you put the interval?

_interval = _this select 2

; how far are we going to rotate in degrees? Where do you put the "how far to rotate in degrees?

_rotate = _this select 3

; are we rotating indefinatley?Oh, I understand this!

_indefrotate = false

? _rotate == 0 AND _indefanticlockwise : _rotate = -360; _indefrotate = true WTF? Is this?!!!

? _rotate == 0 AND NOT(_indefanticlockwise) : _rotate = 360; _indefrotate = true Again..*Sigh*

; are we rotating backwards? I dont know, are we??

_turndiff = 90

? _rotate < 0 : _turndiff = -90

; are we talking about moving a camera? (if yes we will need

; to update the target of the camera each loop)

_camera = _this select 4 Select what now? WHAT?!

; get positions On where I live?

OH GREAT! More crap he's not explaining

_x1 = (getpos _obj select 0)

_y1 = (getpos _obj select 1)

_x0 = (getpos _fixedObj select 0)

_y0 = (getpos _fixedObj select 1)

_z0 = (getpos _fixedObj select 2)

; calc change in positions

_chngx = _x1 - _x0

_chngy = _y1 - _y0

; get the magnitude of difference between two vectors

goto "calcmag"

#magdone

Magnitude of vectors huh? suuure, I live in a spaceship

_theta = asin( _chngx / _mag )

? _y1 < _y0 : _theta = _theta + 180

? _theta < 0 : _theta = _theta + 360

; get number of steps between positions

_nSteps = _mag / _interval

; get change in theta each frame

_chngtheta = _rotate / _nSteps

; loop through object rotation

_i = 0

_hgtdiff = 0

Not even captain america made sence of anything he just said

? NOT(_camera) : goto "skipbugfix"

_camposn = getpos _obj

_obj = "camera" camcreate _camposn

_obj cameraeffect ["internal", "back"]

God just walked in, he's just as lost as I am, HEY LOOK! internal black, the default starting camera lines of code! w00t.. So what..?

; BUG FIX - BIS's FAULT!!!!!

; every call to getpos drops the returned camera height by

; about 30m!!!!!!! so this fixes that

_hgt = (getpos _obj select 2)

_obj setpos [_x1,_y1,_hgt]

_hgtdiff = _hgt - (getpos _obj select 2)

; the line below will need to be:

; _obj setpos [_x1,_y1,_hgt+(2*_hgtdiff)]

; if the camera has not be set properly outside this script

_obj setpos [_x1,_y1,_hgt+(_hgtdiff)]

;TitleText [format["%1", _hgtdiff],"PLAIN DOWN"]

;~10

#skipbugfix

#moveloop

_dirdiff = _theta + ( _i * _chngtheta )

_chngfixedx = (getpos _fixedObj select 0) - _x0

_chngfixedy = (getpos _fixedObj select 1) - _y0

_chngfixedz = (getpos _fixedObj select 2) - _z0

_x = _x0 + ( _mag * sin( _dirdiff ) ) + _chngfixedx

_y = _y0 + ( _mag * cos( _dirdiff ) ) + _chngfixedy

_z = (getpos _obj select 2) + _chngfixedz + _hgtdiff

; face the way object is moving

_obj setdir (_dirdiff + _turndiff)

;hint format["%1,%2,%3,%4",(getpos _fixedObj select 0),(getpos _fixedObj select

1),_oldfixedx,_oldfixedy]

;hint format["%1,%2",_chngfixedx,_chngfixedy]

;TitleText [format["%1", _z],"PLAIN DOWN"]

; set object at new posn

_obj setpos [_x,_y,_z]

; face the target of the camera

? _camera : _obj camsettarget _fixedObj; _obj camcommit 0

; check for exit call

? rotateexited : exit

; quite time

~0.01

? rotateexited : exit

? _i < _nSteps : _i = _i + 1; goto "moveloop"

; are we rotating indefinately?

? _indefrotate : _i = 0; goto "moveloop"

; make a global variable equal the camera

? (_camera) : newcamobj = _obj

; flip the global rotateexited variable

rotateexited = true

exit

; calculate the magnitude of a vector

#calcmag

_magchngx = _chngx * _chngx

_magchngy = _chngy * _chngy

_magnotsqr = _magchngx + _magchngy

_mag = sqrt( _magnotsqr )

goto "magdone" Mag Done? IM DONE------- I quit...

90% of the terms used were NOT explained in the tutorial nore the script itself. I am still confused. Is there anything better out there?

I apologize for the long exasperated post. I'm just starting to think I'll never understand this stuff. I decided to stay up 24 hours to learn the art of camera scripting but I can't now because the guy who wrote it expected all of us to be golden children or something..

Share this post


Link to post
Share on other sites

Well, from reading your comments i can see that

you don't know anything about scripts or how scripts

get executed.

You should first off go through one of the scipting tutorials

e.g. at OFPEC's editor's depot

'The guy' who wrote this tutorial you are talking about

expects you to know at least basic scripting, and for

sure didn't expect the behaviour you show just because

you don't understand it.

You should know that he wrote this for free during his free time and nobody told him to do it.

We've gone all through this scripting jungle at beginning, but once you get the hang with it, everything's fine.

I could now start to explain you everything what you didn't

understand, but then again i would write a whole basic

scripting tutorial over here - this doesn't make sense, since

such already exist at the link i provided you above.

~S~ CD

Share this post


Link to post
Share on other sites

Very funny comments there thumbs-up.gifrofl.gif

CD is right, start learning some basic scripting, after that try learining cam scripting. wink_o.gif

Share this post


Link to post
Share on other sites

Exactly that:

Quote[/b] ]You should first off go through one of the scipting tutorials

e.g. at OFPEC's editor's depot

This tutorial covered all of that. From what is forward/backward/right/left/up/down. He starts his tutorial by stating:

Quote[/b] ]To use this tutorial you need to know how to call a script and the basics of how a script works (see this introduction if you are unsure).

I finished the introduction, it was easy as pie. I understood it. After messing around and experimenting for a few years (Very rarely, off and on). I know about the init field and whatnot. I just HATE having to read 12 pages, going back and forth between game/text and experimenting for 4+ hours. To hit page 12, and go WTF?!!!! Now what? I have to find some other schmuck's tutorial that will explain that of which I didn't understand and then transvert on THEIR page 12 to some other thing I've never seen before?... *Sigh...

Perhaps he wrote this in his spare time, but the point of a tutorial is to teach, and when you have a calculus professor teaching Basic Arithmetic.. Stuff don't click.

=========================

edit: OFPEC's site shows 7 Items under the category: Cutscenes, Music and Custom Resources.

Camera.sqs by Messiah asks me to have read a tutorial by snyper that is not on OFPEC.

Custom Optics Tutorial by earl talks about overlay's and stuff that doesn't pertain to my situation.

Cutrsc/Titlersc Tutorial by General Barron doesn't pertain to my situation ether, but still after only a few lines asks that I have read over: Vectorboson's dialog tutorial.

Intro To Camera Scripting: by Snyper Again, NICE for 12 Pages. Perfect for any editor, although very unclear at page 12. Like he found the bottle of rum in his hidden cabinet and continued to write his tutorial.

Music, Sound & Radio by Navy_Seals: Not doing that.

Switchmove/Playmove Animation Library by AK-Chester: Not doing that ether..

I guess I could just simply ask for some help. Where can I find how to learn the information provided in the script in the first post. (Preferably that doesn't require me to be a rocket scientist 1/2 way through or require me to have previous knowledge of something else, it seems that ALL tutorials require some certain prior knowledge. Sort of impossible for people to start now-a-days..). Thx biggrin_o.gif

PS: Sorry If I'm giving the impression that Im in anyway hostile. I'm just "dust in the wind" without any sence of direction. Really though, if I could just be pointed in the right direction I would appreciate it. What should I read first? Second, third? Thanks for your time all.

Share this post


Link to post
Share on other sites

Victor, the problem is that you do not yet know enough about scripting generally to understand snYpir's excellent tutorial.     OFPEC used to have an wonderful system of tutes, but due to multiple simultaneous hardware failures we lost the lot.   Much of it has been recovered, and more is recoverable yet, but we're not where we were.   Some of the tutes exist elsewhere in the community.

See if you can find

Johan Gustafsson's scripting tute

snYpir's friendly intro to code snippets

Once you've done that, see if you can find messiah's camera.sqs tute which will save you a LOT of work.

My Beginner's Guide to Mission Editing has a good list of suggested tutes with reading order. Recommend also my Tutorial Mission, both are on the Editors Depot resources board at OFPEC.   Take it to pieces and you'll find working examples of simple scripts which will help you understand.   Also, read through the whole of the comref very quickly, don't stop to understand everything, just get a feel for what's there and how it all works.  

What you are trying to do is not difficult, but as you have observed you have to get everything in the right order.    snYpir's camera tute is not perfect, but it is pretty good: it's how I learned to camera script.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×