DGL
https://delphigl.com/forum/

glNewtonRagDoll + glNewtonScene3DS
https://delphigl.com/forum/viewtopic.php?f=19&t=3500
Seite 1 von 1

Autor:  Stucuk [ Sa Nov 20, 2004 23:04 ]
Betreff des Beitrags:  glNewtonRagDoll + glNewtonScene3DS

I tryed to add ragdolls to the 3ds demo using the ragdoll source. But the ragdolls arn't rendered and a access violation happens when the program is closed (but the ball collides with the ragdoll)

Note: Newton.dll and glNewtonScene3DS Scene and textures not included (to keep it under 250kb)
Note 2: The ragdoll is "spawned" under the 1 in railroad.3ds

Dateianhänge:
Dateikommentar: Modifyed Version
glNewtonScene3DS.zip [125.01 KiB]
323-mal heruntergeladen

Autor:  Sascha Willems [ Mo Nov 22, 2004 16:55 ]
Betreff des Beitrags: 

Just for information : I've downloaded that demo yesterday, but I haven't had the time to dig deeper into it and find the bug. So please give me some time and I'll inform you on what causes the problem.

Autor:  Stucuk [ Mo Nov 22, 2004 17:00 ]
Betreff des Beitrags: 

k, thanks. If you wonder why id like to merge the 2, its cos im wanting to test Newton in a bsp world.

Autor:  Sascha Willems [ Di Nov 23, 2004 00:04 ]
Betreff des Beitrags: 

The ragdoll in your demo is perfectly working. You should have checked the rendering. You not only render the ragdolls at the wrong place in the code (so that they can't be seen), but you also don't activate VertexArrays when rendering the RagDolls. So you need to draw them right after you've drawn the 3DS-Scene (in your source, you render them after the camera has finally been set) and you need to enable vertex- and normalarrays before rendering the ragdoll.

The access violation when exiting then still occurs, but that seems to be another thing, cause the RagDoll works.

Autor:  Stucuk [ Di Nov 23, 2004 10:12 ]
Betreff des Beitrags: 

Thx. The access violation only seem to happen when NewtonDestroy(NewtonWorld); is called....... Yet the ragdoll demo calls the same thing in the same place.

Autor:  Sascha Willems [ Di Nov 23, 2004 12:32 ]
Betreff des Beitrags: 

That may be a bug in the version of Newton used in that demos. I'll try with the newest version, but for that I'll have to change some things in the source. I'll inform you if it works with the new newton DLL.

Autor:  Sascha Willems [ Do Dez 02, 2004 12:16 ]
Betreff des Beitrags: 

Haven't had the time to take a look into it earlier, but I found the "problem" : It lies in the material collision callbacks GenericContactBegin and GenericContactProcess. I use NewtonBodyGetUserData there to get user data from the ball (which is a normal newton body). But this function (as the name suggests) only works on bodies, not on ragdolls, so it causes the crash (not immediately but at exiting). So you need to define a special material for the ragdolls that won't call those callbacks. So in TGLForm.InitTimerTimer do this :
Code:
  1. // Ragdoll
  2. MatRagDoll := NewtonMaterialCreateGroupID(NewtonWorld);
  3. NewtonMaterialSetDefaultElasticity(NewtonWorld, MatWorld, MatRagDoll, 0.3);
  4. NewtonMaterialSetDefaultFriction(NewtonWorld, MatWorld, MatRagDoll, 1.1, 0.7);
  5.  

MatRagDoll is an integer, defined in the ragdoll unit.

And in RagDoll.Create at the end change the loop to the following :
Code:
  1. for i := 0 to High(Bone) do
  2.  begin
  3.  NewtonBodyGetMatrix(Bone[i].Body, @Bone[i].StartMatrix[0,0]);
  4.  NewtonBodySetMaterialGroupID(Bone[i].Body, MatRagdoll);
  5.  end;


The ragdoll now has it's own material and the callback (which causes the problems) won't get called when the ragdoll collides with the world or player.

Seite 1 von 1 Alle Zeiten sind UTC + 1 Stunde
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/