== Constraints/Arithb Code ==
* Formatting 'fixes' for more consistency with rest of code * Moved Mat4BlendMat4 from constraint.c to arithb.c/h
This commit is contained in:
@@ -72,9 +72,6 @@
|
||||
#define M_PI 3.14159265358979323846
|
||||
#endif
|
||||
|
||||
/* used by object.c */
|
||||
void Mat4BlendMat4(float [][4], float [][4], float [][4], float );
|
||||
|
||||
/* Local function prototypes */
|
||||
|
||||
/* ********************* Data level ****************** */
|
||||
@@ -493,9 +490,9 @@ void unique_constraint_name (bConstraint *con, ListBase *list)
|
||||
}
|
||||
|
||||
/* See if we even need to do this */
|
||||
for (curcon = list->first; curcon; curcon=curcon->next){
|
||||
for (curcon = list->first; curcon; curcon=curcon->next) {
|
||||
if (curcon!=con){
|
||||
if (!strcmp(curcon->name, con->name)){
|
||||
if (!strcmp(curcon->name, con->name)) {
|
||||
exists = 1;
|
||||
break;
|
||||
}
|
||||
@@ -510,19 +507,19 @@ void unique_constraint_name (bConstraint *con, ListBase *list)
|
||||
if (dot)
|
||||
*dot=0;
|
||||
|
||||
for (number = 1; number <=999; number++){
|
||||
for (number = 1; number <=999; number++) {
|
||||
sprintf (tempname, "%s.%03d", con->name, number);
|
||||
|
||||
exists = 0;
|
||||
for (curcon=list->first; curcon; curcon=curcon->next){
|
||||
if (con!=curcon){
|
||||
if (!strcmp (curcon->name, tempname)){
|
||||
for (curcon=list->first; curcon; curcon=curcon->next) {
|
||||
if (con!=curcon) {
|
||||
if (!strcmp (curcon->name, tempname)) {
|
||||
exists = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!exists){
|
||||
if (!exists) {
|
||||
strcpy (con->name, tempname);
|
||||
return;
|
||||
}
|
||||
@@ -583,14 +580,6 @@ void *new_constraint_data (short type)
|
||||
result = data;
|
||||
}
|
||||
break;
|
||||
case CONSTRAINT_TYPE_ROTLIKE:
|
||||
{
|
||||
bRotateLikeConstraint *data;
|
||||
data = MEM_callocN(sizeof(bRotateLikeConstraint), "rotlikeConstraint");
|
||||
data->flag = ROTLIKE_X|ROTLIKE_Y|ROTLIKE_Z;
|
||||
result = data;
|
||||
}
|
||||
break;
|
||||
case CONSTRAINT_TYPE_LOCLIKE:
|
||||
{
|
||||
bLocateLikeConstraint *data;
|
||||
@@ -599,11 +588,19 @@ void *new_constraint_data (short type)
|
||||
result = data;
|
||||
}
|
||||
break;
|
||||
case CONSTRAINT_TYPE_ROTLIKE:
|
||||
{
|
||||
bRotateLikeConstraint *data;
|
||||
data = MEM_callocN(sizeof(bRotateLikeConstraint), "rotlikeConstraint");
|
||||
data->flag = ROTLIKE_X|ROTLIKE_Y|ROTLIKE_Z;
|
||||
result = data;
|
||||
}
|
||||
break;
|
||||
case CONSTRAINT_TYPE_SIZELIKE:
|
||||
{
|
||||
bSizeLikeConstraint *data;
|
||||
data = MEM_callocN(sizeof(bLocateLikeConstraint), "sizelikeConstraint");
|
||||
data->flag |= SIZELIKE_X|SIZELIKE_Y|SIZELIKE_Z;
|
||||
data->flag = SIZELIKE_X|SIZELIKE_Y|SIZELIKE_Z;
|
||||
result = data;
|
||||
}
|
||||
break;
|
||||
@@ -775,46 +772,6 @@ void do_constraint_channels (ListBase *conbase, ListBase *chanbase, float ctime)
|
||||
}
|
||||
}
|
||||
|
||||
void Mat4BlendMat4(float out[][4], float dst[][4], float src[][4], float srcweight)
|
||||
{
|
||||
float squat[4], dquat[4], fquat[4];
|
||||
float ssize[3], dsize[3], fsize[4];
|
||||
float sloc[3], dloc[3], floc[3];
|
||||
float mat3[3][3], dstweight;
|
||||
float qmat[3][3], smat[3][3];
|
||||
int i;
|
||||
|
||||
dstweight = 1.0F-srcweight;
|
||||
|
||||
Mat3CpyMat4(mat3, dst);
|
||||
Mat3ToQuat(mat3, dquat);
|
||||
Mat3ToSize(mat3, dsize);
|
||||
VECCOPY (dloc, dst[3]);
|
||||
|
||||
Mat3CpyMat4(mat3, src);
|
||||
Mat3ToQuat(mat3, squat);
|
||||
Mat3ToSize(mat3, ssize);
|
||||
VECCOPY (sloc, src[3]);
|
||||
|
||||
/* Do the actual blend */
|
||||
for (i=0; i<3; i++){
|
||||
floc[i] = (dloc[i]*dstweight) + (sloc[i]*srcweight);
|
||||
fsize[i] = 1.0f + ((dsize[i]-1.0f)*dstweight) + ((ssize[i]-1.0f)*srcweight);
|
||||
fquat[i+1] = (dquat[i+1]*dstweight) + (squat[i+1]*srcweight);
|
||||
}
|
||||
|
||||
/* Do one more iteration for the quaternions only and normalize the quaternion if needed */
|
||||
fquat[0] = 1.0f + ((dquat[0]-1.0f)*dstweight) + ((squat[0]-1.0f)*srcweight);
|
||||
NormalQuat (fquat);
|
||||
|
||||
QuatToMat3(fquat, qmat);
|
||||
SizeToMat3(fsize, smat);
|
||||
|
||||
Mat3MulMat3(mat3, qmat, smat);
|
||||
Mat4CpyMat3(out, mat3);
|
||||
VECCOPY (out[3], floc);
|
||||
}
|
||||
|
||||
static void constraint_target_to_mat4 (Object *ob, const char *substring, float mat[][4], float size[3])
|
||||
{
|
||||
|
||||
@@ -937,7 +894,7 @@ short get_constraint_target_matrix (bConstraint *con, short ownertype, void* own
|
||||
{
|
||||
short valid=0;
|
||||
|
||||
switch (con->type){
|
||||
switch (con->type) {
|
||||
case CONSTRAINT_TYPE_NULL:
|
||||
{
|
||||
Mat4One(mat);
|
||||
@@ -959,7 +916,7 @@ short get_constraint_target_matrix (bConstraint *con, short ownertype, void* own
|
||||
if (data->tar==NULL) return 0;
|
||||
|
||||
/* need proper check for bone... */
|
||||
if(data->subtarget[0]) {
|
||||
if (data->subtarget[0]) {
|
||||
pchan = get_pose_channel(data->tar->pose, data->subtarget);
|
||||
if (pchan) {
|
||||
float arm_mat[3][3], pose_mat[3][3]; /* arm mat should be bone mat! bug... */
|
||||
@@ -1002,9 +959,9 @@ short get_constraint_target_matrix (bConstraint *con, short ownertype, void* own
|
||||
}
|
||||
|
||||
Mat3ToEul(tempmat3, eul);
|
||||
eul[0]*=(float)(180.0/M_PI);
|
||||
eul[1]*=(float)(180.0/M_PI);
|
||||
eul[2]*=(float)(180.0/M_PI);
|
||||
eul[0] *= (float)(180.0/M_PI);
|
||||
eul[1] *= (float)(180.0/M_PI);
|
||||
eul[2] *= (float)(180.0/M_PI);
|
||||
|
||||
/* Target defines the animation */
|
||||
s = (eul[data->type]-data->min)/(data->max-data->min);
|
||||
@@ -1072,7 +1029,7 @@ short get_constraint_target_matrix (bConstraint *con, short ownertype, void* own
|
||||
{
|
||||
bMinMaxConstraint *data = (bMinMaxConstraint*)con->data;
|
||||
|
||||
if (data->tar){
|
||||
if (data->tar) {
|
||||
constraint_target_to_mat4(data->tar, data->subtarget, mat, size);
|
||||
valid=1;
|
||||
}
|
||||
@@ -1085,7 +1042,7 @@ short get_constraint_target_matrix (bConstraint *con, short ownertype, void* own
|
||||
bRotateLikeConstraint *data;
|
||||
data = (bRotateLikeConstraint*)con->data;
|
||||
|
||||
if (data->tar){
|
||||
if (data->tar) {
|
||||
constraint_target_to_mat4(data->tar, data->subtarget, mat, size);
|
||||
valid=1;
|
||||
}
|
||||
@@ -1098,7 +1055,7 @@ short get_constraint_target_matrix (bConstraint *con, short ownertype, void* own
|
||||
bSizeLikeConstraint *data;
|
||||
data = (bSizeLikeConstraint*)con->data;
|
||||
|
||||
if (data->tar){
|
||||
if (data->tar) {
|
||||
constraint_target_to_mat4(data->tar, data->subtarget, mat, size);
|
||||
valid=1;
|
||||
}
|
||||
@@ -1111,7 +1068,7 @@ short get_constraint_target_matrix (bConstraint *con, short ownertype, void* own
|
||||
bTrackToConstraint *data;
|
||||
data = (bTrackToConstraint*)con->data;
|
||||
|
||||
if (data->tar){
|
||||
if (data->tar) {
|
||||
constraint_target_to_mat4(data->tar, data->subtarget, mat, size);
|
||||
valid=1;
|
||||
}
|
||||
@@ -1124,14 +1081,14 @@ short get_constraint_target_matrix (bConstraint *con, short ownertype, void* own
|
||||
bKinematicConstraint *data;
|
||||
data = (bKinematicConstraint*)con->data;
|
||||
|
||||
if (data->tar){
|
||||
if (data->tar) {
|
||||
constraint_target_to_mat4(data->tar, data->subtarget, mat, size);
|
||||
valid=1;
|
||||
}
|
||||
else if (data->flag & CONSTRAINT_IK_AUTO) {
|
||||
Object *ob= ownerdata;
|
||||
|
||||
if(ob==NULL)
|
||||
if (ob==NULL)
|
||||
Mat4One(mat);
|
||||
else {
|
||||
float vec[3];
|
||||
@@ -1151,7 +1108,7 @@ short get_constraint_target_matrix (bConstraint *con, short ownertype, void* own
|
||||
bLockTrackConstraint *data;
|
||||
data = (bLockTrackConstraint*)con->data;
|
||||
|
||||
if (data->tar){
|
||||
if (data->tar) {
|
||||
constraint_target_to_mat4(data->tar, data->subtarget, mat, size);
|
||||
valid=1;
|
||||
}
|
||||
@@ -1164,7 +1121,7 @@ short get_constraint_target_matrix (bConstraint *con, short ownertype, void* own
|
||||
bFollowPathConstraint *data;
|
||||
data = (bFollowPathConstraint*)con->data;
|
||||
|
||||
if (data->tar){
|
||||
if (data->tar) {
|
||||
Curve *cu;
|
||||
float q[4], vec[4], dir[3], *quat, x1, totmat[4][4];
|
||||
float curvetime;
|
||||
@@ -1177,22 +1134,21 @@ short get_constraint_target_matrix (bConstraint *con, short ownertype, void* own
|
||||
/* note; when creating constraints that follow path, the curve gets the CU_PATH set now,
|
||||
currently for paths to work it needs to go through the bevlist/displist system (ton) */
|
||||
|
||||
if(cu->path==NULL || cu->path->data==NULL) /* only happens on reload file, but violates depsgraph still... fix! */
|
||||
if (cu->path==NULL || cu->path->data==NULL) /* only happens on reload file, but violates depsgraph still... fix! */
|
||||
makeDispListCurveTypes(data->tar, 0);
|
||||
if(cu->path && cu->path->data) {
|
||||
if (cu->path && cu->path->data) {
|
||||
|
||||
curvetime= bsystem_time(data->tar, data->tar->parent, (float)ctime, 0.0) - data->offset;
|
||||
|
||||
if(calc_ipo_spec(cu->ipo, CU_SPEED, &curvetime)==0) {
|
||||
if (calc_ipo_spec(cu->ipo, CU_SPEED, &curvetime)==0) {
|
||||
curvetime /= cu->pathlen;
|
||||
CLAMP(curvetime, 0.0, 1.0);
|
||||
}
|
||||
|
||||
if(where_on_path(data->tar, curvetime, vec, dir) ) {
|
||||
|
||||
if(data->followflag){
|
||||
|
||||
if (where_on_path(data->tar, curvetime, vec, dir) ) {
|
||||
if (data->followflag) {
|
||||
quat= vectoquat(dir, (short) data->trackflag, (short) data->upflag);
|
||||
|
||||
|
||||
Normalize(dir);
|
||||
q[0]= (float)cos(0.5*vec[3]);
|
||||
x1= (float)sin(0.5*vec[3]);
|
||||
@@ -1201,7 +1157,6 @@ short get_constraint_target_matrix (bConstraint *con, short ownertype, void* own
|
||||
q[3]= -x1*dir[2];
|
||||
QuatMul(quat, q, quat);
|
||||
|
||||
|
||||
QuatToMat4(quat, totmat);
|
||||
}
|
||||
VECCOPY(totmat[3], vec);
|
||||
@@ -1220,7 +1175,7 @@ short get_constraint_target_matrix (bConstraint *con, short ownertype, void* own
|
||||
bStretchToConstraint *data;
|
||||
data = (bStretchToConstraint*)con->data;
|
||||
|
||||
if (data->tar){
|
||||
if (data->tar) {
|
||||
constraint_target_to_mat4(data->tar, data->subtarget, mat, size);
|
||||
valid = 1;
|
||||
}
|
||||
@@ -1238,7 +1193,7 @@ short get_constraint_target_matrix (bConstraint *con, short ownertype, void* own
|
||||
Curve *cu= data->tar->data;
|
||||
|
||||
/* this check is to make sure curve objects get updated on file load correctly.*/
|
||||
if(cu->path==NULL || cu->path->data==NULL) /* only happens on reload file, but violates depsgraph still... fix! */
|
||||
if (cu->path==NULL || cu->path->data==NULL) /* only happens on reload file, but violates depsgraph still... fix! */
|
||||
makeDispListCurveTypes(data->tar, 0);
|
||||
}
|
||||
|
||||
@@ -1312,7 +1267,7 @@ void evaluate_constraint (bConstraint *constraint, Object *ob, short ownertype,
|
||||
|
||||
data = constraint->data;
|
||||
Mat4CpyMat4 (temp, ob->obmat);
|
||||
|
||||
|
||||
Mat4MulMat4(ob->obmat, targetmat, temp);
|
||||
}
|
||||
break;
|
||||
@@ -1375,11 +1330,11 @@ void evaluate_constraint (bConstraint *constraint, Object *ob, short ownertype,
|
||||
}
|
||||
|
||||
if((data->flag & ROTLIKE_X) && (data->flag & ROTLIKE_X_INVERT))
|
||||
eul[0]*=-1;
|
||||
eul[0]*= -1;
|
||||
if((data->flag & ROTLIKE_Y) && (data->flag & ROTLIKE_Y_INVERT))
|
||||
eul[1]*=-1;
|
||||
eul[1]*= -1;
|
||||
if((data->flag & ROTLIKE_Z) && (data->flag & ROTLIKE_Z_INVERT))
|
||||
eul[2]*=-1;
|
||||
eul[2]*= -1;
|
||||
|
||||
LocEulSizeToMat4(ob->obmat, loc, eul, size);
|
||||
}
|
||||
@@ -1414,8 +1369,8 @@ void evaluate_constraint (bConstraint *constraint, Object *ob, short ownertype,
|
||||
Mat4CpyMat4(obmat,ob->obmat);
|
||||
Mat4CpyMat4(tarmat,targetmat);
|
||||
|
||||
if (data->flag&MINMAX_USEROT) {
|
||||
/* take rotation of target into account by doing the transaction in target's localspace */
|
||||
if (data->flag & MINMAX_USEROT) {
|
||||
/* take rotation of target into account by doing the transaction in target's localspace */
|
||||
Mat4Invert(imat,tarmat);
|
||||
Mat4MulMat4(tmat,obmat,imat);
|
||||
Mat4CpyMat4(obmat,tmat);
|
||||
@@ -1465,7 +1420,7 @@ void evaluate_constraint (bConstraint *constraint, Object *ob, short ownertype,
|
||||
}
|
||||
else {
|
||||
VECCOPY(data->cache, obmat[3]);
|
||||
data->flag|=MINMAX_STUCK;
|
||||
data->flag |= MINMAX_STUCK;
|
||||
}
|
||||
}
|
||||
if (data->flag & MINMAX_USEROT) {
|
||||
@@ -1478,9 +1433,8 @@ void evaluate_constraint (bConstraint *constraint, Object *ob, short ownertype,
|
||||
}
|
||||
}
|
||||
else {
|
||||
data->flag&=~MINMAX_STUCK;
|
||||
data->flag &= ~MINMAX_STUCK;
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
case CONSTRAINT_TYPE_TRACKTO:
|
||||
@@ -1491,7 +1445,7 @@ void evaluate_constraint (bConstraint *constraint, Object *ob, short ownertype,
|
||||
float totmat[3][3];
|
||||
float tmat[4][4];
|
||||
|
||||
data=(bTrackToConstraint*)constraint->data;
|
||||
data = constraint->data;
|
||||
|
||||
if (data->tar) {
|
||||
/* Get size property, since ob->size is only the object's own relative size, not its global one */
|
||||
@@ -1499,7 +1453,7 @@ void evaluate_constraint (bConstraint *constraint, Object *ob, short ownertype,
|
||||
|
||||
Mat4CpyMat4 (M_oldmat, ob->obmat);
|
||||
|
||||
// Clear the object's rotation
|
||||
/* Clear the object's rotation */
|
||||
ob->obmat[0][0]=size[0];
|
||||
ob->obmat[0][1]=0;
|
||||
ob->obmat[0][2]=0;
|
||||
@@ -1509,8 +1463,7 @@ void evaluate_constraint (bConstraint *constraint, Object *ob, short ownertype,
|
||||
ob->obmat[2][0]=0;
|
||||
ob->obmat[2][1]=0;
|
||||
ob->obmat[2][2]=size[2];
|
||||
|
||||
|
||||
|
||||
VecSubf(vec, ob->obmat[3], targetmat[3]);
|
||||
vectomat(vec, targetmat[2],
|
||||
(short)data->reserved1, (short)data->reserved2,
|
||||
@@ -1532,274 +1485,274 @@ void evaluate_constraint (bConstraint *constraint, Object *ob, short ownertype,
|
||||
float tmat[4][4];
|
||||
float mdet;
|
||||
|
||||
data=(bLockTrackConstraint*)constraint->data;
|
||||
data = constraint->data;
|
||||
|
||||
if (data->tar) {
|
||||
Mat4CpyMat4 (M_oldmat, ob->obmat);
|
||||
|
||||
|
||||
/* Vector object -> target */
|
||||
VecSubf(vec, targetmat[3], ob->obmat[3]);
|
||||
switch (data->lockflag){
|
||||
case LOCK_X: /* LOCK X */
|
||||
{
|
||||
switch (data->trackflag){
|
||||
case TRACK_Y: /* LOCK X TRACK Y */
|
||||
{
|
||||
switch (data->trackflag) {
|
||||
case TRACK_Y: /* LOCK X TRACK Y */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
Projf(vec2, vec, ob->obmat[0]);
|
||||
VecSubf(totmat[1], vec, vec2);
|
||||
Normalize(totmat[1]);
|
||||
|
||||
/* the x axis is fixed*/
|
||||
totmat[0][0] = ob->obmat[0][0];
|
||||
totmat[0][1] = ob->obmat[0][1];
|
||||
totmat[0][2] = ob->obmat[0][2];
|
||||
Normalize(totmat[0]);
|
||||
|
||||
/* the z axis gets mapped onto
|
||||
a third orthogonal vector */
|
||||
Crossf(totmat[2], totmat[0], totmat[1]);
|
||||
/* Projection of Vector on the plane */
|
||||
Projf(vec2, vec, ob->obmat[0]);
|
||||
VecSubf(totmat[1], vec, vec2);
|
||||
Normalize(totmat[1]);
|
||||
|
||||
/* the x axis is fixed*/
|
||||
totmat[0][0] = ob->obmat[0][0];
|
||||
totmat[0][1] = ob->obmat[0][1];
|
||||
totmat[0][2] = ob->obmat[0][2];
|
||||
Normalize(totmat[0]);
|
||||
|
||||
/* the z axis gets mapped onto
|
||||
a third orthogonal vector */
|
||||
Crossf(totmat[2], totmat[0], totmat[1]);
|
||||
}
|
||||
break;
|
||||
case TRACK_Z: /* LOCK X TRACK Z */
|
||||
break;
|
||||
case TRACK_Z: /* LOCK X TRACK Z */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
Projf(vec2, vec, ob->obmat[0]);
|
||||
VecSubf(totmat[2], vec, vec2);
|
||||
Normalize(totmat[2]);
|
||||
/* Projection of Vector on the plane */
|
||||
Projf(vec2, vec, ob->obmat[0]);
|
||||
VecSubf(totmat[2], vec, vec2);
|
||||
Normalize(totmat[2]);
|
||||
|
||||
/* the x axis is fixed*/
|
||||
totmat[0][0] = ob->obmat[0][0];
|
||||
totmat[0][1] = ob->obmat[0][1];
|
||||
totmat[0][2] = ob->obmat[0][2];
|
||||
Normalize(totmat[0]);
|
||||
|
||||
/* the z axis gets mapped onto
|
||||
a third orthogonal vector */
|
||||
Crossf(totmat[1], totmat[2], totmat[0]);
|
||||
/* the x axis is fixed*/
|
||||
totmat[0][0] = ob->obmat[0][0];
|
||||
totmat[0][1] = ob->obmat[0][1];
|
||||
totmat[0][2] = ob->obmat[0][2];
|
||||
Normalize(totmat[0]);
|
||||
|
||||
/* the z axis gets mapped onto
|
||||
a third orthogonal vector */
|
||||
Crossf(totmat[1], totmat[2], totmat[0]);
|
||||
}
|
||||
break;
|
||||
case TRACK_nY: /* LOCK X TRACK -Y */
|
||||
break;
|
||||
case TRACK_nY: /* LOCK X TRACK -Y */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
Projf(vec2, vec, ob->obmat[0]);
|
||||
VecSubf(totmat[1], vec, vec2);
|
||||
Normalize(totmat[1]);
|
||||
VecMulf(totmat[1],-1);
|
||||
|
||||
/* the x axis is fixed*/
|
||||
totmat[0][0] = ob->obmat[0][0];
|
||||
totmat[0][1] = ob->obmat[0][1];
|
||||
totmat[0][2] = ob->obmat[0][2];
|
||||
Normalize(totmat[0]);
|
||||
|
||||
/* the z axis gets mapped onto
|
||||
a third orthogonal vector */
|
||||
Crossf(totmat[2], totmat[0], totmat[1]);
|
||||
/* Projection of Vector on the plane */
|
||||
Projf(vec2, vec, ob->obmat[0]);
|
||||
VecSubf(totmat[1], vec, vec2);
|
||||
Normalize(totmat[1]);
|
||||
VecMulf(totmat[1],-1);
|
||||
|
||||
/* the x axis is fixed*/
|
||||
totmat[0][0] = ob->obmat[0][0];
|
||||
totmat[0][1] = ob->obmat[0][1];
|
||||
totmat[0][2] = ob->obmat[0][2];
|
||||
Normalize(totmat[0]);
|
||||
|
||||
/* the z axis gets mapped onto
|
||||
a third orthogonal vector */
|
||||
Crossf(totmat[2], totmat[0], totmat[1]);
|
||||
}
|
||||
break;
|
||||
case TRACK_nZ: /* LOCK X TRACK -Z */
|
||||
break;
|
||||
case TRACK_nZ: /* LOCK X TRACK -Z */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
Projf(vec2, vec, ob->obmat[0]);
|
||||
VecSubf(totmat[2], vec, vec2);
|
||||
Normalize(totmat[2]);
|
||||
VecMulf(totmat[2],-1);
|
||||
|
||||
/* the x axis is fixed*/
|
||||
totmat[0][0] = ob->obmat[0][0];
|
||||
totmat[0][1] = ob->obmat[0][1];
|
||||
totmat[0][2] = ob->obmat[0][2];
|
||||
Normalize(totmat[0]);
|
||||
|
||||
/* the z axis gets mapped onto
|
||||
a third orthogonal vector */
|
||||
Crossf(totmat[1], totmat[2], totmat[0]);
|
||||
/* Projection of Vector on the plane */
|
||||
Projf(vec2, vec, ob->obmat[0]);
|
||||
VecSubf(totmat[2], vec, vec2);
|
||||
Normalize(totmat[2]);
|
||||
VecMulf(totmat[2],-1);
|
||||
|
||||
/* the x axis is fixed*/
|
||||
totmat[0][0] = ob->obmat[0][0];
|
||||
totmat[0][1] = ob->obmat[0][1];
|
||||
totmat[0][2] = ob->obmat[0][2];
|
||||
Normalize(totmat[0]);
|
||||
|
||||
/* the z axis gets mapped onto
|
||||
a third orthogonal vector */
|
||||
Crossf(totmat[1], totmat[2], totmat[0]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
{
|
||||
totmat[0][0] = 1;totmat[0][1] = 0;totmat[0][2] = 0;
|
||||
totmat[1][0] = 0;totmat[1][1] = 1;totmat[1][2] = 0;
|
||||
totmat[2][0] = 0;totmat[2][1] = 0;totmat[2][2] = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case LOCK_Y: /* LOCK Y */
|
||||
{
|
||||
switch (data->trackflag){
|
||||
case TRACK_X: /* LOCK Y TRACK X */
|
||||
{
|
||||
switch (data->trackflag) {
|
||||
case TRACK_X: /* LOCK Y TRACK X */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
Projf(vec2, vec, ob->obmat[1]);
|
||||
VecSubf(totmat[0], vec, vec2);
|
||||
Normalize(totmat[0]);
|
||||
|
||||
/* the y axis is fixed*/
|
||||
totmat[1][0] = ob->obmat[1][0];
|
||||
totmat[1][1] = ob->obmat[1][1];
|
||||
totmat[1][2] = ob->obmat[1][2];
|
||||
Normalize(totmat[1]);
|
||||
|
||||
/* the z axis gets mapped onto
|
||||
a third orthogonal vector */
|
||||
Crossf(totmat[2], totmat[0], totmat[1]);
|
||||
/* Projection of Vector on the plane */
|
||||
Projf(vec2, vec, ob->obmat[1]);
|
||||
VecSubf(totmat[0], vec, vec2);
|
||||
Normalize(totmat[0]);
|
||||
|
||||
/* the y axis is fixed*/
|
||||
totmat[1][0] = ob->obmat[1][0];
|
||||
totmat[1][1] = ob->obmat[1][1];
|
||||
totmat[1][2] = ob->obmat[1][2];
|
||||
Normalize(totmat[1]);
|
||||
|
||||
/* the z axis gets mapped onto
|
||||
a third orthogonal vector */
|
||||
Crossf(totmat[2], totmat[0], totmat[1]);
|
||||
}
|
||||
break;
|
||||
case TRACK_Z: /* LOCK Y TRACK Z */
|
||||
break;
|
||||
case TRACK_Z: /* LOCK Y TRACK Z */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
Projf(vec2, vec, ob->obmat[1]);
|
||||
VecSubf(totmat[2], vec, vec2);
|
||||
Normalize(totmat[2]);
|
||||
/* Projection of Vector on the plane */
|
||||
Projf(vec2, vec, ob->obmat[1]);
|
||||
VecSubf(totmat[2], vec, vec2);
|
||||
Normalize(totmat[2]);
|
||||
|
||||
/* the y axis is fixed*/
|
||||
totmat[1][0] = ob->obmat[1][0];
|
||||
totmat[1][1] = ob->obmat[1][1];
|
||||
totmat[1][2] = ob->obmat[1][2];
|
||||
Normalize(totmat[1]);
|
||||
|
||||
/* the z axis gets mapped onto
|
||||
a third orthogonal vector */
|
||||
Crossf(totmat[0], totmat[1], totmat[2]);
|
||||
/* the y axis is fixed*/
|
||||
totmat[1][0] = ob->obmat[1][0];
|
||||
totmat[1][1] = ob->obmat[1][1];
|
||||
totmat[1][2] = ob->obmat[1][2];
|
||||
Normalize(totmat[1]);
|
||||
|
||||
/* the z axis gets mapped onto
|
||||
a third orthogonal vector */
|
||||
Crossf(totmat[0], totmat[1], totmat[2]);
|
||||
}
|
||||
break;
|
||||
case TRACK_nX: /* LOCK Y TRACK -X */
|
||||
break;
|
||||
case TRACK_nX: /* LOCK Y TRACK -X */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
Projf(vec2, vec, ob->obmat[1]);
|
||||
VecSubf(totmat[0], vec, vec2);
|
||||
Normalize(totmat[0]);
|
||||
VecMulf(totmat[0],-1);
|
||||
/* Projection of Vector on the plane */
|
||||
Projf(vec2, vec, ob->obmat[1]);
|
||||
VecSubf(totmat[0], vec, vec2);
|
||||
Normalize(totmat[0]);
|
||||
VecMulf(totmat[0],-1);
|
||||
|
||||
/* the y axis is fixed*/
|
||||
totmat[1][0] = ob->obmat[1][0];
|
||||
totmat[1][1] = ob->obmat[1][1];
|
||||
totmat[1][2] = ob->obmat[1][2];
|
||||
Normalize(totmat[1]);
|
||||
|
||||
/* the z axis gets mapped onto
|
||||
a third orthogonal vector */
|
||||
Crossf(totmat[2], totmat[0], totmat[1]);
|
||||
/* the y axis is fixed*/
|
||||
totmat[1][0] = ob->obmat[1][0];
|
||||
totmat[1][1] = ob->obmat[1][1];
|
||||
totmat[1][2] = ob->obmat[1][2];
|
||||
Normalize(totmat[1]);
|
||||
|
||||
/* the z axis gets mapped onto
|
||||
a third orthogonal vector */
|
||||
Crossf(totmat[2], totmat[0], totmat[1]);
|
||||
}
|
||||
break;
|
||||
case TRACK_nZ: /* LOCK Y TRACK -Z */
|
||||
break;
|
||||
case TRACK_nZ: /* LOCK Y TRACK -Z */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
Projf(vec2, vec, ob->obmat[1]);
|
||||
VecSubf(totmat[2], vec, vec2);
|
||||
Normalize(totmat[2]);
|
||||
VecMulf(totmat[2],-1);
|
||||
/* Projection of Vector on the plane */
|
||||
Projf(vec2, vec, ob->obmat[1]);
|
||||
VecSubf(totmat[2], vec, vec2);
|
||||
Normalize(totmat[2]);
|
||||
VecMulf(totmat[2],-1);
|
||||
|
||||
/* the y axis is fixed*/
|
||||
totmat[1][0] = ob->obmat[1][0];
|
||||
totmat[1][1] = ob->obmat[1][1];
|
||||
totmat[1][2] = ob->obmat[1][2];
|
||||
Normalize(totmat[1]);
|
||||
|
||||
/* the z axis gets mapped onto
|
||||
a third orthogonal vector */
|
||||
Crossf(totmat[0], totmat[1], totmat[2]);
|
||||
/* the y axis is fixed*/
|
||||
totmat[1][0] = ob->obmat[1][0];
|
||||
totmat[1][1] = ob->obmat[1][1];
|
||||
totmat[1][2] = ob->obmat[1][2];
|
||||
Normalize(totmat[1]);
|
||||
|
||||
/* the z axis gets mapped onto
|
||||
a third orthogonal vector */
|
||||
Crossf(totmat[0], totmat[1], totmat[2]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
{
|
||||
totmat[0][0] = 1;totmat[0][1] = 0;totmat[0][2] = 0;
|
||||
totmat[1][0] = 0;totmat[1][1] = 1;totmat[1][2] = 0;
|
||||
totmat[2][0] = 0;totmat[2][1] = 0;totmat[2][2] = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case LOCK_Z: /* LOCK Z */
|
||||
{
|
||||
switch (data->trackflag){
|
||||
case TRACK_X: /* LOCK Z TRACK X */
|
||||
{
|
||||
switch (data->trackflag) {
|
||||
case TRACK_X: /* LOCK Z TRACK X */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
Projf(vec2, vec, ob->obmat[2]);
|
||||
VecSubf(totmat[0], vec, vec2);
|
||||
Normalize(totmat[0]);
|
||||
|
||||
/* the z axis is fixed*/
|
||||
totmat[2][0] = ob->obmat[2][0];
|
||||
totmat[2][1] = ob->obmat[2][1];
|
||||
totmat[2][2] = ob->obmat[2][2];
|
||||
Normalize(totmat[2]);
|
||||
|
||||
/* the x axis gets mapped onto
|
||||
a third orthogonal vector */
|
||||
Crossf(totmat[1], totmat[2], totmat[0]);
|
||||
/* Projection of Vector on the plane */
|
||||
Projf(vec2, vec, ob->obmat[2]);
|
||||
VecSubf(totmat[0], vec, vec2);
|
||||
Normalize(totmat[0]);
|
||||
|
||||
/* the z axis is fixed*/
|
||||
totmat[2][0] = ob->obmat[2][0];
|
||||
totmat[2][1] = ob->obmat[2][1];
|
||||
totmat[2][2] = ob->obmat[2][2];
|
||||
Normalize(totmat[2]);
|
||||
|
||||
/* the x axis gets mapped onto
|
||||
a third orthogonal vector */
|
||||
Crossf(totmat[1], totmat[2], totmat[0]);
|
||||
}
|
||||
break;
|
||||
case TRACK_Y: /* LOCK Z TRACK Y */
|
||||
break;
|
||||
case TRACK_Y: /* LOCK Z TRACK Y */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
Projf(vec2, vec, ob->obmat[2]);
|
||||
VecSubf(totmat[1], vec, vec2);
|
||||
Normalize(totmat[1]);
|
||||
|
||||
/* the z axis is fixed*/
|
||||
totmat[2][0] = ob->obmat[2][0];
|
||||
totmat[2][1] = ob->obmat[2][1];
|
||||
totmat[2][2] = ob->obmat[2][2];
|
||||
Normalize(totmat[2]);
|
||||
|
||||
/* the x axis gets mapped onto
|
||||
a third orthogonal vector */
|
||||
Crossf(totmat[0], totmat[1], totmat[2]);
|
||||
/* Projection of Vector on the plane */
|
||||
Projf(vec2, vec, ob->obmat[2]);
|
||||
VecSubf(totmat[1], vec, vec2);
|
||||
Normalize(totmat[1]);
|
||||
|
||||
/* the z axis is fixed*/
|
||||
totmat[2][0] = ob->obmat[2][0];
|
||||
totmat[2][1] = ob->obmat[2][1];
|
||||
totmat[2][2] = ob->obmat[2][2];
|
||||
Normalize(totmat[2]);
|
||||
|
||||
/* the x axis gets mapped onto
|
||||
a third orthogonal vector */
|
||||
Crossf(totmat[0], totmat[1], totmat[2]);
|
||||
}
|
||||
break;
|
||||
case TRACK_nX: /* LOCK Z TRACK -X */
|
||||
break;
|
||||
case TRACK_nX: /* LOCK Z TRACK -X */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
Projf(vec2, vec, ob->obmat[2]);
|
||||
VecSubf(totmat[0], vec, vec2);
|
||||
Normalize(totmat[0]);
|
||||
VecMulf(totmat[0],-1);
|
||||
|
||||
/* the z axis is fixed*/
|
||||
totmat[2][0] = ob->obmat[2][0];
|
||||
totmat[2][1] = ob->obmat[2][1];
|
||||
totmat[2][2] = ob->obmat[2][2];
|
||||
Normalize(totmat[2]);
|
||||
|
||||
/* the x axis gets mapped onto
|
||||
a third orthogonal vector */
|
||||
Crossf(totmat[1], totmat[2], totmat[0]);
|
||||
/* Projection of Vector on the plane */
|
||||
Projf(vec2, vec, ob->obmat[2]);
|
||||
VecSubf(totmat[0], vec, vec2);
|
||||
Normalize(totmat[0]);
|
||||
VecMulf(totmat[0],-1);
|
||||
|
||||
/* the z axis is fixed*/
|
||||
totmat[2][0] = ob->obmat[2][0];
|
||||
totmat[2][1] = ob->obmat[2][1];
|
||||
totmat[2][2] = ob->obmat[2][2];
|
||||
Normalize(totmat[2]);
|
||||
|
||||
/* the x axis gets mapped onto
|
||||
a third orthogonal vector */
|
||||
Crossf(totmat[1], totmat[2], totmat[0]);
|
||||
}
|
||||
break;
|
||||
case TRACK_nY: /* LOCK Z TRACK -Y */
|
||||
break;
|
||||
case TRACK_nY: /* LOCK Z TRACK -Y */
|
||||
{
|
||||
/* Projection of Vector on the plane */
|
||||
Projf(vec2, vec, ob->obmat[2]);
|
||||
VecSubf(totmat[1], vec, vec2);
|
||||
Normalize(totmat[1]);
|
||||
VecMulf(totmat[1],-1);
|
||||
|
||||
/* the z axis is fixed*/
|
||||
totmat[2][0] = ob->obmat[2][0];
|
||||
totmat[2][1] = ob->obmat[2][1];
|
||||
totmat[2][2] = ob->obmat[2][2];
|
||||
Normalize(totmat[2]);
|
||||
|
||||
/* the x axis gets mapped onto
|
||||
a third orthogonal vector */
|
||||
Crossf(totmat[0], totmat[1], totmat[2]);
|
||||
/* Projection of Vector on the plane */
|
||||
Projf(vec2, vec, ob->obmat[2]);
|
||||
VecSubf(totmat[1], vec, vec2);
|
||||
Normalize(totmat[1]);
|
||||
VecMulf(totmat[1],-1);
|
||||
|
||||
/* the z axis is fixed*/
|
||||
totmat[2][0] = ob->obmat[2][0];
|
||||
totmat[2][1] = ob->obmat[2][1];
|
||||
totmat[2][2] = ob->obmat[2][2];
|
||||
Normalize(totmat[2]);
|
||||
|
||||
/* the x axis gets mapped onto
|
||||
a third orthogonal vector */
|
||||
Crossf(totmat[0], totmat[1], totmat[2]);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
{
|
||||
totmat[0][0] = 1;totmat[0][1] = 0;totmat[0][2] = 0;
|
||||
totmat[1][0] = 0;totmat[1][1] = 1;totmat[1][2] = 0;
|
||||
totmat[2][0] = 0;totmat[2][1] = 0;totmat[2][2] = 1;
|
||||
totmat[0][0] = 1;totmat[0][1] = 0;totmat[0][2] = 0;
|
||||
totmat[1][0] = 0;totmat[1][1] = 1;totmat[1][2] = 0;
|
||||
totmat[2][0] = 0;totmat[2][1] = 0;totmat[2][2] = 1;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
@@ -1845,7 +1798,7 @@ void evaluate_constraint (bConstraint *constraint, Object *ob, short ownertype,
|
||||
float obmat[4][4];
|
||||
float size[3], obsize[3];
|
||||
|
||||
data=(bFollowPathConstraint*)constraint->data;
|
||||
data = constraint->data;
|
||||
|
||||
if (data->tar) {
|
||||
/* get Object local transform (loc/rot/size) to determine transformation from path */
|
||||
@@ -1876,7 +1829,7 @@ void evaluate_constraint (bConstraint *constraint, Object *ob, short ownertype,
|
||||
float tmat[4][4];
|
||||
float dist;
|
||||
|
||||
data=(bStretchToConstraint*)constraint->data;
|
||||
data = constraint->data;
|
||||
Mat4ToSize (ob->obmat, size);
|
||||
|
||||
if (data->tar) {
|
||||
@@ -1885,13 +1838,13 @@ void evaluate_constraint (bConstraint *constraint, Object *ob, short ownertype,
|
||||
xx[1] = ob->obmat[0][1];
|
||||
xx[2] = ob->obmat[0][2];
|
||||
Normalize(xx);
|
||||
|
||||
|
||||
/* store Z orientation before destroying obmat */
|
||||
zz[0] = ob->obmat[2][0];
|
||||
zz[1] = ob->obmat[2][1];
|
||||
zz[2] = ob->obmat[2][2];
|
||||
Normalize(zz);
|
||||
|
||||
|
||||
VecSubf(vec, ob->obmat[3], targetmat[3]);
|
||||
vec[0] /= size[0];
|
||||
vec[1] /= size[1];
|
||||
|
||||
@@ -1734,7 +1734,6 @@ for a lamp that is the child of another object */
|
||||
ob->ipo= ipo;
|
||||
|
||||
}
|
||||
extern void Mat4BlendMat4(float out[][4], float dst[][4], float src[][4], float srcweight);
|
||||
|
||||
void solve_constraints (Object *ob, short obtype, void *obdata, float ctime)
|
||||
{
|
||||
|
||||
@@ -64,577 +64,203 @@ extern "C" {
|
||||
{ 0.0, 0.0, 1.0}}
|
||||
|
||||
|
||||
/* matrix operations */
|
||||
/* void Mat4MulMat4(float m1[][4], float m2[][4], float m3[][4]); */
|
||||
/* void Mat3MulVecfl(float mat[][3], float *vec); */
|
||||
/* or **mat, but it's the same */
|
||||
/*void Mat3MulVecd(float mat[][3], double *vec); */
|
||||
void CalcCent3f(float *cent, float *v1, float *v2, float *v3);
|
||||
void CalcCent4f(float *cent, float *v1, float *v2, float *v3, float *v4);
|
||||
|
||||
/* void Mat4MulVecfl(float mat[][4], float *vec); */
|
||||
/* void Mat4MulSerie(float answ[][4], float m1[][4], float m2[][4], */
|
||||
/* float m3[][4], float m4[][4], float m5[][4], */
|
||||
/* float m6[][4], float m7[][4], float m8[][4]); */
|
||||
/* int Mat4Invert(float inverse[][4], float mat[][4]); */
|
||||
void Crossf(float *c, float *a, float *b);
|
||||
void Projf(float *c, float *v1, float *v2);
|
||||
|
||||
/* m2 to m1 */
|
||||
/* void Mat3CpyMat4(float m1p[][3], float m2p[][4]); */
|
||||
/* void Mat3CpyMat4(float *m1p, float *m2p); */
|
||||
float Inpf(float *v1, float *v2);
|
||||
float Inp2f(float *v1, float *v2);
|
||||
|
||||
/* m1 to m2 */
|
||||
/* void Mat3CpyMat3(float m1p[][3], float m2p[][3]); */
|
||||
/* void Mat3CpyMat3(float *m1p, float *m2p); */
|
||||
float Normalize(float *n);
|
||||
float Normalize2(float *n);
|
||||
|
||||
/* m2 to m1 */
|
||||
/* void Mat4CpyMat3(float m1p[][4], float m2p[][3]); */
|
||||
float Sqrt3f(float f);
|
||||
double Sqrt3d(double d);
|
||||
|
||||
/* M1 = M3*M2 */
|
||||
/* void Mat3MulMat3(float m1[][3], float m2[][3], float m3[][3]); */
|
||||
/*void Mat3MulMat3(float *m1, float *m3, float *m2); */
|
||||
float saacos(float fac);
|
||||
float saasin(float fac);
|
||||
float sasqrt(float fac);
|
||||
|
||||
/* m1 = m2 * m3, ignore the elements on the 4th row/column of m3 */
|
||||
/*void Mat3IsMat3MulMat4(float m1[][3], float m2[][3], float m3[][4]); */
|
||||
int FloatCompare(float *v1, float *v2, float limit);
|
||||
float FloatLerpf(float target, float origin, float fac);
|
||||
|
||||
/* m1 to m2 */
|
||||
/* void Mat4CpyMat4(float m1[][4], float m2[][4]); */
|
||||
/* void Mat4CpyMat4(float *m1, float *m2); */
|
||||
float CalcNormFloat(float *v1, float *v2, float *v3, float *n);
|
||||
float CalcNormFloat4(float *v1, float *v2, float *v3, float *v4, float *n);
|
||||
|
||||
void CalcNormLong(int *v1, int *v2, int *v3, float *n);
|
||||
/* CalcNormShort: is ook uitprodukt - (translates as 'is also out/cross product') */
|
||||
void CalcNormShort(short *v1, short *v2, short *v3, float *n);
|
||||
|
||||
/* void Mat4Ortho(float mat[][4]); */
|
||||
/* void Mat4Mul3Vecfl(float mat[][4], float *vec); */
|
||||
/* void Mat4MulVec4fl(float mat[][4], float *vec); */
|
||||
/* void Mat4SwapMat4(float *m1, float *m2); */
|
||||
|
||||
/* void Mat3Inv(float m1[][3], float m2[][3]); */
|
||||
/* void Mat4One(float m[][4]); */
|
||||
/* void Mat3One(float m[][3]); */
|
||||
|
||||
|
||||
void
|
||||
CalcCent3f(
|
||||
float *cent, float *v1, float *v2, float *v3
|
||||
);
|
||||
|
||||
void
|
||||
CalcCent4f(
|
||||
float *cent, float *v1,
|
||||
float *v2, float *v3,
|
||||
float *v4
|
||||
);
|
||||
|
||||
void
|
||||
Crossf(
|
||||
float *c, float *a, float *b
|
||||
);
|
||||
|
||||
void
|
||||
Projf(
|
||||
float *c, float *v1, float *v2
|
||||
);
|
||||
|
||||
/**
|
||||
* Euler conversion routines
|
||||
* @section Euler conversion routines
|
||||
*/
|
||||
|
||||
void
|
||||
EulToMat3(
|
||||
float *eul,
|
||||
float mat[][3]
|
||||
);
|
||||
void
|
||||
EulToMat4(
|
||||
float* eul,
|
||||
float mat[][4]
|
||||
);
|
||||
void EulToMat3(float *eul, float mat[][3]);
|
||||
void EulToMat4(float *eul, float mat[][4]);
|
||||
|
||||
void
|
||||
Mat3ToEul(
|
||||
float tmat[][3],
|
||||
float *eul
|
||||
);
|
||||
void Mat3ToEul(float tmat[][3], float *eul);
|
||||
void Mat4ToEul(float tmat[][4],float *eul);
|
||||
|
||||
void
|
||||
Mat4ToEul(
|
||||
float tmat[][4],
|
||||
float *eul
|
||||
);
|
||||
void EulToQuat(float *eul, float *quat);
|
||||
|
||||
void compatible_eul(float *eul, float *oldrot);
|
||||
|
||||
void Mat3ToCompatibleEul(float mat[][3], float *eul, float *oldrot);
|
||||
|
||||
|
||||
/**
|
||||
* @section Quaternion arithmetic routines
|
||||
*/
|
||||
|
||||
void
|
||||
QuatToEul(
|
||||
float *quat,
|
||||
float *eul
|
||||
);
|
||||
void
|
||||
QuatOne(
|
||||
float *
|
||||
);
|
||||
void
|
||||
QuatMul(
|
||||
float *,
|
||||
float *,
|
||||
float *
|
||||
);
|
||||
void
|
||||
QuatMulVecf(
|
||||
float *q,
|
||||
float *v
|
||||
);
|
||||
void
|
||||
NormalQuat(
|
||||
float *
|
||||
);
|
||||
void
|
||||
VecRotToQuat(
|
||||
float *vec,
|
||||
float phi,
|
||||
float *quat
|
||||
);
|
||||
void
|
||||
QuatSub(
|
||||
float *q,
|
||||
float *q1,
|
||||
float *q2
|
||||
);
|
||||
void
|
||||
QuatConj(
|
||||
float *q
|
||||
);
|
||||
void
|
||||
QuatInv(
|
||||
float *q
|
||||
);
|
||||
void
|
||||
QuatMulf(
|
||||
float *q,
|
||||
float f
|
||||
);
|
||||
float
|
||||
QuatDot(
|
||||
float *q1,
|
||||
float *q2
|
||||
);
|
||||
void
|
||||
printquat(
|
||||
char *str,
|
||||
float q[4]
|
||||
);
|
||||
void QuatToEul(float *quat, float *eul);
|
||||
void QuatOne(float *);
|
||||
void QuatMul(float *, float *, float *);
|
||||
void QuatMulVecf(float *q, float *v);
|
||||
|
||||
void NormalQuat(float *);
|
||||
void VecRotToQuat(float *vec, float phi, float *quat);
|
||||
|
||||
void QuatSub(float *q, float *q1, float *q2);
|
||||
void QuatConj(float *q);
|
||||
void QuatInv(float *q);
|
||||
void QuatMulf(float *q, float f);
|
||||
float QuatDot(float *q1, float *q2);
|
||||
|
||||
void printquat(char *str, float q[4]);
|
||||
|
||||
void QuatInterpol(float *result, float *quat1, float *quat2, float t);
|
||||
void QuatAdd(float *result, float *quat1, float *quat2, float t);
|
||||
|
||||
|
||||
/**
|
||||
* @section matrix multiplication can copying routines
|
||||
* @section matrix multiplication and copying routines
|
||||
*/
|
||||
|
||||
void
|
||||
Mat3MulFloat(
|
||||
float *m,
|
||||
float f
|
||||
);
|
||||
void
|
||||
Mat4MulFloat(
|
||||
float *m,
|
||||
float f
|
||||
);
|
||||
void
|
||||
Mat4MulFloat3(
|
||||
float *m,
|
||||
float f
|
||||
);
|
||||
void
|
||||
Mat3Transp(
|
||||
float mat[][3]
|
||||
);
|
||||
void
|
||||
Mat4Transp(
|
||||
float mat[][4]
|
||||
);
|
||||
int
|
||||
Mat4Invert(
|
||||
float inverse[][4],
|
||||
float mat[][4]
|
||||
);
|
||||
void
|
||||
Mat4InvertSimp(
|
||||
float inverse[][4],
|
||||
float mat[][4]
|
||||
);
|
||||
void
|
||||
Mat4Inv(
|
||||
float *m1,
|
||||
float *m2
|
||||
);
|
||||
void
|
||||
Mat4InvGG(
|
||||
float out[][4],
|
||||
float in[][4]
|
||||
);
|
||||
void
|
||||
Mat3CpyMat4(
|
||||
float m1[][3],
|
||||
float m2[][4]
|
||||
);
|
||||
void Mat3MulFloat(float *m, float f);
|
||||
void Mat4MulFloat(float *m, float f);
|
||||
void Mat4MulFloat3(float *m, float f);
|
||||
|
||||
void
|
||||
Mat3Inv(
|
||||
float m1[][3],
|
||||
float m2[][3]
|
||||
);
|
||||
void Mat3Transp(float mat[][3]);
|
||||
void Mat4Transp(float mat[][4]);
|
||||
|
||||
void
|
||||
Mat4CpyMat3(
|
||||
float m1[][4],
|
||||
float m2[][3]
|
||||
);
|
||||
int Mat4Invert(float inverse[][4], float mat[][4]);
|
||||
void Mat4InvertSimp(float inverse[][4], float mat[][4]);
|
||||
void Mat4Inv(float *m1, float *m2);
|
||||
void Mat4InvGG(float out[][4], float in[][4]);
|
||||
void Mat3Inv(float m1[][3], float m2[][3]);
|
||||
|
||||
float
|
||||
Det2x2(
|
||||
float a,float b,float c,float d
|
||||
);
|
||||
void Mat3CpyMat4(float m1[][3],float m2[][4]);
|
||||
void Mat4CpyMat3(float m1[][4], float m2[][3]);
|
||||
|
||||
float
|
||||
Det3x3(
|
||||
void Mat4BlendMat4(float out[][4], float dst[][4], float src[][4], float srcweight);
|
||||
|
||||
float Det2x2(float a,float b,float c, float d);
|
||||
|
||||
float Det3x3(
|
||||
float a1, float a2, float a3,
|
||||
float b1, float b2, float b3,
|
||||
float c1, float c2, float c3
|
||||
);
|
||||
|
||||
float
|
||||
Det4x4(
|
||||
float m[][4]
|
||||
);
|
||||
float Det4x4(float m[][4]);
|
||||
|
||||
void
|
||||
Mat4Adj(
|
||||
float out[][4],
|
||||
float in[][4]
|
||||
);
|
||||
void
|
||||
Mat3Adj(
|
||||
float m1[][3],
|
||||
float m[][3]
|
||||
);
|
||||
void
|
||||
Mat4MulMat4(
|
||||
float m1[][4],
|
||||
float m2[][4],
|
||||
float m3[][4]
|
||||
);
|
||||
void
|
||||
subMat4MulMat4(
|
||||
float *m1,
|
||||
float *m2,
|
||||
float *m3
|
||||
);
|
||||
void Mat3Adj(float m1[][3], float m[][3]);
|
||||
void Mat4Adj(float out[][4], float in[][4]);
|
||||
|
||||
void Mat4MulMat4(float m1[][4], float m2[][4], float m3[][4]);
|
||||
void subMat4MulMat4(float *m1, float *m2, float *m3);
|
||||
#ifndef TEST_ACTIVE
|
||||
void
|
||||
Mat3MulMat3(
|
||||
float m1[][3],
|
||||
float m3[][3],
|
||||
float m2[][3]
|
||||
);
|
||||
void Mat3MulMat3(float m1[][3], float m3[][3], float m2[][3]);
|
||||
#else
|
||||
void
|
||||
Mat3MulMat3(
|
||||
float *m1,
|
||||
float *m3,
|
||||
float *m2
|
||||
);
|
||||
void Mat3MulMat3(float *m1, float *m3, float *m2);
|
||||
#endif
|
||||
void
|
||||
Mat4MulMat34(
|
||||
float (*m1)[4],
|
||||
float (*m3)[3],
|
||||
float (*m2)[4]
|
||||
);
|
||||
void
|
||||
Mat4CpyMat4(
|
||||
float m1[][4],
|
||||
float m2[][4]
|
||||
);
|
||||
void
|
||||
Mat4SwapMat4(
|
||||
float *m1,
|
||||
float *m2
|
||||
);
|
||||
void
|
||||
Mat3CpyMat3(
|
||||
float m1[][3],
|
||||
float m2[][3]
|
||||
);
|
||||
void
|
||||
Mat3MulSerie(
|
||||
float answ[][3],
|
||||
void Mat4MulMat34(float (*m1)[4], float (*m3)[3], float (*m2)[4]);
|
||||
void Mat4CpyMat4(float m1[][4], float m2[][4]);
|
||||
void Mat4SwapMat4(float *m1, float *m2);
|
||||
void Mat3CpyMat3(float m1[][3], float m2[][3]);
|
||||
|
||||
void Mat3MulSerie(float answ[][3],
|
||||
float m1[][3], float m2[][3], float m3[][3],
|
||||
float m4[][3], float m5[][3], float m6[][3],
|
||||
float m7[][3], float m8[][3]
|
||||
);
|
||||
void
|
||||
Mat4MulSerie(
|
||||
float answ[][4],
|
||||
float m1[][4],
|
||||
|
||||
void Mat4MulSerie(float answ[][4], float m1[][4],
|
||||
float m2[][4], float m3[][4], float m4[][4],
|
||||
float m5[][4], float m6[][4], float m7[][4],
|
||||
float m8[][4]
|
||||
);
|
||||
void
|
||||
Mat4Clr(
|
||||
float *m
|
||||
);
|
||||
void
|
||||
Mat3Clr(
|
||||
float *m
|
||||
);
|
||||
void
|
||||
Mat3One(
|
||||
float m[][3]
|
||||
);
|
||||
void
|
||||
Mat4MulVec3Project(
|
||||
float mat[][4],
|
||||
float *vec
|
||||
);
|
||||
void
|
||||
Mat4MulVec(
|
||||
float mat[][4],
|
||||
int *vec
|
||||
);
|
||||
void
|
||||
VecMat4MulVecfl(
|
||||
float *in,
|
||||
float mat[][4],
|
||||
float *vec
|
||||
);
|
||||
void
|
||||
Mat4MulMat43(
|
||||
float (*m1)[4],
|
||||
float (*m3)[4],
|
||||
float (*m2)[3]
|
||||
);
|
||||
|
||||
void Mat4Clr(float *m);
|
||||
void Mat3Clr(float *m);
|
||||
|
||||
void Mat3One(float m[][3]);
|
||||
void Mat4One(float m[][4]);
|
||||
|
||||
void
|
||||
Mat3IsMat3MulMat4(
|
||||
float m1[][3],
|
||||
float m2[][3],
|
||||
float m3[][4]
|
||||
);
|
||||
void
|
||||
Mat4One(
|
||||
float m[][4]
|
||||
);
|
||||
void
|
||||
Mat4Mul3Vecfl(
|
||||
float mat[][4],
|
||||
float *vec
|
||||
);
|
||||
void
|
||||
Mat4MulVec4fl(
|
||||
float mat[][4],
|
||||
float *vec
|
||||
);
|
||||
void
|
||||
Mat3MulVec(
|
||||
float mat[][3],
|
||||
int *vec
|
||||
);
|
||||
void
|
||||
Mat4MulVecfl(
|
||||
float mat[][4],
|
||||
float *vec
|
||||
);
|
||||
void
|
||||
Mat4ToQuat(
|
||||
float m[][4],
|
||||
float *q
|
||||
);
|
||||
void
|
||||
VecUpMat3old(
|
||||
float *vec,
|
||||
float mat[][3],
|
||||
short axis
|
||||
);
|
||||
int
|
||||
FloatCompare(
|
||||
float *v1,
|
||||
float *v2,
|
||||
float limit
|
||||
);
|
||||
float
|
||||
FloatLerpf(
|
||||
float target,
|
||||
float origin,
|
||||
float fac
|
||||
);
|
||||
float
|
||||
Normalize(
|
||||
float *n
|
||||
);
|
||||
float
|
||||
CalcNormFloat(
|
||||
float *v1,
|
||||
float *v2,
|
||||
float *v3,
|
||||
float *n
|
||||
);
|
||||
void Mat3Ortho(float mat[][3]);
|
||||
void Mat4Ortho(float mat[][4]);
|
||||
|
||||
float
|
||||
CalcNormFloat4(
|
||||
float *v1,
|
||||
float *v2,
|
||||
float *v3,
|
||||
float *v4,
|
||||
float *n
|
||||
);
|
||||
float
|
||||
VecLenf(
|
||||
float *v1,
|
||||
float *v2
|
||||
);
|
||||
float
|
||||
VecLength(
|
||||
float *v
|
||||
);
|
||||
void
|
||||
VecMulf(
|
||||
float *v1,
|
||||
float f
|
||||
);
|
||||
int
|
||||
VecLenCompare(
|
||||
float *v1,
|
||||
float *v2,
|
||||
float limit
|
||||
);
|
||||
int
|
||||
VecCompare(
|
||||
float *v1,
|
||||
float *v2,
|
||||
float limit
|
||||
);
|
||||
int
|
||||
VecEqual(
|
||||
float *v1,
|
||||
float *v2
|
||||
);
|
||||
float
|
||||
Sqrt3f(
|
||||
float f
|
||||
);
|
||||
double
|
||||
Sqrt3d(
|
||||
double d
|
||||
);
|
||||
void VecMat4MulVecfl(float *in, float mat[][4], float *vec);
|
||||
void Mat4MulMat43(float (*m1)[4], float (*m3)[4], float (*m2)[3]);
|
||||
void Mat3IsMat3MulMat4(float m1[][3], float m2[][3], float m3[][4]);
|
||||
|
||||
void
|
||||
euler_rot(
|
||||
float *beul,
|
||||
float ang,
|
||||
char axis
|
||||
);
|
||||
float
|
||||
saacos(
|
||||
float fac
|
||||
);
|
||||
float
|
||||
saasin(
|
||||
float fac
|
||||
);
|
||||
float
|
||||
sasqrt(
|
||||
float fac
|
||||
);
|
||||
void
|
||||
printvecf(
|
||||
char *str,
|
||||
float v[3]
|
||||
);
|
||||
void
|
||||
printvec4f(
|
||||
char *str,
|
||||
float v[4]
|
||||
);
|
||||
float
|
||||
Inpf(
|
||||
float *v1,
|
||||
float *v2
|
||||
);
|
||||
void
|
||||
VecSubf(
|
||||
float *v,
|
||||
float *v1,
|
||||
float *v2
|
||||
);
|
||||
void
|
||||
VecAddf(
|
||||
float *v,
|
||||
float *v1,
|
||||
float *v2
|
||||
);
|
||||
void
|
||||
VecLerpf(
|
||||
float *target,
|
||||
float *a,
|
||||
float *b,
|
||||
float t
|
||||
);
|
||||
void
|
||||
VecUpMat3(
|
||||
float *vec,
|
||||
float mat[][3],
|
||||
short axis
|
||||
);
|
||||
float
|
||||
DistVL2Dfl(
|
||||
float *v1,
|
||||
float *v2,
|
||||
float *v3
|
||||
);
|
||||
float
|
||||
PdistVL2Dfl(
|
||||
float *v1,
|
||||
float *v2,
|
||||
float *v3
|
||||
);
|
||||
float
|
||||
AreaF2Dfl(
|
||||
float *v1,
|
||||
float *v2,
|
||||
float *v3
|
||||
);
|
||||
float
|
||||
AreaQ3Dfl(
|
||||
float *v1,
|
||||
float *v2,
|
||||
float *v3,
|
||||
float *v4
|
||||
);
|
||||
float
|
||||
AreaT3Dfl(
|
||||
float *v1,
|
||||
float *v2,
|
||||
float *v3
|
||||
);
|
||||
float
|
||||
AreaPoly3Dfl(
|
||||
int nr,
|
||||
float *verts,
|
||||
float *normal
|
||||
);
|
||||
void
|
||||
VecRotToMat3(
|
||||
float *vec,
|
||||
float phi,
|
||||
float mat[][3]
|
||||
);
|
||||
void Mat4MulVec(float mat[][4],int *vec);
|
||||
void Mat4MulVecfl(float mat[][4], float *vec);
|
||||
void Mat4Mul3Vecfl(float mat[][4], float *vec);
|
||||
void Mat4MulVec3Project(float mat[][4],float *vec);
|
||||
void Mat4MulVec4fl(float mat[][4], float *vec);
|
||||
void Mat3MulVec(float mat[][3],int *vec);
|
||||
void Mat3MulVecfl(float mat[][3], float *vec);
|
||||
void Mat3MulVecd(float mat[][3], double *vec);
|
||||
void Mat3TransMulVecfl(float mat[][3], float *vec);
|
||||
|
||||
|
||||
void VecUpMat3old(float *vec, float mat[][3], short axis);
|
||||
void VecUpMat3(float *vec, float mat[][3], short axis);
|
||||
void VecRotToMat3(float *vec, float phi, float mat[][3]);
|
||||
|
||||
void VecCopyf(float *v1, float *v2);
|
||||
int VecLen(int *v1, int *v2);
|
||||
float VecLenf(float *v1, float *v2);
|
||||
float VecLength(float *v);
|
||||
void VecMulf(float *v1, float f);
|
||||
|
||||
int VecLenCompare(float *v1, float *v2, float limit);
|
||||
int VecCompare(float *v1, float *v2, float limit);
|
||||
int VecEqual(float *v1, float *v2);
|
||||
|
||||
void printvecf(char *str,float v[3]);
|
||||
void printvec4f(char *str, float v[4]);
|
||||
|
||||
void VecAddf(float *v, float *v1, float *v2);
|
||||
void VecSubf(float *v, float *v1, float *v2);
|
||||
void VecLerpf(float *target, float *a, float *b, float t);
|
||||
void VecMidf(float *v, float *v1, float *v2);
|
||||
|
||||
float Vec2Lenf(float *v1, float *v2);
|
||||
void Vec2Mulf(float *v1, float f);
|
||||
void Vec2Addf(float *v, float *v1, float *v2);
|
||||
void Vec2Subf(float *v, float *v1, float *v2);
|
||||
void Vec2Copyf(float *v1, float *v2);
|
||||
|
||||
float *vectoquat(float *vec, short axis, short upflag);
|
||||
|
||||
float VecAngle2(float *v1, float *v2);
|
||||
float VecAngle3(float *v1, float *v2, float *v3);
|
||||
float NormalizedVecAngle2(float *v1, float *v2);
|
||||
|
||||
void euler_rot(float *beul, float ang, char axis);
|
||||
|
||||
|
||||
float DistVL2Dfl(float *v1, float *v2, float *v3);
|
||||
float PdistVL2Dfl(float *v1, float *v2, float *v3);
|
||||
float AreaF2Dfl(float *v1, float *v2, float *v3);
|
||||
float AreaQ3Dfl(float *v1, float *v2, float *v3, float *v4);
|
||||
float AreaT3Dfl(float *v1, float *v2, float *v3);
|
||||
float AreaPoly3Dfl(int nr, float *verts, float *normal);
|
||||
|
||||
/* intersect Line-Line
|
||||
return:
|
||||
@@ -647,313 +273,80 @@ extern short IsectLL2Df(float *v1, float *v2, float *v3, float *v4);
|
||||
extern short IsectLL2Ds(short *v1, short *v2, short *v3, short *v4);
|
||||
|
||||
/* interpolation weights of point in a triangle or quad, v4 may be NULL */
|
||||
void
|
||||
InterpWeightsQ3Dfl(
|
||||
float *v1, float *v2, float *v3, float *v4,
|
||||
float *co,
|
||||
float *w
|
||||
);
|
||||
void InterpWeightsQ3Dfl(float *v1, float *v2, float *v3, float *v4, float *co, float *w);
|
||||
|
||||
float *
|
||||
vectoquat(
|
||||
float *vec,
|
||||
short axis,
|
||||
short upflag
|
||||
);
|
||||
|
||||
float
|
||||
VecAngle3(
|
||||
float *v1,
|
||||
float *v2,
|
||||
float *v3
|
||||
);
|
||||
|
||||
float
|
||||
VecAngle2(
|
||||
float *v1,
|
||||
float *v2
|
||||
);
|
||||
float
|
||||
NormalizedVecAngle2(
|
||||
float *v1,
|
||||
float *v2
|
||||
);
|
||||
|
||||
void
|
||||
i_lookat(
|
||||
void i_lookat(
|
||||
float vx, float vy,
|
||||
float vz, float px,
|
||||
float py, float pz,
|
||||
float twist, float mat[][4]
|
||||
);
|
||||
void
|
||||
i_window(
|
||||
|
||||
void i_window(
|
||||
float left, float right,
|
||||
float bottom, float top,
|
||||
float nearClip, float farClip,
|
||||
float mat[][4]
|
||||
);
|
||||
|
||||
void
|
||||
hsv_to_rgb(
|
||||
float h, float s,
|
||||
float v, float *r,
|
||||
float *g, float *b
|
||||
);
|
||||
void hsv_to_rgb(float h, float s, float v, float *r, float *g, float *b);
|
||||
void hex_to_rgb(char *hexcol, float *r, float *g, float *b);
|
||||
void rgb_to_yuv(float r, float g, float b, float *ly, float *lu, float *lv);
|
||||
void yuv_to_rgb(float y, float u, float v, float *lr, float *lg, float *lb);
|
||||
void ycc_to_rgb(float y, float cb, float cr, float *lr, float *lg, float *lb);
|
||||
void rgb_to_ycc(float r, float g, float b, float *ly, float *lcb, float *lcr);
|
||||
void rgb_to_hsv(float r, float g, float b, float *lh, float *ls, float *lv);
|
||||
unsigned int hsv_to_cpack(float h, float s, float v);
|
||||
unsigned int rgb_to_cpack(float r, float g, float b);
|
||||
void cpack_to_rgb(unsigned int col, float *r, float *g, float *b);
|
||||
void MinMaxRGB(short c[]);
|
||||
|
||||
void
|
||||
hex_to_rgb(
|
||||
char *hexcol,
|
||||
float *r,
|
||||
float *g,
|
||||
float *b
|
||||
);
|
||||
|
||||
void
|
||||
rgb_to_yuv(
|
||||
float r, float g, float b,
|
||||
float *ly, float *lu, float *lv
|
||||
);
|
||||
|
||||
void
|
||||
yuv_to_rgb(
|
||||
float y, float u, float v,
|
||||
float *lr, float *lg, float *lb
|
||||
);
|
||||
void VecStar(float mat[][3],float *vec);
|
||||
|
||||
void
|
||||
ycc_to_rgb(
|
||||
float y, float cb, float cr,
|
||||
float *lr, float *lg, float *lb
|
||||
);
|
||||
short EenheidsMat(float mat[][3]);
|
||||
|
||||
void
|
||||
rgb_to_ycc(
|
||||
float r, float g, float b,
|
||||
float *ly, float *lcb, float *lcr
|
||||
);
|
||||
void
|
||||
rgb_to_hsv(
|
||||
float r, float g, float b,
|
||||
float *lh, float *ls, float *lv
|
||||
);
|
||||
unsigned int
|
||||
hsv_to_cpack(
|
||||
float h, float s, float v
|
||||
);
|
||||
unsigned int
|
||||
rgb_to_cpack(
|
||||
float r, float g, float b
|
||||
);
|
||||
void
|
||||
cpack_to_rgb(
|
||||
unsigned int col,
|
||||
float *r, float *g, float *b
|
||||
);
|
||||
void QuatToMat3(float *q, float m[][3]);
|
||||
void QuatToMat4(float *q, float m[][4]);
|
||||
|
||||
void
|
||||
EulToQuat(
|
||||
float *eul,
|
||||
float *quat
|
||||
);
|
||||
void Mat3ToQuat_is_ok(float wmat[][3], float *q);
|
||||
|
||||
void
|
||||
Mat3MulVecfl(
|
||||
float mat[][3],
|
||||
float *vec
|
||||
);
|
||||
void
|
||||
Mat3MulVecd(
|
||||
float mat[][3],
|
||||
double *vec
|
||||
);
|
||||
void
|
||||
Mat3TransMulVecfl(
|
||||
float mat[][3],
|
||||
float *vec
|
||||
);
|
||||
void
|
||||
VecStar(
|
||||
float mat[][3],
|
||||
float *vec
|
||||
);
|
||||
short
|
||||
EenheidsMat(
|
||||
float mat[][3]
|
||||
);
|
||||
void
|
||||
printmatrix3(
|
||||
char *str, float m[][3]
|
||||
);
|
||||
void
|
||||
QuatToMat3(
|
||||
float *q,
|
||||
float m[][3]
|
||||
);
|
||||
void
|
||||
QuatToMat4(
|
||||
float *q,
|
||||
float m[][4]
|
||||
);
|
||||
void
|
||||
Mat3ToQuat_is_ok(
|
||||
float wmat[][3],
|
||||
float *q
|
||||
);
|
||||
void
|
||||
i_ortho(
|
||||
float left, float right,
|
||||
float bottom, float top,
|
||||
float nearClip, float farClip,
|
||||
float matrix[][4]
|
||||
);
|
||||
void
|
||||
i_polarview(
|
||||
float dist, float azimuth, float incidence, float twist,
|
||||
float Vm[][4]
|
||||
);
|
||||
void
|
||||
Mat3Ortho(
|
||||
float mat[][3]
|
||||
);
|
||||
void
|
||||
Mat4Ortho(
|
||||
float mat[][4]
|
||||
);
|
||||
void
|
||||
VecCopyf(
|
||||
float *v1,
|
||||
float *v2
|
||||
);
|
||||
int
|
||||
VecLen(
|
||||
int *v1,
|
||||
int *v2
|
||||
);
|
||||
void
|
||||
CalcNormShort(
|
||||
short *v1,
|
||||
short *v2,
|
||||
short *v3,
|
||||
float *n
|
||||
) /* is ook uitprodukt */;
|
||||
void i_ortho(float left, float right, float bottom, float top, float nearClip, float farClip, float matrix[][4]);
|
||||
void i_polarview(float dist, float azimuth, float incidence, float twist, float Vm[][4]);
|
||||
void i_translate(float Tx, float Ty, float Tz, float mat[][4]);
|
||||
void i_multmatrix(float icand[][4], float Vm[][4]);
|
||||
void i_rotate(float angle, char axis, float mat[][4]);
|
||||
|
||||
void
|
||||
CalcNormLong(
|
||||
int* v1,
|
||||
int*v2,
|
||||
int*v3,
|
||||
float *n
|
||||
);
|
||||
void
|
||||
MinMax3(
|
||||
float *min,
|
||||
float *max,
|
||||
float *vec
|
||||
);
|
||||
|
||||
void
|
||||
SizeToMat3(
|
||||
float *size,
|
||||
float mat[][3]
|
||||
);
|
||||
void
|
||||
printmatrix4(
|
||||
char *str,
|
||||
float m[][4]
|
||||
);
|
||||
|
||||
|
||||
|
||||
void MinMax3(float *min, float *max, float *vec);
|
||||
void SizeToMat3(float *size, float mat[][3]);
|
||||
|
||||
void printmatrix3(char *str, float m[][3]);
|
||||
void printmatrix4(char *str, float m[][4]);
|
||||
|
||||
/* uit Sig.Proc.85 pag 253 */
|
||||
void
|
||||
Mat3ToQuat(
|
||||
float wmat[][3],
|
||||
float *q
|
||||
);
|
||||
void
|
||||
i_translate(
|
||||
float Tx,
|
||||
float Ty,
|
||||
float Tz,
|
||||
float mat[][4]
|
||||
);
|
||||
void
|
||||
i_multmatrix(
|
||||
float icand[][4],
|
||||
float Vm[][4]
|
||||
);
|
||||
void
|
||||
i_rotate(
|
||||
float angle,
|
||||
char axis,
|
||||
float mat[][4]
|
||||
);
|
||||
void
|
||||
VecMidf(
|
||||
float *v, float *v1, float *v2
|
||||
);
|
||||
void
|
||||
Mat3ToSize(
|
||||
float mat[][3], float *size
|
||||
);
|
||||
void
|
||||
Mat4ToSize(
|
||||
float mat[][4], float *size
|
||||
);
|
||||
void
|
||||
triatoquat(
|
||||
float *v1,
|
||||
float *v2,
|
||||
float *v3, float *quat
|
||||
);
|
||||
void
|
||||
MinMaxRGB(
|
||||
short c[]
|
||||
);
|
||||
float
|
||||
Vec2Lenf(
|
||||
float *v1,
|
||||
float *v2
|
||||
);
|
||||
void
|
||||
Vec2Mulf(
|
||||
float *v1,
|
||||
float f
|
||||
);
|
||||
void
|
||||
Vec2Addf(
|
||||
float *v,
|
||||
float *v1,
|
||||
float *v2
|
||||
);
|
||||
void
|
||||
Vec2Subf(
|
||||
float *v,
|
||||
float *v1,
|
||||
float *v2
|
||||
);
|
||||
void
|
||||
Vec2Copyf(
|
||||
float *v1,
|
||||
float *v2
|
||||
);
|
||||
float
|
||||
Inp2f(
|
||||
float *v1,
|
||||
float *v2
|
||||
);
|
||||
float
|
||||
Normalize2(
|
||||
float *n
|
||||
);
|
||||
void Mat3ToQuat(float wmat[][3], float *q);
|
||||
void Mat4ToQuat(float m[][4], float *q);
|
||||
|
||||
void Mat3ToSize(float mat[][3], float *size);
|
||||
void Mat4ToSize(float mat[][4], float *size);
|
||||
|
||||
void triatoquat(float *v1, float *v2, float *v3, float *quat);
|
||||
|
||||
void LocEulSizeToMat4(float mat[][4], float loc[3], float eul[3], float size[3]);
|
||||
void LocQuatSizeToMat4(float mat[][4], float loc[3], float quat[4], float size[3]);
|
||||
|
||||
void tubemap(float x, float y, float z, float *u, float *v);
|
||||
void spheremap(float x, float y, float z, float *u, float *v);
|
||||
|
||||
|
||||
int LineIntersectsTriangle(float p1[3], float p2[3], float v0[3], float v1[3], float v2[3], float *lambda);
|
||||
int point_in_tri_prism(float p[3], float v1[3], float v2[3], float v3[3]);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -760,7 +760,45 @@ void Mat4MulSerie(float answ[][4], float m1[][4],
|
||||
}
|
||||
}
|
||||
|
||||
void Mat4BlendMat4(float out[][4], float dst[][4], float src[][4], float srcweight)
|
||||
{
|
||||
float squat[4], dquat[4], fquat[4];
|
||||
float ssize[3], dsize[3], fsize[4];
|
||||
float sloc[3], dloc[3], floc[3];
|
||||
float mat3[3][3], dstweight;
|
||||
float qmat[3][3], smat[3][3];
|
||||
int i;
|
||||
|
||||
dstweight = 1.0F-srcweight;
|
||||
|
||||
Mat3CpyMat4(mat3, dst);
|
||||
Mat3ToQuat(mat3, dquat);
|
||||
Mat3ToSize(mat3, dsize);
|
||||
VecCopyf(dloc, dst[3]);
|
||||
|
||||
Mat3CpyMat4(mat3, src);
|
||||
Mat3ToQuat(mat3, squat);
|
||||
Mat3ToSize(mat3, ssize);
|
||||
VecCopyf(sloc, src[3]);
|
||||
|
||||
/* Do the actual blend */
|
||||
for (i=0; i<3; i++){
|
||||
floc[i] = (dloc[i]*dstweight) + (sloc[i]*srcweight);
|
||||
fsize[i] = 1.0f + ((dsize[i]-1.0f)*dstweight) + ((ssize[i]-1.0f)*srcweight);
|
||||
fquat[i+1] = (dquat[i+1]*dstweight) + (squat[i+1]*srcweight);
|
||||
}
|
||||
|
||||
/* Do one more iteration for the quaternions only and normalize the quaternion if needed */
|
||||
fquat[0] = 1.0f + ((dquat[0]-1.0f)*dstweight) + ((squat[0]-1.0f)*srcweight);
|
||||
NormalQuat (fquat);
|
||||
|
||||
QuatToMat3(fquat, qmat);
|
||||
SizeToMat3(fsize, smat);
|
||||
|
||||
Mat3MulMat3(mat3, qmat, smat);
|
||||
Mat4CpyMat3(out, mat3);
|
||||
VecCopyf(out[3], floc);
|
||||
}
|
||||
|
||||
void Mat4Clr(float *m)
|
||||
{
|
||||
@@ -1767,7 +1805,6 @@ void Mat4Ortho(float mat[][4])
|
||||
|
||||
void VecCopyf(float *v1, float *v2)
|
||||
{
|
||||
|
||||
v1[0]= v2[0];
|
||||
v1[1]= v2[1];
|
||||
v1[2]= v2[2];
|
||||
|
||||
Reference in New Issue
Block a user