Commit 7af7d661 authored by Jan Kremer's avatar Jan Kremer
Browse files

Cleanup. 2D diagrams now reduce brightness of brushed particles instead of...

Cleanup. 2D diagrams now reduce brightness of brushed particles instead of coloring them black. Added VR pawn to the repo instead of desktop pawn.
parent 0981d341
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
#include "UObject/NoExportTypes.h" #include "UObject/NoExportTypes.h"
#include "Engine/Texture2D.h" #include "Engine/Texture2D.h"
#include <memory> #include <memory>
#include "MyObject.h" #include "SharedEnums.h"
#include "PlotCanvas.generated.h" #include "PlotCanvas.generated.h"
/** /**
...@@ -20,7 +20,7 @@ class IMMERSIVEANALYTICS_API UPlotCanvas : public UObject ...@@ -20,7 +20,7 @@ class IMMERSIVEANALYTICS_API UPlotCanvas : public UObject
public: public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Variables) UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Variables)
UTexture2D* dynamicCanvas; UTexture2D* DynamicCanvas;
UFUNCTION(BlueprintCallable, Category = DrawingTools) UFUNCTION(BlueprintCallable, Category = DrawingTools)
void SetXAxisType(EAxisType Type); void SetXAxisType(EAxisType Type);
...@@ -40,9 +40,6 @@ public: ...@@ -40,9 +40,6 @@ public:
UFUNCTION(BlueprintCallable, Category = DrawingTools) UFUNCTION(BlueprintCallable, Category = DrawingTools)
void ClearCanvas(); void ClearCanvas();
UFUNCTION(BlueprintCallable, Category = DrawingTools)
void InitializeDrawingTools(const int32 brushRadius, uint8 r, uint8 g, uint8 b);
UFUNCTION(BlueprintCallable, Category = DrawingTools) UFUNCTION(BlueprintCallable, Category = DrawingTools)
void DrawScatterPlot(); void DrawScatterPlot();
...@@ -52,19 +49,12 @@ public: ...@@ -52,19 +49,12 @@ public:
UFUNCTION(BlueprintCallable, Category = DrawingTools) UFUNCTION(BlueprintCallable, Category = DrawingTools)
void DrawParallelCoordinatesPlot(); void DrawParallelCoordinatesPlot();
UFUNCTION(BlueprintCallable, Category = DrawingTools)
void DrawDot(const int32 pixelCoordX, const int32 pixelCoordY);
UFUNCTION(BlueprintCallable, Category = DrawingTools) UFUNCTION(BlueprintCallable, Category = DrawingTools)
void DrawPixel(const int32 x, const int32 y, const uint8 r, const uint8 g, const uint8 b, const uint8 a); void DrawPixel(const int32 x, const int32 y, const uint8 r, const uint8 g, const uint8 b, const uint8 a);
UFUNCTION(BlueprintCallable, Category = DrawingTools) UFUNCTION(BlueprintCallable, Category = DrawingTools)
void DrawLine(int32 x1, int32 y1, int32 x2, int32 y2, const uint8 r, const uint8 g, const uint8 b, const uint8 a); void DrawLine(int32 x1, int32 y1, int32 x2, int32 y2, const uint8 r, const uint8 g, const uint8 b, const uint8 a);
void BrushPoints(TArray<int32> BrushPoints, bool Add, bool Rebuild);
void BrushPoint(int32 PointIndex, bool Add);
UFUNCTION(BlueprintCallable, Category = DrawingTools) UFUNCTION(BlueprintCallable, Category = DrawingTools)
void DrawRectangle(int32 x1, int32 y1, int32 x2, int32 y2, const uint8 r, const uint8 g, const uint8 b, const uint8 a); void DrawRectangle(int32 x1, int32 y1, int32 x2, int32 y2, const uint8 r, const uint8 g, const uint8 b, const uint8 a);
...@@ -78,24 +68,16 @@ public: ...@@ -78,24 +68,16 @@ public:
float YMax; float YMax;
private: private:
// canvas std::unique_ptr<uint8[]> CanvasPixelData;
std::unique_ptr<uint8[]> canvasPixelData; int CanvasWidth;
int canvasWidth; int CanvasHeight;
int canvasHeight; int BytesPerPixel;
int bytesPerPixel; int BufferPitch;
int bufferPitch; int BufferSize;
int bufferSize;
// draw brush tool
std::unique_ptr<uint8[]> canvasBrushMask;
int radius;
int brushBufferSize;
std::unique_ptr<FUpdateTextureRegion2D> echoUpdateTextureRegion;
void setPixelColor(uint8*& pointer, uint8 red, uint8 green, uint8 blue, uint8 alpha);
TArray<float>* XArray; std::unique_ptr<FUpdateTextureRegion2D> EchoUpdateTextureRegion;
void SetPixelColor(uint8*& pointer, uint8 red, uint8 green, uint8 blue, uint8 alpha);
TArray<float>* XArray;
TArray<float>* YArray; TArray<float>* YArray;
}; };
// Fill out your copyright notice in the Description page of Project Settings.
#include "PlotRenderTarget.h"
#include "PawnBase.h"
#include "Plot3D.h"
#include "Runtime/Engine/Classes/Engine/Canvas.h"
#include "Runtime/Engine/Classes/Kismet/GameplayStatics.h"
UPlotRenderTarget::UPlotRenderTarget()
{
TScriptDelegate <FWeakObjectPtr> MyDelegate;
MyDelegate.BindUFunction(this, "OnUpdate");
OnCanvasRenderTargetUpdate.Add(MyDelegate);
}
void UPlotRenderTarget::OnUpdate(UCanvas * Canvas, int32 Width, int32 Height)
{
if (!MaterialDot)
{
return;
}
APawn* Pawn = UGameplayStatics::GetPlayerPawn(this, 0);
APawnBase* PawnBase = Cast<APawnBase>(Pawn);
/*
for (int i = 0; i < PawnBase->Plot3D->Points.Num(); ++i)
{
FVector2D Location = FVector2D(PawnBase->Plot3D->Points[i].Location.X * 10000 + Width / 2, PawnBase->Plot3D->U[i] * 5 + Height / 2);
FVector2D LocationB = Location + FVector2D(0, 1);
// Still not fast enough. Using other way to draw the graph.
FCanvasLineItem LineItem(Location, LocationB);
LineItem.LineThickness = 2;
LineItem.SetColor(FLinearColor(1, 1, 1));
LineItem.Draw(Canvas->Canvas);
//Canvas->K2_DrawBox(Location, FVector2D(10, 10), 5);
//Canvas->K2_DrawMaterial(MaterialDot, Location, FVector2D(10, 10), FVector2D(0, 0), FVector2D(1, 1), 0, FVector2D(0.5, 0.5));
//Canvas->K2_DrawLine(Location, LocationB, 2);
}*/
}
// Fill out your copyright notice in the Description page of Project Settings.
#pragma once
#include "CoreMinimal.h"
#include "Engine/CanvasRenderTarget2D.h"
#include "PlotRenderTarget.generated.h"
/**
*
*/
UCLASS()
class IMMERSIVEANALYTICS_API UPlotRenderTarget : public UCanvasRenderTarget2D
{
GENERATED_BODY()
public:
UPlotRenderTarget();
UFUNCTION()
void OnUpdate(UCanvas* Canvas, int32 Width, int32 Height);
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = Default)
UMaterialInterface* MaterialDot;
};
// Fill out your copyright notice in the Description page of Project Settings. // Fill out your copyright notice in the Description page of Project Settings.
#include "MyObject.h" #include "SharedEnums.h"
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
#include "CoreMinimal.h" #include "CoreMinimal.h"
#include "UObject/NoExportTypes.h" #include "UObject/NoExportTypes.h"
#include "MyObject.generated.h" #include "SharedEnums.generated.h"
UENUM(BlueprintType) //"BlueprintType" is essential to include UENUM(BlueprintType) //"BlueprintType" is essential to include
enum class EAxisType : uint8 enum class EAxisType : uint8
...@@ -16,7 +16,7 @@ enum class EAxisType : uint8 ...@@ -16,7 +16,7 @@ enum class EAxisType : uint8
* *
*/ */
UCLASS() UCLASS()
class IMMERSIVEANALYTICS_API UMyObject : public UObject class IMMERSIVEANALYTICS_API USharedEnums : public UObject
{ {
GENERATED_BODY() GENERATED_BODY()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment