MrScautHD
MrScautHD
CC#
Created by MrScautHD on 4/27/2024 in #help
Inlcude content after run a command (.csproj)
No description
4 replies
CC#
Created by MrScautHD on 4/26/2024 in #help
Compile Native Lib
I wanna ask how i can build a C project in my .csproj to use the .dll from it, do someone know or has a example for me?
43 replies
CC#
Created by MrScautHD on 3/17/2024 in #help
PerlinNoise Lib?
Do somone know a perlin noise lib on nuget or in generel a noise lib?
11 replies
CC#
Created by MrScautHD on 3/12/2024 in #help
How can i save `Textures, Shaders...` in my nuget packet?
Hello, i try to save my textures and shaders in my nuget packet but it wont work that i what i tried:
<ItemGroup>
<Content Include="content/**/*" Pack="true">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="content/**/*" Pack="true">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
46 replies
CC#
Created by MrScautHD on 3/9/2024 in #help
Hey guys, how can i check if my 2 Quaternions looking in the same direction?
Hey guys, how can i check if my 2 Quaternions looking in the same direction?
16 replies
CC#
Created by MrScautHD on 2/3/2024 in #help
Bug in c#, with the Dll Importer.
No description
3 replies
CC#
Created by MrScautHD on 11/12/2023 in #help
Frustum culling
Hello i try to setup a Frustum culling system but it always returns true even if the object is not in the frustum. What i guess it is: Before normalization, it functions correctly, albeit with an incorrect size. To achieve precision, I must closely inspect my object, making slight rotations. However, after normalization, it consistently returns true and never provides a false outcome. Normalized: https://media.discordapp.net/attachments/1036008388552839169/1173215015948521573/image.png?ex=656324a1&is=6550afa1&hm=7de8eef894c9cf4cb5be82363e2ee0c06aa89034da866294b7d0da3dbc8ce1d4&= Wihout Normalizing: if i look exactly on it i can see it: https://cdn.discordapp.com/attachments/1036008388552839169/1173215314331320440/image.png?ex=656324e8&is=6550afe8&hm=8bf65ae87f380c572e57db16235cfa9e02d8cc827433beea3cf2dc81af6f577b& But if i move more away it is gone: https://cdn.discordapp.com/attachments/1036008388552839169/1173215337727139890/image.png?ex=656324ed&is=6550afed&hm=64e388f63e55102dda61e83af167daf05b5d8bb4fa258eb9dfea8c73362c0193& My class:
public class Frustum {

// View frustum planes
private Plane[] _frustumPlanes;

public Frustum(Matrix4x4 viewProjectionMatrix) {
_frustumPlanes = ExtractPlanes(viewProjectionMatrix);
}

public bool IsSphereInFrustum(Vector3 center, float radius) {
foreach (var plane in _frustumPlanes) {
float distance = Vector3.Dot(plane.Normal, center) + plane.D;

if (distance < -radius) {
// The sphere is entirely behind this plane, it is outside the frustum
return false;
}
}

// The sphere is not entirely behind any plane, it is partially or fully inside the frustum
return true;
}

private Plane[] ExtractPlanes(Matrix4x4 viewProjectionMatrix) {

// Extract view frustum planes from the view-projection matrix
Plane[] planes = new Plane[6];

// Left plane
planes[0] = new Plane(
viewProjectionMatrix.M14 + viewProjectionMatrix.M11,
viewProjectionMatrix.M24 + viewProjectionMatrix.M21,
viewProjectionMatrix.M34 + viewProjectionMatrix.M31,
viewProjectionMatrix.M44 + viewProjectionMatrix.M41
);

// Right plane
planes[1] = new Plane(
viewProjectionMatrix.M14 - viewProjectionMatrix.M11,
viewProjectionMatrix.M24 - viewProjectionMatrix.M21,
viewProjectionMatrix.M34 - viewProjectionMatrix.M31,
viewProjectionMatrix.M44 - viewProjectionMatrix.M41
);

// Bottom plane
planes[2] = new Plane(
viewProjectionMatrix.M14 + viewProjectionMatrix.M12,
viewProjectionMatrix.M24 + viewProjectionMatrix.M22,
viewProjectionMatrix.M34 + viewProjectionMatrix.M32,
viewProjectionMatrix.M44 + viewProjectionMatrix.M42
);

// Top plane
planes[3] = new Plane(
viewProjectionMatrix.M14 - viewProjectionMatrix.M12,
viewProjectionMatrix.M24 - viewProjectionMatrix.M22,
viewProjectionMatrix.M34 - viewProjectionMatrix.M32,
viewProjectionMatrix.M44 - viewProjectionMatrix.M42
);

// Near plane
planes[4] = new Plane(
viewProjectionMatrix.M13,
viewProjectionMatrix.M23,
viewProjectionMatrix.M33,
viewProjectionMatrix.M43
);

// Far plane
planes[5] = new Plane(
viewProjectionMatrix.M14 - viewProjectionMatrix.M13,
viewProjectionMatrix.M24 - viewProjectionMatrix.M23,
viewProjectionMatrix.M34 - viewProjectionMatrix.M33,
viewProjectionMatrix.M44 - viewProjectionMatrix.M43
);

// Normalize the planes
for (int i = 0; i < 6; i++) {
planes[i] = Plane.Normalize(planes[i]);
}

return planes;
}
}
public class Frustum {

// View frustum planes
private Plane[] _frustumPlanes;

public Frustum(Matrix4x4 viewProjectionMatrix) {
_frustumPlanes = ExtractPlanes(viewProjectionMatrix);
}

public bool IsSphereInFrustum(Vector3 center, float radius) {
foreach (var plane in _frustumPlanes) {
float distance = Vector3.Dot(plane.Normal, center) + plane.D;

if (distance < -radius) {
// The sphere is entirely behind this plane, it is outside the frustum
return false;
}
}

// The sphere is not entirely behind any plane, it is partially or fully inside the frustum
return true;
}

private Plane[] ExtractPlanes(Matrix4x4 viewProjectionMatrix) {

// Extract view frustum planes from the view-projection matrix
Plane[] planes = new Plane[6];

// Left plane
planes[0] = new Plane(
viewProjectionMatrix.M14 + viewProjectionMatrix.M11,
viewProjectionMatrix.M24 + viewProjectionMatrix.M21,
viewProjectionMatrix.M34 + viewProjectionMatrix.M31,
viewProjectionMatrix.M44 + viewProjectionMatrix.M41
);

// Right plane
planes[1] = new Plane(
viewProjectionMatrix.M14 - viewProjectionMatrix.M11,
viewProjectionMatrix.M24 - viewProjectionMatrix.M21,
viewProjectionMatrix.M34 - viewProjectionMatrix.M31,
viewProjectionMatrix.M44 - viewProjectionMatrix.M41
);

// Bottom plane
planes[2] = new Plane(
viewProjectionMatrix.M14 + viewProjectionMatrix.M12,
viewProjectionMatrix.M24 + viewProjectionMatrix.M22,
viewProjectionMatrix.M34 + viewProjectionMatrix.M32,
viewProjectionMatrix.M44 + viewProjectionMatrix.M42
);

// Top plane
planes[3] = new Plane(
viewProjectionMatrix.M14 - viewProjectionMatrix.M12,
viewProjectionMatrix.M24 - viewProjectionMatrix.M22,
viewProjectionMatrix.M34 - viewProjectionMatrix.M32,
viewProjectionMatrix.M44 - viewProjectionMatrix.M42
);

// Near plane
planes[4] = new Plane(
viewProjectionMatrix.M13,
viewProjectionMatrix.M23,
viewProjectionMatrix.M33,
viewProjectionMatrix.M43
);

// Far plane
planes[5] = new Plane(
viewProjectionMatrix.M14 - viewProjectionMatrix.M13,
viewProjectionMatrix.M24 - viewProjectionMatrix.M23,
viewProjectionMatrix.M34 - viewProjectionMatrix.M33,
viewProjectionMatrix.M44 - viewProjectionMatrix.M43
);

// Normalize the planes
for (int i = 0; i < 6; i++) {
planes[i] = Plane.Normalize(planes[i]);
}

return planes;
}
}
4 replies
CC#
Created by MrScautHD on 10/19/2023 in #help
❔ .DLL NOT FOUNDED!
No description
27 replies
CC#
Created by MrScautHD on 10/15/2023 in #help
❔ Why is the Ecxepction not written in the Out TextWriter?
I try to write the Console to a File:
private static void SetupConsoleOutput() {
if (LogPath != null) {

StreamWriter fileWriter = new StreamWriter(LogPath, true);
fileWriter.AutoFlush = true;
SyncTextWriter syncWriter = new SyncTextWriter(Console.Out, fileWriter);

Console.SetOut(syncWriter);
Console.SetError(syncWriter);
}
}
private static void SetupConsoleOutput() {
if (LogPath != null) {

StreamWriter fileWriter = new StreamWriter(LogPath, true);
fileWriter.AutoFlush = true;
SyncTextWriter syncWriter = new SyncTextWriter(Console.Out, fileWriter);

Console.SetOut(syncWriter);
Console.SetError(syncWriter);
}
}
Thats the SyncTextWriter:
public class SyncTextWriter : TextWriter {

private readonly TextWriter _firstWriter;
private readonly TextWriter _secondWriter;

public override Encoding Encoding => Encoding.UTF8;

public SyncTextWriter(TextWriter firstWriter, TextWriter secondWriter) {
this._firstWriter = firstWriter;
this._secondWriter = secondWriter;
}

public override void Write(char value) {
this._firstWriter.Write(value);
this._secondWriter.Write(value);
}

public override void WriteLine(string? value) {
this._firstWriter.WriteLine(value);
this._secondWriter.WriteLine(value);
}

public override void Flush() {
this._firstWriter.Flush();
this._secondWriter.Flush();
}

public override void Close() {
this._firstWriter.Close();
this._secondWriter.Close();
}
}
public class SyncTextWriter : TextWriter {

private readonly TextWriter _firstWriter;
private readonly TextWriter _secondWriter;

public override Encoding Encoding => Encoding.UTF8;

public SyncTextWriter(TextWriter firstWriter, TextWriter secondWriter) {
this._firstWriter = firstWriter;
this._secondWriter = secondWriter;
}

public override void Write(char value) {
this._firstWriter.Write(value);
this._secondWriter.Write(value);
}

public override void WriteLine(string? value) {
this._firstWriter.WriteLine(value);
this._secondWriter.WriteLine(value);
}

public override void Flush() {
this._firstWriter.Flush();
this._secondWriter.Flush();
}

public override void Close() {
this._firstWriter.Close();
this._secondWriter.Close();
}
}
121 replies
CC#
Created by MrScautHD on 10/12/2023 in #help
❔ What is the best Physic library for c#?
Are there any good Physics libraries?
31 replies
CC#
Created by MrScautHD on 9/9/2023 in #help
❔ MSBuild: How to call own Task in the .csproj
Hi i tried to call my task in the . csproj but idk how, that is what i tried:
<Target Name="Headless">
<HeadlessTask SourceFile="*.cs" />
</Target>
<Target Name="Headless">
<HeadlessTask SourceFile="*.cs" />
</Target>
5 replies
CC#
Created by MrScautHD on 9/1/2023 in #help
✅ Attribute that can remove Methods and class from compiling
Hi, im looking for a attribute that can remove methods and classes from the compiler, or would it possbile to doing something like that by my self?
33 replies
CC#
Created by MrScautHD on 8/26/2023 in #help
❔ MSBuild is it possible to set a additonal property?
Hello i tried already: Main Project:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>

