x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Custom FComponentVisualizer

I want to write a small module to visualize some properties if my ASegment class in the editor. I already tried this tutorial: https://wiki.unrealengine.com/Component_Visualizers and got the basic module compiled and activated. I only got problems with the actual drawing and there aren't many useful references about this topic. So this is my custom visualizer class declaration:

  class ASegmentVisualizer : public FComponentVisualizer
     {
     public:
         ASegmentVisualizer();
         virtual void DrawVisualization(const UActorComponent* Component, const FSceneView* View, FPrimitiveDrawInterface* PDI) override;
     };
 
 and the implementation:
     ASegmentVisualizer::ASegmentVisualizer(){
         UE_LOG(CubeProjectModule, Warning, TEXT("SEGMENTVISUALIZER : CONSTRUCTOR"));
     }
 
 void ASegmentVisualizer::DrawVisualization(const UActorComponent* Component, const FSceneView* View, FPrimitiveDrawInterface* PDI)
 {
     //cast the component into the expected component type
     if (const ASegment* TargetingComponent = Cast<const ASegment>(Component))
     {
         const FVector Locaction = TargetingComponent->GetActorLocation();
         PDI->DrawPoint(TargetingComponent->GetActorLocation()+FVector(0,0,120), FLinearColor(255,0,0), 20.f, SDPG_Foreground);
         PDI->DrawLine(TargetingComponent->GetActorLocation() + FVector(0, 0, 500), TargetingComponent->GetActorLocation(), FLinearColor(1.0, 0, 0), 20.f, SDPG_Foreground);
 
         PDI->DrawLine(FVector(0, 0, 200), FVector(500, 0, 200), FLinearColor(1.0, 0, 0), 20.f, SDPG_Foreground);
 
     }
 
     UE_LOG(CubeProjectModule, Warning, TEXT("SEGMENTVISUALIZER : DRAW"));
 
 }

the constructor gets called, but not the drawing method.

Here is my StartupModule() procedure:

 void FCubeProjectModuleModule::StartupModule()
 {
     
     if (GUnrealEd != NULL)
     {
         TSharedPtr<FComponentVisualizer> Visualizer = MakeShareable(new ASegmentVisualizer());
 
         if (Visualizer.IsValid())
         {
             GUnrealEd->RegisterComponentVisualizer(ASegment::StaticClass()->GetFName(), Visualizer);
             Visualizer->OnRegister();
         }
 
     }
     UE_LOG(CubeProjectModule, Warning, TEXT("CubeProjectModule: Log Started"));
 
 }

I don't really know how to get this working. Has anyone any ideas?

Product Version: UE 4.8
Tags:
more ▼

asked Sep 01 '15 at 03:03 PM in C++ Programming

avatar image

maxim6394
16 8 11 14

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

It appears that you are trying to make a component visualizer for an actor. (ASegment appears to be an actor class both from the naming convention and the fact that you are calling GetActorLocation on one) As the name implies, they only work for components.

more ▼

answered Nov 15 '16 at 11:03 PM

avatar image

Teiwaz
639 26 29 57

avatar image LDOGLONDON Aug 10 '18 at 08:21 PM

Do the visualizers work for scene components? Also do you have to add the visualizer component onto the actor you trying to visualize or does it attach/visualize the component automatically?

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question