加入手雷

main
wuyize 2023-04-20 11:44:04 +08:00
parent d837e37713
commit 47ba586987
11 changed files with 861 additions and 6 deletions

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 MiB

Binary file not shown.

View File

@ -0,0 +1,820 @@
{
"asset" : {
"generator" : "Khronos glTF Blender I/O v3.4.50",
"version" : "2.0"
},
"scene" : 0,
"scenes" : [
{
"name" : "Scene",
"nodes" : [
0,
1,
2,
3,
4,
5,
6,
7,
8
]
}
],
"nodes" : [
{
"mesh" : 0,
"name" : "Body",
"translation" : [
0,
-2.247850179672241,
0
]
},
{
"mesh" : 1,
"name" : "Fuze",
"translation" : [
0,
-2.247850179672241,
0
]
},
{
"mesh" : 2,
"name" : "SafetyLever",
"translation" : [
0.6115021705627441,
2.1325087547302246,
0
]
},
{
"mesh" : 3,
"name" : "SafetyRing",
"translation" : [
0.6115090847015381,
2.1325178146362305,
-0.6156752109527588
]
},
{
"mesh" : 4,
"name" : "Seal",
"translation" : [
0,
-2.247849941253662,
0
]
},
{
"mesh" : 5,
"name" : "SafetyPin",
"translation" : [
0.6115090847015381,
2.1325180530548096,
-0.6156752109527588
]
},
{
"mesh" : 6,
"name" : "StrikerPin",
"translation" : [
0.47106197476387024,
2.2471275329589844,
0.000243160204263404
]
},
{
"mesh" : 7,
"name" : "StrikerSpring",
"translation" : [
0.4710620045661926,
2.2471275329589844,
-0.041993532329797745
]
},
{
"mesh" : 8,
"name" : "Striker",
"translation" : [
0.47106197476387024,
2.2471275329589844,
0.00024316018971148878
]
}
],
"materials" : [
{
"doubleSided" : true,
"name" : "mat_Grenade",
"normalTexture" : {
"index" : 0
},
"pbrMetallicRoughness" : {
"baseColorTexture" : {
"index" : 1
},
"metallicRoughnessTexture" : {
"index" : 2
}
}
}
],
"meshes" : [
{
"name" : "grenadeBody_low",
"primitives" : [
{
"attributes" : {
"POSITION" : 0,
"TEXCOORD_0" : 1,
"NORMAL" : 2
},
"indices" : 3,
"material" : 0
}
]
},
{
"name" : "grenadeHead_low",
"primitives" : [
{
"attributes" : {
"POSITION" : 4,
"TEXCOORD_0" : 5,
"NORMAL" : 6
},
"indices" : 7,
"material" : 0
}
]
},
{
"name" : "grenadeCocking_low",
"primitives" : [
{
"attributes" : {
"POSITION" : 8,
"TEXCOORD_0" : 9,
"NORMAL" : 10
},
"indices" : 11,
"material" : 0
}
]
},
{
"name" : "grenadePinspring_low",
"primitives" : [
{
"attributes" : {
"POSITION" : 12,
"TEXCOORD_0" : 13,
"NORMAL" : 14
},
"indices" : 15,
"material" : 0
}
]
},
{
"name" : "grenadeSeal_low",
"primitives" : [
{
"attributes" : {
"POSITION" : 16,
"TEXCOORD_0" : 17,
"NORMAL" : 18
},
"indices" : 19,
"material" : 0
}
]
},
{
"name" : "grenadePin_low",
"primitives" : [
{
"attributes" : {
"POSITION" : 20,
"TEXCOORD_0" : 21,
"NORMAL" : 22
},
"indices" : 23,
"material" : 0
}
]
},
{
"name" : "grenadeSpringpin_low",
"primitives" : [
{
"attributes" : {
"POSITION" : 24,
"TEXCOORD_0" : 25,
"NORMAL" : 26
},
"indices" : 27,
"material" : 0
}
]
},
{
"name" : "grenadeSpring_low",
"primitives" : [
{
"attributes" : {
"POSITION" : 28,
"TEXCOORD_0" : 29,
"NORMAL" : 30
},
"indices" : 31,
"material" : 0
}
]
},
{
"name" : "grenadeHammer_low",
"primitives" : [
{
"attributes" : {
"POSITION" : 32,
"TEXCOORD_0" : 33,
"NORMAL" : 34
},
"indices" : 35,
"material" : 0
}
]
}
],
"textures" : [
{
"sampler" : 0,
"source" : 0
},
{
"sampler" : 0,
"source" : 1
},
{
"sampler" : 0,
"source" : 2
}
],
"images" : [
{
"mimeType" : "image/png",
"name" : "Grenade_N",
"uri" : "Grenade_N.png"
},
{
"mimeType" : "image/png",
"name" : "Grenade_B",
"uri" : "Grenade_B.png"
},
{
"mimeType" : "image/png",
"name" : "Grenade_M-Grenade_R",
"uri" : "Grenade_M-Grenade_R.png"
}
],
"accessors" : [
{
"bufferView" : 0,
"componentType" : 5126,
"count" : 1300,
"max" : [
1.159013271331787,
3.669426202774048,
1.1590133905410767
],
"min" : [
-1.1590133905410767,
-1.9166386664437596e-06,
-1.1590133905410767
],
"type" : "VEC3"
},
{
"bufferView" : 1,
"componentType" : 5126,
"count" : 1300,
"type" : "VEC2"
},
{
"bufferView" : 2,
"componentType" : 5126,
"count" : 1300,
"type" : "VEC3"
},
{
"bufferView" : 3,
"componentType" : 5123,
"count" : 2952,
"type" : "SCALAR"
},
{
"bufferView" : 4,
"componentType" : 5126,
"count" : 482,
"max" : [
0.9789643883705139,
4.635942459106445,
0.5773466229438782
],
"min" : [
-0.6583898067474365,
3.731045961380005,
-0.5773470997810364
],
"type" : "VEC3"
},
{
"bufferView" : 5,
"componentType" : 5126,
"count" : 482,
"type" : "VEC2"
},
{
"bufferView" : 6,
"componentType" : 5126,
"count" : 482,
"type" : "VEC3"
},
{
"bufferView" : 7,
"componentType" : 5123,
"count" : 1356,
"type" : "SCALAR"
},
{
"bufferView" : 8,
"componentType" : 5126,
"count" : 606,
"max" : [
0.9795078635215759,
0.3027413785457611,
0.5291423201560974
],
"min" : [
-1.3077030181884766,
-3.9374680519104004,
-0.529142439365387
],
"type" : "VEC3"
},
{
"bufferView" : 9,
"componentType" : 5126,
"count" : 606,
"type" : "VEC2"
},
{
"bufferView" : 10,
"componentType" : 5126,
"count" : 606,
"type" : "VEC3"
},
{
"bufferView" : 11,
"componentType" : 5123,
"count" : 1668,
"type" : "SCALAR"
},
{
"bufferView" : 12,
"componentType" : 5126,
"count" : 268,
"max" : [
0.6482481360435486,
0.046728670597076416,
0.05197814851999283
],
"min" : [
-0.682935357093811,
-1.2822237014770508,
-0.21923021972179413
],
"type" : "VEC3"
},
{
"bufferView" : 13,
"componentType" : 5126,
"count" : 268,
"type" : "VEC2"
},
{
"bufferView" : 14,
"componentType" : 5126,
"count" : 268,
"type" : "VEC3"
},
{
"bufferView" : 15,
"componentType" : 5123,
"count" : 1188,
"type" : "SCALAR"
},
{
"bufferView" : 16,
"componentType" : 5126,
"count" : 34,
"max" : [
0.5341219902038574,
3.730225086212158,
0.5341217517852783
],
"min" : [
-0.5341173410415649,
3.669447422027588,
-0.5341175198554993
],
"type" : "VEC3"
},
{
"bufferView" : 17,
"componentType" : 5126,
"count" : 34,
"type" : "VEC2"
},
{
"bufferView" : 18,
"componentType" : 5126,
"count" : 34,
"type" : "VEC3"
},
{
"bufferView" : 19,
"componentType" : 5123,
"count" : 96,
"type" : "SCALAR"
},
{
"bufferView" : 20,
"componentType" : 5126,
"count" : 170,
"max" : [
0.02311806008219719,
0.07415742427110672,
1.2472240924835205
],
"min" : [
-0.023298654705286026,
-0.07137548178434372,
-0.06658351421356201
],
"type" : "VEC3"
},
{
"bufferView" : 21,
"componentType" : 5126,
"count" : 170,
"type" : "VEC2"
},
{
"bufferView" : 22,
"componentType" : 5126,
"count" : 170,
"type" : "VEC3"
},
{
"bufferView" : 23,
"componentType" : 5123,
"count" : 588,
"type" : "SCALAR"
},
{
"bufferView" : 24,
"componentType" : 5126,
"count" : 34,
"max" : [
0.06607207655906677,
0.06607206910848618,
0.5017820596694946
],
"min" : [
-0.06607204675674438,
-0.06607206910848618,
-0.5017820596694946
],
"type" : "VEC3"
},
{
"bufferView" : 25,
"componentType" : 5126,
"count" : 34,
"type" : "VEC2"
},
{
"bufferView" : 26,
"componentType" : 5126,
"count" : 34,
"type" : "VEC3"
},
{
"bufferView" : 27,
"componentType" : 5123,
"count" : 84,
"type" : "SCALAR"
},
{
"bufferView" : 28,
"componentType" : 5126,
"count" : 603,
"max" : [
0.10049010813236237,
0.10046502202749252,
0.2720564305782318
],
"min" : [
-0.11457761377096176,
-0.39153483510017395,
-0.2632889151573181
],
"type" : "VEC3"
},
{
"bufferView" : 29,
"componentType" : 5126,
"count" : 603,
"type" : "VEC2"
},
{
"bufferView" : 30,
"componentType" : 5126,
"count" : 603,
"type" : "VEC3"
},
{
"bufferView" : 31,
"componentType" : 5123,
"count" : 2292,
"type" : "SCALAR"
},
{
"bufferView" : 32,
"componentType" : 5126,
"count" : 74,
"max" : [
0.08392742276191711,
0.12473973631858826,
0.15915289521217346
],
"min" : [
-0.6397569179534912,
-0.26187893748283386,
-0.1591528356075287
],
"type" : "VEC3"
},
{
"bufferView" : 33,
"componentType" : 5126,
"count" : 74,
"type" : "VEC2"
},
{
"bufferView" : 34,
"componentType" : 5126,
"count" : 74,
"type" : "VEC3"
},
{
"bufferView" : 35,
"componentType" : 5123,
"count" : 180,
"type" : "SCALAR"
}
],
"bufferViews" : [
{
"buffer" : 0,
"byteLength" : 15600,
"byteOffset" : 0,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 10400,
"byteOffset" : 15600,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 15600,
"byteOffset" : 26000,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 5904,
"byteOffset" : 41600,
"target" : 34963
},
{
"buffer" : 0,
"byteLength" : 5784,
"byteOffset" : 47504,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 3856,
"byteOffset" : 53288,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 5784,
"byteOffset" : 57144,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 2712,
"byteOffset" : 62928,
"target" : 34963
},
{
"buffer" : 0,
"byteLength" : 7272,
"byteOffset" : 65640,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 4848,
"byteOffset" : 72912,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 7272,
"byteOffset" : 77760,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 3336,
"byteOffset" : 85032,
"target" : 34963
},
{
"buffer" : 0,
"byteLength" : 3216,
"byteOffset" : 88368,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 2144,
"byteOffset" : 91584,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 3216,
"byteOffset" : 93728,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 2376,
"byteOffset" : 96944,
"target" : 34963
},
{
"buffer" : 0,
"byteLength" : 408,
"byteOffset" : 99320,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 272,
"byteOffset" : 99728,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 408,
"byteOffset" : 100000,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 192,
"byteOffset" : 100408,
"target" : 34963
},
{
"buffer" : 0,
"byteLength" : 2040,
"byteOffset" : 100600,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 1360,
"byteOffset" : 102640,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 2040,
"byteOffset" : 104000,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 1176,
"byteOffset" : 106040,
"target" : 34963
},
{
"buffer" : 0,
"byteLength" : 408,
"byteOffset" : 107216,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 272,
"byteOffset" : 107624,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 408,
"byteOffset" : 107896,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 168,
"byteOffset" : 108304,
"target" : 34963
},
{
"buffer" : 0,
"byteLength" : 7236,
"byteOffset" : 108472,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 4824,
"byteOffset" : 115708,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 7236,
"byteOffset" : 120532,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 4584,
"byteOffset" : 127768,
"target" : 34963
},
{
"buffer" : 0,
"byteLength" : 888,
"byteOffset" : 132352,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 592,
"byteOffset" : 133240,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 888,
"byteOffset" : 133832,
"target" : 34962
},
{
"buffer" : 0,
"byteLength" : 360,
"byteOffset" : 134720,
"target" : 34963
}
],
"samplers" : [
{
"magFilter" : 9729,
"minFilter" : 9987
}
],
"buffers" : [
{
"byteLength" : 135080,
"uri" : "mk2-frag-grenade.bin"
}
]
}

