81 lines
2.1 KiB
C#
81 lines
2.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Drawing;
|
|
using NBC.Asset;
|
|
using Newtonsoft.Json;
|
|
using UnityEngine;
|
|
using Color = UnityEngine.Color;
|
|
|
|
namespace NBF
|
|
{
|
|
[Serializable]
|
|
public class ModelViewerSettings
|
|
{
|
|
//物体设置
|
|
public Vector3 objectPosition;
|
|
public Vector3 objectRotation;
|
|
public Vector3 objectScale;
|
|
|
|
//摄像机设置
|
|
public Vector3 cameraPosition;
|
|
public Vector3 cameraTarget;
|
|
public bool autoPosition;
|
|
public bool autoScale;
|
|
public bool cameraOrtho;
|
|
public float cameraFov;
|
|
public float cameraSize;
|
|
public float camerasScaleFactor;
|
|
public float perspLastScale;
|
|
|
|
//灯光设置
|
|
public Color lightColour;
|
|
public Vector3 lightDir;
|
|
public float lightIntensity;
|
|
public Color ambientLightColour;
|
|
|
|
|
|
public static ModelViewerSettings Load(int id)
|
|
{
|
|
var configAsset = Assets.Load<TextAsset>($"Assets/ResRaw/config/Viewer/{id}");
|
|
if (configAsset != null)
|
|
{
|
|
return JsonConvert.DeserializeObject<ModelViewerSettings>(configAsset.text);
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
public ModelViewerSettings()
|
|
{
|
|
SetDefValues();
|
|
}
|
|
|
|
public ModelViewerSettings(Shader objRenderShader, string rapidIconRootFolder, GameObject rootObject)
|
|
{
|
|
SetDefValues();
|
|
}
|
|
|
|
private void SetDefValues()
|
|
{
|
|
objectPosition = Vector3.zero;
|
|
objectRotation = Vector3.zero;
|
|
objectScale = Vector3.one;
|
|
autoPosition = true;
|
|
|
|
|
|
cameraPosition = new Vector3(1, Mathf.Sqrt(2), 1);
|
|
perspLastScale = 1;
|
|
cameraOrtho = false;
|
|
cameraFov = 60;
|
|
cameraSize = 5;
|
|
camerasScaleFactor = 1;
|
|
cameraTarget = Vector3.zero;
|
|
autoScale = true;
|
|
|
|
ambientLightColour = Color.gray;
|
|
lightColour = Color.white;
|
|
lightDir = new Vector3(50, -30, 0);
|
|
lightIntensity = 1;
|
|
}
|
|
}
|
|
} |