zoukankan      html  css  js  c++  java
  • [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();  
    }  
  • 相关阅读:
    BZOJ2648: SJY摆棋子
    BZOJ1925: [Sdoi2010]地精部落
    BZOJ1941: [Sdoi2010]Hide and Seek
    BZOJ2434: [Noi2011]阿狸的打字机
    BZOJ3295: [Cqoi2011]动态逆序对
    BZOJ1406: [AHOI2007]密码箱
    BZOJ1115: [POI2009]石子游戏Kam
    BZOJ1531: [POI2005]Bank notes
    BZOJ2730: [HNOI2012]矿场搭建
    计算几何《简单》入土芝士
  • 原文地址:https://www.cnblogs.com/sevenyuan/p/7728140.html
Copyright © 2011-2022 走看看