BOOL PFOperatorInstanceShapeMXSValidator::Validate(PB2Value& v)
{
	INode* iNode = (INode*)v.r;
	if (iNode == NULL) return NULL;
	TimeValue t = GetCOREInterface()->GetTime();
	Tab<INode*> stack;

	stack.Append(1, &iNode, 10);
	while (stack.Count())
	{
		INode *node = stack[stack.Count()-1];
		stack.Delete(stack.Count()-1, 1);

		Object *obj = node->EvalWorldState(t).obj;
		if (obj->CanConvertToType(Class_ID(TRIOBJ_CLASS_ID, 0)))
			return TRUE;

		// add children to the stack
		for (int i = 0; i < node->NumberOfChildren(); i++) {
			INode *childNode = node->GetChildNode(i);
			if (childNode)	stack.Append(1, &childNode, 10);
		}
	}
	return FALSE;
}
bool SplineData::ProjectPoint(int splineIndex, Point3 p,  Point3 &hitUVW, float &d, Point3 &hitPoint, SplineMapProjectionTypes projectionType, bool onlyInsideEnvelope, int maxIterations)
{
	bool hit = false;



	float scale = 1.0f;	//scale is used to expand our envelopes on each pass so we find at least a close point
	float limit = 128.0f;

	if (onlyInsideEnvelope)
		limit = 2.0f;

	mSplineElementData[splineIndex]->mClosestSubs.SetSize(mSplineElementData[splineIndex]->GetNumberOfSubBoundingBoxes());
	mSplineElementData[splineIndex]->mClosestSubs.ClearAll();
	while (!hit && scale < limit)
	{
		Tab<int> bounds;
		//start by getting a list of samples that contain this point
		mSplineElementData[splineIndex]->Contains(p,bounds,scale);	

		if (bounds.Count())
		{
			Point3 uvw = Point3(0.0f,0.0f,0.0f);
			float closestD = -1.0f;

			int closestSeg = 0;
			for (int j = 0; j < bounds.Count(); j++)
			{	
				//get our sample index
				int index = bounds[j];

				Point3 testUVW(0.0f,0.0f,0.0f);
				float testD = 0.0f;
				
				//find the closest sample
				if (mSplineElementData[splineIndex]->ProjectPoint(p, index, testUVW, testD, hitPoint,projectionType,scale,maxIterations))
				{
					if ((testD < closestD) || (closestD == -1.0f))
					{
						hitUVW = testUVW;
						closestD = testD;
						d = testD;
						hit =  true;
						closestSeg = j;
						mSplineElementData[splineIndex]->mClosestSubs.Set(closestSeg,TRUE);
					}		
					else
					{
					}
				}
			}		
				
			
		}		
		//increase our scale in case we did not find a hit
		scale *= 2.0f;
	}
	return hit;
}
void Unreal3DExport::WriteModel()
{
    // Progress
        pInt->ProgressUpdate(Progress, FALSE, GetString(IDS_INFO_WRITE));

        // Open data file
        fMesh = _tfopen(ModelFileName,_T("wb"));
        if( !fMesh ) 
        {
            ProgressMsg.printf(GetString(IDS_ERR_FMODEL),ModelFileName);
            throw MAXException(ProgressMsg.data());
        }

        // Open anim file
        fAnim = _tfopen(AnimFileName,_T("wb"));
        if( !fAnim )
        {
            ProgressMsg.printf(GetString(IDS_ERR_FANIM),AnimFileName);
            throw MAXException(ProgressMsg.data());
        }
        
        // data headers
        hData.NumPolys = Tris.Count();
        hData.NumVertices = VertsPerFrame;

        // anim headers
        hAnim.FrameSize = VertsPerFrame * sizeof(FMeshVert); 
        hAnim.NumFrames = FrameCount;


        // Progress
        CheckCancel();
        pInt->ProgressUpdate(Progress, FALSE, GetString(IDS_INFO_WMESH));
        

        // Write data
        fwrite(&hData,sizeof(FJSDataHeader),1,fMesh);
        if( Tris.Count() > 0 )
        {
            fwrite(Tris.Addr(0),sizeof(FJSMeshTri),Tris.Count(),fMesh);
        }
        Progress += U3D_PROGRESS_WMESH;

        // Progress
        CheckCancel();
        pInt->ProgressUpdate(Progress, FALSE, GetString(IDS_INFO_WANIM));

        // Write anim
        fwrite(&hAnim,sizeof(FJSAnivHeader),1,fAnim);
        if( Verts.Count() > 0 )
        {
            fwrite(Verts.Addr(0),sizeof(FMeshVert),Verts.Count(),fAnim);
        }
        Progress += U3D_PROGRESS_WANIM;
}
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]);
    }
}
예제 #5
0
파일: composit.cpp 프로젝트: 2asoft/xray
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();
	}
