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"

Creating an Instanced Static Mesh without AddInstance()

I'm basically attempting to create an instanced static mesh instance in a more direct way than AddInstance(). This isn't just because I'm trying to cause myself pain; it's part of a bigger picture, but this is a minimum working example of my problem:

Header:

 #include "Runtime/Engine/Private/InstancedStaticMesh.h"
 #include "Runtime/Engine/Classes/Components/InstancedStaticMeshComponent.h"
 #include "Runtime/Engine/Public/StaticMeshResources.h"
 // Plus other things
 

cpp

 // other things
 
 // I make an UInstancedStaticMeshComponent* called ISMComp.
 
 // Set up for the instanced data
 FStaticMeshInstanceData* a = new FStaticMeshInstanceData(true, false);
 // I'm only adding a single instance, but I will be adding more later
 a->AllocateInstances(1, true); 
 
 // Create the SM data, and add a single element (eventually I'll have this in a loop)
 TArray<FInstancedStaticMeshInstanceData> smdata;
 auto NewInstanceData = new(smdata) FInstancedStaticMeshInstanceData(Test); // Test is just an FMatrix with sample coordinates/rotations
 ISMComp->PerInstanceSMData = smdata;
 
 ISMComp->InitPerInstanceRenderData(false, a);
 ISMComp->PerInstanceRenderData->UpdateFromPreallocatedData(ISMComp, *a, true);
 
 ISMComp->PerInstanceRenderData->InitResource(); // Complation Error is due to this line
 
 ISMComp->MarkRenderStateDirty();
 

This seems to make sense to me, but when I compile I get the painful error: CreatorInstrance.cpp.obj :

 error LNK2019: unresolved external symbol "__declspec(dllimport) void __cdecl BeginInitResource(class FRenderResource *)" (__imp_?BeginInitResource@@YAXPEAVFRenderResource@@@Z) referenced in function "public: void __cdecl UCreatorInstrance::Spawn(void)" (?Spawn@UCreatorInstrance@@QEAAXXZ)

I've tried compiling line by line, and it's due to the InitResource() call.

Thank you very much

Product Version: UE 4.19
Tags:
more ▼

asked Jul 17 '18 at 01:42 PM in C++ Programming

avatar image

WarpSpider833
7 1 1 3

avatar image WarpSpider833 Jul 18 '18 at 10:58 AM

Made some edits, a few of my variables were wrong. Problem still stands however.

(comments are locked)
10|2000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
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