ENIGMA Forums

Sharing is caring => Graphics and Video => Topic started by: Solitudinal on September 01, 2017, 03:48:24 pm

Title: [WIP] Collada (.dae) 3d Animated Model Loader
Post by: Solitudinal on September 01, 2017, 03:48:24 pm
Before I start, just let me say that I didn't see any existing code in enigma for loading Collada models, so I started writing my own. I also didn't see any in-built xml readers (aside from the skeletal remains of RapidXML), so I used pugixml (https://pugixml.org/). If I missed something, please be nice :-)
I'm aware that ENIGMA is already capable of reading .obj models, which is awesome, but Collada has animation and such.

Collada is an industry standard format (ISO/PAS 17506 (https://www.iso.org/standard/59902.html)) for animated 3d models, utilizing skeletal joints for animation (it does some other things too, but this is what I'm using it for here). It stores data in XML.

This, then, is my ENIGMA/C++ reader for said format. It is a work in progress, so be patient and I'll continue to share my progress on it, and feel free to share feedback along the way (this is why I've shared it here). I'm developing this for a game idea that I'm poking at in ENIGMA.

I'm aware that other Collada readers exist, but they tend to be extremely bulky, easily reaching up into multiple MBs, so I figured something much smaller could be achieved and could easily be added to ENIGMA.


I'll provide steps for adding this to ENIGMA, but please ADD AT YOUR OWN RISK. Everything should be easily reversible by just undoing these changes (or if you're familiar with git, there's a git path).

First, pick up a copy of pugixml (not pugxml). Copy the .cpp and .hpp files into ENIGMAsystem/SHELL/Universal_System/ and rename the .hpp to .h
Edit both and add the following lines near the top:
Code: [Select]
#define PUGIXML_NO_EXCEPTIONS
#define PUGIXML_NO_STL

Next, edit ENIGMAsystem/SHELL/Graphics_Systems/General/GSmodel.h and add the following function def:
Code: [Select]
void d3d_collada_load(int id, std::string fname);
Finally, edit ENIGMAsystem/SHELL/Graphics_Systems/OpenGL1/GSmodel.cpp (only tested for OpenGL1, but shouldn't require much if any modification for other systems) and on line 41 add the following includes:
Code: [Select]
#include <sstream> //used to split strings
#include <algorithm> //needed for find(), used kinda like indexof
#include "Universal_System/pugixml.h"
And on line 107 or thereabouts (I chose between d3d_model_save and d3d_model_load) add the following code:
Code: [Select]
//temporarily stores the vertex data with texture/normal ids to construct unique VNTs
class Vertex {
public:
  unsigned int index;
  float x, y, z;
  int texId = -1;
  int normId = -1;
  Vertex *next = NULL;

  Vertex(int id, float x, float y, float z) :
      index(id), x(x), y(y), z(z) {}
};

// I don't like enigma's split functions, so I made my own
template <class T>
std::vector<T> cppsplit(const pugi::char_t* slist) {
  std::stringstream ss(slist);
  std::vector<T> tlist;
  T token;
  while (ss >> token)
    tlist.push_back(token);
  return tlist;
}

//This workhorse reads a collada xml file (.dae) into an enigma model "mesh"
void d3d_collada_load(int id, string fname)
{
    pugi::xml_document doc;
    doc.load_file(fname.c_str());
    pugi::xml_node rootNode = doc.child("COLLADA");

    //////////////////
    //GeometryLoader//
    //////////////////
    pugi::xml_node meshData = rootNode.child("library_geometries").child("geometry").child("mesh");
    //readPositions
    const pugi::char_t* posId = meshData.child("vertices").child("input").attribute("source").value();
    pugi::xml_node posData = meshData.find_child_by_attribute("source","id",posId + 1).child("float_array");
    int posCount = posData.attribute("count").as_int();
    const pugi::char_t* sposList = posData.text().get();
    std::stringstream sspos(sposList);
    std::vector<Vertex*> vertices;
    for(int i = 0; i < posCount / 3; i++) {
        float x,y,z;
        sspos >> x >> y >> z;
        //correct Collada's z-up to y-up with (x,z,-y)
        vertices.push_back(new Vertex(i, x,y,z));
    }
    //readNormals
    pugi::xml_node poly = meshData.child("polylist");
    const pugi::char_t* normId = poly.find_child_by_attribute("input","semantic","NORMAL").attribute("source").value();
    pugi::xml_node normData = meshData.find_child_by_attribute("source","id",normId + 1).child("float_array");
    int normCount = normData.attribute("count").as_int();
    const pugi::char_t* snormList = normData.text().get();
    std::stringstream ssnorm(snormList);
    std::vector<std::array<float,3>> normList;
    for(int i = 0; i < normCount / 3; i++) {
        float x,y,z;
        ssnorm >> x >> y >> z;
        std::array<float,3> row = {x,y,z}; //correct Collada's z-up to y-up
        normList.push_back(row);
    }
    //readTextureCoords
    const pugi::char_t* texcId = poly.find_child_by_attribute("input","semantic","TEXCOORD").attribute("source").value();
    pugi::xml_node texcData = meshData.find_child_by_attribute("source","id",texcId + 1).child("float_array");
    int texcCount = texcData.attribute("count").as_int();
    const pugi::char_t* stexcList = texcData.text().get();
    std::stringstream sstexc(stexcList);
    std::vector<std::array<float,2>> texcList;
    for(int i = 0; i < texcCount / 2; i++) {
        float s,t;
        sstexc >> s >> t;
        std::array<float,2> row = {s, 1.0f - t}; //in OpenGL, texture's y coordinate "t" is inverted
        texcList.push_back(row);
    }
    //assembleVertices
    const pugi::char_t* indexData = poly.child("p").text().get();
    std::stringstream ssp(indexData);
    std::vector<unsigned int> indices;
    int idVert, idNorm, idTexc, idCol; //I'm assuming it's just these 4
    while (ssp >> idVert >> idNorm >> idTexc >> idCol) {
        //processVertex
        Vertex *v = vertices[idVert];
        if (v->texId == -1 || v->normId == -1) {
            v->texId = idTexc;
            v->normId = idNorm;
        } else if (v->texId != idTexc || v->normId != idNorm) {
            //modified dealWithAlreadyProcessedVertex
            Vertex *newv = v;
            while (newv != NULL) {
                if (newv->texId == idTexc && newv->normId == idNorm)
                    break;
                v = newv;
                newv = newv->next;
            }
            if (newv == NULL) {
                Vertex *nv = new Vertex(vertices.size(), v->x,v->y,v->z);
                nv->texId = idTexc;
                nv->normId = idNorm;
                vertices.push_back(nv); //this is why we can't just vector<tex,norm>
                newv = nv;
                v->next = newv;
                v = newv;
            }
        }
        indices.push_back(v->index);
    }

    // Close the xml file
//    delete doc;

    //"removeUnusedVertices", or in this case we just link them to first texture and normal
    for (Vertex *vertex : vertices) {
        //tangents aren't used, otherwise we'd average them
        if (vertex->normId == -1) vertex->normId = 0;
        if (vertex->texId == -1) vertex->texId = 0;
    }

    // Convert to ENIGMA model/mesh.
    meshes[id]->Begin(pr_trianglelist);
    for (const Vertex *ov : vertices) {
        meshes[id]->AddVertex(ov->x, ov->y, ov->z);
        meshes[id]->AddNormal(normList[ov->normId][0],normListov->normId][1],normList[ov->normId][2]);
        meshes[id]->AddTexture(texcList[ov->texId][0],texcList[ov->texId][1]);
        delete ov;
    }
    for (unsigned int i = 0; i < indices.size(); i++) {
        meshes[id]->AddIndex(indices[i]);
    }
    meshes[id]->End();
}

So the code will only read the base model right now. Animation will come eventually. It will then push the base model VNT (Vertex, Normal, Texture) and indices into an ENIGMA mesh. Code ported from this java example (https://github.com/TheThinMatrix/OpenGL-Animation) and AnimatedModelLoader.java (https://github.com/TheThinMatrix/OpenGL-Animation/blob/master/Animation/loaders/AnimatedModelLoader.java)
Also, if you need a model/texture to test with, it has one (https://github.com/TheThinMatrix/OpenGL-Animation/tree/master/Resources/res).


Here's an example of it used in a game, if you can get it to compile:
Create a background called tex_dude and load in the texture (diffuse.png in the java example)
Create event:
Code: [Select]
file = "C:/path/to/model.dae" //please point this to a valid collada .dae file
d3d_start();
d3d_set_perspective(true);
d3d_set_hidden(true);
d3d_set_lighting(false);
draw_set_color(c_white);
d3d_set_fog(true,c_white,1,1024);
d3d_set_culling(false)
d3d_set_shading(false);
texture_set_interpolation(true);

//here we load in the model and store it in the "mdl" variable
mdl = d3d_model_create(0); //0 means its static, for now
d3d_collada_load(mdl,file);

Draw event:
Code: [Select]
d3d_set_projection(0,-20,0, 0,0,0, 0,0,1); //feel free to tweak these numbers as needed to point the camera at your model
d3d_model_draw(mdl,0,0,0,background_get_texture(tex_dude));

Updates:
Sept 2 @ 1500est: included a few missing functions
Sept 2 @ 1600est: and a few missing structs
Sept 4 @ 2200est: replaced with instructions for inserting into ENIGMA and an example
Sept 5 @ 1900est: textures now apply correctly
Sept 16 @ 2300est: removed unused skeletal data and recursive function. Should now load a little faster and static models no longer have a dependency on having a skeleton.
Sept 29 @ 1800est: fixed memory leak
Oct 7 @ 1500est: removed unused joint weight data. Should now load a little faster and static models no longer have a dependency on having joint weights.
Title: Re: [WIP] Collada (.dae) 3d Animated Model Loader
Post by: hpg678 on September 02, 2017, 12:48:51 am
sounds interesting, could you do an example and post it please?
Title: Re: [WIP] Collada (.dae) 3d Animated Model Loader
Post by: Solitudinal on September 02, 2017, 01:01:39 pm
Like I said, I hacked it into ENIGMA, so it's not as simple as posting a .gmk file. In fact, for testing/developing it, I've actually got my own independent C++ program running on glew and glfw3. I may post that, but you'd need to set up glew and glfw (which is not fun).

UPDATE OP updated to include instructions, so the rest of this post is outdated.


As far as the ENIGMA route goes, typically I just wrap that code in a function and stick it in one of the files in enigma-dev\ENIGMAsystem\SHELL\Graphics_Systems\OpenGL1, call the function something like
int readCollada(std::string fname)
and have it return indices.size();
Then another function:
Code: [Select]
void drawCollada(int inds) {
glDrawElements(GL_TRIANGLES, inds, GL_UNSIGNED_INT, 0);
}

In a create event:
//General d3d setup code goes here.
vertNum = readCollada("C:/model.dae") //or wherever you put your model

In the draw event:
drawCollada(vertNum)
//don't forget to set up the camera/projection. For the model from the java example, I found the best camera position/orientation to be 0,5,15, 0,5,0, 0,1,0
Title: Re: [WIP] Collada (.dae) 3d Animated Model Loader
Post by: hpg678 on September 03, 2017, 03:43:14 am
ok.....I see. It still is a great achievement and I congratulate you on your efforts.

I have dabbled in loading .obj objects into a 3D Breakout project I was working on but for some reason it was rotated at a right angle. Whether it was due to the modeler i used or perhaps ENIGMA reads it that way. I didn't investigate any further, but am planning to at some later date.

Anyway,  Keep up the good work. :) (Y) (Y)
Title: Re: [WIP] Collada (.dae) 3d Animated Model Loader
Post by: Solitudinal on September 03, 2017, 12:05:02 pm
Yeah, that's what happens here too. As you see in the GeometryLoader->readPositions loop, I correct the Z-up from the modeller to Y-up. To do this, we can either multiply each vertex vector by a rotated correction matrix (as we kinda do here, I just simplified all the matrix math to y = -z and z = y) OR we can perform a rotational transform of the model after it is set up.
The correction matrix used in the java program is:
Code: [Select]
new Matrix4f().rotate((float) Math.toRadians(-90), new Vector3f(1, 0, 0))which I believe simplifies to:
Code: [Select]
{ 1,0,0,0,
  0,0,-1,0,
  0,1,0,0,
  0,0,0,1 }
which again simplifies to:
Code: [Select]
//x = x;
tmp = y;
y = -z;
z = tmp;
//w = w;

And then I set the camera up to be 0,5,15, 0,5,0, 0,1,0 (looking down the Z-axis with Y-up).

I'm currently struggling to get the texture applied. Here's the code I use, which is pretty standard:
Code: [Select]
GLuint textureID;
glGenTextures(1, &textureID);

// "Bind" the newly created texture : all future texture functions will modify this texture
glBindTexture(GL_TEXTURE_2D, textureID);

// Give the image to OpenGL
glTexImage2D(GL_TEXTURE_2D, 0,GL_RGBA, width, height, 0, GL_BGR, GL_UNSIGNED_BYTE, &img[0]);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
but it doesn't apply

I'm also poking at porting this to Enigma's "mesh" used by other models.
Title: Re: [WIP] Collada (.dae) 3d Animated Model Loader
Post by: Solitudinal on September 05, 2017, 06:03:38 pm
I've updated the first post. You'll find that it's now uses ENIGMA's built in mesh/modelling system, and is able to utilize textures. I've also made it a lot easier to stick into ENIGMA with instructions.
(I also found out the texture was applying incorrectly because OpenGL inverts the y coordinates "t" of the texture, so once I accounted for that in the code with 1.0f - t, it worked amazing)

Next I'll be working on animation. This may take a while, but in the meantime, enjoy the ability to read in static collada models!

And if anybody who works on ENIGMA wants to either make this official or figure out how to make this an Extension, that'd be awesome.
Title: Re: [WIP] Collada (.dae) 3d Animated Model Loader
Post by: time-killer-games on September 05, 2017, 11:04:50 pm
This looks great! :D Is it platform-specific functionality or is it portable?
Title: Re: [WIP] Collada (.dae) 3d Animated Model Loader
Post by: Solitudinal on September 06, 2017, 02:39:28 pm
To answer that, let's break it down into 4 parts:
1: Pugixml
Pugixml is its own thing, so you'd have to consult with their website or such for more information, but since all you have to include is just two source files (.cpp and .h) and don't need a dll or anything, it should be relatively platform independent, aside from Windows Line Endings1
2: Interpreting the XML nodes
As far as I can tell, all of my code is standard C++ stuff, nothing fancy or platform dependant. I don't make any direct GL calls, window calls, or filesystem calls, or anything of the sort. Just be platform aware with the path/filename that you pass in.
3: Transferring that data into an ENIGMA mesh
This is just transferring memory to memory, and only depends on ENIGMA's Mesh struct, which appears to have an equivalent in DirectX9, OpenGL1, and so on
4: ENIGMA's GL calls
Again, this is up to ENIGMA. I don't make any GL calls myself, I just offload the Mesh to ENIGMA, and leave it up to the selected GL to make the appropriate calls. I'm on Windows, and ENIGMA is defaulting to OpenGL1, and it works fine.

1 Windows Line Endings don't even seem to play any part in this. I opened up a collada file in notepad and saw no rhyme or reason to line endings - I kinda don't think it uses any. My code also doesn't do anything that would necessarily care about line endings. The only strings I deal with are node names - which should be short identifiers - and space-separated number lists which I simply split on any whitespace.


tl;dr: It's as portable as ENIGMA's GL and Pugixml are. So yes, it should be quite portable. Just copy the code to each GL you intend to use it on.
Title: Re: [WIP] Collada (.dae) 3d Animated Model Loader
Post by: Goombert on September 08, 2017, 05:26:53 am
Hey, this is really awesome, keep up the good work!
Title: Re: [WIP] Collada (.dae) 3d Animated Model Loader
Post by: Solitudinal on September 12, 2017, 05:21:15 pm
Just wanted to give a quick little update.
The way that the java project that I'm porting this from does the animation is by using shaders, so I've taken a bit of time to learn about GLSL and have a pretty good grasp on it now, and also understand why it does this.
I believe shaders are GL2+ (mainly GL3), meaning that if I were to do a direct port, I'd probably have to drop OpenGL1 and target OpenGL3 in ENIGMA? Since everything is shaders these days, this seems like the way to go.
There's 3 alternatives I can think of:
0) The aforementioned shaders path.
1) Generate vertex models for every animation frame. This would use a huge amount of memory.
2) Handle all the vertex calculations through the CPU. This would require porting the shader's responsibilities into C++ code. Not sure how much ENIGMA's engine can support me along this way, but if I end up writing my own GL calls, GL3.1+ isn't going to like it unless you stick it in compat mode.