예제 #6
0
파일: composit.cpp 프로젝트: 2asoft/xray
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;
	}
예제 #7
0
파일: PolyOps.cpp 프로젝트: 2asoft/xray
void PolyOpChamferEdge::Do (MNMesh & mesh)
{
	MNChamferData *pMeshChamData = new MNChamferData;
	mesh.ChamferEdges (MN_USER, pMeshChamData);
	Tab<UVVert> mapDelta;
	for (int mapChannel = -NUM_HIDDENMAPS; mapChannel<mesh.numm; mapChannel++) {
		if (mesh.M(mapChannel)->GetFlag (MN_DEAD)) continue;
		pMeshChamData->GetMapDelta (mesh, mapChannel, mAmount, mapDelta);
		for (int i=0; i<mapDelta.Count(); i++) mesh.M(mapChannel)->v[i] += mapDelta[i];
	}

	Tab<Point3> vertexDelta;
	pMeshChamData->GetDelta (mAmount, vertexDelta);
	for (int i=0; i<vertexDelta.Count(); i++) mesh.P(i) += vertexDelta[i];
}
예제 #8
0
파일: PolyOps.cpp 프로젝트: 2asoft/xray
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;
}
예제 #9
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);
	}
예제 #10
0
BOOL plDistributor::IProjectVertex(const Point3& pt, const Point3& dir, float maxDist, Tab<int32_t>&faces, Point3& projPt) const
{
    BOOL retVal = false;
    plTriUtils triUtil;
    int i;
    for( i = 0; i < faces.Count(); i++ )
    {
        int iFace = faces[i];
        const hsPoint3& p0 = hsP3(fSurfMesh->getVert(fSurfMesh->faces[iFace].getVert(0)) * fSurfToWorld);
        const hsPoint3& p1 = hsP3(fSurfMesh->getVert(fSurfMesh->faces[iFace].getVert(1)) * fSurfToWorld);
        const hsPoint3& p2 = hsP3(fSurfMesh->getVert(fSurfMesh->faces[iFace].getVert(2)) * fSurfToWorld);

        Point3 plnPt = pt;
        if( triUtil.ProjectOntoPlaneAlongVector(p0, p1, p2, hsV3(dir), hsP3(plnPt)) )
        {
            Point3 bary = plnPt;
            plTriUtils::Bary baryVal = triUtil.ComputeBarycentric(p0, p1, p2, hsP3(plnPt), hsP3(bary));
            if( (plTriUtils::kOutsideTri != baryVal) && (plTriUtils::kDegenerateTri != baryVal) )
            {
                float dist = DotProd((pt - plnPt), dir);
                if( (dist <= maxDist) && (dist >= -maxDist) )
                {
                    projPt = plnPt;
                    maxDist = dist >= 0 ? dist : -dist;
                    retVal = true;
                }
            }
        }

    }
    return retVal;
}
예제 #11
0
void SpringSys::SetInitialBoneStates(Tab<Matrix3> boneTMs)
{
	for (int x = 0; x< GetParticles()->length(); x++)
	{
		SSParticle *p = GetParticle(x);
		for (int tmId = 0; tmId< boneTMs.Count(); tmId++)
		{
			for (int i=0;i<p->GetSprings()->length();i++)
			{
				if (tmId == p->GetSpring(i)->GetPointConstraint()->GetIndex())
				{
					if (tmId == 0) 
						p->GetSpring(i)->SetLength(Point3::Origin);
					else p->GetSpring(i)->SetLength( initPosTab[x] * Inverse(boneTMs[tmId]) );
					
					p->GetSpring(i)->GetPointConstraint()->SetPos(initPosTab[x]);
					p->GetSpring(i)->GetPointConstraint()->SetVel(Point3::Origin);
				}
			}
			if (frameCache.bone.length() <= tmId) 
			{
				SSConstraintPoint contBone = SSConstraintPoint(tmId);
				frameCache.bone.append(contBone);
			}
		}
		//frameCache.bone.SetCount(tmId+1);
	}
}
예제 #12
0
파일: composit.cpp 프로젝트: 2asoft/xray
IOResult Composite::Save(ISave *isave) { 
	IOResult res;
	ULONG nb;
	// Save common stuff
	isave->BeginChunk(MTL_HDR_CHUNK);
	res = MtlBase::Save(isave);
	if (res!=IO_OK) return res;
	isave->EndChunk();
	
	int c = subTex.Count();
	isave->BeginChunk(SUBTEX_COUNT_CHUNK);
	isave->Write(&c,sizeof(c),&nb);
	isave->EndChunk();

	isave->BeginChunk(PARAM2_CHUNK);
	isave->EndChunk();

/*	for (int i=0; i<subTex.Count(); i++) {
		if (mapOn[i]==0) {
			isave->BeginChunk(MAPOFF_CHUNK+i);
			isave->EndChunk();
			}
		}
*/

	return IO_OK;
	}	
