BOOL SplineData::HitTestCrossSection(GraphicsWindow *gw, HitRegion hr,  SplineMapProjectionTypes projType, Tab<int> &hitSplines, Tab<int> &hitCrossSections)
{
	hitSplines.SetCount(0);
	hitCrossSections.SetCount(0);
	DWORD limit = gw->getRndLimits();
	gw->setRndLimits(( limit | GW_PICK) & ~GW_ILLUM);
	gw->setHitRegion(&hr);
	//loop through splines

	for (int splineIndex = 0; splineIndex < mSplineElementData.Count();splineIndex++)
	{

		if (mSplineElementData[splineIndex]->IsSelected())
		{			
			for (int crossSectionIndex = 0; crossSectionIndex <  NumberOfCrossSections(splineIndex); crossSectionIndex++)
			{
				SplineCrossSection section = mSplineElementData[splineIndex]->GetCrossSection(crossSectionIndex);
				Matrix3 crossSectionTM = section.mTM;
				gw->setTransform(crossSectionTM);

				gw->clearHitCode();
				mSplineElementData[splineIndex]->DisplayCrossSections(gw, crossSectionIndex,projType );
				if (gw->checkHitCode())
				{
					hitSplines.Append(1,&splineIndex,10);
					hitCrossSections.Append(1,&crossSectionIndex,10);
				}

			}
		}

	}

	return hitSplines.Count();
}
void Unreal3DExport::WriteTracking()
{
    Tab<Point3> Loc;
    Tab<Quat> Quat;
    Tab<Point3> Euler;

    Loc.SetCount(FrameCount);
    Quat.SetCount(FrameCount);
    Euler.SetCount(FrameCount);

    for( int n=0; n<TrackedNodes.Count(); ++n )
    {
        IGameNode* node = TrackedNodes[n];

        for( int t=0; t<FrameCount; ++t )
        {            
            // Progress
            CheckCancel();
            
            // Set frame
            int curframe = FrameStart + t;
            pScene->SetStaticFrame(curframe);

            // Write tracking
            GMatrix objTM = node->GetWorldTM();
            Loc[t] = objTM.Translation();
            Quat[t] = objTM.Rotation();

            float eu[3];
            QuatToEuler(Quat[t],eu);
            Euler[t]=Point3(eu[0],eu[1],eu[2]);
            Euler[t] *= 180.0f/pi;

            eu[1] *= -1;
            EulerToQuat(eu,Quat[t],EULERTYPE_YXZ);
        }
        
        for( int t=0; t<FrameCount; ++t )
        {    
            _ftprintf( fLog, _T("%sLoc[%d]=(X=%f,Y=%f,Z=%f)\n"), node->GetName(), t, Loc[t].x, Loc[t].y, Loc[t].z );
        }
        
        for( int t=0; t<FrameCount; ++t )
        {    
            _ftprintf( fLog, _T("%sQuat[%d]=(W=%f,X=%f,Y=%f,Z=%f)\n"), node->GetName(), t, Quat[t].w, Quat[t].x, Quat[t].y, Quat[t].z ); 
        }
        
        for( int t=0; t<FrameCount; ++t )
        {    
            _ftprintf( fLog, _T("%sEuler[%d]=(X=%f,Y=%f,Z=%f)\n"), node->GetName(), t, Euler[t].x, Euler[t].y, Euler[t].z ); 
        }
    }
}
Example #3
0
void AFRMod::ModifyObject (TimeValue t, ModContext &mc, ObjectState *os, INode *node) {
	Interval iv = FOREVER;
	float f, p, b;
	int backface;
	Point3 pt1, pt2;
	pblock->GetValue(PB_FALLOFF,t,f,iv);
	pblock->GetValue(PB_PINCH,t,p,iv);
	pblock->GetValue(PB_BUBBLE,t,b,iv);
	pblock->GetValue(PB_BACKFACE,t,backface,iv);
	p1->GetValue(t,&pt1,iv,CTRL_ABSOLUTE);
	p2->GetValue(t,&pt2,iv,CTRL_ABSOLUTE);
	if (f==0.0) {
		os->obj->UpdateValidity(GEOM_CHAN_NUM,iv);	
		return;
	}
	Tab<Point3> normals;
	if (backface) {
		// Need to get vertex normals.
		if (os->obj->IsSubClassOf(triObjectClassID)) {
			TriObject *tobj = (TriObject*)os->obj;
			AverageVertexNormals (tobj->GetMesh(), normals);
		} else if (os->obj->IsSubClassOf (polyObjectClassID)) {
			PolyObject *pobj = (PolyObject *) os->obj;
			MNMesh &mesh = pobj->GetMesh();
			normals.SetCount (mesh.numv);
			Point3 *vn = normals.Addr(0);
			for (int i=0; i<mesh.numv; i++) {
				if (mesh.v[i].GetFlag (MN_DEAD)) vn[i]=Point3(0,0,0);
				else vn[i] = mesh.GetVertexNormal (i);
			}
#ifndef NO_PATCHES
		} else if (os->obj->IsSubClassOf (patchObjectClassID)) {
			PatchObject *pobj = (PatchObject *) os->obj;
			normals.SetCount (pobj->NumPoints ());
			Point3 *vn = normals.Addr(0);
			for (int i=0; i<pobj->NumPoints(); i++) vn[i] = pobj->VertexNormal (i);
#endif
		}
	}
	if (normals.Count()) {
		AFRDeformer deformer(mc,f,p,b,pt1,pt2,&normals);
		os->obj->Deform(&deformer, TRUE);
	} else {
		AFRDeformer deformer(mc,f,p,b,pt1,pt2);
		os->obj->Deform(&deformer, TRUE);
	}	
	os->obj->UpdateValidity(GEOM_CHAN_NUM,iv);	
	}
Example #4
0
void Water::ReInit() {
	float c[3], d;

	if (count!=waves.Count()) {
		waves.SetCount(count);
		waves.Resize(count);
		}

	// Reseed random number generator
	srand(randSeed); 

	// Compute wave centers on sphere with radius size
	for (int i = 0; i < count; i++) {
		WaveDesc &wv = waves[i];
		c[0] = frand();
		c[1] = (type == 0) ? frand() : 0.0f;
		c[2] = frand();
		d = size/(float)sqrt(c[0]*c[0]+c[1]*c[1]+c[2]*c[2]);
		wv.cent[0] = c[0]*d;
		wv.cent[1] = c[1]*d;
		wv.cent[2] = c[2]*d;
		wv.period = (((float)(rand()&0x7FFF))/32768.0f)*
			(maxperiod-minperiod)+minperiod; 
		wv.rate = (float)sqrt(maxperiod/wv.period);
		}
	}
Example #5
0
void BonesDefMod::RebuildPaintNodes()
	{
	//this sends all our dependant nodes to the painter
	MyEnumProc dep;              
	EnumDependents(&dep);
	Tab<INode *> nodes;
	for (int i = 0; i < nodes.Count(); i++)
		{

		ObjectState os = nodes[i]->EvalWorldState(GetCOREInterface()->GetTime());
						
		if ( (os.obj->NumPoints() != painterData[i].bmd->VertexData.Count()) ||
			  (painterData[i].bmd->isPatch) || (painterData[i].bmd->inputObjectIsNURBS) )
			{
			int ct = painterData[i].bmd->VertexData.Count();
			Tab<Point3> pointList;
			pointList.SetCount(ct);
			Matrix3 tm = nodes[i]->GetObjectTM(GetCOREInterface()->GetTime());
			for (int j =0; j < ct; j++)
				{
				pointList[j] = painterData[i].bmd->VertexData[j]->LocalPosPostDeform*tm;
				}
			pPainterInterface->LoadCustomPointGather(ct, pointList.Addr(0), nodes[i]);
			}
		}
	pPainterInterface->UpdateMeshes(TRUE);
	}
Example #6
0
void UVW_ChannelClass::CloneFaces(Tab<UVW_TVFaceClass*> &t)
	{
	int ct = f.Count();
	t.SetCount(ct);
	for (int i =0; i < ct; i++)
		t[i] = f[i]->Clone();
	}
Example #7
0
void PolyOpExtrudeEdge::Do (MNMesh & mesh) {
	MNChamferData chamData;
	chamData.InitToMesh(mesh);
	Tab<Point3> tUpDir;
	tUpDir.SetCount (mesh.numv);

	// Topology change:
	if (!mesh.ExtrudeEdges (MN_USER, &chamData, tUpDir)) return;

	// Apply map changes based on base width:
	int i;
	Tab<UVVert> tMapDelta;
	for (int mapChannel=-NUM_HIDDENMAPS; mapChannel<mesh.numm; mapChannel++) {
		if (mesh.M(mapChannel)->GetFlag (MN_DEAD)) continue;
		chamData.GetMapDelta (mesh, mapChannel, mWidth, tMapDelta);
		UVVert *pMapVerts = mesh.M(mapChannel)->v;
		if (!pMapVerts) continue;
		for (i=0; i<mesh.M(mapChannel)->numv; i++) pMapVerts[i] += tMapDelta[i];
	}

	// Apply geom changes based on base width:
	Tab<Point3> tDelta;
	chamData.GetDelta (mWidth, tDelta);
	for (i=0; i<mesh.numv; i++) mesh.v[i].p += tDelta[i];

	// Move the points up:
	for (i=0; i<tUpDir.Count(); i++) mesh.v[i].p += tUpDir[i]*mHeight;
}
Example #8
0
    bool GetComponents()
    {
        fSelectedNodes.ZeroCount();
        fSharedComps.ZeroCount();

        Interface *ip = GetCOREInterface();

        int nodeCount = ip->GetSelNodeCount();
        if (nodeCount == 0)
            return false;
        
        // Get the components shared among the selected nodes
        int i;
        fSelectedNodes.SetCount(nodeCount);
        for (i = 0; i < nodeCount; i++)
            fSelectedNodes[i] = ip->GetSelNode(i);

        INodeTab sharedComps;
        if (plSharedComponents(fSelectedNodes, sharedComps) == 0)
            return false;

        // Put the shared components in a list
        fSharedComps.SetCount(sharedComps.Count());
        for (i = 0; i < sharedComps.Count(); i++)
            fSharedComps[i] = ((plMaxNode*)sharedComps[i])->ConvertToComponent();

        return true;
    }
IOResult ParticleMesherObject::Load(ILoad *iload)
   {
   IOResult res = IO_OK;
   ULONG nb;
   SimpleObject2::Load(iload);
   // Default names
   
   int ct = 0;
   while (IO_OK==(res=iload->OpenChunk())) {
      switch (iload->CurChunkID()) {
         case TMCOUNT_CHUNK: 
            {
            int ct;
            iload->Read(&ct,sizeof(ct),&nb);
            tmList.SetCount(ct); 
            break;
            }
         case TMDATA_CHUNK: 
            {
            Matrix3 tm;
            tm.Load(iload);
            tmList[ct++] = tm;
            
            break;
            }
         }
      
      iload->CloseChunk();
      if (res!=IO_OK)  return res;
      }

   return IO_OK;
   }
Example #10
0
void Water::SetNum(int i, TimeValue t, BOOL init) { 
	count = i;
	waves.SetCount(count); 
	waves.Resize(count);
//	pblock->SetValue(PB_NUM, t, i);
	pblock->SetValue(water_num, t, i);
	if (init) ReInit();
	}