So yeah. For the time being, I'm forging ahead and porting option 0.
Title: Re: [WIP] Collada (.dae) 3d Animated Model Loader
Post by: Goombert on September 14, 2017, 02:15:08 pm
No you can use shaders in OpenGL1, just not all kinds of shaders and not all shader functions. Well technically you can use them and they won't fail on your computer because I don't think we are setting the context to actually use a specific core, but it will just fail if you release the game and somebody else's computer only supports OpenGL1. You probably don't need to worry about that though because Windows XP is almost dead (hard to kill, but it's almost there). SFML or SDL or something (I forget) is only OpenGL2 but it still has vertex and fragment shaders too.

https://www.khronos.org/opengl/wiki/Core_Language_(GLSL)#OpenGL_and_GLSL_versions
Title: Re: [WIP] Collada (.dae) 3d Animated Model Loader
Post by: Solitudinal on September 14, 2017, 04:11:19 pm
Yeah, for the purpose of the game I'm making, I don't care about dropping GL1 and older computer support. But for the purpose of making the code accessible to other ENIGMA users, I'm trying to be mindful of it. I'm assuming shader words like "in/out/texture" are ok to use in place of "attribute/varying/texture2d", too?
Title: Re: [WIP] Collada (.dae) 3d Animated Model Loader
Post by: Goombert on September 15, 2017, 12:34:49 pm
Yes, but I think you have it backwards, this post over on the OpenGL forums suggests that in and out actually replace varying, meaning varying is the one that's deprecated:
https://www.opengl.org/discussion_boards/showthread.php/174424-varying-in-out

The Wiki also says varying is removed:
https://www.khronos.org/opengl/wiki/Type_Qualifier_(GLSL)#Removed_qualifiers

Forgive me, it's been a while since I've worked with GLSL, been doing a lot of UI and higher-level things lately.
Title: Re: [WIP] Collada (.dae) 3d Animated Model Loader
Post by: Solitudinal on September 15, 2017, 02:23:05 pm
Nope, that's what I said, and that's why I said it :)

Great, I'll do that then. Had to check cuz it's a little hard to find info on GL1 and GLSL. I just find a bunch of stuff for GL3+ and lots of deprecated functions without replacements (frustum? I 'ardly knew 'em). (and before you say anything, yes, I know you're responsible for your own matrices now. Just find it amusing that GL decided to nix all the useful functions)
Title: Re: [WIP] Collada (.dae) 3d Animated Model Loader
Post by: Solitudinal on September 16, 2017, 02:29:58 pm
According to this:
https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/texture.xhtml
texture() was not introduced until GLSL 130, so I guess I'll have to stick with the deprecated texture2d for OpenGL1, but that's easy enough to swap out for OpenGL3/etc.

In my test program I've switched over to shaders without too much trouble. Also decided to use GLM, since handling my own matrices was becoming too much of a burden (much as I enjoyed doing matrix math, I could never get GL to render right). Hopefully this shouldn't be too hard to port back to ENIGMA.

Come to think of it, are there any examples using ENIGMA's shaders, especially in a 3d environment? I'm wondering how the MVP (Model-View-Projection) is handled.
Title: Re: [WIP] Collada (.dae) 3d Animated Model Loader
Post by: Goombert on September 16, 2017, 04:26:04 pm
Yes, the multi-textured terrain I started:
http://enigma-dev.org/forums/index.php?topic=1495.0

Look at TheExDeus's though, his is probably more correct than mine. What I am working on will be related to improving the shaders approach in ENIGMA, so I must focus on that.
Title: Re: [WIP] Collada (.dae) 3d Animated Model Loader
Post by: Solitudinal on October 02, 2017, 12:25:32 am
Another update (attn Goombert?):
It's been a while, so I figured I'd check in so you guys know that I'm still hard at work on this.

Static code status:
In case you've missed it, I've made a few changes to the static model code, making it quite a bit leaner.

Animation status:
After endless debugging, I've finished porting the animation code over to C++, and it finally works fantastic. I did break down and start using GLM, and I have a pretty heavy dependency on it right now, because it just made the matrix math that I need so much easier. The end result is about 850 lines of code or 25kb (source, not compiled), plus the shader (50 lines), plus pugixml (375kb source), plus GLM (ehhh...), plus another 200 lines for spinning up my own main/glfw window/glew calls/camera (stuff which ENIGMA normally handles, so that wouldn't be ported over).
I did write GLSL1 shaders for it, and it works great, so that's excellent. Now I'm half waiting on Goombert to share the code for his multi-textured terrain example (the dropbox link is 404) and/or whatever he's secretly doing with shaders -- and half figuring it out myself (which would probably include hacking it a bit myself)