예제 #13
0
파일: water.cpp 프로젝트: artemeliy/inf4715
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);
		}
	}
void	SplineData::RotateSelectedCrossSections(Quat q)
{
	Tab<int> selSplines;
	Tab<int> selCrossSections;
	GetSelectedCrossSections(selSplines,selCrossSections);

	//move the cross sections
	for (int i = 0; i < selSplines.Count(); i++)
	{
		int splineIndex = selSplines[i];
		int crossSectionIndex = selCrossSections[i];
		SplineCrossSection *section = GetCrossSection(splineIndex,crossSectionIndex);

		Matrix3 sTM = section->mTM;
		sTM.NoScale();
		sTM.NoTrans();

		Quat tq = TransformQuat(sTM,q);
		//no back into our initial space
		tq = TransformQuat(section->mIBaseTM,tq);

		section->mQuat += tq;


	}

	RecomputeCrossSections();	
}
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();
}
예제 #16
0
bool ParticleChannelInt::Spawn(Tab<int>& spawnTable)
{
	SysUtil::NeedToImplementLater(); // optimize the implementation

	int i, checkCount = min(spawnTable.Count(), Count());

	if (isGlobal())
	{
		int newCount = 0;
		for(i=0; i<checkCount; i++)
			if (spawnTable[i] > 0) newCount += spawnTable[i];
		_globalCount() = newCount;
	}
	else
	{
		Tab<int> oldData(data());
		int j, k, newCount = 0;
		for(i=0; i<checkCount; i++)
			if (spawnTable[i] > 0) newCount += spawnTable[i];
		_data().SetCount(newCount);
		for(i=0, j=0; i<checkCount; i++)
			for(k=0; k<spawnTable[i]; k++)
				_data(j++) = oldData[i];
	}
	return true;
}
예제 #17
0
void CModelExporter::ExportMeshVertex(IGameNode* /*pNode*/, IGameMesh* pMesh, IGameMaterial* pMat, size_t uMatID, BOOL bMultiMat)
{
    pMesh->SetUseWeightedNormals();
    pMesh->InitializeData();

    Tab<FaceEx*> faceTab;

    CollectMeshFaces(faceTab, pMesh, uMatID, bMultiMat);
    size_t uFaceCount = faceTab.Count();
    size_t uVertexCount = uFaceCount * 3;
    m_serializer << uVertexCount;

    BOOL bDiffusemap = GetTextureMap(pMat, ID_DI) == NULL ? FALSE : TRUE;
    BOOL bNormalmap = GetTextureMap(pMat, ID_BU) == NULL ? FALSE : TRUE;
    BOOL bSpecularmap = GetTextureMap(pMat, ID_SS) == NULL ? FALSE : TRUE;
    BOOL bLightmap = GetTextureMap(pMat, ID_AM) == NULL ? FALSE : TRUE;
    float centerX = 0;
    float centerY = 0;
    float centerZ = 0;
    for(size_t i = 0; i < uFaceCount; ++i)
    {
        FaceEx* pFace = faceTab[i];
        for(int  j = 0; j < 3; ++j)
        {
            DWORD mapIndex[3];
            Point3 ptUV;
            int indexUV = pFace->texCoord[j];
            int nChannel = 0;
            if(bDiffusemap || bNormalmap || bSpecularmap)
            {
                IGameTextureMap* pMap = GetTextureMap(pMat, ID_DI);
                nChannel = pMap->GetMapChannel();
            }
            else if(bLightmap)
            {
                IGameTextureMap* pMap = GetTextureMap(pMat, ID_AM);
                nChannel = pMap->GetMapChannel();
            }
            if(pMesh->GetMapFaceIndex(nChannel, pFace->meshFaceIndex, mapIndex))
                ptUV = pMesh->GetMapVertex(nChannel, mapIndex[j]);
            else
                ptUV = pMesh->GetMapVertex(nChannel, indexUV);
            int indexPos = pFace->vert[j];
            Point3 pos = pMesh->GetVertex(indexPos);

            m_serializer << pos.x << pos.y << pos.z;
            m_serializer << ptUV.x << ptUV.y;
            centerX += pos.x;
            centerY += pos.y;
            centerZ += pos.z;
        }
    }
    if (uFaceCount > 0)
    {
        centerX /= (uFaceCount * 3);
        centerY /= (uFaceCount * 3);
        centerZ /= (uFaceCount * 3);
        m_serializer << centerX << centerY << centerZ;
    }
}
예제 #18
0
파일: composit.cpp 프로젝트: 2asoft/xray
RefResult Composite::NotifyRefChanged(Interval changeInt, RefTargetHandle hTarget, 
   PartID& partID, RefMessage message ) {
	switch (message) {
		case REFMSG_CHANGE:			
			if (paramDlg) 
				paramDlg->Invalidate();
			if (pblock->LastNotifyParamID() == comptex_tex && pblock->Count(comptex_tex) != subTex.Count())
				SetNumMaps(pblock->Count(comptex_tex));
			else if (pblock->LastNotifyParamID() == comptex_ons && pblock->Count(comptex_ons) != subTex.Count())
				SetNumMaps(pblock->Count(comptex_ons));
			DiscardTexHandles(); // DS 5/4/00
			ivalid.SetEmpty();
			if (paramDlg&&Active())
				paramDlg->ip->MtlChanged();
			break;
		
		case REFMSG_GET_PARAM_DIM:
			return REF_STOP; 
		
		case REFMSG_GET_PARAM_NAME: {
			GetParamName *gpn = (GetParamName*)partID;
			gpn->name= GetSubTexmapSlotName(gpn->index);			
			return REF_STOP; 
			}
		}
	return(REF_SUCCEED);
	}
