Page 1 of 1

Scripted zoom

Posted: Sun Dec 03, 2006 8:50 am
by Juutis
I have a big problem with my scripted weapons: I can't find a way to make snipers zoomable!
Any suggestions of how to do it?



Does anyone have any info about the SetCameraWindow() command? What is the 'Field of View' exactly? It doesn't seem to have effect on anything...
Is there something special I need to know about it?

Posted: Sun Dec 03, 2006 6:46 pm
by scott
yea i havnt scripted before but when going over the scipts some time ago i saw this and thought yea could be used for sniper
SetCameraWindow(float FOV, bool UseWidthHeight, int Left, int Top, int Width/Right, int Height/Bottom);

Sets the field of view of the camera and the size of the camera viewport. If UseWidhtHeigth is true, the last 2 parameters are the width and height of the viewport, otherwise these parameters represent the bottom right corner of the viewport.
if i understand this correctly then you would have a resolution of say 800x600 and to zoom in you would have a field view of 30,30 in the bottom left corner (so it would be a 30x30 pixle view of what was originaly seen) and get the camera to move to the center of view, so use another command that moves camera view by ## number of pixels x ## number of pixles so it would now be showing the center of what was on the screen

this will cause problems with lod models and would have to reduce the turning rate down so the cpu doesnt have to work over time to see all the distant objects in high detail.

Posted: Mon Dec 04, 2006 5:25 pm
by GD1
it seemed to work fine when i used it. Sorry to correct u scott, but your number entries for FOV were way off. FOV sets the zoom amount. The lower the number the more you zoom. RF uses a default FOV of 2. in order to zoom in you need to reduce this number. try these settings:

SetCameraWindow(0.5, true, 100, 100, 640, 480);

Posted: Tue Dec 05, 2006 10:49 am
by Juutis
RF uses a default FOV of 2
Thanks for that info! I thought FOV was something like degrees and I was trying numbers like 90. :D

But.... I still couldn't get it to work. However, I've found a way around this.
I can attach a FixedCamera to the player and activate it whenever I need to use the zoom. The SetFixedCameraFOV command works like a dream.

Posted: Tue Dec 05, 2006 2:40 pm
by scott
thats alright, i didnt know how it used the numbers, i thought it would use pixles, so the original would be set at 800x600 at what ever resolution you are using, and from that you specifide how many of those then would be put on the screen, like 30x30, but as i think of it i understand that wouldnt work, but hay, for my very first thought to scriptingi have ever made i was close :D

Posted: Fri Dec 08, 2006 5:38 pm
by GD1
I don't blame you. all these numbers can be really confusing and when your not around to see the forum topic when the feature gets put in, you probably aren't gonna know how to use it. Unless you read the DOCS very carefully, but even then some things aren't clear.

Posted: Sun Dec 17, 2006 9:48 am
by Juutis
Allright, I found out why it didn't work.

For some reason, a weapon needs to be equipped in order for the SetCameraWindow() command to work.

Posted: Mon Dec 18, 2006 1:53 pm
by QuestOfDreams
Hmm.. that shouldn't be necessary... I'll have a look at the code. Can you please tell me how exactly you used the command?

Posted: Mon Dec 18, 2006 2:13 pm
by Juutis
I tested it with this simple script:

Code: Select all

{
a [1]

	Spawn[ ()
	{
		Console(true);

		LowLevel("setup");
	} ]

	setup[ ()
	{
		self.ThinkTime = 0;
		a = a + 0.1;

		SetCameraWindow(sin(a));
	} ]

}
First I only had some projectile definitions in the weapon.ini (I'm using scripted weapons, so that's all I need). Not a single weapon definition, and the FOV part of the SetCameraWindow() command didn't work. I could change the size of the viewport but not 'zoom in'.

Then I added one weapon to the weapon.ini. I just copied the 'c8' weapon definition from the RF demo, and wham! it worked just like it's supposed to.