Jump to content

Publish the project.


photo

Recommended Posts

Creating Mesh Clusters from Mesh Clutters

How can I use C + + to implement this function?Call this function with code

and How to set the bounding box of an object?

Edited by 908317477
Link to comment

Hello @908317477

ObjectMeshClusterPtr createFrom(const ObjectMeshClutterPtr &clutter)
{
	auto cluster = ObjectMeshCluster::create(clutter->getMeshName());
	String name(clutter->getName());
	cluster->setName(name.append("_Cluster"));
	cluster->setParent(clutter->getParent());
	cluster->setWorldTransform(clutter->getWorldTransform());
	cluster->setVisibleDistance(clutter->getVisibleDistance());
	cluster->setFadeDistance(clutter->getFadeDistance());

	const int suf_num = clutter->getNumSurfaces();
	for (int suf_index = 0; suf_index < suf_num; ++suf_index)
	{
		cluster->setEnabled           (clutter->isEnabled            (suf_index), suf_index);
		cluster->setViewportMask      (clutter->getViewportMask      (suf_index), suf_index);
		cluster->setShadowMask        (clutter->getShadowMask        (suf_index), suf_index);
		cluster->setCastShadow        (clutter->getCastShadow        (suf_index), suf_index);
		cluster->setCastWorldShadow   (clutter->getCastWorldShadow   (suf_index), suf_index);
		cluster->setBakeToEnvProbe    (clutter->getBakeToEnvProbe    (suf_index), suf_index);
		cluster->setBakeToVoxelProbe  (clutter->getBakeToVoxelProbe  (suf_index), suf_index);
		cluster->setCastEnvProbeShadow(clutter->getCastEnvProbeShadow(suf_index), suf_index);
		cluster->setShadowMode        (clutter->getShadowMode        (suf_index), suf_index);
		cluster->setMinVisibleDistance(clutter->getMinVisibleDistance(suf_index), suf_index);
		cluster->setMaxVisibleDistance(clutter->getMaxVisibleDistance(suf_index), suf_index);
		cluster->setMinFadeDistance   (clutter->getMinFadeDistance   (suf_index), suf_index);
		cluster->setMaxFadeDistance   (clutter->getMaxFadeDistance   (suf_index), suf_index);
		cluster->setIntersection      (clutter->getIntersection      (suf_index), suf_index);
		cluster->setIntersectionMask  (clutter->getIntersectionMask  (suf_index), suf_index);
		cluster->setCollision         (clutter->getCollision         (suf_index), suf_index);
		cluster->setCollisionMask     (clutter->getCollisionMask     (suf_index), suf_index);
		cluster->setSoundOcclusion    (clutter->getSoundOcclusion    (suf_index), suf_index);
		cluster->setSoundOcclusionMask(clutter->getSoundOcclusionMask(suf_index), suf_index);
		cluster->setPhysicsFriction   (clutter->getPhysicsFriction   (suf_index), suf_index);
		cluster->setPhysicsRestitution(clutter->getPhysicsRestitution(suf_index), suf_index);
		cluster->setMaterial          (clutter->getMaterial          (suf_index), suf_index);
		cluster->setSurfaceProperty   (clutter->getSurfaceProperty   (suf_index), suf_index);
	}

	Vector<Mat4> transforms;
	clutter->createClutterTransforms();
	if (!clutter->getClutterWorldTransforms(transforms))
	{
		return ObjectMeshClusterPtr{};
	}
	cluster->createMeshes(transforms);
	return cluster;
}

 

Link to comment
×
×
  • Create New...