【发布时间】:2017-05-18 09:52:49
【问题描述】:
我目前正在实时种植树木,并且我正在为树叶使用实例化静态网格组件,因为每片树叶都是独一无二的。当我将一个叶子实例添加到我的组件时,我对其进行了随机旋转。但是由于某种原因,没有设置这个旋转,我所有的叶子都有一个 zerorotator。设置了比例,也设置了变换,但没有设置旋转。
代码如下:
//Instanced static mesh component instanciation, as a component of the tree
foliage = NewObject<UInstancedStaticMeshComponent>(this);
foliage->SetWorldLocation(GetActorLocation());
foliage->RegisterComponent();
foliage->SetStaticMesh(data->leaves[treeType]);
foliage->SetFlags(RF_Transactional);
this->AddInstanceComponent(foliage);
//Adding a instance of foliage
const FTransform leafTrans = FTransform(
FMath::VRandCone(normals[branches[i].segments[j].firstVertice + 2], 2.0f).Rotation(),
vertices[branches[i].segments[j].firstVertice + 2], FVector::ZeroVector);
foliage->AddInstance(leafTrans);
我最近更改了 Instanced Static Mesh Component,我开始将它放在一个子 actor 上,并且旋转起作用了。但我不得不将其删除以解决其他问题。
我确定这是我错过的一件小事,但是我在互联网上搜索浪费了太多时间,而且关于这个主题的文档并不多......
谢谢:)
【问题讨论】:
标签: c++ unreal-engine4