예제 #19
0
파일: fp_basics.cpp 프로젝트: ducthangho/3D
void FP_Basic::pack(Tab<float>& listRect, Tab<float>& enclosingRect)
{
	std::vector<MyRectangle> lr;
	for (int i = 0; i < listRect.Count(); i += 4)
	{
		lr.emplace_back(listRect[i + 2], listRect[i + 3]);
	}

	Node er(0, 0, enclosingRect[0], enclosingRect[1]);
	er.packWithNoPreSort(lr, er);

	for (int i = 0, j = 0; i < listRect.Count(); i += 4, ++j)
	{
		listRect[i] = lr[j].x;
		listRect[i + 1] = lr[j].y;
	}
}
int SplineData::HitTest(ViewExp *vpt,INode *node, ModContext *mc, Matrix3 tm, HitRegion hr, int flags, SplineMapProjectionTypes projType, BOOL selectCrossSection )
{
	if ( ! vpt || ! vpt->IsAlive() )
	{
		// why are we here?
		DbgAssert(!_T("Doing HitTest() on invalid viewport!"));
		return FALSE;
	}

	int res = 0;

	GraphicsWindow *gw = vpt->getGW();
	DWORD limit = gw->getRndLimits();
	gw->setRndLimits(( limit | GW_PICK) & ~GW_ILLUM);
	if (selectCrossSection)
	{
		Tab<int> hitSplines;
		Tab<int> hitCrossSections;

		if (HitTestCrossSection(gw, hr,  projType, hitSplines,hitCrossSections))
		{
			for (int i = 0; i < hitSplines.Count(); i++)
			{
				int splineIndex = hitSplines[i];
				int crossSectionIndex = hitCrossSections[i];
				if ( (mSplineElementData[splineIndex]->CrossSectionIsSelected(crossSectionIndex) && (flags&HIT_SELONLY)) ||
					!(flags&(HIT_UNSELONLY|HIT_SELONLY)))
					vpt->LogHit(node,mc,crossSectionIndex,splineIndex,NULL);
				else if ( (!mSplineElementData[splineIndex]->CrossSectionIsSelected(crossSectionIndex) && (flags&HIT_UNSELONLY)) ||
					!(flags&(HIT_UNSELONLY|HIT_SELONLY)))
					vpt->LogHit(node,mc,crossSectionIndex,splineIndex,NULL);
			}
		}
	}
	else
	{
		for (int splineIndex = 0; splineIndex < mSplineElementData.Count();splineIndex++)
		{
			gw->clearHitCode();
			mSplineElementData[splineIndex]->Display(gw,Matrix3(1),projType );
			if (gw->checkHitCode())
			{
				if ( (mSplineElementData[splineIndex]->IsSelected() && (flags&HIT_SELONLY)) ||
					!(flags&(HIT_UNSELONLY|HIT_SELONLY)))
					vpt->LogHit(node,mc,0,splineIndex,NULL);
				else if ( (!mSplineElementData[splineIndex]->IsSelected() && (flags&HIT_UNSELONLY)) ||
					!(flags&(HIT_UNSELONLY|HIT_SELONLY)))
					vpt->LogHit(node,mc,0,splineIndex,NULL);
			}

		}

	}

	gw->setRndLimits(limit);
	return res;
}
예제 #21
0
파일: PolyOps.cpp 프로젝트: 2asoft/xray
void PolyOperation::CopyBasics (PolyOperation *pCopyTo)
{
	pCopyTo->mSelection = mSelection;
	Tab<int> paramList;
	GetParameters (paramList);
	for (int i=0; i<paramList.Count (); i++) {
		int id = paramList[i];
		memcpy (pCopyTo->Parameter(id), Parameter(id), ParameterSize(id));
	}
}
예제 #22
0
 virtual void proc(INodeTab &nodeTab)
 {
     for (int i = 0; i < nodeTab.Count(); i++)
     {
         for (int j = 0; j < fSharedComps.Count(); j++)
         {
             fSharedComps[j]->AddTarget((plMaxNodeBase*)nodeTab[i]);
         }
     }
 }
예제 #23
0
파일: ToolUnfold.cpp 프로젝트: 2asoft/xray
Point3*	UnwrapMod::fnGetNormal(int faceIndex)
	{
	//check for type
	ModContextList mcList;		
	INodeTab nodes;
	
	Point3 norm(0.0f,0.0f,0.0f);

	n = norm;
	if (!ip) return &n;
	ip->GetModContexts(mcList,nodes);

	int objects = mcList.Count();

	

	faceIndex--;


	if (objects != 0)
		{
		MeshTopoData *md = (MeshTopoData*)mcList[0]->localData;

		if (md == NULL) 
			{
			return NULL;
			}


		Tab<Point3> objNormList;
		BuildNormals(md,objNormList);
		if ((faceIndex >= 0) && (faceIndex < objNormList.Count()))
			norm = objNormList[faceIndex];
		else
			{
			faceIndex = 0;
			int ct = 1;
			for (int i =0; i < md->faceSel.GetSize(); i++)
				{
				if (md->faceSel[i])
					{
					faceIndex = i;
					norm = objNormList[faceIndex];
					TSTR normstr;
					normstr.printf("norm%d = Point3 %f %f %f",ct,norm.x,norm.y,norm.z);
					ct++;
					macroRecorder->ScriptString(normstr);
					macroRecorder->EmitScript();
					}
				}
			}
		}
	n = norm;
	return &n;
	}
