]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Added DP_CSQC_ENTITYMODELLIGHT extension (CSQC-updated modellight using modellight_...
authorvortex <vortex@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 12 Sep 2011 16:53:12 +0000 (16:53 +0000)
committervortex <vortex@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 12 Sep 2011 16:53:12 +0000 (16:53 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@11344 d7cf8633-e32d-0410-b094-e92efae38249

csprogs.c
csprogs.h
dpdefs/csprogsdefs.qc
gl_rmain.c
meshqueue.c
protocol.h
prvm_offsets.h
svvm_cmds.c

index 8a9bf1ddd96a9b999a780958680defe2f4a2df06..69483ae1961afd78955f11da1874629639f82087 100644 (file)
--- a/csprogs.c
+++ b/csprogs.c
@@ -370,13 +370,22 @@ qboolean CSQC_AddRenderEdict(prvm_edict_t *ed, int edictnum)
        if (renderflags & RF_USETRANSPARENTOFFSET)
                entrender->transparent_offset = PRVM_clientglobalfloat(transparent_offset);
 
+       // model light
+       if (renderflags & RF_MODELLIGHT)
+       {
+               if(PRVM_clientedictvector(ed, modellight_ambient)) VectorCopy(PRVM_clientedictvector(ed, modellight_ambient), entrender->modellight_ambient);
+               if(PRVM_clientedictvector(ed, modellight_diffuse)) VectorCopy(PRVM_clientedictvector(ed, modellight_diffuse), entrender->modellight_diffuse);
+               if(PRVM_clientedictvector(ed, modellight_dir))     VectorCopy(PRVM_clientedictvector(ed, modellight_dir), entrender->modellight_lightdir);
+               entrender->flags |= RENDER_CUSTOMIZEDMODELLIGHT;
+       }
+
        if(renderflags)
        {
-               if(renderflags & RF_VIEWMODEL)  entrender->flags |= RENDER_VIEWMODEL | RENDER_NODEPTHTEST;
-               if(renderflags & RF_EXTERNALMODEL)entrender->flags |= RENDER_EXTERIORMODEL;
-               if(renderflags & RF_NOCULL)             entrender->flags |= RENDER_NOCULL;
-               if(renderflags & RF_DEPTHHACK)  entrender->flags |= RENDER_NODEPTHTEST;
-               if(renderflags & RF_ADDITIVE)           entrender->flags |= RENDER_ADDITIVE;
+               if(renderflags & RF_VIEWMODEL) entrender->flags |= RENDER_VIEWMODEL | RENDER_NODEPTHTEST;
+               if(renderflags & RF_EXTERNALMODEL) entrender->flags |= RENDER_EXTERIORMODEL;
+               if(renderflags & RF_WORLDOBJECT) entrender->flags |= RENDER_WORLDOBJECT;
+               if(renderflags & RF_DEPTHHACK) entrender->flags |= RENDER_NODEPTHTEST;
+               if(renderflags & RF_ADDITIVE) entrender->flags |= RENDER_ADDITIVE;
        }
 
        c = (int)PRVM_clientedictfloat(ed, colormap);
index c82974b2a0862370040a39ca10b56b37d83fa359..a5f478c161ca308b77271219aa132b0f91a8a511 100644 (file)
--- a/csprogs.h
+++ b/csprogs.h
@@ -59,8 +59,9 @@
 #define RF_USEAXIS                     16      // When set, the entity will use the v_forward, v_right and v_up globals instead of it's angles field for orientation. Angles will be ignored compleatly.
                                                                // Note that to use this properly, you'll NEED to use the predraw function to set the globals.
 //#define RF_DOUBLESIDED               32
-#define RF_USETRANSPARENTOFFSET 64 // Allows QC to customize origin used for transparent sorting via transparent_origin global, helps to fix transparent sorting bugs on a very large entities
-#define RF_NOCULL                              128 // do not cull this entity using r_cullentities, for large outdoor entities (asteroids on the sky. etc)
+#define RF_USETRANSPARENTOFFSET 64   // Allows QC to customize origin used for transparent sorting via transparent_origin global, helps to fix transparent sorting bugs on a very large entities
+#define RF_WORLDOBJECT          128  // for large outdoor entities that should not be culled
+#define RF_MODELLIGHT           4096 // CSQC-set model light
 
 #define RF_FULLBRIGHT                  256
 #define RF_NOSHADOW                            512
index 2100605d5e2ca8f72e8abca72510bec52e465beb..1a08e588e0d97abbb084e63cc20e01121c883293 100644 (file)
@@ -734,13 +734,21 @@ float transparent_offset; // should be set before entity is added
 // example: transparent_offset = 1000000; // entity always appear on background of other transparents
 // note: offset is done in view forward axis
 
-// DP_CSQC_ENTITYNOCULL
+// DP_CSQC_ENTITYWORLDOBJECT
 // idea: VorteX
 // darkplaces implementation: VorteX
-const float RF_NOCULL = 128;
+const float RF_WORLDOBJECT = 128;
 // description: when renderflag is set, engine will not use culling methods for this entity, e.g. it will always be drawn
-// useful for large outdoor objects (like asteriods on sky horizont or sky models)
-// also useful when culling is done at CSQC side
+// useful for large outdoor objects (like asteroids on sky horizon or sky models)
+
+// DP_CSQC_ENTITYMODELLIGHT
+// idea: VorteX
+// darkplaces implementation: VorteX
+const float RF_MODELLIGHT = 4096;
+.vector modellight_ambient;
+.vector modellight_diffuse;
+.vector modellight_dir;
+// description: allows CSQC to override directional model lightning on entity
 
 // DP_CSQC_SETPAUSE
 // idea: VorteX
@@ -868,4 +876,4 @@ string(string command, float bindmap) findkeysforcommand = #610;
 //builtin definitions: (CSQC)
 float(string url, float id, string content_type, string delim, float buf, float keyid) crypto_uri_postbuf = #513;
 //description:
-//use -1 as buffer handle to justs end delim as postdata
+//use -1 as buffer handle to justs end delim as postdata
\ No newline at end of file
index 5da6228fbed2b06c54d67dc26b74ce4374a598ee..438c5e42c5b3779e0adb8a81c0f5480e4fa9de73 100644 (file)
@@ -4801,8 +4801,8 @@ static void R_View_UpdateEntityLighting (void)
        {
                ent = r_refdef.scene.entities[i];
 
-               // skip unseen models
-               if (!r_refdef.viewcache.entityvisible[i] && skipunseen)
+               // skip unseen models and models that updated by CSQC
+               if ((!r_refdef.viewcache.entityvisible[i] && skipunseen) || ent->flags & RENDER_CUSTOMIZEDMODELLIGHT)
                        continue;
 
                // skip bsp models
@@ -4958,7 +4958,7 @@ static void R_View_UpdateEntityVisible (void)
                        ent = r_refdef.scene.entities[i];
                        if (!(ent->flags & renderimask))
                        if (!R_CullBox(ent->mins, ent->maxs) || (ent->model && ent->model->type == mod_sprite && (ent->model->sprite.sprnum_type == SPR_LABEL || ent->model->sprite.sprnum_type == SPR_LABEL_SCALE)))
-                       if ((ent->flags & (RENDER_NODEPTHTEST | RENDER_VIEWMODEL)) || r_refdef.scene.worldmodel->brush.BoxTouchingVisibleLeafs(r_refdef.scene.worldmodel, r_refdef.viewcache.world_leafvisible, ent->mins, ent->maxs))
+                       if ((ent->flags & (RENDER_NODEPTHTEST | RENDER_WORLDOBJECT | RENDER_VIEWMODEL)) || r_refdef.scene.worldmodel->brush.BoxTouchingVisibleLeafs(r_refdef.scene.worldmodel, r_refdef.viewcache.world_leafvisible, ent->mins, ent->maxs))
                                r_refdef.viewcache.entityvisible[i] = true;
                }
        }
@@ -4979,7 +4979,7 @@ static void R_View_UpdateEntityVisible (void)
                        if (!r_refdef.viewcache.entityvisible[i])
                                continue;
                        ent = r_refdef.scene.entities[i];
-                       if(!(ent->flags & (RENDER_VIEWMODEL | RENDER_NOCULL | RENDER_NODEPTHTEST)) && !(ent->model && (ent->model->name[0] == '*')))
+                       if(!(ent->flags & (RENDER_VIEWMODEL | RENDER_WORLDOBJECT | RENDER_NODEPTHTEST)) && !(ent->model && (ent->model->name[0] == '*')))
                        {
                                samples = ent->entitynumber ? r_cullentities_trace_samples.integer : r_cullentities_trace_tempentitysamples.integer;
                                if (samples < 0)
@@ -7673,8 +7673,9 @@ void R_tcMod_ApplyToMatrix(matrix4x4_t *texmatrix, q3shaderinfo_layer_tcmod_t *t
                        Matrix4x4_CreateTranslate(&matrix, 0, 0, 0);
                        break;
                case Q3TCMOD_ROTATE:
+                       f = tcmod->parms[0] * rsurface.shadertime;
                        Matrix4x4_CreateTranslate(&matrix, 0.5, 0.5, 0);
-                       Matrix4x4_ConcatRotate(&matrix, tcmod->parms[0] * rsurface.shadertime, 0, 0, 1);
+                       Matrix4x4_ConcatRotate(&matrix, (f / 360 - floor(f / 360)) * 360, 0, 0, 1);
                        Matrix4x4_ConcatTranslate(&matrix, -0.5, -0.5, 0);
                        break;
                case Q3TCMOD_SCALE:
@@ -7695,7 +7696,7 @@ void R_tcMod_ApplyToMatrix(matrix4x4_t *texmatrix, q3shaderinfo_layer_tcmod_t *t
                        Matrix4x4_CreateTranslate(&matrix, (idx % w) / tcmod->parms[0], (idx / w) / tcmod->parms[1], 0);
                        break;
                case Q3TCMOD_STRETCH:
-                       f = 1.0f / R_EvaluateQ3WaveFunc(tcmod->wavefunc, tcmod->waveparms);
+                       f = 1.0f / R_EvaluateQ3WaveFunc(tcmod->wavefunc, tcmod->waveparms);ClientTime
                        Matrix4x4_CreateFromQuakeEntity(&matrix, 0.5f * (1 - f), 0.5 * (1 - f), 0, 0, 0, 0, f);
                        break;
                case Q3TCMOD_TRANSFORM:
index 34334e6d1ff9ba3b590f038129d8dbde789d5b41..e0e1e8c7091c7765783b311010f8da3399a1e3c2 100644 (file)
@@ -53,7 +53,10 @@ void R_MeshQueue_AddTransparent(const vec3_t center, void (*callback)(const enti
        mq->ent = ent;
        mq->surfacenumber = surfacenumber;
        mq->rtlight = rtlight;
-       mq->dist = DotProduct(center, r_refdef.view.forward) - mqt_viewplanedist;
+       if (ent && (ent->flags & RENDER_WORLDOBJECT))
+               mq->dist = mqt_viewmaxdist;
+       else
+               mq->dist = DotProduct(center, r_refdef.view.forward) - mqt_viewplanedist;
        mq->next = NULL;
        mqt_viewmaxdist = max(mqt_viewmaxdist, mq->dist);
 }
index c101665d53f93ffb0538ed8a3ac58f0724e36408..50a5215b826b7e4db30b9709becccf230b28099a 100644 (file)
@@ -332,7 +332,7 @@ void Protocol_Names(char *buffer, size_t buffersize);
 #define RENDER_EXTERIORMODEL 8
 #define RENDER_LOWPRECISION 16 // send as low precision coordinates to save bandwidth
 #define RENDER_COLORMAPPED 32
-#define RENDER_NOCULL 64 // do not cull this entity with r_cullentities
+#define RENDER_WORLDOBJECT 64 // do not cull this entity with r_cullentities
 #define RENDER_COMPLEXANIMATION 128
 
 #define RENDER_SHADOW 65536 // cast shadow
@@ -343,6 +343,7 @@ void Protocol_Names(char *buffer, size_t buffersize);
 #define RENDER_NODEPTHTEST 1048576
 #define RENDER_ADDITIVE 2097152
 #define RENDER_DOUBLESIDED 4194304
+#define RENDER_CUSTOMIZEDMODELLIGHT 4096
 
 #define MAX_FRAMEGROUPBLENDS 4
 typedef struct framegroupblend_s
index 1bd6c5e16f197bc79d1af5b0ffbb59a4d93a3d94..cfcf220ab5c99a9521ac9883edb0d808e61f6683 100644 (file)
@@ -68,6 +68,9 @@ PRVM_DECLARE_clientfieldvector(oldorigin)
 PRVM_DECLARE_clientfieldvector(origin)
 PRVM_DECLARE_clientfieldvector(size)
 PRVM_DECLARE_clientfieldvector(velocity)
+PRVM_DECLARE_clientfieldvector(modellight_ambient)
+PRVM_DECLARE_clientfieldvector(modellight_diffuse)
+PRVM_DECLARE_clientfieldvector(modellight_dir)
 PRVM_DECLARE_clientfunction(CSQC_ConsoleCommand)
 PRVM_DECLARE_clientfunction(CSQC_Ent_Remove)
 PRVM_DECLARE_clientfunction(CSQC_Ent_Spawn)
@@ -361,6 +364,9 @@ PRVM_DECLARE_field(userwavefunc_param2)
 PRVM_DECLARE_field(userwavefunc_param3)
 PRVM_DECLARE_field(v_angle)
 PRVM_DECLARE_field(velocity)
+PRVM_DECLARE_field(modellight_ambient)
+PRVM_DECLARE_field(modellight_diffuse)
+PRVM_DECLARE_field(modellight_dir)
 PRVM_DECLARE_field(view_ofs)
 PRVM_DECLARE_field(viewmodelforclient)
 PRVM_DECLARE_field(viewzoom)
index f5d3293b35977745f4db73c26f2e5fa0a306d453..30d17453fafedb0577399490d02c604dbc630e7c 100644 (file)
@@ -21,7 +21,8 @@ const char *vm_sv_extensions =
 "DP_CON_STARTMAP "
 "DP_CRYPTO "
 "DP_CSQC_BINDMAPS "
-"DP_CSQC_ENTITYNOCULL "
+"DP_CSQC_ENTITYWORLDOBJECT "
+"DP_CSQC_ENTITYMODELLIGHT "
 "DP_CSQC_ENTITYTRANSPARENTSORTING_OFFSET "
 "DP_CSQC_MULTIFRAME_INTERPOLATION "
 "DP_CSQC_BOXPARTICLES "