Scripted zoom

Topics regarding Scripting with Reality Factory
Post Reply
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Scripted zoom

Post 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?
Pain is only psychological.
User avatar
scott
Posts: 1151
Joined: Tue Jul 05, 2005 1:59 am
Location: United Kingdom

Post 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.
*GD*
GD1
Posts: 413
Joined: Tue Jul 05, 2005 2:33 pm

Post 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);
Check out my band
Tougher Than Fort Knox
Image
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post 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.
Pain is only psychological.
User avatar
scott
Posts: 1151
Joined: Tue Jul 05, 2005 1:59 am
Location: United Kingdom

Post 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
*GD*
GD1
Posts: 413
Joined: Tue Jul 05, 2005 2:33 pm

Post 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.
Check out my band
Tougher Than Fort Knox
Image
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post 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.
Pain is only psychological.
User avatar
QuestOfDreams
Site Admin
Posts: 1520
Joined: Sun Jul 03, 2005 11:12 pm
Location: Austria
Contact:

Post 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?
User avatar
Juutis
Posts: 1511
Joined: Thu Jan 12, 2006 12:46 pm
Location: Finland

Post 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.
Pain is only psychological.
Post Reply