void Unreal3DExport::RegisterMaterial( IGameNode* node, IGameMesh* mesh, FaceEx* f, FJSMeshTri* tri )
{
    tri->TextureNum = f->matID;

    int matid = f->matID;

    IGameMaterial* mat = mesh->GetMaterialFromFace(f);
    if( mat )
    {
        Tab<TSTR*> tokens = TokStr(mat->GetMaterialName(),_T(" \t,;"));
        for( int i=0; i!=tokens.Count(); ++i )
        {
            if( MatchPattern(*tokens[i],TSTR(_T("F=*")),TRUE) )
            {
                SplitStr(*tokens[i],_T('='));
                tri->Flags = static_cast<byte>(_ttoi(tokens[i]->data()));
            }
        }
        tokens.Delete(0,tokens.Count());

        if( Materials.Count() <= matid )
        {
            Materials.Append(matid-Materials.Count()+1,&sMaterial::DefaultMaterial);
        }
        
        if( Materials[matid].Mat != mat )
        {
            Materials[matid].Mat = mat;
        }

        /*for( int i=0; i!=mat->GetSubMaterialCount(); ++i )
        {
            IGameMaterial* sub = mat->GetSubMaterial(i);
            if( sub )
            {
                TSTR matname = sub->GetMaterialName();
                int subid = mat->GetMaterialID(i);
                int x = 0;
            }
        }*/
    }
}
예제 #25
0
void plDistributor::IFindFaceSet(const Box3& box, Tab<int32_t>& faces) const
{
    Tab<int32_t> distNodes;
    fMeshTree.HarvestBox(box, distNodes);
    int i;
    for( i = 0; i < distNodes.Count(); i++ )
    {
        int32_t iFace = int32_t(fMeshTree.GetBox(distNodes[i]).fIData);
        faces.Append(1, &iFace);
    }
}
예제 #26
0
파일: fp_basics.cpp 프로젝트: ducthangho/3D
Tab<float> FP_Basic::myFunction5(Tab<float> listRect)
{
	mprintf(L"xin chao mytestfunction5\n");
	mflush();
	for (int i = 0; i < listRect.Count(); ++i) {
		listRect[i]++;
		mprintf(L"listRect[%d] = %f\n", i, listRect[i]);
	};
	mflush();
	return Tab<float>();
}
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 ); 
        }
    }
}
예제 #28
0
파일: composit.cpp 프로젝트: 2asoft/xray
RefTargetHandle Composite::Clone(RemapDir &remap) 
	{
	Composite *mnew = new Composite();
	*((MtlBase*)mnew) = *((MtlBase*)this);  // copy superclass stuff	
	mnew->ivalid.SetEmpty();	
	mnew->subTex.SetCount(subTex.Count());
	mnew->ReplaceReference(0,remap.CloneRef(pblock));

	mnew->offset = offset;
	mnew->mapOn.SetCount(subTex.Count()); //DS 3/8/99  this seems necessary due to the param block 2 changes.

	for (int i = 0; i<subTex.Count(); i++) {
		mnew->subTex[i] = NULL;
		if (subTex[i]) {
			mnew->ReplaceReference(i+1,remap.CloneRef(subTex[i]));
		//	GetCOREInterface()->AssignNewName(mnew->subTex[i]);
			}
//		mnew->mapOn[i] = mapOn[i];
		}
	BaseClone(this, mnew, remap);
	return (RefTargetHandle)mnew;
	}
예제 #29
0
파일: PolyOps.cpp 프로젝트: 2asoft/xray
void PolyOpExtrudeAlongSpline::Do (MNMesh & mesh) {
	if (mpSpline == NULL) return;
	
	Tab<Matrix3> tTransforms;
	theFrenetFinder.ConvertPathToFrenets (mpSpline, mSplineXfm, tTransforms,
		mSegments, mAlign?true:false, mRotation);

	// Apply taper and twist to transforms:
	float denom = float(tTransforms.Count()-1);
	for (int i=1; i<tTransforms.Count(); i++) {
		float amount = float(i)/denom;
		// This equation taken from Taper modifier:
		float taperAmount =	1.0f + amount*mTaper + mTaperCurve*amount*(1.0f-amount);
		if (taperAmount != 1.0f) {
			// Pre-scale matrix by taperAmount.
			tTransforms[i].PreScale (Point3(taperAmount, taperAmount, taperAmount));
		}
		if (mTwist != 0.0f) {
			float twistAmount = mTwist * amount;
			tTransforms[i].PreRotateZ (twistAmount);
		}
	}

	// Note:
	// If there are multiple face clusters, the first call to ExtrudeFaceClusterAlongPath
	// will bring mesh.numf and fClust.clust.Count() out of synch - fClust isn't updated.
	// So we fix that here.
	MNFaceClusters fClust (mesh, MN_USER);
	for (i=0; i<fClust.count; i++) {
		if (mesh.ExtrudeFaceClusterAlongPath (tTransforms, fClust, i, mAlign?true:false)) {
			if (i+1<fClust.count) {
				// New faces not in any cluster.
				int oldnumf = fClust.clust.Count();
				fClust.clust.SetCount (mesh.numf);
				for (int j=oldnumf; j<mesh.numf; j++) fClust.clust[j] = -1;
			}
		}
	}
}
예제 #30
0
파일: composit.cpp 프로젝트: 2asoft/xray
void CompTexPostLoadCallback::proc(ILoad *iload)
{
	if (Param1)
		{
		s->pblock->SetCount(comptex_ons,ons.Count());
		s->pblock->SetCount(comptex_tex,ons.Count());
		for (int i=0; i<s->subTex.Count(); i++) {
			s->pblock->SetValue(comptex_ons,0,ons[i],i);

			}
		}
	delete this;
}