载入中...
搜索中...
未找到
ObjectBuildLayer.h
浏览该文件的文档.
1#pragma once
2
3#include "common/Result.h"
4#include "procgen/PointSet.h"
5
6#include <cstdint>
7#include <string>
8#include <vector>
9
10namespace eve::procgen {
11
14 float minPitch = 0.f;
15 float maxPitch = 0.f;
16 float minYaw = 0.f;
17 float maxYaw = 0.f;
18 float minRoll = 0.f;
19 float maxRoll = 0.f;
20 float minScaleX = 1.f;
21 float maxScaleX = 1.f;
22 float minScaleY = 1.f;
23 float maxScaleY = 1.f;
24 float minScaleZ = 1.f;
25 float maxScaleZ = 1.f;
26 bool uniformScale = false;
27};
28
38public:
40 [[nodiscard]] Result<void> addAsset(std::string asset, float weight);
41 void clearAssets();
42
44 void setSeed(std::uint32_t seed) noexcept;
46 void setLayerOffset(float x, float y, float z) noexcept;
48 [[nodiscard]] Result<void> setLayerScale(float x, float y, float z);
50 [[nodiscard]] Result<void> setPositionRadius(float radius);
52 [[nodiscard]] Result<void> setRandomTransform(const ObjectTransformRange& range);
54 [[nodiscard]] Result<void> setRandomRotation(float minPitch, float maxPitch, float minYaw, float maxYaw,
55 float minRoll, float maxRoll);
57 [[nodiscard]] Result<void> setRandomScale(float minX, float maxX, float minY, float maxY, float minZ, float maxZ,
58 bool uniform);
60 [[nodiscard]] Result<void> setOrientation(float cellSize, float yawOffset, bool invert);
61 void disableOrientation() noexcept;
63 void setPlaceOnTop(bool enabled, bool useLowest, float topOffset) noexcept;
64
72 [[nodiscard]] Result<void> addChildRule(std::string asset, int count, float radius,
75 [[nodiscard]] Result<void> addChild(std::string asset, int count, float radius, float minScale, float maxScale,
76 float minYaw, float maxYaw);
78 void clearChildRules();
79
88 [[nodiscard]] Result<PointSet> build(const PointSet& source, const PointSet* orientation = nullptr) const;
90 [[nodiscard]] std::string serializeDefinition() const;
92 [[nodiscard]] Result<void> deserializeDefinition(std::string_view definition);
93
94private:
95 struct Asset {
96 std::string id;
97 float weight = 1.f;
98 };
99 struct ChildRule {
100 std::string asset;
101 int count = 0;
102 float radius = 0.f;
103 ObjectTransformRange transform;
104 };
105
106 std::vector<Asset> assets_;
107 std::vector<ChildRule> children_;
108 ObjectTransformRange transform_;
109 std::uint32_t seed_ = 1;
110 float offsetX_ = 0.f;
111 float offsetY_ = 0.f;
112 float offsetZ_ = 0.f;
113 float scaleX_ = 1.f;
114 float scaleY_ = 1.f;
115 float scaleZ_ = 1.f;
116 float positionRadius_ = 0.f;
117 bool orient_ = false;
118 bool invertOrientation_ = false;
119 float orientationCellSize_ = 1.f;
120 float orientationYawOffset_ = 0.f;
121 bool placeOnTop_ = false;
122 bool useLowest_ = false;
123 float topOffset_ = 0.f;
124};
125
126} // namespace eve::procgen
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
float z
Definition AnimClip.cpp:738
#define EVENGINE_API_DOMAINS
Definition Export.h:110
Range range
float radius
std::string id
Definition PlayHost.cpp:108
std::uint32_t seed
Definition PointSet.cpp:807
Move-only, checked operation results for the common layer.
std::uint32_t count
LogicalId definition
const UnitySourceAsset & source
Move-only operation result carrying either a value or Status.
Definition Result.h:155
Deterministic TileWorldCreator-style object build layer.
Script-friendly collection of attributed 3D samples.
Definition PointSet.h:59
bool enabled
Random transform interval used by one object build rule.