Several Questions
-
- Posts: 40
- Joined: Mon Sep 06, 2010 9:22 pm
Several Questions
First, sorry for my bad english...
So, my name is Lucas, I'm the creator of the LarX game engine, if you want to see a video of my editor, http://www.youtube.com/watch?v=FGuDtv5H1vk
I'm trying to change my old Physics System to bEPU, but I'm having some problems:
How to make an object IMMOVABLE? Don't apply gravity, just check for collisions... Tried BecomeKinematic() but the object keep falling... And I'm using TeletransportTo to move the Body...
How can I get the Scale values of the Entity? Is there a Vector3 with all the props, or am I going to need to make a class for every Entity? Cause Box has Width,Height and Lenght, instead of one Vector3 of Size.
I need the scale for serializing. The Position and Rotation I'm getting with the Vector3.Transform Method, transforming the World and Orientation Matrix to Vectors..
Ok, that's it for now!
Thanks for reading!
So, my name is Lucas, I'm the creator of the LarX game engine, if you want to see a video of my editor, http://www.youtube.com/watch?v=FGuDtv5H1vk
I'm trying to change my old Physics System to bEPU, but I'm having some problems:
How to make an object IMMOVABLE? Don't apply gravity, just check for collisions... Tried BecomeKinematic() but the object keep falling... And I'm using TeletransportTo to move the Body...
How can I get the Scale values of the Entity? Is there a Vector3 with all the props, or am I going to need to make a class for every Entity? Cause Box has Width,Height and Lenght, instead of one Vector3 of Size.
I need the scale for serializing. The Position and Rotation I'm getting with the Vector3.Transform Method, transforming the World and Orientation Matrix to Vectors..
Ok, that's it for now!
Thanks for reading!
Re: Several Questions
The engine is looking good 
While calling BecomeKinematic is one way to make an entity kinematic, you can also create them as kinematic initially. All entities have multiple constructors, some of which take a mass parameter, and some that do not. The ones that do not take a mass parameter will create a kinematic entity.
Basically, TeleportTo and setting the position in general is good for when you're actually teleporting with the intent to ignore collisions- otherwise, use velocities.

Kinematic entities have infinite inertia, so they are good options for static geometry. Kinematic entities can also move if you directly change their velocity, but gravity/collisions cannot change their velocity. Changing a dynamic entity to a kinematic entity will preserve whatever velocity the dynamic entity had by design. If you set the kinematic entity's LinearVelocity and AngularVelocity to zero, it will stop moving.How to make an object IMMOVABLE?
While calling BecomeKinematic is one way to make an entity kinematic, you can also create them as kinematic initially. All entities have multiple constructors, some of which take a mass parameter, and some that do not. The ones that do not take a mass parameter will create a kinematic entity.
I'm not clear on exactly how the TeleportTo is being used here, but be careful. An object will happily allow itself to be teleported through other objects without obeying collisions. This is because TeleportTo is truly teleporting the entity, Star Trek style. If you want to control the motion of an entity, using velocities is the best option. Collisions will correct penetrating velocities as necessary, preventing objects from ignoring each other.And I'm using TeletransportTo to move the Body...
Basically, TeleportTo and setting the position in general is good for when you're actually teleporting with the intent to ignore collisions- otherwise, use velocities.
Universal local scaling is not available in v0.14.1. Scale would need to be handled on a per-type basis. v0.15.0 includes significant redesigns to most of the engine which will let local scaling be implemented. If it isn't ready for v0.15.0, it will be put into the subsequent version. It won't be ready for some time, though.How can I get the Scale values of the Entity? Is there a Vector3 with all the props, or am I going to need to make a class for every Entity? Cause Box has Width,Height and Lenght, instead of one Vector3 of Size.
-
- Posts: 40
- Joined: Mon Sep 06, 2010 9:22 pm
Re: Several Questions
Thanks for the comment, and for the fast reply!
So, I make a box, and I have to make it -1 Position, so I change the Pos.Y to - 1, the code Pos is using is this:
public Vector3 Pos
{
get
{
Vector3 scale; Vector3 pos; Quaternion qua;
Object.WorldTransform.Decompose(out scale, out qua, out pos);
return pos;
}
set
{
Object.TeleportTo(value);
}
}
When I use it, the Box starts moving down, even if the mass is 0.
After, I try to set Kinematic to true, the code is:
public bool Kinematic
{
get { return !Object.IsDynamic; }
set
{
if (value)
{
Object.BecomeKinematic();
Object.LinearVelocity = Vector3.Zero;
Object.AngularVelocity = Vector3.Zero;
}
else
{
Object.BecomeDynamic(Mass);
}
}
}
But the box seems to continue falling, but I cant see it....
And, I create the box with: new Box(Vector3.Zero, 1, 1, 1)
I can change the values of Position and Rotation in Realtime. But, what can I do with the Scale?
My PhysicActor class is kinda like that:
It has an Entity Object:
public Entity Object;
In its constructors, it gets an Entity:
public BepuActorPlayer(Entity Entity...)
{
this.Object = Entity;
}
In the Draw, it pass the parameters to the Actor, that has the model to draw:
Engine.Render.AddModelToDraw(Actor.World, Actor.Model, Actor.Material, Actor.Changes);
Actor.Position = Vector3.Transform(Actor.Position, Object.WorldTransform);
Actor.RotationMatrix = Object.OrientationMatrix;
Actor.VectorRotation = Vector3.Transform(Actor.VectorRotation, Object.OrientationMatrix);
Vector3 scale; Vector3 pos; Quaternion qua;
Object.WorldTransform.Decompose(out scale, out qua, out pos);
Actor.Scale = scale;
Will I have to create several classes, like BoxBepuActorPlayer(Box Box...), TriangleMeshActorPlayer(TriangleMesh Mesh...), just because I can't access the Scale?
In my editor, for tests, what I want to do is create a plane, and a box above it...Norbo wrote:Kinematic entities have infinite inertia, so they are good options for static geometry. Kinematic entities can also move if you directly change their velocity, but gravity/collisions cannot change their velocity. Changing a dynamic entity to a kinematic entity will preserve whatever velocity the dynamic entity had by design. If you set the kinematic entity's LinearVelocity and AngularVelocity to zero, it will stop moving.How to make an object IMMOVABLE?
So, I make a box, and I have to make it -1 Position, so I change the Pos.Y to - 1, the code Pos is using is this:
public Vector3 Pos
{
get
{
Vector3 scale; Vector3 pos; Quaternion qua;
Object.WorldTransform.Decompose(out scale, out qua, out pos);
return pos;
}
set
{
Object.TeleportTo(value);
}
}
When I use it, the Box starts moving down, even if the mass is 0.
After, I try to set Kinematic to true, the code is:
public bool Kinematic
{
get { return !Object.IsDynamic; }
set
{
if (value)
{
Object.BecomeKinematic();
Object.LinearVelocity = Vector3.Zero;
Object.AngularVelocity = Vector3.Zero;
}
else
{
Object.BecomeDynamic(Mass);
}
}
}
But the box seems to continue falling, but I cant see it....
And, I create the box with: new Box(Vector3.Zero, 1, 1, 1)
I can change the values of Position and Rotation in Realtime. But, what can I do with the Scale?
My PhysicActor class is kinda like that:
It has an Entity Object:
public Entity Object;
In its constructors, it gets an Entity:
public BepuActorPlayer(Entity Entity...)
{
this.Object = Entity;
}
In the Draw, it pass the parameters to the Actor, that has the model to draw:
Engine.Render.AddModelToDraw(Actor.World, Actor.Model, Actor.Material, Actor.Changes);
Actor.Position = Vector3.Transform(Actor.Position, Object.WorldTransform);
Actor.RotationMatrix = Object.OrientationMatrix;
Actor.VectorRotation = Vector3.Transform(Actor.VectorRotation, Object.OrientationMatrix);
Vector3 scale; Vector3 pos; Quaternion qua;
Object.WorldTransform.Decompose(out scale, out qua, out pos);
Actor.Scale = scale;
Will I have to create several classes, like BoxBepuActorPlayer(Box Box...), TriangleMeshActorPlayer(TriangleMesh Mesh...), just because I can't access the Scale?
Re: Several Questions
I can't tell exactly what is going wrong; I'd recommend trying some stripped down versions of the configuration in a demo of the BEPUphysicsDemos project. Stripping away all the extra stuff should make it easier to analyze the behavior.In my editor, for tests, what I want to do is create a plane, and a box above it...
But the box seems to continue falling, but I cant see it....
BEPUphysics entities have no concept of "scale" at this time, so you're left with configuring the individual shape properties of each entity. Each entity type has different properties. Boxes have width/length/height, but a sphere just has radius, and a capsule has radius and length, and so on. The TriangleMesh is not an entity and actually does have a full WorldMatrix which can include deformations like scale.Will I have to create several classes, like BoxBepuActorPlayer(Box Box...), TriangleMeshActorPlayer(TriangleMesh Mesh...), just because I can't access the Scale?
There are a variety of ways to deal with this problem. A descriptive class per entity type is one option, although you will not be able to extract 'scale' from all entities' properties even with special cases.
-
- Posts: 40
- Joined: Mon Sep 06, 2010 9:22 pm
Re: Several Questions
So, I came back 
And, now, I'm using bEPU, it's working well, at least for now
I can make an object Kinematic, but I don't know how to make one thing:
I can get the scale of the object
I can get the rotation of the object
But how can I get the Position(Vector3) of the Object? I'm needing it for serializing...
EDIT: Going to try Matrix.Decompose(), but it doesn't work really well with me...
Ah, and I'm getting the Object Rotation by doing this:
public Vector3 BodyRotation
{
get
{
Vector3 sca; Quaternion rot; Vector3 pos;
Box.WorldTransform.Decompose(out sca, out rot, out pos);
return QuaternionToEuler(rot);
}
}
public Vector3 QuaternionToEuler(Quaternion rotation)
{
float q0 = rotation.W;
float q1 = rotation.Y;
float q2 = rotation.X;
float q3 = rotation.Z;
Vector3 radAngles = new Vector3();
radAngles.Y = (float)Math.Atan2(2 * (q0 * q1 + q2 * q3), 1 - 2 * (Math.Pow(q1, 2) + Math.Pow(q2, 2)));
radAngles.X = (float)Math.Asin(2 * (q0 * q2 - q3 * q1));
radAngles.Z = (float)Math.Atan2(2 * (q0 * q3 + q1 * q2), 1 - 2 * (Math.Pow(q2, 2) + Math.Pow(q3, 2)));
Vector3 angles = new Vector3();
angles.X = MathHelper.ToDegrees(radAngles.X);
angles.Y = MathHelper.ToDegrees(radAngles.Y);
angles.Z = MathHelper.ToDegrees(radAngles.Z);
return radAngles;
}
Is that right?

