码迷,mamicode.com
首页 > 编程语言 > 详细

[UE4]C++代码操作SplineMesh

时间:2017-10-25 13:24:47      阅读:414      评论:0      收藏:0      [点我收藏+]

标签:this   logs   color   nts   instanced   void   and   ndt   shadow   

转自:http://aigo.iteye.com/blog/2279503

void ARaceSpline::OnConstruction(const FTransform& Transform)  
{  
    for (int32 i = 0; i < mSplineComponent->GetNumSplinePoints() - 1; i++)  
    {  
        USplineMeshComponent* SplineMesh = ConstructObject<USplineMeshComponent>(USplineMeshComponent::StaticClass(), this);  
  
        SplineMesh->bCreatedByConstructionScript = true;  
        SplineMesh->SetMobility(EComponentMobility::Movable);  
        SplineMesh->AttachParent = mSplineComponent;  
  
        //Set the color!  
        UMaterialInstanceDynamic* dynamicMat = UMaterialInstanceDynamic::Create(mSplineMeshMaterial, NULL);  
        dynamicMat->SetVectorParameterValue(TEXT("Color"), FLinearColor(mSegments[i].mColor));  
  
        SplineMesh->bCastDynamicShadow = false;  
        SplineMesh->SetStaticMesh(mGridMesh);  
        SplineMesh->SetMaterial(0, dynamicMat);  
  
        //Width of the mesh   
        SplineMesh->SetStartScale(FVector2D(50, 50));  
        SplineMesh->SetEndScale(FVector2D(50, 50));  
  
        FVector pointLocationStart, pointTangentStart, pointLocationEnd, pointTangentEnd;  
        mSplineComponent->GetLocalLocationAndTangentAtSplinePoint(i, pointLocationStart, pointTangentStart);  
        mSplineComponent->GetLocalLocationAndTangentAtSplinePoint(i + 1, pointLocationEnd, pointTangentEnd);  
  
        SplineMesh->SetStartAndEnd(pointLocationStart, pointTangentStart, pointLocationEnd, pointTangentEnd);  
    }  
  
    RegisterAllComponents();  
}  

 

[UE4]C++代码操作SplineMesh

标签:this   logs   color   nts   instanced   void   and   ndt   shadow   

原文地址:http://www.cnblogs.com/sevenyuan/p/7728140.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!