-
Notifications
You must be signed in to change notification settings - Fork 16
Model prototype #105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
AVinitzca
wants to merge
11
commits into
develop
Choose a base branch
from
model-prototype
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Model prototype #105
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f58cb9a
Base Sample. Still missing docs
AVinitzca 20b3daa
Added docs and made ModelInfo disposable
AVinitzca 2ae5990
Merge remote-tracking branch 'origin/develop' into model-prototype
AVinitzca 5c92de8
Fixed the Merged methods
AVinitzca 0334805
Fixed codacy issues
AVinitzca 32609b6
Fixed yet another round of codacy warnings
AVinitzca e68018a
Yet another round of codacy issues
AVinitzca bdc3405
Hopefully final codacy rules
AVinitzca 90453a9
Final final.final
AVinitzca 043059a
Addressed requested changes and added docs
AVinitzca 4893491
Fixed problem related to Sonar, to check if it's resolved.
AVinitzca File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
TGC.MonoGame.Samples/Content/3D/sponza/Sponza.fbm/background.tga
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
TGC.MonoGame.Samples/Content/3D/sponza/Sponza.fbm/chain_texture.tga
Git LFS file not shown
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
TGC.MonoGame.Samples/Content/3D/sponza/Sponza.fbm/spnza_bricks_a_diff.tga
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
TGC.MonoGame.Samples/Content/3D/sponza/Sponza.fbm/sponza_arch_diff.tga
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
TGC.MonoGame.Samples/Content/3D/sponza/Sponza.fbm/sponza_ceiling_a_diff.tga
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
TGC.MonoGame.Samples/Content/3D/sponza/Sponza.fbm/sponza_column_a_diff.tga
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
TGC.MonoGame.Samples/Content/3D/sponza/Sponza.fbm/sponza_column_b_diff.tga
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
TGC.MonoGame.Samples/Content/3D/sponza/Sponza.fbm/sponza_column_c_diff.tga
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
TGC.MonoGame.Samples/Content/3D/sponza/Sponza.fbm/sponza_curtain_blue_diff.tga
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
TGC.MonoGame.Samples/Content/3D/sponza/Sponza.fbm/sponza_curtain_diff.tga
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
TGC.MonoGame.Samples/Content/3D/sponza/Sponza.fbm/sponza_curtain_green_diff.tga
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
TGC.MonoGame.Samples/Content/3D/sponza/Sponza.fbm/sponza_details_diff.tga
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
TGC.MonoGame.Samples/Content/3D/sponza/Sponza.fbm/sponza_fabric_blue_diff.tga
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
TGC.MonoGame.Samples/Content/3D/sponza/Sponza.fbm/sponza_fabric_diff.tga
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
TGC.MonoGame.Samples/Content/3D/sponza/Sponza.fbm/sponza_fabric_green_diff.tga
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
TGC.MonoGame.Samples/Content/3D/sponza/Sponza.fbm/sponza_flagpole_diff.tga
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
TGC.MonoGame.Samples/Content/3D/sponza/Sponza.fbm/sponza_floor_a_diff.tga
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
TGC.MonoGame.Samples/Content/3D/sponza/Sponza.fbm/sponza_roof_diff.tga
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
TGC.MonoGame.Samples/Content/3D/sponza/Sponza.fbm/sponza_thorn_diff.tga
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
TGC.MonoGame.Samples/Content/3D/sponza/Sponza.fbm/vase_dif.tga
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
TGC.MonoGame.Samples/Content/3D/sponza/Sponza.fbm/vase_hanging.tga
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
TGC.MonoGame.Samples/Content/3D/sponza/Sponza.fbm/vase_plant.tga
Git LFS file not shown
3 changes: 3 additions & 0 deletions
3
TGC.MonoGame.Samples/Content/3D/sponza/Sponza.fbm/vase_round.tga
Git LFS file not shown
Git LFS file not shown
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| #if OPENGL | ||
| #define SV_POSITION POSITION | ||
| #define VS_SHADERMODEL vs_3_0 | ||
| #define PS_SHADERMODEL ps_3_0 | ||
| #else | ||
| #define VS_SHADERMODEL vs_4_0_level_9_1 | ||
| #define PS_SHADERMODEL ps_4_0_level_9_1 | ||
| #endif | ||
|
|
||
| float4x4 World; | ||
| float4x4 View; | ||
| float4x4 Projection; | ||
|
|
||
| struct VertexShaderInput | ||
| { | ||
| float4 Position : POSITION0; | ||
| float2 TextureCoordinate : TEXCOORD0; | ||
| }; | ||
|
|
||
| struct VertexShaderOutput | ||
| { | ||
| float4 Position : SV_POSITION; | ||
| float2 TextureCoordinate : TEXCOORD1; | ||
| }; | ||
|
|
||
| texture ModelTexture; | ||
| sampler2D textureSampler = sampler_state | ||
| { | ||
| Texture = (ModelTexture); | ||
| MagFilter = Linear; | ||
| MinFilter = Linear; | ||
| AddressU = Wrap; | ||
| AddressV = Wrap; | ||
| }; | ||
|
|
||
| VertexShaderOutput MainVS(in VertexShaderInput input) | ||
| { | ||
| VertexShaderOutput output = (VertexShaderOutput)0; | ||
|
|
||
| float4 worldPosition = mul(input.Position, World); | ||
| float4 viewPosition = mul(worldPosition, View); | ||
|
|
||
| // Project position | ||
| output.Position = mul(viewPosition, Projection); | ||
|
|
||
| // Propagate texture coordinates | ||
| output.TextureCoordinate = input.TextureCoordinate; | ||
|
|
||
| return output; | ||
| } | ||
|
|
||
| float4 MainPS(VertexShaderOutput input) : COLOR | ||
| { | ||
| // Get the texture texel textureSampler is the sampler, Texcoord is the interpolated coordinates | ||
| return tex2D(textureSampler, input.TextureCoordinate); | ||
| } | ||
|
|
||
| technique BasicDrawing | ||
| { | ||
| pass P0 | ||
| { | ||
| VertexShader = compile VS_SHADERMODEL MainVS(); | ||
| PixelShader = compile PS_SHADERMODEL MainPS(); | ||
| } | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| using System; | ||
| using Microsoft.Xna.Framework.Graphics; | ||
|
|
||
| namespace TGC.MonoGame.Samples.Models; | ||
|
|
||
| public class Geometry : IDisposable | ||
| { | ||
| internal VertexBuffer VertexBuffer; | ||
|
|
||
| internal IndexBuffer IndexBuffer; | ||
|
|
||
| internal int VertexOffset; | ||
|
|
||
| internal int StartIndex; | ||
|
|
||
| internal int PrimitiveCount; | ||
|
|
||
| internal bool OwnsVertexBuffer; | ||
|
|
||
| internal bool OwnsIndexBuffer; | ||
|
|
||
|
|
||
| internal static Geometry FromMeshPart(ModelMeshPart part) | ||
| { | ||
| return new Geometry(part); | ||
| } | ||
|
|
||
| internal Geometry() | ||
| { } | ||
|
|
||
| internal Geometry(VertexBuffer vertexBuffer, IndexBuffer indexBuffer) | ||
| { | ||
| VertexBuffer = vertexBuffer; | ||
| IndexBuffer = indexBuffer; | ||
| VertexOffset = 0; | ||
| StartIndex = 0; | ||
| PrimitiveCount = indexBuffer.IndexCount / 3; | ||
| OwnsVertexBuffer = true; | ||
| OwnsIndexBuffer = true; | ||
| } | ||
|
|
||
| private Geometry(ModelMeshPart part) | ||
| { | ||
| VertexBuffer = part.VertexBuffer; | ||
| IndexBuffer = part.IndexBuffer; | ||
| VertexOffset = part.VertexOffset; | ||
| StartIndex = part.StartIndex; | ||
| PrimitiveCount = part.PrimitiveCount; | ||
| OwnsVertexBuffer = false; | ||
| OwnsIndexBuffer = false; | ||
| } | ||
|
|
||
| public void Draw(Effect effect) | ||
| { | ||
| var graphicsDevice = effect.GraphicsDevice; | ||
|
|
||
| graphicsDevice.SetVertexBuffer(VertexBuffer); | ||
| graphicsDevice.Indices = IndexBuffer; | ||
|
|
||
| foreach (var pass in effect.CurrentTechnique.Passes) | ||
| { | ||
| pass.Apply(); | ||
| graphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, | ||
| VertexOffset, StartIndex, PrimitiveCount); | ||
| } | ||
| } | ||
|
|
||
|
|
||
| public void Dispose() | ||
| { | ||
| if (OwnsVertexBuffer) | ||
| { | ||
| VertexBuffer.Dispose(); | ||
| } | ||
|
|
||
| if (OwnsIndexBuffer) | ||
| { | ||
| IndexBuffer.Dispose(); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| using Microsoft.Xna.Framework; | ||
| using Microsoft.Xna.Framework.Graphics; | ||
|
|
||
| namespace TGC.MonoGame.Samples.Models; | ||
|
|
||
| public struct GeometryData(Geometry geometry, Matrix relativeMatrix, Texture[] textures) | ||
| { | ||
| public Geometry Geometry { get; private set; } = geometry; | ||
|
|
||
| public Matrix RelativeMatrix { get; private set; } = relativeMatrix; | ||
|
|
||
| public Texture[] Textures { get; private set; } = textures; | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.