Tempust85 Posted November 10, 2013 Posted November 10, 2013 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. 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 ) 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"
eezstreet Posted November 10, 2013 Posted November 10, 2013 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.
Tempust85 Posted November 11, 2013 Author Posted November 11, 2013 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
ensiform Posted November 11, 2013 Posted November 11, 2013 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
eezstreet Posted November 11, 2013 Posted November 11, 2013 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
Tempust85 Posted November 16, 2013 Author Posted November 16, 2013 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
ensiform Posted November 17, 2013 Posted November 17, 2013 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:
Tempust85 Posted November 17, 2013 Author Posted November 17, 2013 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.
eezstreet Posted November 17, 2013 Posted November 17, 2013 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.
Tempust85 Posted November 17, 2013 Author Posted November 17, 2013 I don't know about entities, but loading a savegame will re-run scripts. Very handy to edit scripts on-the-fly.
ensiform Posted April 13, 2014 Posted April 13, 2014 Any chance for a pull request on the modelscale stuff still? @@DT85
Tempust85 Posted April 14, 2014 Author Posted April 14, 2014 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);
Tempust85 Posted November 20, 2014 Author Posted November 20, 2014 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. Exmirai likes this
Tempust85 Posted December 4, 2014 Author Posted December 4, 2014 (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 December 4, 2014 by DT85 Archangel35757 likes this
Tempust85 Posted December 4, 2014 Author Posted December 4, 2014 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. :\
ensiform Posted December 4, 2014 Posted December 4, 2014 Probably RF_NOSHADOW being set on the refent
Tempust85 Posted December 5, 2014 Author Posted December 5, 2014 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.
ensiform Posted December 5, 2014 Posted December 5, 2014 Well I know that misc_model_statics are implicitly set as RF_NOSHADOW in SP and MP.
Tempust85 Posted December 5, 2014 Author Posted December 5, 2014 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.
Archangel35757 Posted December 7, 2014 Posted December 7, 2014 So you can't give it a property to make it cast shadows?
Tempust85 Posted December 7, 2014 Author Posted December 7, 2014 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.
Archangel35757 Posted December 8, 2014 Posted December 8, 2014 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
Xycaleth Posted December 8, 2014 Posted December 8, 2014 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
Tempust85 Posted December 9, 2014 Author Posted December 9, 2014 Where would I fix the position of the shadows? 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.
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now