Unreal Engine : 实例化静态网格体在实例化时不旋转
Unreal Engine : Instanced Static Mesh doesn't rotate on instanciation
我目前正在实时种植树木,我正在为树叶使用实例化静态网格组件,因为每片叶子都是独一无二的。当我将一个叶实例添加到我的组件时,我对其进行了随机旋转。但由于某种原因,这个旋转没有设置,我所有的叶子都有一个 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,我开始将其放在儿童演员身上,并且旋转有效。但我不得不将其删除以解决其他问题。
我确定这是我遗漏的一件小事,但我浪费了太多时间在 Internet 上搜索,并且没有那么多关于这个主题的文档...
谢谢:)
好的,问题是规模。出于某种原因,如果它设置为零,它也会将旋转设置为零...
我目前正在实时种植树木,我正在为树叶使用实例化静态网格组件,因为每片叶子都是独一无二的。当我将一个叶实例添加到我的组件时,我对其进行了随机旋转。但由于某种原因,这个旋转没有设置,我所有的叶子都有一个 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,我开始将其放在儿童演员身上,并且旋转有效。但我不得不将其删除以解决其他问题。
我确定这是我遗漏的一件小事,但我浪费了太多时间在 Internet 上搜索,并且没有那么多关于这个主题的文档...
谢谢:)
好的,问题是规模。出于某种原因,如果它设置为零,它也会将旋转设置为零...