Skip to content

Commit

Permalink
Voxel Sprite W.I.P functionnality.
Browse files Browse the repository at this point in the history
  • Loading branch information
Blackvoxel committed Aug 5, 2021
1 parent 9dd02aa commit 037211b
Showing 1 changed file with 64 additions and 6 deletions.
70 changes: 64 additions & 6 deletions src/ZVoxelSprite.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,73 @@ class ZVoxelSprite
public:
ZVoxelSector Sprite;

ZVoxelSprite() {}
ZVoxelSprite() {Sprite.Fill(0);}
ZVoxelSprite(Long sx, Long sy, Long sz) : Sprite(sx,sy,sz) { }

void Resize(ZVector3L * NewSize) { Sprite.ChangeSize(NewSize->x, NewSize->y, NewSize->z); }
void SetHandle(Long x, Long y, Long z)
{
Sprite.Handle_x = x;
Sprite.Handle_y = y;
Sprite.Handle_z = z;
}


bool ExtractFromWorld(ZVoxelWorld * World, ZVector3L * Position, int Direction)
{
return(World->WorldToSprite(&Sprite, Position, Direction));
}

bool Old_ExtractFromWorld(ZVoxelWorld * World, ZVector3L * Position, int Direction)
{
Long x,y,z;

//ZMemSize OtherInfos;
//UShort VoxelType;
ZVoxelLocation Loc;

ZVector3L Size;
int xf1, zf1, xf2, zf2;
Size.x = Sprite.Size_x; Size.y = Sprite.Size_y; Size.z = Sprite.Size_z;

switch (Direction)
{
default:
case 0: xf1 = 1 ; zf1 = 0; xf2 = 0; zf2 = 1; break;
case 1: xf1 = 0 ; zf1 = 1; xf2 = 1; zf2 = 0; break;
case 2: xf1 = -1; zf1 = 0; xf2 = 0; zf2 = -1;break;
case 3: xf1 = 0 ; zf1 = -1; xf2 = -1; zf2 = 0; break;
}


if (Size.x <= 0 || Size.y <= 0 || Size.z <= 0) return(false);
Resize(&Size);

for (z = 0 ; z<Size.z ; z++)
for (x = 0 ; x<Size.x ; x++)
for (y = 0 ; y<Size.y ; y++)
{
printf("(%d)",Position->y - Sprite.Handle_y + y);
World->GetVoxelLocation(&Loc, Position->x - Sprite.Handle_x + (x * xf1) + (z *zf1) , Position->y - Sprite.Handle_y + y , Position->z - Sprite.Handle_z + (x * xf2) + (z*zf2));
// VoxelType = Loc.Sector->Data[Loc.Offset];
Sprite.SetCube_Transfert_NSS(x,y,z, &Loc);

}
return(true);
}


bool PutIntoWorld(ZVoxelWorld * World, ZVector3L * Position, int Direction)
{
return(World->SpriteToWorld(&Sprite,Position, Direction));
}

bool Old_PutIntoWorld(ZVoxelWorld * World, ZVector3L * Position, int Direction)
{
Long x,y,z;

ZMemSize OtherInfos;
UShort VoxelType;
//ZMemSize OtherInfos;
//UShort VoxelType;
ZVoxelLocation Loc;

ZVector3L Size;
Expand All @@ -79,9 +137,9 @@ class ZVoxelSprite
for (x = 0 ; x<Size.x ; x++)
for (y = 0 ; y<Size.y ; y++)
{
World->GetVoxelLocation(&Loc, Position->x - Sprite.Handle_x + (x * xf1) + (z *zf1) , Position->y - Sprite.Handle_y , Position->z - Sprite.Handle_z + (x * xf2) + (z*zf2));
VoxelType = Loc.Sector->Data[Loc.Offset];
Sprite.SetCube_Transfert(x,y,z, &Loc);
World->GetVoxelLocation(&Loc, Position->x - Sprite.Handle_x + (x * xf1) + (z *zf1) , Position->y - Sprite.Handle_y +y , Position->z - Sprite.Handle_z + (x * xf2) + (z*zf2));
// VoxelType = Loc.Sector->Data[Loc.Offset];
Sprite.SetCube_TransfertTo_NSS(x,y,z, &Loc);

}
return(true);
Expand Down

0 comments on commit 037211b

Please sign in to comment.