And, now, I'm using bEPU, it's working well, at least for now

I can make an object Kinematic, but I don't know how to make one thing:
I can get the scale of the object
I can get the rotation of the object
But how can I get the Position(Vector3) of the Object? I'm needing it for serializing...
EDIT: Going to try Matrix.Decompose(), but it doesn't work really well with me...
Ah, and I'm getting the Object Rotation by doing this:
public Vector3 BodyRotation
{
get
{
Vector3 sca; Quaternion rot; Vector3 pos;
Box.WorldTransform.Decompose(out sca, out rot, out pos);
return QuaternionToEuler(rot);
}
}
public Vector3 QuaternionToEuler(Quaternion rotation)
{
float q0 = rotation.W;
float q1 = rotation.Y;
float q2 = rotation.X;
float q3 = rotation.Z;
Vector3 radAngles = new Vector3();
radAngles.Y = (float)Math.Atan2(2 * (q0 * q1 + q2 * q3), 1 - 2 * (Math.Pow(q1, 2) + Math.Pow(q2, 2)));
radAngles.X = (float)Math.Asin(2 * (q0 * q2 - q3 * q1));
radAngles.Z = (float)Math.Atan2(2 * (q0 * q3 + q1 * q2), 1 - 2 * (Math.Pow(q2, 2) + Math.Pow(q3, 2)));
Vector3 angles = new Vector3();
angles.X = MathHelper.ToDegrees(radAngles.X);
angles.Y = MathHelper.ToDegrees(radAngles.Y);
angles.Z = MathHelper.ToDegrees(radAngles.Z);
return radAngles;
}
Is that right?
Re: Several Questions
Entity.CenterPosition 
The WorldTransform property is actually created directly from the OrientationMatrix and CenterPosition. Referencing those properties directly would be easier than decomposing the matrix.
Edit: There's also an OrientationQuaternion property if you need a quaternion representation.

