当前位置: 首页>>代码示例>>C++>>正文


C++ Box3::Contains方法代码示例

本文整理汇总了C++中Box3::Contains方法的典型用法代码示例。如果您正苦于以下问题:C++ Box3::Contains方法的具体用法?C++ Box3::Contains怎么用?C++ Box3::Contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Box3的用法示例。


在下文中一共展示了Box3::Contains方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Contains

hsBool plMaxNodeBase::Contains(const Point3& worldPt)
{
    TimeValue currTime = 0;//hsConverterUtils::Instance().GetTime(GetInterface());
    Object *obj = EvalWorldState(currTime).obj;
    if( !obj )
        return false;

    Matrix3 l2w = GetObjectTM(currTime);
    Matrix3 w2l = Inverse(l2w);
    Point3 pt = w2l * worldPt;

    if( obj->ClassID() == Class_ID(DUMMY_CLASS_ID,0) )
    {
        DummyObject* dummy = (DummyObject*)obj;
        Box3 bnd = dummy->GetBox();
        return bnd.Contains(pt);
    }
    if( obj->CanConvertToType(triObjectClassID) )
    {
        TriObject   *meshObj = (TriObject *)obj->ConvertToType(currTime, triObjectClassID);
        if( !meshObj )
            return false;

        Mesh& mesh = meshObj->mesh;
        Box3 bnd = mesh.getBoundingBox();
        if( !bnd.Contains(pt) )
        {
            if( meshObj != obj )
                meshObj->DeleteThis();
            return false;
        }

        hsBool retVal = true;
        int i;
        for( i = 0; i < mesh.getNumFaces(); i++ )
        {
            Face& face = mesh.faces[i];

            Point3 p0 = mesh.verts[face.v[0]];
            Point3 p1 = mesh.verts[face.v[1]];
            Point3 p2 = mesh.verts[face.v[2]];

            Point3 n = CrossProd(p1 - p0, p2 - p0);

            if( DotProd(pt, n) > DotProd(p0, n) )
            {
                retVal = false;
                break;
            }
        }

        if( meshObj != obj )
            meshObj->DeleteThis();

        return retVal;
    }

    // If we can't figure out what it is, the point isn't inside it.
    return false;
}
开发者ID:cwalther,项目名称:Plasma-nobink-test,代码行数:60,代码来源:plMaxNodeBase.cpp

示例2: EdgeIntersect

int UVW_ChannelClass::EdgeIntersect(Point3 p, float threshold, int i1,int i2)
{

 static int startEdge = 0;
 if (startEdge >= ePtrList.Count()) startEdge = 0;
 if (ePtrList.Count() == 0) return -1;

 int ct = 0;
 BOOL done = FALSE;


 int hitEdge = -1;
 while (!done) 
	{
 //check bounding volumes

	Box3 bounds;
	bounds.Init();

	int index1 = ePtrList[startEdge]->a;
	int index2 = ePtrList[startEdge]->b;
	if (v[index1].IsHidden() && v[index2].IsHidden())
		{
		}
	else if (v[index1].IsFrozen() && v[index1].IsFrozen()) 
		{
		}
	else
		{
		Point3 p1(0.0f,0.0f,0.0f);
		p1[i1] = v[index1].GetP()[i1];
		p1[i2] = v[index1].GetP()[i2];
//		p1.z = 0.0f;
		bounds += p1;
		Point3 p2(0.0f,0.0f,0.0f);
		p2[i1] = v[index2].GetP()[i1];
		p2[i2] = v[index2].GetP()[i2];
//		p2.z = 0.0f;
		bounds += p2;
		bounds.EnlargeBy(threshold);
		if (bounds.Contains(p))
			{
//check edge distance
			if (LineToPoint(p, p1, p2) < threshold)
				{
				hitEdge = startEdge;
				done = TRUE;
//				LineToPoint(p, p1, p2);
				}
			}
		}
 	ct++;
	startEdge++;
	if (ct == ePtrList.Count()) done = TRUE;
	if (startEdge >= ePtrList.Count()) startEdge = 0;
	}
 
 return hitEdge;
}
开发者ID:artemeliy,项目名称:inf4715,代码行数:59,代码来源:tvdata.cpp

示例3: LengthSquared

void
UniformGrid::ClosestPoint(Point3 p, float radius, int &pindex, float &d)
{
	xHitList.ClearAll();
	yHitList.ClearAll();
	zHitList.ClearAll();
	hitList.SetCount(0);

	//find the cell in the XGrid
	TagCells(p,radius, 0);
	//find the cell in the YGrid
	TagCells(p,radius, 1);
	//find the cell in the ZGrid
	TagCells(p,radius, 2);

	BitArray usedList;
	usedList.SetSize(pointBase.Count());
	usedList.ClearAll();

	int closest = -1;
	d = 0.0f;
	Box3 localBounds;
	localBounds.Init();
	localBounds += p;
	localBounds.EnlargeBy(radius);


	for (int i = 0; i < hitList.Count(); i++)
	{
		int index = hitList[i];
		if (!usedList[index])  //check to see if we have processed this one or not
		{
			if (xHitList[index] && yHitList[index] && zHitList[index])
			{
				usedList.Set(index);
				Point3 source = pointBase[index];
				if (localBounds.Contains(source))
				{
					float dist = LengthSquared(source-p);
					if ((dist < d) || (closest == -1))
					{
						d = dist;
						closest = index;
					}
				}
			}
		}
	}
	pindex = closest;
	d = sqrt(d);


}
开发者ID:DimondTheCat,项目名称:xray,代码行数:53,代码来源:UniformGrid.cpp

示例4:

void
UniformGrid::InRadius(Point3 p,  Tab<int> &indexList)
{
	float radius = largestRadius;
	xHitList.ClearAll();
	yHitList.ClearAll();
	zHitList.ClearAll();
	hitList.SetCount(0);

	//find the cell in the XGrid
	TagCells(p,radius, 0);
	//find the cell in the YGrid
	TagCells(p,radius, 1);
	//find the cell in the ZGrid
	TagCells(p,radius, 2);

	BitArray usedList;
	usedList.SetSize(pointBase.Count());
	usedList.ClearAll();

	int closest = -1;
	float d = 0.0f;
	Box3 localBounds;
	localBounds.Init();
	localBounds += p;
	localBounds.EnlargeBy(radius);


	for (int i = 0; i < hitList.Count(); i++)
	{
		int index = hitList[i];
		if (!usedList[index])  //check to see if we have processed this one or not
		{
			if (xHitList[index] && yHitList[index] && zHitList[index])
			{
				usedList.Set(index);
				Point3 source = pointBase[index];
				if (localBounds.Contains(source))
				{
					indexList.Append(1,&index,1000);

				}
			}
		}
	}

}
开发者ID:DimondTheCat,项目名称:xray,代码行数:47,代码来源:UniformGrid.cpp


注:本文中的Box3::Contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。