📄 oxnewtonbonesragdoll.pas
字号:
unit oxNewtonBonesRagdoll;
{******************************************************************************}
// [15-9-2007]: oxNewtonBonesRagdoll last change by Dave Gravel. //
{******************************************************************************}
{===============================================================================
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is "oxNewton opengl-Dynamics-delphi-component".
The Initial Developer of the Original Code is
Dave Gravel, OrionX3D Opengl & Delphi Programming, dave.gravel@cgocable.ca.
http://www.Dave.ServeUsers.com
http://www.k00m.sexidude.com
Portions created by Dave Gravel are Copyright (C) 2004 - 2006.
Dave Gravel. All Rights Reserved.
Contributor(s): GLScene (http://www.glscene.org) -
Julio Jerez and Alain Suero (http://www.newtondynamics.com) -
Sascha Willems (www.delphigl.de)
Skinned part based on the Lucas Goraieb code.
This he have create the skinned part based on my old ode ragdoll box demo good work.
This work is unfinished in the moment I working on the bones editor.
The ragdoll is build with custom joints and in smd format file loaded from the
nice GLScene tools and Newton dynamics.
================================================================================
oxNewton v1.55 by Dave Gravel.
PS: I request only one thing from the users of my oxNewton Component,
it is to put on your about or your help a comment saying you using the
oxNewton Component with my name Dave Gravel and my
e-mail: dave.gravel@cgocable.ca
Don't modify or remove any comment or information on my file
if you do some modification on my code please contact me.
Read the Newton license too, it is realy important.
================================================================================}
interface
{******************************************************************************}
// [15-9-2007]: oxNewtonBonesRagdoll last change by Dave Gravel. //
{******************************************************************************}
uses
Forms, Windows, Messages, SysUtils, Classes, Graphics, Controls, ExtCtrls,
Dialogs, Math, VectorGeometry, GLObjects, GLMisc, GLScene, GLVectorFileObjects,
VectorLists, PersistentClasses, OpenGL1x, GLTexture, GLMesh, MeshUtils, GLState,
XCollection, GLGeomObjects, GLVerletClothify, XOpenGL, GLTerrainRenderer, VectorTypes,
GLCrossPlatform, GLContext, GLSilhouette, TGA, GLFileSMD, JPEG,
StdCtrls,
// oxNewton
oxNewtonImport, oxNewtondll, oxNewtonCustomJoints,
oxNewtonUtils;
{******************************************************************************}
// [15-9-2007]: TOXRagdoll last change by Dave Gravel. //
{******************************************************************************}
type
TOXRagdoll = class;
TRagdollBone = class;
TRagdollJoint = class
end;
{******************************************************************************}
// [15-9-2007]: TRagdollBoneList last change by Dave Gravel. //
{******************************************************************************}
TRagdollBoneList = class( TPersistentObjectList )
private
{ Private Declarations }
FRagdoll: TOXRagdoll;
protected
{ Protected Declarations }
function GetRagdollBone( Index: Integer ): TRagdollBone;
public
{ Public Declarations }
constructor Create( Ragdoll: TOXRagdoll );
destructor Destroy; override;
property Ragdoll: TOXRagdoll read FRagdoll;
property Items[Index: Integer]: TRagdollBone read GetRagdollBone; default;
end;
{******************************************************************************}
// [15-9-2007]: TRagdollBone last change by Dave Gravel. //
{******************************************************************************}
TRagdollBone = class ( TRagdollBoneList )
private
{ Private Declarations }
FOwner: TRagdollBoneList;
FName: String;
FBoneID: Integer;
FBoundMax: TOXVector3;
FBoundMin: TOXVector3;
FBoundBoneDelta: TOXVector3;
FOrigin: TOXVector3;
FSize: TOXVector3;
FJoint: TRagdollJoint;
FBoneMatrix: TOXMatrix;
FReferenceMatrix: TOXMatrix;
FOriginalMatrix: TOXMatrix;
FAnchor: TOXVector3;
procedure SetAnchor( Anchor: TOXVector3 );
procedure AlignToSkeleton;
procedure CreateBoundingBox;
procedure CreateBoundsChild;
procedure StartChild;
procedure AlignChild;
procedure UpdateChild;
procedure StopChild;
protected
{ Protected Declarations }
function GetRagdollBone( Index: Integer ): TRagdollBone;
procedure Start; virtual; abstract;
procedure Align; virtual; abstract;
procedure Update; virtual; abstract;
procedure Stop; virtual; abstract;
public
{ Public Declarations }
constructor CreateOwned( aOwner: TRagdollBoneList );
constructor Create( Ragdoll: TOXRagdoll );
destructor Destroy; override;
property Owner: TRagdollBoneList read FOwner;
property Name: String read FName write FName;
property BoneID: Integer read FBoneID write FBoneID;
property Origin: TOXVector3 read FOrigin;
property Size: TOXVector3 read FSize;
property Joint: TRagdollJoint read FJoint write FJoint;
property Anchor: TOXVector3 read FAnchor;
property BoneMatrix: TOXMatrix read FBoneMatrix;
property ReferenceMatrix: TOXMatrix read FReferenceMatrix;
property Items[Index: Integer]: TRagdollBone read GetRagdollBone; default;
end;
{******************************************************************************}
// [15-9-2007]: TOXRagdoll last change by Dave Gravel. //
{******************************************************************************}
TOXRagdoll = class( TPersistentObject )
private
{ Private Declarations }
FOwner: TGLBaseMesh;
FRootBone: TRagdollBone;
FEnabled: Boolean;
FBuilt: Boolean;
protected
{ Protected Declarations }
public
{ Public Declarations }
constructor Create( AOwner: TGLBaseMesh );
destructor Destroy; override;
procedure SetRootBone( RootBone: TRagdollBone );
procedure BuildRagdoll;
procedure Start;
procedure Update;
procedure Stop;
property Owner: TGLBaseMesh read FOwner;
property RootBone: TRagdollBone read FRootBone;
property Enabled: Boolean read FEnabled;
end;
{******************************************************************************}
// [15-9-2007]: TNewtonRagdollHingeJoint last change by Dave Gravel. //
{******************************************************************************}
TNewtonRagdollHingeJoint = class( TRagdollJoint )
private
FLimitationMin0: Float;
FLimitationMax0: Float;
FAxis: TOXVector3;
FName: string;
public
constructor Create( Axis: TOXVector3;
LimitationMin0: Float; LimitationMax0: Float );
property Name: string read FName write FName;
property Axis: TOXVector3 read FAxis;
property LimitationMin0: Float read FLimitationMin0 write FLimitationMin0;
property LimitationMax0: Float read FLimitationMax0 write FLimitationMax0;
end;
{******************************************************************************}
// [15-9-2007]: TNewtonRagdollUniversalJoint last change by Dave Gravel. //
{******************************************************************************}
TNewtonRagdollUniversalJoint = class( TNewtonRagdollHingeJoint )
private
FLimitationMin1: Float;
FLimitationMax1: Float;
FAxis2: TOXVector3;
public
constructor Create
( Axis: TOXVector3; LimitationMin0: Float; LimitationMax0: Float;
Axis2: TOXVector3; LimitationMin1: Float; LimitationMax1: Float );
property Axis2: TOXVector3 read FAxis2;
property LimitationMin1: Float read FLimitationMin1 write FLimitationMin1;
property LimitationMax1: Float read FLimitationMax1 write FLimitationMax1;
end;
{******************************************************************************}
// [15-9-2007]: TNewtonRagdoll last change by Dave Gravel. //
{******************************************************************************}
type
TNewtonRagdoll = class;
TNewtonRagdollDummyJoint = class( TRagdollJoint )
end;
{******************************************************************************}
// [15-9-2007]: TNewtonRagdollBone last change by Dave Gravel. //
{******************************************************************************}
TNewtonRagdollBone = class( TRagdollBone )
private
FOwner: TNewtonRagdollBone;
FRagdoll: TNewtonRagdoll;
FBody: PNewtonBody;
FGeom: PNewtonCollision;
FForceAndTorque: TOXPhysicsApplyForceAndTorque;
protected
procedure Start; override;
procedure Align; override;
procedure Update; override;
procedure Stop; override;
public
constructor CreateOwned( aOwner: TNewtonRagdollBone );
constructor Create( Ragdoll: TNewtonRagdoll );
property Body: PNewtonBody read FBody write FBody;
property Geom: PNewtonCollision read FGeom write FGeom;
property ApplyForceAndTorque: TOXPhysicsApplyForceAndTorque read FForceAndTorque write FForceAndTorque;
end;
{******************************************************************************}
// [15-9-2007]: TNewtonRagdoll last change by Dave Gravel. //
{******************************************************************************}
TNewtonRagdoll = class( TOXRagdoll )
private
FGLSceneRoot: TGLBaseSceneObject;
FBodyList: TList;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -