doom3-gpl
Doom 3 GPL source release
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Anim_Testmodel.cpp
Go to the documentation of this file.
1 /*
2 ===========================================================================
3 
4 Doom 3 GPL Source Code
5 Copyright (C) 1999-2011 id Software LLC, a ZeniMax Media company.
6 
7 This file is part of the Doom 3 GPL Source Code (?Doom 3 Source Code?).
8 
9 Doom 3 Source Code is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 Doom 3 Source Code is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 along with Doom 3 Source Code. If not, see <http://www.gnu.org/licenses/>.
21 
22 In addition, the Doom 3 Source Code is also subject to certain additional terms. You should have received a copy of these additional terms immediately following the terms and conditions of the GNU General Public License which accompanied the Doom 3 Source Code. If not, please request a copy in writing from id Software at the address below.
23 
24 If you have questions concerning this license or the applicable additional terms, you may contact in writing id Software LLC, c/o ZeniMax Media Inc., Suite 120, Rockville, Maryland 20850 USA.
25 
26 ===========================================================================
27 */
28 /*
29 =============================================================================
30 
31  MODEL TESTING
32 
33 Model viewing can begin with either "testmodel <modelname>"
34 
35 The names must be the full pathname after the basedir, like
36 "models/weapons/v_launch/tris.md3" or "players/male/tris.md3"
37 
38 Extension will default to ".ase" if not specified.
39 
40 Testmodel will create a fake entity 100 units in front of the current view
41 position, directly facing the viewer. It will remain immobile, so you can
42 move around it to view it from different angles.
43 
44  g_testModelRotate
45  g_testModelAnimate
46  g_testModelBlend
47 
48 =============================================================================
49 */
50 
51 #include "../../idlib/precompiled.h"
52 #pragma hdrstop
53 
54 #include "../Game_local.h"
55 
57  EVENT( EV_FootstepLeft, idTestModel::Event_Footstep )
58  EVENT( EV_FootstepRight, idTestModel::Event_Footstep )
60 
61 /*
62 ================
63 idTestModel::idTestModel
64 ================
65 */
67  head = NULL;
68  headAnimator = NULL;
69  anim = 0;
70  headAnim = 0;
71  starttime = 0;
72  animtime = 0;
73  mode = 0;
74  frame = 0;
75 }
76 
77 /*
78 ================
79 idTestModel::Save
80 ================
81 */
82 void idTestModel::Save( idSaveGame *savefile ) {
83 }
84 
85 /*
86 ================
87 idTestModel::Restore
88 ================
89 */
91  // FIXME: one day we may actually want to save/restore test models, but for now we'll just delete them
92  delete this;
93 }
94 
95 /*
96 ================
97 idTestModel::Spawn
98 ================
99 */
100 void idTestModel::Spawn( void ) {
101  idVec3 size;
102  idBounds bounds;
103  const char *headModel;
104  jointHandle_t joint;
105  idStr jointName;
106  idVec3 origin, modelOffset;
107  idMat3 axis;
108  const idKeyValue *kv;
109  copyJoints_t copyJoint;
110 
112  gameLocal.Warning( "Unable to create testmodel for '%s' : model defaulted", spawnArgs.GetString( "model" ) );
113  PostEventMS( &EV_Remove, 0 );
114  return;
115  }
116 
119 
120  physicsObj.SetSelf( this );
121  physicsObj.SetOrigin( GetPhysics()->GetOrigin() );
122  physicsObj.SetAxis( GetPhysics()->GetAxis() );
123 
124  if ( spawnArgs.GetVector( "mins", NULL, bounds[0] ) ) {
125  spawnArgs.GetVector( "maxs", NULL, bounds[1] );
126  physicsObj.SetClipBox( bounds, 1.0f );
127  physicsObj.SetContents( 0 );
128  } else if ( spawnArgs.GetVector( "size", NULL, size ) ) {
129  bounds[ 0 ].Set( size.x * -0.5f, size.y * -0.5f, 0.0f );
130  bounds[ 1 ].Set( size.x * 0.5f, size.y * 0.5f, size.z );
131  physicsObj.SetClipBox( bounds, 1.0f );
132  physicsObj.SetContents( 0 );
133  }
134 
135  spawnArgs.GetVector( "offsetModel", "0 0 0", modelOffset );
136 
137  // add the head model if it has one
138  headModel = spawnArgs.GetString( "def_head", "" );
139  if ( headModel[ 0 ] ) {
140  jointName = spawnArgs.GetString( "head_joint" );
141  joint = animator.GetJointHandle( jointName );
142  if ( joint == INVALID_JOINT ) {
143  gameLocal.Warning( "Joint '%s' not found for 'head_joint'", jointName.c_str() );
144  } else {
145  // copy any sounds in case we have frame commands on the head
146  idDict args;
147  const idKeyValue *sndKV = spawnArgs.MatchPrefix( "snd_", NULL );
148  while( sndKV ) {
149  args.Set( sndKV->GetKey(), sndKV->GetValue() );
150  sndKV = spawnArgs.MatchPrefix( "snd_", sndKV );
151  }
152 
153  head = gameLocal.SpawnEntityType( idAnimatedEntity::Type, &args );
154  animator.GetJointTransform( joint, gameLocal.time, origin, axis );
155  origin = GetPhysics()->GetOrigin() + ( origin + modelOffset ) * GetPhysics()->GetAxis();
156  head.GetEntity()->SetModel( headModel );
157  head.GetEntity()->SetOrigin( origin );
158  head.GetEntity()->SetAxis( GetPhysics()->GetAxis() );
159  head.GetEntity()->BindToJoint( this, animator.GetJointName( joint ), true );
160 
162 
163  // set up the list of joints to copy to the head
164  for( kv = spawnArgs.MatchPrefix( "copy_joint", NULL ); kv != NULL; kv = spawnArgs.MatchPrefix( "copy_joint", kv ) ) {
165  jointName = kv->GetKey();
166 
167  if ( jointName.StripLeadingOnce( "copy_joint_world " ) ) {
168  copyJoint.mod = JOINTMOD_WORLD_OVERRIDE;
169  } else {
170  jointName.StripLeadingOnce( "copy_joint " );
171  copyJoint.mod = JOINTMOD_LOCAL_OVERRIDE;
172  }
173 
174  copyJoint.from = animator.GetJointHandle( jointName );
175  if ( copyJoint.from == INVALID_JOINT ) {
176  gameLocal.Warning( "Unknown copy_joint '%s'", jointName.c_str() );
177  continue;
178  }
179 
180  copyJoint.to = headAnimator->GetJointHandle( jointName );
181  if ( copyJoint.to == INVALID_JOINT ) {
182  gameLocal.Warning( "Unknown copy_joint '%s' on head", jointName.c_str() );
183  continue;
184  }
185 
186  copyJoints.Append( copyJoint );
187  }
188  }
189  }
190 
191  // start any shader effects based off of the spawn time
193 
195 
196  gameLocal.Printf( "Added testmodel at origin = '%s', angles = '%s'\n", GetPhysics()->GetOrigin().ToString(), GetPhysics()->GetAxis().ToAngles().ToString() );
198 }
199 
200 /*
201 ================
202 idTestModel::~idTestModel
203 ================
204 */
206  StopSound( SND_CHANNEL_ANY, false );
207  if ( renderEntity.hModel ) {
208  gameLocal.Printf( "Removing testmodel %s\n", renderEntity.hModel->Name() );
209  } else {
210  gameLocal.Printf( "Removing testmodel\n" );
211  }
212  if ( gameLocal.testmodel == this ) {
214  }
215  if ( head.GetEntity() ) {
218  }
219 }
220 
221 /*
222 ===============
223 idTestModel::Event_Footstep
224 ===============
225 */
227  StartSound( "snd_footstep", SND_CHANNEL_BODY, 0, false, NULL );
228 }
229 
230 /*
231 ================
232 idTestModel::ShouldConstructScriptObjectAtSpawn
233 
234 Called during idEntity::Spawn to see if it should construct the script object or not.
235 Overridden by subclasses that need to spawn the script object themselves.
236 ================
237 */
239  return false;
240 }
241 
242 /*
243 ================
244 idTestModel::Think
245 ================
246 */
247 void idTestModel::Think( void ) {
248  idVec3 pos;
249  idMat3 axis;
250  idAngles ang;
251  int i;
252 
253  if ( thinkFlags & TH_THINK ) {
254  if ( anim && ( gameLocal.testmodel == this ) && ( mode != g_testModelAnimate.GetInteger() ) ) {
255  StopSound( SND_CHANNEL_ANY, false );
256  if ( head.GetEntity() ) {
258  }
259  switch( g_testModelAnimate.GetInteger() ) {
260  default:
261  case 0:
262  // cycle anim with origin reset
263  if ( animator.NumFrames( anim ) <= 1 ) {
264  // single frame animations end immediately, so just cycle it since it's the same result
266  if ( headAnim ) {
268  }
269  } else {
271  if ( headAnim ) {
274  // loop the body anim when the head anim is longer
276  }
277  }
278  }
279  animator.RemoveOriginOffset( false );
280  break;
281 
282  case 1:
283  // cycle anim with fixed origin
286  if ( headAnim ) {
288  }
289  break;
290 
291  case 2:
292  // cycle anim with continuous origin
294  animator.RemoveOriginOffset( false );
295  if ( headAnim ) {
297  }
298  break;
299 
300  case 3:
301  // frame by frame with continuous origin
303  animator.RemoveOriginOffset( false );
304  if ( headAnim ) {
306  }
307  break;
308 
309  case 4:
310  // play anim once
312  animator.RemoveOriginOffset( false );
313  if ( headAnim ) {
315  }
316  break;
317 
318  case 5:
319  // frame by frame with fixed origin
322  if ( headAnim ) {
324  }
325  break;
326  }
327 
329  }
330 
331  if ( ( mode == 0 ) && ( gameLocal.time >= starttime + animtime ) ) {
333  StopSound( SND_CHANNEL_ANY, false );
335  if ( headAnim ) {
338  // loop the body anim when the head anim is longer
340  }
341  }
342  }
343 
344  if ( headAnimator ) {
345  // copy the animation from the body to the head
346  for( i = 0; i < copyJoints.Num(); i++ ) {
347  if ( copyJoints[ i ].mod == JOINTMOD_WORLD_OVERRIDE ) {
349  GetJointWorldTransform( copyJoints[ i ].from, gameLocal.time, pos, axis );
350  pos -= head.GetEntity()->GetPhysics()->GetOrigin();
351  headAnimator->SetJointPos( copyJoints[ i ].to, copyJoints[ i ].mod, pos * mat );
352  headAnimator->SetJointAxis( copyJoints[ i ].to, copyJoints[ i ].mod, axis * mat );
353  } else {
354  animator.GetJointLocalTransform( copyJoints[ i ].from, gameLocal.time, pos, axis );
355  headAnimator->SetJointPos( copyJoints[ i ].to, copyJoints[ i ].mod, pos );
356  headAnimator->SetJointAxis( copyJoints[ i ].to, copyJoints[ i ].mod, axis );
357  }
358  }
359  }
360 
361  // update rotation
362  RunPhysics();
363 
364  physicsObj.GetAngles( ang );
366 
368  if ( clip && animator.ModelDef() ) {
369  idVec3 neworigin;
370  idMat3 axis;
371  jointHandle_t joint;
372 
373  joint = animator.GetJointHandle( "origin" );
374  animator.GetJointTransform( joint, gameLocal.time, neworigin, axis );
375  neworigin = ( ( neworigin - animator.ModelDef()->GetVisualOffset() ) * physicsObj.GetAxis() ) + GetPhysics()->GetOrigin();
376  clip->Link( gameLocal.clip, this, 0, neworigin, clip->GetAxis() );
377  }
378  }
379 
380  UpdateAnimation();
381  Present();
382 
383  if ( ( gameLocal.testmodel == this ) && g_showTestModelFrame.GetInteger() && anim ) {
384  gameLocal.Printf( "^5 Anim: ^7%s ^5Frame: ^7%d/%d Time: %.3f\n", animator.AnimFullName( anim ), animator.CurrentAnim( ANIMCHANNEL_ALL )->GetFrameNumber( gameLocal.time ),
386  if ( headAnim ) {
387  gameLocal.Printf( "^5 Head: ^7%s ^5Frame: ^7%d/%d Time: %.3f\n\n", headAnimator->AnimFullName( headAnim ), headAnimator->CurrentAnim( ANIMCHANNEL_ALL )->GetFrameNumber( gameLocal.time ),
389  } else {
390  gameLocal.Printf( "\n\n" );
391  }
392  }
393 }
394 
395 /*
396 ================
397 idTestModel::NextAnim
398 ================
399 */
400 void idTestModel::NextAnim( const idCmdArgs &args ) {
401  if ( !animator.NumAnims() ) {
402  return;
403  }
404 
405  anim++;
406  if ( anim >= animator.NumAnims() ) {
407  // anim 0 is no anim
408  anim = 1;
409  }
410 
414  headAnim = 0;
415  if ( headAnimator ) {
418  if ( !headAnim ) {
419  headAnim = headAnimator->GetAnim( "idle" );
420  }
421 
422  if ( headAnim && ( headAnimator->AnimLength( headAnim ) > animtime ) ) {
424  }
425  }
426 
427  gameLocal.Printf( "anim '%s', %d.%03d seconds, %d frames\n", animname.c_str(), animator.AnimLength( anim ) / 1000, animator.AnimLength( anim ) % 1000, animator.NumFrames( anim ) );
428  if ( headAnim ) {
429  gameLocal.Printf( "head '%s', %d.%03d seconds, %d frames\n", headAnimator->AnimFullName( headAnim ), headAnimator->AnimLength( headAnim ) / 1000, headAnimator->AnimLength( headAnim ) % 1000, headAnimator->NumFrames( headAnim ) );
430  }
431 
432  // reset the anim
433  mode = -1;
434  frame = 1;
435 }
436 
437 /*
438 ================
439 idTestModel::PrevAnim
440 ================
441 */
442 void idTestModel::PrevAnim( const idCmdArgs &args ) {
443  if ( !animator.NumAnims() ) {
444  return;
445  }
446 
447  headAnim = 0;
448  anim--;
449  if ( anim < 0 ) {
450  anim = animator.NumAnims() - 1;
451  }
452 
456  headAnim = 0;
457  if ( headAnimator ) {
460  if ( !headAnim ) {
461  headAnim = headAnimator->GetAnim( "idle" );
462  }
463 
464  if ( headAnim && ( headAnimator->AnimLength( headAnim ) > animtime ) ) {
466  }
467  }
468 
469  gameLocal.Printf( "anim '%s', %d.%03d seconds, %d frames\n", animname.c_str(), animator.AnimLength( anim ) / 1000, animator.AnimLength( anim ) % 1000, animator.NumFrames( anim ) );
470  if ( headAnim ) {
471  gameLocal.Printf( "head '%s', %d.%03d seconds, %d frames\n", headAnimator->AnimFullName( headAnim ), headAnimator->AnimLength( headAnim ) / 1000, headAnimator->AnimLength( headAnim ) % 1000, headAnimator->NumFrames( headAnim ) );
472  }
473 
474  // reset the anim
475  mode = -1;
476  frame = 1;
477 }
478 
479 /*
480 ================
481 idTestModel::NextFrame
482 ================
483 */
484 void idTestModel::NextFrame( const idCmdArgs &args ) {
485  if ( !anim || ( ( g_testModelAnimate.GetInteger() != 3 ) && ( g_testModelAnimate.GetInteger() != 5 ) ) ) {
486  return;
487  }
488 
489  frame++;
490  if ( frame > animator.NumFrames( anim ) ) {
491  frame = 1;
492  }
493 
494  gameLocal.Printf( "^5 Anim: ^7%s\n^5Frame: ^7%d/%d\n\n", animator.AnimFullName( anim ), frame, animator.NumFrames( anim ) );
495 
496  // reset the anim
497  mode = -1;
498 }
499 
500 /*
501 ================
502 idTestModel::PrevFrame
503 ================
504 */
505 void idTestModel::PrevFrame( const idCmdArgs &args ) {
506  if ( !anim || ( ( g_testModelAnimate.GetInteger() != 3 ) && ( g_testModelAnimate.GetInteger() != 5 ) ) ) {
507  return;
508  }
509 
510  frame--;
511  if ( frame < 1 ) {
513  }
514 
515  gameLocal.Printf( "^5 Anim: ^7%s\n^5Frame: ^7%d/%d\n\n", animator.AnimFullName( anim ), frame, animator.NumFrames( anim ) );
516 
517  // reset the anim
518  mode = -1;
519 }
520 
521 /*
522 ================
523 idTestModel::TestAnim
524 ================
525 */
526 void idTestModel::TestAnim( const idCmdArgs &args ) {
527  idStr name;
528  int animNum;
529  const idAnim *newanim;
530 
531  if ( args.Argc() < 2 ) {
532  gameLocal.Printf( "usage: testanim <animname>\n" );
533  return;
534  }
535 
536  newanim = NULL;
537 
538  name = args.Argv( 1 );
539 #if 0
540  if ( strstr( name, ".ma" ) || strstr( name, ".mb" ) ) {
541  const idMD5Anim *md5anims[ ANIM_MaxSyncedAnims ];
542  idModelExport exporter;
543  exporter.ExportAnim( name );
545  md5anims[ 0 ] = animationLib.GetAnim( name );
546  if ( md5anims[ 0 ] ) {
547  customAnim.SetAnim( animator.ModelDef(), name, name, 1, md5anims );
548  newanim = &customAnim;
549  }
550  } else {
551  animNum = animator.GetAnim( name );
552  }
553 #else
554  animNum = animator.GetAnim( name );
555 #endif
556 
557  if ( !animNum ) {
558  gameLocal.Printf( "Animation '%s' not found.\n", name.c_str() );
559  return;
560  }
561 
562  anim = animNum;
565  headAnim = 0;
566  if ( headAnimator ) {
569  if ( !headAnim ) {
570  headAnim = headAnimator->GetAnim( "idle" );
571  if ( !headAnim ) {
572  gameLocal.Printf( "Missing 'idle' anim for head.\n" );
573  }
574  }
575 
576  if ( headAnim && ( headAnimator->AnimLength( headAnim ) > animtime ) ) {
578  }
579  }
580 
581  animname = name;
582  gameLocal.Printf( "anim '%s', %d.%03d seconds, %d frames\n", animname.c_str(), animator.AnimLength( anim ) / 1000, animator.AnimLength( anim ) % 1000, animator.NumFrames( anim ) );
583 
584  // reset the anim
585  mode = -1;
586 }
587 
588 /*
589 =====================
590 idTestModel::BlendAnim
591 =====================
592 */
593 void idTestModel::BlendAnim( const idCmdArgs &args ) {
594  int anim1;
595  int anim2;
596 
597  if ( args.Argc() < 4 ) {
598  gameLocal.Printf( "usage: testblend <anim1> <anim2> <frames>\n" );
599  return;
600  }
601 
602  anim1 = gameLocal.testmodel->animator.GetAnim( args.Argv( 1 ) );
603  if ( !anim1 ) {
604  gameLocal.Printf( "Animation '%s' not found.\n", args.Argv( 1 ) );
605  return;
606  }
607 
608  anim2 = gameLocal.testmodel->animator.GetAnim( args.Argv( 2 ) );
609  if ( !anim2 ) {
610  gameLocal.Printf( "Animation '%s' not found.\n", args.Argv( 2 ) );
611  return;
612  }
613 
614  animname = args.Argv( 2 );
616  animator.CycleAnim( ANIMCHANNEL_ALL, anim2, gameLocal.time, FRAME2MS( atoi( args.Argv( 3 ) ) ) );
617 
618  anim = anim2;
619  headAnim = 0;
620 }
621 
622 /***********************************************************************
623 
624  Testmodel console commands
625 
626 ***********************************************************************/
627 
628 /*
629 =================
630 idTestModel::KeepTestModel_f
631 
632 Makes the current test model permanent, allowing you to place
633 multiple test models
634 =================
635 */
637  if ( !gameLocal.testmodel ) {
638  gameLocal.Printf( "No active testModel.\n" );
639  return;
640  }
641 
642  gameLocal.Printf( "modelDef %p kept\n", gameLocal.testmodel->renderEntity.hModel );
643 
645 }
646 
647 /*
648 =================
649 idTestModel::TestSkin_f
650 
651 Sets a skin on an existing testModel
652 =================
653 */
654 void idTestModel::TestSkin_f( const idCmdArgs &args ) {
655  idVec3 offset;
656  idStr name;
657  idPlayer * player;
658  idDict dict;
659 
660  player = gameLocal.GetLocalPlayer();
661  if ( !player || !gameLocal.CheatsOk() ) {
662  return;
663  }
664 
665  // delete the testModel if active
666  if ( !gameLocal.testmodel ) {
667  common->Printf( "No active testModel\n" );
668  return;
669  }
670 
671  if ( args.Argc() < 2 ) {
672  common->Printf( "removing testSkin.\n" );
674  return;
675  }
676 
677  name = args.Argv( 1 );
679 }
680 
681 /*
682 =================
683 idTestModel::TestShaderParm_f
684 
685 Sets a shaderParm on an existing testModel
686 =================
687 */
689  idVec3 offset;
690  idStr name;
691  idPlayer * player;
692  idDict dict;
693 
694  player = gameLocal.GetLocalPlayer();
695  if ( !player || !gameLocal.CheatsOk() ) {
696  return;
697  }
698 
699  // delete the testModel if active
700  if ( !gameLocal.testmodel ) {
701  common->Printf( "No active testModel\n" );
702  return;
703  }
704 
705  if ( args.Argc() != 3 ) {
706  common->Printf( "USAGE: testShaderParm <parmNum> <float | \"time\">\n" );
707  return;
708  }
709 
710  int parm = atoi( args.Argv( 1 ) );
711  if ( parm < 0 || parm >= MAX_ENTITY_SHADER_PARMS ) {
712  common->Printf( "parmNum %i out of range\n", parm );
713  return;
714  }
715 
716  float value;
717  if ( !idStr::Icmp( args.Argv( 2 ), "time" ) ) {
718  value = gameLocal.time * -0.001;
719  } else {
720  value = atof( args.Argv( 2 ) );
721  }
722 
723  gameLocal.testmodel->SetShaderParm( parm, value );
724 }
725 
726 /*
727 =================
728 idTestModel::TestModel_f
729 
730 Creates a static modelDef in front of the current position, which
731 can then be moved around
732 =================
733 */
734 void idTestModel::TestModel_f( const idCmdArgs &args ) {
735  idVec3 offset;
736  idStr name;
737  idPlayer * player;
738  const idDict * entityDef;
739  idDict dict;
740 
741  player = gameLocal.GetLocalPlayer();
742  if ( !player || !gameLocal.CheatsOk() ) {
743  return;
744  }
745 
746  // delete the testModel if active
747  if ( gameLocal.testmodel ) {
748  delete gameLocal.testmodel;
750  }
751 
752  if ( args.Argc() < 2 ) {
753  return;
754  }
755 
756  name = args.Argv( 1 );
757 
758  entityDef = gameLocal.FindEntityDefDict( name, false );
759  if ( entityDef ) {
760  dict = *entityDef;
761  } else {
762  if ( declManager->FindType( DECL_MODELDEF, name, false ) ) {
763  dict.Set( "model", name );
764  } else {
765  // allow map models with underscore prefixes to be tested during development
766  // without appending an ase
767  if ( name[ 0 ] != '_' ) {
768  name.DefaultFileExtension( ".ase" );
769  }
770 
771 #ifndef _D3XP
772  // Maya ascii format is supported natively now
773  if ( strstr( name, ".ma" ) || strstr( name, ".mb" ) ) {
774  idModelExport exporter;
775  exporter.ExportModel( name );
777  }
778 #endif
779 
780  if ( !renderModelManager->CheckModel( name ) ) {
781  gameLocal.Printf( "Can't register model\n" );
782  return;
783  }
784  dict.Set( "model", name );
785  }
786  }
787 
788  offset = player->GetPhysics()->GetOrigin() + player->viewAngles.ToForward() * 100.0f;
789 
790  dict.Set( "origin", offset.ToString() );
791  dict.Set( "angle", va( "%f", player->viewAngles.yaw + 180.0f ) );
792  gameLocal.testmodel = ( idTestModel * )gameLocal.SpawnEntityType( idTestModel::Type, &dict );
794 }
795 
796 /*
797 =====================
798 idTestModel::ArgCompletion_TestModel
799 =====================
800 */
801 void idTestModel::ArgCompletion_TestModel( const idCmdArgs &args, void(*callback)( const char *s ) ) {
802  int i, num;
803 
805  for ( i = 0; i < num; i++ ) {
806  callback( idStr( args.Argv( 0 ) ) + " " + declManager->DeclByIndex( DECL_ENTITYDEF, i , false )->GetName() );
807  }
809  for ( i = 0; i < num; i++ ) {
810  callback( idStr( args.Argv( 0 ) ) + " " + declManager->DeclByIndex( DECL_MODELDEF, i , false )->GetName() );
811  }
812  cmdSystem->ArgCompletion_FolderExtension( args, callback, "models/", false, ".lwo", ".ase", ".md5mesh", ".ma", ".mb", NULL );
813 }
814 
815 /*
816 =====================
817 idTestModel::TestParticleStopTime_f
818 =====================
819 */
821  if ( !gameLocal.testmodel ) {
822  gameLocal.Printf( "No testModel active.\n" );
823  return;
824  }
825 
828 }
829 
830 /*
831 =====================
832 idTestModel::TestAnim_f
833 =====================
834 */
835 void idTestModel::TestAnim_f( const idCmdArgs &args ) {
836  if ( !gameLocal.testmodel ) {
837  gameLocal.Printf( "No testModel active.\n" );
838  return;
839  }
840 
841  gameLocal.testmodel->TestAnim( args );
842 }
843 
844 
845 /*
846 =====================
847 idTestModel::ArgCompletion_TestAnim
848 =====================
849 */
850 void idTestModel::ArgCompletion_TestAnim( const idCmdArgs &args, void(*callback)( const char *s ) ) {
851  if ( gameLocal.testmodel ) {
853  for( int i = 0; i < animator->NumAnims(); i++ ) {
854  callback( va( "%s %s", args.Argv( 0 ), animator->AnimFullName( i ) ) );
855  }
856  }
857 }
858 
859 /*
860 =====================
861 idTestModel::TestBlend_f
862 =====================
863 */
864 void idTestModel::TestBlend_f( const idCmdArgs &args ) {
865  if ( !gameLocal.testmodel ) {
866  gameLocal.Printf( "No testModel active.\n" );
867  return;
868  }
869 
870  gameLocal.testmodel->BlendAnim( args );
871 }
872 
873 /*
874 =====================
875 idTestModel::TestModelNextAnim_f
876 =====================
877 */
879  if ( !gameLocal.testmodel ) {
880  gameLocal.Printf( "No testModel active.\n" );
881  return;
882  }
883 
884  gameLocal.testmodel->NextAnim( args );
885 }
886 
887 /*
888 =====================
889 idTestModel::TestModelPrevAnim_f
890 =====================
891 */
893  if ( !gameLocal.testmodel ) {
894  gameLocal.Printf( "No testModel active.\n" );
895  return;
896  }
897 
898  gameLocal.testmodel->PrevAnim( args );
899 }
900 
901 /*
902 =====================
903 idTestModel::TestModelNextFrame_f
904 =====================
905 */
907  if ( !gameLocal.testmodel ) {
908  gameLocal.Printf( "No testModel active.\n" );
909  return;
910  }
911 
912  gameLocal.testmodel->NextFrame( args );
913 }
914 
915 /*
916 =====================
917 idTestModel::TestModelPrevFrame_f
918 =====================
919 */
921  if ( !gameLocal.testmodel ) {
922  gameLocal.Printf( "No testModel active.\n" );
923  return;
924  }
925 
926  gameLocal.testmodel->PrevFrame( args );
927 }
virtual const idVec3 & GetOrigin(int id=0) const =0
jointHandle_t
Definition: Model.h:156
idPlayer * GetLocalPlayer() const
renderEntity_t renderEntity
Definition: Entity.h:371
#define MD5_ANIM_EXT
Definition: Model.h:43
bool GetJointTransform(jointHandle_t jointHandle, int currenttime, idVec3 &offset, idMat3 &axis)
GLsizei const GLfloat * value
Definition: glext.h:3614
void SetCycleCount(int count)
idStr & SetFileExtension(const char *extension)
Definition: Str.cpp:743
void SetContents(int contents, int id=-1)
const idDict * FindEntityDefDict(const char *name, bool makeDefault=true) const
void Link(idClip &clp)
Definition: Clip.cpp:545
extrapolation_t
Definition: Extrapolate.h:40
virtual idAnimator * GetAnimator(void)
Definition: Entity.cpp:1566
const idMat3 & GetAxis(int id=0) const
idClip clip
Definition: Game_local.h:296
void Printf(const char *fmt,...) const id_attribute((format(printf
Definition: Game_local.cpp:699
idAnimator * headAnimator
void BindToJoint(idEntity *master, const char *jointname, bool orientated)
Definition: Entity.cpp:1921
void SetAngularExtrapolation(extrapolation_t type, int time, int duration, const idAngles &base, const idAngles &speed, const idAngles &baseSpeed)
type * GetEntity(void) const
Definition: Game_local.h:695
void SetShaderParm(int parmnum, float value)
Definition: Entity.cpp:1067
virtual void SetClipBox(const idBounds &bounds, float density)
Definition: Physics.cpp:67
float GetFloat(void) const
Definition: CVarSystem.h:144
const idStr & GetKey(void) const
Definition: Dict.h:52
idAnim customAnim
idMat3 Transpose(void) const
Definition: Matrix.h:677
void SetAxis(const idMat3 &axis)
Definition: Entity.cpp:2796
const int ANIMCHANNEL_ALL
Definition: Anim.h:41
const int ANIM_MaxSyncedAnims
Definition: Anim.h:36
void TestAnim(const idCmdArgs &args)
virtual void Think(void)
const idMat3 & GetAxis(void) const
Definition: Clip.h:210
float z
Definition: Vector.h:320
const idKeyValue * MatchPrefix(const char *prefix, const idKeyValue *lastMatch=NULL) const
Definition: Dict.cpp:523
jointHandle_t from
Definition: Actor.h:107
void PlayAnim(int channelNum, int animnum, int currenttime, int blendTime)
prefInfo callback
jointHandle_t GetJointHandle(const char *name) const
const char * GetName(void) const
Definition: DeclManager.h:140
Definition: Vector.h:316
idAngles ang_zero(0.0f, 0.0f, 0.0f)
bool ExportAnim(const char *anim)
static void TestModelNextFrame_f(const idCmdArgs &args)
virtual const char * Name() const =0
idCmdSystem * cmdSystem
Definition: CmdSystem.cpp:116
void SetJointPos(jointHandle_t jointnum, jointModTransform_t transform_type, const idVec3 &pos)
static void TestModelPrevAnim_f(const idCmdArgs &args)
static void TestModelNextAnim_f(const idCmdArgs &args)
GLdouble s
Definition: glext.h:2935
idStr & DefaultFileExtension(const char *extension)
Definition: Str.cpp:794
void Set(const char *key, const char *value)
Definition: Dict.cpp:275
float x
Definition: Vector.h:318
idDict spawnArgs
Definition: Entity.h:122
idTestModel * testmodel
Definition: Game_local.h:300
int i
Definition: process.py:33
idCVar g_testModelAnimate("g_testModelAnimate","0", CVAR_GAME|CVAR_INTEGER,"test model animation,\n""0 = cycle anim with origin reset\n""1 = cycle anim with fixed origin\n""2 = cycle anim with continuous origin\n""3 = frame by frame with continuous origin\n""4 = play anim once", 0, 4, idCmdSystem::ArgCompletion_Integer< 0, 4 >)
GLintptr offset
Definition: glext.h:3113
void SetAnim(const idDeclModelDef *modelDef, const char *sourcename, const char *animname, int num, const idMD5Anim *md5anims[ANIM_MaxSyncedAnims])
Definition: Anim_Blend.cpp:110
GLuint GLuint num
Definition: glext.h:5390
virtual void SetModel(const char *modelname)
Definition: Entity.cpp:1150
int Icmp(const char *text) const
Definition: Str.h:667
static void TestBlend_f(const idCmdArgs &args)
#define EVENT(event, function)
Definition: Class.h:53
void SetAxis(const idMat3 &newAxis, int id=-1)
const int MAX_ENTITY_SHADER_PARMS
Definition: Material.h:258
static void TestParticleStopTime_f(const idCmdArgs &args)
void SetJointAxis(jointHandle_t jointnum, jointModTransform_t transform_type, const idMat3 &mat)
idCVar g_testModelRotate("g_testModelRotate","0", CVAR_GAME,"test model rotation speed")
static void TestAnim_f(const idCmdArgs &args)
idCVar g_testModelBlend("g_testModelBlend","0", CVAR_GAME|CVAR_INTEGER,"number of frames to blend")
idAnimator animator
Definition: Entity.h:534
idEntity * SpawnEntityType(const idTypeInfo &classdef, const idDict *args=NULL, bool bIsClientReadSnapshot=false)
void void void Warning(const char *fmt,...) const id_attribute((format(printf
Definition: Game_local.cpp:735
void PrevFrame(const idCmdArgs &args)
int GetFrameNumber(int currenttime) const
void SetSelf(idEntity *e)
virtual void ArgCompletion_FolderExtension(const idCmdArgs &args, void(*callback)(const char *s), const char *folder, bool stripFolder,...)=0
static void ArgCompletion_TestModel(const idCmdArgs &args, void(*callback)(const char *s))
const idEventDef EV_FootstepLeft("leftFoot")
void RemoveOriginOffset(bool remove)
static void TestModel_f(const idCmdArgs &args)
idPhysics * GetPhysics(void) const
Definition: Entity.cpp:2607
idMD5Anim * GetAnim(const char *name)
Definition: Anim.cpp:953
void SetSkin(const idDeclSkin *skin)
Definition: Entity.cpp:1178
const char * GetString(const char *key, const char *defaultString="") const
Definition: Dict.h:240
idVec3 ToForward(void) const
Definition: Angles.cpp:117
bool StartSound(const char *soundName, const s_channelType channel, int soundShaderFlags, bool broadcast, int *length)
Definition: Entity.cpp:1622
void Restore(idRestoreGame *savefile)
void SetOrigin(const idVec3 &newOrigin, int id=-1)
void SetPhysics(idPhysics *phys)
Definition: Entity.cpp:2574
idEntityPtr< idEntity > head
jointModTransform_t mod
Definition: Actor.h:106
idCommon * common
Definition: Common.cpp:206
void Event_Footstep(void)
void ClearAllAnims(int currentTime, int cleartime)
Definition: Dict.h:65
#define NULL
Definition: Lib.h:88
idAnimBlend * CurrentAnim(int channelNum)
virtual const idDecl * FindType(declType_t type, const char *name, bool makeDefault=true)=0
float y
Definition: Vector.h:319
void Save(idSaveGame *savefile)
int GetInteger(void) const
Definition: CVarSystem.h:143
idVec3 GetVector(const char *key, const char *defaultString=NULL) const
Definition: Dict.h:260
bool GetJointLocalTransform(jointHandle_t jointHandle, int currentTime, idVec3 &offset, idMat3 &axis)
const idAnim * GetAnim(int index) const
void CycleAnim(int channelNum, int animnum, int currenttime, int blendtime)
void GetAngles(idAngles &curAngles) const
GLint mode
Definition: glext.h:4165
static void TestModelPrevFrame_f(const idCmdArgs &args)
bool ExportModel(const char *model)
const idStr & GetValue(void) const
Definition: Dict.h:53
int Argc(void) const
Definition: CmdArgs.h:48
virtual const idMat3 & GetAxis(int id=0) const =0
virtual idAnimator * GetAnimator(void)
Definition: Entity.cpp:5213
const idDeclModelDef * ModelDef(void) const
idGameLocal gameLocal
Definition: Game_local.cpp:64
bool RunPhysics(void)
Definition: Entity.cpp:2616
static void TestShaderParm_f(const idCmdArgs &args)
const int SHADERPARM_TIMEOFFSET
Definition: RenderWorld.h:51
int NumAnims(void) const
#define END_CLASS
Definition: Class.h:54
idRenderModel * hModel
Definition: RenderWorld.h:81
virtual void Printf(const char *fmt,...) id_attribute((format(printf
const idVec3 & GetVisualOffset(void) const
idClipModel * GetClipModel(int id=0) const
static void ArgCompletion_TestAnim(const idCmdArgs &args, void(*callback)(const char *s))
void Spawn(void)
const char * ToString(int precision=2) const
Definition: Vector.cpp:221
virtual void Present(void)
Definition: Entity.cpp:1471
virtual bool ShouldConstructScriptObjectAtSpawn(void) const
idDeclManager * declManager
virtual int GetNumDecls(declType_t type)=0
int AnimLength(int animnum) const
int Append(const type &obj)
Definition: List.h:646
idRenderModelManager * renderModelManager
Definition: Matrix.h:333
virtual bool IsDefaultModel() const =0
float yaw
Definition: Angles.h:54
void UpdateVisuals(void)
Definition: Entity.cpp:1310
const char * AnimFullName(int animnum) const
void NextAnim(const idCmdArgs &args)
virtual const idDecl * DeclByIndex(declType_t type, int index, bool forceParse=true)=0
tuple f
Definition: idal.py:89
void BlendAnim(const idCmdArgs &args)
idCVar g_showTestModelFrame("g_showTestModelFrame","0", CVAR_GAME|CVAR_BOOL,"displays the current animation and frame # for testmodels")
idAngles viewAngles
Definition: Player.h:258
const idEventDef EV_FootstepRight("rightFoot")
#define MD5_MESH_EXT
Definition: Model.h:42
int Num(void) const
Definition: List.h:265
GLsizeiptr size
Definition: glext.h:3112
idList< copyJoints_t > copyJoints
bool GetJointWorldTransform(jointHandle_t jointHandle, int currentTime, idVec3 &offset, idMat3 &axis)
Definition: Entity.cpp:5248
#define CLASS_DECLARATION(nameofsuperclass, nameofclass)
Definition: Class.h:110
Definition: Str.h:116
static void TestSkin_f(const idCmdArgs &args)
void UpdateAnimation(void)
Definition: Entity.cpp:5172
idAnimManager animationLib
Definition: Game_local.cpp:61
const char * c_str(void) const
Definition: Str.h:487
int NumFrames(int animnum) const
ID_INLINE int FRAME2MS(int framenum)
Definition: Anim.h:48
const char * GetJointName(jointHandle_t handle) const
void BecomeActive(int flags)
Definition: Entity.cpp:995
const idEventDef EV_Remove("<immediateremove>", NULL)
jointHandle_t to
Definition: Actor.h:108
void SetFrame(int channelNum, int animnum, int frame, int currenttime, int blendtime)
const char * Argv(int arg) const
Definition: CmdArgs.h:50
virtual const idDeclSkin * FindSkin(const char *name, bool makeDefault=true)=0
bool CheatsOk(bool requirePlayer=true)
int NumFrames(void) const
int GetStartTime(void) const
virtual idRenderModel * CheckModel(const char *modelName)=0
char * va(const char *fmt,...)
Definition: Str.cpp:1568
void SetOrigin(const idVec3 &org)
Definition: Entity.cpp:2784
bool PostEventMS(const idEventDef *ev, int time)
Definition: Class.cpp:666
idStr name
Definition: Entity.h:121
void PrevAnim(const idCmdArgs &args)
int thinkFlags
Definition: Entity.h:125
float shaderParms[MAX_ENTITY_SHADER_PARMS]
Definition: RenderWorld.h:127
void NextFrame(const idCmdArgs &args)
void StopSound(const s_channelType channel, bool broadcast)
Definition: Entity.cpp:1713
Definition: Anim.h:280
bool StripLeadingOnce(const char *string)
Definition: Str.cpp:498
#define MS2SEC(t)
Definition: Math.h:60
idPhysics_Parametric physicsObj
static void KeepTestModel_f(const idCmdArgs &args)
const int SHADERPARM_PARTICLE_STOPTIME
Definition: RenderWorld.h:71