Jump to content

Recommended Posts

Im posting this as a follow up to a discussion Gunter and I had on my DynamicCamo thread about a form of camo which would adapt to reflect its visual environment. I thought Id post this up to show the proof of concept. No doubt this has been done before but this is my take on it with code I really just slapped together. This particular version works on a Slammer Tank but can be easily adapted too other vehicles.

My real aim was to produce a small sniper deployable screen which a sniper could hide behind. Ive got a working version of that but I wnt to see if I can get it better before posting it. Anyway meanwhile - 

 

(Note this is ( a bit) a semi realistic effect as some armed forces have done work on this type of camo.)

 

1. Place a Slammer Tank in editor.

2. Name the tank  tank     ( im so original)

3. In the tanks Ini put 

 0=[tank] spawn compile preprocessfile "camCamo.sqf";

 

4.  the camCamo.sqf script will give the visual camo. If you want to make sure the tank is indeed harder for AI to see you might want to also add

this setunittrait ["camouflageCoef",0.2];    (Ai don't actually respond to the visual  camouflage of the vehicle as far as I can tell but will use the camouflagecoeff.)

 

5. Save the following script as camCamo.sqf to your scenario folder and then run the scenario and wtch the tank. drive it about and watch the visual camo reflect its surroundings and the jobs done.

 

I'll post a redeployable sniper screen version up at some point fairly soon.

 

Spoiler

params ["_veh"];

_pipcam = "camera" camCreate [0,0,0];
_pipcam attachTo [_veh, [0,-3,5]] ;

_y= 180; _p = -90; _r = 0;
_pipcam setVectorDirAndUp [
    [ sin _y * cos _p,cos _y * cos _p,sin _p],
    [ [ sin _r,-sin _p,cos _r * cos _p],-_y] call BIS_fnc_rotateVector2D
];

_pipcam cameraEffect ["Internal", "Back", "_pic"];
_pipcam camSetFov 1.2;

_veh setObjectTexture [0, "#(argb,512,512,1)r2t(_pic,1.33)"];
_veh setObjectTexture [1, "#(argb,512,512,1)r2t(_pic,1.33)"];
_veh setObjectTexture [2, "#(argb,512,512,1)r2t(_pic,1.33)"];
_veh setObjectTexture [3, "#(argb,512,512,1)r2t(_pic,1.33)"];

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

I should have noted - the last number in each line where I'm  setobjectexture   is as far as I recall ( I wrote this weeks ago) a texture multiplier. A higher number makes more duplicates of the texture to that slot. You might want to bugger about with those figures to find what pleases you. Oh and bugger about with the FOV as well.

  • Like 1

Share this post


Link to post
Share on other sites
14 hours ago, The Real Bunc said:

I should have noted - the last number in each line where I'm  setobjectexture   is as far as I recall ( I wrote this weeks ago) a texture multiplier.

Reading the wiki helps

https://community.bistudio.com/wiki/Procedural_Textures#Render_To_Texture

 

Quote

aspect - Aspect ratio of the image

 

 

You never use the _pic variable that you assign, I assume that might be an error and you tried to do something different with that?

Share this post


Link to post
Share on other sites

As I said this was code I slapped together weeks ago so it's likely full of redundancy and inefficiency. It does work though. I'm using the _pic variable in the setobjecttexture lines though am I not - maybe you didn't notice that?  Re the number being aspect ratio - yes indeed. My bad. As I said it was weeks ago I slapped out this code just to test the approach. I'm certainly not going to die on a lonely hill defending the specific code as it stands! 😂 

Share this post


Link to post
Share on other sites
6 hours ago, The Real Bunc said:

I'm using the _pic variable in the setobjecttexture lines though am I not

No you're not.
You are using the string "_pic" there, but not the content of the _pic variable.

Share this post


Link to post
Share on other sites

,Hi Dedman, I stand corrected, thanks for that.. Not sure what that _pic variable assignment was for, its probably a code line left over from me doing something else with it.  I've edited the code to take that out.  I should have also noted for anyone trying this code snippet that it wont work without PIP enabled.

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

×