Mathmatical challenge - 'flipping the vector'

Blitz3D Forums/Blitz3D Programming/Mathmatical challenge - 'flipping the vector'

puki(Posted 2006) [#1]
We've all been there - you try to move a mesh from one place to another and once the little fellar is on his way via the vector, the little fellar is moving backwards (facing the opposite way it is moving) but is moving in the right direction:

bx#=EntityX(targetmesh)-EntityX(yourmesh)
bz#=EntityZ(targetmesh)-EntityZ(yourmesh)
bn#=Sqr(bx^2+by^2+bz^2)
bx#=bx/bn
bz#=bz/bn
AlignToVector yourmesh,bx,0,bz,0,.1
MoveEntity yourmesh,0,0,.05

Mathmatically, can the above be written to move the mesh but not reverse the way it is facing?

I played around with it a bit and managed to send the mesh on a negative vector (ie moving the right way and facing the right way), but the steering went wonky.

I'm just wondering if mathmatically this can be done? Perhaps, I am even doing the math wrong?

Some might suggest to 'RotateMesh' the mesh beforehand or load it into a modelling package and face it the opposite way. However, my problem is the characters are all rigged up with skeletons and stuff. If I try to flip them then they go all wonky like something out of 'The Thing'.

I feel that a solution to this problem benefits the community


Grey Alien(Posted 2006) [#2]
matrix matrix matrix.


big10p(Posted 2006) [#3]
I'm a bit pi**ed at the mo but, can't you just negate the movement vector? i.e. -x,-y,-z


puki(Posted 2006) [#4]
I tried using a negative vector before and sending the mesh on a negative movement, but it didn't work.

Sniffage.


Grey Alien(Posted 2006) [#5]
Try applying a normal sausage.


puki(Posted 2006) [#6]
In fact, I just emailed the model authors and asked if they could just face the models the opposite way on the Z axis. Maybe other programming products are not affected by this as both authors supply models for Torque and DB, etc?

I'd still like to know how to solve it in code.


BlitzSupport(Posted 2006) [#7]
Not sure I'm grasping what's going on, or whether this does what you're asking, but how about parenting to a pivot and rotating the mesh "beneath" that, moving the mesh via the pivot?


H&K(Posted 2006) [#8]
Why not just do it the way you said in the first post, but just steer in the oposite direction

Did you giveup driveing because you couldnot reverse? Did you demand that the drivers seat turned around. No you just got used to turning the wheel the other way.

My Oblivion clone, is going to be well better than yours


simonh(Posted 2006) [#9]
Try LoaderMatrix...


puki(Posted 2006) [#10]
Ah, this must be what "Grey Alien" was spouting on about.

I've never used the command. I'll take a look and lesson those meshes.


Defoc8(Posted 2006) [#11]
jst a couple of things..
- align to vector causes the local axis of an object to
tranform..so your making the zaxis point in a given direction..
This is fine, but keep this in mind, because if you now rotate
about the axis vectors you may not get the expected
results - the local axes have become none orthonormal (they are no longer at right angles to each each other).
[i could be wrong here..but i imagine this could be a problem]

as for moving backwards without changinf direction..
moventity(blah,0,0,-1) = -1 along z vector/axis

if you want to use positioning - grab the z vector, negate
it, multiply by a scalar displacement...and add it to your
position... the a vectors negative, has opposite sense..
so unless theres something wrong elsewhere, you should
be moving backwards..

perhaps ive missed something, but from what you have written, i dont see a real problem..


puki(Posted 2006) [#12]
Interesting answer from BasilStudio:

I am aware that the b3d models are flipped though that is intended as i optimized the models for the
Realmcrafter Engine that require the models to be like that. Though you are right its a good idea to include a normal version.


It shows that B3D is not the daddy - I am sorting this.

I assumed it would have to be in relation to other programming environments - as it didn't make sense to me.

Also, BasilStudio supplied me with upated .b3d meshes - so nice one BasilStudio - although I am their most favourite customer.

Actually, this is also a cause for concern over the future release of the RC media - best I email them now before it goes splat at launch.


puki(Posted 2006) [#13]
Can anyone vouch for the 'LoaderMatrix' command working with .b3d files?

I resolved the above problems by getting the model authors to redo the models. In now have a new batch of animated b3d models that all face the wrong way on the Z-axis.

I find that 'LoaderMatrix' does not do anything, regardless of what values I throw at it.


puki(Posted 2006) [#14]
In fact, I'll assume 'LoaderMatrix' does not work for this type of thing:

http://www.blitzbasic.com/Community/posts.php?topic=36026

I hope "Matty" is right.


puki(Posted 2006) [#15]
In fact it does not work - it almost works, but the skeleton is still slightly screwed up in the way the joints bend.


puki(Posted 2006) [#16]
It's okay - panic over - the RC media is being sorted at source.

Right, no need for maggoty little pivots anymore.