Merge branch 'master' of http://www.hyzgame.com:3000/hyzboy/CMCore
This commit is contained in:
@@ -3,6 +3,13 @@
|
|||||||
#include<hgl/type/SortedSet.h>
|
#include<hgl/type/SortedSet.h>
|
||||||
#include<hgl/io/event/InputEventSource.h>
|
#include<hgl/io/event/InputEventSource.h>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 现阶段事件分发流程:
|
||||||
|
*
|
||||||
|
* 操作系统事件 -> Window -> RenderFramework -> WorkManager
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
namespace hgl::io
|
namespace hgl::io
|
||||||
{
|
{
|
||||||
struct EventHeader
|
struct EventHeader
|
||||||
@@ -23,19 +30,22 @@ namespace hgl::io
|
|||||||
Break,
|
Break,
|
||||||
};
|
};
|
||||||
|
|
||||||
class EventDispatch
|
/**
|
||||||
|
* 事件分发器
|
||||||
|
*/
|
||||||
|
class EventDispatcher
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
InputEventSource source_type;
|
InputEventSource source_type;
|
||||||
|
|
||||||
EventDispatch * parent_input_event;
|
EventDispatcher * parent_input_event;
|
||||||
|
|
||||||
SortedSet<EventDispatch *> event_dispatch_subscribers;
|
SortedSet<EventDispatcher *> child_dispatchers;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
void SetParent(EventDispatch *ie){parent_input_event=ie;}
|
void SetParent(EventDispatcher *ie){parent_input_event=ie;}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -46,9 +56,9 @@ namespace hgl::io
|
|||||||
if(!RangeCheck(header.type))
|
if(!RangeCheck(header.type))
|
||||||
return(EventProcResult::Break);
|
return(EventProcResult::Break);
|
||||||
|
|
||||||
if(!event_dispatch_subscribers.IsEmpty())
|
if(!child_dispatchers.IsEmpty())
|
||||||
{
|
{
|
||||||
for(EventDispatch *ie:event_dispatch_subscribers)
|
for(EventDispatcher *ie:child_dispatchers)
|
||||||
if(ie->OnEvent(header,data)==EventProcResult::Break)
|
if(ie->OnEvent(header,data)==EventProcResult::Break)
|
||||||
return EventProcResult::Break;
|
return EventProcResult::Break;
|
||||||
}
|
}
|
||||||
@@ -58,53 +68,27 @@ namespace hgl::io
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
EventDispatch()
|
EventDispatcher()
|
||||||
{
|
{
|
||||||
source_type=InputEventSource::Root;
|
source_type=InputEventSource::Root;
|
||||||
parent_input_event=nullptr;
|
parent_input_event=nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
EventDispatch(InputEventSource ies)
|
EventDispatcher(InputEventSource ies)
|
||||||
{
|
{
|
||||||
source_type=ies;
|
source_type=ies;
|
||||||
parent_input_event=nullptr;
|
parent_input_event=nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~EventDispatch()
|
virtual ~EventDispatcher()
|
||||||
{
|
{
|
||||||
if(parent_input_event)
|
if(parent_input_event)
|
||||||
parent_input_event->UnregisterEventDispatch(this);
|
parent_input_event->RemoveChildDispatcher(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool RegisterEventDispatch(EventDispatch *ie)
|
virtual bool AddChildDispatcher(EventDispatcher *ie);
|
||||||
{
|
virtual bool RemoveChildDispatcher(EventDispatcher *ie);
|
||||||
if(!ie)
|
|
||||||
return(false);
|
|
||||||
|
|
||||||
const InputEventSource ies=ie->GetInputEventSource();
|
|
||||||
|
|
||||||
if(!RangeCheck(ies))
|
|
||||||
return(false);
|
|
||||||
|
|
||||||
ie->SetParent(this);
|
|
||||||
|
|
||||||
return(event_dispatch_subscribers.Add(ie)!=-1);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool UnregisterEventDispatch(EventDispatch *ie)
|
|
||||||
{
|
|
||||||
if(!ie)return(false);
|
|
||||||
|
|
||||||
const InputEventSource ies=ie->GetInputEventSource();
|
|
||||||
|
|
||||||
if(!RangeCheck(ies))
|
|
||||||
return(false);
|
|
||||||
|
|
||||||
ie->SetParent(nullptr);
|
|
||||||
|
|
||||||
return event_dispatch_subscribers.Delete(ie);
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool Update(){return true;}
|
virtual bool Update(){return true;}
|
||||||
};//class EventDispatch
|
};//class EventDispatcher
|
||||||
}//namespace hgl::io
|
}//namespace hgl::io
|
@@ -1,7 +1,7 @@
|
|||||||
#ifndef HGL_IO_KEYBOARD_EVENT_INCLUDE
|
#ifndef HGL_IO_KEYBOARD_EVENT_INCLUDE
|
||||||
#define HGL_IO_KEYBOARD_EVENT_INCLUDE
|
#define HGL_IO_KEYBOARD_EVENT_INCLUDE
|
||||||
|
|
||||||
#include<hgl/io/event/EventDispatch.h>
|
#include<hgl/io/event/EventDispatcher.h>
|
||||||
namespace hgl
|
namespace hgl
|
||||||
{
|
{
|
||||||
namespace io
|
namespace io
|
||||||
@@ -158,11 +158,11 @@ namespace hgl
|
|||||||
os_char ch;
|
os_char ch;
|
||||||
};
|
};
|
||||||
|
|
||||||
class KeyboardEvent:public EventDispatch
|
class KeyboardEvent:public EventDispatcher
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
KeyboardEvent():EventDispatch(InputEventSource::Keyboard){}
|
KeyboardEvent():EventDispatcher(InputEventSource::Keyboard){}
|
||||||
virtual ~KeyboardEvent()=default;
|
virtual ~KeyboardEvent()=default;
|
||||||
|
|
||||||
EventProcResult OnEvent(const EventHeader &header,const uint64 data) override
|
EventProcResult OnEvent(const EventHeader &header,const uint64 data) override
|
||||||
@@ -177,7 +177,7 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(EventDispatch::OnEvent(header,data)==EventProcResult::Break)
|
if(EventDispatcher::OnEvent(header,data)==EventProcResult::Break)
|
||||||
return EventProcResult::Break;
|
return EventProcResult::Break;
|
||||||
|
|
||||||
return EventProcResult::Continue;
|
return EventProcResult::Continue;
|
||||||
|
@@ -1,6 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include<hgl/io/event/EventDispatch.h>
|
#include<hgl/io/event/EventDispatcher.h>
|
||||||
#include<hgl/math/Vector.h>
|
#include<hgl/math/Vector.h>
|
||||||
namespace hgl::io
|
namespace hgl::io
|
||||||
{
|
{
|
||||||
@@ -42,68 +42,31 @@ namespace hgl::io
|
|||||||
|
|
||||||
constexpr size_t MouseEventDataBytes=sizeof(MouseEventData);
|
constexpr size_t MouseEventDataBytes=sizeof(MouseEventData);
|
||||||
|
|
||||||
class MouseEvent:public EventDispatch
|
class MouseEvent:public EventDispatcher
|
||||||
{
|
{
|
||||||
MouseEventData *med;
|
MouseEventData *med=nullptr;
|
||||||
|
|
||||||
Vector2i position;
|
Vector2i position{};
|
||||||
|
|
||||||
bool pressed_statues[size_t(MouseButton::RANGE_SIZE)];
|
bool pressed_statues[size_t(MouseButton::RANGE_SIZE)]{};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
MouseEvent():EventDispatch(InputEventSource::Mouse)
|
MouseEvent():EventDispatcher(InputEventSource::Mouse){}
|
||||||
{
|
|
||||||
med=nullptr;
|
|
||||||
position.x=0;
|
|
||||||
position.y=0;;
|
|
||||||
hgl_zero(pressed_statues);
|
|
||||||
}
|
|
||||||
virtual ~MouseEvent()=default;
|
virtual ~MouseEvent()=default;
|
||||||
|
|
||||||
EventProcResult OnEvent(const EventHeader &header,const uint64 data) override
|
|
||||||
{
|
|
||||||
if(header.type==InputEventSource::Mouse)
|
|
||||||
{
|
|
||||||
med=(MouseEventData *)&data;
|
|
||||||
|
|
||||||
if(MouseEventID(header.id)==MouseEventID::Wheel)
|
virtual EventProcResult OnEvent (const EventHeader &header,const uint64 data) override;
|
||||||
{
|
|
||||||
if(OnWheel (med->x,med->y) )return EventProcResult::Break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
position.x=med->x;
|
|
||||||
position.y=med->y;
|
|
||||||
|
|
||||||
switch(MouseEventID(header.id))
|
virtual bool OnMove (int,int){return false;}
|
||||||
{
|
virtual bool OnWheel (int,int){return false;}
|
||||||
case MouseEventID::Move: if(OnMove (med->x,med->y) )return EventProcResult::Break;break;
|
|
||||||
case MouseEventID::Pressed: pressed_statues[med->button]=true;
|
|
||||||
if(OnPressed (med->x,med->y,MouseButton(med->button)))return EventProcResult::Break;break;
|
|
||||||
case MouseEventID::Released: pressed_statues[med->button]=false;
|
|
||||||
if(OnReleased (med->x,med->y,MouseButton(med->button)))return EventProcResult::Break;break;
|
|
||||||
case MouseEventID::DblClicked: if(OnDblClicked (med->x,med->y,MouseButton(med->button)))return EventProcResult::Break;break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(EventDispatch::OnEvent(header,data)==EventProcResult::Break)
|
virtual bool OnPressed (int,int,MouseButton){return false;}
|
||||||
return EventProcResult::Break;
|
virtual bool OnReleased (int,int,MouseButton){return false;}
|
||||||
|
virtual bool OnDblClicked(int,int,MouseButton){return false;}
|
||||||
return EventProcResult::Continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
virtual bool OnMove (int,int){return false;}
|
|
||||||
virtual bool OnWheel (int,int){return false;}
|
|
||||||
|
|
||||||
virtual bool OnPressed (int,int,MouseButton){return false;}
|
|
||||||
virtual bool OnReleased (int,int,MouseButton){return false;}
|
|
||||||
virtual bool OnDblClicked(int,int,MouseButton){return false;}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 某按键是否按下
|
* 某按键是否按下
|
||||||
*/
|
*/
|
||||||
const bool HasPressed(const MouseButton &mb)const
|
const bool HasPressed(const MouseButton &mb)const
|
||||||
{
|
{
|
||||||
if(!RangeCheck(mb))return(false);
|
if(!RangeCheck(mb))return(false);
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
#ifndef HGL_IO_WINDOW_EVENT_INCLUDE
|
#ifndef HGL_IO_WINDOW_EVENT_INCLUDE
|
||||||
#define HGL_IO_WINDOW_EVENT_INCLUDE
|
#define HGL_IO_WINDOW_EVENT_INCLUDE
|
||||||
|
|
||||||
#include<hgl/io/event/EventDispatch.h>
|
#include<hgl/io/event/EventDispatcher.h>
|
||||||
namespace hgl
|
namespace hgl
|
||||||
{
|
{
|
||||||
namespace io
|
namespace io
|
||||||
@@ -27,13 +27,13 @@ namespace hgl
|
|||||||
|
|
||||||
constexpr size_t WindowEventDataBytes=sizeof(WindowEventData);
|
constexpr size_t WindowEventDataBytes=sizeof(WindowEventData);
|
||||||
|
|
||||||
class WindowEvent:public EventDispatch
|
class WindowEvent:public EventDispatcher
|
||||||
{
|
{
|
||||||
WindowEventData *wed;
|
WindowEventData *wed;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
WindowEvent():EventDispatch(InputEventSource::Window){wed=nullptr;}
|
WindowEvent():EventDispatcher(InputEventSource::Window){wed=nullptr;}
|
||||||
virtual ~WindowEvent()=default;
|
virtual ~WindowEvent()=default;
|
||||||
|
|
||||||
virtual EventProcResult OnEvent(const EventHeader &header,const uint64 data) override
|
virtual EventProcResult OnEvent(const EventHeader &header,const uint64 data) override
|
||||||
@@ -50,7 +50,7 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(EventDispatch::OnEvent(header,data)==EventProcResult::Break)
|
if(EventDispatcher::OnEvent(header,data)==EventProcResult::Break)
|
||||||
return EventProcResult::Break;
|
return EventProcResult::Break;
|
||||||
|
|
||||||
return EventProcResult::Continue;
|
return EventProcResult::Continue;
|
||||||
@@ -61,7 +61,7 @@ namespace hgl
|
|||||||
virtual void OnResize(uint w,uint h){}
|
virtual void OnResize(uint w,uint h){}
|
||||||
virtual void OnActive(bool){}
|
virtual void OnActive(bool){}
|
||||||
virtual void OnClose (){}
|
virtual void OnClose (){}
|
||||||
};//class WindowEvent:public EventDispatch
|
};//class WindowEvent:public EventDispatcher
|
||||||
}//namespace io
|
}//namespace io
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
#endif//HGL_IO_WINDOW_EVENT_INCLUDE
|
#endif//HGL_IO_WINDOW_EVENT_INCLUDE
|
||||||
|
@@ -51,16 +51,6 @@ namespace hgl
|
|||||||
return glm::all(glm::epsilonEqual(q1,q2,err));
|
return glm::all(glm::epsilonEqual(q1,q2,err));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Matrix4f inverse(const Matrix4f &m)
|
|
||||||
{
|
|
||||||
return glm::inverse(m);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline Matrix4f transpose(const Matrix4f &m)
|
|
||||||
{
|
|
||||||
return glm::transpose(m);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成一个正角视图矩阵
|
* 生成一个正角视图矩阵
|
||||||
* @param left 左
|
* @param left 左
|
||||||
@@ -70,7 +60,7 @@ namespace hgl
|
|||||||
* @param znear 近平面z值
|
* @param znear 近平面z值
|
||||||
* @param zfar 远平台z值
|
* @param zfar 远平台z值
|
||||||
*/
|
*/
|
||||||
Matrix4f ortho( float left,
|
Matrix4f OrthoMatrix( float left,
|
||||||
float right,
|
float right,
|
||||||
float bottom,
|
float bottom,
|
||||||
float top,
|
float top,
|
||||||
@@ -84,14 +74,14 @@ namespace hgl
|
|||||||
* @param znear 近平面z值
|
* @param znear 近平面z值
|
||||||
* @param zfar 远平台z值
|
* @param zfar 远平台z值
|
||||||
*/
|
*/
|
||||||
Matrix4f ortho(float width,float height,float znear,float zfar);
|
Matrix4f OrthoMatrix(float width,float height,float znear,float zfar);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成一个正角视图矩阵
|
* 生成一个正角视图矩阵
|
||||||
* @param width 宽
|
* @param width 宽
|
||||||
* @param height 高
|
* @param height 高
|
||||||
*/
|
*/
|
||||||
Matrix4f ortho(float width,float height);
|
Matrix4f OrthoMatrix(float width,float height);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成一个透视矩阵
|
* 生成一个透视矩阵
|
||||||
@@ -100,7 +90,7 @@ namespace hgl
|
|||||||
* @param znear 近截面
|
* @param znear 近截面
|
||||||
* @param zfar 远截面
|
* @param zfar 远截面
|
||||||
*/
|
*/
|
||||||
Matrix4f perspective( float field_of_view,
|
Matrix4f PerspectiveMatrix( float field_of_view,
|
||||||
float aspect_ratio,
|
float aspect_ratio,
|
||||||
float znear,
|
float znear,
|
||||||
float zfar);
|
float zfar);
|
||||||
@@ -110,66 +100,70 @@ namespace hgl
|
|||||||
* @param target 目标位置
|
* @param target 目标位置
|
||||||
* @param up 向上向量
|
* @param up 向上向量
|
||||||
*/
|
*/
|
||||||
Matrix4f lookat(const Vector3f &eye,const Vector3f &target,const Vector3f &up=AxisVector::Z);
|
Matrix4f LookAtMatrix(const Vector3f &eye,const Vector3f &target,const Vector3f &up=AxisVector::Z);
|
||||||
|
|
||||||
inline Matrix4f translate(const Vector3f &v)
|
inline Matrix4f TranslateMatrix(const Vector3f &v)
|
||||||
{
|
{
|
||||||
return glm::translate(Matrix4f(1.0f),v);
|
return glm::translate(Matrix4f(1.0f),v);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Matrix4f translate(float x,float y,float z)
|
inline Matrix4f TranslateMatrix(float x,float y,float z)
|
||||||
{
|
{
|
||||||
return glm::translate(Matrix4f(1.0f),Vector3f(x,y,z));
|
return glm::translate(Matrix4f(1.0f),Vector3f(x,y,z));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Matrix4f translate(float x,float y)
|
inline Matrix4f TranslateMatrix(float x,float y)
|
||||||
{
|
{
|
||||||
return translate(x,y,1.0f);
|
return glm::translate(Matrix4f(1.0f),Vector3f(x,y,1.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Matrix4f scale(const Vector3f &v)
|
inline Matrix4f ScaleMatrix(const Vector3f &v)
|
||||||
{
|
{
|
||||||
return glm::scale(Matrix4f(1.0f),v);
|
return glm::scale(Matrix4f(1.0f),v);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Matrix4f scale(float x,float y,float z)
|
inline Matrix4f ScaleMatrix(float x,float y,float z)
|
||||||
{
|
{
|
||||||
return glm::scale(Matrix4f(1.0f),Vector3f(x,y,z));
|
return glm::scale(Matrix4f(1.0f),Vector3f(x,y,z));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Matrix4f scale(float x,float y)
|
inline Matrix4f ScaleMatrix(float x,float y)
|
||||||
{
|
{
|
||||||
return scale(x,y,1.0f);
|
return glm::scale(Matrix4f(1.0f),Vector3f(x,y,1.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Matrix4f scale(float s)
|
inline Matrix4f ScaleMatrix(float s)
|
||||||
{
|
{
|
||||||
return glm::scale(Matrix4f(1.0f),Vector3f(s,s,s));
|
return glm::scale(Matrix4f(1.0f),Vector3f(s,s,s));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Matrix4f rotate(float rad,const Vector3f &axis)
|
inline Matrix4f AxisXRotate(float rad){return glm::rotate(Matrix4f(1.0f),rad,AxisVector::X);}
|
||||||
|
inline Matrix4f AxisYRotate(float rad){return glm::rotate(Matrix4f(1.0f),rad,AxisVector::Y);}
|
||||||
|
inline Matrix4f AxisZRotate(float rad){return glm::rotate(Matrix4f(1.0f),rad,AxisVector::Z);}
|
||||||
|
|
||||||
|
inline Matrix4f AxisRotate(float rad,const Vector3f &axis)
|
||||||
{
|
{
|
||||||
return glm::rotate(Matrix4f(1.0f),rad,axis);
|
return glm::rotate(Matrix4f(1.0f),rad,axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Matrix4f rotate(float rad,float x,float y,float z)
|
inline Matrix4f AxisRotate(float rad,float x,float y,float z)
|
||||||
{
|
{
|
||||||
return glm::rotate(Matrix4f(1.0f),rad,Vector3f(x,y,z));
|
return glm::rotate(Matrix4f(1.0f),rad,Vector3f(x,y,z));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Matrix4f rotate(float rad,float x,float y)
|
inline Matrix4f AxisRotate(float rad,float x,float y)
|
||||||
{
|
{
|
||||||
return rotate(rad,x,y,1.0f);
|
return AxisRotate(rad,x,y,1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Matrix4f rotate(float rad,const Vector4f &axis)
|
inline Matrix4f AxisRotate(float rad,const Vector4f &axis)
|
||||||
{
|
{
|
||||||
return rotate(rad,Vector3f(axis.x,axis.y,axis.z));
|
return AxisRotate(rad,Vector3f(axis.x,axis.y,axis.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Vector3f rotate(const Vector3f &v3f,float rad,const Vector3f &axis)
|
inline Vector3f AxisRotate(const Vector3f &v3f,float rad,const Vector3f &axis)
|
||||||
{
|
{
|
||||||
Vector4f result = rotate(rad, axis)*Vector4f(v3f, 1.0f);
|
Vector4f result = AxisRotate(rad, axis)*Vector4f(v3f, 1.0f);
|
||||||
|
|
||||||
return Vector3f(result.x,result.y,result.z);
|
return Vector3f(result.x,result.y,result.z);
|
||||||
}
|
}
|
||||||
|
@@ -95,7 +95,7 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 摄氏度到开氏度
|
* 摄氏度到开尔文度
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline T Celsius2Kelvin(const T &c)
|
inline T Celsius2Kelvin(const T &c)
|
||||||
@@ -104,7 +104,7 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开氏度到摄氏度
|
* 开尔文度到摄氏度
|
||||||
*/
|
*/
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline T Kelvin2Celsius(const T &k)
|
inline T Kelvin2Celsius(const T &k)
|
||||||
|
@@ -101,7 +101,7 @@ namespace hgl
|
|||||||
|
|
||||||
void MakeNewestData(Matrix4f &mat) override
|
void MakeNewestData(Matrix4f &mat) override
|
||||||
{
|
{
|
||||||
mat=translate(offset);
|
mat=TranslateMatrix(offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -215,7 +215,7 @@ namespace hgl
|
|||||||
|
|
||||||
void MakeNewestData(Matrix4f &mat) override
|
void MakeNewestData(Matrix4f &mat) override
|
||||||
{
|
{
|
||||||
mat=rotate(angle,axis);
|
mat=AxisRotate(angle,axis);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -342,7 +342,7 @@ namespace hgl
|
|||||||
|
|
||||||
void MakeNewestData(Matrix4f &mat) override
|
void MakeNewestData(Matrix4f &mat) override
|
||||||
{
|
{
|
||||||
mat=scale(scale3f);
|
mat=ScaleMatrix(scale3f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -395,7 +395,7 @@ namespace hgl
|
|||||||
|
|
||||||
void MakeNewestData(Matrix4f &mat) override
|
void MakeNewestData(Matrix4f &mat) override
|
||||||
{
|
{
|
||||||
mat=lookat(eye,center,up);
|
mat=LookAtMatrix(eye,center,up);
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@@ -695,7 +695,7 @@ namespace hgl
|
|||||||
const Matrix4f GetMatrix()const //不能执行UpdateMatrix时的获取
|
const Matrix4f GetMatrix()const //不能执行UpdateMatrix时的获取
|
||||||
{
|
{
|
||||||
if(matrix_dirty)
|
if(matrix_dirty)
|
||||||
return translate(translation_vector)*ToMatrix(rotation_quat)*scale(scale_vector);
|
return TranslateMatrix(translation_vector)*ToMatrix(rotation_quat)*ScaleMatrix(scale_vector);
|
||||||
else
|
else
|
||||||
return matrix;
|
return matrix;
|
||||||
}
|
}
|
||||||
|
@@ -33,7 +33,7 @@ namespace hgl
|
|||||||
return ArrayList<T *>::Insert(index,obj);
|
return ArrayList<T *>::Insert(index,obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void Free() override ///<清除所有数据
|
virtual void Free() override ///<清除所有数据并释放缓冲区
|
||||||
{
|
{
|
||||||
Clear();
|
Clear();
|
||||||
ArrayList<T *>::Free();
|
ArrayList<T *>::Free();
|
||||||
|
@@ -1,5 +1,4 @@
|
|||||||
#ifndef HGL_STR_TEMPLATE_INCLUDE
|
#pragma once
|
||||||
#define HGL_STR_TEMPLATE_INCLUDE
|
|
||||||
|
|
||||||
#include<hgl/TypeFunc.h>
|
#include<hgl/TypeFunc.h>
|
||||||
namespace hgl
|
namespace hgl
|
||||||
@@ -2729,7 +2728,6 @@ namespace hgl
|
|||||||
if(pna->ToNumber(sp,result))
|
if(pna->ToNumber(sp,result))
|
||||||
{
|
{
|
||||||
++count;
|
++count;
|
||||||
|
|
||||||
result_list.Add(result);
|
result_list.Add(result);
|
||||||
|
|
||||||
++p;
|
++p;
|
||||||
@@ -3004,7 +3002,7 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将一串原始数据转转成16进制数值字符串
|
* 将一串原始数据转换成16进制数值字符串
|
||||||
* @param str 16进制数值字符串存入处
|
* @param str 16进制数值字符串存入处
|
||||||
* @param src 原始的数据
|
* @param src 原始的数据
|
||||||
* @param size 原始数据字节长度
|
* @param size 原始数据字节长度
|
||||||
@@ -3056,5 +3054,4 @@ namespace hgl
|
|||||||
|
|
||||||
template<typename T> inline void ToUpperHexStr(T *str,const void *data,const int size,const T gap_char=0){DataToHexStr<T>(str,(const uint8 *)data,size,UpperHexChar,gap_char);}
|
template<typename T> inline void ToUpperHexStr(T *str,const void *data,const int size,const T gap_char=0){DataToHexStr<T>(str,(const uint8 *)data,size,UpperHexChar,gap_char);}
|
||||||
template<typename T> inline void ToLowerHexStr(T *str,const void *data,const int size,const T gap_char=0){DataToHexStr<T>(str,(const uint8 *)data,size,LowerHexChar,gap_char);}
|
template<typename T> inline void ToLowerHexStr(T *str,const void *data,const int size,const T gap_char=0){DataToHexStr<T>(str,(const uint8 *)data,size,LowerHexChar,gap_char);}
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
#endif//HGL_STR_TEMPLATE_INCLUDE
|
|
||||||
|
@@ -507,9 +507,9 @@ namespace hgl
|
|||||||
/**
|
/**
|
||||||
* 和一个字符串进行比较
|
* 和一个字符串进行比较
|
||||||
* @param bs 比较字符串
|
* @param bs 比较字符串
|
||||||
* @return <0 自身小
|
* @return <0 此字符串小于参数字符串
|
||||||
* @return 0 等同
|
* @return 0 相等
|
||||||
* @return >0 自身大
|
* @return >0 此字符串大于参数字符串
|
||||||
*/
|
*/
|
||||||
int Comp(const SelfClass &bs)const
|
int Comp(const SelfClass &bs)const
|
||||||
{
|
{
|
||||||
@@ -525,9 +525,9 @@ namespace hgl
|
|||||||
/**
|
/**
|
||||||
* 和一个字符串进行比较
|
* 和一个字符串进行比较
|
||||||
* @param str 比较字符串
|
* @param str 比较字符串
|
||||||
* @return <0 自身小
|
* @return <0 此字符串小于参数字符串
|
||||||
* @return 0 等同
|
* @return 0 相等
|
||||||
* @return >0 自身大
|
* @return >0 此字符串大于参数字符串
|
||||||
*/
|
*/
|
||||||
int Comp(const T *str)const
|
int Comp(const T *str)const
|
||||||
{
|
{
|
||||||
@@ -546,9 +546,9 @@ namespace hgl
|
|||||||
* 和一个字符串进行比较
|
* 和一个字符串进行比较
|
||||||
* @param pos 起始位置
|
* @param pos 起始位置
|
||||||
* @param bs 比较字符串
|
* @param bs 比较字符串
|
||||||
* @return <0 自身小
|
* @return <0 此字符串小于参数字符串
|
||||||
* @return 0 等同
|
* @return 0 相等
|
||||||
* @return >0 自身大
|
* @return >0 此字符串大于参数字符串
|
||||||
*/
|
*/
|
||||||
int Comp(const uint pos,const SelfClass &bs)const
|
int Comp(const uint pos,const SelfClass &bs)const
|
||||||
{
|
{
|
||||||
@@ -566,9 +566,9 @@ namespace hgl
|
|||||||
* @param pos 起始位置
|
* @param pos 起始位置
|
||||||
* @param bs 比较字符串
|
* @param bs 比较字符串
|
||||||
* @param num 比较长度
|
* @param num 比较长度
|
||||||
* @return <0 自身小
|
* @return <0 此字符串小于参数字符串
|
||||||
* @return 0 等同
|
* @return 0 相等
|
||||||
* @return >0 自身大
|
* @return >0 此字符串大于参数字符串
|
||||||
*/
|
*/
|
||||||
int Comp(const uint pos,const SelfClass &bs,const int num)const
|
int Comp(const uint pos,const SelfClass &bs,const int num)const
|
||||||
{
|
{
|
||||||
@@ -585,9 +585,9 @@ namespace hgl
|
|||||||
* 和一个字符串进行比较
|
* 和一个字符串进行比较
|
||||||
* @param pos 起始位置
|
* @param pos 起始位置
|
||||||
* @param str 比较字符串
|
* @param str 比较字符串
|
||||||
* @return <0 自身小
|
* @return <0 此字符串小于参数字符串
|
||||||
* @return 0 等同
|
* @return 0 相等
|
||||||
* @return >0 自身大
|
* @return >0 此字符串大于参数字符串
|
||||||
*/
|
*/
|
||||||
int Comp(const uint pos,const T *str)const
|
int Comp(const uint pos,const T *str)const
|
||||||
{
|
{
|
||||||
@@ -607,9 +607,9 @@ namespace hgl
|
|||||||
* @param pos 起始位置
|
* @param pos 起始位置
|
||||||
* @param str 比较字符串
|
* @param str 比较字符串
|
||||||
* @param num 比较长度
|
* @param num 比较长度
|
||||||
* @return <0 自身小
|
* @return <0 此字符串小于参数字符串
|
||||||
* @return 0 等同
|
* @return 0 相等
|
||||||
* @return >0 自身大
|
* @return >0 此字符串大于参数字符串
|
||||||
*/
|
*/
|
||||||
int Comp(const uint pos,const T *str,const int num)const
|
int Comp(const uint pos,const T *str,const int num)const
|
||||||
{
|
{
|
||||||
@@ -625,11 +625,11 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 和那一个字符串进行比较,英文不区分大小写
|
* 和另一个字符串进行比较,英文不区分大小写
|
||||||
* @param bs 比较字符串
|
* @param bs 比较字符串
|
||||||
* @return <0 自身小
|
* @return <0 此字符串小于参数字符串
|
||||||
* @return 0 等同
|
* @return 0 相等
|
||||||
* @return >0 自身大
|
* @return >0 此字符串大于参数字符串
|
||||||
*/
|
*/
|
||||||
int CaseComp(const SelfClass &bs)const
|
int CaseComp(const SelfClass &bs)const
|
||||||
{
|
{
|
||||||
@@ -645,11 +645,11 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 和那一个字符串进行比较,英文不区分大小写
|
* 和另一个字符串进行比较,英文不区分大小写
|
||||||
* @param str 比较字符串
|
* @param str 比较字符串
|
||||||
* @return <0 自身小
|
* @return <0 此字符串小于参数字符串
|
||||||
* @return 0 等同
|
* @return 0 相等
|
||||||
* @return >0 自身大
|
* @return >0 此字符串大于参数字符串
|
||||||
*/
|
*/
|
||||||
int CaseComp(const T *str)const
|
int CaseComp(const T *str)const
|
||||||
{
|
{
|
||||||
@@ -665,12 +665,12 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 和那一个字符串比较指字长度的字符
|
* 和另一个字符串比较指定长度的字符
|
||||||
* @param bs 比较字符串
|
* @param bs 比较字符串
|
||||||
* @param num 比较字数
|
* @param num 比较字符数
|
||||||
* @return <0 自身小
|
* @return <0 此字符串小于参数字符串
|
||||||
* @return 0 等同
|
* @return 0 相等
|
||||||
* @return >0 自身大
|
* @return >0 此字符串大于参数字符串
|
||||||
*/
|
*/
|
||||||
int Comp(const SelfClass &bs,const int num)const
|
int Comp(const SelfClass &bs,const int num)const
|
||||||
{
|
{
|
||||||
@@ -688,12 +688,12 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 和那一个字符串比较指字长度的字符
|
* 和另一个字符串比较指定长度的字符
|
||||||
* @param str 比较字符串
|
* @param str 比较字符串
|
||||||
* @param num 比较字数
|
* @param num 比较字符数
|
||||||
* @return <0 自身小
|
* @return <0 此字符串小于参数字符串
|
||||||
* @return 0 等同
|
* @return 0 相等
|
||||||
* @return >0 自身大
|
* @return >0 此字符串大于参数字符串
|
||||||
*/
|
*/
|
||||||
int Comp(const T *str,const int num)const
|
int Comp(const T *str,const int num)const
|
||||||
{
|
{
|
||||||
@@ -709,12 +709,12 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 和那一个字符串比较指字长度的字符,英文不区分大小写
|
* 和另一个字符串比较指定长度的字符,英文不区分大小写
|
||||||
* @param bs 比较字符串
|
* @param bs 比较字符串
|
||||||
* @param num 比较字数
|
* @param num 比较字符数
|
||||||
* @return <0 自身小
|
* @return <0 此字符串小于参数字符串
|
||||||
* @return 0 等同
|
* @return 0 相等
|
||||||
* @return >0 自身大
|
* @return >0 此字符串大于参数字符串
|
||||||
*/
|
*/
|
||||||
int CaseComp(const SelfClass &bs,const int num)const
|
int CaseComp(const SelfClass &bs,const int num)const
|
||||||
{
|
{
|
||||||
@@ -732,12 +732,12 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 和那一个字符串比较指字长度的字符,英文不区分大小写
|
* 和另一个字符串比较指定长度的字符,英文不区分大小写
|
||||||
* @param str 比较字符串
|
* @param str 比较字符串
|
||||||
* @param num 比较字数
|
* @param num 比较字符数
|
||||||
* @return <0 自身小
|
* @return <0 此字符串小于参数字符串
|
||||||
* @return 0 等同
|
* @return 0 相等
|
||||||
* @return >0 自身大
|
* @return >0 此字符串大于参数字符串
|
||||||
*/
|
*/
|
||||||
int CaseComp(const T *str,const int num)const
|
int CaseComp(const T *str,const int num)const
|
||||||
{
|
{
|
||||||
@@ -753,12 +753,12 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 和那一个字符串比较指字长度的字符,英文不区分大小写
|
* 和另一个字符串比较指定长度的字符,英文不区分大小写
|
||||||
* @param str 比较字符串
|
* @param str 比较字符串
|
||||||
* @param num 比较字数
|
* @param num 比较字符数
|
||||||
* @return <0 自身小
|
* @return <0 此字符串小于参数字符串
|
||||||
* @return 0 等同
|
* @return 0 相等
|
||||||
* @return >0 自身大
|
* @return >0 此字符串大于参数字符串
|
||||||
*/
|
*/
|
||||||
int CaseComp(const uint pos,const T *str,const int num)const
|
int CaseComp(const uint pos,const T *str,const int num)const
|
||||||
{
|
{
|
||||||
|
@@ -192,11 +192,11 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查找字符串,英文无视大小写
|
* 查找字符串,英文不区分大小写
|
||||||
* @param str 要指找的字符串
|
* @param str 要查找的字符串
|
||||||
* @return 查找到的字符串的索引,未找到返回-1
|
* @return 查找到的字符串的索引,未找到返回-1
|
||||||
*/
|
*/
|
||||||
int CaseFind(const StringClass &str) const ///<查找字符串,英文无视大小写,未找到返回-1
|
int CaseFind(const StringClass &str) const ///<查找字符串,英文不区分大小写,未找到返回-1
|
||||||
{
|
{
|
||||||
const int count=Items.GetCount();
|
const int count=Items.GetCount();
|
||||||
StringClass** sl = Items.GetData();
|
StringClass** sl = Items.GetData();
|
||||||
@@ -219,9 +219,9 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 确认字符串存在,英文无视大小写
|
* 确认字符串存在,英文不区分大小写
|
||||||
*/
|
*/
|
||||||
bool CaseExist(const StringClass &str) const ///<确认字符串存在,英文无视大小写
|
bool CaseExist(const StringClass &str) const ///<确认字符串存在,英文不区分大小写
|
||||||
{
|
{
|
||||||
return CaseFind(str)!=-1;
|
return CaseFind(str)!=-1;
|
||||||
}
|
}
|
||||||
@@ -248,12 +248,12 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查找字符串,英文无视大小写,并指定最大比较长度
|
* 查找字符串,英文不区分大小写,并指定最大比较长度
|
||||||
* @param str 要指找的字符串
|
* @param str 要查找的字符串
|
||||||
* @param cn 限定的要查找字符串的最大长度
|
* @param cn 限定的要查找字符串的最大长度
|
||||||
* @return 查找到的字符串的索引,未找到返回-1
|
* @return 查找到的字符串的索引,未找到返回-1
|
||||||
*/
|
*/
|
||||||
int CaseFind(const StringClass &str,const int cn) const ///<查找字符串,英文无视大小写,未找到返回-1
|
int CaseFind(const StringClass &str,const int cn) const ///<查找字符串,英文不区分大小写,未找到返回-1
|
||||||
{
|
{
|
||||||
const int count=Items.GetCount();
|
const int count=Items.GetCount();
|
||||||
|
|
||||||
|
@@ -193,8 +193,10 @@ SET(IO_TEXT_FILES IO/TextOutputStream.cpp
|
|||||||
SET(INPUT_EVENT_FILES ${IO_INCLUDE_PATH}/event/KeyboardEvent.h
|
SET(INPUT_EVENT_FILES ${IO_INCLUDE_PATH}/event/KeyboardEvent.h
|
||||||
${IO_INCLUDE_PATH}/event/MouseEvent.h
|
${IO_INCLUDE_PATH}/event/MouseEvent.h
|
||||||
${IO_INCLUDE_PATH}/event/JoystickEvent.h
|
${IO_INCLUDE_PATH}/event/JoystickEvent.h
|
||||||
${IO_INCLUDE_PATH}/event/EventDispatch.h
|
${IO_INCLUDE_PATH}/event/EventDispatcher.h
|
||||||
${IO_INCLUDE_PATH}/event/InputMapping.h
|
${IO_INCLUDE_PATH}/event/InputMapping.h
|
||||||
|
IO/Event/MouseEvent.cpp
|
||||||
|
IO/Event/EventDispatcher.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
SOURCE_GROUP("IO\\Event" FILES ${INPUT_EVENT_FILES})
|
SOURCE_GROUP("IO\\Event" FILES ${INPUT_EVENT_FILES})
|
||||||
@@ -247,10 +249,10 @@ SOURCE_GROUP("Thread" FILES ${BASE_THREAD_HEADER_FILES}
|
|||||||
${BASE_THREAD_SOURCE_FILES})
|
${BASE_THREAD_SOURCE_FILES})
|
||||||
|
|
||||||
FILE(GLOB BASE_EVENT_HEADER_FILES ${CMCORE_ROOT_INCLUDE_PATH}/hgl/event/*.*)
|
FILE(GLOB BASE_EVENT_HEADER_FILES ${CMCORE_ROOT_INCLUDE_PATH}/hgl/event/*.*)
|
||||||
FILE(GLOB BASE_EVENT_SOURCE_FILES Event/*.*)
|
#FILE(GLOB BASE_EVENT_SOURCE_FILES Event/*.*)
|
||||||
|
|
||||||
SOURCE_GROUP("Event" FILES ${BASE_EVENT_HEADER_FILES}
|
SOURCE_GROUP("Event" FILES ${BASE_EVENT_HEADER_FILES})
|
||||||
${BASE_EVENT_SOURCE_FILES})
|
#${BASE_EVENT_SOURCE_FILES})
|
||||||
|
|
||||||
file(GLOB BASE_PLUG_IN_HEADER ${CMCORE_ROOT_INCLUDE_PATH}/hgl/plugin/*.h)
|
file(GLOB BASE_PLUG_IN_HEADER ${CMCORE_ROOT_INCLUDE_PATH}/hgl/plugin/*.h)
|
||||||
file(GLOB BASE_PLUG_IN_SOURCE PlugIn/*.cpp)
|
file(GLOB BASE_PLUG_IN_SOURCE PlugIn/*.cpp)
|
||||||
|
33
src/IO/Event/EventDispatcher.cpp
Normal file
33
src/IO/Event/EventDispatcher.cpp
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
#include<hgl/io/event/EventDispatcher.h>
|
||||||
|
|
||||||
|
namespace hgl::io
|
||||||
|
{
|
||||||
|
bool EventDispatcher::AddChildDispatcher(EventDispatcher *ie)
|
||||||
|
{
|
||||||
|
if(!ie)
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
const InputEventSource ies=ie->GetInputEventSource();
|
||||||
|
|
||||||
|
if(!RangeCheck(ies))
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
ie->SetParent(this);
|
||||||
|
|
||||||
|
return(child_dispatchers.Add(ie)!=-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EventDispatcher::RemoveChildDispatcher(EventDispatcher *ie)
|
||||||
|
{
|
||||||
|
if(!ie)return(false);
|
||||||
|
|
||||||
|
const InputEventSource ies=ie->GetInputEventSource();
|
||||||
|
|
||||||
|
if(!RangeCheck(ies))
|
||||||
|
return(false);
|
||||||
|
|
||||||
|
ie->SetParent(nullptr);
|
||||||
|
|
||||||
|
return child_dispatchers.Delete(ie);
|
||||||
|
}
|
||||||
|
}//namespace hgl::io
|
37
src/IO/Event/MouseEvent.cpp
Normal file
37
src/IO/Event/MouseEvent.cpp
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
#include<hgl/io/event/MouseEvent.h>
|
||||||
|
|
||||||
|
namespace hgl::io
|
||||||
|
{
|
||||||
|
EventProcResult MouseEvent::OnEvent(const EventHeader &header,const uint64 data)
|
||||||
|
{
|
||||||
|
if(header.type==InputEventSource::Mouse)
|
||||||
|
{
|
||||||
|
med=(MouseEventData *)&data;
|
||||||
|
|
||||||
|
if(MouseEventID(header.id)==MouseEventID::Wheel)
|
||||||
|
{
|
||||||
|
if(OnWheel (med->x,med->y) )return EventProcResult::Break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
position.x=med->x;
|
||||||
|
position.y=med->y;
|
||||||
|
|
||||||
|
switch(MouseEventID(header.id))
|
||||||
|
{
|
||||||
|
case MouseEventID::Move: if(OnMove (med->x,med->y) )return EventProcResult::Break;break;
|
||||||
|
case MouseEventID::Pressed: pressed_statues[med->button]=true;
|
||||||
|
if(OnPressed (med->x,med->y,MouseButton(med->button)))return EventProcResult::Break;break;
|
||||||
|
case MouseEventID::Released: pressed_statues[med->button]=false;
|
||||||
|
if(OnReleased (med->x,med->y,MouseButton(med->button)))return EventProcResult::Break;break;
|
||||||
|
case MouseEventID::DblClicked: if(OnDblClicked (med->x,med->y,MouseButton(med->button)))return EventProcResult::Break;break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(EventDispatcher::OnEvent(header,data)==EventProcResult::Break)
|
||||||
|
return EventProcResult::Break;
|
||||||
|
|
||||||
|
return EventProcResult::Continue;
|
||||||
|
}
|
||||||
|
}//namespace hgl::io
|
@@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
namespace hgl
|
namespace hgl
|
||||||
{
|
{
|
||||||
Matrix4f ortho( float left,
|
Matrix4f OrthoMatrix( float left,
|
||||||
float right,
|
float right,
|
||||||
float bottom,
|
float bottom,
|
||||||
float top,
|
float top,
|
||||||
@@ -51,9 +51,9 @@ namespace hgl
|
|||||||
* @param znear 近平面z值
|
* @param znear 近平面z值
|
||||||
* @param zfar 远平台z值
|
* @param zfar 远平台z值
|
||||||
*/
|
*/
|
||||||
Matrix4f ortho(float width,float height,float znear,float zfar)
|
Matrix4f OrthoMatrix(float width,float height,float znear,float zfar)
|
||||||
{
|
{
|
||||||
return ortho(0.0f,width,height,0.0f,znear,zfar);
|
return OrthoMatrix(0.0f,width,height,0.0f,znear,zfar);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,9 +61,9 @@ namespace hgl
|
|||||||
* @param width 宽
|
* @param width 宽
|
||||||
* @param height 高
|
* @param height 高
|
||||||
*/
|
*/
|
||||||
Matrix4f ortho(float width,float height)
|
Matrix4f OrthoMatrix(float width,float height)
|
||||||
{
|
{
|
||||||
return ortho(width,height,0.0f,1.0f);
|
return OrthoMatrix(width,height,0.0f,1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -73,7 +73,7 @@ namespace hgl
|
|||||||
* @param znear 近截面
|
* @param znear 近截面
|
||||||
* @param zfar 远截面
|
* @param zfar 远截面
|
||||||
*/
|
*/
|
||||||
Matrix4f perspective( float field_of_view,
|
Matrix4f PerspectiveMatrix( float field_of_view,
|
||||||
float aspect_ratio,
|
float aspect_ratio,
|
||||||
float znear,
|
float znear,
|
||||||
float zfar)
|
float zfar)
|
||||||
@@ -105,7 +105,7 @@ namespace hgl
|
|||||||
//经查证,此代码等于glm::perspectiveRH_ZO之后将[1][1]乘-1,在SaschaWillems的范例中,如果反转Y轴,则[1][1]确实要乘-1。
|
//经查证,此代码等于glm::perspectiveRH_ZO之后将[1][1]乘-1,在SaschaWillems的范例中,如果反转Y轴,则[1][1]确实要乘-1。
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix4f lookat(const Vector3f &eye,const Vector3f &target,const Vector3f &up)
|
Matrix4f LookAtMatrix(const Vector3f &eye,const Vector3f &target,const Vector3f &up)
|
||||||
{
|
{
|
||||||
Vector3f forward=normalize(target-eye);
|
Vector3f forward=normalize(target-eye);
|
||||||
Vector3f right =normalize(cross(forward,up));
|
Vector3f right =normalize(cross(forward,up));
|
||||||
|
@@ -52,7 +52,7 @@ namespace hgl
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
matrix=translate(translation_vector)*ToMatrix(rotation_quat)*scale(scale_vector);
|
matrix=TranslateMatrix(translation_vector)*ToMatrix(rotation_quat)*ScaleMatrix(scale_vector);
|
||||||
inverse_matrix=inverse(matrix);
|
inverse_matrix=inverse(matrix);
|
||||||
transpose_inverse_matrix=transpose(inverse_matrix);
|
transpose_inverse_matrix=transpose(inverse_matrix);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user