Jump to content
Sign in to follow this  
DBR_ONIX

Working Camera Project

Recommended Posts

Right..

FWATCH was made by Kegetys a few months ago, which opened up huge scripting ablities.. But, it should have been used a lot more than it has been.. I think one problem with it is people thinking "Yey, but what can I do with it"

Last night, for no real reason, I decided to see what I could do with it.

Using a combination of Visual Basic, FWATCH's scripting additons and the power of bordum, I've put together the first (Proof of concept) version of "OFPCamera"

To use (Italics are extra info, you don't have to read these bits)..

1. Start the EXE (Can be at any time, before you launch OFP, or during the mission, whenever, as long as it's before you want to take a photo, obviously..).

2. Start Flashpoint USING FWATCH. If you don't, it will not work :;):

3. Load the demo mission (I will incorporate the scripts into a unit with a camera in the next version)

4. Press the H key, and it takes a screenshot, saving it into C:\ScreenShots. One bmp, called _bmp_0.bmp, and a jpg, called 0.jpg.

If you restart the program, it will number the screenie the next avalible number, so if you have _bmp_0.bmp, and 1 and 2, it will number it as 3, if you remove 0, it will name it 0.

If you get an error when starting the OFPCamera exe, chances are you need the Visual Basic 6 Run Times

It uses the Freeimage DLLI. t can generate a thumbnail of the photo, compress the screenshot to lower quality JPEG etc, or, more importantly resize an image to 512x512, or 1204x1204, I've tried this, and it works fine biggrin_o.gif.

Just let me know if a DLL-free version is wanted smile_o.gif

OFP Camera V0.4 (523kb - Beta Release)

Demo Mission :

Included in above download

Once again, start the OFPCamera EXE, start OFP using FWATCH, load the demo mission and press H

I'll release the source code for the program along with the camera addon (the one with intergrated scripts).

Future Improvements :

1. Camera addon, config-ed as pistol, with weak ammo. When fired, use's switchcamera to change the view to optics (blank), takes photo, and switches back to first person (Unless the current view can be detected, when switch back to last used view).

2. Work out, if possible, to trigger DXDLL's disable UI feature, and take photo with no UI

3. Neaten GUI on program, the segment of the previous screenshot was left there for testing purposes, can be handy to see it's working

4. Sort sorting of screenshots, move BMP's to a folder, and JPGs to another.

5. Introduce more error handling on options page, I've not checked, but if you put a trailing \ on the path, it will screw up. It checks if the OFP folder entered exists. It auto-detects the OFP folder from registery, so I dont think it should matter. The screenshot folder is auto-created if it doesn't exist, I should include an option to cancel this and go back and change it.

Any suggestions I will try and implement

Feedback excluding "What's the point in this?" is welcome

"Whats the point in this?" - Showing what can be done with FWATCH smile_o.gif

- Ben

Edit : Updated ZIP, with demo mission and fixed EXE

Share this post


Link to post
Share on other sites

I am I right in guessing that the created .jpg file could be then used in a dialong or Cut Resource, within the same mission?

Share this post


Link to post
Share on other sites

That was what I was going to work on next :;):

Basicly, yes, all that needs to be done is change the save screenshot dir to

C:\Program Files\Codemasters\Operation Flashpoint\

And you can access the file via

../../../0.jpg

Slightly less basicly, the VB app writes to another file, currentPhoto.db, current=0, or current=132.

Then using FWATCH, you read that value, and

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_currNo = call loadFile format[":file read currentPhoto.db %1", "current"]

_path=FORMAT ["../../%1.jpg",_currNo]

this setobjecttexture _path

Two problems, 1, it'll clutter your OFP folder to hell

2, Cut resource's are defined in the Description.ext, as are Dialouges, these are read by OFP when the misison is loaded, so can't be changed mid-mission

If setobjecttexture isn't useable (Quaity can be quite low on big textures I think), if a flag can be stoped from moving, setflag seems better quality.

- Ben

Share this post


Link to post
Share on other sites

just for some info to people: theres a good chance im making a camera model for this..

Share this post


Link to post
Share on other sites
Quote[/b] ]2, Cut resource's are defined in the Description.ext, as are Dialouges, these are read by OFP when the misison is loaded, so can't be changed mid-mission

Sure the dimensions and stuff like that are, but the text or "picture" can be changed in game.

