diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index c671cd4..e3068fc 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -1,8 +1,9 @@ [/Script/EngineSettings.GameMapsSettings] -GameDefaultMap=/Engine/Maps/Templates/Template_Default.Template_Default - +GameDefaultMap=/Game/Levels/Main.Main +EditorStartupMap=/Game/Levels/Main.Main +GlobalDefaultGameMode=/Script/PBDRobotics.PBDRoboticsGameModeBase [/Script/HardwareTargeting.HardwareTargetingSettings] TargetedHardwareClass=Desktop @@ -15,3 +16,6 @@ AppliedDefaultGraphicsPerformance=Maximum +ActiveGameNameRedirects=(OldGameName="/Script/TP_Blank",NewGameName="/Script/PBDRobotics") +ActiveClassRedirects=(OldClassName="TP_BlankGameModeBase",NewClassName="PBDRoboticsGameModeBase") +[/Script/Engine.RendererSettings] +r.DefaultFeature.AutoExposure=False + diff --git a/Content/Blueprints/BP_Link.uasset b/Content/Blueprints/BP_Link.uasset new file mode 100644 index 0000000..42a76c5 Binary files /dev/null and b/Content/Blueprints/BP_Link.uasset differ diff --git a/Content/Blueprints/BP_Puma.uasset b/Content/Blueprints/BP_Puma.uasset new file mode 100644 index 0000000..db3d858 Binary files /dev/null and b/Content/Blueprints/BP_Puma.uasset differ diff --git a/Content/Blueprints/BP_Robot.uasset b/Content/Blueprints/BP_Robot.uasset new file mode 100644 index 0000000..b03c769 Binary files /dev/null and b/Content/Blueprints/BP_Robot.uasset differ diff --git a/Content/Levels/Main.umap b/Content/Levels/Main.umap new file mode 100644 index 0000000..e0733bb Binary files /dev/null and b/Content/Levels/Main.umap differ diff --git a/Content/Materials/M_Effector.uasset b/Content/Materials/M_Effector.uasset new file mode 100644 index 0000000..ff1cb81 Binary files /dev/null and b/Content/Materials/M_Effector.uasset differ diff --git a/Content/Materials/M_Link.uasset b/Content/Materials/M_Link.uasset new file mode 100644 index 0000000..273887f Binary files /dev/null and b/Content/Materials/M_Link.uasset differ diff --git a/PBDRobotics.uproject b/PBDRobotics.uproject index 412174d..d739a2d 100644 --- a/PBDRobotics.uproject +++ b/PBDRobotics.uproject @@ -7,7 +7,10 @@ { "Name": "PBDRobotics", "Type": "Runtime", - "LoadingPhase": "Default" + "LoadingPhase": "Default", + "AdditionalDependencies": [ + "Engine" + ] } ] } \ No newline at end of file diff --git a/Source/PBDRobotics/Link.cpp b/Source/PBDRobotics/Link.cpp new file mode 100644 index 0000000..73f17d3 --- /dev/null +++ b/Source/PBDRobotics/Link.cpp @@ -0,0 +1,43 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Link.h" + +#include + +#include "Eigen/Dense" + +Eigen::Matrix3d ULink::GetMomentOfInertia() const { + const FVector FI = this->GetInertiaTensor(); + + // Inertial tensor of rotation + const Eigen::Vector3d I(FI.X, FI.Y, FI.Z); + + // Moment of inertia + const Eigen::Matrix3d I0;// = R.transpose() * I * R; + + return I0; +} + +Eigen::Matrix3d ULink::GetRotationMatrix() const{ + const FQuat fq = this->GetRelativeRotation().Quaternion(); + const Eigen::Vector3d q(fq.X, fq.Y, fq.Z); + const double w = fq.W; + Eigen::Matrix3d q_hat; + q_hat << 0, -q.z(), q.y(), + q.z(), 0, -q.x(), + -q.y(), q.x(), 0; + const Eigen::Matrix3d R = (w * w - q.dot(q)) * Eigen::Matrix3d::Identity() + 2 * q * q.transpose() + 2 * w * q_hat; + return R; +} + +void ULink::BeginPlay(){ + const FVector t = this->GetInertiaTensor(); + inertia_tensor = Eigen::Vector3d(t.X, t.Y, t.Z); + + const double M = this->CalculateMass(); + Eigen::Vector3d v; + v << 3, 5, 7; + + UE_LOG(LogTemp, Log, TEXT("%f"), M); +} diff --git a/Source/PBDRobotics/Link.h b/Source/PBDRobotics/Link.h new file mode 100644 index 0000000..3284333 --- /dev/null +++ b/Source/PBDRobotics/Link.h @@ -0,0 +1,34 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "Components/StaticMeshComponent.h" +#include "Eigen/Dense" +#include "Link.generated.h" + +/** + * + */ +UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent)) +class PBDROBOTICS_API ULink : public UStaticMeshComponent +{ + GENERATED_BODY() + +public: + Eigen::Vector3d CenterOfMass; + Eigen::Vector3d Position; + Eigen::Vector3d Velocity; + double Mass; + Eigen::Quaterniond Orientation; + Eigen::Vector3d AngleVelocity; + Eigen::Matrix3d Inertia; + +private: + Eigen::Vector3d inertia_tensor; + Eigen::Matrix3d GetMomentOfInertia() const; + Eigen::Matrix3d GetRotationMatrix() const; + +protected: + virtual void BeginPlay() override; +}; diff --git a/Source/PBDRobotics/Robot.cpp b/Source/PBDRobotics/Robot.cpp new file mode 100644 index 0000000..55ff5b0 --- /dev/null +++ b/Source/PBDRobotics/Robot.cpp @@ -0,0 +1,27 @@ +// Fill out your copyright notice in the Description page of Project Settings. + + +#include "Robot.h" + +// Sets default values +ARobot::ARobot() +{ + // Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it. + PrimaryActorTick.bCanEverTick = true; + +} + +// Called when the game starts or when spawned +void ARobot::BeginPlay() +{ + Super::BeginPlay(); + +} + +// Called every frame +void ARobot::Tick(float DeltaTime) +{ + Super::Tick(DeltaTime); + +} + diff --git a/Source/PBDRobotics/Robot.h b/Source/PBDRobotics/Robot.h new file mode 100644 index 0000000..758d741 --- /dev/null +++ b/Source/PBDRobotics/Robot.h @@ -0,0 +1,26 @@ +// Fill out your copyright notice in the Description page of Project Settings. + +#pragma once + +#include "CoreMinimal.h" +#include "GameFramework/Actor.h" +#include "Robot.generated.h" + +UCLASS() +class PBDROBOTICS_API ARobot : public AActor +{ + GENERATED_BODY() + +public: + // Sets default values for this actor's properties + ARobot(); + +protected: + // Called when the game starts or when spawned + virtual void BeginPlay() override; + +public: + // Called every frame + virtual void Tick(float DeltaTime) override; + +};