mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-28 13:09:51 +01:00
Compare commits
2
Commits
c6c0e02fea
...
c6f8c1e6a5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c6f8c1e6a5 | ||
|
|
333c310d5b |
No files matched your search
@@ -32,8 +32,8 @@ public class MonoGltf
|
||||
readonly SceneBuilder scene = new();
|
||||
readonly Dictionary<string, MaterialBuilder> materialMap = [];
|
||||
|
||||
readonly MaterialBuilder emptyMaterial = new("empty_material");
|
||||
readonly ExporterOptions options = new() { TextureFormat = ETextureFormat.Jpeg };
|
||||
static readonly MaterialBuilder emptyMaterial = new("empty_material");
|
||||
static readonly ExporterOptions options = new() { TextureFormat = ETextureFormat.Jpeg };
|
||||
public static readonly Dictionary<string, KnownChannel[]> knownChannels = new()
|
||||
{
|
||||
{ "BaseColor", [KnownChannel.BaseColor] },
|
||||
@@ -41,7 +41,8 @@ public class MonoGltf
|
||||
{ "RMAO", [KnownChannel.MetallicRoughness, KnownChannel.Occlusion] },
|
||||
// { "CDE", ?? },
|
||||
};
|
||||
readonly byte[] stubBytes = File.ReadAllBytes("../game/stub/small.png");
|
||||
static readonly byte[] stubBytes = File.ReadAllBytes("../game/stub/small.png");
|
||||
static readonly float scaleCorrection = 0.01f;
|
||||
|
||||
public MonoGltf(FStructFallback settings)
|
||||
{
|
||||
@@ -59,23 +60,43 @@ public class MonoGltf
|
||||
|
||||
if (settings.TryGet<UStaticMesh>(key, out var staticMesh))
|
||||
{
|
||||
AddMesh(key, parent, staticMesh);
|
||||
AddMesh(parent.CreateNode(key), staticMesh);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (settings.TryGet<USkeletalMesh>(key, out var skeletalMesh))
|
||||
{
|
||||
AddMesh(key, parent, skeletalMesh);
|
||||
AddMesh(parent.CreateNode(key), skeletalMesh);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (settings.TryGet<FStructFallback[]>(key, out var array))
|
||||
{
|
||||
var group = parent.CreateNode(key);
|
||||
|
||||
foreach (var item in array)
|
||||
{
|
||||
Traverse(item, group);
|
||||
Traverse(item, parent.CreateNode(key));
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (key == "BoneTransform")
|
||||
{
|
||||
var transform = settings.Get<FStructFallback>(key);
|
||||
|
||||
if (transform.TryGet<FQuat>("Rotation", out var rotation))
|
||||
{
|
||||
parent.WithLocalRotation(SwapYZ(rotation));
|
||||
}
|
||||
|
||||
if (transform.TryGet<FVector>("Translation", out var translation))
|
||||
{
|
||||
parent.WithLocalTranslation(SwapYZ(translation) * scaleCorrection);
|
||||
}
|
||||
|
||||
if (transform.TryGet<FVector>("Scale3D", out var scale))
|
||||
{
|
||||
parent.WithLocalScale(SwapYZ(scale));
|
||||
}
|
||||
|
||||
continue;
|
||||
@@ -87,10 +108,8 @@ public class MonoGltf
|
||||
}
|
||||
}
|
||||
|
||||
void AddMesh(string key, NodeBuilder parent, UObject mesh)
|
||||
void AddMesh(NodeBuilder meshNode, UObject mesh)
|
||||
{
|
||||
var meshNode = parent.CreateNode(key);
|
||||
|
||||
if (mesh is UStaticMesh staticMesh)
|
||||
{
|
||||
staticMesh.TryConvert(out var convertedStaticMesh);
|
||||
@@ -236,17 +255,17 @@ public class MonoGltf
|
||||
) PrepareTriangles(CMeshVertex vert1, CMeshVertex vert2, CMeshVertex vert3)
|
||||
{
|
||||
var v1 = new VertexPositionNormalTangent(
|
||||
SwapYZ(vert1.Position * 0.01f),
|
||||
SwapYZ(vert1.Position * scaleCorrection),
|
||||
SwapYZAndNormalize((FVector)vert1.Normal),
|
||||
SwapYZAndNormalize((Vector4)vert1.Tangent)
|
||||
);
|
||||
var v2 = new VertexPositionNormalTangent(
|
||||
SwapYZ(vert2.Position * 0.01f),
|
||||
SwapYZ(vert2.Position * scaleCorrection),
|
||||
SwapYZAndNormalize((FVector)vert2.Normal),
|
||||
SwapYZAndNormalize((Vector4)vert2.Tangent)
|
||||
);
|
||||
var v3 = new VertexPositionNormalTangent(
|
||||
SwapYZ(vert3.Position * 0.01f),
|
||||
SwapYZ(vert3.Position * scaleCorrection),
|
||||
SwapYZAndNormalize((FVector)vert3.Normal),
|
||||
SwapYZAndNormalize((Vector4)vert3.Tangent)
|
||||
);
|
||||
@@ -260,6 +279,11 @@ public class MonoGltf
|
||||
return res;
|
||||
}
|
||||
|
||||
public static Quaternion SwapYZ(Quaternion q)
|
||||
{
|
||||
return Quaternion.Normalize(new Quaternion(q.X, q.Z, q.Y, -q.W));
|
||||
}
|
||||
|
||||
public static FVector SwapYZAndNormalize(FVector vec)
|
||||
{
|
||||
var res = SwapYZ(vec);
|
||||
|
||||
@@ -9,7 +9,7 @@ const THETA_OFFSET = degToRad(-152);
|
||||
const LIGHT_DISTANCE = 13;
|
||||
const LIGHT_HEIGHT_0 = 4;
|
||||
const LIGHT_HEIGHT_1 = 2;
|
||||
const INTENSITY_0 = 3.5;
|
||||
const INTENSITY_0 = 2.5;
|
||||
const INTENSITY_1 = 1.5;
|
||||
const HEMISPHERE_INTENSITY = 2;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import { useTankGunModel } from "../../hooks/useTankGunModel";
|
||||
import { useTankHullModel } from "../../hooks/useTankHullModel";
|
||||
import { useTankTurretModel } from "../../hooks/useTankTurretModel";
|
||||
import { TankopediaLighting } from "../TankopediaLighting";
|
||||
import { SceneProps } from "../TankopediaSceneProps";
|
||||
import styles from "./index.module.css";
|
||||
|
||||
interface TankopediaSandboxProps {
|
||||
@@ -17,7 +18,6 @@ export function TankopediaSandbox({ parameters }: TankopediaSandboxProps) {
|
||||
<div className={styles.wrapper}>
|
||||
<div className={styles.sandbox}>
|
||||
<Canvas
|
||||
// scene={{ fog: new FogExp2("black", 0.05) }}
|
||||
camera={{ fov: 40 }}
|
||||
shadows
|
||||
className={styles.canvas}
|
||||
@@ -43,20 +43,16 @@ function Content({ parameters }: TankopediaSandboxProps) {
|
||||
<primitive object={hull} />
|
||||
</group>
|
||||
|
||||
<group position={[19.515463 / 100, 129.6958 / 100, 0.0039617573 / 100]}>
|
||||
<group>
|
||||
<primitive object={turret} />
|
||||
</group>
|
||||
|
||||
<group position={[154.39078 / 100, 178.7401 / 100, 0.11611016 / 100]}>
|
||||
<group>
|
||||
<primitive object={gun} />
|
||||
</group>
|
||||
|
||||
<TankopediaLighting />
|
||||
|
||||
<mesh receiveShadow rotation={[-Math.PI / 2, 0, 0]}>
|
||||
<planeGeometry args={[2 ** 9, 2 ** 9]} />
|
||||
<meshStandardMaterial color="black" />
|
||||
</mesh>
|
||||
<SceneProps />
|
||||
|
||||
<OrbitControls />
|
||||
</>
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
const SIZE = 2 ** 6;
|
||||
|
||||
export function SceneProps() {
|
||||
return (
|
||||
<mesh rotation={[-Math.PI / 2, 0, 0]} receiveShadow renderOrder={-1}>
|
||||
<planeGeometry args={[SIZE, SIZE]} />
|
||||
<meshStandardMaterial
|
||||
transparent
|
||||
opacity={0.5}
|
||||
color="black"
|
||||
roughness={1}
|
||||
metalness={0}
|
||||
/>
|
||||
</mesh>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user