FTE and ODE?

Discuss CSQC related programming.
Post Reply
drm_wayne
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

FTE and ODE?

Post by drm_wayne »

Im trying to get this to work based on this tutorial, but theres one problem:

https://spawnhost.wordpress.com/article ... cs-in-fte/

fte doesnt have that physics cvars... any idea what im doing wrong? the ode_double.dll is in the folder...
Max_Salivan
Posts: 96
Joined: Thu Dec 15, 2011 1:00 pm

Re: FTE and ODE?

Post by Max_Salivan »

Spike moved ode into plugin,you can download it here:http://triptohell.info/moodles/win32/
and type plug_load ode in console
Sorry for my english :)
drm_wayne
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: FTE and ODE?

Post by drm_wayne »

still doesnt work... im really tired of all those undocumented features...
I see my current game already dying because of that...
Julius
Posts: 98
Joined: Sun Aug 29, 2010 4:32 pm
Contact:

Re: FTE and ODE?

Post by Julius »

Did you have a look at this:
http://forums.insideqc.com/viewtopic.php?f=17&t=5686

But I agree, we need a user created FTEQW wiki to start collecting all this kind of information.
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: FTE and ODE?

Post by Spike »

as mentioned, I moved ODE to a plugin a while back. the primary reason was because I was working on bullet at the time (which I still never gave support for joints), and plugins can be unloaded. It existed as a built-in plugin for a while (that is, treated as a plugin despite not being a separate file), but eventually I kicked it out of the engine and into its own DLL, which allows it to statically link against the ODE library thereby avoiding the need to find a usable+compatible version of ODE.

recently I wanted to rework a few things like not loading random dlls simply because they were found in the quake directory with a suitable filename (some other engines might still have bugs that allow creating such files, even outside of any correct gamedir), so the plug_loaddefault 1 setting now loads only plugins that were selected via the menu_downloads menu. Set it to 2 to restore the previous behaviour.

plug_unload ode will take effect immediately by disabling the rigid body physics stuff, but plug_load ode will only affect physics after a map restart (savegame+loadgame should also count here) although any new cvars should be created promptly if you didn't already set them somehow anyway.
you can tell which plugins are loaded with the plug_list command

the physics_ode_enable cvar was redundant when you can just enable/disable the plugin itself instead (and the engine couldn't enforce its 0 value without lots of hacks) (and of course checking for physics_ode_enable if you're using bullet was weird).

I think I just saw a copypaste bug (from r_meshpitch support) that will probably prevent the ode plugin from working properly. it should still give some results, just not the ones you want.
Julius
Posts: 98
Joined: Sun Aug 29, 2010 4:32 pm
Contact:

Re: FTE and ODE?

Post by Julius »

So does anyone have a well working FTEQW implementation of ragdolls and basic rigid body physics that they are willing to share? I saw a video of Ragdolls in FTEQW a while back, but I can't recall it being linked to some sample code.

P.s.: @Spike, any plans to get back to implementing bullet, or has that been abandoned?
Nahuel
Posts: 495
Joined: Wed Jan 12, 2011 8:42 pm
Location: mar del plata

Re: FTE and ODE?

Post by Nahuel »

please spike we need a new extension

.float ragdoll

self.ragdoll = TRUE;

:razz: :razz: :razz: :razz: :razz: :razz: :razz: :razz:
:lol: :lol: :lol: :lol: :lol: :lol: :lol: :lol:
hi, I am nahuel, I love quake and qc.
Julius
Posts: 98
Joined: Sun Aug 29, 2010 4:32 pm
Contact:

Re: FTE and ODE?

Post by Julius »

This freely licensed model from Sauerbraten should come in the compatible .iqm format and has all the skeletal information for ragdoll physics. Could be a good test model.
https://opengameart.org/content/ironsnout-x10k
drm_wayne
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: FTE and ODE?

Post by drm_wayne »

I gave up on this, this is all undocumented and im not going to waste time just for that...
I had plans to make grenades and a few mapprops with proper physics, but i dont have motivation
for alot of trial and error....
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: FTE and ODE?

Post by Spike »

Sorry its taken me so long to actually look into this, I've been a little distracted by other things lately.
It also doesn't help that this forum is still swallowing long posts - that'll teach me to verify what I'm saying huh.
I don't have any plans regarding bullet. I've actually committed what I have now, but there's still no public build. It would be nice to get both working, but I don't personally have the interest at this time.

