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


C++ AutoAlloc::GetNearestIntersection方法代码示例

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


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

示例1: ModifyPoints

void DropEffector::ModifyPoints(BaseObject* op, BaseObject* gen, BaseDocument* doc, EffectorDataStruct* data, MoData* md, BaseThread* thread)
{
	if (!ed.target || !rcol || data->strength == 0.0)
		return;

	C4D_Falloff* falloff = GetFalloff();
	if (!falloff)
		return;

	Int32	 i = 0;
	Float	 fall	 = 0.0;
	Vector off	 = Vector(0.0);
	Vector ray_p = Vector(0.0), ray_dir = Vector(0.0);
	Vector targ_off = Vector(0.0), targ_hpb = Vector(0.0);

	MDArray<Int32>	flag_array = md->GetLongArray(MODATA_FLAGS);
	MDArray<Matrix> mat_array	 = md->GetMatrixArray(MODATA_MATRIX);
	MDArray<Float>	weight_array = md->GetRealArray(MODATA_WEIGHT);

	if (!mat_array)
		return;

	Int32 mdcount = (Int32)md->GetCount();
	for (i = 0; i < mdcount; i++)
	{
		//If the particle isn't visible, don't calculate
		if (!(flag_array[i] & MOGENFLAG_CLONE_ON) || (flag_array[i] & MOGENFLAG_DISABLE))
			continue;

		//Multiply into global space
		off = mat_array[i].off;
		off = ed.genmg * off;

		//Sample the falloff
		falloff->Sample(off, &fall, true, weight_array[i]);
		if (fall == 0.0)
			continue;

		//Set up the ray for the collision
		ray_p = ed.itargmg * off;
		switch (ed.mode)
		{
			default:
			case DROPEFFECTOR_MODE_PNORMAL:		ray_dir = ed.genmg.TransformVector(mat_array[i].v3); break;
			case DROPEFFECTOR_MODE_NNORMAL:		ray_dir = ed.genmg.TransformVector(-mat_array[i].v3); break;
			case DROPEFFECTOR_MODE_AXIS:			ray_dir = (ed.targmg.off - off); break;
			case DROPEFFECTOR_MODE_SELFAXIS:	ray_dir = (ed.genmg.off - off);	break;
			case DROPEFFECTOR_MODE_PX:				ray_dir = Vector(1.0, 0.0, 0.0); break;
			case DROPEFFECTOR_MODE_PY:				ray_dir = Vector(0.0, 1.0, 0.0); break;
			case DROPEFFECTOR_MODE_PZ:				ray_dir = Vector(0.0, 0.0, 1.0); break;
			case DROPEFFECTOR_MODE_NX:				ray_dir = Vector(-1.0, 0.0, 0.0);	break;
			case DROPEFFECTOR_MODE_NY:				ray_dir = Vector(0.0, -1.0, 0.0);	break;
			case DROPEFFECTOR_MODE_NZ:				ray_dir = Vector(0.0, 0.0, -1.0);	break;
		}
		ray_dir = ed.itargmg.TransformVector(ray_dir);

		//Calculate an intersection
		if (rcol->Intersect(ray_p, !ray_dir, ed.maxdist, false))
		{
			if (rcol->GetNearestIntersection(&rcolres))
			{
				fall *= data->strength;

				targ_off = Blend(mat_array[i].off, ed.igenmg * (ed.targmg * rcolres.hitpos), fall);
				targ_hpb = VectorToHPB(ed.igenmg.TransformVector(ed.targmg.TransformVector(rcolres.s_normal)));

				mat_array[i] = HPBToMatrix(Blend(MatrixToHPB(mat_array[i], ROTATIONORDER_DEFAULT), targ_hpb, fall), ROTATIONORDER_DEFAULT);
				mat_array[i].off = targ_off;
			}
		}
	}
}
开发者ID:archimy,项目名称:cinema4d_cpp_sdk,代码行数:72,代码来源:dropeffector.cpp


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