|
@@ -7,305 +7,305 @@
|
|
|
#include "bgfx_utils.h"
|
|
#include "bgfx_utils.h"
|
|
|
#include "imgui/imgui.h"
|
|
#include "imgui/imgui.h"
|
|
|
|
|
|
|
|
-class Wireframe : public entry::AppI
|
|
|
|
|
|
|
+struct DrawMode
|
|
|
{
|
|
{
|
|
|
- struct DrawMode
|
|
|
|
|
|
|
+ enum
|
|
|
{
|
|
{
|
|
|
- enum
|
|
|
|
|
- {
|
|
|
|
|
- WireframeShaded,
|
|
|
|
|
- Wireframe,
|
|
|
|
|
- Shaded,
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ WireframeShaded,
|
|
|
|
|
+ Wireframe,
|
|
|
|
|
+ Shaded,
|
|
|
};
|
|
};
|
|
|
|
|
+};
|
|
|
|
|
|
|
|
- struct Camera
|
|
|
|
|
|
|
+struct Camera
|
|
|
|
|
+{
|
|
|
|
|
+ Camera()
|
|
|
{
|
|
{
|
|
|
- Camera()
|
|
|
|
|
- {
|
|
|
|
|
- reset();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- void reset()
|
|
|
|
|
- {
|
|
|
|
|
- m_target.curr[0] = 0.0f;
|
|
|
|
|
- m_target.curr[1] = 0.0f;
|
|
|
|
|
- m_target.curr[2] = 0.0f;
|
|
|
|
|
- m_target.dest[0] = 0.0f;
|
|
|
|
|
- m_target.dest[1] = 0.0f;
|
|
|
|
|
- m_target.dest[2] = 0.0f;
|
|
|
|
|
-
|
|
|
|
|
- m_pos.curr[0] = 0.0f;
|
|
|
|
|
- m_pos.curr[1] = 0.0f;
|
|
|
|
|
- m_pos.curr[2] = -2.0f;
|
|
|
|
|
- m_pos.dest[0] = 0.0f;
|
|
|
|
|
- m_pos.dest[1] = 0.0f;
|
|
|
|
|
- m_pos.dest[2] = -2.0f;
|
|
|
|
|
-
|
|
|
|
|
- m_orbit[0] = 0.0f;
|
|
|
|
|
- m_orbit[1] = 0.0f;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ reset();
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- void mtxLookAt(float* _outViewMtx)
|
|
|
|
|
- {
|
|
|
|
|
- bx::mtxLookAt(_outViewMtx, m_pos.curr, m_target.curr);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ void reset()
|
|
|
|
|
+ {
|
|
|
|
|
+ m_target.curr[0] = 0.0f;
|
|
|
|
|
+ m_target.curr[1] = 0.0f;
|
|
|
|
|
+ m_target.curr[2] = 0.0f;
|
|
|
|
|
+ m_target.dest[0] = 0.0f;
|
|
|
|
|
+ m_target.dest[1] = 0.0f;
|
|
|
|
|
+ m_target.dest[2] = 0.0f;
|
|
|
|
|
+
|
|
|
|
|
+ m_pos.curr[0] = 0.0f;
|
|
|
|
|
+ m_pos.curr[1] = 0.0f;
|
|
|
|
|
+ m_pos.curr[2] = -2.0f;
|
|
|
|
|
+ m_pos.dest[0] = 0.0f;
|
|
|
|
|
+ m_pos.dest[1] = 0.0f;
|
|
|
|
|
+ m_pos.dest[2] = -2.0f;
|
|
|
|
|
+
|
|
|
|
|
+ m_orbit[0] = 0.0f;
|
|
|
|
|
+ m_orbit[1] = 0.0f;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- void orbit(float _dx, float _dy)
|
|
|
|
|
- {
|
|
|
|
|
- m_orbit[0] += _dx;
|
|
|
|
|
- m_orbit[1] += _dy;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ void mtxLookAt(float* _outViewMtx)
|
|
|
|
|
+ {
|
|
|
|
|
+ bx::mtxLookAt(_outViewMtx, m_pos.curr, m_target.curr);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- void dolly(float _dz)
|
|
|
|
|
- {
|
|
|
|
|
- const float cnear = 0.01f;
|
|
|
|
|
- const float cfar = 10.0f;
|
|
|
|
|
|
|
+ void orbit(float _dx, float _dy)
|
|
|
|
|
+ {
|
|
|
|
|
+ m_orbit[0] += _dx;
|
|
|
|
|
+ m_orbit[1] += _dy;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- const float toTarget[3] =
|
|
|
|
|
- {
|
|
|
|
|
- m_target.dest[0] - m_pos.dest[0],
|
|
|
|
|
- m_target.dest[1] - m_pos.dest[1],
|
|
|
|
|
- m_target.dest[2] - m_pos.dest[2],
|
|
|
|
|
- };
|
|
|
|
|
- const float toTargetLen = bx::vec3Length(toTarget);
|
|
|
|
|
- const float invToTargetLen = 1.0f/(toTargetLen+FLT_MIN);
|
|
|
|
|
- const float toTargetNorm[3] =
|
|
|
|
|
- {
|
|
|
|
|
- toTarget[0]*invToTargetLen,
|
|
|
|
|
- toTarget[1]*invToTargetLen,
|
|
|
|
|
- toTarget[2]*invToTargetLen,
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- float delta = toTargetLen*_dz;
|
|
|
|
|
- float newLen = toTargetLen + delta;
|
|
|
|
|
- if ( (cnear < newLen || _dz < 0.0f)
|
|
|
|
|
- && (newLen < cfar || _dz > 0.0f) )
|
|
|
|
|
- {
|
|
|
|
|
- m_pos.dest[0] += toTargetNorm[0]*delta;
|
|
|
|
|
- m_pos.dest[1] += toTargetNorm[1]*delta;
|
|
|
|
|
- m_pos.dest[2] += toTargetNorm[2]*delta;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ void dolly(float _dz)
|
|
|
|
|
+ {
|
|
|
|
|
+ const float cnear = 0.01f;
|
|
|
|
|
+ const float cfar = 10.0f;
|
|
|
|
|
|
|
|
- void consumeOrbit(float _amount)
|
|
|
|
|
|
|
+ const float toTarget[3] =
|
|
|
|
|
+ {
|
|
|
|
|
+ m_target.dest[0] - m_pos.dest[0],
|
|
|
|
|
+ m_target.dest[1] - m_pos.dest[1],
|
|
|
|
|
+ m_target.dest[2] - m_pos.dest[2],
|
|
|
|
|
+ };
|
|
|
|
|
+ const float toTargetLen = bx::vec3Length(toTarget);
|
|
|
|
|
+ const float invToTargetLen = 1.0f/(toTargetLen+FLT_MIN);
|
|
|
|
|
+ const float toTargetNorm[3] =
|
|
|
{
|
|
{
|
|
|
- float consume[2];
|
|
|
|
|
- consume[0] = m_orbit[0]*_amount;
|
|
|
|
|
- consume[1] = m_orbit[1]*_amount;
|
|
|
|
|
- m_orbit[0] -= consume[0];
|
|
|
|
|
- m_orbit[1] -= consume[1];
|
|
|
|
|
|
|
+ toTarget[0]*invToTargetLen,
|
|
|
|
|
+ toTarget[1]*invToTargetLen,
|
|
|
|
|
+ toTarget[2]*invToTargetLen,
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
- const float toPos[3] =
|
|
|
|
|
- {
|
|
|
|
|
- m_pos.curr[0] - m_target.curr[0],
|
|
|
|
|
- m_pos.curr[1] - m_target.curr[1],
|
|
|
|
|
- m_pos.curr[2] - m_target.curr[2],
|
|
|
|
|
- };
|
|
|
|
|
- const float toPosLen = bx::vec3Length(toPos);
|
|
|
|
|
- const float invToPosLen = 1.0f/(toPosLen+FLT_MIN);
|
|
|
|
|
- const float toPosNorm[3] =
|
|
|
|
|
- {
|
|
|
|
|
- toPos[0]*invToPosLen,
|
|
|
|
|
- toPos[1]*invToPosLen,
|
|
|
|
|
- toPos[2]*invToPosLen,
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- float ll[2];
|
|
|
|
|
- latLongFromVec(ll[0], ll[1], toPosNorm);
|
|
|
|
|
- ll[0] += consume[0];
|
|
|
|
|
- ll[1] -= consume[1];
|
|
|
|
|
- ll[1] = bx::fclamp(ll[1], 0.02f, 0.98f);
|
|
|
|
|
-
|
|
|
|
|
- float tmp[3];
|
|
|
|
|
- vecFromLatLong(tmp, ll[0], ll[1]);
|
|
|
|
|
-
|
|
|
|
|
- float diff[3];
|
|
|
|
|
- diff[0] = (tmp[0]-toPosNorm[0])*toPosLen;
|
|
|
|
|
- diff[1] = (tmp[1]-toPosNorm[1])*toPosLen;
|
|
|
|
|
- diff[2] = (tmp[2]-toPosNorm[2])*toPosLen;
|
|
|
|
|
-
|
|
|
|
|
- m_pos.curr[0] += diff[0];
|
|
|
|
|
- m_pos.curr[1] += diff[1];
|
|
|
|
|
- m_pos.curr[2] += diff[2];
|
|
|
|
|
- m_pos.dest[0] += diff[0];
|
|
|
|
|
- m_pos.dest[1] += diff[1];
|
|
|
|
|
- m_pos.dest[2] += diff[2];
|
|
|
|
|
|
|
+ float delta = toTargetLen*_dz;
|
|
|
|
|
+ float newLen = toTargetLen + delta;
|
|
|
|
|
+ if ( (cnear < newLen || _dz < 0.0f)
|
|
|
|
|
+ && (newLen < cfar || _dz > 0.0f) )
|
|
|
|
|
+ {
|
|
|
|
|
+ m_pos.dest[0] += toTargetNorm[0]*delta;
|
|
|
|
|
+ m_pos.dest[1] += toTargetNorm[1]*delta;
|
|
|
|
|
+ m_pos.dest[2] += toTargetNorm[2]*delta;
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ void consumeOrbit(float _amount)
|
|
|
|
|
+ {
|
|
|
|
|
+ float consume[2];
|
|
|
|
|
+ consume[0] = m_orbit[0]*_amount;
|
|
|
|
|
+ consume[1] = m_orbit[1]*_amount;
|
|
|
|
|
+ m_orbit[0] -= consume[0];
|
|
|
|
|
+ m_orbit[1] -= consume[1];
|
|
|
|
|
|
|
|
- void update(float _dt)
|
|
|
|
|
|
|
+ const float toPos[3] =
|
|
|
{
|
|
{
|
|
|
- const float amount = bx::fmin(_dt/0.12f, 1.0f);
|
|
|
|
|
|
|
+ m_pos.curr[0] - m_target.curr[0],
|
|
|
|
|
+ m_pos.curr[1] - m_target.curr[1],
|
|
|
|
|
+ m_pos.curr[2] - m_target.curr[2],
|
|
|
|
|
+ };
|
|
|
|
|
+ const float toPosLen = bx::vec3Length(toPos);
|
|
|
|
|
+ const float invToPosLen = 1.0f/(toPosLen+FLT_MIN);
|
|
|
|
|
+ const float toPosNorm[3] =
|
|
|
|
|
+ {
|
|
|
|
|
+ toPos[0]*invToPosLen,
|
|
|
|
|
+ toPos[1]*invToPosLen,
|
|
|
|
|
+ toPos[2]*invToPosLen,
|
|
|
|
|
+ };
|
|
|
|
|
|
|
|
- consumeOrbit(amount);
|
|
|
|
|
|
|
+ float ll[2];
|
|
|
|
|
+ latLongFromVec(ll[0], ll[1], toPosNorm);
|
|
|
|
|
+ ll[0] += consume[0];
|
|
|
|
|
+ ll[1] -= consume[1];
|
|
|
|
|
+ ll[1] = bx::fclamp(ll[1], 0.02f, 0.98f);
|
|
|
|
|
+
|
|
|
|
|
+ float tmp[3];
|
|
|
|
|
+ vecFromLatLong(tmp, ll[0], ll[1]);
|
|
|
|
|
+
|
|
|
|
|
+ float diff[3];
|
|
|
|
|
+ diff[0] = (tmp[0]-toPosNorm[0])*toPosLen;
|
|
|
|
|
+ diff[1] = (tmp[1]-toPosNorm[1])*toPosLen;
|
|
|
|
|
+ diff[2] = (tmp[2]-toPosNorm[2])*toPosLen;
|
|
|
|
|
+
|
|
|
|
|
+ m_pos.curr[0] += diff[0];
|
|
|
|
|
+ m_pos.curr[1] += diff[1];
|
|
|
|
|
+ m_pos.curr[2] += diff[2];
|
|
|
|
|
+ m_pos.dest[0] += diff[0];
|
|
|
|
|
+ m_pos.dest[1] += diff[1];
|
|
|
|
|
+ m_pos.dest[2] += diff[2];
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- m_target.curr[0] = bx::flerp(m_target.curr[0], m_target.dest[0], amount);
|
|
|
|
|
- m_target.curr[1] = bx::flerp(m_target.curr[1], m_target.dest[1], amount);
|
|
|
|
|
- m_target.curr[2] = bx::flerp(m_target.curr[2], m_target.dest[2], amount);
|
|
|
|
|
- m_pos.curr[0] = bx::flerp(m_pos.curr[0], m_pos.dest[0], amount);
|
|
|
|
|
- m_pos.curr[1] = bx::flerp(m_pos.curr[1], m_pos.dest[1], amount);
|
|
|
|
|
- m_pos.curr[2] = bx::flerp(m_pos.curr[2], m_pos.dest[2], amount);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ void update(float _dt)
|
|
|
|
|
+ {
|
|
|
|
|
+ const float amount = bx::fmin(_dt/0.12f, 1.0f);
|
|
|
|
|
|
|
|
- static inline void vecFromLatLong(float _vec[3], float _u, float _v)
|
|
|
|
|
- {
|
|
|
|
|
- const float phi = _u * 2.0f*bx::pi;
|
|
|
|
|
- const float theta = _v * bx::pi;
|
|
|
|
|
|
|
+ consumeOrbit(amount);
|
|
|
|
|
|
|
|
- const float st = bx::fsin(theta);
|
|
|
|
|
- const float sp = bx::fsin(phi);
|
|
|
|
|
- const float ct = bx::fcos(theta);
|
|
|
|
|
- const float cp = bx::fcos(phi);
|
|
|
|
|
|
|
+ m_target.curr[0] = bx::flerp(m_target.curr[0], m_target.dest[0], amount);
|
|
|
|
|
+ m_target.curr[1] = bx::flerp(m_target.curr[1], m_target.dest[1], amount);
|
|
|
|
|
+ m_target.curr[2] = bx::flerp(m_target.curr[2], m_target.dest[2], amount);
|
|
|
|
|
+ m_pos.curr[0] = bx::flerp(m_pos.curr[0], m_pos.dest[0], amount);
|
|
|
|
|
+ m_pos.curr[1] = bx::flerp(m_pos.curr[1], m_pos.dest[1], amount);
|
|
|
|
|
+ m_pos.curr[2] = bx::flerp(m_pos.curr[2], m_pos.dest[2], amount);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- _vec[0] = -st*sp;
|
|
|
|
|
- _vec[1] = ct;
|
|
|
|
|
- _vec[2] = -st*cp;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ static inline void vecFromLatLong(float _vec[3], float _u, float _v)
|
|
|
|
|
+ {
|
|
|
|
|
+ const float phi = _u * 2.0f*bx::pi;
|
|
|
|
|
+ const float theta = _v * bx::pi;
|
|
|
|
|
|
|
|
- static inline void latLongFromVec(float& _u, float& _v, const float _vec[3])
|
|
|
|
|
- {
|
|
|
|
|
- const float phi = atan2f(_vec[0], _vec[2]);
|
|
|
|
|
- const float theta = acosf(_vec[1]);
|
|
|
|
|
|
|
+ const float st = bx::fsin(theta);
|
|
|
|
|
+ const float sp = bx::fsin(phi);
|
|
|
|
|
+ const float ct = bx::fcos(theta);
|
|
|
|
|
+ const float cp = bx::fcos(phi);
|
|
|
|
|
|
|
|
- _u = (bx::pi + phi)*bx::invPi*0.5f;
|
|
|
|
|
- _v = theta*bx::invPi;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ _vec[0] = -st*sp;
|
|
|
|
|
+ _vec[1] = ct;
|
|
|
|
|
+ _vec[2] = -st*cp;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- struct Interp3f
|
|
|
|
|
- {
|
|
|
|
|
- float curr[3];
|
|
|
|
|
- float dest[3];
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ static inline void latLongFromVec(float& _u, float& _v, const float _vec[3])
|
|
|
|
|
+ {
|
|
|
|
|
+ const float phi = atan2f(_vec[0], _vec[2]);
|
|
|
|
|
+ const float theta = acosf(_vec[1]);
|
|
|
|
|
+
|
|
|
|
|
+ _u = (bx::pi + phi)*bx::invPi*0.5f;
|
|
|
|
|
+ _v = theta*bx::invPi;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- Interp3f m_target;
|
|
|
|
|
- Interp3f m_pos;
|
|
|
|
|
- float m_orbit[2];
|
|
|
|
|
|
|
+ struct Interp3f
|
|
|
|
|
+ {
|
|
|
|
|
+ float curr[3];
|
|
|
|
|
+ float dest[3];
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- struct Mouse
|
|
|
|
|
|
|
+ Interp3f m_target;
|
|
|
|
|
+ Interp3f m_pos;
|
|
|
|
|
+ float m_orbit[2];
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+struct Mouse
|
|
|
|
|
+{
|
|
|
|
|
+ Mouse()
|
|
|
{
|
|
{
|
|
|
- Mouse()
|
|
|
|
|
- {
|
|
|
|
|
- m_dx = 0.0f;
|
|
|
|
|
- m_dy = 0.0f;
|
|
|
|
|
- m_prevMx = 0.0f;
|
|
|
|
|
- m_prevMx = 0.0f;
|
|
|
|
|
- m_scroll = 0;
|
|
|
|
|
- m_scrollPrev = 0;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ m_dx = 0.0f;
|
|
|
|
|
+ m_dy = 0.0f;
|
|
|
|
|
+ m_prevMx = 0.0f;
|
|
|
|
|
+ m_prevMx = 0.0f;
|
|
|
|
|
+ m_scroll = 0;
|
|
|
|
|
+ m_scrollPrev = 0;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- void update(float _mx, float _my, int32_t _mz, uint32_t _width, uint32_t _height)
|
|
|
|
|
- {
|
|
|
|
|
- const float widthf = float(int32_t(_width));
|
|
|
|
|
- const float heightf = float(int32_t(_height));
|
|
|
|
|
|
|
+ void update(float _mx, float _my, int32_t _mz, uint32_t _width, uint32_t _height)
|
|
|
|
|
+ {
|
|
|
|
|
+ const float widthf = float(int32_t(_width));
|
|
|
|
|
+ const float heightf = float(int32_t(_height));
|
|
|
|
|
|
|
|
- // Delta movement.
|
|
|
|
|
- m_dx = float(_mx - m_prevMx)/widthf;
|
|
|
|
|
- m_dy = float(_my - m_prevMy)/heightf;
|
|
|
|
|
|
|
+ // Delta movement.
|
|
|
|
|
+ m_dx = float(_mx - m_prevMx)/widthf;
|
|
|
|
|
+ m_dy = float(_my - m_prevMy)/heightf;
|
|
|
|
|
|
|
|
- m_prevMx = _mx;
|
|
|
|
|
- m_prevMy = _my;
|
|
|
|
|
|
|
+ m_prevMx = _mx;
|
|
|
|
|
+ m_prevMy = _my;
|
|
|
|
|
|
|
|
- // Scroll.
|
|
|
|
|
- m_scroll = _mz - m_scrollPrev;
|
|
|
|
|
- m_scrollPrev = _mz;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // Scroll.
|
|
|
|
|
+ m_scroll = _mz - m_scrollPrev;
|
|
|
|
|
+ m_scrollPrev = _mz;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- float m_dx; // Screen space.
|
|
|
|
|
- float m_dy;
|
|
|
|
|
- float m_prevMx;
|
|
|
|
|
- float m_prevMy;
|
|
|
|
|
- int32_t m_scroll;
|
|
|
|
|
- int32_t m_scrollPrev;
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ float m_dx; // Screen space.
|
|
|
|
|
+ float m_dy;
|
|
|
|
|
+ float m_prevMx;
|
|
|
|
|
+ float m_prevMy;
|
|
|
|
|
+ int32_t m_scroll;
|
|
|
|
|
+ int32_t m_scrollPrev;
|
|
|
|
|
+};
|
|
|
|
|
|
|
|
- struct MeshMtx
|
|
|
|
|
|
|
+struct MeshMtx
|
|
|
|
|
+{
|
|
|
|
|
+ MeshMtx()
|
|
|
{
|
|
{
|
|
|
- MeshMtx()
|
|
|
|
|
- {
|
|
|
|
|
- m_mesh = NULL;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ m_mesh = NULL;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- void init(const char* _path
|
|
|
|
|
- , float _scale = 1.0f
|
|
|
|
|
- , float _rotX = 0.0f
|
|
|
|
|
- , float _rotY = 0.0f
|
|
|
|
|
- , float _rotZ = 0.0f
|
|
|
|
|
- , float _transX = 0.0f
|
|
|
|
|
- , float _transY = 0.0f
|
|
|
|
|
- , float _transZ = 0.0f
|
|
|
|
|
- )
|
|
|
|
|
- {
|
|
|
|
|
- m_mesh = meshLoad(_path);
|
|
|
|
|
- bx::mtxSRT(m_mtx
|
|
|
|
|
- , _scale
|
|
|
|
|
- , _scale
|
|
|
|
|
- , _scale
|
|
|
|
|
- , _rotX
|
|
|
|
|
- , _rotY
|
|
|
|
|
- , _rotZ
|
|
|
|
|
- , _transX
|
|
|
|
|
- , _transY
|
|
|
|
|
- , _transZ
|
|
|
|
|
- );
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ void init(const char* _path
|
|
|
|
|
+ , float _scale = 1.0f
|
|
|
|
|
+ , float _rotX = 0.0f
|
|
|
|
|
+ , float _rotY = 0.0f
|
|
|
|
|
+ , float _rotZ = 0.0f
|
|
|
|
|
+ , float _transX = 0.0f
|
|
|
|
|
+ , float _transY = 0.0f
|
|
|
|
|
+ , float _transZ = 0.0f
|
|
|
|
|
+ )
|
|
|
|
|
+ {
|
|
|
|
|
+ m_mesh = meshLoad(_path);
|
|
|
|
|
+ bx::mtxSRT(m_mtx
|
|
|
|
|
+ , _scale
|
|
|
|
|
+ , _scale
|
|
|
|
|
+ , _scale
|
|
|
|
|
+ , _rotX
|
|
|
|
|
+ , _rotY
|
|
|
|
|
+ , _rotZ
|
|
|
|
|
+ , _transX
|
|
|
|
|
+ , _transY
|
|
|
|
|
+ , _transZ
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- void destroy()
|
|
|
|
|
|
|
+ void destroy()
|
|
|
|
|
+ {
|
|
|
|
|
+ if (NULL != m_mesh)
|
|
|
{
|
|
{
|
|
|
- if (NULL != m_mesh)
|
|
|
|
|
- {
|
|
|
|
|
- meshUnload(m_mesh);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ meshUnload(m_mesh);
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- Mesh* m_mesh;
|
|
|
|
|
- float m_mtx[16];
|
|
|
|
|
- };
|
|
|
|
|
|
|
+ Mesh* m_mesh;
|
|
|
|
|
+ float m_mtx[16];
|
|
|
|
|
+};
|
|
|
|
|
|
|
|
- struct Uniforms
|
|
|
|
|
- {
|
|
|
|
|
- enum { NumVec4 = 3 };
|
|
|
|
|
|
|
+struct Uniforms
|
|
|
|
|
+{
|
|
|
|
|
+ enum { NumVec4 = 3 };
|
|
|
|
|
|
|
|
- void init()
|
|
|
|
|
- {
|
|
|
|
|
- m_camPos[0] = 0.0f;
|
|
|
|
|
- m_camPos[1] = 1.0f;
|
|
|
|
|
- m_camPos[2] = -2.5f;
|
|
|
|
|
- m_wfColor[0] = 1.0f;
|
|
|
|
|
- m_wfColor[1] = 0.0f;
|
|
|
|
|
- m_wfColor[2] = 0.0f;
|
|
|
|
|
- m_wfOpacity = 0.7f;
|
|
|
|
|
- m_drawEdges = 0.0f;
|
|
|
|
|
- m_wfThickness = 1.5f;
|
|
|
|
|
-
|
|
|
|
|
- u_params = bgfx::createUniform("u_params", bgfx::UniformType::Vec4, NumVec4);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ void init()
|
|
|
|
|
+ {
|
|
|
|
|
+ m_camPos[0] = 0.0f;
|
|
|
|
|
+ m_camPos[1] = 1.0f;
|
|
|
|
|
+ m_camPos[2] = -2.5f;
|
|
|
|
|
+ m_wfColor[0] = 1.0f;
|
|
|
|
|
+ m_wfColor[1] = 0.0f;
|
|
|
|
|
+ m_wfColor[2] = 0.0f;
|
|
|
|
|
+ m_wfOpacity = 0.7f;
|
|
|
|
|
+ m_drawEdges = 0.0f;
|
|
|
|
|
+ m_wfThickness = 1.5f;
|
|
|
|
|
+
|
|
|
|
|
+ u_params = bgfx::createUniform("u_params", bgfx::UniformType::Vec4, NumVec4);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- void submit()
|
|
|
|
|
- {
|
|
|
|
|
- bgfx::setUniform(u_params, m_params, NumVec4);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ void submit()
|
|
|
|
|
+ {
|
|
|
|
|
+ bgfx::setUniform(u_params, m_params, NumVec4);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- void destroy()
|
|
|
|
|
- {
|
|
|
|
|
- bgfx::destroyUniform(u_params);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ void destroy()
|
|
|
|
|
+ {
|
|
|
|
|
+ bgfx::destroyUniform(u_params);
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- union
|
|
|
|
|
|
|
+ union
|
|
|
|
|
+ {
|
|
|
|
|
+ struct
|
|
|
{
|
|
{
|
|
|
- struct
|
|
|
|
|
- {
|
|
|
|
|
- /*0*/struct { float m_camPos[3], m_unused0; };
|
|
|
|
|
- /*1*/struct { float m_wfColor[3], m_wfOpacity; };
|
|
|
|
|
- /*2*/struct { float m_drawEdges, m_wfThickness, m_unused2[2]; };
|
|
|
|
|
- };
|
|
|
|
|
-
|
|
|
|
|
- float m_params[NumVec4*4];
|
|
|
|
|
|
|
+ /*0*/struct { float m_camPos[3], m_unused0; };
|
|
|
|
|
+ /*1*/struct { float m_wfColor[3], m_wfOpacity; };
|
|
|
|
|
+ /*2*/struct { float m_drawEdges, m_wfThickness, m_unused2[2]; };
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- bgfx::UniformHandle u_params;
|
|
|
|
|
|
|
+ float m_params[NumVec4*4];
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
+ bgfx::UniformHandle u_params;
|
|
|
|
|
+};
|
|
|
|
|
+
|
|
|
|
|
+class ExampleWireframe : public entry::AppI
|
|
|
|
|
+{
|
|
|
void init(int _argc, char** _argv) BX_OVERRIDE
|
|
void init(int _argc, char** _argv) BX_OVERRIDE
|
|
|
{
|
|
{
|
|
|
Args args(_argc, _argv);
|
|
Args args(_argc, _argv);
|
|
@@ -563,4 +563,4 @@ class Wireframe : public entry::AppI
|
|
|
int32_t m_scrollArea;
|
|
int32_t m_scrollArea;
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-ENTRY_IMPLEMENT_MAIN(Wireframe);
|
|
|
|
|
|
|
+ENTRY_IMPLEMENT_MAIN(ExampleWireframe);
|