Page 1 of 1

[1.0.18] Model index feature not working?

Posted: Thu Jul 27, 2006 22:47
by Nash
First, download this:

Edit: Reuploaded file
http://nash.wanzafran.com/playermodel.zip

Now replace the existing modeldef.txt with below:

Code: Select all

Model DoomPlayer_                // Name of actor in DECORATE 
{ 
   Path "models/player"          // Path to model in PK3 

   Model 0 "player.md2"          // Model index, model file
   Skin 0 "green.pcx"            // Model index, texture (can be in any format supported by GZDoom) 

   Model 1 "weapon.md2"
   Skin 1 "weapon.pcx"

   Scale 1.2 1.2 1.2           // Scale values 


   // Standing
   Frame NULA A 0 "stand01"      // The sprite lump, sprite frame, model index, name of frame 

   // Running
   Frame NULC A 0 "run1"
   Frame NULC B 0 "run2" 
   Frame NULC C 0 "run3" 
   Frame NULC D 0 "run4"
   Frame NULC E 0 "run5" 
   Frame NULC F 0 "run6"

   // Attacking
   Frame NULD A 0 "attack1"
   Frame NULD B 0 "attack2" 
   Frame NULD C 0 "attack3" 
   Frame NULD D 0 "attack4"
   Frame NULD E 0 "attack5" 
   Frame NULD F 0 "attack6" 
   Frame NULD G 0 "attack7" 
   Frame NULD H 0 "attack8"

   // Pain
   Frame NULE A 0 "pain101"
   Frame NULE B 0 "pain102" 
   Frame NULE C 0 "pain103" 
   Frame NULE D 0 "pain104"

   // Death
   Frame NULF A 0 "death301"
   Frame NULF B 0 "death302" 
   Frame NULF C 0 "death303" 
   Frame NULF D 0 "death304"
   Frame NULF E 0 "death305"
   Frame NULF F 0 "death306" 
   Frame NULF G 0 "death307" 
   Frame NULF H 0 "death308"

   // Weapon model definition

   // Standing
   Frame NULA A 1 "stand01"

   // Running
   Frame NULC A 1 "run1"
   Frame NULC B 1 "run2" 
   Frame NULC C 1 "run3" 
   Frame NULC D 1 "run4"
   Frame NULC E 1 "run5" 
   Frame NULC F 1 "run6"

   // Attacking
   Frame NULD A 1 "attack1"
   Frame NULD B 1 "attack2" 
   Frame NULD C 1 "attack3" 
   Frame NULD D 1 "attack4"
   Frame NULD E 1 "attack5" 
   Frame NULD F 1 "attack6" 
   Frame NULD G 1 "attack7" 
   Frame NULD H 1 "attack8"

   // Pain
   Frame NULE A 1 "pain101"
   Frame NULE B 1 "pain102" 
   Frame NULE C 1 "pain103" 
   Frame NULE D 1 "pain104"

}
You'll see that, although the player weapon is loaded (although with too low Y offsets; I'll need to fix that in a model editor later), the main player model appears in its dead state. So you see a moving weapon dragging around a dead body. :)

Or do I just not understand how model index is supposed to work? In that case, what is the correct way to define more than one model per actor?

Posted: Tue Sep 12, 2006 20:31
by Nash
Sorry for the bump, but I'd like to know if it's an error on my part, or if the feature really is broken?

Re: [1.0.18] Model index feature not working?

Posted: Wed Sep 13, 2006 14:46
by Cutmanmike
Nash wrote:So you see a moving weapon dragging around a dead body. :)
Don't fix this!! :P

Posted: Sat Jan 13, 2007 12:42
by Chilvence
Bumped for future importance ^^

Posted: Thu Aug 16, 2007 17:54
by Torr Samaho
I ran into a similar problem while making a definition for the AllMap Item. I dug through the model definition parsing source to see if I could understand and fix the problem and came to the following conclusion: The code makes the assumption that one definition only defines one frame. Respecting this I could fix my allmap:
Spoiler: Allmap
This way one should be able to solve the original problem, too.

Posted: Fri Aug 17, 2007 13:38
by Risen
Torr Samaho wrote:Respecting this I could fix my allmap:
Did you do this? Did it work?

Posted: Fri Aug 17, 2007 13:45
by Torr Samaho
Risen wrote:Did you do this? Did it work?
Yes, it works as it should. The AllMap model shows all four different screen skins this way.

Posted: Sun Aug 19, 2007 13:06
by Nash
One definition for one frame? That sounds way too convoluted. Was it really meant to work like this?

Graf?

Posted: Mon Aug 20, 2007 9:56
by Torr Samaho
I doubt that it was intended like this, but from my understanding of the source the only way to define the allmap currently is to write one definition per frame.

Posted: Tue Aug 21, 2007 7:38
by Nash

Code: Select all

Model DoomPlayer_
	{ 
	Path "models/player"

	Model 0 "player.md2"
	Skin 0 "green.pcx"

	Model 1 "weapon.md2"
	Skin 1 "weapon.pcx"

	Scale 1.2 1.2 1.2

	// Standing
	Frame NULA A 0 "stand01"
	Frame NULA A 1 "stand01"
	
	// Running
	Frame NULC A 0 "run1"
	Frame NULC A 1 "run1"
	 
	Frame NULC B 0 "run2"
	Frame NULC B 1 "run2"
	
	Frame NULC C 0 "run3"
	Frame NULC C 1 "run3"
	
	Frame NULC D 0 "run4"
	Frame NULC D 1 "run4"
	
	Frame NULC E 0 "run5"
	Frame NULC E 1 "run5"
	
	Frame NULC F 0 "run6"
	Frame NULC F 1 "run6"
	
	// Attacking
	Frame NULD A 0 "attack1"
	Frame NULD A 1 "attack1"
	
	Frame NULD B 0 "attack2"
	Frame NULD B 1 "attack2"
	
	Frame NULD C 0 "attack3"
	Frame NULD C 1 "attack3"
	
	Frame NULD D 0 "attack4"
	Frame NULD D 1 "attack4"
	
	Frame NULD E 0 "attack5"
	Frame NULD E 1 "attack5"

	Frame NULD F 0 "attack6"
	Frame NULD F 1 "attack6"
	
	Frame NULD G 0 "attack7"
	Frame NULD G 1 "attack7"
	
	Frame NULD H 0 "attack8"
	Frame NULD H 1 "attack8"
	
	// Pain
	Frame NULE A 0 "pain101"
	Frame NULE A 1 "pain101"
	
	Frame NULE B 0 "pain102"
	Frame NULE B 1 "pain102"
	
	Frame NULE C 0 "pain103"
	Frame NULE C 1 "pain103"
	
	Frame NULE D 0 "pain104"
	Frame NULE D 1 "pain104"
	
	
	// Death
	Frame NULF A 0 "death301"
	Frame NULF A 1 "death"

	Frame NULF B 0 "death302"
	Frame NULF B 1 "death"

	Frame NULF C 0 "death303"
	Frame NULF C 1 "death"

	Frame NULF D 0 "death304"
	Frame NULF D 1 "death"

	Frame NULF E 0 "death305"
	Frame NULF E 1 "death"

	Frame NULF F 0 "death306"
	Frame NULF F 1 "death"

	Frame NULF G 0 "death307"
	Frame NULF G 1 "death"

	Frame NULF H 0 "death308"
	Frame NULF H 1 "death"
	
	}
