intermediate commit
parent
94affb09da
commit
455f59c4e1
|
@ -452,8 +452,6 @@ void CharacterEntity::UpdateIKConstraintSet() {
|
||||||
mIKConstraintSet.lambda = 1.0e-3;
|
mIKConstraintSet.lambda = 1.0e-3;
|
||||||
mIKConstraintSet.max_steps = 2;
|
mIKConstraintSet.max_steps = 2;
|
||||||
mIKConstraintSet.step_tol = 1.0e-5;
|
mIKConstraintSet.step_tol = 1.0e-5;
|
||||||
|
|
||||||
mIKConstraintSet.Bind(*mRigModel);
|
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < mIKConstraints.size(); ++i) {
|
for (int i = 0; i < mIKConstraints.size(); ++i) {
|
||||||
const IKConstraint& constraint = mIKConstraints[i];
|
const IKConstraint& constraint = mIKConstraints[i];
|
||||||
|
@ -521,7 +519,7 @@ void CharacterEntity::ApplyIKConstraints() {
|
||||||
void CharacterEntity::Update(float dt) {
|
void CharacterEntity::Update(float dt) {
|
||||||
UpdateIKGizmos();
|
UpdateIKGizmos();
|
||||||
ApplyCharacterController(dt);
|
ApplyCharacterController(dt);
|
||||||
ApplyIKConstraints();
|
// ApplyIKConstraints();
|
||||||
UpdateBoneMatrices();
|
UpdateBoneMatrices();
|
||||||
|
|
||||||
cur_time += dt;
|
cur_time += dt;
|
||||||
|
@ -575,6 +573,8 @@ void ShowCharacterPropertiesWindow (CharacterEntity* character) {
|
||||||
character->Reset();
|
character->Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ImGui::Checkbox("Render", &character->mEntity->mDrawEntity);
|
||||||
|
|
||||||
ImGui::Protot::DragFloat4Normalized ("Offset Quat", offset_quat.data(),
|
ImGui::Protot::DragFloat4Normalized ("Offset Quat", offset_quat.data(),
|
||||||
0.01f, -1.0f, 1.0f);
|
0.01f, -1.0f, 1.0f);
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "Serializer.h"
|
#include "Serializer.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
using namespace SimpleMath::GL;
|
||||||
|
|
||||||
typedef Matrix44f Matrix44f;
|
typedef Matrix44f Matrix44f;
|
||||||
typedef Vector4f Vector4f;
|
typedef Vector4f Vector4f;
|
||||||
|
@ -850,6 +851,33 @@ void Renderer::createGeometries() {
|
||||||
plane_ibh = bgfx::createIndexBuffer(
|
plane_ibh = bgfx::createIndexBuffer(
|
||||||
bgfx::makeRef(s_planeIndices, sizeof(s_planeIndices) )
|
bgfx::makeRef(s_planeIndices, sizeof(s_planeIndices) )
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// debugBoneMesh.Merge(
|
||||||
|
// *Mesh::sCreateCuboid (1., 1., 1.),
|
||||||
|
// TranslateMat44(0.f, .0f, 0.5f)
|
||||||
|
// );
|
||||||
|
|
||||||
|
Mesh* sphere = Mesh::sCreateUVSphere (4, 4, 0.1f);
|
||||||
|
|
||||||
|
debugBoneMesh.Merge(
|
||||||
|
*sphere,
|
||||||
|
TranslateMat44(0.f, .0f, 0.0f)
|
||||||
|
);
|
||||||
|
|
||||||
|
debugBoneMesh.Merge(
|
||||||
|
*sphere,
|
||||||
|
TranslateMat44(0.f, .0f, 1.0f)
|
||||||
|
);
|
||||||
|
|
||||||
|
Mesh* cuboid = Mesh::sCreateCuboid (0.1f, 0.1f, 1.0f);
|
||||||
|
debugBoneMesh.Merge(
|
||||||
|
*cuboid,
|
||||||
|
TranslateMat44(0.f, .0f, 0.5f)
|
||||||
|
);
|
||||||
|
|
||||||
|
delete sphere;
|
||||||
|
debugBoneMesh.Update();
|
||||||
|
delete cuboid;
|
||||||
}
|
}
|
||||||
|
|
||||||
Path::~Path() {
|
Path::~Path() {
|
||||||
|
@ -1397,7 +1425,6 @@ void Renderer::paintGL() {
|
||||||
// Floor.
|
// Floor.
|
||||||
bx::mtxMul(lightMtx, mtxFloor, lights[0].mtxShadow);
|
bx::mtxMul(lightMtx, mtxFloor, lights[0].mtxShadow);
|
||||||
bgfx::setUniform(lights[0].u_lightMtx, lightMtx);
|
bgfx::setUniform(lights[0].u_lightMtx, lightMtx);
|
||||||
bgfx::setUniform(lights[0].u_lightPos, lights[0].pos.data());
|
|
||||||
|
|
||||||
// Clear backbuffer and shadowmap framebuffer at beginning.
|
// Clear backbuffer and shadowmap framebuffer at beginning.
|
||||||
bgfx::setViewClear(RenderState::Skybox
|
bgfx::setViewClear(RenderState::Skybox
|
||||||
|
@ -1475,7 +1502,6 @@ void Renderer::paintGL() {
|
||||||
}
|
}
|
||||||
|
|
||||||
bgfx::setUniform(lights[0].u_lightMtx, lightMtx);
|
bgfx::setUniform(lights[0].u_lightMtx, lightMtx);
|
||||||
bgfx::setUniform(lights[0].u_lightPos, lights[0].pos.data());
|
|
||||||
bgfx::setUniform(u_color, Vector4f(1.f, 1.f, 1.f, 1.f).data(), 4);
|
bgfx::setUniform(u_color, Vector4f(1.f, 1.f, 1.f, 1.f).data(), 4);
|
||||||
bgfx::setIndexBuffer(plane_ibh);
|
bgfx::setIndexBuffer(plane_ibh);
|
||||||
bgfx::setVertexBuffer(plane_vbh);
|
bgfx::setVertexBuffer(plane_vbh);
|
||||||
|
@ -1490,6 +1516,9 @@ void Renderer::paintGL() {
|
||||||
|
|
||||||
// render entities
|
// render entities
|
||||||
for (size_t i = 0; i < entities.size(); i++) {
|
for (size_t i = 0; i < entities.size(); i++) {
|
||||||
|
if (entities[i]->mDrawEntity == false)
|
||||||
|
continue;
|
||||||
|
|
||||||
float mtxLightViewProjInv[16];
|
float mtxLightViewProjInv[16];
|
||||||
float light_pos_world[3];
|
float light_pos_world[3];
|
||||||
|
|
||||||
|
@ -1534,6 +1563,7 @@ void Renderer::paintGL() {
|
||||||
entities[i]->mSkeletonMeshes.GetBoneMatrix(j).data()
|
entities[i]->mSkeletonMeshes.GetBoneMatrix(j).data()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// render debug information
|
// render debug information
|
||||||
|
@ -1574,6 +1604,12 @@ void Renderer::paintGL() {
|
||||||
bgfx::submit(st.m_viewId, st.m_program.program);
|
bgfx::submit(st.m_viewId, st.m_program.program);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// render debug skeletons
|
||||||
|
for (size_t i = 0; i < entities.size(); i++) {
|
||||||
|
debugBoneMesh.Submit(&s_renderStates[RenderState::Scene],
|
||||||
|
entities[i]->mTransform.toMatrix().data());
|
||||||
|
}
|
||||||
|
|
||||||
// debug commands
|
// debug commands
|
||||||
bgfx::setUniform(u_color, Vector4f(1.0f, 1.0f, 1.0f, 1.f).data(), 4);
|
bgfx::setUniform(u_color, Vector4f(1.0f, 1.0f, 1.0f, 1.f).data(), 4);
|
||||||
|
|
||||||
|
|
|
@ -313,6 +313,7 @@ struct Entity {
|
||||||
Vector4f mColor;
|
Vector4f mColor;
|
||||||
Skeleton mSkeleton;
|
Skeleton mSkeleton;
|
||||||
SkeletonMeshes mSkeletonMeshes;
|
SkeletonMeshes mSkeletonMeshes;
|
||||||
|
bool mDrawEntity = false;
|
||||||
|
|
||||||
Entity() :
|
Entity() :
|
||||||
mColor (1.f, 1.f, 1.f, 1.f ),
|
mColor (1.f, 1.f, 1.f, 1.f ),
|
||||||
|
@ -393,6 +394,8 @@ struct Renderer {
|
||||||
std::vector<Path> debugPaths;
|
std::vector<Path> debugPaths;
|
||||||
std::vector<DebugCommand> debugCommands;
|
std::vector<DebugCommand> debugCommands;
|
||||||
|
|
||||||
|
Mesh debugBoneMesh;
|
||||||
|
|
||||||
uint16_t activeCameraIndex;
|
uint16_t activeCameraIndex;
|
||||||
|
|
||||||
Renderer() :
|
Renderer() :
|
||||||
|
|
Loading…
Reference in New Issue