Next:
Porting my code to ENIGMA. This involves figuring out how ENIGMA handles shaders and maybe forcing it to handle how *I* want to use shaders (or hopefully not). Then I'd probably have to replace all my dependencies on GLM with enigma's matrix math, because GLM is massive (2mb) and I don't think ENIGMA wants to add that library just to make model animation a little easier.


Here's a few good notes for users at the current time:
* Multiple models are supported, of course. One model (animated, static, or both) per file. Just construct a new collada model for each one, and point it to the file.
* Static and Animated models will both be supported, with a simple boolean switch in the constructor to determine how to read it in (so exclusively static models don't have to have animation data), and animated models can be read in as animated and still render their static/base model version by simply using a shader that ignores the animation data (in theory, the Fixed Function Pipeline (FFP) should suffice).
* Relatively simple API lets you construct a model with one call, get how long the animation is, set the animation frame (increment each step to animate), and render. There may be a couple other calls to set up the shader, and don't forget to set up the texture, too.
* A single model can be rendered as many times as you'd like in as many different frames (or same frames) as you'd like. In my test code, I've got two guys running and two guys standing, going around in a circle like a merry-go-round.
* No error checking at this time keeps things fast. If anything is missing, it will be omitted, which could easily cascade down to your model not rendering, but the rest of your game should still be playable.
* In order to keep the code small, we make a few assumptions about how the model is constructed and behaves, so a lot of the fancy Collada features will not be present, like materials, special interpolation methods, Collada lights (you have to program your own lights in ENIGMA, you know that), and so on. Refer to the java example model for what features you can use, or feel free to hack in anything I missed.


Hopefully next time you hear from me (may take a while again), I'll have some animation code that you can stick in ENIGMA and use!
If anybody wants to see my current independent (working) code, let me know and I'll consider sharing it, but again keep in mind that it has dependencies on GLFW, GLEW, and GLM, which took me a while to figure out how to set up.
Also, if anybody wants to help, either in this or in the game that I'm working on (no, it's not a 3d MMORPG), that'd be super awesome. Let me know and we can figure out what parts you can work on and/or what parts need done. But I'm assuming most of you guys are probably busy working on your own things right now, so that's fine, I'll just keep chugging away at this :)
Title: Re: [WIP] Collada (.dae) 3d Animated Model Loader
Post by: Solitudinal on October 07, 2017, 01:57:43 pm
Just another quick update.

