Vector::dot?

Post Reply
perrinoia
Site Admin
Posts: 3732
Joined: Sun Jul 01, 2012 7:18 pm

Vector::dot?

Post by perrinoia »

I need some help figuring something out...

I'm writing a function that determines if a player is on the correct side of the terrain, regardless of the rotation of the terrain.

Currently, it checks if the terrain rotation is "0 0 0" or NOT "0 0 0", assuming that it is either right side up, or up side down... However, there are other rotations to consider... For instance, there are a couple of maps in the Annihilation map pack that have terrain at odd angles...

I was looking at some deploy functions and noticed they used Vector::dot to determine if the surface you are deploying on is close to level or not, and was wondering if any of you geniuses could explain how it works (or more importantly, what range of return values I should test for).
Image
perrinoia
Site Admin
Posts: 3732
Joined: Sun Jul 01, 2012 7:18 pm

Re: Vector::dot?

Post by perrinoia »

Yes.. I did.

I scrapped the idea of using vector::dot completely...

Instead, I wrote a function that creates 2 variables for each terrain.
The object ID (to compare against $LOS::Object) and a direction (vector::getFromRot) to look in for the terrain.

The idea is, another function will search from the player's position, in the direction of the vector for each terrain, and compare the found object id to the object id associated with the vector. If the object ID's match, the player is underground.

It's still a work in progress, as the rough draft isn't yielding the results I wanted...
Image
perrinoia
Site Admin
Posts: 3732
Joined: Sun Jul 01, 2012 7:18 pm

Update:

Post by perrinoia »

OK, I got it working, now...

The problem occured when I stored values in the variable array.

If I was playing on a map with two terrains, the function could tell which side of the second terrain I was on, but not the first.
If I was playing on a map with one terrain, the function could not tell which side of the terrain I was on.

The reason is because I incremented the index of my array after storing the information, and never initialized the variable for the index before, so rather than counting 0, 1, 2, 3, etc... It counted "", 1, 2, 3, etc...

However, the function that looked for the terrains, counted 0, 1, 2, 3, etc... So the first vector and object id to search for were never found.

It is fixed now, though. Works flawlessly (until you get to the edge of the terrain or a hole, of course).
Image
Post Reply