Page 6 of 8
Posted: Wed Oct 31, 2007 4:39 pm
by fps
i found an interesting video that shows weapon physcis in use i watched it without sound (broken speakers) so i dont know for sure if its appropriate but i didnt see anything wrong with it. watch the shotgun flip off the arm of the small couch. now i you could have snatched that out of the air and blown someone away that would have been an incredible game experience.
also i dont know if the video will show. the video is called "RagDoll Physics: Artform. Chapter One"
i foud it while looking through rag doll physics vids on you tube.
thanks,
fps
<object width="425" height="355"><param name="movie" value="
http://www.youtube.com/v/gFwUrcGzLZ4&re ... ram><param name="wmode" value="transparent"></param><embed src="
http://www.youtube.com/v/gFwUrcGzLZ4&rel=1" type="application/x-shockwave-flash" wmode="transparent" width="425" height="355"></embed></object>
Posted: Thu Nov 01, 2007 3:20 am
by kikosmalltalk
Hi Federico
Thank you again.
The that more it interests me at this time, it is the form that you use to Newton update.
Newton uses callback, that return the position of my actor. Something like that:
Code: Select all
void PhysicsSetTransform (const NewtonBody* body, const dFloat* matrix)
{
RenderPrimitive* primitive;
// get the graphic object form the rigid body
primitive = (RenderPrimitive*) NewtonBodyGetUserData (body);
// set the transformation matrix for this rigid body
dMatrix& mat = *((dMatrix*)matrix);
primitive->SetMatrix (mat);
}
I update newton this way:
Code: Select all
float t = 0.0f;
const float dt = 0.01f;
float currentTime = 0.0f;
float accumulator = 0.0f;
State previous;
State current;
while (!quit)
{
float newTime = time();
float deltaTime = newTime - currentTime;
currentTime = newTime;
accumulator += deltaTime;
while (accumulator>=dt)
{
previousState = currentState;
integrate(currentState, t, dt);
t += dt;
accumulator -= dt;
}
const float alpha = accumulator / dt;
State state = currentState*alpha + previousState*(1.0f-alpha);
render(state);
}
That it uses the same concept that their form of update Newton. Right ?.
you wrote:
UpdateLoop is defined in the physicsSystem entity and force the phsycisengine to run multiple update in the same frame.
The problem is that NewtonUpdate is executed 3 times and the frame 1 time, for example. When I relocate the actors I will have a stutterer problem.
As it describes the article that I commented him.
Do you understand? .
Now. Tokamak uses callback as Newton, but I don't find as Nout it solved the problem.
Did he use INTERPOLATION? .
This is the code:
Code: Select all
//Run now the real physics simulation
dwTicks = (float)(TimeTicks)/IterationTime;
geVec3d Pos;
//Calculate the new positions for all rigid bodies
//If the engine is slow, run multiple physics loops
for (int p = 0; p <(1 + dwTicks); p++)
{
gSim->Advance(AdvanceTime*0.001f);
for (int nr = 0; nr<sizeInfo.rigidBodiesCount; nr++)
{
//Calculate the new positions for all rigid bodies
neT3 trans = rBody[nr]->GetTransform();
geXForm3d M;
geXForm3d_SetIdentity(&M);
geVec3d Angles;
neGeometry *geom;
rBody[nr]->BeginIterateGeometry(); //get the corresponding actor index number
int s=0;
while (geom = rBody[nr]->GetNextGeometry())
{
if (s>0)
{
neT3 gtrans = geom->GetTransform();
neT3 gmt = trans * gtrans;
M.AX = gmt.rot[0][0];
M.BX = gmt.rot[0][1];
M.CX = gmt.rot[0][2];
M.AY = gmt.rot[1][0];
M.BY = gmt.rot[1][1];
M.CY = gmt.rot[1][2];
M.AZ = gmt.rot[2][0];
M.BZ = gmt.rot[2][1];
M.CZ = gmt.rot[2][2];
M.Translation.X = gmt.pos[0];
M.Translation.Y = gmt.pos[1];
M.Translation.Z = gmt.pos[2];
Pos.X = gmt.pos[0];
Pos.Y = gmt.pos[1];
Pos.Z = gmt.pos[2];
}
else
{
M.AX = trans.rot[0][0];
M.BX = trans.rot[0][1];
M.CX = trans.rot[0][2];
M.AY = trans.rot[1][0];
M.BY = trans.rot[1][1];
M.CY = trans.rot[1][2];
M.AZ = trans.rot[2][0];
M.BZ = trans.rot[2][1];
M.CZ = trans.rot[2][2];
M.Translation.X = trans.pos[0];
M.Translation.Y = trans.pos[1];
M.Translation.Z = trans.pos[2];
Pos.X = trans.pos[0];
Pos.Y = trans.pos[1];
Pos.Z = trans.pos[2];
}
int rgNr = geom->GetUserData();
CCD->ActorManager()->Position(PhActor[rgNr], Pos);
geXForm3d_GetEulerAngles(&M, &Angles);
CCD->ActorManager()->Rotate(PhActor[rgNr], Angles);
s++;
}
}
}
Best regards, KIKO
PD: I hope you understand what I mean
Posted: Thu Nov 01, 2007 11:51 am
by federico
@fps
http://www.youtube.com/watch?v=gFwUrcGzLZ4
The attribute entity is now physics driven, QoD added the ability to add entities at runtime. I think could be possible... theorically.
___
@kiko
yes I think it's an interpolation process. Your method and the Nout's one aren't different.
Nout on tokamak:
Code: Select all
//Run now the real physics simulation
dwTicks = (float)(TimeTicks)/IterationTime;
//Calculate the new positions for all rigid bodies
//If the engine is slow, run multiple physics loops
for (int p = 0; p <(1 + dwTicks); p++)
{
//Update Physics
}
TimeTicks is time sliced by RealityFactory. Where? in CCommonData.cpp. Look at the RF code.
Code: Select all
dwTicksGoneBy = CCD->GetTimePassed_F();
if(dwTicksGoneBy <= 0.0f)
return RGF_SUCCESS; // No time passed? Ignore call!
// ...
thePhysicsManager->Tick(dwTicksGoneBy);
Code: Select all
/* ------------------------------------------------------------------------------------ */
// Get the amount of time passed since the last call, in milliseconds.
// ..Return the result as a floating-point value.
/* ------------------------------------------------------------------------------------ */
geFloat CCommonData::GetTimePassed_F()
{
geFloat DeltaTime;
DeltaTime = (geFloat)TimeCounter - (geFloat)LastTimePoll;
LastTimePoll = TimeCounter;
LastTimePassed_D = (DWORD)DeltaTime; // Last elapsed time as DWORD
LastTimePassed_F = DeltaTime; // Need in both places
return DeltaTime;
}
so TimeTicks is the time sliced as in your code. My problem is that I don't unterstand exactly in your code where's the newtonupdate...
In my code is the PhysicsManager class in the Tick(TimeStep) method, as shown above.
Code: Select all
void CPhysicsManager::Tick(geFloat TimeTicks)
{
float dwTicks = 0.0f;
dwTicks = (float)(TimeTicks)*IterationTime;
for (int p = 0; p <(1 + dwTicks); p++)
{
//update your entities etc...
float theTick = dwTicks*AdvanceTime;
NewtonUpdate (nWorld, theTick);
}
}
IterationTime is a user defined value that tells the engine how to loop the physics against the graphics loop. In my case it is a value between 0.1 and 1 and I arranged to define this value in the world editor (0.4 is my default value).
a) 1 = results in a higher update
b) 0.1 = in lower update
a) bigger physics step = the physics sim is faster = more calculations needed to draw a frame = worse graphics framerate
b) smaller physics step = the physics sim is slower = less calculations needed to draw a frame = better graphics framerate
________________
Kiko I really need help on vehicles. I know you got it working, please share your code.
Federico
Posted: Fri Nov 02, 2007 9:58 pm
by fps
you have got to see the celfactor revolution videos.
check them out.
Posted: Fri Nov 02, 2007 11:33 pm
by kikosmalltalk
Hi Fediro
Did you see the code of example of Newton vehicleJoint?
and the code of StuntPlayground_2_0_source?.
My vehicle works, but I have problems with the control of Side Sleep.
What problem do you have with the vehicleJoint?.
Perhaps I can help.
you wrote:
My problem is that I don't unterstand exactly in your code where's the newtonupdate...
I update Newton this way in a called class NewtonSpaceManager:
Code: Select all
timer tick.
elapsed := timer elapsedTime .
(elapsed > 0.25) ifTrue:[elapsed:=0.25] .
accumulatedTime:=accumulatedTime + elapsed.
[accumulatedTime >= 0.016] whileTrue:[newtonWorld
update: 0.016.
accumulatedTime:=accumulatedTime - 0.016.
].
you wrote:
yes I think it's an interpolation process. Your method and the Nout's one aren't different.
The problem is that I cannot see where Nout makes the interpolation.
Federico you have their private mail, perhaps the one can clarify like it works
Best regards kiko
PD: Please, if you have some problem with the vehicleJoint, ask and I will try to help him
Posted: Sat Nov 03, 2007 10:05 pm
by fps
is there going to be a community release of the physics engine and jays release anytime soon?
Posted: Sat Nov 03, 2007 10:37 pm
by federico
as soon as I release the source, I think that Jay can easily integrate his features, so he can release an a community release of Realityfactory NGD. Anyway I hope that physics could actually be integrated in the RF stable release. I have to set up some things to release the alpha2. I've tried some experiment on cars, but I don't think I will go on in this way. Probably I will try a better solution to refine wet zones (instead of defining a water height) and something different in the update code to avoid the growing time paradox.
Posted: Mon Nov 05, 2007 1:47 pm
by fps
a time paradox!!!
could this possibly be the solution to all of mankinds problems?
Just kidding.
what it the matter with the time? (daylight saving, im up an hour early
).
So i should be asking jay that question.
thanks,
fps
Posted: Mon Nov 05, 2007 2:40 pm
by Jay
yes it's perfectly right with me if federico first finishes his work to an extent where he is content with it. Otherwise i will be working on the merging and he migth be working on new features at the same time, and then i release it and federico releases it 2 weeks later, and i have got to do the whole work again. (i think that's what you meant, federico?)
Posted: Mon Nov 05, 2007 2:58 pm
by fps
your right,
it wouldent make any sence to itergrate it before fredrico is happy with it.
just keep up the good work, both of you.
Posted: Wed Nov 07, 2007 3:47 pm
by fps
why is it that when i make a copy of demo6 and copy the ragpawn and its working parts, rename everything ragpawn3. then shoot it.
both ragpawns that are the same guy die?
Posted: Wed Nov 07, 2007 3:54 pm
by federico
Please be specific. Write the names of your entities (pawns and Ragdoll entities) with parameters.
What's 'ragpawn3'? Is it the szEntityname of the Pawn entity?
both ragpawns that are the same guy die?
I don't understand the question, sorry. You have two pawn entities and when the first dies, also the second one dies? Is that the issue?
Posted: Wed Nov 07, 2007 8:20 pm
by fps
the die at the exact same time.
it must be a naming problem because the both go ragdoll at he exact same time. like the bullet hits both of them.
that might be usefull for somthing intentional.
but now im just trying to but some more guys in the level.
Posted: Wed Nov 07, 2007 9:52 pm
by federico
please post the parameters of the ragdoll and pawn entities.
As a starting suggest, consider to check if the names are correctly setup.
the pawn has name 'XXX' so the RagdollEntity parameter in the ragdoll entity should be the same and the ActivationTrigger should be 'XXX_Die' according to my script.
In my script:
Code: Select all
if(in_pain)
{
SetEventState(EntityName#"_Die",true);
}
Posted: Thu Nov 08, 2007 8:53 pm
by kikosmalltalk
Hi Federico
Aaaaaaa!!!!. You send a private mail.
Excuse, I don't habitually look at the private mail of RF.
This is my code:
Code: Select all
VehicleDemo>>initializeVehicleJoint
"Initialize the receiver's vehicle joint"
vehicleJoint:= NewtonVehicleJoint world: self newtonWorld
upDirection: (GeVec3D x:0.0 y:1.0 z:0.0 )
body: self chassis body.
vehicleJoint tireCallback:( GenesisVehicle methodAddressAt:#tirePhysicsUpdate:);
userData: self .
Code: Select all
VehicleDemo>>initializeTires
" Initialize the receiver's tires. "
|tire1 tire2 tire3 tire4|
tires:=OrderedCollection new.
tire1:=FrontWheel for: self .
tire1 setupIn: (D3DXVECTOR3 x:-0.90 y:-0.75 z:-1.3).
self addTire: tire1.
tire2:=FrontWheel for: self .
tire2 setupIn: (D3DXVECTOR3 x:0.87 y:-0.75 z:-1.3).
self addTire: tire2 .
tire3:=RearWheel for: self .
tire3 setupIn: (D3DXVECTOR3 x:-0.87 y:-0.75 z:1.35).
self addTire: tire3 .
tire4:=RearWheel for: self .
tire4 setupIn: (D3DXVECTOR3 x:0.87 y:-0.75 z:1.35).
self addTire: tire4 .
self tires do:[:each | each setupActor]
Code: Select all
VehicleChassis>>initializeBody
|world inertia origin mass|
world:=self parent newtonWorld .
body:=NewtonRigidBody world: world
collision: self bodyCollision.
body autoFreeze: 0.
world unFreezeBody: body .
body userData: self;
transformCallback:(VehicleChassis _methodAddressAt: #transform:from:);
forceAndTorqueCallback:(VehicleChassis _methodAddressAt:#applyGravityForce:).
inertia:=bodyCollision calculeInertiaMatrix .
mass:=1000.0.
body massMatrix: mass
inertiaX: (inertia x * mass)
inertiaY: (inertia y * mass)
inertiaZ: (inertia z * mass).
origin:=GeVec3D x:0.0 y:0.2 z:0.0.
body centreOfMass: origin;
linearDamping:0.0 .
self bodyCollision release.
Code: Select all
VehicleWheel>>setupIn: aPosition
"Setup the receiver with default values"
|position rotation matrix|
position:=D3DXMATRIX identity translation: aPosition.
rotation:= D3DXMATRIX identity rotationY:89.55.
matrix:= rotation multiply: position .
id:=WINAPI NewtonVehicleAddTire: self vehicleJoint
with: matrix basicAddress
with: (GeVec3D x:0.0 y:0.0 z:1.0) basicAddress
with: self mass
with: self width
with: self radius
with: self suspensionShock
with: self suspensionSpring
with: self suspensionLength
with: self basicAddress
with: 0x100 .
Code: Select all
VehicleDemo(Class)>>controlCallback: pVehicleJoint
|vehicle|
vehicle:= NewtonVehicleJoint userDataFrom: pVehicleJoint.
vehicle control.
^NULL
Code: Select all
VehicleDemo>>control
|omega count|
omega := 0.0.
count := 0 .
self tires do:[:each | omega:= omega + each omeg] .
omega:= (omega / 4.0) abs.
self manualTransmission ifFalse:[
"& (omegaIsPositive)"
((self currentGear = 1)& (omega <= 1.0) & (self brakesOn))
ifTrue:[ self currentGear: 0].
(self currentGear = 0) ifTrue:[
(self throttle = 0.0)not ifTrue:[ self currentGear: 1]
ifFalse:[ (self brakeOn) ifTrue:[ self mThrottle:1.0;
brakesOn: false]
].
]
]
Code: Select all
VehicleDemo(Class)>>tirePhysicsUpdate: pVehicleJoint
" Update tire physics of the receiver"
|vehicle|
vehicle:= NewtonVehicleJoint userDataFrom: pVehicleJoint .
vehicle tirePhysics.
^NULL
Code: Select all
VehicleDemo>>tirePhysics
"Apply tire physics"
self tires do:[:each | each tirePhysics].
Code: Select all
VehicleRearWheel>>tirePhysics
|speed brakeAcceleration |
(brakes > 0.0) ifTrue:[
brakeAcceleration := self vehicleJoint calculateMaxBrakeAccelerationFor: self id.
" tell Newton you want this tire stooped but only if the torque need it is less than
the brakes pad can withstand (assume max brake pad torque is 500 newton * meter)"
self vehicleJoint brakeAccelerationFor: self id
acceleration: brakeAcceleration
maxFrictionTorque:1500.0 .
" set some side slip as function of the linear speed "
speed := self vehicleJoint longitudinalSpeedFor: self id .
self vehicleJoint maxSideSleepSpeedFor: self id with: speed *1000 ]
ifFalse:[brakes = 0.0].
super tirePhysics.
WINAPI NewtonVehicleSetTireTorque: self vehicleJoint
with: self id
with: self torque .
Code: Select all
VehicleFrontWheel>>tirePhysics
| speed load delta |
WINAPI NewtonVehicleSetTireSteerAngle: vehicleJoint
with: self id
with: steerAngle.
super tirePhysics .
Code: Select all
VehicleWheel>>tirePhysics
|speed load |
speed := (self omega "* radius* 3.6") abs.
load := self normalLoad.
self maxSideSleepSpeed: (speed * 0.1) ;
sideSleepCoefficient: (speed * load * load *0.8) .
speed := self longitudinalSpeed.
self maxLongitudinalSlideSpeed: (speed *0.1 );
longitudinalSlideCoefficient: ( speed * load *load* 0.8 ) .
In all ways it can be he very useful to look at Newton example and StundPlayGround.
I have problems to control the you skid
I hope you understand.
Have present that can have code to improve.
kiko