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 Encompass;
using Kav;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
@ -8,11 +9,19 @@ namespace KavTest
{ {
public Texture2D Texture { get; } public Texture2D Texture { get; }
public Vector2 Origin { 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; Texture = texture;
Origin = origin; Origin = origin;
Rotation = rotation;
BillboardConstraint = billboardConstraint;
} }
} }
} }

View File

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

View File

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

View File

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

View File

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