Example #11
0
void EditFaceDataModData::SynchSize (int numFaces) {
	if (numFaces<0) {
		// We're supposed to get the right size from the cache.
		if (mpCacheMesh) numFaces = mpCacheMesh->numFaces;
		if (mpCacheMNMesh) numFaces = mpCacheMNMesh->numf;
		if (numFaces<0) return;	// do nothing if cache missing.
	}
	mFaceSel.SetSize (numFaces, true);
	mFacesAffected.SetSize (numFaces, true);
	mtNewFaceValues.SetCount (numFaces);
}
void	SplineData::CopyCrossSectionData(Tab<SplineElementData*> &data)
{
	data.SetCount(mSplineElementData.Count());
	for (int i = 0; i < mSplineElementData.Count(); i++)
	{
		if (mSplineElementData[i])
		{
			data[i] = new SplineElementData(mSplineElementData[i]);			
		}
	}
}
void Unreal3DExport::Prepare()
{
    
    // Optimize
    if( bMaxResolution && Points.Count() > 1 )
    {
        pInt->ProgressUpdate(Progress, FALSE, GetString(IDS_INFO_OPT_SCAN));

        Point3 MaxPoint = Points[0];
        Point3 MinPoint = MaxPoint;

        // get scene bounding box
        for( int i=1; i<Points.Count(); ++i )
        {
            if      ( Points[i].x > MaxPoint.x )    MaxPoint.x = Points[i].x;
            else if ( Points[i].x < MinPoint.x )    MinPoint.x = Points[i].x;

            if      ( Points[i].y > MaxPoint.y )    MaxPoint.y = Points[i].y;
            else if ( Points[i].y < MinPoint.y )    MinPoint.y = Points[i].y;

            if      ( Points[i].z > MaxPoint.z )    MaxPoint.z = Points[i].z;
            else if ( Points[i].z < MinPoint.z )    MinPoint.z = Points[i].z;
        }
    
        // get center point
        OptOffset = MaxPoint+MinPoint;
        OptOffset *= 0.5;

        // center bounding box 
        MaxPoint -= OptOffset;
        MinPoint -= OptOffset;  

        // See FMeshVert
        OptScale.x = 1023.0f / max(fabs(MaxPoint.x),fabs(MinPoint.x));
        OptScale.y = 1023.0f / max(fabs(MaxPoint.y),fabs(MinPoint.y));
        OptScale.z = 511.0f / max(fabs(MaxPoint.z),fabs(MinPoint.z));

        // apply adjustments
        pInt->ProgressUpdate(Progress, FALSE, GetString(IDS_INFO_OPT_APPLY));
        for( int i=0; i<Points.Count(); ++i )
        {
            Point3& p = Points[i];
            p -= OptOffset;
            p *= OptScale;   
        }
    }
    
    // Convert verts
    Verts.SetCount(Points.Count(),TRUE);
    for( int i=0; i<Points.Count(); ++i )
    {
        Verts[i] = FMeshVert(Points[i]);
    }
}
void	SplineData::GetSelectedSplines(Tab<int> &selSplines)
{
	selSplines.SetCount(0);

	for (int i = 0; i < mSplineElementData.Count(); i++)
	{
		if (mSplineElementData[i]->IsSelected())
		{
			selSplines.Append(1,&i,10);
		}
	}
}
Example #15
0
IOResult Composite::Load(ILoad *iload) { 
	IOResult res;	
	ULONG nb;
	Param1 = TRUE;
	while (IO_OK==(res=iload->OpenChunk())) {
		int id = iload->CurChunkID();
		if (id>=MAPOFF_CHUNK&&id<=MAPOFF_CHUNK+0x1000) {
			mapOn[id-MAPOFF_CHUNK] = FALSE; 
			}
		else 
		switch(id)  {
			case SUBTEX_COUNT_CHUNK: {
				int c;
				iload->Read(&c,sizeof(c),&nb);
				subTex.SetCount(c);
				mapOn.SetCount(c);
				for (int i=0; i<c; i++)  {
					subTex[i] = NULL;
					mapOn[i] = TRUE;
					}
				break;
				}

			case MTL_HDR_CHUNK:
				res = MtlBase::Load(iload);
				break;
			case PARAM2_CHUNK:
				Param1 = FALSE;
				break;
			}
		iload->CloseChunk();
		if (res!=IO_OK) 
			return res;
		}	
	CompTexPostLoadCallback* comptexplcb = new CompTexPostLoadCallback(this,Param1,mapOn);
	iload->RegisterPostLoadCallback(comptexplcb);

	return IO_OK;
	}
