Strange "Linepick" situation

Blitz3D Forums/Blitz3D Programming/Strange "Linepick" situation

Jack(Posted 2005) [#1]
LinePick(EntityX(gb),EntityY(gb)+h,EntityZ(gb),EntityX(gb),EntityY(gb),EntityZ(gb)+2115)

The above LinePickcommand in my app finds an object which stands between the Entity "gb" and its target.The +h is just variable in a loop that checks different heights along the line.

Now;I got the distance from "gb" to the target two ways.
From the relative position of the object posZ and "gb" posZ and the Blitz distance command.That result was 250.
I did bioth ways just for a double check.

Notice the +2115 in the LinePick command.If I make that number any less the LinePick does not find the object.

Is this as it should be and if it is - why and how is it computed.Otherwise -what the heck???????


Shambler(Posted 2005) [#2]
Have you applied scaling to the entity?

If so you must scale the line pick also.


Jack(Posted 2005) [#3]
Yes,I scaled the object 2.5.
That still does not relate 2115 to 250 in any way.
Nor does scaling seem to effect the distance.
Are you sure that is relevant?


Matty(Posted 2005) [#4]
You are using linepick incorrectly:
Your first 3 parameters are correct -the position you wish to linepick from. The next 3 parameters should be the components of the vector from your starting position to your ending position. Assuming your target point is at coordinates "TargetX#, TargetY# and TargetZ#" then do this instead:

linepick entityx(gb),entityy(gb)+h,entityz(gb),targetx-entityx(gb),h+targety-entityy(gb),targetz-entityz(gb)


Jack(Posted 2005) [#5]
Matty -

I really do not have a target.

My intent is to go on for infinity (Kind of).

Basically what I am doing is a vector to nothing.

I just wonder if the spot of the hit cannon be measured in this manner.


John Blackledge(Posted 2005) [#6]
If it's any help, my linepick from the sky to the ground messed up until I realised that I had to use EntityPickMode on the ground. (Doh!)
EntityType Ground\hent,TYPE_TERRAIN
EntityPickMode Ground\hent,2
- or whatever.


Matty(Posted 2005) [#7]
Jack - what do you mean by a 'vector to nothing'. 'My intent id to go on for infinity' - what direction though (a vector is not just magnitude but also directional).


I didn't quite understand what you meant by "I just wonder if the spot of the hit cannon be measured in this manner".


Jeremy Alessi(Posted 2005) [#8]
Use EntityPick() instead.


Jack(Posted 2005) [#9]
Matty - it is in the "Z" direction only.

Jeremy - Why? .The lLinePick is fine otherwise.


Matty(Posted 2005) [#10]
Jack - Local Z Direction or Global Z Direction? (ie character or object's forwards direction or the world's forwards direction)

If you want to check for an object using linepick in the 'local z direction' then you will need to use the TformVector commands to transform the entity's space to the world space.

As an example, if I were to have a character that I wanted to test for an object that is directly in front of it (local space) then I would do this:

LocalX#=0
LocalY#=0
LocalZ#=some number for how far in front you wish to check..

TFormVector LocalX,LocalY,LocalZ,CharacterEntity,0
;the above line takes a vector and transforms it from your character's local space to the world space (or global coordinates)

objectihit=linepick EntityX(CharacterEntity),EntityY(CharacterEntity),EntityZ(CharacterEntity),TFormedX(),TFormedY(),TFormedZ()
;this performs a linepick directly forwards from the character's point of view.

;put the rest of your code here as normal...



Note though that (in my experience) linepicks are often slow and wherever you can get away without them the better


Jack(Posted 2005) [#11]
John - Thanks.I made sure I did this a while back.

Matty - At this point I am not sure that this is a problem since I have not rotated the "character" and the move commands all work as expected.IE - the Z direction is straight into the distance.BUT - I'm glad you gave me this info since that will not always be the case and I never thought of setting the linepick this way.I figured on having to do some angle stuff when I rotate the "character"

I will check this as the "character" is pointed now.Since I will always want the linepick from the direction the "character" is pointed I guess I can set this once and forget it for the remainder of the time the object is moving.

By the way - I'm not too worried about the time factor since this will only fire once - before movement starts.
I cannot use EntityPick" because I need to get the SURFACE hit and not just the OBJECT.

Thanks for the input.