载入中...
搜索中...
未找到
FoliageCluster.cpp
浏览该文件的文档.
24V3 cross(V3 a, V3 b) { return {a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x}; }
31float randomRange(std::mt19937 &rng, float lo, float hi) { return std::uniform_real_distribution<float>(lo, hi)(rng); }
60std::vector<V2> samplePlaneCentres(std::uint32_t seed, float radius, float minDistance, int maxLeaves) {
68 const float capSpacing = std::sqrt(2.f * kPi * radius * radius / (std::sqrt(3.f) * float(maxLeaves)));
72 const int squareBudget = int(1.3f * float(maxLeaves) * squareArea / std::max(kPi * radius * radius, 1e-6f)) + 8;
89void addLeafCard(MeshBuild &out, V3 center, V3 right, V3 forward, float size, float aspect, float roll, float u0,
100 out.addVertex(p.x, p.y, p.z, n.x, n.y, n.z, u0 + (xs[i] + 0.5f) * (u1 - u0), v0 + (ys[i] + 0.5f) * (v1 - v0));
159 cap ? randomRange(rng, 0.f, 2.f * kPi) : yawPhase + (float(index) + randomRange(rng, 0.2f, 0.8f)) * yawStep;
162 const float tilt = cap ? ((index & 1) ? 1.f : -1.f) * randomRange(rng, 62.f, 86.f) * kPi / 180.f
164 const V3 planeNormal{std::sin(yaw) * std::cos(tilt), std::sin(tilt), std::cos(yaw) * std::cos(tilt)};
174 center, add(mul(right, std::cos(offsetAngle) * offsetR), mul(forward, std::sin(offsetAngle) * offsetR)));
176 const std::vector<V2> centers = samplePlaneCentres(desc.seed ^ (std::uint32_t(index + 1) * 2654435761u),
CPU triangle mesh from procedural mesh recipes (e.g. marching cubes). Positions/normals are xyz-packe...
Definition MeshBuild.h:20
@ PointSet
ForceVector add(ForceVector a, ForceVector b)
Definition ForceMath.h:13
Definition EvpackPointGraphLoader.h:12
int addFoliageCluster(MeshBuild &out, const FoliageClusterDesc &desc)
Append one blue-noise leaf cluster to a mesh.
Definition FoliageCluster.cpp:112
PointSet poissonDiskPoints(int width, int depth, float radius, uint32_t seed, int maxPoints)
Bridson blue-noise (Poisson disk) samples in a width x depth area (XZ, y=0).
Definition PointSet.cpp:506
Recipe for one stylized leaf cluster ("foliage card bundle").
Definition FoliageCluster.h:24