GLM:
I've successfully ditched GLM and replaced it with enigma::Matrix4 and such for the Collada. That actually went smoother than expected, so... thanks?

GL1 / GL3 / shaders:
It's come to my attention that generating my VAO/VBOs currently uses calls to glVertexAttribPointer (generic attributes), which requires GL2.0+. In GL1.1, we used to use fixed attributes glVertexPointer/glNormalPointer/glTexCoordPointer/glColorPointer. I use generic attributes to communicate each vertex's meshed Joints (and its Weights) to the shader. This takes me back to the decision point I was making before, where I either store/render animations CPU-side (as we used to do in GL1.1), or ditch GL1.1 and render them in the shader via calls to glVertexAttribPointer.
Unless someone can suggest some way to salvage GL1.1 support, I'm forced to ditch OpenGL1 and port my code into OpenGL3.

Non-animated code (OP):
The code I shared in the first post, for the base (non-animated) model is fully compatible with GL1.1 (OpenGL1), as it does not depend on VBOs or generic attributes. Feel free to continue using it, and I will continue to support it, but due to the above note, I have no intention of ever adding animation to it. If you want animation, you'll want to switch to OpenGL3. If you're just using it for static models, you can stick to OpenGL1.


Edit: Looking at enigma's GL3 code, you guys didn't make it easy on me. Enigma's Meshes don't support generic attributes either, so I'll probably just bypass Mesh.
Title: Re: [WIP] Collada (.dae) 3d Animated Model Loader
Post by: Goombert on October 08, 2017, 12:23:45 am
Sorry for not getting back to you quicker on this. I just have so much going on, but the past week we've spent working really hard to get continuous integration working:
https://github.com/enigma-dev/enigma-dev#enigma--

