Browse Source
First bits of entity logic: assign alias models, update transform and animation, remove entity. Still lots of problems to solve, but it's starting to do something.
console
First bits of entity logic: assign alias models, update transform and animation, remove entity. Still lots of problems to solve, but it's starting to do something.
console
19 changed files with 279 additions and 9 deletions
-
5Assets/Scripts/Data/QExtensions.cs
-
62Assets/Scripts/Game/Entity.cs
-
3Assets/Scripts/Game/Entity.cs.meta
-
15Assets/Scripts/Game/GameAssets.cs
-
65Assets/Scripts/Game/GameState.cs
-
36Assets/Scripts/Modules/GameModule.Interop.cs
-
33Assets/Scripts/Modules/GameModule.cs
-
6Assets/Scripts/Modules/RenderModule.cs
-
2Assets/Scripts/Support/AliasModel.cs
-
2Assets/Scripts/UniQuake.Interop.cs
-
4Assets/Scripts/UniQuake.cs
-
3engine/Quake/cl_main.c
-
7engine/Quake/cl_parse.c
-
4engine/Quake/client.h
-
29engine/UniQuake/game_uniquake.c
-
3engine/UniQuake/uniquake.c
-
3engine/UniQuake/uniquake.h
-
1engine/Windows/VisualStudio/uniquake.vcxproj
-
3engine/Windows/VisualStudio/uniquake.vcxproj.filters
@ -0,0 +1,62 @@ |
|||||
|
using UnityEngine; |
||||
|
using UnityEngine.Rendering; |
||||
|
|
||||
|
public class Entity |
||||
|
{ |
||||
|
private readonly int entityNum; |
||||
|
|
||||
|
private GameObject gameObject; |
||||
|
private SkinnedMeshRenderer meshRenderer; |
||||
|
|
||||
|
private AliasModel aliasModel; |
||||
|
|
||||
|
public Entity(int entityNum) |
||||
|
{ |
||||
|
this.entityNum = entityNum; |
||||
|
CreateGameObject(); |
||||
|
} |
||||
|
|
||||
|
private void CreateGameObject() |
||||
|
{ |
||||
|
gameObject = new GameObject($"Entity_{entityNum}"); |
||||
|
|
||||
|
// DEBUG - we'll want to instantiate a prefab and assign materials from a preset collection
|
||||
|
meshRenderer = gameObject.AddComponent<SkinnedMeshRenderer>(); |
||||
|
meshRenderer.material = new Material(Shader.Find("Universal Render Pipeline/Simple Lit")); |
||||
|
meshRenderer.shadowCastingMode = ShadowCastingMode.Off; |
||||
|
meshRenderer.receiveShadows = false; |
||||
|
meshRenderer.lightProbeUsage = LightProbeUsage.Off; |
||||
|
meshRenderer.reflectionProbeUsage = ReflectionProbeUsage.Off; |
||||
|
} |
||||
|
|
||||
|
public void Destroy() |
||||
|
{ |
||||
|
Object.Destroy(gameObject); |
||||
|
} |
||||
|
|
||||
|
public void SetAliasModel(AliasModel model) |
||||
|
{ |
||||
|
aliasModel = model; |
||||
|
|
||||
|
// Set a default pose based on the first animation frame
|
||||
|
UpdateAnimation(0); |
||||
|
} |
||||
|
|
||||
|
public void UpdateAnimation(int frameNum) |
||||
|
{ |
||||
|
if (aliasModel != null) |
||||
|
{ |
||||
|
aliasModel.Animate(frameNum, out Mesh mesh, out float blendWeight); |
||||
|
meshRenderer.sharedMesh = mesh; |
||||
|
|
||||
|
if (mesh.blendShapeCount > 0) |
||||
|
meshRenderer.SetBlendShapeWeight(0, blendWeight); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public void SetTransform(Vector3 position, Quaternion rotation) |
||||
|
{ |
||||
|
gameObject.transform.position = position; |
||||
|
gameObject.transform.rotation = rotation; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,3 @@ |
|||||
|
fileFormatVersion: 2 |
||||
|
guid: e876769ea29c4d10bfa6b7eea48009a3 |
||||
|
timeCreated: 1625824889 |
||||
@ -0,0 +1,29 @@ |
|||||
|
#include "uniquake.h" |
||||
|
|
||||
|
#include "../Quake/quakedef.h" |
||||
|
|
||||
|
typedef struct unity_gamecalls_s |
||||
|
{ |
||||
|
void *target; |
||||
|
|
||||
|
void(*SetEntityModel)(void *target, int entityNum, const char *modelName, int frame); |
||||
|
void(*SetEntityTransform)(void *target, int entityNum, vec3_t origin, vec3_t angles); |
||||
|
void(*RemoveEntity)(void *target, int entityNum); |
||||
|
} unity_gamecalls_t; |
||||
|
|
||||
|
const unity_gamecalls_t *unity_gamecalls; |
||||
|
|
||||
|
void UQ_Game_SetEntityModel(int entityNum, const char *modelName, int frame) |
||||
|
{ |
||||
|
unity_gamecalls->SetEntityModel(unity_gamecalls->target, entityNum, modelName, frame); |
||||
|
} |
||||
|
|
||||
|
void UQ_Game_SetEntityTransform(int entityNum, vec3_t origin, vec3_t angles) |
||||
|
{ |
||||
|
unity_gamecalls->SetEntityTransform(unity_gamecalls->target, entityNum, origin, angles); |
||||
|
} |
||||
|
|
||||
|
void UQ_Game_RemoveEntity(int entityNum) |
||||
|
{ |
||||
|
unity_gamecalls->RemoveEntity(unity_gamecalls->target, entityNum); |
||||
|
} |
||||
Write
Preview
Loading…
Cancel
Save
Reference in new issue