add physX colliders ,add trigger, colliders now can visible, some rotation for cs and native cpp connection
This commit is contained in:
@ -9,6 +9,7 @@
|
||||
|
||||
#include "glm/gtx/matrix_decompose.hpp"
|
||||
#include "Prism/Core/Input.h"
|
||||
#include "Prism/Physics/Physics3D.h"
|
||||
#include "Prism/Renderer/Renderer2D.h"
|
||||
#include "Prism/Script/ScriptEngine.h"
|
||||
|
||||
@ -172,7 +173,7 @@ namespace Prism
|
||||
m_CheckerboardTex = Texture2D::Create("assets/editor/Checkerboard.tga");
|
||||
m_PlayButtonTex = Texture2D::Create("assets/editor/PlayButton.png");
|
||||
|
||||
m_EditorScene = Ref<Scene>::Create();
|
||||
m_EditorScene = Ref<Scene>::Create("untitled Scene", true);
|
||||
ScriptEngine::SetSceneContext(m_EditorScene);
|
||||
m_SceneHierarchyPanel = CreateScope<SceneHierarchyPanel>(m_EditorScene);
|
||||
m_SceneHierarchyPanel->SetSelectionChangedCallback(std::bind(&EditorLayer::SelectEntity, this, std::placeholders::_1));
|
||||
@ -199,7 +200,7 @@ namespace Prism
|
||||
if (m_DrawOnTopBoundingBoxes)
|
||||
{
|
||||
Renderer::BeginRenderPass(SceneRenderer::GetFinalRenderPass(), false);
|
||||
auto viewProj = m_EditorCamera.GetViewProjection();
|
||||
const auto viewProj = m_EditorCamera.GetViewProjection();
|
||||
Renderer2D::BeginScene(viewProj, false);
|
||||
// TODO: Renderer::DrawAABB(m_MeshEntity.GetComponent<MeshComponent>(), m_MeshEntity.GetComponent<TransformComponent>());
|
||||
Renderer2D::EndScene();
|
||||
@ -233,7 +234,7 @@ namespace Prism
|
||||
const glm::vec3 rotation = glm::eulerAngles(rotationQuat);
|
||||
|
||||
Renderer::BeginRenderPass(SceneRenderer::GetFinalRenderPass(), false);
|
||||
auto viewProj = m_EditorCamera.GetViewProjection();
|
||||
const auto viewProj = m_EditorCamera.GetViewProjection();
|
||||
Renderer2D::BeginScene(viewProj, false);
|
||||
Renderer2D::DrawRotatedQuad({ translation.x, translation.y }, size * 2.0f, glm::degrees(rotation.z), { 1.0f, 0.0f, 1.0f, 1.0f });
|
||||
Renderer2D::EndScene();
|
||||
@ -360,6 +361,21 @@ namespace Prism
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
if (ImGui::BeginMenu("Tools"))
|
||||
{
|
||||
// PhysX Debugger
|
||||
if (ImGui::MenuItem("Connect to PVD"))
|
||||
{
|
||||
Physics3D::ConnectPVD();
|
||||
}
|
||||
if (ImGui::MenuItem("Disconnect from PVD", nullptr, nullptr, Physics3D::IsPVDConnected()))
|
||||
{
|
||||
Physics3D::DisconnectPVD();
|
||||
}
|
||||
|
||||
ImGui::EndMenu();
|
||||
}
|
||||
|
||||
ImGui::EndMenuBar();
|
||||
}
|
||||
|
||||
@ -914,8 +930,8 @@ namespace Prism
|
||||
glm::inverse(glm::mat3(entity.Transform()) * glm::mat3(submesh.Transform)) * direction
|
||||
};
|
||||
|
||||
float t;
|
||||
if (bool intersects = ray.IntersectsAABB(submesh.BoundingBox, t))
|
||||
float t = 0;
|
||||
if (ray.IntersectsAABB(submesh.BoundingBox, t))
|
||||
{
|
||||
const auto& triangleCache = mesh->GetTriangleCache(i);
|
||||
for (const auto& triangle : triangleCache)
|
||||
@ -1029,10 +1045,10 @@ namespace Prism
|
||||
void EditorLayer::OpenScene()
|
||||
{
|
||||
const auto& app = Application::Get();
|
||||
const std::string filepath = app.OpenFile("Hazel Scene (*.hsc)\0*.hsc\0");
|
||||
const std::string filepath = app.OpenFile("Prism Scene (*.hsc)\0*.hsc\0");
|
||||
if (!filepath.empty())
|
||||
{
|
||||
const Ref<Scene> newScene = Ref<Scene>::Create();
|
||||
const Ref<Scene> newScene = Ref<Scene>::Create("EditorScene", true);
|
||||
SceneSerializer serializer(newScene);
|
||||
serializer.Deserialize(filepath);
|
||||
m_EditorScene = newScene;
|
||||
@ -1057,7 +1073,7 @@ namespace Prism
|
||||
void EditorLayer::SaveSceneAs()
|
||||
{
|
||||
auto& app = Application::Get();
|
||||
std::string filepath = app.SaveFile("Hazel Scene (*.hsc)\0*.hsc\0");
|
||||
std::string filepath = app.SaveFile("Prism Scene (*.hsc)\0*.hsc\0");
|
||||
if (!filepath.empty())
|
||||
{
|
||||
SceneSerializer serializer(m_EditorScene);
|
||||
|
||||
BIN
Editor/assets/meshes/Capsule.fbx
Normal file
BIN
Editor/assets/meshes/Capsule.fbx
Normal file
Binary file not shown.
167
Editor/assets/scenes/FPSDemo.scene
Normal file
167
Editor/assets/scenes/FPSDemo.scene
Normal file
@ -0,0 +1,167 @@
|
||||
Scene: Scene Name
|
||||
Environment:
|
||||
AssetPath: assets/env/pink_sunrise_4k.hdr
|
||||
Light:
|
||||
Direction: [-0.787, -0.73299998, 1]
|
||||
Radiance: [1, 1, 1]
|
||||
Multiplier: 0.514999986
|
||||
Entities:
|
||||
- Entity: 3247025703490125974
|
||||
TagComponent:
|
||||
Tag: Player
|
||||
TransformComponent:
|
||||
Position: [2.80803752, 1.5, 0]
|
||||
Rotation: [1, 0, 0, 0]
|
||||
Scale: [2, 2, 2]
|
||||
ScriptComponent:
|
||||
ModuleName: FPSExample.FPSPlayer
|
||||
StoredFields:
|
||||
- Name: WalkingSpeed
|
||||
Type: 1
|
||||
Data: 20
|
||||
- Name: RunSpeed
|
||||
Type: 1
|
||||
Data: 50
|
||||
- Name: JumpForce
|
||||
Type: 1
|
||||
Data: 50
|
||||
MeshComponent:
|
||||
AssetPath: assets/meshes/Capsule.fbx
|
||||
RigidBodyComponent:
|
||||
BodyType: 1
|
||||
Mass: 1
|
||||
IsKinematic: false
|
||||
Constraints:
|
||||
LockPositionX: false
|
||||
LockPositionY: false
|
||||
LockPositionZ: false
|
||||
LockRotationX: true
|
||||
LockRotationY: false
|
||||
LockRotationZ: true
|
||||
PhysicsMaterialComponent:
|
||||
StaticFriction: 0.100000001
|
||||
DynamicFriction: 0.100000001
|
||||
Bounciness: 0.100000001
|
||||
MeshColliderComponent:
|
||||
AssetPath: assets/meshes/Capsule.fbx
|
||||
IsTrigger: false
|
||||
- Entity: 11149966982516343187
|
||||
TagComponent:
|
||||
Tag: Mesh Collider
|
||||
TransformComponent:
|
||||
Position: [-2.60455179, 1, -0.00171399117]
|
||||
Rotation: [1, 0, 0, 0]
|
||||
Scale: [1, 1, 1]
|
||||
MeshComponent:
|
||||
AssetPath: assets/meshes/Sphere1m.fbx
|
||||
RigidBodyComponent:
|
||||
BodyType: 1
|
||||
Mass: 0.100000001
|
||||
IsKinematic: false
|
||||
Constraints:
|
||||
LockPositionX: false
|
||||
LockPositionY: false
|
||||
LockPositionZ: false
|
||||
LockRotationX: false
|
||||
LockRotationY: false
|
||||
LockRotationZ: false
|
||||
PhysicsMaterialComponent:
|
||||
StaticFriction: 1
|
||||
DynamicFriction: 1
|
||||
Bounciness: 0.100000001
|
||||
MeshColliderComponent:
|
||||
AssetPath: assets/meshes/Sphere1m.fbx
|
||||
IsTrigger: false
|
||||
- Entity: 10169503531257462571
|
||||
TagComponent:
|
||||
Tag: Box
|
||||
TransformComponent:
|
||||
Position: [0, 1.5, 0]
|
||||
Rotation: [1, 0, 0, 0]
|
||||
Scale: [2, 2, 2]
|
||||
MeshComponent:
|
||||
AssetPath: assets/meshes/Cube1m.fbx
|
||||
RigidBodyComponent:
|
||||
BodyType: 1
|
||||
Mass: 0.5
|
||||
IsKinematic: false
|
||||
Constraints:
|
||||
LockPositionX: false
|
||||
LockPositionY: false
|
||||
LockPositionZ: false
|
||||
LockRotationX: false
|
||||
LockRotationY: false
|
||||
LockRotationZ: false
|
||||
PhysicsMaterialComponent:
|
||||
StaticFriction: 1
|
||||
DynamicFriction: 1
|
||||
Bounciness: 0
|
||||
BoxColliderComponent:
|
||||
Offset: [0, 0, 0]
|
||||
Size: [1, 1, 1]
|
||||
IsTrigger: false
|
||||
- Entity: 14057422478420564497
|
||||
TagComponent:
|
||||
Tag: Sphere
|
||||
TransformComponent:
|
||||
Position: [-3.98769951, 1, -1.96695328e-06]
|
||||
Rotation: [1, 0, 0, 0]
|
||||
Scale: [1, 1, 1]
|
||||
MeshComponent:
|
||||
AssetPath: assets/meshes/Sphere1m.fbx
|
||||
RigidBodyComponent:
|
||||
BodyType: 1
|
||||
Mass: 1
|
||||
IsKinematic: false
|
||||
Constraints:
|
||||
LockPositionX: false
|
||||
LockPositionY: false
|
||||
LockPositionZ: false
|
||||
LockRotationX: true
|
||||
LockRotationY: true
|
||||
LockRotationZ: true
|
||||
PhysicsMaterialComponent:
|
||||
StaticFriction: 0.100000001
|
||||
DynamicFriction: 0.100000001
|
||||
Bounciness: 0.100000001
|
||||
SphereColliderComponent:
|
||||
Radius: 0.5
|
||||
IsTrigger: false
|
||||
- Entity: 5178862374589434728
|
||||
TagComponent:
|
||||
Tag: Camera
|
||||
TransformComponent:
|
||||
Position: [2.80800009, 2.25, 0]
|
||||
Rotation: [1, 0, 0, 0]
|
||||
Scale: [1, 1, 1]
|
||||
CameraComponent:
|
||||
Camera: some camera data...
|
||||
Primary: true
|
||||
- Entity: 18306113171518048249
|
||||
TagComponent:
|
||||
Tag: Box
|
||||
TransformComponent:
|
||||
Position: [0, 0, 0]
|
||||
Rotation: [1, 0, 0, 0]
|
||||
Scale: [50, 1, 50]
|
||||
MeshComponent:
|
||||
AssetPath: assets/meshes/Cube1m.fbx
|
||||
RigidBodyComponent:
|
||||
BodyType: 0
|
||||
Mass: 1
|
||||
IsKinematic: false
|
||||
Constraints:
|
||||
LockPositionX: false
|
||||
LockPositionY: false
|
||||
LockPositionZ: false
|
||||
LockRotationX: false
|
||||
LockRotationY: false
|
||||
LockRotationZ: false
|
||||
PhysicsMaterialComponent:
|
||||
StaticFriction: 1
|
||||
DynamicFriction: 1
|
||||
Bounciness: 0
|
||||
BoxColliderComponent:
|
||||
Offset: [0, 0, 0]
|
||||
Size: [1, 1, 1]
|
||||
IsTrigger: false
|
||||
@ -18,6 +18,14 @@ Entities:
|
||||
RigidBodyComponent:
|
||||
BodyType: 1
|
||||
Mass: 0.5
|
||||
IsKinematic: false
|
||||
Constraints:
|
||||
LockPositionX: false
|
||||
LockPositionY: false
|
||||
LockPositionZ: false
|
||||
LockRotationX: true
|
||||
LockRotationY: true
|
||||
LockRotationZ: true
|
||||
PhysicsMaterialComponent:
|
||||
StaticFriction: 1
|
||||
DynamicFriction: 1
|
||||
@ -49,6 +57,14 @@ Entities:
|
||||
RigidBodyComponent:
|
||||
BodyType: 1
|
||||
Mass: 1
|
||||
IsKinematic: false
|
||||
Constraints:
|
||||
LockPositionX: false
|
||||
LockPositionY: false
|
||||
LockPositionZ: false
|
||||
LockRotationX: true
|
||||
LockRotationY: true
|
||||
LockRotationZ: true
|
||||
PhysicsMaterialComponent:
|
||||
StaticFriction: 1
|
||||
DynamicFriction: 1
|
||||
@ -86,6 +102,14 @@ Entities:
|
||||
RigidBodyComponent:
|
||||
BodyType: 0
|
||||
Mass: 1
|
||||
IsKinematic: false
|
||||
Constraints:
|
||||
LockPositionX: false
|
||||
LockPositionY: false
|
||||
LockPositionZ: false
|
||||
LockRotationX: true
|
||||
LockRotationY: true
|
||||
LockRotationZ: true
|
||||
PhysicsMaterialComponent:
|
||||
StaticFriction: 1
|
||||
DynamicFriction: 1
|
||||
|
||||
24
Editor/assets/shaders/Collider.glsl
Normal file
24
Editor/assets/shaders/Collider.glsl
Normal file
@ -0,0 +1,24 @@
|
||||
// Collider Shader
|
||||
|
||||
#type vertex
|
||||
#version 450
|
||||
|
||||
layout(location = 0) in vec3 a_Position;
|
||||
|
||||
uniform mat4 u_ViewProjection;
|
||||
uniform mat4 u_Transform;
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_ViewProjection * u_Transform * vec4(a_Position, 1.0);
|
||||
}
|
||||
|
||||
#type fragment
|
||||
#version 450
|
||||
|
||||
layout(location = 0) out vec4 color;
|
||||
|
||||
void main()
|
||||
{
|
||||
color = vec4(0.1, 1.0, 0.1, 1.0);
|
||||
}
|
||||
Reference in New Issue
Block a user