OpenGL Tutorial 13 - Model Loading

Поділитися
Вставка
  • Опубліковано 9 лис 2024

КОМЕНТАРІ • 237

  • @mikk5428
    @mikk5428 2 роки тому +27

    For those who are having crashes with loading new models.
    Main reason might be the file "Model.cpp" on line 193. Loader is trying to load "byteOffset" value from the .gltf file which may not be present.
    Fix this by setting the default value of the returned JSON value. Change the line to "unsigned int byteOffset = bufferView.value("byteOffset", 0);"
    You may still have some crashes with some models, textures being messed up or meshes not in the right position. In this case you should really understand how this simple loader gets its data from the gltf files.

  • @ojaskavathe
    @ojaskavathe 2 роки тому +17

    7:47 I think this may be the reason for you having to negate the rotation matrix and the UVs. The order in which parameters of a function are read is unspecified in c++. MSVC reads them from right to left, so in the constructor of glm::vec3, i++ in the z value gets incremented first, then y, and then x. The x and z values are thus interchanged, but the y remains unaffected. It's probably better to use a more traditional for loop here.

    • @VictorGordan
      @VictorGordan  2 роки тому +5

      Huh... I had no idea about that 🤔 thank you! I should def study up on C++ more... 😅

  • @maxencedupont5523
    @maxencedupont5523 2 роки тому +6

    I found a little flaw ! This model loader works perfectly in Debug Mode, however , it does not load anything in Releae Mode. It is a vicious issue lol. the error is due to release mode optimizing the for loops. The compiler will try and run for loops in parallel meaning the code in model.cpp from lines 305 onwards will not run as expected (the groupFloatsVec functions). You will need to change them to be for (int i = 0; i < floatVec.size(); i+=3) (replace 3 with 2 for vec2 and 4 for vec4 etc) then you need to do glm::vec3(floatVec[i+2], floatVec[i+1], floatVec[i] for a vec3 for example) etc in the for loop. You really should precise it cause Release Mode is neccesary for anyone that wants to export their projects as .exe files. Hope that helps !

    • @VictorGordan
      @VictorGordan  2 роки тому +1

      Sadly the model loader has more flaws than just that haha. Not very proud of this video tbh :(
      But even so, I think it might still help some ppl •~•

    • @JayLovesProgramming
      @JayLovesProgramming 20 днів тому

      @@VictorGordan Dude great video. I followed part through and managed to get this to build, run, output the JSON data in the output and still no models shows... Guess it's time to watch the tutorial from the start but if you could make a updated version of this tutorial that would be AWESOME. Thanks again dude, great vid

  • @ema1ih
    @ema1ih 2 роки тому +1

    Thank you so much for the tutorials!! I'm trying to finish a project for college and so far you explained almost everything i have to implement!

  • @CarterM2008
    @CarterM2008 2 роки тому +4

    Learning OpenGL is a very rewarding thing, just watched the Tutorial from beginning up to this one on a crash course.
    P.S. The programming code kinda reminds me of ZScript from Doom Source Ports and Mods but more simple.

  • @ZizuZiomek
    @ZizuZiomek 3 роки тому +5

    Scroll model has holes. To draw them correctly, fragment shader should discard pixel where: "if(texcolor.a < 0.5)
    discard;".
    Alternative solution is to use alpha blending (requires sorting geometry or Order Independent Transparency method, so it's much harder), but in that model discarding is enough.

    • @VictorGordan
      @VictorGordan  3 роки тому

      Yeah, I'm planning to do a video on transparency soon! :)

    • @ZizuZiomek
      @ZizuZiomek 3 роки тому +1

      if someone has problem with rendering in release mode, or rotated bunny model (other models probably too):
      Solution 1: change C++ version to 17
      Solution 2: change every expression like "uint8_t bytes[] = { data[i++], data[i++], data[i++], data[i++]};" to "uint8_t bytes[] = { data[i], data[i+1], data[i+2], data[i+3]}; i+=4;". At least in Model.cpp
      Problem was with undefined order of computing arguments in older version of C++. C++17 finally specifies the order.

    • @VictorGordan
      @VictorGordan  3 роки тому

      @@ZizuZiomek Thank you for contributing!

  • @kazeroth1234
    @kazeroth1234 2 роки тому +3

    A troubleshooting tip.
    I wasn't able to get a Model to load for quite awhile and after stepping through with the Debugger. I noticed that my scale was either set to some extremely low value (e-6) or exactly 0.
    I found out that in my Mesh.h, in my void Draw() that I was initializing the scale values to be glm::vec3(0.0f, 0.0f, 0.0f) by accident.
    While I'm not sure if its because the sword.gltf did not have scale values to over-ride the 0s and I'm missing something else.
    But I hope this helps anyone who reads this and is stuck!

  • @piotrek7633
    @piotrek7633 4 місяці тому

    actually goated for explaining the format

  • @malysonbreno3361
    @malysonbreno3361 2 роки тому +1

    Nice tutorial, it really helped me.
    Waiting for the animation tutorial.

    • @VictorGordan
      @VictorGordan  2 роки тому +1

      Thank you! ^-^
      Don't hold your breath, the animation tutorial is unlikely to come anytime soon...

  • @SUUHOO-i4g
    @SUUHOO-i4g Рік тому +3

    I've been watching your tutorials and really appreciate them. However, I have a question about glTF and the JSON description.
    After a quick search, it seems that glTF can import objects using JSON files.
    If I need to import an asset (.uasset) created in unrealengine or a model from another program, do I need to convert the model to a JSON file so I can import it into glTF?
    Does this require some knowledge of JSON to import, and is that why you added the explanation in the tutorial?

    • @piotrek7633
      @piotrek7633 4 місяці тому

      You need some converter i think khronos linked them in their github page

  • @_jose_antonio_
    @_jose_antonio_ 2 роки тому +4

    this video helped me a lot to put objects and scenarios in my project, but I'm having problems making the animation system, I already made one in assimp so I know the base

  • @andrenguyen8373
    @andrenguyen8373 Рік тому +2

    Hello Victor, thanks for this tutorial. The 3D model is loading but i still get an error. If I compile the program, it is bringing me to this line in json.h:
    JSON_THROW(type_error::create(302, concat("type must be number, but is ", j.type_name()), &j));
    I copied your code in github and paste it everywhere, hoping it vanish. Do you have any idea? Still thank you for your tutorials!

  • @Byynx
    @Byynx Рік тому +10

    This is a good example on how this teaching style doesn't work.

    • @freemotion21
      @freemotion21 10 місяців тому

      Wdym

    • @kingofspades9720
      @kingofspades9720 7 місяців тому +4

      @@freemotion21probably because it doesn’t really teach, so knowledge isn’t really gained because you are essentially just copy and pasting code while scrambling to try to do it as fast as possible because he only goes over topics for a split second in the video

    • @Combinehuntsmanunit
      @Combinehuntsmanunit 18 днів тому

      @@kingofspades9720 this sort of tutorial is meant for people that are already experienced with c++. he isn't really teaching c++ or anything, mainly hes just explaining the opengl implementation in c++ while giving you an example. this is more for people making their own engine that want to understand opengl more. your correct about the headache inducing editing though, he should really pause for a second every edit just to allow you to keep up.

    • @kingofspades9720
      @kingofspades9720 17 днів тому

      @@Combinehuntsmanunit I’m not amazing at programming or anything, but I have a masters in computer software(at the end of this term), and this still was a super annoying video to watch to learn OpenGL, it wasn’t the complexity of having to basically learn C++ and OpenGL, this video still has a horrible teaching style even if you have the C++ experience

  • @BrUSomania
    @BrUSomania 2 роки тому

    Great tutorial as always, Victor! Dictionaries is one of the reasons why I love Python, so it's awesome to see the C++ (JSON) variant to this in your tutorial.

  • @TheCaptainginger
    @TheCaptainginger 2 роки тому +1

    Great lesson! No problems with simple models, really. But with complex gltf i cannot understand, whether supported several meshes in one model or not. I have a car model with 80 objects in it (with simple single materials for every mesh), but Model.cpp draws only first mesh. So car body looks great but has no wheels, decals, and so on. PS. used with MinGW.

    • @VictorGordan
      @VictorGordan  2 роки тому +2

      Yeah, this does not work with complex models :(

  • @AndroidGameCoder
    @AndroidGameCoder Рік тому +1

    The index files I come across have 4 vertex/texture/normal groups per line instead of 3. Is that forth one used with 2 of the first three to make another triangle with a shared side?

  • @gavgonacrt
    @gavgonacrt 2 роки тому +1

    Great tutorial, as always! How would I go about rotating a model/ changing its position when a key is pressed? Thanks in advance!

    • @VictorGordan
      @VictorGordan  2 роки тому +1

      Look at the camera tutorial to see how to handel inputs, and look at the going 3d tutorial to see an example of using rotation matrices to rotate models ;)

    • @colbymartin2499
      @colbymartin2499 Рік тому

      @gavgonacrt Did you ever end up figuring this out?

    • @gavgonacrt
      @gavgonacrt Рік тому

      @@colbymartin2499 Yeah I did in the end. For a rotating cylinder, I wrote it something like this:
      - Set a starting speed of 0.0f to a speed variable
      - Create a key listener
      - When the key is pressed, set speed to whatever
      - Set the ObjectModel = glm::rotate(ObjectModel, glm::radians(the speed variable), glm::vec3(axis to rotate on))
      - Activate shader
      - Update matrices

  • @testotesti8307
    @testotesti8307 3 роки тому

    Very good tutorials, congrats!
    You seem to have corrected the negative sign in front of the rotation matrix 12:18 , in the tutorial 14, you don't have it anymore.
    Could you tell us how you fixed it?
    Thanks for everything!

    • @VictorGordan
      @VictorGordan  3 роки тому

      I have sadly did not fix it :c
      I just removed it cause that's what worked for this particular model...

    • @testotesti8307
      @testotesti8307 3 роки тому

      @@VictorGordan that's weird, all objects you have in your resources are print upside down without it for me (including the ones of the next tutorials)

    • @VictorGordan
      @VictorGordan  3 роки тому

      Hmmm, yeah tbh I'm not sure what's going on exactly 🤔 I messed up smth small at some point somewhere, but at this point I really don't feel like finding the bug... don't even have the time for it

  • @spire_dev354
    @spire_dev354 3 роки тому +2

    Hi 👋, I need some help, I imported models from your repo, everything works fine but textures aren’t being mapped properly, textures are messed up (I even tried the source code)

    • @VictorGordan
      @VictorGordan  3 роки тому

      Can you describe in what way they are messed up? My guess would be they are turned by 90 degrees in one direction. If you look in the vertex shader, you'll see I multiply the texture coordinates with a mat2. For me rotating them makes them look normal, but perhaps your system is different. So just delete that mat2 and see if that fixes it. ;)
      Good luck!

  • @Nick-kb2jc
    @Nick-kb2jc 2 роки тому +1

    What 3D modeling program are you using to generate your "scene.gltf" file? I exported one from Blender and it doesn't have that "uri" field. I also tried exporting my gltf using the three.js online editor and it did have the "uri" field that time, but it was populated with a long string of data starting with "data:application/" and then followed by a bunch of binary data instead of "scene.bin" like your file.
    EDIT: Nevermind! I found out how to export the bin with Blender. Thanks for the tutorial!

    • @VictorGordan
      @VictorGordan  2 роки тому +1

      You can also get gltf models from the website I mentioned in the video. I think they're owned by Epic now, so they probably have even more free stuff than before haha

    • @Nick-kb2jc
      @Nick-kb2jc 2 роки тому +1

      @@skibidisigma122 First select "File > Export > glTF". Then in the window that comes up after, select "glTF Seperate (.gltf + .bin)" from the format dropdown menu.

  • @hashtag9990
    @hashtag9990 2 роки тому

    Typing feels so clean, without tabbing every word

  • @aaron6807
    @aaron6807 3 роки тому

    This has been very helpful though admittedly most of the JSON explanations went over my head lol.
    Thank you for this series. And any clue how to render with a single or a couple draw calls for these models? Calling the Mesh::Draw function for every mesh seems inefficient

    • @VictorGordan
      @VictorGordan  3 роки тому +1

      Thank you! Check out tutorial number 21 (Instancing) to see how to use less draw calls for identical models. As for models that differ, the only way I am aware of is to combine their vertex data into a single VBO and so you only need one draw call. But that's a bit more advanced...

    • @aaron6807
      @aaron6807 3 роки тому

      @@VictorGordan I thought of that. It has been a busy week but I'm finally getting to implement it

  • @IlliaZhdanov
    @IlliaZhdanov Рік тому

    pls make a video on rendering .STL's w/ microstl + opengl.

  • @slugintub
    @slugintub 9 місяців тому +1

    Hey victor, do you have any idea how multiple models could be loaded? I tried but only one mesh displays.

    • @RetroEcoChicken
      @RetroEcoChicken 6 місяців тому

      if you want, you can use his totorial with something called assimp. i used this because it lets me import obj and fbx file formats thats what blender 2.79 can export. i now have a gameobject class that stores meshes and executes a alternative mesh.draw so i have them all liked to one gameobject. this also lets me do stuff like rotating the whole object at its axis. i also use it because it imports bones too so im working on getting animation to work. if you want to try it dont get the files from their site since it looks sketchy. safer to get it from jpres's library. he uses directx11 but it works since we just want the uv coords, vecticies and indicies.

  • @randomdudely
    @randomdudely 3 роки тому +1

    Hi, nice tutorials. Why is the default value of bufferViewInd set as 1? If the index is not specified, shouldn't it be 0?

    • @VictorGordan
      @VictorGordan  3 роки тому +1

      Thx :)
      Could you point out where in the video I wrote that? I wrote this a long time ago so I don't remember what that is for 😬

    • @randomdudely
      @randomdudely 3 роки тому

      @@VictorGordan Oh sorry about that. It's 5:20

    • @VictorGordan
      @VictorGordan  3 роки тому +1

      @@randomdudely yeah, I believe you are right, it should be 0...oops
      Thx for the catch!

    • @randomdudely
      @randomdudely 3 роки тому

      @@VictorGordan no problem. Thank you for this series :)

  • @shadow_blader192
    @shadow_blader192 10 місяців тому +1

    12:30 why did i put minus sign like you :c? It reversed all of my axes

  • @CohnDavid
    @CohnDavid 2 роки тому +1

    Thank you for your video. It works fine for me for the models in your repo. But it didn't work for any other model I downloaded from sketchfab. I understand that you intentionally wrote a simple importer for this tutorial that will work only for basic models. Is there an official importer somewhere that works for all models? (in gltf site for example?) I looked everywhere in the internet and didn't find any. I find it very strange that the developers of gltf didn't supply any importer for opengl (c++) since that's the goal of gltf isn't it? how can people use it and render models without an importer?

    • @VictorGordan
      @VictorGordan  2 роки тому

      I think there are some gltf importers, but not any official ones. If u want a quick library to use, go with assimp, especially since there are some tutorials on it out there ;)

    • @BlessedDog
      @BlessedDog Рік тому

      It doesnt work because the model is huge and when imported it goes way beyond the camera's vision. Rescale the model in Blender.

  • @oh-facts
    @oh-facts 9 місяців тому

    In your opinion, could there be any benefits to parsing the gltf files yourself (apart from learning), or is it better to use a library?

    • @VictorGordan
      @VictorGordan  9 місяців тому

      99% of the time a library would be better

    • @piotrek7633
      @piotrek7633 4 місяці тому

      If there's a library for it then you 100% use it, apart from practice, why bother wasting time understanding a big data type such as gltf if the creators/passionate programmer already did and made some easy importer for it. We have tinygltf for example, it already parses the data into nice lists that you can pick from, without you needing to understand all the fuckfest of a tree they created

  • @x3n662
    @x3n662 2 місяці тому

    Hello Victor, I am having a problem in this video related to textures, when I use one of my models the textures doesnt load and it only appears the model in black, I know its been 3 years but, Can you help me?

  • @kartikkain386
    @kartikkain386 2 роки тому

    I did evrything exactly as you but i'm having 4 warnings and the glwindow is closing after a second , warings are C26800 use of a moved from object "("")" in json.h file on line 4009.

  • @cheesebu
    @cheesebu 2 роки тому

    @Victor Gordan Very nice series, has motivated me to return to OpenGL. I am having a problem with this tutorial tho: after calling the draw function I don't see the model (only the background) and I don't get any errors. Any idea why this might be happening?

    • @VictorGordan
      @VictorGordan  2 роки тому

      Most likely a vertex shader bug, or a problem with the model loader

    • @cheesebu
      @cheesebu 2 роки тому

      @@VictorGordan Managed to track down the error. I am getting a GL_INVALID_OPERATION from the VAO.Bind() in the Mesh::Draw() call. This just got me even more confused. Any ideas?

    • @VictorGordan
      @VictorGordan  2 роки тому

      That error can be caused by many many things :(

    • @cheesebu
      @cheesebu 2 роки тому +1

      @@VictorGordan I figured it out. It's because I am a dumbass! For some reason I decided to call glDeleteVertexArrays in the destructor of the VAO, which was called when we are adding temporary objects to the vector, so by the time I was drawing the model I didn't have a VAO.

  • @SNOW-dz8qc
    @SNOW-dz8qc 11 місяців тому

    I have followed the tutorial exactly and I managed to load the bunny model in , but it is upside down. Also, how can I load a model that I downloaded online that only has a .gltf file and nothing else? The way your code works, I also need basecolor and metallic elements.

  • @LynJuice
    @LynJuice 3 роки тому +1

    well, this is weird all the models work textures and all. but when I make a random cube with a texture it just loads black yet in any other program, it loads in normally. is there a converter that would work or anything that could help?

    • @VictorGordan
      @VictorGordan  3 роки тому +1

      If you made a cube in Blender, then you probably exported the model in a compact format, while the importer in the tutorials requires a gltf file + a binary file + texture files.
      Also make sure the textures have names that the importer supports. Changing just the names of the textures does not work, you also have to change the names of the textures inside the gltf file ;)

    • @LynJuice
      @LynJuice 3 роки тому

      @@VictorGordan thank you turns out the texture name wasn't supported

  • @adrianojose7172
    @adrianojose7172 3 роки тому +1

    Hi thanks for the videos they all have been extremely helpful, I was wondering how could I move a model up/down/left/right. I loaded in two models but they seem to be quite close to each other. Can you help me?

    • @VictorGordan
      @VictorGordan  3 роки тому +1

      Move them using translations matrices! You just have to slightly modify the model class to accept translation matrices from outside the importer like it is now

    • @adrianojose7172
      @adrianojose7172 3 роки тому

      @@VictorGordan Thank you!! :D

    • @kyonoaku8478
      @kyonoaku8478 2 роки тому

      @@VictorGordan May I ask that how to modify the code specifically? I tried. But it still can't move correctly. Could you help me?

    • @VictorGordan
      @VictorGordan  2 роки тому

      @@kyonoaku8478 rewatch the "Going 3D" tutorial from this series, that should hopefully clear it up

    • @kyonoaku8478
      @kyonoaku8478 2 роки тому

      @@VictorGordan Thank you! I'll watch it again. This series is awesome. You did a mega job! ❤️

  • @johngayman4100
    @johngayman4100 2 роки тому +2

    Just personal opinion but I think this tutorial kinda goes a little bit overboard with .gltf file. Something easy like .obj file could have been better. That being said, great work my guy.

    • @VictorGordan
      @VictorGordan  2 роки тому

      Very fair point. I was actually thinking about using .obj due to its simplicity, but decided against it due to the *hopefully* bright future of glTF. That being said, if I ever decide to redo this series and make it better, I will probably use .obj since it would be a lot more noob friendly haha

  • @AB-bp9fi
    @AB-bp9fi 3 роки тому

    How can i know xyz coordinates of mesh triangle (or point) selected with mouse on imported mesh? Does opengl provide method to tell which vertex was clicked? Separate question is which object was clicked.

    • @VictorGordan
      @VictorGordan  3 роки тому +1

      OpenGL doesn't provide anything like that by default, you have to implement it yourself. Here's something to get you started on it: community.khronos.org/t/selecting-vertices/44202

  • @diahaidificbs
    @diahaidificbs 2 роки тому +1

    Hey I used to be able to load models easily following ur tuts, but now every time I load something new, json.h throws an exception for type_error saying “type must be number”. I can still load previous models but I can’t load any new models at all even though windows model loader opens them just fine. Do u know what’s going on with that exception? Cheers

    • @VictorGordan
      @VictorGordan  2 роки тому

      The loader is not that good, it probably sees smth it doesn't expect and just throws an error 😅

    • @diahaidificbs
      @diahaidificbs 2 роки тому

      @@VictorGordan ahh now i see why, btw any plans on doing assimp? I know there are other resources out there but ur style of teaching is what makes it great 😌

    • @VictorGordan
      @VictorGordan  2 роки тому

      No, I won't do assimp, sorry :(

    • @mikk5428
      @mikk5428 2 роки тому +1

      Same here. Provided models work fine but any new .gltf file throws an error "nlohmann::detail::type_error at memory location 0x0000001AB82FA388" at the "type must be number" line.
      Props for making custom loader but would be awesome tutorial if it would show what to do next to get it working again or point to the right direction. I believe pros definitely know what to do but majority of the viewers here are beginners.

  • @thomasspalter5958
    @thomasspalter5958 3 роки тому

    Hi! Loving your tutorials so far! One question: I got the code working with the provided models in Debug, but not in Release. Do you know why that could be? Thanks!

    • @VictorGordan
      @VictorGordan  3 роки тому +1

      When you were setting up your project properties you did not select "All Configurations" ;)

    • @thomasspalter5958
      @thomasspalter5958 3 роки тому

      @@VictorGordan Thanks for the quick help! Unfortunately, it looks like I did do that. I even tried resetting the dependencies for All Configurations and All Platforms... Any idea what I should do?

    • @VictorGordan
      @VictorGordan  3 роки тому +1

      @@thomasspalter5958 Wait, by "Release" did you actually mean the executable? Because if you try to run it from outside VS, then you need to copy all the resource files (shaders, textures, meshes) into the same folder as the executable ;)

    • @thomasspalter5958
      @thomasspalter5958 3 роки тому

      @@VictorGordan I don't think so, as I'm still running the program from VS. If this helps, the problem I'm running into happens before I press Local Windows Debugger, where next to it I can choose Debug or Release. In Debug, the Model shows, and there's a short period where the program's screen is white before displaying the model with my ClearColor. In Release, the ClearColor shows up immediately, but there is no model. Thanks for your help!

    • @VictorGordan
      @VictorGordan  3 роки тому

      The only other explanation I can think of is that one of the libraries you might be debug only, not release as well. Other than that I really have no idea, sorry :/

  • @coronelwhatsapp7151
    @coronelwhatsapp7151 2 роки тому +1

    Very nice series of tutorials except I didn’t really like the speed of the tutorial, I always had to pause the video or turn the playback speed down.

  • @AnalyzeForSafety
    @AnalyzeForSafety 3 роки тому

    I was following up all the series to this video, but after this one, I just don't get where the lighting is coming from
    You seem to have removed the lighShader in the main.cpp file, so how does it work?
    Or is the light supposed to be included in the gltf file?
    When I import the bunny, I just get a get bunny without light...
    I tried the sword model and I don't see anything.
    The scroll model is soo big... even when zooming out, I just see a part of it
    I probably did something wrong, if you could let me know what this is that would be awesome!
    Thanks

    • @VictorGordan
      @VictorGordan  3 роки тому +1

      The lightShader has nothing to do with lighting. All that the shader was for, was to display the little cube as a representation of a light source. The actual light "comes" from the lightColor uniform and the lightPos uniform, and then the way that light "behaves" is all coded in the default.frag shader.
      But keep in mind that just because your models are black, it does not mean that there is something wrong with the lighting. There might be something wrong with the texture importing, or something else. Can't really tell you much without seeing the code.
      I suggest just making sure your code is the same as the source code. Also, I suggest re-watching the lighting video since you don't seem to fully comprehend how the light works.

    • @AnalyzeForSafety
      @AnalyzeForSafety 3 роки тому

      @@VictorGordan Thank you for this reply and your comments, I'll have a look again at the code, probably some bug in my code as I rewrote while I was following the videos! I didn't understand everything 100% indeed, sometimes your video go very fast... but I definitively learned a lot. Thanks again for your amazing video series

    • @VictorGordan
      @VictorGordan  3 роки тому

      Yeah, they do go fast, but if you don't understand something, just go back a few seconds and listen to it again :)
      The way I meant the videos to be watched it by looking at the theory, seeing some code, pausing, writing it, unpausing, listen to some more theory. It's not really meant to take you the length of the video.
      Glad you enjoy the series though! :)

    • @AnalyzeForSafety
      @AnalyzeForSafety 3 роки тому

      @@VictorGordan Yeah sure, I understand and it's really well done!
      I found my problem and it was very stupid... just forgot to change the light type in the fragment shader... it was set to spotlight so I didn't see anything. Now it works ! Thanks again

  • @babdie
    @babdie 4 місяці тому

    trans, rot , scale are all abstracted to mesh class while model class only 2 parameters in its Draw() function , its not possible to transform from main.cpp file 😪

  • @loping4
    @loping4 Рік тому

    Bunny model is small, scroll model is so huge that is clips out when I try to zoom back far enough to see all of it.

    • @VictorGordan
      @VictorGordan  Рік тому

      Yeah, they are of different sizes haha. You can make them bigger or smaller by multiplying their vertex positions by a constant

    • @loping4
      @loping4 Рік тому

      @@VictorGordan Thanks! Do you plan on making a video on collision detection? What I'm interested in is creating walls for my environment that the camera can't go past.

    • @VictorGordan
      @VictorGordan  Рік тому

      I might do that at some point, but it's for sure not a priority right now

    • @loping4
      @loping4 Рік тому

      @@VictorGordan Thanks for the info, keep it up, these tutorials are the best I've seen so far on OpenGL.

  • @Derekstefan
    @Derekstefan 3 роки тому

    If you wanted to load lets say 3 models, what would you have to do with reference to your code?

    • @VictorGordan
      @VictorGordan  3 роки тому +1

      You'd just have to load three models and draw them. That's all there is to it 😅

    • @Derekstefan
      @Derekstefan 3 роки тому

      @@VictorGordan oh ok lol

  • @maverikmiller6746
    @maverikmiller6746 2 роки тому

    Hey man. If I wanted to have an .obj importer instead of gltf what would I have to do ?
    Thanks.

    • @VictorGordan
      @VictorGordan  2 роки тому

      .obj should be much easiee than .gltf, but also much more limited in terms of the stuff it can hold. I suggest looking for some tutorials (there should be some for .obj) or just looking at how the file is structured.
      Keep in mind .obj is essentially a text file, so you'll have to read and interpret the data yourself as far as I'm aware.

    • @maverikmiller6746
      @maverikmiller6746 2 роки тому

      @@VictorGordan Thanks man. Will look for it. Hope it works.

  • @AbSEnZzZ
    @AbSEnZzZ 2 роки тому

    In the constructor for the Model class I get a "nlohmann::detail::parse_error " when trying to parse any of the models :( any idea?

    • @VictorGordan
      @VictorGordan  2 роки тому

      Nu clue honestly. Smth to do with the json library. Try googling it

  • @ghostrat_1792
    @ghostrat_1792 3 роки тому +1

    Hey could anyone help me I keep getting an error which says Unhandled exception thrown: read access violation.
    **_Parent_proxy** was 0xFFFFFFFFFFFFFFF7. could anyone help?

    • @VictorGordan
      @VictorGordan  3 роки тому

      It's basically impossible to debug that without seeing the code. I suggest first trying to find the line where the error happens, and then posting a question on stack overflow :)

  • @cezarhg2007
    @cezarhg2007 3 роки тому

    problem here, important sword model and the vertices / shape of the sword is fine but it seems the textures arent been set because the sword just has red, green, blue lines

    • @VictorGordan
      @VictorGordan  3 роки тому

      That should be an easy fix. You probably imported the texture as GL_RGB instead of GL_RGBA or viceversa ;)

    • @cezarhg2007
      @cezarhg2007 3 роки тому +1

      @@VictorGordan found the problem, i changed the desired channels in stbi_load from 0 to stbi_rgb_alpha because there was an exception error when running the pyramid program. changed it back and it work fine

  • @russtycrussty7884
    @russtycrussty7884 Рік тому

    yo how do i change the scale, position, and rotation of a model. cant seem to figure it out looking at the code.

    • @VictorGordan
      @VictorGordan  Рік тому

      Check tutorial 7. It's about how 3D projection works. That should answer your question if I remember the contents of the video correctly

  • @mackerel987
    @mackerel987 2 роки тому

    Hello Victor! I have some problems with the model loading... I get "unhandled exception" when i try to run my code. It happens specifically at the data=getData() function in model.cpp. The error says "int at memory location 0x00".
    Any ideas on this?

    • @VictorGordan
      @VictorGordan  2 роки тому +1

      No clue, it could be anything really :(

    • @mackerel987
      @mackerel987 2 роки тому

      @@VictorGordan Hello Victor. I'm trying to use assimp loading from learnopengl tutorial in conjunction with this tutorial. Do you have any plans on making an assimp tutorial for this series?

    • @VictorGordan
      @VictorGordan  2 роки тому +1

      No, I don't plan on making an AssImp tutorial :/

  • @Greenlaser
    @Greenlaser 3 роки тому +2

    idk if im dumb or what or is it supposed to happen but im getting like 5k errors at 1:19 including E0135 namespace "nlohmann" has no member "json"
    using json = nlohmann::json;
    the second json is underlined with red but yours isnt, is that supposed to happen? i made the json.h file at libraries/include/json with the json stuff in it

    • @Greenlaser
      @Greenlaser 3 роки тому

      ok so apparently these two files are different?
      the one i copied: raw.githubusercontent.com/nlohmann/json/develop/include/nlohmann/json.hpp
      and your json.h:
      raw.githubusercontent.com/VictorGordan/opengl-tutorials/main/UA-camOpenGL%2013%20-%20Model%20Loading/Libraries/include/json/json.h
      yours is working fine but the one i got gave all the errors

    • @Greenlaser
      @Greenlaser 3 роки тому

      i found the problem - i clicked on the releases json file which was released in 2020 august while the correct one in the actual develop branch was the most up to date one :D

    • @VictorGordan
      @VictorGordan  3 роки тому

      👌🏻

  • @oscarbayton1118
    @oscarbayton1118 2 роки тому

    where do you put the models? Do you just take the models folder and copy and paste it directly into your solution? I dont think you specify this and you go way too fast at the end

    • @VictorGordan
      @VictorGordan  2 роки тому +1

      It doesn't really matter where the models are as long as your filepath to the models is correct

  • @Greenlaser
    @Greenlaser 3 роки тому

    hey when switching between debug and release i dont see the models in release but theyre fine in debug, was there anything else i needed to edit other than vc++ directories - include and library directories and linker - input - additional dependencies? i cant figure out where the problem is at :D

    • @VictorGordan
      @VictorGordan  3 роки тому +1

      That's why you should always select "All Configurations" :p haha
      Check the following:
      Configuration Properties -> General
      Configuration Properties -> VC++ Directories
      C/C++ -> General
      Linker -> Input
      Though these seem to be the same as the ones you've listed.... I might be missing something as well though. Also keep in mind that perhaps one of your libraries only works for debugging and not for release. Some libraries are split like that.
      Good luck finding the problem ;)

    • @Greenlaser
      @Greenlaser 3 роки тому

      @@VictorGordan i'm also getting a defaultlib 'MSVCRTD' conflicts with use of other libs error and PDB 'glfw3.pdb' was not found at x64/release when on release, could potentially be a library issue?

    • @VictorGordan
      @VictorGordan  3 роки тому +1

      @@Greenlaser To be honest I don't really know what the problem might be. Never happened to me (I usually just mess up the linking or something like that, which does not seem to be the case here).
      Sorry... :/

    • @Greenlaser
      @Greenlaser 3 роки тому

      @@VictorGordan i believe the best solution then is to redo the project from the beginning cuz i cant find the problem :D

    • @VictorGordan
      @VictorGordan  3 роки тому +1

      lol, that's one way of going about it I suppose haha

  • @SNOW-dz8qc
    @SNOW-dz8qc 10 місяців тому

    Hello, I have a very urgent matter if anyone in the comments can help me. Is there a tutorial, based on the model class in this tutorial that shows us how to move the model once we loaded it? I have loaded in a submarine model, but I want to make it so that when I press the WASD keys the submarine moves. how do I do that?

  • @zeroskyline8037
    @zeroskyline8037 Рік тому

    👍

  • @silvertakana3932
    @silvertakana3932 2 роки тому +3

    longer than usual? this is still way shorter than those other 30 mins to an hour of OpenGL tutorials! often, they would talk about the life problem! But you, you're just speeding man! also, the Triangle one is 15 minutes and this is 14 minutes and 49 seconds🙃

    • @VictorGordan
      @VictorGordan  2 роки тому +2

      I also find it annoying when they just stop and spend time thinking about something or tell their life story haha

  • @Greenlaser
    @Greenlaser 3 роки тому

    getting this error when loading
    SHADER_COMPILATION_ERROR for:VERTEX
    the project loads fine but i cant see anything other than the blue color

    • @VictorGordan
      @VictorGordan  3 роки тому

      Well as it says, you have an error somewhere inside your Vertex Shader most likely. That's also why nothing appears, because if there is an error in the vertex shader, it discards all the geometry. If there is an error in the fragment shader, is keeps the geometry but makes it all black.
      Hope that helps :)

    • @Greenlaser
      @Greenlaser 3 роки тому

      @@VictorGordan yes i found differences in both the Model.cpp and default.vert scripts :D

  • @tunglequang8503
    @tunglequang8503 2 роки тому

    Hi, I have a question. How could i blur a model or move it? Can you help me?

    • @VictorGordan
      @VictorGordan  2 роки тому +1

      You move it using translation matrices, look at the camera and going 3D tutorials for more insight into that.
      You can blur a scene using framebuffers, I also have a tutorial on that ;)

    • @tunglequang8503
      @tunglequang8503 2 роки тому

      @@VictorGordan Thanks. And how could i disappear half of model or something like that? 😅

    • @VictorGordan
      @VictorGordan  2 роки тому

      Not sure what you mean exactly, but I'm sure there are multiple ways of doing it (stencil buffers come to mind first, which I also have a tutorial on)

  • @samholland209
    @samholland209 10 місяців тому

    Why not use the .obj file format.

    • @VictorGordan
      @VictorGordan  10 місяців тому

      Very limited. But yeah, for a series meant for beginners I should have went with .obj

  • @octopro8937
    @octopro8937 Рік тому

    If you are having issues and ur thing says something about auto texture recognition, comment out the else statement in texture.cpp and the throw std invalid thingy

  • @n0o0ot38
    @n0o0ot38 3 роки тому

    I can only load the stanford rabbit for some reason and I copy and pasted from the source in every file apart from main.cpp. please help.

    • @VictorGordan
      @VictorGordan  3 роки тому +1

      Well I can't help you with that little information... All I can say is check the code is the same (many people say the code is identical, and then they discover it's not)

    • @n0o0ot38
      @n0o0ot38 3 роки тому

      @@VictorGordan nvm I got it working it was a problem with the gltf files and the textures for some reason they just refused to load

    • @diahaidificbs
      @diahaidificbs 3 роки тому +1

      @@n0o0ot38 hey man having the same problem here, mind telling me how u fixed it?

    • @n0o0ot38
      @n0o0ot38 3 роки тому +1

      Just try redownloading the models and everything until they work with the windows model loader. Or sometimes itll not work with the windows model loader but sometimes load. It's just really finnicky

    • @Lado93
      @Lado93 2 роки тому

      I have simillar problem. I can load all model but their are not rotated in right way (where their should be vertically oriented they are horizontally) and my texture look like they are loading wrong. They are there but not the right way.

  • @longjohn7992
    @longjohn7992 Рік тому

    Lighting doesn’t work anymore.

  • @cloudbeta614
    @cloudbeta614 Рік тому

    Hello i wanted to ask where the matrix is? I mean how can i transform the model? I have just a vector of matricies

    • @VictorGordan
      @VictorGordan  Рік тому

      Hmmm, I honestly don't remember, it was a long time ago. It's either in the json file, or you can manually send it to the shader using a uniform ;)

    • @cloudbeta614
      @cloudbeta614 Рік тому

      @@VictorGordan I just want to implement a method called "rotate" because i have to rotate my model. I would not want to create a new model for every rotation i want 😅 Is there not somewhere the data? You talked about we need to assign the transfomation i thought it is i there?

    • @VictorGordan
      @VictorGordan  Рік тому

      Then you for sure need to use uniforms ;)

    • @cloudbeta614
      @cloudbeta614 Рік тому

      @@VictorGordan Doesnt it reset the uniform after one frame?

    • @VictorGordan
      @VictorGordan  Рік тому

      Only if you choose to reset it. From what I remember the uniform will keep the value it was last set to

  • @maximzelencik8623
    @maximzelencik8623 3 роки тому

    When I try to compile I get LNK2019 error and I can't figure out how to solve it

    • @VictorGordan
      @VictorGordan  3 роки тому

      That's a linking error. There are many possible causes for it, so I can't rly help :/

    • @maximzelencik8623
      @maximzelencik8623 3 роки тому

      ​@@VictorGordan It says the problem is in the Model.obj
      I didn't have this error before I included JSON

    • @VictorGordan
      @VictorGordan  3 роки тому

      Then it's a linking error related to JSON. You didn't link it properly

    • @maximzelencik8623
      @maximzelencik8623 3 роки тому

      I did it same as it is in the tutorial is there something more I need to do?

    • @VictorGordan
      @VictorGordan  3 роки тому

      You probably missed a small step or something. The way I did it in the tutorial should work

  • @manshaafzal9979
    @manshaafzal9979 10 місяців тому

    Severity Code Description Project File Line Suppression State
    Error C2783 'nlohmann::json_abi_v3_11_3::basic_json::operator ValueType(void) const': could not deduce template argument for 'ValueType' Project1 C:\Users\mansha\Documents\Project1\Model.cpp 124 can someone please explain why showing this error?

  • @noname-ni3hp
    @noname-ni3hp Рік тому

    how its gonna know what the value of loadedTex/TexName

    • @VictorGordan
      @VictorGordan  Рік тому

      It's a long time ago that I wrote the code, but if I remember correctly it either has a default name such as "diffuse0.png", or there is a variable of the name somewhere in the code...

    • @noname-ni3hp
      @noname-ni3hp Рік тому

      @@VictorGordan i looked up for everything i am trying to fix this issue 2 days ago the sword mesh is being huge and there are no texture just black color

    • @noname-ni3hp
      @noname-ni3hp Рік тому

      @@VictorGordan I checked every .h and every .cpp file that we created this lesson and are the same what you did in the source code

    • @noname-ni3hp
      @noname-ni3hp Рік тому

      @@VictorGordan I solved it i must take the texture to the ImageTexture folder in the .sln

  • @stfoggy124
    @stfoggy124 2 роки тому

    is this faster than assimp?

    • @VictorGordan
      @VictorGordan  2 роки тому

      This exact implementation? No, not at all. It's not good. But generally speaking if you make a custom glTF importer, then yes, it can be faster than assimp :)

  • @RosieSapphireMusic
    @RosieSapphireMusic 2 роки тому

    And here I am trying to port all this shit to C.

    • @VictorGordan
      @VictorGordan  2 роки тому

      Ooof, good luck!

    • @RosieSapphireMusic
      @RosieSapphireMusic 2 роки тому

      @@VictorGordan I actually found something really cool called Assimp, which effectively parses all the data from most 3D model formats into a specific structure with all the data in it you'd need for vertices, indices, etc. It's got a C interface, so I'm gonna try implementing it first thing tomorrow.

    • @VictorGordan
      @VictorGordan  2 роки тому

      Yeah, did I not mention assimp in the video? I chose not to use it for reasons I explained in the video as far as I remember

    • @RosieSapphireMusic
      @RosieSapphireMusic 2 роки тому

      @@VictorGordan I don't remember you talking about Assimp in the video. Maybe you just wanted the project to be as dependency-light as possible?

    • @VictorGordan
      @VictorGordan  2 роки тому

      Yeah, and I think that there being a shit ton of data formats for meshes is really annoying and I hope that glTF will be the future of mesh data formats

  • @yourcommander3412
    @yourcommander3412 2 роки тому

    So this dont work for me at all - to the extent that I removed my project and just copied the source.
    I get this
    Cannot open include file: 'std_image.h': No such file or directory OpenGLGame C:\Programming\OpenGLGame\OpenGLGame\stb.cpp
    I dont know why stb has stopped working :/

    • @VictorGordan
      @VictorGordan  2 роки тому

      Maybe change "std_image.h" to "stb_image.h"? Otherwise the path is likely incorrect or you didn't properly link the stb library 🤷‍♂️

    • @yourcommander3412
      @yourcommander3412 2 роки тому

      @@VictorGordan Your right - however I think Im going look into assimp instead.

  • @akriminsoe5527
    @akriminsoe5527 3 роки тому +8

    Pls upload model loading tutorial with using assimp header files because assimp is better than JSON. how to edit loaded model in our program.

  • @maxencedupont5523
    @maxencedupont5523 2 роки тому

    Hi ! Great video as always !
    I tried to export a textured cube made with Blender in the correct format (separated GLTF) but it seems only the shape is rendered, and not the texture : I get a black cube as a result... any hint ?

    • @VictorGordan
      @VictorGordan  2 роки тому

      Make sure the texture is named "diffuse" since that's required due to the way I made the model importer

    • @maxencedupont5523
      @maxencedupont5523 2 роки тому

      @@VictorGordan I tried, but it still doesn't work (also the texture in the sword model doesn't have "diffuse" in its name) :( Maybe I should use another editor ?

    • @VictorGordan
      @VictorGordan  2 роки тому

      The editor shouldn't be the problem 🤔

    • @maxencedupont5523
      @maxencedupont5523 2 роки тому

      @@VictorGordan I see.
      I see. May i know where the 3D models in the resources come from? I want to reproduce the exact same config

    • @VictorGordan
      @VictorGordan  2 роки тому

      From sketchfab. Though I had to modify them slightly I think. As in changing the name of the texture in itself and also inside the .gltf file

  • @nubdevice4412
    @nubdevice4412 2 роки тому

    Works in debug mode but not in release mode.

    • @VictorGordan
      @VictorGordan  2 роки тому +1

      Yeah, I've gotten that comment before. Most likely it's my fault... but I wouldn't use this importer for any sort of release project haha

    • @rishikeshjaiswal3979
      @rishikeshjaiswal3979 11 місяців тому

      what does debug and release mode mean?@@VictorGordan

  • @lukasjetu9776
    @lukasjetu9776 9 місяців тому

    i'm not getting any erorrs, but it just doesn't work, the model isn't showing up, trust me, i copied almost every file now from your github, because it didn't work but still, it doesn't work, i'll try tomorrow, let's not ruin this day

    • @lukasjetu9776
      @lukasjetu9776 9 місяців тому

      ok, my computer has problems... it gets bluescreens and stuff, but my guess is that the problem doesn't lie in my code, it maybe lies in the model itself

    • @lukasjetu9776
      @lukasjetu9776 9 місяців тому

      E=YESS, i just copied the fragment source and it finally worked!

  • @lanchanoinguyen2914
    @lanchanoinguyen2914 2 роки тому

    Lol that looks so complicated.I mean why did they have to make the code that confuse and complicated.

  • @post_rot
    @post_rot 2 роки тому

    gltf is fucking terrible, i tried importing alot of gltf models but they just dont work so i made my own obj and ply parsers instead of this disfunctional format which was 20 times easier and 100% more working

    • @VictorGordan
      @VictorGordan  2 роки тому

      To be fair, it's not gltf's fault. It's mine. This is not a good importer 😅

  • @КошкинКошкин
    @КошкинКошкин 9 місяців тому

    Doesn't work in VS 2022

  • @iveyvines3977
    @iveyvines3977 8 місяців тому

    Could you actually go faster?