This is going to be so much better for ENIGMA because it tests all graphics systems (OpenGL & Direct3D) and Windows and Linux as well as all extensions and such in a huge build matrix. Every pull request must pass the CI tests now before they get merged. Anyway, this should mean the graphics systems will break less in the future. It's already done, no more work to do on that, the CI services are running right now.

I and the others who worked on the GL3 system are also aware of the limitations you've mentioned. I was hoping to redo all of this soon and delete a ton of duplicate code from the graphics systems with these new improvements. Bypassing the model struct for now should be absolutely fine but hopefully I can get the vertex buffers actually done in all of the systems soon and remake the model class on top of that.
Title: Re: [WIP] Collada (.dae) 3d Animated Model Loader
Post by: Solitudinal on October 08, 2017, 04:10:14 pm
Awesome, thanks Goombert. Any luck digging up a copy of that multitextured terrain example?

I'll keep an eye open for changes to the graphics system and try to keep my code current with them, but if you could poke this topic (or the forums in general) when you do revisit and update the model/mesh class, that'd really help me know to re-integrate my code with it.

In the meantime, I'll keep chugging away.
Title: Re: [WIP] Collada (.dae) 3d Animated Model Loader
Post by: hpg678 on October 09, 2017, 01:25:11 am
 (Y) (Y)