to get ode working now that its a plugin, you need to load up fte, go into the packages/updates menu (hidden somewhere on the options menu), and enable 'Plugins/ODE Plugin', the one with 5093+ after it.
(make sure there's no simple 'ode' entry listed, because that's one that you've manually installed and will be older - you can delete it from the updates menu).
the plug_load command should also work, but only until you exit the game.

Note that if you have a manifest file, you can put this into it and the user will be 'strongly encouraged' to download+enable the plugin streamlining what is above - this ONLY works for the default.fmf file. Other fmf files will be ignored if they try these lines.

Code: Select all

downloadsurl "https://fte.triptohell.info/downloadables.php"
install "Plugins/ODE Plugin"
Use these cvar settings. You should put them in your mod's default.cfg file.

Code: Select all

//apparently I was trying to mess with damping, and it was too strong (0.005 is apparently too high...). 5093 has revised defaults, but its possible a config file's settings will linger if a user had cfg_save_all set to 1.
set physics_ode_world_damping 0
//force a fixed tick rate, to stop things from suddenly exploding.
sv_mintic 0.013
sv_maxtic 0.013
In combination with the ode plugin being enabled via the updates menu, ode should now be functional.

At the end of W_FireGrenade:

Code: Select all

	missile.movetype = MOVETYPE_PHYSICS;
	missile.solid = SOLID_PHYSICS_CYLINDER;
	setsize(missile, '-16 -4 -4', '16 4 4');
	missile.mass = 1;
Your grenades will now obey physics better, as well as knock each other around.
They'll also roll along the floor and spin faster if they hit walls at an angle, etc.

At the bottom of PlaceItem:

Code: Select all

	if (substring(self.model, -4, -1) == ".bsp")
	{
		self.mass = 1;
		self.solid = SOLID_PHYSICS_BOX;
		self.movetype = MOVETYPE_PHYSICS;	
		self.origin_z += 1;	//move stuff up again slightly, in the hope that they won't ping across the map in a stupid way.
	}
Your ammo boxes will now be physics objects. You can fire grenades at them and they'll get knocked over and fall against each other, etc.


If you wish to create a joint, you need a new entity.

Code: Select all

void(entity e1, entity e2) makeajoint =
{
	entity j = spawn();
	j.movetype = MOVETYPE_NONE; //actually, it will move...
	j.origin = (e1.origin + e2.origin)*0.5; //hinges need pivots, for instance.
	j.angles = vectoangles(e1.origin - e2.origin); //and sometimes an orientation.
	j.enemy = e1;
	j.aiment = e2;
	j.movedir = [Vel, -FMax, Stop]; //various properties, depending on the joint type. if the y arg is positive then its [K, D, Stop] with CFM and ERP calculated from those and gahwthisthat. Or you can just leave it set to 0 0 0 and see what you get.
	j.jointtype = JOINTTYPE_POINT;
};
The above code will join the two physics bodies together with a joint. A body can be affected by multiple joints at a time of course, and in doing so you can connect complex objects together.
Really though, once you have ODE starting up the rest should be the same as DP, except that FTE's ODE support also works in csqc, and for the extra .doll stuff. I mention this because you might find better docs there.
Note that JOINTTYPE_POINT creates a ball+socket. the two ents will both rotate around the joint's origin (and possibly move the joint around with them. If one of your bodies is the world entity then you should be able to leave the other body dangling from it. FMax specifies some sort of angle limit, iirc.

If you have multiple physics bodies and some skeletal bones, you can use skel_set_bone_world to force those bones to be rendered where the physics bodies are.
Alternatively, as Nahuel asked for, you can create a .doll file and then set self.frame|=0x8000; for the frames that you want it to fully flop. You can do this purely from ssqc without any need to deal with csqc and its skeletal objects. However, you do need to be able to figure out the .doll [text file] format, and its almost totally undocumented.
drm_wayne
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: FTE and ODE?

Post by drm_wayne »

thanks, that looks great :D
Im going to test this soon :smile:

If it works good im even thinking about to add more mapobjects with physics kinda like the buckets in F.E.A.R / Condemned games (which will also wake up near enemys).

edit: seems to work, but why can i walk thru my barrels?? :confused:

Code: Select all

void physic_test()
{
	setsize(self, '-16 -4 -4', '16 4 4');
    self.movetype = MOVETYPE_PHYSICS;
    self.solid = SOLID_PHYSICS_CYLINDER;
    self.mass = 5;
    self.bouncefactor = 0.5;
    self.bouncestop = 0.1;
    self.friction = 1;
    precache_model ("models/firebarrel.md3");
	
	
    setmodel (self, "models/firebarrel.md3");
    setorigin (self, self.origin);
    physics_enable (self, 1);

}

toneddu2000
Posts: 1395
Joined: Tue Feb 24, 2009 4:39 pm
Location: Italy

Re: FTE and ODE?

Post by toneddu2000 »

for ragdolls you can try my ragdoll test here, my fteskel project as Julius linked and a modeling guide (very important for ragdolls and skeletal animation) I wrote here. I admire your courage, here few suggestions:
  1. Remember to scale to 1 every .iqm you export to fte. Non-1 models will behave weird with ODE
  2. ODE crashes A LOT. Get used to it. When you change a map or quit game, make sure to make a loop between skeletal characters, unload their models (setmodel(myentity,""))and localcmd(disconnect) first. Otherwise FTE will crash.
  3. if you plan to make a ssqc+csqc game put all ragdolls creation code to csqc. If you share for example skeletal player models between ssqc and csqc and shoot another player at position [300,-120,60], ragdoll will activate at [300,-120,60]. Next time, when any other player will be killed, no matter where they die, their ragdolls will play at [300,-120,60]! So, when a player dies, in ssqc clear player models and use CSQC_ParseEvent to create a brand new csqc skeletal entity with ragdoll code (I don't remember if fteskel uses that approach, probably worth a look)
  4. Ragdolls reaction to world geometry is sometimes..funny. You'll probably bang your head to wall many times to figure out why corpses react every time different to a shotgun blast, for example
After 6 months of trial and error I completely abandoned the idea of implementing ragdolls in projectUnknown and Crafter editor. So, if ever I should use ragdoll physics in my projects, I'll do it on pure csqc skeletal code + physics or no ragdoll at all (probably most the 2nd one), but, of course, this doesn't mean you cannot succeed. In case you make something good, don't forget to make a video! :biggrin:
Meadow Fun!! - my first commercial game, made with FTEQW game engine
drm_wayne
Posts: 232
Joined: Sat Feb 11, 2012 5:47 pm

Re: FTE and ODE?

Post by drm_wayne »

Well spikes examplecode works fine, but for some reason the player cant collide with the objects, but fuck it, at least it works for grenades ;)
Im currently focusing on getting my viewmodels to work, sadly i cant set attachments to my muzzleflash and shell ejecting, muzzlelfash spawns always at work origin...
Post Reply