View File

@ -71,6 +71,11 @@ std::pair<glm::vec3, glm::vec3> Actor::getAABB()
return model.getAABB();
}
float Actor::getAnimatorCurrentTime()
{
return animator.getCurrentTime();
}
void Actor::updateTransform()
{
model.setTransform(glm::translate(glm::mat4(1), position) * glm::scale(glm::mat4(1), scale) * glm::mat4_cast(rotation));

View File

@ -25,6 +25,8 @@ public:
std::pair<glm::vec3, glm::vec3> getAABB();
float getAnimatorCurrentTime();
protected:
GladGLContext* gl;
Model model;

View File

@ -85,6 +85,14 @@ public:
return finalBonesMatricesUBO;
}
float getCurrentTime()
{
if (currentAnimation)
return currentTime / currentAnimation->GetTicksPerSecond();
else
return 0;
}
private:
GladGLContext* gl;
std::vector<glm::mat4> finalBoneMatrices;

View File

@ -22,19 +22,22 @@ DemoWorld::DemoWorld()
sponza->setScale(glm::vec3(2));
auto shoot = std::make_shared<Actor>("Models\\shoot_gun\\scene.gltf");
shoot->setPosition({ 5,0,-1 });
shoot->setScale(glm::vec3{ 45 });
shoot->setScale(glm::vec3(45));
auto grenade_throw = std::make_shared<Actor>("Models\\grenade_throw\\scene.gltf");
grenade_throw->setPosition({ -5,0,-1 });
grenade_throw->setScale(glm::vec3{ 45 });
throwPerson = std::make_shared<Actor>("Models\\grenade_throw\\scene.gltf");
throwPerson->setPosition({ -5,0,-1 });
throwPerson->setScale(glm::vec3{ 45 });
mk2 = std::make_shared<Particle>(10, "Models\\mk2-frag-grenade\\mk2-frag-grenade.gltf");
mk2->enableGravity();
addActor(actor);
addActor(actor2);
addActor(actor3);
addActor(sponza);
addActor(shoot);
addActor(grenade_throw);
addActor(throwPerson);
addActor(mk2);
float boardMass = 10;
glm::vec3 boardScale(0.01);
@ -84,4 +87,18 @@ void DemoWorld::logicalTick(float deltaTime)
}
particles[i]->setRotaion(glm::rotation(glm::vec3(0, 0, 1), d));
}
if (throwPerson->getAnimatorCurrentTime() - 3.f < 1e-3f)
{
mk2->setPosition({ -5.5,2,-1 });
mk2->setScale(glm::vec3(0.1));
mk2->setSpeed({ 0,0,2 });
}
}
void DemoWorld::rendererTick(float deltaTime)
{
World::rendererTick(deltaTime);
}

View File

@ -6,7 +6,10 @@ class DemoWorld : public World
public:
DemoWorld();
virtual void logicalTick(float deltaTime) override;
virtual void rendererTick(float deltaTime) override;
private:
std::vector<std::shared_ptr<Particle>> particles;
std::shared_ptr<Actor> throwPerson;
std::shared_ptr<Particle> mk2;
};