Keep up the good work guys!
Title: Re: [WIP] Collada (.dae) 3d Animated Model Loader
Post by: time-killer-games on October 11, 2017, 02:07:42 am
I think we should let's get naked.
Title: Re: [WIP] Collada (.dae) 3d Animated Model Loader
Post by: Josh @ Dreamland on October 22, 2017, 03:02:40 pm
If I had time to explore the 3D modeling space in ENIGMA, I would focus on adding support for AssImp (https://www.khronos.org/collada/wiki/Open_Asset_Import_Library) in general. I think Collada is a big step in that direction, though, so this is an awesome change. Have you considered putting this code in a pull request? Movement in the 3D space here remains slow.
Title: Re: [WIP] Collada (.dae) 3d Animated Model Loader
Post by: Solitudinal on October 23, 2017, 12:22:17 am
I'd looked at AssImp, but the library is massive, so I passed it by. The zip is 30+ MB. I don't know how that would pan out with the rest of ENIGMA.
As far as a pull request goes, I don't actually have a github account, but once the code gets large enough (and stable enough) to warrant it, I'll consider it.
Slow dev or otherwise, I'm happy; with just a little tweaking and some customer support, you have the features I need for my game programming needs.
Title: Re: [WIP] Collada (.dae) 3d Animated Model Loader
Post by: time-killer-games on December 09, 2017, 10:28:29 pm
@Solitudinal if you were worried about executable file size, you could've made it an ENIGMA extension, that way, if the user needs it and doesn't mind the file size increase, they can tick the checkbox, otherwise, they can leave the feature out of their builds completely.
Title: Re: [WIP] Collada (.dae) 3d Animated Model Loader
Post by: hpg678 on December 09, 2017, 11:32:29 pm
@Solitudinal if you were worried about executable file size, you could've made it an ENIGMA extension, that way, if the user needs it and doesn't mind the file size increase, they can tick the checkbox, otherwise, they can leave the feature out of their builds completely.

I quite agree. I tried to use it following his instructions and somewhere along the way broke my ENIGMA. ALL my fault! So I never actually got to see it in action. I so wanted to try in out in my game. Oh well, I have to use sprites instead.
Title: Re: [WIP] Collada (.dae) 3d Animated Model Loader
Post by: Solitudinal on December 10, 2017, 02:38:45 pm
@Solitudinal if you were worried about executable file size, you could've made it an ENIGMA extension, that way, if the user needs it and doesn't mind the file size increase, they can tick the checkbox, otherwise, they can leave the feature out of their builds completely.
Yes, that's what I want to do. I just couldn't figure out how to do it. I created an extension folder almost identical to some of the other ones and ENIGMA wasn't automatically picking it up. Was hoping someone more familiar with it would take my code and do it/show me how to do it - probably once my code is closer to completion.

w.r.t. AssImp, though, I was more worried about ENIGMA's size, not the resulting executable size. AssImp alone is almost as big as ENIGMA, meaning if it were shipped with ENIGMA, it would just about double ENIGMA's size for a feature that's not even going to be checked on in 10% of ENIGMA games.


I quite agree. I tried to use it following his instructions and somewhere along the way broke my ENIGMA. ALL my fault! So I never actually got to see it in action. I so wanted to try in out in my game. Oh well, I have to use sprites instead.
If you want it so bad, feel free to try again. Try and look at the code where you're inserting it to make sure that it makes sense - line numbers change. Obviously you don't want to stick it in the middle of a function. If I had more time, I'd make a patch, but I'm kinda busy developing the code so I don't have time to maintain a patch.