HCP Class Reference

A HCP represents a model Control Point you see in Animation Master, the building block of splines. More...

#include <HCP.h>

Inheritance diagram for HCP:

Inheritance graph
[legend]
Collaboration diagram for HCP:

Collaboration graph
[legend]
List of all members.

Public Member Functions

const VectorGetPosition ()
const VectorGetModelPosition ()
const VectorGetWorldPosition ()
const VectorGetScreenPosition ()
HCPInstanceGetCPInstance ()
HCPInstanceCreateCPInstance ()
HSplineGetSpline ()
HCPGetNext ()
HCPGetPrev ()
float GetInGamma ()
float GetInAlpha ()
float GetInMagnitude ()
float GetOutGamma ()
float GetOutAlpha ()
float GetOutMagnitude ()
Vector GetInTangent ()
Vector GetOutTangent ()
Vector GetModelInTangent ()
Vector GetModelOutTangent ()
Vector GetWorldInTangent ()
Vector GetWorldOutTangent ()
Vector GetScreenInTangent ()
Vector GetScreenOutTangent ()
HCPGetNextAttached ()
HCPGetPrevAttached ()
HCPGetHead ()
HCPWeight * GetCPWeightHead ()
BOOL AddToGroup (HGroupCP **gh)
BOOL AddStackToGroup (HGroupCP **gh)
void SetPosition (Vector *p)
void SetInGamma (float fValue)
void SetInAlpha (float fValue)
void SetInMagnitude (float fValue)
void SetOutGamma (float fValue)
void SetOutAlpha (float fValue)
void SetOutMagnitude (float fValue)
void SetPeaked ()
void SetSmooth ()
void SetHide (BOOL bHide)
void ComputeInBias (const Vector &goalit, float &alpha, float &gamma, float &magnitude)
void ComputeOutBias (const Vector &goalot, float &alpha, float &gamma, float &magnitude)
UINT GetID ()
HCPWeight * AddCPWeight ()
void RemoveCPWeight (HCPWeight *hcpweight)
BOOL IsLoop ()
BOOL IsPeaked ()
BOOL IsSmooth ()
BOOL IsHook ()
BOOL IsFlip ()
BOOL IsHide ()
BOOL IsGroup ()
BOOL IsLocked ()
BOOL IsEndHook ()
BOOL IsHookBase ()
HSegmentCacheGetSegmentCache ()

Detailed Description

A HCP represents a model Control Point you see in Animation Master, the building block of splines.

A HCP can link to the previous and next CP in a HSpline. HCPs can also be attached to other HCPs to form a stack. To the user, attached HCPs appear to be only one HCP, where more than one spline intersect. When a HCP is attached to another HCP, the position of the control point is stored in the first HCP in the stack, which is called the head.

About Bias and Magnitude

Bias and Magnitude control the shape of the spline as it goes through the control point. Bias is made up of Gamma and Alpha.

Gamma is the angle of the spline as it goes in and out of the control point in the plane defined by the current control point and the previous and next control points. The range of Gamma can be from -180 to 180 degrees.

Alpha is similar to Gamma, except that it control the angle of the spline along the plane perpendicular to the patch's surface. The default values of Gamma and Alpha are normally zero.

Magnitude controls the amount of curve of the spline as it passes through the control point. The default value is 1.0, and a value of 0.0 creates a sharp point.

Basically the tangents are adjusted every time the vertices move. The default tangents can be calculated by subtracting the previous vertex from the next vertex and normalizing it.

p1 = previous vertex
p2 = this vertex
p3 = next vertex.

a = (p2-p1).Norm();
b = (p3-p1).Norm();
c = (p3-p1).Norm();
default input magnitude for p2 = a/((a+b)/c)
default output magnitude for p2 = b/((a+b)/c)

Note:
Since v8.0, the above pseudocode is not exact anymore. The tangents are not calculated by (p3-p1).Normalize() anymore. It is more complex, and much, much better. It isn't perfect, but as perfect as A:M can allow. The restrictions are that the tangents on a given point are calculated by the positions of the previous and next vertex. The choice to abide by this is to simplify editing.
Then the non default magnitude, alpha, and gamma are added on top of these default calculated tangents. The non default values are the once entered in AM by the user in the CP properties.

