Hey,
Yes i want. One Cube in my Game is created of 6 Rectangles. And this Rectangles must be implemented by the Collision/Physics Engine of DigitalRune :D
heres my Code to Create the Matrixes:
public class Transforms
{
//Variables
private v3 ChunkPos;
public Matrix[] Matrixes = null;
//Funktions
public Transforms(v3 ChunkPosition)
{
ChunkPos = ChunkPosition;
}
public void Create(Vector3 InChunkPosition, float Scale, Vector3 Rotation, int MatrixID)
{
//Check Matrix
if (Matrixes == null)
Matrixes = new Matrix[6];
//Create Position
Vector3 Position = new Vector3((ChunkPos.X * Static.MapChunkSize) + InChunkPosition.X, (ChunkPos.Y * Static.MapChunkSize) + InChunkPosition.Y, (ChunkPos.Z * Static.MapChunkSize) + InChunkPosition.Z);
//Create Scale/Rotation/Position
Matrixes[MatrixID] = Matrix.CreateScale(Scale) * Matrix.CreateRotationX(Rotation.X) *
Matrix.CreateRotationY(Rotation.Y) *
Matrix.CreateRotationZ(Rotation.Z) *
Matrix.CreateTranslation(Position);
}
//0 = FRONT
//1 = BACK
//2 = LEFT
//3 = RIGHT
//4 = TOP
//5 = DOWN
}
My Cube is created of 6 Transform Matrixes (instead of one Cube Model), because my whole Map is based on the Cubes. So i cant draw 129837198237 Cube-Models (because this would lag and 90% percent of the cubes arent seen by the player).
I do it like this:
//Left = 0
if (Static.Game.World.IsTransCube(Static.helper.AddV(TotalPosition, 0, 0, 1)) == true)
transforms.Create(new Vector3(TX, TY, TZ + Scale), Scale, new Vector3(Full / 2, 0, 0), 0);
//Right = 1
if (Static.Game.World.IsTransCube(Static.helper.AddV(TotalPosition, 0, 0, -1)) == true)
transforms.Create(new Vector3(TX, TY, TZ - Scale), Scale, new Vector3(Full / 2, Full, 0), 1);
//Front = 2
if (Static.Game.World.IsTransCube(Static.helper.AddV(TotalPosition, -1, 0, 0)) == true)
transforms.Create(new Vector3(TX - Scale, TY, TZ), Scale, new Vector3(0, 0, Full / 2), 2);
//Back = 3
if (Static.Game.World.IsTransCube(Static.helper.AddV(TotalPosition, 1, 0, 0)) == true)
transforms.Create(new Vector3(TX + Scale, TY, TZ), Scale, new Vector3(Full, Full, Full / 2), 3);
//Top = 4
if (Static.Game.World.IsTransCube(Static.helper.AddV(TotalPosition, 0, 1, 0)) == true)
transforms.Create(new Vector3(TX, TY + Scale, TZ), Scale, new Vector3(0, 0, 0), 4);
//Down = 5
if (Static.Game.World.IsTransCube(Static.helper.AddV(TotalPosition, 0, -1, 0)) == true)
transforms.Create(new Vector3(TX, TY - Scale, TZ), Scale, new Vector3(0, 0, Full), 5);
I check each side of the cube.
My Map looks like this: