Announcement

Collapse
No announcement yet.

CustBrushBuilder Error Brush

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    CustBrushBuilder Error Brush

    Hello,I would like to use EditorBrushBuilder (CustBrushBuilder) to build a brush ,Following code:

    Code:
    bool UCustBrushBuilder::Build(UWorld * InWorld, ABrush * InBrush)
    {
    	//TArray<FVector> LocBottomVertexs = OneVertexs;
    	//LocBottomVertexs.Append(OtherVertexs);
    
    	if(BottomVertexs.Num() < 3)
    		return BadParameters(LOCTEXT("WallBottomFaceVertexsCount", "Invalid Vertex Count!"));
    
    	BeginBrush(false, TEXT("CustBrush")); 
    	
    	//int32 Direction = JugePolyOrderAndAoTo(BottomVertexs);
    	BuildCustBrush(+1, BottomVertexs);
    	return EndBrush(InWorld, InBrush);
    }
    Code:
    void UCustBrushBuilder::BuildCustBrush(int32 Direction, const TArray<FVector2D>& InBottomVertexs)
    {
    	check(InBottomVertexs.Num() > 2);
    
    	int32  BottomFaceVertexCount = InBottomVertexs.Num(); 
    
    	int n = InBottomVertexs.Num() * 2; 
    	float Height = 30;
    	for (int32 index = 0; index < n; ++index)
    	{
    		if (index < BottomFaceVertexCount)
    		{
    			Vertex3f(InBottomVertexs[index].X, InBottomVertexs[index].Y, 0);
    		}
    		else
    		{
    			Vertex3f(InBottomVertexs[index % BottomFaceVertexCount].X, InBottomVertexs[index % BottomFaceVertexCount].Y, Height);
    		}
    	}
    	
    
    	//ScalPoly(Vertices);
    
    	//Bottom Face Begin
    	PolyBegin(Direction, "Bottom");
    	for (int32 BottomFaceIndex = BottomFaceVertexCount-1; BottomFaceIndex > -1; BottomFaceIndex--)
    	{
    		Polyi(BottomFaceIndex);
    	}
    	PolyEnd();
    	//Bottom Face End
    
    	//Each Face begin
    	for (int32 EachFaceIndex = 0; EachFaceIndex < BottomFaceVertexCount; ++EachFaceIndex)
    	{
    		int32 FirstIndex = EachFaceIndex; // 0
    		int32 SecIndex = EachFaceIndex + BottomFaceVertexCount;
    		int32 ThirdIndex = (EachFaceIndex + 1) % BottomFaceVertexCount + BottomFaceVertexCount;
    		int32 FourIndex = (EachFaceIndex + 1) % BottomFaceVertexCount;
    
    		Poly4i(Direction, FourIndex, ThirdIndex, SecIndex, FirstIndex, "Each");
    	}
    	//Each Face End
    
    	//Top Face Begin
    	PolyBegin(Direction, "Top");
    	for (int32 TopFaceIndex = BottomFaceVertexCount; TopFaceIndex < n; ++TopFaceIndex)
    	{
    		Polyi(TopFaceIndex);
    	}
    	PolyEnd();
    	//Top Face End
    }
    BottomVertexs[5]
    - BottomVertexs Num=5 TArray<FVector2D,FDefaultAllocator>
    + [0] {X=-404.539948 Y=3105.41455 } FVector2D
    + [1] {X=-667.448730 Y=-754.085632 } FVector2D
    + [2] {X=4131.35010 Y=-544.531250 } FVector2D
    + [3] {X=1116.35742 Y=1687.62085 } FVector2D
    + [4] {X=4096.51123 Y=2377.76196 } FVector2D

    Error result :
    Click image for larger version

Name:	error.png
Views:	1
Size:	342.9 KB
ID:	1219863

    Correct result :
    Click image for larger version

Name:	ok.png
Views:	1
Size:	255.0 KB
ID:	1219864

    why?

    #2
    I've been trying to work on something similar, but I can't even get my project to build. Trying to extend UEditorBrushBuilder gives me a bunch of unresolved external symbol errors. How did you get around that?

    Comment


      #3
      Originally posted by Vormulac View Post
      I've been trying to work on something similar, but I can't even get my project to build. Trying to extend UEditorBrushBuilder gives me a bunch of unresolved external symbol errors. How did you get around that?
      Did you add the dependency? UEditorBrushBuilder is part of UnrealEd module.

      Add that to you .build.cs
      Code:
      PublicDependencyModuleNames.AddRange(new string[] { "UnrealEd" });
      
      OR depending of what you need
      
      PrivateDependencyModuleNames.AddRange(new string[] { "UnrealEd" });
      DebugWidget - Helper for debugging in VR
      WidgetBox - Recycle your widgets the smart way
      NotificationBackbone - Send notifications via Feeds
      SteamWorkhop - Blueprint and Cpp
      UnrealPluginBuilder - Package via Drag&Drop
      RuntimeMeshImportExport - Sync and Async

      Comment


        #4
        Originally posted by Angus.Pei View Post
        Hello,I would like to use EditorBrushBuilder (CustBrushBuilder) to build a brush ,Following code:

        Code:
        bool UCustBrushBuilder::Build(UWorld * InWorld, ABrush * InBrush)
        {
        //TArray<FVector> LocBottomVertexs = OneVertexs;
        //LocBottomVertexs.Append(OtherVertexs);
        
        if(BottomVertexs.Num() < 3)
        return BadParameters(LOCTEXT("WallBottomFaceVertexsCount", "Invalid Vertex Count!"));
        
        BeginBrush(false, TEXT("CustBrush"));
        
        //int32 Direction = JugePolyOrderAndAoTo(BottomVertexs);
        BuildCustBrush(+1, BottomVertexs);
        return EndBrush(InWorld, InBrush);
        }
        Code:
        void UCustBrushBuilder::BuildCustBrush(int32 Direction, const TArray<FVector2D>& InBottomVertexs)
        {
        check(InBottomVertexs.Num() > 2);
        
        int32 BottomFaceVertexCount = InBottomVertexs.Num();
        
        int n = InBottomVertexs.Num() * 2;
        float Height = 30;
        for (int32 index = 0; index < n; ++index)
        {
        if (index < BottomFaceVertexCount)
        {
        Vertex3f(InBottomVertexs[index].X, InBottomVertexs[index].Y, 0);
        }
        else
        {
        Vertex3f(InBottomVertexs[index % BottomFaceVertexCount].X, InBottomVertexs[index % BottomFaceVertexCount].Y, Height);
        }
        }
        
        
        //ScalPoly(Vertices);
        
        //Bottom Face Begin
        PolyBegin(Direction, "Bottom");
        for (int32 BottomFaceIndex = BottomFaceVertexCount-1; BottomFaceIndex > -1; BottomFaceIndex--)
        {
        Polyi(BottomFaceIndex);
        }
        PolyEnd();
        //Bottom Face End
        
        //Each Face begin
        for (int32 EachFaceIndex = 0; EachFaceIndex < BottomFaceVertexCount; ++EachFaceIndex)
        {
        int32 FirstIndex = EachFaceIndex; // 0
        int32 SecIndex = EachFaceIndex + BottomFaceVertexCount;
        int32 ThirdIndex = (EachFaceIndex + 1) % BottomFaceVertexCount + BottomFaceVertexCount;
        int32 FourIndex = (EachFaceIndex + 1) % BottomFaceVertexCount;
        
        Poly4i(Direction, FourIndex, ThirdIndex, SecIndex, FirstIndex, "Each");
        }
        //Each Face End
        
        //Top Face Begin
        PolyBegin(Direction, "Top");
        for (int32 TopFaceIndex = BottomFaceVertexCount; TopFaceIndex < n; ++TopFaceIndex)
        {
        Polyi(TopFaceIndex);
        }
        PolyEnd();
        //Top Face End
        }
        BottomVertexs[5]
        - BottomVertexs Num=5 TArray<FVector2D,FDefaultAllocator>
        + [0] {X=-404.539948 Y=3105.41455 } FVector2D
        + [1] {X=-667.448730 Y=-754.085632 } FVector2D
        + [2] {X=4131.35010 Y=-544.531250 } FVector2D
        + [3] {X=1116.35742 Y=1687.62085 } FVector2D
        + [4] {X=4096.51123 Y=2377.76196 } FVector2D

        Error result :
        [ATTACH=CONFIG]140193[/ATTACH]

        Correct result :
        [ATTACH=CONFIG]140194[/ATTACH]

        why?
        /**
        * Base class of UnrealEd brush builders.
        *
        *
        * Tips for writing brush builders:
        *
        * - Always validate the user-specified and call BadParameters function
        * if anything is wrong, instead of actually building geometry.
        * If you build an invalid brush due to bad user parameters, you'll
        * cause an extraordinary amount of pain for the poor user.
        *
        * - When generating polygons with more than 3 vertices, BE SURE all the
        * polygon's vertices are coplanar! Out-of-plane polygons will cause
        * geometry to be corrupted.

        */
        UCLASS(abstract, hidecategories=(Object), MinimalAPI)
        class UBrushBuilder
        { ... }
        DebugWidget - Helper for debugging in VR
        WidgetBox - Recycle your widgets the smart way
        NotificationBackbone - Send notifications via Feeds
        SteamWorkhop - Blueprint and Cpp
        UnrealPluginBuilder - Package via Drag&Drop
        RuntimeMeshImportExport - Sync and Async

        Comment

        Working...
        X