The folder containing the Unreal project must have the same name as the project itself (repounreal) for compilation to succeed. [1]
The Instanced Materials assets are specified as FSoftObjectPath
s, so it would also be possible to expose this in the Editor and use the same loading functionality [2].
The meshes are created as Procedural Mesh Components. Each Procedural Mesh Component instance has its own Dynamic Material Instance. Procedural Mesh Component instances are created on-demand and added to a single ARepoSupermeshActor
.
The plugin can show a number of statistics, such as the amount of data downloaded, using the Unreal stats system. To see these, give the console command STAT Repo3D
. Give the command again to hide the stats.
The sample project creates a new AGameModeBase
(ArepounrealGameModeBase
) and APlayerController
(ArepounrealPlayerController
). The PlayerController is the class that determines how a user interacts with Unreal. The ArepounrealGameModeBase
sets the ArepounrealPlayerController
as the default player controller. The ArepounrealGameModeBase
is set as the default Game Mode in the Project Settings (Project Settings -> Project -> Maps & Modes -> Default GameMode).
The ArepounrealPlayerController
binds to an action mapping called OnMouseClick
. Action Mappings are set-up in Project Settings -> Engine -> Input.
On the action, it casts a ray from the cursor location on the screen into the world using UWorld::LineTraceSingleByChannel and returns the hit geometry. If the geometry has a Repo Actor, then the identity of the individual object hit can be returned from a dedicated API provided by the plugin (IRepoTraceable::GetMeshIdFromFaceIndex
).
The maximum selection distance is set by the Trace Distance
parameter under Mouse Interface
on the PlayerController
in the Editor. (The APlayerController::HitResultTraceDistance
member, programmatically.) The default value is 100000.0.
The plugin creates a highly optimised scene. The properties of individual objects are stored in maps. Each map is managed by a URepoSupermeshMapComponent
. These maps can be accessed by Materials to control the appearance of individual objects. You can have as many maps as needed to support your application.
The inbuilt ARepoSupermeshActor
includes one map: DiffuseMap, to control object colour. The sample project creates a subclass of the inbuilt actor, ASampleRepoSupermeshActor
, which adds a second map: HighlightMap.
Parameters can be accessed by calling URepoSupermeshMapComponent::SetParameter()
/GetParameter()
. The parameters are set by object Id.
In the sample project, the Id is returned by IRepoTraceable::GetMeshIdFromFaceIndex
on a mouse click, and used to invert a parameter in the HighlightMap.
The plugin is also configured to use RepoHighlightMaterial
and RepoHighlightMaterialTranslucent
samples when importing the model. These materials are like RepoMaterial
and RepoMaterialTranslucent
, but they also read the HighlightMap and change the colour of the object, depending on the object's parameter value in that map.
In Materials, parameter maps should be read using the 3D Repo Sampler
custom node. Copy this node into your own Materials to access URepoSupermeshMapComponent
maps.
In addition to the RepoHighlightMaterial
and RepoHighlightMaterialTranslucent
, minimal working material samples are included (RepoMaterial
and RepoMaterialTranslucent
). All sample materials have back-face culling off. Turn on backface culling by unchecking the Two-Sided flag for the material.
## References
[1][https://answers.unrealengine.com/questions/669760/unable-to-compile-new-actor-classes.html]
[2]https://docs.unrealengine.com/en-US/Programming/Assets/AsyncLoading/index.html