daily update on 20240828 by nitload youmu, autotexture added

This commit is contained in:
Nitload
2024-08-28 10:58:31 +08:00
parent d082071f2d
commit 1ee4e4a42f
586 changed files with 60910 additions and 123106 deletions
+20 -19
View File
@@ -38,6 +38,7 @@ namespace StgSharp.Gaming
{
public abstract class Bullet : IInstancing, IPlainEntity
{
protected Bullet
(
PlainInstancingBuffer<Bullet> buffer,
@@ -54,11 +55,23 @@ namespace StgSharp.Gaming
GlobalBuffer = buffer;
BufferId = buffer.CreateInstanceID();
((IInstancing)this).Scale = scale;
((IInstancing)this).Coord = new vec3d( beginPosition,0);
((IInstancing)this).Coord = new vec3d(beginPosition, 0);
((IInstancing)this).Rotation = angle;
Motion = movement;
}
public GeometryMotion Motion
{
get;
set;
}
public IInstancingBuffer GlobalBuffer
{
get;
set;
}
public int BufferId
{
get;
@@ -71,28 +84,16 @@ namespace StgSharp.Gaming
set;
}
public IInstancingBuffer GlobalBuffer
{
get;
set;
}
public GeometryMotion Motion
{
get;
set;
}
vec3d IInstancing.CenterPositionGlobal
{
get;
set;
}
public bool CollideWith(IPlainEntity entity)
{
throw new System.NotImplementedException();
}
vec3d IInstancing.CenterPositionGlobal
{
get;
set;
}
}
}
+76 -106
View File
@@ -31,9 +31,10 @@
using StgSharp.Data;
using StgSharp.Geometries;
using StgSharp.Graphics;
using StgSharp.Graphics.GL;
using StgSharp.Logic;
using StgSharp.Graphics.OpenGL;
using StgSharp.Math;
using StgSharp.MVVM;
using System;
using System.Buffers;
@@ -45,74 +46,97 @@ using System.Threading.Tasks;
namespace StgSharp.Stg
{
public class CollisionTextureInput : BlueprintPipelineArgs
public interface IOneDimensionalCollisionTexture2D
{
#pragma warning disable CS8618
public CollisionTextureInput()
#pragma warning restore CS8618
{
}
public new List<IInstancingBuffer> Value
{
get; set;
}
public void Init(Radius angleStride, string name);
}
public class OneDimensionalCollisionTexture2D : glRenderStream
public sealed class OneDimensionalCollisionTexture2D_GL : glRenderStream, IOneDimensionalCollisionTexture2D
{
private const string inputName = "InstanceBufferList";
private const string outputName = "CollisionTextureOutput";
float[] textureOutput;
ElementBuffer ebo;
private FrameBuffer fbo;
RenderBuffer rbo;
ShaderProgram generatingShader;
TextureGL t;
VertexArray vao;
VertexBuffer vbo;
ElementBuffer ebo;
public OneDimensionalCollisionTexture2D(ViewPort args) : base(args,(1,1,1))
public OneDimensionalCollisionTexture2D_GL()
{
throw new InvalidOperationException(
$"Collision TextureGL unit cannot share context with other render stream or set as mainstream of a form," +
$"and cannot be inited by {typeof(ViewPort).Name} as well."
);
}
#pragma warning disable CS8618
public OneDimensionalCollisionTexture2D(Radius angleStride, string name) :
#pragma warning restore CS8618
base( new ViewPort()
public override bool IsContextSharable => false;
public void GenerateCollisionTexture(IEnumerable<IInstancingBuffer> bufferEnumeration)
{
fbo.Bind(0);
GL.ClearColor(0, 0, 0, 1);
GL.Clear(MaskBufferBit.DEPTH | MaskBufferBit.COLOR);
generatingShader.Use();
vao.Bind(0);
foreach (IInstancingBuffer item in bufferEnumeration)
{
IGeometry g = item.TypicalShape;
if (!(g is PlainGeometry))
{
throw new InvalidOperationException("The current particle buffer contains non-planar geometry,");
}
ebo.Bind(0);
ebo.SetValue<int>(0, g.VertexIndices, BufferUsage.StreamDraw);
vbo.WriteVectorData<vec4d>(0, item.CoordAndRotationSpan, BufferUsage.StreamDraw);
vao.SetVertexAttribute(1, 3, TypeCode.Single, false, 4 * sizeof(float), 0);
vao.SetVertexAttribute(2, 1, TypeCode.Single, false, 4 * sizeof(float), 3 * sizeof(float));
vbo.WriteScalerData<float>(2, item.ScalingSpan, BufferUsage.StreamDraw);
vao.SetVertexAttribute(3, 1, TypeCode.Single, false, sizeof(float), 0);
vbo.WriteVectorData(1, g.VertexStream, BufferUsage.StreamDraw);
vao.SetVertexAttribute(0, 3, TypeCode.Single, false, 4 * sizeof(float), 0);
GL.DrawElementsInstanced(GeometryType.TRIANGLES, ((uint)g.VertexIndices.Length) / 3,
TypeCode.UInt32, IntPtr.Zero, (uint)item.ScalingSpan.Length);
}
t.Bind2D(0);
GL.GetTextureImage(Texture2DTarget.Texture2D, 0, ImageChannel.SingleColor, PixelChannelLayout.Float, textureOutput);
VertexArray.BindNull();
}
public void Init(Radius angleStride, string name)
{
primeArgs = new ViewPort
{
Height = 1,
Width = (int)((new Radius(Scaler.Pi)) / angleStride),
Name = name,
},(1, 1, 1))
{
InternalInit();
};
_coordStretch = (1, 1, 1);
PlatformSpecifiedInitialize();
CustomizeInit();
}
protected override string[] InputPortsName =>
[
inputName,
];
#pragma warning disable CS8618
protected override string[] OutputPortsName =>
[
outputName,
];
protected override void Deinit()
protected override void CustomizeDeinit()
{
throw new NotImplementedException();
}
protected override void Init()
protected override void CustomizeInit()
{
generatingShader = CreateShaderProgram();
@@ -133,84 +157,30 @@ namespace StgSharp.Stg
fbo = CreateFrameBuffer(1);
RenderBuffer rbo = CreateRenderBuffer(1);
glFunc.SetRenderBufferStorage(
rbo = CreateRenderBuffer(1);
GL.SetRenderBufferStorage(
RenderBufferInternalFormat.Depth24_Stencil8, this.Size);
t = CreateTexture(1);
t.Bind2D(0);
glFunc.TextureImage2d(Texture2DTarget.Texture2D, 0, (int)ImageChannel.WithAlphaChannel,
(uint)Width, (uint)Height, (int)ImageChannel.WithAlphaChannel, ImageChannelLayout.Byte, glHandle.ZeroHandle);
GL.TextureImage2d<byte>(Texture2DTarget.Texture2D, 0, (int)ImageChannel.WithAlphaChannel,
(uint)Width, (uint)Height, (int)ImageChannel.WithAlphaChannel, PixelChannelLayout.Byte, Array.Empty<byte>());
t.Set2dWrapProperty(Wrap.Repeat, Wrap.Repeat);
t.Set2dFilterProperty(Filter.Nearest, Filter.Nearest);
t.Set2dWrapProperty(0, TextureWrap.Repeat, TextureWrap.Repeat);
t.Set2dFilterProperty(0, TextureFilter.Nearest, TextureFilter.Nearest);
glFunc.FrameBufferTexture2d(FrameBufferTarget.All, glAttachment.Color(0),
GL.FrameBufferTexture2d(FrameBufferTarget.All, glAttachment.Color(0),
Texture2DTarget.Texture2D, t[0], 0);
glFunc.CombineFrameBufferRenderBuffer(fbo[0], rbo[0]);
GL.CombineFrameBufferRenderBuffer(FrameBufferAttachment.Color, rbo[0]);
textureOutput = new float[this.Width];
}
TextureGL t;
float[] textureOutput;
protected override void Main(
in Dictionary<string, BlueprintPipeline> input,
in Dictionary<string, BlueprintPipeline> output)
protected override void Main()
{
if (input == null)
{
throw new InvalidOperationException($"Unknown operation lead to null ref of {nameof(input)}");
}
if (input[inputName].Args is not CollisionTextureInput inpipeline || inpipeline.Value == null || inpipeline.Value.Count == 0)
{
throw new InvalidOperationException();
}
List<IInstancingBuffer> bufferList = inpipeline.Value;
fbo.Bind(0);
glFunc.ClearColor(0, 0, 0, 1);
glFunc.Clear(MaskBufferBit.DEPTH|MaskBufferBit.COLOR);
generatingShader.Use();
vao.Bind(0);
foreach (IInstancingBuffer item in bufferList)
{
IGeometry g = item.TypicalShape;
if (!(g is PlainGeometry))
{
throw new InvalidOperationException("The current particle buffer contains non-planar geometry,");
}
ebo.Bind(0);
ebo.SetValue<int>(0,g.VertexIndices,BufferUsage.StreamDraw);
vbo.WriteVectorData<vec4d>(0,item.CoordAndRotationSpan,BufferUsage.StreamDraw);
VertexArray.SetVertexAttribute(1,3,TypeCode.Single,false, 4 * sizeof(float), 0);
VertexArray.SetVertexAttribute(2,1, TypeCode.Single,false,4*sizeof(float), 3 * sizeof(float));
vbo.WriteScalerData<float>(2, item.ScalingSpan, BufferUsage.StreamDraw);
VertexArray.SetVertexAttribute(3, 1, TypeCode.Single, false, sizeof(float), 0);
vbo.WriteVectorData(1,g.VertexStream,BufferUsage.StreamDraw);
VertexArray.SetVertexAttribute(0,3,TypeCode.Single,false,4*sizeof(float),0);
glFunc.DrawElementsInstanced(GeometryType.TRIANGLES,(uint)g.VertexIndices.Length / 3,
TypeCode.UInt32,IntPtr.Zero,(uint)item.ScalingSpan.Length);
}
t.Bind2D(0);
glFunc.GetTextureImage(Texture2DTarget.Texture2D,0,ImageChannel.SingleColor,ImageChannelLayout.Float,ref textureOutput);
VertexArray.BindNull();
}
protected override void ProcessInput()
{
throw new NotImplementedException();
throw new NotSupportedException();
}
}
+31 -1
View File
@@ -1,4 +1,34 @@
using System;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="TimeLine.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
@@ -1,4 +1,34 @@
using StgSharp.Graphics;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="TouhouBuilder.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Graphics;
using StgSharp.Touhou;
using System;
@@ -12,7 +42,7 @@ namespace StgSharp.Stg.Touhou
/*
public static View BuildTouhouWorld()
public static ViewBase BuildTouhouWorld()
{
TouhouForm form = new TouhouForm();
@@ -1,4 +1,36 @@
using StgSharp.Graphics;
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="TouhouWindow.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.Graphics;
using StgSharp.MVVM;
using StgSharp.MVVM.ViewModel;
using System;
using System.Collections.Generic;
@@ -6,5 +38,14 @@ using System.Text;
namespace StgSharp.Touhou
{
public abstract class TouhouWindowMain : ViewModelBase
{
protected TouhouWindowMain(ViewPort vp) : base(vp, 60)
{
}
}
}
@@ -0,0 +1,53 @@
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
// file="OpenningView.cs"
// Project: StgSharp
// AuthorGroup: Nitload Space
// Copyright (c) Nitload Space. All rights reserved.
//
// Permission is hereby granted, free of charge, to any person
// obtaining a copy of this software and associated documentation
// files (the “Software”), to deal in the Software without restriction,
// including without limitation the rights to use, copy, modify, merge,
// publish, distribute, sublicense, and/or sell copies of the Software,
// and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
//
// The above copyright notice and
// this permission notice shall be included in all copies
// or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED “AS IS”,
// WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
// INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
// IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH
// THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
//-----------------------------------------------------------------------
//-----------------------------------------------------------------------
using StgSharp.MVVM.View;
using StgSharp.MVVM.ViewModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StgSharp.Stg.Touhou
{
public abstract class OpenningView : ViewBase
{
public override void CustomizedInitialize(ViewModelBase viewModelBinding)
{
throw new NotImplementedException();
}
}
}