IE: if you make a dialogue that will show a picture when you hit a "Look at Camera feed" action, and the dialogue is say dialog IDC 420, and its classed as RSCPicture, you can simply do:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_currNo = call loadFile format[":file read currentPhoto.db %1", "current"]

_path=FORMAT ["../../%1.jpg",_currNo]

ctrlsettext [420,_path]

And the picture will show up.

So in this way, it is possible to have a person being a recon guy and having a 'helmet cam' that takes a picture every 2 seconds. Having a picture every 2 seconds would be incredibly annoying tho.

Share this post


Link to post
Share on other sites

True, true

I'll try this out smile_o.gif

Hmm.. Another idea, for multiplayer.. One computer runs a client, which takes the photo, compresses it, and sends it to the server..

So the recon-guy's PC would be running the client, and send photos to the rest of the people's computer.

So you could see what he's seeing on your setobjecttextured, or ctrlsettext thing..

Draw back is obvious, but if it was updated every 5 seconds, should be okay..

I'll check out this idea, make sure it works before going on any further tounge2.gif

- Ben

Share this post


Link to post
Share on other sites

Don't Windows programs look the dlls from program directory first? See if that works.

Share this post


Link to post
Share on other sites

Ah, sorry.. I know what I did wrong..

It didn't work puting it in the same folder as the VB project when I was testing it (Run button in VB), because it puts the EXE in a temp folder..

It works fine having the compiled EXE in same folder as DLL

Ta for reminding me to try icon_rolleyes.gif

- Ben

Edit : I've fiddled with code, it now saves the JPG as 512x512, and the BMP is orig resoulution. I'll add in an option to choose the size, and whether to enable this option or not. This will be released with camera addon smile_o.gif

Share this post


Link to post
Share on other sites

Current status on EXE-Program :

- Now writes to a file currentPhoto.db, with the current screenshot number

- Now has options to compress screenshot to JPEG, or compress to JPEG and resize

- Few random fixes

Current status on OFP scripts :

- Now reads current number, and setflagtexture's the current screenshot (This is done by setting Screenshot folder to same as OFP folder, and the code I'll put up in a minute)

- Half-done the working camera scripts, using fired EH (Will be added in unit config), checking the weapon fired.

- Still works with H button (Must be set up in INIT.sqs or any other scipt in mission)

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_x = call loadFile format[":file read currentPhoto.db %1", "currentPhoto"]

HINT FORMAT ["%1",_x]

_path = FORMAT ["../../../%1.jpg",_x]

HINT FORMAT ["%1",_path]

flag1 setflagtexture _path

Basicly reads the value put by the VB program, puts it in ../../../>here<.JPG, and applys that to the flag

This could be looped, not tried that yet (Just wrote code a few minutes ago, and tested once or twice, seemed fine).

Problems : If screenshot folder is changed, the currentPhoto.db file contains the numbers for folders that OFP can't reach (I.e trying to access ../../../4.jpg, even though 4.jpg is in C:\Screenshots)

Other Ideas :

- Fly over view in cutscene of enemy base, when the view is in the middle, use the code to take a photo, this is then setobjecttextured to a screen at the players base. Real Intelligence photos (This was the idea that started the whole VB/OFP stuff, acctualy)

- Using a real webcam, and similar idea to the current program, but instead of using screenshot, use a picture taken from webcam (Code around to do this easily enough), moderatly pointless, but could be fun tounge2.gif

- Dynamicly updating stats via internet. Using FWATCH, and VB. VB reads a file FWATCH creates, and sends this data to a PHP script (I'm using languages I know, this could be done in C and Perl, but I don't know them tounge2.gif), it updates a database, maybe player's name, current rating and mission name. So at the end of every mission, FWATCH makes a file with

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

player=Ben

rating=100

mission=MyMission1

Then these are read by a program, changed to

http://blah.com/handleS....ission1

And entered into database.

- Using the results in the database form previous idea, generate a dynamic image, and download this using a program, and apply it to a billboard or, even easier, write this files to a file, and use FWATCH to retrive these, and sidechat/hint/titletext them.

Anyway, the camera project should be done within a week. smile_o.gif

- Ben

Share this post


Link to post
Share on other sites

mhh

the actual difficult part starts now...

how do u want to get the iamges into ofp back again??

setobjecttexture is a bad option...

and u can basically forget resources as theyere predefiend

Share this post


Link to post
Share on other sites

Best way (Quality wise) I can think of is to split the image into

