OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Gaia on 03 Aug 2006, 19:52:57

Title: Detect stance
Post by: Gaia on 03 Aug 2006, 19:52:57
I'm trying to detect soldiers stance using camera to locate soldiers head which has different height for every stance.

Code: [Select]
_sensor = "EmptyDetector" CreateVehicle [0,0,0]
_callheight1 = {_sensor setpos [position _this Select 0, position _this Select 1, 0]; _result = position _sensor select 2; _result};
_callheight2 = {_sensor setpos [position _logic Select 0, position _logic Select 1, 0]; _result = position _sensor select 2; _result};
_absheight1 = abs(player call _callheight1)

_logic = "logic" createvehicle [(position _this select 0)+1,position _this select 1,0]
_absheight2 = abs(player call _callheight2)
_height = abs(_absheight2 - _absheight1)

_basepos = [(position _this select 0)+1,position _this select 1,_height]

deletevehicle _logic
deletevehicle _sensor

_cam = "Camera" CamCreate _basepos
_cam CameraEffect ["INTERNAL","BACK"]
_cam camsettarget _this
_cam camcommit 0

_cam2 = "Camera" CamCreate [0,0,0]
_camposnew = position _cam

_cam2 CamSetTarget _cam
_cam2 CamSetRelPos [0,(_camposnew select 2),0]
_cam2 CamCommit 0

~0.0000001

_cam2 CamSetRelPos [0,+500,0]
_cam2 CamCommit 0
_camtarget = position _cam2

_cam CameraEffect ["TERMINATE","BACK"]
CamDestroy _cam
CamDestroy _cam2

_status = _camtarget select 2
?_status > 400: _anim = "Stand"
?_status < 400: _anim = "Kneel"
?_status < 300: _anim = "Lying"

hint format ["%1\n\n%2\n\n%3",_status,_anim,_height]

exit

This script is based on old Jezuro's camera script and it's only prototype with some bugs. The most visible is blink after creating a camera where is the camera shown for a little while. I don't know how to get rid of it, so I need Your help.
Another bugs are on sloped terrain, but it can be later fixed using more cameras created in the same height as unit (using detecting ASL height).
Title: Re: Detect stance
Post by: Mr.Peanut on 03 Aug 2006, 23:28:14
_CAM camCommand "manual on"
_CAM camCommand "inertia off"
Title: Re: Detect stance
Post by: Wolfrug on 04 Aug 2006, 17:12:19
Hmm! That's a very clever idea, actually.  ;D Maybe you can help The-Architect's problem with making a steaming-breath thing in conversation if you manage to make it work (same forum, a couple of posts below, can't be arsed with linking ;D).

I'd read through it or test it but I need to iron my shirt. Just wanted to say it sounds good.

/Wolfrug out.
Title: Re: Detect stance
Post by: h- on 04 Aug 2006, 20:12:26
Interesting indeed..

I also have played around with the cameras but I never got it to work in anyway..
Probably because I'm an idiot and complete math retard :P

If only you would make this into a function ;)
Title: Re: Detect stance
Post by: JasonO on 05 Aug 2006, 23:34:47
Hmm! That's a very clever idea, actually.  ;D Maybe you can help The-Architect's problem with making a steaming-breath thing in conversation if you manage to make it work (same forum, a couple of posts below, can't be arsed with linking ;D).

I'd read through it or test it but I need to iron my shirt. Just wanted to say it sounds good.

/Wolfrug out.

http://www.ofpec.com/forum/index.php?topic=26301.0

:)
Title: Re: Detect stance
Post by: Mr.Peanut on 15 Aug 2006, 23:10:25
Any progress?
Title: Re: Detect stance
Post by: JasonO on 16 Aug 2006, 00:01:07
Any progress?

Yes, good question  :D

This is a very promising script, please share anything new you have found out. :P
Title: Re: Detect stance
Post by: bdfy85 on 16 Aug 2006, 18:16:24
Quote
I'm trying to detect soldiers stance using camera to locate soldiers head which has different height for every stance.
No chance. There's no command you can place  camera near unit's head. You will always get ground coords cause that's unit ingame position.
Title: Re: Detect stance
Post by: Gaia on 18 Aug 2006, 12:32:27
No chance. There's no command you can place  camera near unit's head. You will always get ground coords cause that's unit ingame position.
Maybe, but camera always targets unit's head.
And no progress yet, I hadn't tried it since last post, because of not 100% work. Jezuro, maker of original script, tried it too, and he said there is no way to create that camera without visible delay.
Title: Re: Detect stance
Post by: bdfy85 on 18 Aug 2006, 16:11:35
Quote
Maybe, but camera always targets unit's head.
And what can you do with this direction ? you can't get  3d dir of the camera or caculate head position in another way.
script in the first postdoen't seem to be worky  - it calculates everything but not what is needed. If you can get working algorithm I'm sure camera issue will be solved.
Title: Re: Detect stance
Post by: DanAK47 on 19 Aug 2006, 19:30:41
Maybe you should try the script yourself.

Works great for me. The blink is not as bad as you make it out to be. Maybe you could just do a little fade action to hide it.
Title: Re: Detect stance
Post by: bdfy85 on 19 Aug 2006, 22:32:08
Hmm... I get half of my words back :)
It does work - on flat surfaces only.
There're lots of unnesessary calculations in the script - that makes it difficult to understand. And I still can't see any clear ida behind it...
Anyway there's definately something to think about... I'm missing such command very much
Title: Re: Detect stance
Post by: DanAK47 on 20 Aug 2006, 07:56:32
Yeah. It has the same reliability problems every other method has, but does work..
Title: Re: Detect stance
Post by: bdfy85 on 20 Aug 2006, 10:36:51
Quote
but does work..
Yes, but how ? Can the very author explain what he is doing in this script ? Cause it's a set of command without clear sence for me at the moment :(
Quote
here is no way to create that camera without visible delay.
You set this delay in the script ;) You have to use  camcommitted command - not pause if you don't want to see delay.
But without such delay it doesn't work for some strange reason.
So if you want help - explain your idea to the community first - cause it's hard to get it from the script :(
Title: Re: Detect stance
Post by: Cheetah on 20 Aug 2006, 11:19:12
You may also want to try this script: http://www.ofpec.com/forum/index.php?topic=27992.0