8 public class ModelData : IComparable<ModelData> {
69 loader.PrepareModels(
this, camera, skipped, out
bool skip);
77 for (
int i = 0; i < modelsToDraw.Length; i++) {
78 modelsToDraw[i].Clear();
101 loader.RenderModels(
this, camera, drawOrder, skipped, out
bool skip);
152 "GetMaxInstancesCount",
195 modelData.Light = num.Value;
202 public virtual void DrawModels(
Camera camera, List<ModelData> modelsData,
float? alphaThreshold) {
213 modelShader.FogBottomTopDensity =
new Vector3(
219 modelShader.FogYMultiplier =
m_subsystemSky.VisibilityRangeYMultiplier;
224 if (alphaThreshold.HasValue) {
225 modelShader.AlphaThreshold = alphaThreshold.Value;
228 "ModelShaderParameter",
230 modLoader.ModelShaderParameter(modelShader, camera, modelsData, alphaThreshold);
235 "SetShaderParameter",
237 modLoader.SetShaderParameter(modelShader, camera);
241 foreach (
ModelData modelsDatum
in modelsData) {
242 bool skipDrawing =
false;
244 "OnModelDataDrawing",
246 modLoader.OnModelDataDrawing(modelsDatum, modelShader, camera,
this, out
bool skip);
254 float num = componentModel.Opacity ?? 1f;
256 modelShader.MaterialColor =
new Vector4(v * num, num);
257 modelShader.EmissionColor = componentModel.EmissionColor ??
Vector4.
Zero;
259 modelShader.DiffuseLightColor1 =
new Vector3(modelsDatum.
Light);
260 modelShader.DiffuseLightColor2 =
new Vector3(modelsDatum.
Light);
264 modelShader.Transforms.World,
268 componentModel.
Model,
283 "OnModelRendererDrawExtra",
285 modLoader.OnModelRendererDrawExtra(
this, modelsDatum, camera, alphaThreshold);
293 foreach (
ModelData modelData
in modelsData) {
296 Vector3 shadowPosition = modelData.ComponentBody.Position +
new Vector3(0f, 0.02f, 0f);
298 float shadowDiameter = 2.25f * (boundingBox.Max.X - boundingBox.
Min.
X);
313 p = !boneTransform.HasValue ? Vector3.Zero : boneTransform.Value.Translation +
new Vector3(0f, 0.9f, 0f);
324 if (!(num <= 1024f)) {
327 float num2 = MathF.Sqrt(num);
329 float num4 = shadowDiameter / 2f;
334 for (
int i = num5; i <= num7; i++) {
335 for (
int j = num6; j <= num8; j++) {
338 for (
int num11 = num9; num11 >= num10; num11--) {
344 for (
int k = 0; k < customCollisionBoxes.Length; k++) {
346 float num13 = boundingBox.Max.Y + num11;
347 if (shadowPosition.
Y - num13 > -0.5f) {
348 float num14 = camera.ViewPosition.Y - num13;
352 Vector3 p =
new(boundingBox.Min.X + i, num13 + num15, boundingBox.Min.Z + j);
353 Vector3 p2 =
new(boundingBox.Max.X + i, num13 + num15, boundingBox.Min.Z + j);
354 Vector3 p3 =
new(boundingBox.Max.X + i, num13 + num15, boundingBox.Max.Z + j);
355 Vector3 p4 =
new(boundingBox.Min.X + i, num13 + num15, boundingBox.Max.Z + j);
static readonly BlendState Opaque
static readonly BlendState AlphaBlend
static readonly DepthStencilState Default
static void DrawIndexed(PrimitiveType primitiveType, Shader shader, VertexBuffer vertexBuffer, IndexBuffer indexBuffer, int startIndex, int indicesCount)
static readonly RasterizerState CullNoneScissor
static readonly RasterizerState CullCounterClockwiseScissor
static SamplerState PointClamp
static int Min(int x1, int x2)
static float Saturate(float x)
static int Max(int x1, int x2)
static double FrameStartTime
float ObjectShadowStrength
virtual BoundingBox[] GetCustomCollisionBoxes(SubsystemTerrain terrain, int value)
virtual BoundingBox BoundingBox
virtual void CalculateIsVisible(Camera camera)
virtual void DrawExtras(Camera camera)
virtual ModelRenderingMode RenderingMode
virtual void CalculateAbsoluteBonesTransforms(Camera camera)
Matrix[] AbsoluteBoneTransformsForCamera
Texture2D TextureOverride
virtual ? Matrix GetBoneTransform(int boneIndex)
VertexBuffer VertexBuffer
static InstancedModelData GetInstancedModelData(Model model, int[] meshDrawOrders)
static readonly Vector3 DirectionToLight2
static readonly float LightAmbient
static ? float CalculateSmoothLight(SubsystemTerrain subsystemTerrain, Vector3 p)
static readonly Vector3 DirectionToLight1
static bool ObjectsShadowsEnabled
static string GetFast(string fname)
ComponentModel ComponentModel
int CompareTo(ModelData other)
ComponentBody ComponentBody
virtual void PrepareModel(ModelData modelData, Camera camera)
virtual void DrawInstancedModels(Camera camera, List< ModelData > modelsData, float? alphaThreshold)
PrimitivesRenderer3D PrimitivesRenderer
virtual void ShadowDraw(SubsystemShadows subsystemShadows, Camera camera, Vector3 shadowPosition, float shadowDiameter, float alpha)
PrimitivesRenderer3D m_primitivesRenderer
virtual ? float CalculateModelLight(ModelData modelData)
SubsystemTerrain m_subsystemTerrain
Dictionary< ComponentModel, ModelData > m_componentModels
ModelShader m_shaderOpaque
static ModelShader ShaderOpaque
static ModelShader ShaderAlphaTested
ModelShader m_shaderAlphaTested
virtual void Draw(Camera camera, int drawOrder)
override void OnEntityAdded(Entity entity)
SubsystemShadows m_subsystemShadows
SubsystemTimeOfDay m_subsystemTimeOfDay
List< ModelData >[] m_modelsToDraw
List< ModelData > m_modelsToPrepare
virtual void DrawModelsExtras(Camera camera, List< ModelData > modelsData)
override void Load(ValuesDictionary valuesDictionary)
override void OnEntityRemoved(Entity entity)
static bool DisableDrawingModels
virtual void DrawModels(Camera camera, List< ModelData > modelsData, float? alphaThreshold)
SubsystemSky m_subsystemSky
SubsystemTerrain m_subsystemTerrain
virtual void DrawShadowOverQuad(Vector3 p1, Vector3 p2, Vector3 p3, Vector3 p4, Vector3 shadowPosition, float shadowDiameter, float alpha)
static int ExtractContents(int value)
virtual int GetCellValueFast(int x, int y, int z)
static int ToCell(float x)
Component FindComponent(Type type, string name, bool throwOnError)
ValuesDictionary ValuesDictionary
static void HookAction(string HookName, Func< ModLoader, bool > action)
执行Hook
static readonly Matrix Identity
static float DistanceSquared(Vector3 v1, Vector3 v2)
static readonly Vector3 One
static Vector3 TransformNormal(Vector3 v, Matrix m)
static readonly Vector3 UnitY
static readonly Vector4 Zero