Jump to content

misc_model_ghoul


Tempust85

Recommended Posts

Posted

I *think* I've fixed misc_model_ghoul. Appears to have just needed gi.linkentity (ent); in void SP_misc_model_ghoul( gentity_t *ent ) inside file g_misc_model.cpp. However it doesn't work with .skin files (so it's just like MD3), scaling on the entity doesn't work and I have no idea if the models are being turned into BSP or they are loaded like misc_model_static.

 

pslf.jpg

void SP_misc_model_ghoul( gentity_t *ent )
{
#if 1
ent->s.modelindex = G_ModelIndex( ent->model );
gi.G2API_InitGhoul2Model(ent->ghoul2, ent->model, ent->s.modelindex, NULL_HANDLE, NULL_HANDLE, 0, 0);
ent->s.radius = 50;

gi.linkentity (ent);
#else
char name1[200] = "models/players/kyle/model.glm";
.......blah blah blah





I'd like someone who actually knows what they are doing (cuz I don't :P ) to check this out and perhaps add in model scaling support, .skin file support and what I'd also love to see is the ability to play animations for example:

 

key "anim"

value "BOTH_STAND1"

Posted

They appear to be loaded like misc_model_static. Adding gi.linkentity to it makes sense as to why it would fix it.

 

I'd like to mess around with it but I don't have the time or the willpower to do so.

Posted

Ok because I can't work out how to work github that well, can someone please add this fix in for SP:

void SP_misc_model_ghoul( gentity_t *ent )
{
#if 1
ent->s.modelindex = G_ModelIndex( ent->model );
gi.G2API_InitGhoul2Model(ent->ghoul2, ent->model, ent->s.modelindex, NULL_HANDLE, NULL_HANDLE, 0, 0);
ent->s.radius = 50;
//enable origin & angles to be set via radiant
G_SetOrigin( ent, ent->s.origin );
G_SetAngles( ent, ent->s.angles );
//fixed to enable GLM model loading
gi.linkentity (ent);

Just replace the entire #if 1 part up until the #else in g_misc_model.cpp

 

 

What it does:

 

- Supports GLM model loading

- Rotation & origin can be set via the entity as normal

 

What it doesn't do:

 

- Loading of .skin files. You will need to set up your model textures as you would when making an MD3

- Animation. I tried to get this to work but it didn't set animation per entity, instead it set it for all the misc_model_ghoul's in the map

- Model scaling

- Model is non-solid, so you will need to use clip brushes

Posted

You're better off making an NPC play an anim for you with icarus than using one of these though.  Especially since misc_model_ghoul is specific to SP.

 

And yes, they're just a normal entity, not BSP'd like md3's.  Thats only md3s and only done in the compile process.

Tempust85 likes this
Posted

Using the Github app, it's a simple process:

 

- Make a fork of OpenJK on Github

- In the Github App, clone the fork

- Make changes to the code

- Commit the code to your fork (github app -> hit arrow on your fork, select files and push to repository)

- Make a pull request on JACoders/OpenJK

Posted

Added modelscale & modelscale_vec. Tested and working:

void SP_misc_model_ghoul( gentity_t *ent )
{
#if 1
ent->s.modelindex = G_ModelIndex( ent->model );
gi.G2API_InitGhoul2Model(ent->ghoul2, ent->model, ent->s.modelindex, NULL_HANDLE, NULL_HANDLE, 0, 0);
ent->s.radius = 50;
//DT EDIT: enable origin & angles to be set via radiant
G_SetOrigin( ent, ent->s.origin );
G_SetAngles( ent, ent->s.angles );
//DT EDIT: enable modelscale & modelscale_vec to be set via radiant
qboolean bHasScale = G_SpawnVector("modelscale_vec", "0 0 0", ent->s.modelScale);
if (!bHasScale)
{
float temp;
G_SpawnFloat( "modelscale", "0", &temp);
if (temp != 0.0f)
{
ent->s.modelScale[ 0 ] = ent->s.modelScale[ 1 ] = ent->s.modelScale[ 2 ] = temp;
bHasScale = qtrue;
}
}
if (bHasScale)
{
//scale the x axis of the bbox up.
ent->maxs[0] *= ent->s.modelScale[0];//*scaleFactor;
ent->mins[0] *= ent->s.modelScale[0];//*scaleFactor;
 
//scale the y axis of the bbox up.
ent->maxs[1] *= ent->s.modelScale[1];//*scaleFactor;
ent->mins[1] *= ent->s.modelScale[1];//*scaleFactor;
 
//scale the z axis of the bbox up and adjust origin accordingly
ent->maxs[2] *= ent->s.modelScale[2];
float oldMins2 = ent->mins[2];
ent->mins[2] *= ent->s.modelScale[2];
ent->s.origin[2] += (oldMins2-ent->mins[2]);
}
//DT EDIT: fixed to enable GLM model loading
gi.linkentity (ent);
#else
blah blah.............

So misc_model_ghoul can be used for static ghoul2 models. If you want animated ghoul2 models, use NPC_spawner and a spawnscript to play an animation. ;)

Archangel35757 likes this
Posted

I believe adding custom skin and shader support may not work so well due to the fact that they have to be cached and stored in some configstring.  Which would break saving compat.  :wacko:

Posted

Yeah I think just add in the scale stuff I posted above and call this entity fixed. Can always make a new NPC and use NPC_spawner to load it up if people want to use multiple skins and use animation.

Posted

Does saving and reloading, in effect, re-spawn the entities? I know that for players and NPCs it stores the playerstate (and possibly the entitystate too?), and it also stores current configstrings but I have no idea what else it stores.

  • 4 months later...
Posted

I think this is all of it in g_misc_model:

 

void SP_misc_model_ghoul(gentity_t *ent)
{
	ent->s.modelindex = G_ModelIndex(ent->model);
	gi.G2API_InitGhoul2Model(ent->ghoul2, 
	ent->model, ent->s.modelindex, NULL_HANDLE, NULL_HANDLE, 0, 0);
	ent->s.radius = 50;

	G_SetOrigin( ent, ent->s.origin);
	G_SetAngles( ent, ent->s.angles);

	qboolean bHasScale = G_SpawnVector("modelscale_vec", "0 0 0, ent->s.modelScale); 
	if (!bHasScale) 
	{ 
		float temp; 
		G_SpawnFloat( "modelscale", "0", &temp); 
		if (temp != 0.0f)
		{
 
			ent->s.modelScale[ 0 ] = ent->s.modelScale[ 1 ] = ent->s.modelScale[ 2 ] = temp; 
			bHasScale = qtrue; 
		} 
	} 

	if (bHasScale) 
	{ 
		//scale the x axis of the bbox up. 
		ent->maxs[0] *= ent->s.modelScale[0];//*scaleFactor;
		ent->mins[0] *= ent->s.modelScale[0];//*scaleFactor;

		//scale the y axis of the bbox up. 
		ent->maxs[1] *= ent->s.modelScale[1];//*scaleFactor;
		ent->mins[1] *=	ent->s.modelScale[1];//*scaleFactor;

 		//scale the z axis of the bbox up and adjust origin accordingly 
		ent->maxs[2] *= ent->s.modelScale[2];
		float oldMins2 = ent->mins[2];
		ent->mins[2] *= ent->s.modelScale[2]; 
		ent->s.origin[2] += (oldMins2-ent->mins[2]); 
	}

	gi.linkentity (ent);
  • 7 months later...
Posted

Ok, so here's my update:

void SP_misc_model_ghoul( gentity_t *ent )
{
	ent->s.modelindex = G_ModelIndex( ent->model );
	gi.G2API_InitGhoul2Model(ent->ghoul2, ent->model, ent->s.modelindex, NULL_HANDLE, NULL_HANDLE, 0, 0);
	ent->s.radius = 50;

	G_SetOrigin( ent, ent->s.origin );
	G_SetAngles( ent, ent->s.angles );

	qboolean bHasScale = G_SpawnVector( "modelscale_vec", "1 1 1", ent->s.modelScale );
	if ( !bHasScale ) {
		float temp;
		G_SpawnFloat( "modelscale", "0", &temp );
		if ( temp != 0.0f ) {
			ent->s.modelScale[0] = ent->s.modelScale[1] = ent->s.modelScale[2] = temp;
			bHasScale = qtrue;
		}
	}
	if ( bHasScale ) {
		//scale the x axis of the bbox up.
		ent->maxs[0] *= ent->s.modelScale[0];
		ent->mins[0] *= ent->s.modelScale[0];

		//scale the y axis of the bbox up.
		ent->maxs[1] *= ent->s.modelScale[1];
		ent->mins[1] *= ent->s.modelScale[1];

		//scale the z axis of the bbox up and adjust origin accordingly
		ent->maxs[2] *= ent->s.modelScale[2];
		float oldMins2 = ent->mins[2];
		ent->mins[2] *= ent->s.modelScale[2];
		ent->s.origin[2] += (oldMins2 - ent->mins[2]);
	}

	//DT EDIT: Added Ghoul2 animation code - START
	G_SpawnInt("startframe", "0", &ent->startFrame);
	G_SpawnInt("endframe", "0", &ent->endFrame);

	gi.G2API_SetBoneAnim(&ent->ghoul2[0], "model_root", ent->startFrame, ent->endFrame, BONE_ANIM_OVERRIDE_LOOP, 1.0f + crandom() * 0.1f, 0, -1, -1);
	ent->endFrame = 0; // don't allow it to do anything with the animation function in G_main
	//DT EDIT: Added Ghoul2 animation code - END

	gi.linkentity (ent);

Not sure about this line if it's needed:

ent->endFrame = 0; // don't allow it to do anything with the animation function in G_main

I can't work out how to do a pull request thing, so you'll have to manually add it for me. :P

Exmirai likes this
  • 2 weeks later...
Posted (edited)

I don't particularly want to make another thread about this, so I'm posting a help request here.

 

I'd like to have skin file read support for misc_model_ghoul (currently has to read the internal texture name in the GLM, which carcass doesn't do properly and the texture is white & the noesis route is VERY fiddley), but from what I can tell, there's no support for anything to do with skin files for map entities. How hard would it be exactly to add it, and could someone please point me in the right direction?

 

I've tried putting this in misc_model_ghoul and it does nothing:

	char	skinName[MAX_QPATH];
	int skin = gi.RE_RegisterSkin(skinName);

	gi.G2API_SetSkin(&ent->ghoul2[ent->playerModel], G_SkinIndex(skinName), skin);

I thought I'd try and get it to just load a model_default.skin seeing as every model does/should have one of these.

 

EDIT: Looks like I got it to work by adding this to misc_model_ghoul:

	char	*skinName;//[MAX_QPATH];
	int skin = gi.RE_RegisterSkin(skinName);

	G_SpawnString("skinFile", "models/players/kyle/model_default.skin", &skinName);

	gi.G2API_SetSkin(&ent->ghoul2[ent->playerModel], G_SkinIndex(skinName), skin);

It shows the skin & allows it to be specified on the misc_model_ghoul entity. Surf off/on work, as do shaders.  :)

Edited by DT85
Archangel35757 likes this
Posted

Only issue now is that it casts no shadow. I've commented out RF_SHADOW_PLANE in tr_ghoul2 & tr_mesh and while it shows stencil shadows on base JKA maps, it won't show any on mine for some reason so I can't even test out misc_model_ghoul shadows. :\

Posted

I had a look and I can't see it. Thing is though, the shadows appear on the model_static's in vjun3 but not on my own custom map.

Posted

Yeah I'm not sure what's going on. Projection shadows work, but they are offset from the floor unlike on the player model & NPC's so that's not a viable option. I guess I'm just going to have to fake the shadows with a patch and animate the texture for movement.

Posted

Tried but it won't work for some reason. Stencil & projected shadows work, but not all the time and not properly. Blob shadows don't work either. Not sure where blob shadows are even done, I can only find the other 2.

Posted

Tried but it won't work for some reason. Stencil & projected shadows work, but not all the time and not properly. Blob shadows don't work either. Not sure where blob shadows are even done, I can only find the other 2.

Maybe you're missing something in hooking in the shadow code for it? Maybe @@Xycaleth can help?

Tempust85 likes this
Posted

Tried but it won't work for some reason. Stencil & projected shadows work, but not all the time and not properly. Blob shadows don't work either. Not sure where blob shadows are even done, I can only find the other 2.

Blob shadows are done by the cgame module. They're completely separate from the renderer.

 

For projected shadows (r_shadow 2) to work, it looks like you need to set the shadowPlane field on the object's refEntity_t. This is usually done in cgame as well (CG_PlayerShadow in cg_players.c) so you could do this for misc_model_ghouls as well. I'm going to guess that misc_model_ghouls are ET_GENERAL entities, so take a look perhaps at setting the shadowPlane in CG_General in cg_ents.c

Tempust85 and Archangel35757 like this
Posted

Where would I fix the position of the shadows?

 

kyop2.jpg

 

From far left: misc_model_static, misc_model_ghoul, NPC_Jedi. As you can see, the shadows aren't hitting the floor but floating above the entity. Both misc_model_ghoul & static have the same issue.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...