Jump to content

misc_model_ghoul


Tempust85

Recommended Posts

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"

Link to comment

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

Link to comment

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

Link to comment

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
Link to comment
  • 4 months later...

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);
Link to comment
  • 7 months later...

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
Link to comment
  • 2 weeks later...

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
Link to comment

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. :\

Link to comment

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.

Link to comment

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

Archangel35757 and Tempust85 like this
Link to comment

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.

Link to comment

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...