Yuck. :(

Posted: Sun Dec 09, 2007 2:00
by ChupaReaper
There is another way, but it limits you to 4 models and it now sometimes has problems with the new interpolation.

The script below makes a model which changes skins for attacking and death.

Code: Select all

Model	DArachnotron
{
	Model 0 "Arachnotron.md2"
	Skin 0 "Arachnotron.png"
	Model 1 "Arachnotron.md2"
	Skin 1 "Arachnotron_Missile.png"
	Model 2 "Arachnotron_Death.md2"
	Skin 2 "Arachnotron_Death.png"
	Scale 2.5 2.5 2.5

	FrameIndex IDLE A 0 0 //Spawn
	FrameIndex IDLE A 1 999 <-----By setting models 1 + 2 to 999, a non-existant frame, they disapear thus aren't dragged around by model 0.
	FrameIndex IDLE A 2 999
	FrameIndex IDLE B 0 1
	FrameIndex IDLE C 0 2
	FrameIndex IDLE D 0 3

	FrameIndex MOVE A 0 4 //Chase
	FrameIndex MOVE B 0 5
	FrameIndex MOVE C 0 6
	FrameIndex MOVE D 0 7
	FrameIndex MOVE E 0 8
	FrameIndex MOVE F 0 9

	FrameIndex PAIN A 0 10 //Pain
	FrameIndex PAIN B 0 11

	FrameIndex MISL A 0 12 //Missile
	FrameIndex MISL B 0 13
	FrameIndex MISL C 1 14 //Emit
	FrameIndex MISL C 0 999
	FrameIndex MISL C 2 999

	FrameIndex DETH A 2 0 //Death
	FrameIndex DETH A 0 999
	FrameIndex DETH A 1 999
	FrameIndex DETH B 2 1
	FrameIndex DETH C 2 2
	FrameIndex DETH D 2 3
	FrameIndex DETH E 2 4
	FrameIndex DETH F 2 5
	FrameIndex DETH G 2 6
	FrameIndex DETH H 2 7
	FrameIndex DETH I 2 8
	FrameIndex DETH J 2 9
	FrameIndex DETH K 2 10
	FrameIndex DETH L 2 11
	FrameIndex DETH M 2 12
	FrameIndex DETH N 2 13
	FrameIndex DETH O 2 14
}
Coding everything like this has worked perfectly until interpolation was added. The problem now is that the models disapearing are interpolated so one can see the enemy flashing about! But if seperate model definitions aren't interpolated between each other, then this may solve this problem. It shouldn't be necesary to redefine every frame, just when ever a different model is used.

EDIT: I've made a new modeldef for the arachnotron which works perfectly, for each model change, start a new definition.

Code: Select all

Model	DArachnotron <---Main frames which use main model + skin
{
	Model 0 "Arachnotron.md2"
	Skin 0 "Arachnotron.png"
	Scale 2.5 2.5 2.5

	FrameIndex IDLE A 0 0 //Spawn
	FrameIndex IDLE B 0 1
	FrameIndex IDLE C 0 2
	FrameIndex IDLE D 0 3

	FrameIndex MOVE A 0 4 //Chase
	FrameIndex MOVE B 0 5
	FrameIndex MOVE C 0 6
	FrameIndex MOVE D 0 7
	FrameIndex MOVE E 0 8
	FrameIndex MOVE F 0 9

	FrameIndex PAIN A 0 10 //Pain
	FrameIndex PAIN B 0 11

	FrameIndex MISL A 0 12 //Missile
	FrameIndex MISL B 0 13
}

Model	DArachnotron <---Frame using attack skin
{
	Model 0 "Arachnotron.md2"
	Skin 0 "Arachnotron_Missile.png"
	Scale 2.5 2.5 2.5

	FrameIndex MISL C 0 14 //Emit //Missile
}

Model	DArachnotron <---Frames using death model + skin
{
	Model 0 "Arachnotron_Death.md2"
	Skin 0 "Arachnotron_Death.png"
	Scale 2.5 2.5 2.5

	FrameIndex DETH A 0 0 //Death
	FrameIndex DETH B 0 1
	FrameIndex DETH C 0 2
	FrameIndex DETH D 0 3
	FrameIndex DETH E 0 4
	FrameIndex DETH F 0 5
	FrameIndex DETH G 0 6
	FrameIndex DETH H 0 7
	FrameIndex DETH I 0 8
	FrameIndex DETH J 0 9
	FrameIndex DETH K 0 10
	FrameIndex DETH L 0 11
	FrameIndex DETH M 0 12
	FrameIndex DETH N 0 13
	FrameIndex DETH O 0 14
}

Posted: Sun Dec 09, 2007 8:48
by Torr Samaho
ChupaReaper wrote:

Code: Select all

	FrameIndex IDLE A 1 999 <-----By setting models 1 + 2 to 999, a non-existant frame, they disapear thus aren't dragged around by model 0.
From my understanding of the model code you are exploiting a bug not a feature here. So I don't consider this to be a bug of the interpolation code.

Posted: Sun Dec 09, 2007 19:43
by ChupaReaper
Torr Samaho wrote:
ChupaReaper wrote:

Code: Select all

	FrameIndex IDLE A 1 999 <-----By setting models 1 + 2 to 999, a non-existant frame, they disapear thus aren't dragged around by model 0.
From my understanding of the model code you are exploiting a bug not a feature here. So I don't consider this to be a bug of the interpolation code.
Yeah, it's a useful little cheat! But my new method is much cleaner and hasn't any problems. How is this a bug though? What should happen if a non-existant frame is called?

Posted: Sun Dec 09, 2007 21:49
by Graf Zahl
It's undefined behavior and might cease to work at any time.

Posted: Sun Dec 09, 2007 21:52
by ChupaReaper
Graf Zahl wrote:It's undefined behavior and might cease to work at any time.
Oh well, doesn't matter anymore, the new way I do modeldefs is much better and works well with the new frame interpolation.