mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-23 04:42:32 +00:00
[ruamoko] Allow entity model to be set
And add header and function definitions for scene to libcsqc.
This commit is contained in:
parent
3b926ec154
commit
2493ca71c7
6 changed files with 119 additions and 1 deletions
|
@ -137,6 +137,9 @@ bi_Model_Load (progs_t *pr, void *_res)
|
|||
model_t *
|
||||
Model_GetModel (progs_t *pr, int handle)
|
||||
{
|
||||
if (!handle) {
|
||||
return 0;
|
||||
}
|
||||
rua_model_resources_t *res = PR_Resources_Find (pr, "Model");
|
||||
rua_model_t *h = rua_model_handle_get (res, handle);
|
||||
|
||||
|
|
|
@ -38,7 +38,11 @@
|
|||
|
||||
#include "QF/cmem.h"
|
||||
#include "QF/hash.h"
|
||||
#include "QF/model.h"
|
||||
#include "QF/progs.h"
|
||||
#include "QF/render.h"
|
||||
|
||||
#include "QF/plugin/vid_render.h"
|
||||
|
||||
#include "QF/scene/entity.h"
|
||||
#include "QF/scene/scene.h"
|
||||
|
@ -209,6 +213,20 @@ bi_Entity_GetTransform (progs_t *pr, void *_res)
|
|||
R_ULONG (pr) = MAKE_ID (ent->transform->id, ent_id);
|
||||
}
|
||||
|
||||
static void
|
||||
bi_Entity_SetModel (progs_t *pr, void *_res)
|
||||
{
|
||||
rua_scene_resources_t *res = _res;
|
||||
pr_ulong_t ent_id = P_ULONG (pr, 0);
|
||||
pr_int_t model_id = P_INT (pr, 1);
|
||||
entity_t *ent = rua_entity_get (res, ent_id);
|
||||
model_t *model = Model_GetModel (pr, model_id);
|
||||
|
||||
R_RemoveEfrags (ent);
|
||||
ent->renderer.model = model;
|
||||
R_AddEfrags (&r_data->refdef->worldmodel->brush, ent);//FIXME r_data
|
||||
}
|
||||
|
||||
static void
|
||||
bi_Transform_ChildCount (progs_t *pr, void *_res)
|
||||
{
|
||||
|
@ -431,6 +449,7 @@ static builtin_t builtins[] = {
|
|||
bi(Scene_DestroyEntity, 1, p(ulong)),
|
||||
|
||||
bi(Entity_GetTransform, 1, p(ulong)),
|
||||
bi(Entity_SetModel, 2, p(ulong), p(int)),
|
||||
|
||||
bi(Transform_ChildCount, 1, p(ulong)),
|
||||
bi(Transform_GetChild, 2, p(ulong), p(int)),
|
||||
|
|
|
@ -16,8 +16,9 @@ ruamoko_include = \
|
|||
ruamoko/include/qw_physics.h \
|
||||
ruamoko/include/qw_sys.h \
|
||||
ruamoko/include/server.h \
|
||||
ruamoko/include/sound.h \
|
||||
ruamoko/include/scene.h \
|
||||
ruamoko/include/script.h \
|
||||
ruamoko/include/sound.h \
|
||||
ruamoko/include/stdlib.h \
|
||||
ruamoko/include/string.h \
|
||||
ruamoko/include/sv_sound.h \
|
||||
|
|
54
ruamoko/include/scene.h
Normal file
54
ruamoko/include/scene.h
Normal file
|
@ -0,0 +1,54 @@
|
|||
#ifndef __ruamoko_scene_h
|
||||
#define __ruamoko_scene_h
|
||||
|
||||
//FIXME this should be a native type so it can be used in math
|
||||
typedef struct {
|
||||
vec4 col[4];
|
||||
} mat4x4;
|
||||
|
||||
//FIXME need a handle type
|
||||
typedef struct { long handle; } scene_t;
|
||||
typedef struct { long handle; } entity_t;
|
||||
typedef struct { long handle; } transform_t;
|
||||
typedef struct { int handle; } model_t;
|
||||
|
||||
scene_t Scene_NewScene (void);
|
||||
void Scene_DeleteScene (scene_t scene);
|
||||
entity_t Scene_CreateEntity (scene_t scene);
|
||||
void Scene_DestroyEntity (entity_t ent);
|
||||
|
||||
transform_t Entity_GetTransform (entity_t ent);
|
||||
void Entity_SetModel (entity_t ent, model_t model);
|
||||
|
||||
unsigned Transform_ChildCount (transform_t transform);
|
||||
transform_t Transform_GetChild (transform_t transform,
|
||||
unsigned childIndex);
|
||||
void Transform_SetParent (transform_t transform, transform_t parent);
|
||||
transform_t Transform_GetParent (transform_t transform);
|
||||
void Transform_SetTag (transform_t transform, unsigned tag);
|
||||
unsigned Transform_GetTag (transform_t transform);
|
||||
mat4x4 Transform_GetLocalMatrix (transform_t transform);
|
||||
mat4x4 Transform_GetLocalInverse (transform_t transform);
|
||||
mat4x4 Transform_GetWorldMatrix (transform_t transform);
|
||||
mat4x4 Transform_GetWorldInverse (transform_t transform);
|
||||
vec4 Transform_GetLocalPosition (transform_t transform);
|
||||
void Transform_SetLocalPosition (transform_t transform, vec4 position);
|
||||
vec4 Transform_GetLocalRotation (transform_t transform);
|
||||
void Transform_SetLocalRotation (transform_t transform, vec4 rotation);
|
||||
vec4 Transform_GetLocalScale (transform_t transform);
|
||||
void Transform_SetLocalScale (transform_t transform, vec4 scale);
|
||||
vec4 Transform_GetWorldPosition (transform_t transform);
|
||||
void Transform_SetWorldPosition (transform_t transform, vec4 position);
|
||||
vec4 Transform_GetWorldRotation (transform_t transform);
|
||||
void Transform_SetWorldRotation (transform_t transform, vec4 rotation);
|
||||
vec4 Transform_GetWorldScale (transform_t transform);
|
||||
void Transform_SetLocalTransform (transform_t transform, vec4 scale,
|
||||
vec4 rotation, vec4 position);
|
||||
vec4 Transform_Forward (transform_t transform);
|
||||
vec4 Transform_Right (transform_t transform);
|
||||
vec4 Transform_Up (transform_t transform);
|
||||
|
||||
model_t Model_Load (string path);
|
||||
void Model_Unload (model_t model);
|
||||
|
||||
#endif//__ruamoko_scene_h
|
|
@ -65,6 +65,7 @@ ruamoko_lib_libcsqc_a_src= \
|
|||
ruamoko/lib/gib.r \
|
||||
ruamoko/lib/input.r \
|
||||
ruamoko/lib/mersenne.r \
|
||||
ruamoko/lib/scene.r \
|
||||
ruamoko/lib/key.r
|
||||
|
||||
ruamoko_lib_common_dep=$(call qcautodep,$(ruamoko_lib_common_src))
|
||||
|
|
40
ruamoko/lib/scene.r
Normal file
40
ruamoko/lib/scene.r
Normal file
|
@ -0,0 +1,40 @@
|
|||
#include <scene.h>
|
||||
|
||||
scene_t Scene_NewScene (void) = #0;
|
||||
void Scene_DeleteScene (scene_t scene) = #0;
|
||||
entity_t Scene_CreateEntity (scene_t scene) = #0;
|
||||
void Scene_DestroyEntity (entity_t ent) = #0;
|
||||
|
||||
transform_t Entity_GetTransform (entity_t ent) = #0;
|
||||
void Entity_SetModel (entity_t ent, model_t model) = #0;
|
||||
|
||||
unsigned Transform_ChildCount (transform_t transform) = #0;
|
||||
transform_t Transform_GetChild (transform_t transform,
|
||||
unsigned childIndex) = #0;
|
||||
void Transform_SetParent (transform_t transform, transform_t parent) = #0;
|
||||
transform_t Transform_GetParent (transform_t transform) = #0;
|
||||
void Transform_SetTag (transform_t transform, unsigned tag) = #0;
|
||||
unsigned Transform_GetTag (transform_t transform) = #0;
|
||||
mat4x4 Transform_GetLocalMatrix (transform_t transform) = #0;
|
||||
mat4x4 Transform_GetLocalInverse (transform_t transform) = #0;
|
||||
mat4x4 Transform_GetWorldMatrix (transform_t transform) = #0;
|
||||
mat4x4 Transform_GetWorldInverse (transform_t transform) = #0;
|
||||
vec4 Transform_GetLocalPosition (transform_t transform) = #0;
|
||||
void Transform_SetLocalPosition (transform_t transform, vec4 position) = #0;
|
||||
vec4 Transform_GetLocalRotation (transform_t transform) = #0;
|
||||
void Transform_SetLocalRotation (transform_t transform, vec4 rotation) = #0;
|
||||
vec4 Transform_GetLocalScale (transform_t transform) = #0;
|
||||
void Transform_SetLocalScale (transform_t transform, vec4 scale) = #0;
|
||||
vec4 Transform_GetWorldPosition (transform_t transform) = #0;
|
||||
void Transform_SetWorldPosition (transform_t transform, vec4 position) = #0;
|
||||
vec4 Transform_GetWorldRotation (transform_t transform) = #0;
|
||||
void Transform_SetWorldRotation (transform_t transform, vec4 rotation) = #0;
|
||||
vec4 Transform_GetWorldScale (transform_t transform) = #0;
|
||||
void Transform_SetLocalTransform (transform_t transform, vec4 scale,
|
||||
vec4 rotation, vec4 position) = #0;
|
||||
vec4 Transform_Forward (transform_t transform) = #0;
|
||||
vec4 Transform_Right (transform_t transform) = #0;
|
||||
vec4 Transform_Up (transform_t transform) = #0;
|
||||
|
||||
model_t Model_Load (string path) = #0;
|
||||
void Model_Unload (model_t model) = #0;
|
Loading…
Reference in a new issue