void Unreal3DExport::GetAnim()
{
    
    // Export vertex animation
    int lastvert = 0;
    FMeshVert nullvert = FMeshVert();
    Points.SetCount(VertsPerFrame*FrameCount,TRUE);
    for( int t=0; t<FrameCount; ++t )
    {            
        // Progress
        CheckCancel();
        ProgressMsg.printf(GetString(IDS_INFO_ANIM),t+1,FrameCount);
        pInt->ProgressUpdate(Progress+((float)t/FrameCount*U3D_PROGRESS_ANIM), FALSE, ProgressMsg.data());
        
        // Set frame
        int frameverts = 0;
        int curframe = FrameStart + t;
        pScene->SetStaticFrame(curframe);
        
        // Write mesh verts
        for( int n=0; n<Nodes.Count(); ++n )
        {
            CheckCancel();

            IGameMesh * mesh = (IGameMesh*)Nodes[n]->GetIGameObject();          
            if( mesh->InitializeData() )
            {
                int vertcount = mesh->GetNumberOfVerts();
                for( int i=0; i<vertcount; ++i )
                {
                    Point3 p;
                    if( mesh->GetVertex(i,p) )
                    {
                        Points[lastvert++] = p;
                    }
                }
                frameverts += vertcount;
            }
            Nodes[n]->ReleaseIGameObject();
        }

        // Check number of verts in this frame
        if( frameverts != VertsPerFrame )
        {
            ProgressMsg.printf(GetString(IDS_ERR_NOVERTS),curframe,frameverts,VertsPerFrame);
            throw MAXException(ProgressMsg.data());
        }
    }
    Progress += U3D_PROGRESS_ANIM;

}
Example #17
0
void Composite::SetSubTexmap(int i, Texmap *m) {
	if (i>=subTex.Count()) {
		int n = subTex.Count();
		subTex.SetCount(i+1);
		pblock->SetCount(comptex_tex,i+1);

		for (int j=n; j<=i; j++)
			subTex[j] = NULL;
		}
	ReplaceReference(i+1,m);
	ivalid.SetEmpty();
	if (paramDlg)
		paramDlg->UpdateSubTexNames();
	}
Example #18
0
void Composite::Update(TimeValue t, Interval& valid) 
	{
	if (!ivalid.InInterval(t)) {
		ivalid.SetInfinite();		
		int n = pblock->Count(comptex_ons);
		if (n!=mapOn.Count()) mapOn.SetCount(n);
		for (int i=0; i<subTex.Count(); i++) {
			pblock->GetValue(comptex_ons,0,mapOn[i],valid,i);
	
			if (subTex[i]) 
				subTex[i]->Update(t,ivalid);
			}
		}
	valid &= ivalid;
	}
Example #19
0
void UVW_ChannelClass::BuildAdjacentGeomEdgesToVerts(Tab<AdjacentItem*> &verts)
{
	verts.SetCount(geomPoints.Count());
	for (int i = 0; i < geomPoints.Count(); i++)
	{
		verts[i] = new AdjacentItem();
	}

	for (int i = 0; i < gePtrList.Count(); i++)
	{
		int a = gePtrList[i]->a;
		verts[a]->index.Append(1,&i,5);
		a = gePtrList[i]->b;
		verts[a]->index.Append(1,&i,5);
	}
}
Example #20
0
void  UnwrapMod::fnFlattenMapNoParams()
   {
   Tab<Point3*> normList;
   normList.SetCount(6);

   normList[0] = new Point3(1.0f,0.0f,0.0f);
   normList[1] = new Point3(-1.0f,0.0f,0.0f);
   normList[2] = new Point3(0.0f,1.0f,0.0f);
   normList[3] = new Point3(0.0f,-1.0f,0.0f);
   normList[4] = new Point3(0.0f,0.0f,1.0f);
   normList[5] = new Point3(0.0f,0.0f,-1.0f);


   fnFlattenMap(flattenAngleThreshold, &normList, flattenSpacing, flattenNormalize, 2, flattenRotate, flattenCollapse);
   for (int i = 0; i < 6; i++)
      delete normList[i];
   }