Magnitude can simply be muliplied by the default magnitude. Ex. If the user enters 150 for magnitude, simply multiply the default mag by 1.5.

To solve the gamma for p2, you define a plane created by p1, p2, p3. Gamma is entered in degrees. A close representation would be rotating the tangent in degrees starting at its calculated default tangent location along the plane decribed above. But for efficiency purpose, instead of rotating the tangent in degrees, we linearly interpolate the gamma along a line starting at the tangent to a location 90 degrees from the tangent. Then the new tangent would intersect this point on that line. So 0, 45, and 90 degrees will give you the exact same result as rotating the angle, but the in betweens will differ slighly. You might not care to do the linear part because rotating is pretty close.

Alpha is similar to gamma, but you must look at neighboring splines. You can only adjust alpha if there is a junction of two splines through a vertex. Cross the two vertices to net the normal that the alpha value will rotate around.

End tangent calculation

Here is how to calculate the input tangent into P2, if P2 is the end point on a spline P2, P3, P4, P5, etc.

Tangent.gif

End tangent calculation illustrations

Functions
float Vector.Norm() // length of vector;
void Vector.Normalized() // normalized vector
// Vector * Vector represents dot product

T3 (P2’s new input tangent)
// L1: Length from P2 to P3.
L1 = (P3-P2).Norm()
// T1: L1’s length along line segment P2 P4.          
T1 = (P4-P2).Normalized() * L1
// T2: T1 Projected onto line segment P2 P3. 
T2 = ((T1-P2) * (P3-P2).Normalized()) * (P3-P2).Normalized()
// T3: The mirror of T1 across P2 P3.     
T3 = T2 + (T2-T1)
Cos A1 = (P3-P2) .Normalized() * (T3-P2).Normalized()
Cos A2 = ((P2+P4)/2 – P3).Normalized() * (P2-P3).Normalized()

If A1 > A2 (cos A1 < cos A2) // We must cap A1’s angle
   P2+((P3-(P2+P4)/2).Normalized() *L1)

This is the new location of T3. We found by capping the angle of A1, to be no larger than A2, it significantly helped the appearance of the spline. One of our goals of calculating the new tangent (T3) was to preserve its distance from P2, which is L1. If angle A1 is greater than angle A2, then an easy way to adjust T3 so that A1 is the same as A2 is to use the normalized vector A2 to the midpoint of P2P4 and multiply by it the length L1 and add it to P2. This is guarateed to make angle A1 the same as A2 because they are opposite angles of an intersection between two parallel lines.

Peaked CPs

Peak points are treated differently. Their tangents actually lie on the line between its vertex and the adjoining vertex. End points are a little trickier. They actually take into consideration the previous two vertices.

Definition at line 27 of file HCP.h.


Member Function Documentation

HCPWeight* HCP::AddCPWeight  ) 
 

BOOL HCP::AddStackToGroup HGroupCP **  gh  ) 
 

This function is the same as AddToGroup() except that instead of just adding this HCP, it will add this HCP and all attached HCPs to the group. This is useful when adding control points that were created with the Extrude() function. This function always returns TRUE.

Parameters:
gh - (uplink) the address of a pointer to the first HGroupCP in the group you wish to add this control point to.

BOOL HCP::AddToGroup HGroupCP **  gh  ) 
 

This function first searches the group to make sure this control point isn't already in this group. If it finds that it is, the function returns FALSE. Otherwise, a new HGroupCP is allocated and it is set to point to this HCP and the function returns TRUE. The new HGroupCP is returned in the uplink parameter.

Parameters:
gh - (uplink) the address of a pointer to the first HGroupCP in the group you wish to add this control point to.

void HCP::ComputeInBias const Vector goalit,
float &  alpha,
float &  gamma,
float &  magnitude
 

Note:
Don't seem to work on endpoints of non-looped splines.

void HCP::ComputeOutBias const Vector goalot,
float &  alpha,
float &  gamma,
float &  magnitude
 

Note:
Don't seem to work on endpoints of non-looped splines.

HCPInstance * HCP::CreateCPInstance  ) 
 

Once you are editing the action with a certain model you need to make a call to CreateCPInstance. CreateCPInstance creates a HCPInstance object for the HCP and returns it. if a HCPInstance object already exists for this HCP, the existing object is returned.

HCPInstance * HCP::GetCPInstance  ) 
 

If a HCPInstance object already exists for this HCP, the existing object is returned. Otherwise, NULL is returned.

See also:
HCP::CreateCPInstance

HCPWeight* HCP::GetCPWeightHead  ) 
 

HCP * HCP::GetHead  ) 
 

This function returns a pointer to the first HCP in a stack of attached HCPs. When multiple HCPs are attached, the position is stored in the head HCP. So it is important to use GetPosition() and SetPosition() with the HCP that GetHead() returns when dealing with control points that are attached.

UINT HCP::GetID  ) 
 

float HCP::GetInAlpha  ) 
 

This function returns the Alpha angle value of the spline as it goes into the HCP from the next HCP.

float HCP::GetInGamma  ) 
 

This function returns the Gamma angle value of the spline as it goes into the HCP from the next HCP.

float HCP::GetInMagnitude  ) 
 

This function returns the Magnitude of the spline's curvature as it goes into the HCP from the next HCP.

Vector HCP::GetInTangent  ) 
 

Returns a vector that contains the direction of the tangent of the spline going into this control point. The tangent direction includes muscle, and pose motion, but no skeletal

Note:
HCP::GetInTangent() and HCP::GetOutTangent() may return differing magnitudes, but their direction is the same. For the purposes of computing normals, you must therefore flip the direction of either the In or Out tangents.

Vector HCP::GetModelInTangent  ) 
 

Returns a vector that contains the direction of the tangent of the spline going into this control point. The tangent direction is with no motion, from raw model data.

Vector HCP::GetModelOutTangent  ) 
 

Returns a vector that contains the direction of the tangent of the spline going out of this control point. The tangent direction is with no motion, from raw model data.

const Vector * HCP::GetModelPosition  ) 
 

Returns a pointer to a vector which stores the location of the control point. This is the position of the CP with no motion, raw model data.

HCP * HCP::GetNext  ) 
 

Returns the next HCP in the spline. Returns NULL when it reaches the end of the spline even if the spline is looped.

HCP * HCP::GetNextAttached  ) 
 

This function returns a pointer to the next attached HCP on a stack of attached HCPs. It will return FALSE when it reaches the end. Use this function to walk through attached HCPs.

This is to retrieve the multiple HCP that may be attached together where multiple HSplines meet. So this will in effect jump from Spline to SPline.

float HCP::GetOutAlpha  ) 
 

This function returns the Alpha angle value of the spline as it goes out of the HCP to the previous HCP.

float HCP::GetOutGamma  ) 
 

This function returns the Gamma angle value of the spline as it goes out of the HCP to the previous HCP.

float HCP::GetOutMagnitude  ) 
 

This function returns the Magnitude of the spline's curvature as it goes out of the HCP to the previous HCP.

Vector HCP::GetOutTangent  ) 
 

Returns a vector that contains the direction of the tangent of the spline going out of this control point.

Note:
HCP::GetInTangent() and HCP::GetOutTangent() may return differing magnitudes, but their direction is the same. For the purposes of computing normals, you must therefore flip the direction of either the In or Out tangents.

const Vector * HCP::GetPosition  ) 
 

Returns a pointer to a vector which stores the location of the control point. The position of the CP, includes muscle, and pose motion, but no skeletal

If this control point is attached to another, you may want to use GetHead() to make sure it is the head's position.

HCP * HCP::GetPrev  ) 
 

Returns the previous HCP in the spline. Returns NULL when it reaches the beginning of the spline even if the spline is looped.

HCP * HCP::GetPrevAttached  ) 
 

This function returns a pointer to the previous attached HCP on a stack of attached HCPs. It will return FALSE when it reaches the beginning. Use this function to walk backwards through attached HCPs.

This is to retrieve the multiple HCP that may be attached together where multiple HSplines meet. So this will in effect jump from Spline to SPline.

Vector HCP::GetScreenInTangent  ) 
 

Returns a vector that contains the direction of the tangent of the spline going into this control point. This is the tangent direction completely transformed in world style coordinated, but facing the camera.

Vector HCP::GetScreenOutTangent  ) 
 

