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


C++ Attachment::getRTTI方法代码示例

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


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

示例1: UpdateMesh

void SSpineWidget::UpdateMesh(int32 LayerId, FSlateWindowElementList& OutDrawElements, const FGeometry& AllottedGeometry, Skeleton* Skeleton) {
	TArray<FVector> vertices;
	TArray<int32> indices;
	TArray<FVector2D> uvs;
	TArray<FColor> colors;
	TArray<FVector> darkColors;

	int idx = 0;
	int meshSection = 0;
	UMaterialInstanceDynamic* lastMaterial = nullptr;

	SkeletonClipping &clipper = widget->clipper;
	Vector<float> &worldVertices = widget->worldVertices;

	float depthOffset = 0;
	unsigned short quadIndices[] = { 0, 1, 2, 0, 2, 3 };

	for (int i = 0; i < (int)Skeleton->getSlots().size(); ++i) {
		Vector<float> &attachmentVertices = worldVertices;
		unsigned short* attachmentIndices = nullptr;
		int numVertices;
		int numIndices;
		AtlasRegion* attachmentAtlasRegion = nullptr;
		Color attachmentColor;
		attachmentColor.set(1, 1, 1, 1);
		float* attachmentUvs = nullptr;

		Slot* slot = Skeleton->getDrawOrder()[i];
		Attachment* attachment = slot->getAttachment();
		if (!attachment) continue;
		if (!attachment->getRTTI().isExactly(RegionAttachment::rtti) && !attachment->getRTTI().isExactly(MeshAttachment::rtti) && !attachment->getRTTI().isExactly(ClippingAttachment::rtti)) continue;

		if (attachment->getRTTI().isExactly(RegionAttachment::rtti)) {
			RegionAttachment* regionAttachment = (RegionAttachment*)attachment;
			attachmentColor.set(regionAttachment->getColor());
			attachmentAtlasRegion = (AtlasRegion*)regionAttachment->getRendererObject();
			regionAttachment->computeWorldVertices(slot->getBone(), attachmentVertices, 0, 2);
			attachmentIndices = quadIndices;
			attachmentUvs = regionAttachment->getUVs().buffer();
			numVertices = 4;
			numIndices = 6;
		}
		else if (attachment->getRTTI().isExactly(MeshAttachment::rtti)) {
			MeshAttachment* mesh = (MeshAttachment*)attachment;
			attachmentColor.set(mesh->getColor());
			attachmentAtlasRegion = (AtlasRegion*)mesh->getRendererObject();
			mesh->computeWorldVertices(*slot, 0, mesh->getWorldVerticesLength(), attachmentVertices, 0, 2);
			attachmentIndices = mesh->getTriangles().buffer();
			attachmentUvs = mesh->getUVs().buffer();
			numVertices = mesh->getWorldVerticesLength() >> 1;
			numIndices = mesh->getTriangles().size();
		}
		else /* clipping */ {
开发者ID:smaren,项目名称:spine-runtimes,代码行数:53,代码来源:SSpineWidget.cpp

示例2: update

void PathConstraint::update() {
	Attachment *baseAttachment = _target->getAttachment();
	if (baseAttachment == NULL || !baseAttachment->getRTTI().instanceOf(PathAttachment::rtti)) {
		return;
	}

	PathAttachment *attachment = static_cast<PathAttachment *>(baseAttachment);

	float rotateMix = _rotateMix;
	float translateMix = _translateMix;
	bool translate = translateMix > 0;
	bool rotate = rotateMix > 0;
	if (!translate && !rotate) {
		return;
	}

	PathConstraintData &data = _data;
	bool percentSpacing = data._spacingMode == SpacingMode_Percent;
	RotateMode rotateMode = data._rotateMode;
	bool tangents = rotateMode == RotateMode_Tangent, scale = rotateMode == RotateMode_ChainScale;
	size_t boneCount = _bones.size();
	size_t spacesCount = tangents ? boneCount : boneCount + 1;
	_spaces.setSize(spacesCount, 0);
	float spacing = _spacing;
	if (scale || !percentSpacing) {
		if (scale) {
			_lengths.setSize(boneCount, 0);
		}
		bool lengthSpacing = data._spacingMode == SpacingMode_Length;

		for (size_t i = 0, n = spacesCount - 1; i < n;) {
			Bone *boneP = _bones[i];
			Bone &bone = *boneP;
			float setupLength = bone._data.getLength();
			if (setupLength < PathConstraint::EPSILON) {
				if (scale) {
					_lengths[i] = 0;
				}
				_spaces[++i] = 0;
			} else if (percentSpacing) {
				if (scale) {
					float x = setupLength * bone._a, y = setupLength * bone._c;
					float length = MathUtil::sqrt(x * x + y * y);
					_lengths[i] = length;
				}
				_spaces[++i] = spacing;
			} else {
				float x = setupLength * bone._a;
				float y = setupLength * bone._c;
				float length = MathUtil::sqrt(x * x + y * y);
				if (scale) {
					_lengths[i] = length;
				}

				_spaces[++i] = (lengthSpacing ? setupLength + spacing : spacing) * length / setupLength;
			}
		}
	} else {
		for (size_t i = 1; i < spacesCount; ++i) {
			_spaces[i] = spacing;
		}
	}

	Vector<float>& positions = computeWorldPositions(*attachment, spacesCount, tangents,
													data.getPositionMode() == PositionMode_Percent,
													percentSpacing);
	float boneX = positions[0];
	float boneY = positions[1];
	float offsetRotation = data.getOffsetRotation();
	bool tip;
	if (offsetRotation == 0) {
		tip = rotateMode == RotateMode_Chain;
	} else {
		tip = false;
		Bone &p = _target->getBone();
		offsetRotation *= p.getA() * p.getD() - p.getB() * p.getC() > 0 ? MathUtil::Deg_Rad : -MathUtil::Deg_Rad;
	}

	for (size_t i = 0, p = 3; i < boneCount; i++, p += 3) {
		Bone *boneP = _bones[i];
		Bone &bone = *boneP;
		bone._worldX += (boneX - bone._worldX) * translateMix;
		bone._worldY += (boneY - bone._worldY) * translateMix;
		float x = positions[p];
		float y = positions[p + 1];
		float dx = x - boneX;
		float dy = y - boneY;
		if (scale) {
			float length = _lengths[i];
			if (length >= PathConstraint::EPSILON) {
				float s = (MathUtil::sqrt(dx * dx + dy * dy) / length - 1) * rotateMix + 1;
				bone._a *= s;
				bone._c *= s;
			}
		}

		boneX = x;
		boneY = y;

		if (rotate) {
//.........这里部分代码省略.........
开发者ID:smaren,项目名称:spine-runtimes,代码行数:101,代码来源:PathConstraint.cpp


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