Started fixing texture tool (incomplete)
This commit is contained in:
		@@ -9,5 +9,6 @@ target_sources(${DAWN_TARGET_NAME}
 | 
			
		||||
    MeshRenderer.cpp
 | 
			
		||||
    CubeMeshHost.cpp
 | 
			
		||||
    CapsuleMeshHost.cpp
 | 
			
		||||
    QuadMeshHost.cpp
 | 
			
		||||
    MeshHost.cpp
 | 
			
		||||
)
 | 
			
		||||
							
								
								
									
										30
									
								
								src/dawn/scene/components/display/mesh/QuadMeshHost.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										30
									
								
								src/dawn/scene/components/display/mesh/QuadMeshHost.cpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,30 @@
 | 
			
		||||
// Copyright (c) 2023 Dominic Masters
 | 
			
		||||
// 
 | 
			
		||||
// This software is released under the MIT License.
 | 
			
		||||
// https://opensource.org/licenses/MIT
 | 
			
		||||
 | 
			
		||||
#include "QuadMeshHost.hpp"
 | 
			
		||||
 | 
			
		||||
using namespace Dawn;
 | 
			
		||||
 | 
			
		||||
QuadMeshHost::QuadMeshHost(SceneItem *item) :
 | 
			
		||||
  xy0(glm::vec2(-0.5f, -0.5f)), xy1(glm::vec2(0.5f, 0.5f)),
 | 
			
		||||
  uv0(glm::vec2(0, 0)), uv1(glm::vec2(1, 1)),
 | 
			
		||||
  MeshHost(item)
 | 
			
		||||
{
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void QuadMeshHost::onStart() {
 | 
			
		||||
  this->mesh.createBuffers(QUAD_VERTICE_COUNT, QUAD_INDICE_COUNT);
 | 
			
		||||
 | 
			
		||||
  useEffect([&]{
 | 
			
		||||
    QuadMesh::bufferQuadMesh(
 | 
			
		||||
      &this->mesh,
 | 
			
		||||
      glm::vec2(this->xy0),
 | 
			
		||||
      glm::vec2(this->uv0),
 | 
			
		||||
      glm::vec2(this->xy1),
 | 
			
		||||
      glm::vec2(this->uv1),
 | 
			
		||||
      0, 0
 | 
			
		||||
    );
 | 
			
		||||
  }, { &this->xy0, &this->xy1, &this->uv0, &this->uv1 })();
 | 
			
		||||
}
 | 
			
		||||
							
								
								
									
										25
									
								
								src/dawn/scene/components/display/mesh/QuadMeshHost.hpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								src/dawn/scene/components/display/mesh/QuadMeshHost.hpp
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,25 @@
 | 
			
		||||
// Copyright (c) 2023 Dominic Masters
 | 
			
		||||
// 
 | 
			
		||||
// This software is released under the MIT License.
 | 
			
		||||
// https://opensource.org/licenses/MIT
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
#include "MeshHost.hpp"
 | 
			
		||||
#include "display/mesh/QuadMesh.hpp"
 | 
			
		||||
 | 
			
		||||
namespace Dawn {
 | 
			
		||||
  class QuadMeshHost : public MeshHost {
 | 
			
		||||
    public:
 | 
			
		||||
      // @optional
 | 
			
		||||
      StateProperty<glm::vec2> xy0;
 | 
			
		||||
      // @optional
 | 
			
		||||
      StateProperty<glm::vec2> xy1;
 | 
			
		||||
      // @optional
 | 
			
		||||
      StateProperty<glm::vec2> uv0;
 | 
			
		||||
      // @optional
 | 
			
		||||
      StateProperty<glm::vec2> uv1;
 | 
			
		||||
 | 
			
		||||
      QuadMeshHost(SceneItem *item);
 | 
			
		||||
      void onStart() override;
 | 
			
		||||
  };
 | 
			
		||||
}
 | 
			
		||||
@@ -14,6 +14,8 @@ CharacterController2D::CharacterController2D(SceneItem *i) :
 | 
			
		||||
 | 
			
		||||
void CharacterController2D::onStart() {
 | 
			
		||||
  useEvent([&](float_t delta){
 | 
			
		||||
    if(velocity == glm::vec2(0, 0)) return;
 | 
			
		||||
 | 
			
		||||
    // Common variables
 | 
			
		||||
    auto myCollider = item->getComponent<Collider2D>();
 | 
			
		||||
 | 
			
		||||
@@ -62,11 +64,6 @@ void CharacterController2D::onStart() {
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // if(
 | 
			
		||||
    //   mathAbs<float_t>(moveAmount.x) <= 0.001f &&
 | 
			
		||||
    //   mathAbs<float_t>(moveAmount.y) <= 0.001f
 | 
			
		||||
    // ) return;
 | 
			
		||||
 | 
			
		||||
    transform->setLocalPosition(
 | 
			
		||||
      transform->getLocalPosition() + (glm::vec3(moveAmount.x, 0, moveAmount.y) * delta)
 | 
			
		||||
    );
 | 
			
		||||
@@ -83,5 +80,8 @@ void CharacterController2D::onStart() {
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Stop velocity near zero.
 | 
			
		||||
    if(mathAbs<float_t>(velocity.x) <= 0.001f) velocity.x = 0;
 | 
			
		||||
    if(mathAbs<float_t>(velocity.y) <= 0.001f) velocity.y = 0;
 | 
			
		||||
  }, getScene()->eventSceneUpdate);
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user