Returns a vector that contains the direction of the tangent of the spline going out of this control point. This is the tangent direction completely transformed in world style coordinated, but facing the camera.

const Vector * HCP::GetScreenPosition  ) 
 

Returns a pointer to a vector which stores the location of the control point. This is the position of the CP completely transformed in world style coordinated, but facing the camera and relative to camera position.

HSegmentCache* HCP::GetSegmentCache  ) 
 

HSpline * HCP::GetSpline  ) 
 

Returns the spline of which the conrol point is a part.

Vector HCP::GetWorldInTangent  ) 
 

Returns a vector that contains the direction of the tangent of the spline going into this control point. This is the tangent direction completely transformed.

Vector HCP::GetWorldOutTangent  ) 
 

Returns a vector that contains the direction of the tangent of the spline going out of this control point. This is the tangent direction completely transformed.

const Vector * HCP::GetWorldPosition  ) 
 

Returns a pointer to a vector which stores the location of the control point. This is the position of the CP completely transformed.

BOOL HCP::IsEndHook  ) 
 

BOOL HCP::IsFlip  ) 
 

BOOL HCP::IsGroup  ) 
 

BOOL HCP::IsHide  ) 
 

BOOL HCP::IsHook  ) 
 

Returns TRUE if the HCP is a hook.

BOOL HCP::IsHookBase  ) 
 

Returns TRUE if the HCP is the start of a spline segment to which hooks are attached.

BOOL HCP::IsLocked  ) 
 

BOOL HCP::IsLoop  ) 
 

Returns the flag setting indicating whether this control point loops back to the first control point in the spline. If IsLoop() is TRUE, this HCP's GetNext() will return the first HCP in the spline. If you are walking a spline with GetNext(), check the IsLoop flag with this function to prevent an infinite loop.

BOOL HCP::IsPeaked  ) 
 

Returns TRUE if the spline passing through the HCP is set to be a hard peak with no curve.

BOOL HCP::IsSmooth  ) 
 

Returns TRUE if the spline passing through the HCP is set to be a smooth curve.

void HCP::RemoveCPWeight HCPWeight *  hcpweight  ) 
 

void HCP::SetHide BOOL  bHide  ) 
 

void HCP::SetInAlpha float  fValue  ) 
 

This function sets the alpha angle going into the HCP.

Parameters:
fValue - a float value from -180 to 180 degrees.

void HCP::SetInGamma float  fValue  ) 
 

This function sets the gamma angle going into the HCP.

Parameters:
fValue - a float value from -180 to 180 degrees.

void HCP::SetInMagnitude float  fValue  ) 
 

This function sets the curvature magnitude of the spline as it goes into the HCP.

Parameters:
fValue - a float value. 0.0 for a hard peak, and 1.0 for the default curve.

void HCP::SetOutAlpha float  fValue  ) 
 

This function sets the alpha angle going out of the HCP.

Parameters:
fValue - a float value from -180 to 180 degrees.

void HCP::SetOutGamma float  fValue  ) 
 

This function sets the gamma angle going out of the HCP.

Parameters:
fValue - a float value from -180 to 180 degrees.

void HCP::SetOutMagnitude float  fValue  ) 
 

This function sets the curvature magnitude of the spline as it goes out of the HCP.

Parameters:
fValue - a float value. 0.0 for a hard peak, and 1.0 for the default curve.

void HCP::SetPeaked  ) 
 

Sets the spline that passes through the HCP to have a hard peak with no curve.

void HCP::SetPosition Vector p  ) 
 

Use this function to set the location of the control point. If this is an attached control point, you may want to use GetHead() to make sure you are setting the head's position.

Parameters:
p - Pass a vector with the appropriate X, Y, and Z values.

void HCP::SetSmooth  ) 
 

Sets the spline that passes through the HCP to have a smooth curve.


The documentation for this class was generated from the following files:
This A:M SDK v12.0 documentation is maintained by Hash Inc. Please address any comments concerning this documentation to AMReports. If you have any information, knowledge, or documentation to share with the A:M developer community, please post them on the Hash SDK forum.

Generated on Thu Oct 27 11:46:55 2005 with doxygen 1.4.5 written by Dimitri van Heesch, © 1997-2001