Check Distance Within Certain Angle

Started by
19 comments, last by belfegor 10 years, 9 months ago


character should never see the model if it's too high...

On which axis is height? Does that ring some bells?

Advertisement

X = Right/Left

Y = Up/Down

Z = Forward/Backward

Then check the distance along Y axis between character and model.

The problem is the character could move his head to look up, in that case the character should see the model above him.

So, it will be based on where the character head is pointing at.

Example: The character heard something above him, then he would look up.

Then grab view orientation where his head is facing to build "view cone".

Maybe it's easier to calculate the distance based on Y axis and do calculation based on the player head rotation angle?

dealing with targets above/below is the same as dealing with targets left/right, but instead of working in the x-z plane, you work in the vertical plane that lies in the direction the player is pointing.

again, it can be done by calculating relative angle, or by checking dot products.

if you use dot products, remember that the range -1 to 1 is not linear, its sinusoidal. not an issue if you're just testing boundary conditions.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

How do I get the "view" to deal with targets above/below?

I need to change the following line:


D3DXVECTOR3 view( temp.m[2][0], temp.m[2][1], temp.m[2][2] );

How do I get the "view" to deal with targets above/below?

You could store two matrices for your character, one used to move him around the world and other "dummy" for local orientation of his head (if it is a humanoid) you probably also need to constrain your rotations.


struct Character
{
    matrix world;
    matrix dummyHead;
};
...
// extract "view"
matrix headPos, headRot;
// head offset pos from character model center
// so it doesn't look from its stomach (or feet) depending where do you place it in modeling editor
// if your character is 1.8 tall and you center it on origin this will move his "head" in somewhat normal position
MatrixTranslation(&headPos, 0.0f, 0.82f, 0.0f); 
// head rotation
MatrixYawPitchRoll(&headRot, clampDegree(head_rotationX, -80, 80), clampDegree(head_rotationY, -70, 70), clampDegree(head_rotationZ, -20, 20));
dummyHead = headRot * headPos;
matrix temp = world * dummyHead;
vec3 view( temp.m[2][0], temp.m[2][1], temp.m[2][2] );
normalize( &view );
...

The head is associated with "preset animation", so how do I determine the current head transformation?

Do I have to get the head bone transformation?

This topic is closed to new replies.

Advertisement