<!-- Define a default value for EnableMyFeature, can be overridden by referencing project -->
<EnableMyFeature>false</EnableMyFeature>
</PropertyGroup>

<PropertyGroup Condition="'$(EnableMyFeature)' == 'true'">
<DefineConstants>$(DefineConstants);MY_CONSTANT</DefineConstants>
</PropertyGroup>

<!-- ... -->
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>

<!-- Define a default value for EnableMyFeature, can be overridden by referencing project -->
<EnableMyFeature>false</EnableMyFeature>
</PropertyGroup>

<PropertyGroup Condition="'$(EnableMyFeature)' == 'true'">
<DefineConstants>$(DefineConstants);MY_CONSTANT</DefineConstants>
</PropertyGroup>

<!-- ... -->
</Project>
Project that referencing this ^^
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>

<!-- Override EnableMyFeature here -->
<EnableMyFeature>true</EnableMyFeature>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="path/to/LibraryProject.csproj">
<AdditionalProperties>EnableMyFeature=$(EnableMyFeature)</AdditionalProperties>
</ProjectReference>
</ItemGroup>

<!-- ... -->
</Project>
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>

<!-- Override EnableMyFeature here -->
<EnableMyFeature>true</EnableMyFeature>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="path/to/LibraryProject.csproj">
<AdditionalProperties>EnableMyFeature=$(EnableMyFeature)</AdditionalProperties>
</ProjectReference>
</ItemGroup>

<!-- ... -->
</Project>
But idk why i does not work Do i use the right nuget packet?
<PackageReference Include="Microsoft.Build" Version="17.7.2" />
<PackageReference Include="Microsoft.Build" Version="17.7.2" />
46 replies
CC#
Created by MrScautHD on 8/22/2023 in #help
❔ Is there a way to override a Variable in the .csproj by a project that is reference this project?
Is there a way to override a Variable in the .csproj by a project that is reference this project?
10 replies
CC#
Created by MrScautHD on 8/19/2023 in #help
❔ How can i remove methods or classes with an Attribute from compiling?
61 replies
CC#
Created by MrScautHD on 8/16/2023 in #help
❔ What is the best GUI system for C#?
Does anyone know a good lib that impliment a gui system?
59 replies
CC#
Created by MrScautHD on 6/5/2023 in #help
❔ I looking for Game Engine / Framework!
Is there any cool Game Engine / Framework
7 replies
CC#
Created by MrScautHD on 6/3/2023 in #help
❔ How to start a Console Project with code.
Like i run my client and want to start a server by pressing on a button in the application then should start a server Any idea to do this?
3 replies
CC#
Created by MrScautHD on 5/28/2023 in #help
❔ Get all Types that extend from my class Entity
Heyy! I want to get all my Entity Typesm would that possible to get all classes that use Entity?
17 replies
CC#
Created by MrScautHD on 5/19/2023 in #help
✅ I updated to .NET 8 and now it broke...
23 replies