Example #21
0
void EditPolyData::ApplyAllOperations (MNMesh & mesh)
{
#ifdef __DEBUG_PRINT_EDIT_POLY
	DebugPrint (_T("EditPolyData::ApplyAllOperations\n"));
#endif

	if (mpOpList) {
		// Preallocate if possible.  (Upon first application, this will do nothing.)
		PolyOperationRecord* pOpRec = NULL;
		int newFaces(0), newVertices(0), newEdges(0);
		Tab<int> newMapVertices;
		newMapVertices.SetCount (mesh.numm + NUM_HIDDENMAPS);
		for (int mp=-NUM_HIDDENMAPS; mp<mesh.numm; mp++) newMapVertices[mp+NUM_HIDDENMAPS] = 0;
		for (pOpRec=mpOpList; pOpRec != NULL; pOpRec=pOpRec->Next()) {
			newFaces += pOpRec->Operation()->NewFaceCount();
			newVertices += pOpRec->Operation()->NewVertexCount();
			newEdges += pOpRec->Operation()->NewEdgeCount ();

			for (int mp=-NUM_HIDDENMAPS; mp<mesh.numm; mp++) {
				if (mesh.M(mp)->GetFlag (MN_DEAD)) continue;
				newMapVertices[mp+NUM_HIDDENMAPS] += pOpRec->Operation()->NewMapVertexCount(mp);
			}
		}

		mesh.VAlloc (mesh.numv + newVertices);
		mesh.EAlloc (mesh.nume + newEdges);
		mesh.FAlloc (mesh.numf + newFaces);
		for (int mp=-NUM_HIDDENMAPS; mp<mesh.numm; mp++) {
			MNMap *map = mesh.M(mp);
			if (map->GetFlag (MN_DEAD)) continue;
			map->VAlloc (map->numv + newMapVertices[mp+NUM_HIDDENMAPS]);
			map->FAlloc (map->numf + newFaces);
		}

		for (pOpRec=mpOpList; pOpRec != NULL; pOpRec=pOpRec->Next())
		{
#ifdef __DEBUG_PRINT_EDIT_POLY
			DebugPrint (_T("EditPolyData::Applying %s\n"), pOpRec->Operation()->Name());
#endif
			pOpRec->Operation()->SetUserFlags (mesh);
			bool ret = pOpRec->Operation()->Apply (mesh, pOpRec->LocalData());
			if (ret && pOpRec->Operation()->CanDelete()) mesh.CollapseDeadStructs ();
		}
	}
}
//////////////////////////////////////////////////////////////////////////
// MNMeshLoopAdvancerEdge
// TODO
int MNMeshLoopAdvancerEdge::SetupFront(int startid, Tab<MNMeshLoopFront> &fronts)
{
  // first previous is root
  // set initial connectors
  MNEdge *edge = m_mesh->E(startid);

  fronts.SetCount(0);
  int outcount = 0;
  for (int o = 0; o < 4; o++){
    if (m_disableFlag & 1<<o) continue;

    int connector = -1;
    int contype;
    int nextid;

    if (o < 2){
      // loop
      contype = 0;
      connector = o ? edge->v1 : edge->v2;
      nextid = MNMeshLoop_nextEdgeLoop(m_mesh,startid,connector);
    }
    else{
      // ring
      contype = 1;
      connector = o%2 ? edge->f1 : edge->f2;
      nextid = connector >= 0 ? MNMeshLoop_nextEdgeRing(m_mesh,startid,connector) : -1;
    }

    if (nextid >= 0){
      MNMeshLoopFront advance;
      advance.previndex = 0;
      advance.nextid = nextid;
      advance.connector = connector;
      advance.contype = contype;
      advance.crossed = FALSE;

      outcount++;

      fronts.Append(1,&advance);
    }
  }

  return outcount;
}
void	SplineData::GetSelectedCrossSections(Tab<int> &selSplines, Tab<int> &selCrossSections)
{
	selSplines.SetCount(0);

	for (int i = 0; i < mSplineElementData.Count(); i++)
	{
		if (mSplineElementData[i]->IsSelected())
		{
			for (int j = 0; j < NumberOfCrossSections(i); j++)
			{
				if (CrossSectionIsSelected(i,j))
				{
					selCrossSections.Append(1,&j,10);
					selSplines.Append(1,&i,10);
				}
			}			
		}
	}
}
Example #24
0
//+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+
//|							From IPFTest									 |
//+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+
bool PFTestSplitBySource::Proceed(IObject* pCont, 
							PreciseTimeValue timeStart, 
							PreciseTimeValue& timeEnd, 
							Object* pSystem, 
							INode* pNode, 
							INode* actionNode, 
							IPFIntegrator* integrator, 
							BitArray& testResult, 
							Tab<float>& testTime)
{
	if (pNode == NULL) return false;

	bool exactStep = IsExactIntegrationStep(timeEnd, pSystem);
	int conditionType	= pblock()->GetInt(kSplitBySource_conditionType, timeStart);

	// acquire absolutely necessary particle channels
	IParticleChannelAmountR* chAmount = GetParticleChannelAmountRInterface(pCont);
	if (chAmount == NULL) return false; // can't find number of particles in the container
	int count = chAmount->Count();

	bool isSelectedSource = false;
	int i, systemHandle = pNode->GetHandle();
	for(i=0; i<pblock()->Count(kSplitBySource_sources); i++) {
		if (systemHandle == pblock()->GetInt(kSplitBySource_sources, 0, i)) {
			isSelectedSource = true; break;
		}
	}
				
	// test all particles
	testResult.SetSize(count);
	testResult.ClearAll();
	testTime.SetCount(count);
	if (exactStep) {
		if ((isSelectedSource && (conditionType == kSplitBySource_conditionType_selected)) 
			|| (!isSelectedSource && (conditionType == kSplitBySource_conditionType_notSelected))) {
			testResult.SetAll();
			for(i=0; i<count; i++) testTime[i] = 0.0f;
		}
	}

	return true;
}
int MNMeshLoopAdvancerVertex::SetupFront(int startid, Tab<MNMeshLoopFront> &fronts)
{
  // first previous is root
  // set initial connectors
  Tab<int> &connected = m_mesh->vedg[startid];
  int outcount = connected.Count();
  // for each direction
  fronts.SetCount(outcount);
  for (int o = 0; o < outcount; o++){
    MNMeshLoopFront *advance = fronts.Addr(o);

    int nextid = m_mesh->E(connected[o])->OtherVert(startid);
    advance->previndex = 0;
    advance->nextid = nextid;
    advance->connector = connected[o];
    advance->crossed = FALSE;
  }

  return outcount;
}
//////////////////////////////////////////////////////////////////////////
// MNMeshLoopAdvancerFace
int MNMeshLoopAdvancerFace::SetupFront(int startid, Tab<MNMeshLoopFront> &fronts)
{
  // first previous is root
  // set initial connectors
  MNFace *face = m_mesh->F(startid);

  int outcount = face->deg;
  // for each direction
  fronts.SetCount(outcount);
  for (int o = 0; o < outcount; o++){
    MNMeshLoopFront *advance = fronts.Addr(o);

    int nextid = m_mesh->E(face->edg[o])->OtherFace(startid);
    advance->previndex = 0;
    advance->nextid = nextid;
    advance->connector = face->edg[o];
    advance->crossed = FALSE;
  }

  return outcount;
}
Example #27
0
void UVW_ChannelClass::BuildAdjacentUVFacesToVerts(Tab<AdjacentItem*> &verts)
{
	verts.SetCount(v.Count());
	for (int i = 0; i < v.Count(); i++)
	{
		verts[i] = new AdjacentItem();
	}

	for (int i = 0; i < f.Count(); i++)
	{
		if (!(f[i]->flags & FLAG_DEAD ))
		{
			int deg = f[i]->count;
			for (int j = 0; j < deg; j++)
			{
				int a = f[i]->t[j];

				verts[a]->index.Append(1,&i,5);
			}
		}
	}
}
Example #28
0
//+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+
//|							From IPFTest									 |
//+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+
bool PFTestGoToNextEvent::Proceed(IObject* pCont, 
							PreciseTimeValue timeStart, 
							PreciseTimeValue& timeEnd, 
							Object* pSystem, 
							INode* pNode, 
							INode* actionNode, 
							IPFIntegrator* integrator, 
							BitArray& testResult, 
							Tab<float>& testTime)
{
	int conditionType	= pblock()->GetInt(kGoToNextEvent_conditionType, timeStart);
	bool exactStep = IsExactIntegrationStep(timeEnd, pSystem);

	// get channel container interface
	IChannelContainer* chCont;
	chCont = GetChannelContainerInterface(pCont);
	if (chCont == NULL) return false;

	// acquire absolutely necessary particle channels
	IParticleChannelAmountR* chAmount = GetParticleChannelAmountRInterface(pCont);
	if (chAmount == NULL) return false; // can't find number of particles in the container
	IParticleChannelPTVR* chTime = GetParticleChannelTimeRInterface(pCont);
	if (chTime == NULL) return false; // can't read timing info for a particle

	int count = chAmount->Count();
	if (count <= 0) return true;

	testResult.SetSize(count);
	testTime.SetCount(count);
	if((conditionType == kGoToNextEvent_conditionType_all) && exactStep) {
		testResult.SetAll();
		for(int i=0; i<count; i++) testTime[i] = 0.0f;
	} else {
		testResult.ClearAll();
	}

	return true;
}
//+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+
//|							From IPFTest									 |
//+>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>+
bool PFTestSplitSelected::Proceed(IObject* pCont, 
							PreciseTimeValue timeStart, 
							PreciseTimeValue& timeEnd, 
							Object* pSystem, 
							INode* pNode, 
							INode* actionNode, 
							IPFIntegrator* integrator, 
							BitArray& testResult, 
							Tab<float>& testTime)
{
	bool exactStep = IsExactIntegrationStep(timeEnd, pSystem);
	int conditionType	= pblock()->GetInt(kSplitSelected_conditionType, timeStart);

	// acquire absolutely necessary particle channels
	IParticleChannelAmountR* chAmount = GetParticleChannelAmountRInterface(pCont);
	if (chAmount == NULL) return false; // can't find number of particles in the container
	int count = chAmount->Count();
	IParticleChannelPTVR* chTime = GetParticleChannelTimeRInterface(pCont);
	if (chTime == NULL) return false; // can't read timing info for a particle
	IParticleChannelBoolR* chSelect = GetParticleChannelSelectionRInterface(pCont);

	// test all particles
	testResult.SetSize(count);
	testResult.ClearAll();
	testTime.SetCount(count);
	for(int i=0; i<count; i++)
	{
		bool selected = (chSelect != NULL) ? chSelect->GetValue(i) : false;
		bool sendOut = ((selected && (conditionType == kSplitSelected_conditionType_selected)) 
						|| (!selected && (conditionType == kSplitSelected_conditionType_notSelected)));
		if (sendOut && exactStep) {
			testResult.Set(i);
			testTime[i] = 0.0f;
		}
	}
	return true;
}
Example #30
0
void Composite::SetNumMaps(int n)
	{
	int ct = subTex.Count();
	if (n!=ct) {
		if (n<ct) {
			for (int i=n; i<ct; i++) {
				// Tell mtledit to deactivate texture map in UI
				if (subTex[i])
					subTex[i]->DeactivateMapsInTree();
				ReplaceReference(i+1,NULL);
				}
			}
		
		subTex.SetCount(n);
		// [dl | 01oct2003] Bug#525010. Initialize the new elements in the tab or pblock->SetCount()
		// may try to deference an invalid pointer from this tab.
		for(int j = ct; j < n; ++j) {
			subTex[j] = NULL;
		}

//		mapOn.SetCount(n);
		pblock->SetCount(comptex_tex,n);
		macroRec->Disable();  // JBW 4/21/99, only record one count change
		pblock->SetCount(comptex_ons,n);
		macroRec->Enable();

		if (n>ct) {
			for (int i=ct; i<subTex.Count(); i++) {
				subTex[i] = NULL;				
				pblock->SetValue(comptex_ons,0,TRUE,i);
//				mapOn[i] = TRUE;
				}
			}		
		NotifyChanged();
		}
	}