different billboarding types

main
cosmonaut 2020-12-04 18:52:20 -08:00
parent 54f5976cd4
commit f6f78eccbb
6 changed files with 29 additions and 12 deletions

2
Kav

@ -1 +1 @@
Subproject commit 665ff6dd44ac12b7e73e6d9c1998db4797d668a4
Subproject commit ae445d94d3ad642cbda297ab97349f6f53090151

View File

@ -1,4 +1,5 @@
using Encompass;
using Kav;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@ -8,11 +9,19 @@ namespace KavTest
{
public Texture2D Texture { get; }
public Vector2 Origin { get; }
public float Rotation { get; }
public SpriteBillboardConstraint BillboardConstraint { get; }
public SpriteComponent(Texture2D texture, Vector2 origin)
{
public SpriteComponent(
Texture2D texture,
Vector2 origin,
float rotation,
SpriteBillboardConstraint billboardConstraint
) {
Texture = texture;
Origin = origin;
Rotation = rotation;
BillboardConstraint = billboardConstraint;
}
}
}

View File

@ -18,8 +18,12 @@ namespace KavTest.Spawners
);
AddComponent(entity, new Transform3DComponent(transform));
AddComponent(entity, new SpriteComponent(message.Texture, message.Origin));
AddComponent(entity, new AngularVelocityComponent(new Vector3(2f, 0, 0)));
AddComponent(entity, new SpriteComponent(
message.Texture,
message.Origin,
message.Rotation,
message.BillboardConstraint
));
}
}
}

View File

@ -247,8 +247,9 @@ namespace KavTest
WorldBuilder.SendMessage(new BillboardSpriteSpawnMessage(
mushroomGuyTexture,
new Vector3(3, 1, 10),
0,
Vector2.One
1f,
Vector2.One,
Kav.SpriteBillboardConstraint.Horizontal
));
// WorldBuilder.SendMessage(new StaticModelSpawnMessage(

View File

@ -1,4 +1,5 @@
using Encompass;
using Kav;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
@ -11,18 +12,21 @@ namespace KavTest.Messages
public Vector2 Origin { get; }
public float Rotation { get; }
public Vector2 Scale { get; }
public SpriteBillboardConstraint BillboardConstraint { get; }
public BillboardSpriteSpawnMessage(
Texture2D texture,
Vector3 position,
float rotation,
Vector2 scale
Vector2 scale,
SpriteBillboardConstraint billboardConstraint
) {
Texture = texture;
Origin = new Vector2(texture.Width / 2, texture.Height / 2);
Position = position;
Rotation = rotation;
Scale = scale;
BillboardConstraint = billboardConstraint;
}
}
}

View File

@ -98,17 +98,16 @@ namespace KavTest.Renderers
var transformComponent = GetComponent<Transform3DComponent>(entity);
var spriteComponent = GetComponent<SpriteComponent>(entity);
var angles = transformComponent.Transform.Orientation.EulerAngles();
yield return new Sprite(
spriteComponent.Texture,
transformComponent.Transform.Position,
spriteComponent.Origin,
angles.X,
spriteComponent.Rotation,
new Vector2(
transformComponent.Transform.Scale.X,
transformComponent.Transform.Scale.Y
)
),
spriteComponent.BillboardConstraint
);
}
}