Skip to content
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

Chapter 3 Part 1: Model Loading #90

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

DigitalBox98
Copy link

This version is inspired by adamsmith1990 initial work but with the same approach than LearnOpenGL website for textures rendering.

Camera movement is via the left-click on mouse and wireframe/plain texture via the N key.

Tested OK on dotnet6.0 (and revert to dotnet8.0 before commit)

plain wire

Version with same approach than LearnOpenGL for textures
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should mark the OBJ file as a binary file or something like that so that git doesn't track 200k lines in this commit. Can you mark a file as binary and still have automatic EOL conversions happen?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, via .gitattributes

Copy link
Member

@NogginBops NogginBops left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have some things I want to change with this in the future but I think it's fine to get this merged as it is right now and then I can use my review comments as TODOs in #89.

Common/Model.cs Outdated
for (int i = 0; i < mat.GetMaterialTextureCount(type); i++)
{
TextureSlot str;
mat.GetMaterialTexture(type, i, out str);
string filename = directory + "/" + str.FilePath;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be Path.Combine(directory, str.FilePath).


public static Texture LoadFromFile(string path)
public static Texture LoadFromFile(string filename, string type = "texture_diffuse")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We generally avoid default arguments in opentk code. Also I don't think this field is a good idea, and if we where going to do it I would rather this be an enum rather than a string.

Comment on lines +65 to +74
string number = new string("0");
string name = textures[i].type;
if (name == "texture_diffuse")
number = new string(""+diffuseNr++);
else if (name == "texture_specular")
number = new string("" + specularNr++); // transfer int to string
else if (name == "texture_normal")
number = new string("" + normalNr++); // transfer int to string
else if (name == "texture_height")
number = new string("" + heightNr++); // transfer int to string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to rework this texture solution in it's entirety.
But I think it's fine for this PR, I'll be able to do the rework as part of #89.

@NogginBops
Copy link
Member

I just realized that there are two model loading PRs.
Will take a look at #76 and see if we can reconcile these PRs and get a best of both worlds.

@NogginBops
Copy link
Member

Also, after marking .obj files as binary you also have to "re-add" the file to get git to actually consider it a binary file. The diff of this PR is still 200 thousand lines.

@DigitalBox98
Copy link
Author

Ok i have removed the backpack.obj and then added it again.
I'm not sure if it has worked as I can see this file in this PR not considered as a BIN.
Is there anything wrong somewhere ?

@deccer
Copy link
Collaborator

deccer commented Feb 24, 2024

bin and obj and all their combinations are in .gitignore, because of bin and obj folders. I am not sure if we should include rather large model files in this repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants