0
\$\begingroup\$

I'm developing a video game using OpenGL as graphic API and C++ programming language, and I'm creating all models with blender.

One question I have is how you deal with models (vertices), I mean, once you have created a model and want to load them with OpenGL you use hard-coded or a software module to load them on runtime?.

\$\endgroup\$
  • \$\begingroup\$ They're loaded at runtime, not hard coded in the application. There is a part (a 'module') of the software that interprets the content of the model data file and make an intelligible internal version of the model. Since games generally have specific needs, the model data is often custom designed for the application. As for the protection, you either make it harder for 'hackers' to 'decrypt' your model files, or you just don't care cuz it's going to happen anyways. \$\endgroup\$ – Alexandre Vaillancourt Jun 22 '15 at 17:20
  • 3
    \$\begingroup\$ Oh, and one last thing; we're not rude here :) However, we don't hesitate to flag/close questions that do not fit well in the site, so when this question will be put on hold, don't take it personal, we aim for questions that fit well within the rules. If you have other specific questions, please ask again! \$\endgroup\$ – Alexandre Vaillancourt Jun 22 '15 at 17:22
  • 2
    \$\begingroup\$ It sounds like there are multiple questions here. Could we split them? \$\endgroup\$ – Anko Jun 22 '15 at 22:15
  • \$\begingroup\$ Further help on how the site works: try to keep it to one question per post, like Anko suggested, because it improves clarity and search-ability (aka signal to noise). Because protecting your game data from theft is a broad topic completely separate from loading models, and it didn't match your title, I removed that part of your question. You are able to revise or reverse my edit if you disagree with it, and you are certainly allowed to post it as its own question. \$\endgroup\$ – Seth Battin Jun 28 '15 at 18:19
  • \$\begingroup\$ check out ASIMP - one of the best easy to use model modelers \$\endgroup\$ – DanielCollier Nov 30 '16 at 15:19
3
\$\begingroup\$

Loading:

To expand on what Sandalfoot said:

You must create you models in an external application, (Blender is popular and free, 3DSMax is free for non-commercial use) and then export them in a suitable format. There are many different model formats which target different things. Here are some:

  • The Wavefront .OBJ format is very simple and easy to load, it is just a text based list of Vertices and Faces, with optional normals, UV textures and basic materials. The OBJ format is only used for static, non-animated models.
  • The 3DS file format is binary format. This means that it is smaller and faster to load, but less intuitive. It is limited to storing 65536 Vertices. 3DS files can also be animated, but this is not as common.
  • The DAE (COLLADA) file format is an XML based format. It is a free and open standard and can be animated. A bit complicated compared to .OBJ and .3DS but widely supported in many 3D packages.

If you are planning on writing your own importer for your program, then you should start with the .OBJ format. There are dozens of tutorials about loading .OBJ files with OpenGL and C++.

Alternatively, you can use a model loading library to load almost any model for you. ASSImp is a good one that supports .OBJ, .3DS, .DAE, and many more. This is the recommended path! Maintaining model loads in probably not your idea of fun, so you should use an external one.

Protecting:

And as to encryption and model protection? If you're really into encrypting you models (this is called DRM) or hardcoding them (just... bad), it won't still won't work. Each model must be uploaded to the graphics card, unencrypted. The unencrypted models can be intercepted with a fake OpenGL library, or some other method my pure and unsullied mind cannot comprehend. :) It is impossible for you to secure your models so there are three (typical) ways of dealing with this:

  • Copyright them and have a good lawyer on the payroll. Sue people who steal your models. This is what big game studios generally do.
  • Copyright them and hope they are not stolen. If they are stolen, send a letter and/or a lawyer. This is what some indie game devs and small studios do.
  • Put your models under one of the CC licenses (or another similar license) and let people use your models but require attribution and other terms. You get free publicity whenever someone uses your models! This is what I would do, and what many open source projects end up doing.
\$\endgroup\$
2
\$\begingroup\$

It depends. Generally speaking, yes; you will create your models in an external program (Blender, 3DSMax, etc.) and export them into a format that your game can read. Unless you feel like writing a parser for an existing format from scratch, though, chances are you will be able to find a library to load any kind of model format your software can export.

That's not to say you can't write your own format and then create plugins/libraries for your tools and code that reads and writes it (which I've done in the past), but unless you have a really good reason for doing it, don't waste your effort.

As to how to keep your assets "safe" from being exported by someone? You can't, so don't even try.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.