diff --git a/SHADE_Application/src/Scenes/SBTestScene.cpp b/SHADE_Application/src/Scenes/SBTestScene.cpp index a6aa0f36..664497df 100644 --- a/SHADE_Application/src/Scenes/SBTestScene.cpp +++ b/SHADE_Application/src/Scenes/SBTestScene.cpp @@ -44,7 +44,7 @@ namespace Sandbox { if (mesh.meshName == "Cube.012") { - handles.push_back(graphicsSystem->AddMesh( + handles.push_back(graphicsSystem->AddMesh( mesh.header.vertexCount, mesh.vertexPosition.data(), mesh.texCoords.data(), @@ -107,9 +107,9 @@ namespace Sandbox stressTestObjects.emplace_back(entity); } - auto entity = SHEntityManager::CreateEntity(); - auto& renderable = *SHComponentManager::GetComponent_s(entity); - auto& transform = *SHComponentManager::GetComponent_s(entity); + auto raccoonSpin = SHEntityManager::CreateEntity(); + auto& renderable = *SHComponentManager::GetComponent_s(raccoonSpin); + auto& transform = *SHComponentManager::GetComponent_s(raccoonSpin); renderable.Mesh = handles.front(); renderable.SetMaterial(customMat); @@ -137,7 +137,21 @@ namespace Sandbox //testObjRenderable.SetMaterial(matInst); SHADE::SHScriptEngine* scriptEngine = static_cast(SHADE::SHSystemManager::GetSystem()); - scriptEngine->AddScript(testObj, "TestScript"); + scriptEngine->AddScript(raccoonSpin, "RaccoonSpin"); + + auto raccoonShowcase = SHEntityManager::CreateEntity(); + auto& renderableShowcase = *SHComponentManager::GetComponent_s(raccoonShowcase); + auto& transformShowcase = *SHComponentManager::GetComponent_s(raccoonShowcase); + + renderableShowcase.Mesh = handles.front(); + renderableShowcase.SetMaterial(customMat); + renderableShowcase.GetModifiableMaterial()->SetProperty("data.color", SHVec4(0.0f, 0.0f, 0.0f, 0.0f)); + renderableShowcase.GetModifiableMaterial()->SetProperty("data.alpha", 1.0f); + renderableShowcase.GetModifiableMaterial()->SetProperty("data.textureIndex", 1); + + transformShowcase.SetWorldPosition({ 3.0f, -1.0f, -1.0f }); + transformShowcase.SetLocalScale({ 5.0f, 5.0f, 5.0f }); + scriptEngine->AddScript(raccoonShowcase, "RaccoonShowcase"); } void SBTestScene::Update(float dt) diff --git a/SHADE_Managed/src/Components/Transform.cxx b/SHADE_Managed/src/Components/Transform.cxx index e065015e..0f0716dc 100644 --- a/SHADE_Managed/src/Components/Transform.cxx +++ b/SHADE_Managed/src/Components/Transform.cxx @@ -35,7 +35,7 @@ namespace SHADE } void Transform::LocalRotation::set(Vector3 val) { - GetNativeComponent()->SetLocalPosition(Convert::ToNative(val)); + GetNativeComponent()->SetLocalRotation(Convert::ToNative(val)); } Vector3 Transform::LocalScale::get() { diff --git a/TempScriptsFolder/RaccoonShowcase.cs b/TempScriptsFolder/RaccoonShowcase.cs new file mode 100644 index 00000000..e2d6454d --- /dev/null +++ b/TempScriptsFolder/RaccoonShowcase.cs @@ -0,0 +1,31 @@ +using SHADE; +using System; + +public class RaccoonShowcase : Script +{ + public double RotateSpeed = 1.0; + public Vector3 ScaleSpeed = new Vector3(1.0, 1.0, 0.0); + private Transform Transform; + private double rotation = 0.0; + private Vector3 scale = Vector3.Zero; + private double originalScale = 1.0f; + public RaccoonShowcase(GameObject gameObj) : base(gameObj) {} + + protected override void awake() + { + Transform = GetComponent(); + if (Transform == null) + { + Debug.LogError("Transform is NULL!"); + } + + originalScale = Transform.LocalScale.z; + } + protected override void update() + { + rotation += RotateSpeed * 0.16; + scale += ScaleSpeed * 0.16; + Transform.LocalRotation = new Vector3(0.0f, rotation, 0.0f); + Transform.LocalScale = new Vector3(System.Math.Abs(System.Math.Sin(scale.x)) * originalScale, System.Math.Abs(System.Math.Cos(scale.y)) * originalScale, System.Math.Abs(System.Math.Sin(scale.z)) * originalScale); + } +} \ No newline at end of file diff --git a/TempScriptsFolder/RaccoonSpin.cs b/TempScriptsFolder/RaccoonSpin.cs new file mode 100644 index 00000000..7785cfd5 --- /dev/null +++ b/TempScriptsFolder/RaccoonSpin.cs @@ -0,0 +1,24 @@ +using SHADE; +using System; + +public class RaccoonSpin : Script +{ + public double RotateSpeed = 1.0; + private double rotation = 0.0; + private Transform Transform; + public RaccoonSpin(GameObject gameObj) : base(gameObj) { } + + protected override void awake() + { + Transform = GetComponent(); + if (Transform == null) + { + Debug.LogError("Transform is NULL!"); + } + } + protected override void update() + { + rotation += RotateSpeed * 0.16; + Transform.LocalRotation = new Vector3(0.0f, rotation, 0.0f); + } +} \ No newline at end of file diff --git a/TempScriptsFolder/TestScript.cs b/TempScriptsFolder/TestScript.cs deleted file mode 100644 index 185b543e..00000000 --- a/TempScriptsFolder/TestScript.cs +++ /dev/null @@ -1,34 +0,0 @@ -using SHADE; - -public class TestScript : Script -{ - public double Speed = 1.0; - public Vector3 ATestVector; - public bool ABoolean; - private Transform Transform; - private double time = 0.0; - public TestScript(GameObject gameObj) : base(gameObj) {} - - protected override void awake() - { - Debug.Log("TestScript.Awake()"); - Transform = GetComponent(); - if (Transform == null) - { - Debug.LogError("Transform is NULL!"); - } - } - protected override void start() - { - Debug.Log("TestScript.Start()"); - } - protected override void update() - { - time += Speed * 0.16; - Transform.GlobalPosition = new Vector3(System.Math.Sin(time), System.Math.Cos(time), 0.0f); - } - protected override void onDestroy() - { - Debug.Log("TestScript.OnDestroy()"); - } -} \ No newline at end of file