Patch update - V9.2.13
Physics update
This commit is contained in:
parent
9c6db5c76d
commit
0e45e0688c
@ -1,7 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="RiderProjectSettingsUpdater">
|
<component name="RiderProjectSettingsUpdater">
|
||||||
<option name="singleClickDiffPreview" value="1" />
|
<option name="vcsConfiguration" value="2" />
|
||||||
<option name="vcsConfiguration" value="3" />
|
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
87
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
87
.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml
generated
@ -4,7 +4,16 @@
|
|||||||
<option name="autoReloadType" value="SELECTIVE" />
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="e81d6e08-efc7-40a0-909d-ec4943d948e9" name="Changes" comment="" />
|
<list default="true" id="e81d6e08-efc7-40a0-909d-ec4943d948e9" name="Changes" comment="">
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/projectSettingsUpdater.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/projectSettingsUpdater.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.KhaoticEngineReborn/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/imgui.ini" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/imgui.ini" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/imguiManager.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/imguiManager.h" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/inc/system/object.h" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/inc/system/object.h" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/applicationclass.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/applicationclass.cpp" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/imguiManager.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/imguiManager.cpp" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/enginecustom/src/src/system/object.cpp" beforeDir="false" afterPath="$PROJECT_DIR$/enginecustom/src/src/system/object.cpp" afterDir="false" />
|
||||||
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
|
||||||
@ -17,8 +26,8 @@
|
|||||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||||
</component>
|
</component>
|
||||||
<component name="HighlightingSettingsPerFile">
|
<component name="HighlightingSettingsPerFile">
|
||||||
<setting file="file://C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/shared/windef.h" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/../../../../../Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/shared/windef.h" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="file://C:/Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um/DirectXMath.h" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/../../../../../Program Files (x86)/Windows Kits/10/Include/10.0.26100.0/um/DirectXMath.h" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/enginecustom/include/Vulkan/Include/vulkan/vulkan_core.h" root0="SKIP_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/enginecustom/include/Vulkan/Include/vulkan/vulkan_core.h" root0="SKIP_HIGHLIGHTING" />
|
||||||
<setting file="file://$PROJECT_DIR$/enginecustom/src/src/shader/CelShadingShader.cpp" root0="FORCE_HIGHLIGHTING" />
|
<setting file="file://$PROJECT_DIR$/enginecustom/src/src/shader/CelShadingShader.cpp" root0="FORCE_HIGHLIGHTING" />
|
||||||
</component>
|
</component>
|
||||||
@ -34,30 +43,38 @@
|
|||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent">{
|
<component name="PropertiesComponent"><![CDATA[{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
"ASKED_SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||||
"C++ Project.enginecustom.executor": "Run",
|
"C++ Project.enginecustom.executor": "Run",
|
||||||
"C/C++ Project.enginecustom.executor": "Run",
|
"C/C++ Project.enginecustom.executor": "Run",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"RunOnceActivity.git.unshallow": "true",
|
"RunOnceActivity.git.unshallow": "true",
|
||||||
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
"SHARE_PROJECT_CONFIGURATION_FILES": "true",
|
||||||
"git-widget-placeholder": "main",
|
"git-widget-placeholder": "main",
|
||||||
"ignore.virus.scanning.warn.message": "true",
|
"ignore.virus.scanning.warn.message": "true",
|
||||||
"node.js.detected.package.eslint": "true",
|
"node.js.detected.package.eslint": "true",
|
||||||
"node.js.detected.package.tslint": "true",
|
"node.js.detected.package.tslint": "true",
|
||||||
"node.js.selected.package.eslint": "(autodetect)",
|
"node.js.selected.package.eslint": "(autodetect)",
|
||||||
"node.js.selected.package.tslint": "(autodetect)",
|
"node.js.selected.package.tslint": "(autodetect)",
|
||||||
"nodejs_package_manager_path": "npm",
|
"nodejs_package_manager_path": "npm",
|
||||||
"settings.editor.selected.configurable": "preferences.pluginManager",
|
"settings.editor.selected.configurable": "preferences.pluginManager",
|
||||||
"vue.rearranger.settings.migration": "true"
|
"vue.rearranger.settings.migration": "true"
|
||||||
|
},
|
||||||
|
"keyToStringList": {
|
||||||
|
"rider.external.source.directories": [
|
||||||
|
"C:\\Users\\arivas\\AppData\\Roaming\\JetBrains\\Rider2024.1\\resharper-host\\DecompilerCache",
|
||||||
|
"C:\\Users\\arivas\\AppData\\Roaming\\JetBrains\\Rider2024.1\\resharper-host\\SourcesCache",
|
||||||
|
"C:\\Users\\arivas\\AppData\\Local\\Symbols\\src"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}</component>
|
}]]></component>
|
||||||
<component name="RunManager" selected="C/C++ Project.enginecustom">
|
<component name="RunManager" selected="C++ Project.enginecustom">
|
||||||
<configuration name="KhaoticDemo" type="CppProject" factoryName="C++ Project">
|
<configuration name="KhaoticDemo" type="CppProject" factoryName="C++ Project">
|
||||||
<configuration_1 setup="1">
|
<configuration_1>
|
||||||
<option name="CONFIGURATION" value="Debug" />
|
<option name="CONFIGURATION" value="Debug" />
|
||||||
<option name="PLATFORM" value="x64" />
|
<option name="PLATFORM" value="x64" />
|
||||||
|
<option name="PROJECT_FILE_PATH" value="$PROJECT_DIR$/KhaoticDemo/KhaoticDemo.vcxproj" />
|
||||||
<option name="CURRENT_LAUNCH_PROFILE" value="Local" />
|
<option name="CURRENT_LAUNCH_PROFILE" value="Local" />
|
||||||
<option name="EXE_PATH" value="$(LocalDebuggerCommand)" />
|
<option name="EXE_PATH" value="$(LocalDebuggerCommand)" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="$(LocalDebuggerCommandArguments)" />
|
<option name="PROGRAM_PARAMETERS" value="$(LocalDebuggerCommandArguments)" />
|
||||||
@ -65,19 +82,18 @@
|
|||||||
<option name="PASS_PARENT_ENVS" value="1" />
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||||
<option name="TERMINAL_INTERACTION_BEHAVIOR" value="AUTO_DETECT" />
|
<option name="TERMINAL_INTERACTION_BEHAVIOR" value="AUTO_DETECT" />
|
||||||
<option name="PROJECT_FILE_PATH" value="$PROJECT_DIR$/KhaoticDemo/KhaoticDemo.vcxproj" />
|
|
||||||
</configuration_1>
|
</configuration_1>
|
||||||
<option name="DEFAULT_PROJECT_PATH" value="$PROJECT_DIR$/KhaoticDemo/KhaoticDemo.vcxproj" />
|
<option name="DEFAULT_PROJECT_PATH" value="$PROJECT_DIR$/KhaoticDemo/KhaoticDemo.vcxproj" />
|
||||||
<option name="PROJECT_FILE_PATH" value="$PROJECT_DIR$/KhaoticDemo/KhaoticDemo.vcxproj" />
|
|
||||||
<option name="AUTO_SELECT_PRIORITY" value="0" />
|
<option name="AUTO_SELECT_PRIORITY" value="0" />
|
||||||
<method v="2">
|
<method v="2">
|
||||||
<option name="Build" />
|
<option name="Build" />
|
||||||
</method>
|
</method>
|
||||||
</configuration>
|
</configuration>
|
||||||
<configuration name="enginecustom" type="CppProject" factoryName="C++ Project">
|
<configuration name="enginecustom" type="CppProject" factoryName="C++ Project">
|
||||||
<configuration_1 setup="1">
|
<configuration_1>
|
||||||
<option name="CONFIGURATION" value="Debug" />
|
<option name="CONFIGURATION" value="Debug" />
|
||||||
<option name="PLATFORM" value="x64" />
|
<option name="PLATFORM" value="x64" />
|
||||||
|
<option name="PROJECT_FILE_PATH" value="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" />
|
||||||
<option name="CURRENT_LAUNCH_PROFILE" value="Local" />
|
<option name="CURRENT_LAUNCH_PROFILE" value="Local" />
|
||||||
<option name="EXE_PATH" value="$(LocalDebuggerCommand)" />
|
<option name="EXE_PATH" value="$(LocalDebuggerCommand)" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="$(LocalDebuggerCommandArguments)" />
|
<option name="PROGRAM_PARAMETERS" value="$(LocalDebuggerCommandArguments)" />
|
||||||
@ -85,11 +101,11 @@
|
|||||||
<option name="PASS_PARENT_ENVS" value="1" />
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||||
<option name="TERMINAL_INTERACTION_BEHAVIOR" value="AUTO_DETECT" />
|
<option name="TERMINAL_INTERACTION_BEHAVIOR" value="AUTO_DETECT" />
|
||||||
<option name="PROJECT_FILE_PATH" value="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" />
|
|
||||||
</configuration_1>
|
</configuration_1>
|
||||||
<configuration_2 setup="1">
|
<configuration_2>
|
||||||
<option name="CONFIGURATION" value="Release" />
|
<option name="CONFIGURATION" value="Release" />
|
||||||
<option name="PLATFORM" value="x64" />
|
<option name="PLATFORM" value="x64" />
|
||||||
|
<option name="PROJECT_FILE_PATH" value="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" />
|
||||||
<option name="CURRENT_LAUNCH_PROFILE" value="Local" />
|
<option name="CURRENT_LAUNCH_PROFILE" value="Local" />
|
||||||
<option name="EXE_PATH" value="$(TargetPath)" />
|
<option name="EXE_PATH" value="$(TargetPath)" />
|
||||||
<option name="PROGRAM_PARAMETERS" value="" />
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
@ -97,10 +113,20 @@
|
|||||||
<option name="PASS_PARENT_ENVS" value="1" />
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||||
<option name="TERMINAL_INTERACTION_BEHAVIOR" value="AUTO_DETECT" />
|
<option name="TERMINAL_INTERACTION_BEHAVIOR" value="AUTO_DETECT" />
|
||||||
<option name="PROJECT_FILE_PATH" value="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" />
|
|
||||||
</configuration_2>
|
</configuration_2>
|
||||||
|
<configuration_3>
|
||||||
|
<option name="CONFIGURATION" value="" />
|
||||||
|
<option name="PLATFORM" value="" />
|
||||||
|
<option name="PROJECT_FILE_PATH" value="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" />
|
||||||
|
<option name="CURRENT_LAUNCH_PROFILE" value="Local" />
|
||||||
|
<option name="EXE_PATH" value="$(TargetPath)" />
|
||||||
|
<option name="PROGRAM_PARAMETERS" value="" />
|
||||||
|
<option name="WORKING_DIRECTORY" value="$(ProjectDir)" />
|
||||||
|
<option name="PASS_PARENT_ENVS" value="1" />
|
||||||
|
<option name="USE_EXTERNAL_CONSOLE" value="0" />
|
||||||
|
<option name="TERMINAL_INTERACTION_BEHAVIOR" value="AUTO_DETECT" />
|
||||||
|
</configuration_3>
|
||||||
<option name="DEFAULT_PROJECT_PATH" value="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" />
|
<option name="DEFAULT_PROJECT_PATH" value="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" />
|
||||||
<option name="PROJECT_FILE_PATH" value="$PROJECT_DIR$/enginecustom/enginecustom.vcxproj" />
|
|
||||||
<option name="AUTO_SELECT_PRIORITY" value="0" />
|
<option name="AUTO_SELECT_PRIORITY" value="0" />
|
||||||
<method v="2">
|
<method v="2">
|
||||||
<option name="Build" />
|
<option name="Build" />
|
||||||
@ -157,6 +183,7 @@
|
|||||||
<workItem from="1743355100472" duration="708000" />
|
<workItem from="1743355100472" duration="708000" />
|
||||||
<workItem from="1743355837694" duration="1514000" />
|
<workItem from="1743355837694" duration="1514000" />
|
||||||
<workItem from="1743370106270" duration="901000" />
|
<workItem from="1743370106270" duration="901000" />
|
||||||
|
<workItem from="1743505399891" duration="2361000" />
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00001" summary="Minor update - viewport window tweak">
|
<task id="LOCAL-00001" summary="Minor update - viewport window tweak">
|
||||||
<option name="closed" value="true" />
|
<option name="closed" value="true" />
|
||||||
|
@ -13,7 +13,7 @@ DockId=0x00000005,0
|
|||||||
Pos=8,27
|
Pos=8,27
|
||||||
Size=289,826
|
Size=289,826
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000009,0
|
DockId=0x00000009,1
|
||||||
|
|
||||||
[Window][Terrain]
|
[Window][Terrain]
|
||||||
Pos=8,27
|
Pos=8,27
|
||||||
@ -35,7 +35,7 @@ DockId=0x00000001,2
|
|||||||
|
|
||||||
[Window][Engine Settings]
|
[Window][Engine Settings]
|
||||||
Pos=8,27
|
Pos=8,27
|
||||||
Size=289,974
|
Size=289,826
|
||||||
Collapsed=0
|
Collapsed=0
|
||||||
DockId=0x00000009,0
|
DockId=0x00000009,0
|
||||||
|
|
||||||
|
@ -67,6 +67,7 @@ private:
|
|||||||
bool showLogWindow;
|
bool showLogWindow;
|
||||||
|
|
||||||
bool m_isPhyiscsEnabled = false;
|
bool m_isPhyiscsEnabled = false;
|
||||||
|
bool m_isGravityEnabled = false;
|
||||||
|
|
||||||
ImGuiIO* io;
|
ImGuiIO* io;
|
||||||
|
|
||||||
|
@ -95,11 +95,23 @@ public:
|
|||||||
ObjectType StringToObjectType(const std::string& objectType);
|
ObjectType StringToObjectType(const std::string& objectType);
|
||||||
std::string ObjectTypeToString(ObjectType objectType);
|
std::string ObjectTypeToString(ObjectType objectType);
|
||||||
|
|
||||||
|
void LaunchObject();
|
||||||
|
void SetAlpha(float alpha) { m_alpha = alpha; }
|
||||||
|
float GetAlpha() const { return m_alpha; }
|
||||||
|
void SetInitialStretch(float initialStretch) { m_initialStretch = initialStretch; }
|
||||||
|
float GetInitialStretch() const { return m_initialStretch; }
|
||||||
|
void SetSpringConstant(float springConstant) { m_springConstant = springConstant; }
|
||||||
|
float GetSpringConstant() const { return m_springConstant; }
|
||||||
|
|
||||||
|
bool IsGravityEnabled() const { return m_gravityEnabled; }
|
||||||
|
void SetGravityEnabled(bool state) { m_gravityEnabled = state; }
|
||||||
|
|
||||||
public :
|
public :
|
||||||
bool m_demoSpinning = false;
|
bool m_demoSpinning = false;
|
||||||
XMVECTOR m_previousPosition;
|
XMVECTOR m_previousPosition;
|
||||||
XMVECTOR m_velocity;
|
XMVECTOR m_velocity;
|
||||||
int m_id;
|
int m_id;
|
||||||
|
bool m_gravityEnabled = true;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
XMMATRIX m_scaleMatrix;
|
XMMATRIX m_scaleMatrix;
|
||||||
@ -121,4 +133,9 @@ private:
|
|||||||
|
|
||||||
float m_boundingRadius;
|
float m_boundingRadius;
|
||||||
std::wstring m_modelPath;
|
std::wstring m_modelPath;
|
||||||
|
float m_alpha = 0.0f;
|
||||||
|
float m_initialStretch = 0.0f;
|
||||||
|
float m_springConstant = 10.0f;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -2150,7 +2150,9 @@ bool ApplicationClass::RenderPhysics(bool keyLeft, bool keyRight, bool keyUp, bo
|
|||||||
object->SetVelocity(velocity);
|
object->SetVelocity(velocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_Physics->ApplyGravity(object, deltaTime);
|
if (object->m_gravityEnabled) {
|
||||||
|
m_Physics->ApplyGravity(object, deltaTime);
|
||||||
|
}
|
||||||
|
|
||||||
if (XMVectorGetY(object->GetPosition()) < -30.0f) {
|
if (XMVectorGetY(object->GetPosition()) < -30.0f) {
|
||||||
XMVECTOR currentPosition = object->GetPosition();
|
XMVECTOR currentPosition = object->GetPosition();
|
||||||
|
@ -401,6 +401,14 @@ void imguiManager::WidgetObjectWindow(ApplicationClass* app)
|
|||||||
object->SetPhysicsEnabled(m_isPhyiscsEnabled);
|
object->SetPhysicsEnabled(m_isPhyiscsEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Gravity Enabled checkbox
|
||||||
|
std::string gravityLabel = "Gravity##" + std::to_string(index);
|
||||||
|
if (ImGui::Checkbox(gravityLabel.c_str(), &object->m_gravityEnabled))
|
||||||
|
{
|
||||||
|
object->SetGravityEnabled(object->m_gravityEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 3 radio button on the same line to set the ObjectType
|
// 3 radio button on the same line to set the ObjectType
|
||||||
std::string typeLabel = "Type##" + std::to_string(index);
|
std::string typeLabel = "Type##" + std::to_string(index);
|
||||||
ObjectType type = object->GetType();
|
ObjectType type = object->GetType();
|
||||||
@ -419,6 +427,40 @@ void imguiManager::WidgetObjectWindow(ApplicationClass* app)
|
|||||||
object->SetType(ObjectType::Sphere);
|
object->SetType(ObjectType::Sphere);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// button to launch the object
|
||||||
|
std::string launchLabel = "Launch##" + std::to_string(index);
|
||||||
|
|
||||||
|
// paraeter to set the alpha, initial stretch and spring constant
|
||||||
|
float alpha = object->GetAlpha();
|
||||||
|
float initialStretch = object->GetInitialStretch();
|
||||||
|
float springConstant = object->GetSpringConstant();
|
||||||
|
if (ImGui::DragFloat("Alpha##" , &alpha, 0.01f, 0.0f, 1.0f))
|
||||||
|
{
|
||||||
|
object->SetAlpha(alpha);
|
||||||
|
}
|
||||||
|
if (ImGui::DragFloat("Initial Stretch##", &initialStretch, 0.01f, 0.0f, 1.0f))
|
||||||
|
{
|
||||||
|
object->SetInitialStretch(initialStretch);
|
||||||
|
}
|
||||||
|
if (ImGui::DragFloat("Spring Constant##", &springConstant, 0.01f, 0.0f, 100.0f))
|
||||||
|
{
|
||||||
|
object->SetSpringConstant(springConstant);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::Button(launchLabel.c_str()))
|
||||||
|
{
|
||||||
|
object->LaunchObject();
|
||||||
|
}
|
||||||
|
ImGui::SameLine();
|
||||||
|
// button to stop the object
|
||||||
|
std::string stopLabel = "Stop##" + std::to_string(index);
|
||||||
|
if (ImGui::Button(stopLabel.c_str()))
|
||||||
|
{
|
||||||
|
object->SetVelocity(XMVectorSet(0.0f, 0.0f, 0.0f, 0.0f));
|
||||||
|
object->SetPosition(XMVectorSet(0.0f, 0.0f, 0.0f, 0.0f));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
|
@ -306,4 +306,46 @@ ShaderType Object::StringToShaderType(const std::string& str) {
|
|||||||
if (str == "SUNLIGHT") return ShaderType::SUNLIGHT;
|
if (str == "SUNLIGHT") return ShaderType::SUNLIGHT;
|
||||||
// Add other cases as needed
|
// Add other cases as needed
|
||||||
return ShaderType::TEXTURE;
|
return ShaderType::TEXTURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Object::LaunchObject()
|
||||||
|
{
|
||||||
|
// Constants
|
||||||
|
const float gravity = -9.81f;
|
||||||
|
|
||||||
|
// Convert alpha from degrees to radians if needed
|
||||||
|
float alphaRadians = m_alpha * (XM_PI / 180.0f);
|
||||||
|
|
||||||
|
// Scale factors to make the physics simulation more visible
|
||||||
|
float scaleFactor = 200.0f; // Adjust this based on your world scale
|
||||||
|
|
||||||
|
// Calculate initial velocity magnitude using the same formula as the Python code
|
||||||
|
// v_eject = l1 * sqrt(k/m) * sqrt(1 - (m*g*sin(alpha)/(k*l1))^2)
|
||||||
|
float velocityMagnitude = m_initialStretch * sqrtf(m_springConstant / m_mass) *
|
||||||
|
sqrtf(1.0f - powf((m_mass * gravity * sinf(alphaRadians) / (m_springConstant * m_initialStretch)), 2.0f));
|
||||||
|
|
||||||
|
// Apply scale factor
|
||||||
|
velocityMagnitude *= scaleFactor;
|
||||||
|
|
||||||
|
// Calculate velocity components
|
||||||
|
XMVECTOR velocity = XMVectorSet(
|
||||||
|
velocityMagnitude * cosf(alphaRadians), // vx = v0 * cos(alpha)
|
||||||
|
velocityMagnitude * sinf(alphaRadians), // vy = v0 * sin(alpha)
|
||||||
|
0.0f, // z-component (0 for 2D trajectory)
|
||||||
|
0.0f
|
||||||
|
);
|
||||||
|
|
||||||
|
// Apply velocity to object
|
||||||
|
SetVelocity(velocity);
|
||||||
|
|
||||||
|
// Enable physics for the object to handle the trajectory
|
||||||
|
SetPhysicsEnabled(true);
|
||||||
|
|
||||||
|
// Reset grounded state
|
||||||
|
SetGrounded(false);
|
||||||
|
|
||||||
|
// Debug output
|
||||||
|
char buffer[256];
|
||||||
|
sprintf_s(buffer, "Launch velocity: %f m/s at angle %f degrees", XMVectorGetX(XMVector3Length(velocity)), m_alpha);
|
||||||
|
OutputDebugStringA(buffer);
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user