Game Development Reference

In-Depth Information

q14 = a*d;

q22 = b*b;

q23 = b*c;

q24 = b*d;

q33 = c*c;

q34 = c*d;

q44 = d*d;

valid = TRUE;

v.x = 0.0; v.y = 0.0; v.z = 0.0;

deleted = FALSE;

return TRUE;

}

To return the quadric error metric of a pair, we take the sum of the vertex

quadrics and multiply by the contraction target and its transpose. This

utility function assumes that the sum of the vertex quadrics is stored in the

member variables. We pass the contraction target as a VECTOR

reference.

double CQuadric::QEM(VECTOR &v)

{

double vx, vy, vz;

vx = q11*v.x + q12*v.y + q13*v.z + q14;

vy = q12*v.x + q22*v.y + q23*v.z + q24;

vz = q13*v.x + q23*v.y + q33*v.z + q34;

return (vx*v.x + vy*v.y + vz*v.z + 1.0);

}

When creating an array of valid pairs we first assign every edge. This is

done by iterating through each polygon and adding each edge of a polygon

to the valid pairs array. If the pair is already present in the array then the

algorithm moves on without adding this pair. If the pair is not present then

the current pair is added to the valid pairs array. After adding the pair a

counter
qpTotal
is incremented. If this value exceeds the array size, which

is stored in the variable
qpMax
, then the array is doubled in size and the

original array copied to the new memory allocation. This dynamic allocation

of memory can provide a useful technique for array expansion. Valid pairs

include vertices whose distance apart is within a certain boundary. One of

the parameters used for the function
CreateValidPairsArray
is
distance
.

Search Nedrilad ::

Custom Search