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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

Make other types (shared Pointer) accessible in blueprint?

For blueprint variables I can choose a lot of types. But how can I choose other types than the native ones (int, float etc) and UObjects (class or reference etc).

For example: I have a plugin where I can access PointClouds using the Point Cloud Library (PCL). So I use the pcl´s pointcloud type for some algorithms. Now the idea is to have a shared pointer so I can access the type within a blueprint (and assign it to a variable eg).

My first attempt was to encapsulate the pointer within a USTRUCT, but that does not compile:

 USTRUCT()
 struct FPointCloudPointer {
     GENERATED_BODY()
     pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr cloud;    // pcl shared pointer
 };
 
 
 UCLASS( ClassGroup=(Custom), meta=(BlueprintSpawnableComponent) )
 class POINTCLOUDRENDEREREDITOR_API UPointCloudGeneratorComponent : public UActorComponent
 {
     GENERATED_BODY()
 
 public:    
     ...
     UFUNCTION(BlueprintCallable, Category = "PCL")
         FPointCloudPointer GetPointCloud();
    ....
 }

Any suggestions please?

Product Version: UE 4.18
Tags:
more ▼

asked Oct 15 '18 at 12:28 PM in C++ Programming

avatar image

DaKenpachi
79 4 6 10

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

1 answer: sort voted first

So, after a bit trying I decided to change it to an interface kind of access.

I wrote a UInterface class (so it can be seen in Blueprints), which tells the inheritand class to provide a getter function to the pointcloud pointer:

 UINTERFACE(BlueprintType)
 class POINTCLOUDRENDEREREDITOR_API UPointCloudFactoryInterface : public UInterface
 {
     GENERATED_BODY()
 };
 
 
 class IPointCloudFactoryInterface
 {
     GENERATED_BODY()
 
 public:
 
     virtual pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr GetPointCloud() const = 0;
 };

So, one component has a UFunction consuming those interfaces:

 UFUNCTION(BlueprintCallable, Category = "PCL")
 void SetPointCloudSources(TScriptInterface<IPointCloudFactoryInterface> TargetCloudFactory, TScriptInterface<IPointCloudFactoryInterface> SourceCloudFactory)
 {
    targetPointCloud = TargetCloudFactory->GetPointCloud();
    sourcePointCloud = SourceCloudFactory->GetPointCloud();
 }

And in my Blueprint I can choose any component that implements the interface can be chosen:

alt text

more ▼

answered Oct 19 '18 at 09:13 AM

avatar image

DaKenpachi
79 4 6 10

(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