Exemple #1
0
int main()
{
	int ch; // choice of the user
	while(1)
	{
		// input of choice
		printf("1.Insert at front\n");
		printf("2.Insert at end\n");
		printf("3.Insert at any position\n");
		printf("4.Delete from front\n");
		printf("5.Delete from rear.\n");
		printf("6.Delete at any position\n");
		printf("7.Display\n");
		printf("8.End\n");
		intd(ch);
		// calling other functions as per the choice
		if(ch==1)
		{
			insFr();
		}
		if(ch==2)
		{
			insEnd();
		}
		if(ch==3)
		{
			insPos();
		}
		if(ch==4)
		{
			delFr();
		}
		if(ch==5)
		{
			delEnd();
		}
		if(ch==6)
		{
			delPos();
		}
		if(ch==7)
		{
			display();
		}
		if(ch==8)
		{
			break;
		}
	}
	return 0;
}
Exemple #2
0
// MorphDelta - ComputeDeltas
void plMorphDelta::ComputeDeltas(const hsTArray<plGeometrySpan*>& base, const hsTArray<plGeometrySpan*>& moved, const hsMatrix44& d2b, const hsMatrix44& d2bTInv)
{
    SetNumSpans(base.GetCount());

    hsPoint3 delUVWs[8];

    // For each span
    int iSpan;
    for( iSpan = 0; iSpan < base.GetCount(); iSpan++ )
    {
        plAccessSpan baseAcc;
        plAccessGeometry::Instance()->AccessSpanFromGeometrySpan(baseAcc, base[iSpan]);
        plAccessSpan movedAcc;
        plAccessGeometry::Instance()->AccessSpanFromGeometrySpan(movedAcc, moved[iSpan]);

        plAccPosNormUVWIterator baseIter(&baseAcc.AccessVtx());
        plAccPosNormUVWIterator movedIter(&movedAcc.AccessVtx());


        plMorphSpan& dst = fSpans[iSpan];

        const uint16_t numUVWs = baseAcc.AccessVtx().NumUVWs();

        hsTArray<plVertDelta> deltas;
        hsTArray<hsPoint3> uvws;
        deltas.SetCount(0);
        uvws.SetCount(0);


        int iVert = 0;;
        for( baseIter.Begin(), movedIter.Begin(); baseIter.More(); baseIter.Advance(), movedIter.Advance() )
        {
            // NOTE: we want to discard zero deltas, but a
            // delta in any channel forces us to save the whole thing.
            // But we don't want to compare to zero (because we'll end
            // up with a lot of near zero deltas), but the epsilon we
            // compare to needs to be different for comparing something
            // like a normal delta and a position delta.
            //
            // For position, normal, color and all uvws
            // Calc del and delLenSq
            // If any delLenSq big enough, set nonZero to true
            bool nonZero = false;

            // These are actually min del SQUARED.
            plConst(float) kMinDelPos(1.e-4f); // From Budtpueller's Handbook of Constants
            plConst(float) kMinDelNorm(3.e-2f); // About 10 degrees
            plConst(float) kMinDelUVW(1.e-4f); // From BHC
            hsPoint3 mPos = d2b * *movedIter.Position();
            hsVector3 delPos( &mPos, baseIter.Position());
            float delPosSq = delPos.MagnitudeSquared();
            if( delPosSq > kMinDelPos )
                nonZero = true;
            else
                delPos.Set(0,0,0);


            hsVector3 delNorm = (d2bTInv * *movedIter.Normal()) - *baseIter.Normal();
            float delNormSq = delNorm.MagnitudeSquared();
            if( delNormSq > kMinDelNorm )
                nonZero = true;
            else
                delNorm.Set(0,0,0);

            int i;
            for( i = 0; i < numUVWs; i++ )
            {
                delUVWs[i] = *movedIter.UVW(i) - *baseIter.UVW(i);
                float delUVWSq = delUVWs[i].MagnitudeSquared();
                if( delUVWSq > kMinDelUVW )
                    nonZero = true;
                else
                    delUVWs[i].Set(0,0,0);
            }

            if( nonZero )
            {
                // Append to deltas (i, del's)
                plVertDelta del;
                del.fIdx = iVert;
                del.fPos = delPos;
                del.fNorm = delNorm;
                deltas.Append(del);

                for( i = 0; i < numUVWs; i++ )
                    uvws.Append(delUVWs[i]);
            }
            else
            {
                nonZero = false; // Breakpoint.
            }

            iVert++;
        }
        SetDeltas(iSpan, deltas, numUVWs, uvws.AcquireArray());
    }
}