image0split0, image0split1 etc, into 9 bits, or so, and setobjecttexture each one (_path=FORMAT ["../../../split/image%1split%2",_currentPhoto,_counter])

Not very neat, but the images could go in 3 folders, /BMP/, /JPG/, /SPLITS/

And it wouldn't mess up the OFP folder too much

Biggest problem just now is it only works for missions from Editor, to get the pictures in Single Missions for example, you have to use ../%1.jpg, not ../../../%1.jpg

Never really used them, dialouges can display image inside mission folder? Thats another thing I have to get around to learning icon_rolleyes.gif

- Ben

Share this post


Link to post
Share on other sites

Just waiting for camera model, if I got that now, it'd be done by tomorrow, so 2 days and it should be out..

Programs nearly complete, may have a look at using registery for storing previous settings.

- Ben

Edit : Release iminent, no camera model/weapon, sadly, this will be released seperatly if interest. Blame lies on standard-scapegoat, Dave biggrin_o.giftounge2.gif

Share this post


Link to post
Share on other sites

Release!

The program, VB Source code and documentation

http://www.dbrweb.co.uk/hosted/OFPCamera.zip

The important bit, the documentation :

http://www.dbrweb.co.uk/hosted/OFPCamera-Documentation.htm

Sorry I didn't include the camera/photographer addon, but this really wasn't the point behind this project. The point was to get people to use FWATCH more. But if there is interest, I'll do the Photographer unit smile_o.gif

"Go Create" tounge2.gif

- Ben

Share this post


Link to post
Share on other sites

Cool addon.

It reminds me of Hidden and Dangerous where you had to take a camera on missions to get a screen shot. It will add a whole new dynamic to missions now.

Recon photography.

All we need now is the "weapon" biggrin_o.gif

Share this post


Link to post
Share on other sites

This sounds quite nice, though I'm either blind or there is no demo mission included in the zip. And both an _bmp_n.bmp and n.jpg is saved no matter whether I have checked "Compress to JPEG" or not.

Sorry for the picking, it's just that I imagine playing a real realistic and innovative coop mission where locating enemy activity is half the job smile_o.gif

Edit:

Another idea would be to make a camera addon do about 0.0001 damage to the unit(s) included in the image or something similar. This way one should be able to identify which unit(s) have been actually spotted by the camera guy, and base a mission objective on the content taken in the photo, for instance an enemy tank in a no-military zone.

Share this post


Link to post
Share on other sites

Opps... I forgot to include the demo mission in the zip icon_rolleyes.gif

Here it is

Sorry about that..

Anyway, the problem with using a weak bullet to see where the player has taken a photo is that you can't tell if they took the photo with, say, the tank in the left side of the screen, it'd have to be centeralised. But.. if you worked out where the "bullet" hit, and got it's distance to the tank, and if that is less than 10m, the photo is taken.

As for the always saving as JPEG, what the program did was save the value into the registery, but it's only reading these values, if you "uninstall" the program (Remove it from registery), and restart it, it doesn't save the jpeg version, I'll fix this now.

Cervo pointed out an interesting idea, every second or so, get the distance between each player, then save this to a file, then using a voice comm program, reworked, adjust each players vioce according to the distance between them. So if your right next to them, it's normal volume, and this slowly fades over distance, to you not being able to hear them at hunder meters or whatever..

Very interstesting idea, but hard to implement, as it involves writing a teamspeak-a-like, or modifiy an existing Voice-Comm program, and matching up the ingame name to the teamspeak name.

I suppose if this (The script to get distances) was run in a custom gamelogic, and started in the config file. It would be easy enough to use, just shove the gamelogic in the mission.

Hmm, if the distances were worked out on the server, and the server sent the volume to each client, so if there were 5 people on the server.

1, 0

2,0.5

3,-1

4,1

5,0

(1, who is Mr One in Flashpoint is far away from this client, Mr 2 is half-the audible distance, the client is Mr 3, Mr 4 is right next to the client, and 5 is far away as well)..

This way, the clients only have to run the server, and normal flashpoint, so only FWATCH on server biggrin_o.gif

(Simply : The server checks distance between players, sends these values to a TS-style server/client, and also sends distances, and fades the people talking's voice out the further they are away)

Here's V0.5 of the program, put it in the same folder as the FreeImage.DLL file

Seems to be okay, not fully tested though

- Ben

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  

×