Esempio n. 1
0
std::vector<float> vCross(std::vector<float> a, std::vector<float> b) {
	std::vector<float> retVec(3);
	retVec[0] = a.at(1)*b.at(2)-a.at(2)*b.at(1);
	retVec[1] = a.at(2)*b.at(0)-a.at(0)*b.at(2);
	retVec[2] = a.at(0)*b.at(1)-a.at(1)*b.at(0);
	return retVec;
}
Esempio n. 2
0
std::vector<float> vSub(std::vector<float> a, std::vector<float> b) {
	std::vector<float> retVec(3);
	retVec[0] = a.at(0)-b.at(0);
	retVec[1] = a.at(1)-b.at(1);
	retVec[2] = a.at(2)-b.at(2);
	return retVec;
}
Esempio n. 3
0
std::vector<float> vScale(float scalar, std::vector<float> a) {
	std::vector<float> retVec(3);
	retVec[0] = a.at(0)*scalar;
	retVec[1] = a.at(1)*scalar;
	retVec[2] = a.at(2)*scalar;
	return retVec;
}
Esempio n. 4
0
std::vector<float> vAdd(std::vector<float> a, std::vector<float> b) {
	std::vector<float> retVec(3);
	retVec[0] = a.at(0)+b.at(0);
	retVec[1] = a.at(1)+b.at(1);
	retVec[2] = a.at(2)+b.at(2);
	return retVec;
}
Esempio n. 5
0
std::vector<float> normalize(std::vector<float> a) {
	std::vector<float> retVec(3);
	float mag = magnitude(a);
	retVec[0] = a.at(0)/mag;
	retVec[1] = a.at(1)/mag;
	retVec[2] = a.at(2)/mag;
	return retVec;
}
Esempio n. 6
0
vecDouble RevKBCCTrainer::ConcatVec( vecDouble first, vecDouble second )
{
    vecDouble retVec(first.size() + second.size());
    int newSize = first.size() + second.size();
    int i = 0;
    BOOST_FOREACH(double val, first) {
        retVec[i] = val;
        i++;
    }
Esempio n. 7
0
void plAvatarMgr::PointToDniCoordinate(hsPoint3 pt, plDniCoordinateInfo* ret)
{
    int count = fMaintainersMarkers.Count();
    //  plDniCoordinateInfo ret = new plDniCoordinateInfo;
    if (count > 0)
    {   

        // find the closest maintainers marker
        int nearestIndex = 0;
        if (count > 1)
        {
            for (int i = 0; i < fMaintainersMarkers.Count(); i++)
            {
                if (fMaintainersMarkers[i]->GetTarget(0))
                {
                    hsVector3 testDist(fMaintainersMarkers[i]->GetTarget(0)->GetCoordinateInterface()->GetLocalToWorld().GetTranslate() - pt);
                    hsVector3 baseDist(fMaintainersMarkers[nearestIndex]->GetTarget(0)->GetCoordinateInterface()->GetLocalToWorld().GetTranslate() - pt);  
                    if (testDist.MagnitudeSquared() < baseDist.MagnitudeSquared())
                        nearestIndex = i;
                }
            }
        }
        // convert the marker position to Dni coordinates
        int status = fMaintainersMarkers[nearestIndex]->GetCalibrated();

        switch (status)
        {
        case  plMaintainersMarkerModifier::kBroken:
            {
                plRandom rnd;
                rnd.SetSeed((int)(hsTimer::GetSeconds()));
                rnd.RandRangeI(1,999);
                ret->SetHSpans( rnd.RandRangeI(1,999) );
                ret->SetVSpans( rnd.RandRangeI(1,999) );
                ret->SetTorans( rnd.RandRangeI(1,62500) );
            }
            break;
        case plMaintainersMarkerModifier::kRepaired:
            {
                ret->SetHSpans(0);
                ret->SetVSpans(0);
                ret->SetTorans(0);
            }
            break;
        case plMaintainersMarkerModifier::kCalibrated:
            {
                // this is the real deal here:
                // vertical spans:
                hsPoint3 retPoint = fMaintainersMarkers[nearestIndex]->GetTarget(0)->GetCoordinateInterface()->GetLocalToWorld().GetTranslate();
                ret->SetVSpans( ((int)(pt.fZ - retPoint.fZ) / 16) );

                // horizontal spans:

                // zero out the z axis...
                retPoint.fZ = pt.fZ = 0.0f;
                hsVector3 hSpanVec(retPoint - pt);
                ret->SetHSpans( (int)hSpanVec.Magnitude() / 16) ;

                // torans
                hsVector3 zeroVec = fMaintainersMarkers[nearestIndex]->GetTarget(0)->GetCoordinateInterface()->GetLocalToWorld().GetAxis(hsMatrix44::kView);
                hsVector3 zeroRight = fMaintainersMarkers[nearestIndex]->GetTarget(0)->GetCoordinateInterface()->GetLocalToWorld().GetAxis(hsMatrix44::kRight);
                zeroVec *= -1; // match the zero vectors to the positive X & Y axes in 3DSMax
                zeroRight *= -1;
                hsVector3 retVec(pt - retPoint);
                retVec.Normalize();

                float dotView = retVec * zeroVec;
                float dotRight = retVec * zeroRight;

                float deg = acosf(dotView);
                deg*=(180/3.141592);
                // account for being > 180
                if (dotRight < 0.0f) 
                {
                    deg = 360.f - deg;
                }
                // convert it to dni radians (torans)
                deg*=173.61;
                ret->SetTorans((int)deg);
            }
            break;
        }

    }
}