• [UE4]C++代码操作SplineMesh


    转自: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();  
    }  
  • 相关阅读:
    CruiseControl.NET 三言两语
    在MFC程序中增加控制台
    VS2005 编译Release版本出现清单文件的错误
    内存泄露问题
    软件设计原则
    boost::shared_ptr 分析与实现
    corelDraw 的CDR格式解析
    13. 量词操作符—【LINQ标准查询操作符】
    SQL SERVER执行查询的顺序
    CSLA命令对象的简单封装
  • 原文地址:https://www.cnblogs.com/sevenyuan/p/7728140.html
Copyright © 2020-2023  润新知