The WorldTransform property is actually created directly from the OrientationMatrix and CenterPosition. Referencing those properties directly would be easier than decomposing the matrix.
Edit: There's also an OrientationQuaternion property if you need a quaternion representation.
-
- Posts: 40
- Joined: Mon Sep 06, 2010 9:22 pm
Re: Several Questions
And, how can I set a value for the rotation? Is there a way?
Re: Several Questions
All of those properties can be set.
The properties that are prefixed with Internal are not buffered, which means you will see the result of your set immediately. On the other hand, buffered property sets will be applied at the beginning of the next frame (when the write buffer is flushed).
The properties that are prefixed with Internal are not buffered, which means you will see the result of your set immediately. On the other hand, buffered property sets will be applied at the beginning of the next frame (when the write buffer is flushed).
-
- Posts: 40
- Joined: Mon Sep 06, 2010 9:22 pm
Re: Several Questions
But, for example:Norbo wrote:All of those properties can be set.
The properties that are prefixed with Internal are not buffered, which means you will see the result of your set immediately. On the other hand, buffered property sets will be applied at the beginning of the next frame (when the write buffer is flushed).
I have a Manipulator on my editor, that adds a value to the Rotation Vector3 of the actor, to rotate it.
In the bEPU Entity class, there is no rotation vector, for position I don't need to decompose the Matrix, but for Rotation I still do...
So, for example:
Actually, my Rotation value is like this:
public Vector3 Rotation
{
get
{
Vector3 sca; Quaternion rot; Vector3 pos;
Entity.WorldTransform.Decompose(out sca, out rot, out pos);
return QuaternionToEuler(rot);
}
set
{
}
}
What should I put in the Set Method?
Re: Several Questions
The triple-angle representation does require some decomposition, but just 'compose' the angles into a Matrix or Quaternion in the same but opposite manner in which you 'decompose' the Matrix or Quaternion into angles.
This requires making some arbitrary choices on your end on how you actually handle the angles. I prefer completely avoiding triple angles
This requires making some arbitrary choices on your end on how you actually handle the angles. I prefer completely avoiding triple angles

-
- Posts: 40
- Joined: Mon Sep 06, 2010 9:22 pm
Re: Several Questions
Hey, I did that, then I entered here againNorbo wrote:The triple-angle representation does require some decomposition, but just 'compose' the angles into a Matrix or Quaternion in the same but opposite manner in which you 'decompose' the Matrix or Quaternion into angles.
This requires making some arbitrary choices on your end on how you actually handle the angles. I prefer completely avoiding triple angles

hehe, it's working with Matrix.CreateFromYawPicthRow(value.x, value....)
Thanks for all the help!
-
- Posts: 40
- Joined: Mon Sep 06, 2010 9:22 pm
Re: Several Questions
I'm uploading a video to YouTube, when it's ready I will post here 

-
- Posts: 40
- Joined: Mon Sep 06, 2010 9:22 pm
Re: Several Questions
The YouTube video : http://www.youtube.com/watch?v=KeIqhq2YfTY
-
- Posts: 40
- Joined: Mon Sep 06, 2010 9:22 pm
Re: Several Questions
Thanks, I'm going to finish the Collision system here, and then I will post my Balad videoNorbo wrote:Neat
