Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

3D dress-up game?

124»

Comments

  • Just updated the gist, it's better now:

    • uses the suuuuuuuuuuper simple color picker I just shared in the forum
    • doesn't draw touches to the 2D plane, only to the 3D model
    • doesn't draw the buffer cameo in the corner

    It's now much more fun to play with, since it's free of all that for-debugging-only clutter, and since you can actually control the color you draw.

    It's also got a side effect that is fun: all touches on the 3D model get drawn to it, even touches that started on the color picker. So if you put your finger on the color picker and then slide it over to the model and swirl it around, the line changes color as you draw with it! Fun.

  • @yojimbo2000: it seems like there should be some easy math that can make the stroke width on the mesh look the same as the current strokeWidth setting, but I can't figure it out.

    Something like the ratio of the screen to the texture and then the ratio of the stroke to the screen size? But then some addition for the distance of the mesh from the camera?

    If the math for that comes easily to you, could you share it with me?

  • IgnatzIgnatz Mod
    edited September 2015 Posts: 5,396

    @UberGoober - This should help

    https://coolcodea.wordpress.com/2014/12/30/189-locating-the-2d-position-of-a-3d-point/

    Look at the section "What are the matrices for?", and especially the explanation of m[16].

    Let me know if it's unclear.

  • edited September 2015 Posts: 557

    @Ignatz, that is the clearest explanation of modelMatrix vs. projectionMatrix vs. viewMatrix I've read. SO helpful. I'm still working through the math for sizing, but I wanted to mention that.

  • @Yojimbo2000, did you ever get your super-fast object loader into shareable shape?

  • I seem to be really close to a 0.1 version of this, having created projects that do the core functions:

    • I can load a female figure, with clothes on, and use an alpha channel to modify the lengths of the sleeves/dress/whatever
    • I can draw directly to a 3D object with my finger

    I now just need to put them together, and I'll have a clothed female figure whose outfit can be modified extensively by hand. Cool!

    The big bottleneck is how long it takes the female figure to load. It's surprisingly quick, to me, but way too slow for coding with. I need something I can run and modify several times a minute.

    So I'm doing two things: looking online for simpler female models (with clothes!) and trying to figure out what you guys were talking about when you were discussing how to make loading .obj files go much, much faster.

  • IgnatzIgnatz Mod
    Posts: 5,396

    For testing purposes, I would store the obj data in a way that can be loaded most quickly, and the obvious way is in its final form of tables of vertices and texture coords. You still have to serialise the tables into strings, but I think we discussed this earlier.

    Then when you're done programming, you can go back to loading from obj.

  • edited September 2015 Posts: 2,020

    @UberGoober I did experiment with storing 3D obj data in an intermediary format (like @Ignatz is saying, comma separated values of the final tables), and there was a slight speed increase (about a third?) but not enough to justify the extra steps and code complexity (plus larger data size). I think that the main thing slowing it down is calculating the average normals (of course, you could also store the normals in the intermediary format. But then the data size would be +60%).

    I ended up going back to reading obj files. As @Ignatz and I discussed earlier in this thread, I think you could perhaps make a saving by incorporating the average normal calculation into the vertex winding section of the .obj decoder (you would at least save one iteration through all of the vertices). @Ignatz pointed out that it was probably just all of the cross calculations that was taking time. So I never bothered testing this.

    I think the thing that I said was much faster was the workflow. Because I'm working with 3D animations, interpolating between keyframes, I have lots of .obj files. I rewrote the .obj importer so that it would accept multiple files from the Dropbox/Apps/Codea/ folder, so that you can export from Blender straight into the Dropbox, and then just run the Codea importer, with no intermediary steps of editing the obj files, combining them into one etc.

    Loading from the local dropbox is faster than http.requests (but did you implement loading from the local dropbox anyway?)

    Because you're not doing asynchronous loading via http.requests, the obj loader becomes much simpler. It's just a few hundred lines, and its really just a single function, plus a few helper functions (it doesn't have to be a class any more, which you need really for asynchronous file loading). The idea is, I can make some edits to a model in Blender, hit export, in Codea I have to sync the Dropbox, but then I can just run the project and the new model is there. That all makes a big difference.

    The other thing I only recently discovered in Blender, is that the .obj exporter allows you to save sets of export settings, which really helps smooth things over (especially if you return to work on a project after some time away from it).

    I'll see if I can make this presentable enough to share (the idea was eventually to write a 5th part to my blog series on animating 3D models, but other things like Soda got in the way).

    I'm not sure how useful my code would be for you. The animation-related parts presumably aren't relevant to your project. Because the models I work with just have one texture per model, I took out the whole mechanism that @Ignatz has for splitting the .obj file up into multiple models and multiple textures. So depending on how your model and the clothes are organised you'd have to export each texture as a separate model (this isn't hard: choose the texture, press select in the texture window to select everything that has that texture, in the export window select "export selection only"). But this might not be worth the hassle if you've got your code working with @Ignatz 's loader.

    How slow are the startup times anyway? I have the loader in a coroutine so I can animate a progress bar.

  • edited September 2015 Posts: 557

    @Ignatz, that's a great idea. Hard-code the model. I'll do that and see how it affects speed.

    @Yojimbo2000, yes I'm reading from the local folder, not making http requests. Speeding up the workflow by not having to edit the files sounds really good to me though! Could you share that part of your code? As to your other questions: the model is its own mesh and the clothes and hair are their own meshes; loading takes long enough that I stop counting how long it takes! :) ...which is between 45-60 seconds.

  • Posts: 2,020

    Wow, that's really really long. I was getting impatient after 6 seconds. This is the third time I've asked this :P , but how many verts are all the meshes?

  • IgnatzIgnatz Mod
    Posts: 5,396

    That's very long, none of my models take more than 5 seconds

  • Posts: 2,020

    If you're interested in a benchmark, this is what I wrote on page 2 of this thread. 130,368 vertices worth of models were processed in 6 seconds on an Air:

    Pros of using an intermediary format:

    • load times are around a third faster (4 seconds instead of 6 on an iPad Air for 130,368 vertices worth of models). Not as big a gain as I'd hoped for, because both methods still need the average normals to be calculated. And if average normal calculation can be done at the .obj processing stage, then .obj might have an advantage over the intermediary format.

    • for animation via keyframe interpolation, I pack the vertices from several .obj files into one file (I put colours and texCoords into a separate file, as these don't change from frame to frame). Not sure if this is a pro, but keeps your Dropbox folder tidy.

    • by saving it as a text asset, it automatically gets included in your project when you export. Although, you can achieve a similar effect by changing the extension of the obj file in Dropbox from .obj to .txt (you can do this in the Codea obj loading program using os.rename), and then loading the file with readText instead of io.read. So again, perhaps not such a unique pro.

    Cons

    • 3D asset sizes can be almost twice as big (1404 kb vs 2639 kb for 130,368 verts worth of models). This is using @Ignatz 's minimal comma-separated value format too.

    • it does involve an extra step of importing

  • IgnatzIgnatz Mod
    Posts: 5,396

    A size of a couple of megs isn't so bad these days, I would think. Does it matter?

  • @Yojimbo2000--sorry I keep meaning to try to count it, but the file is too big on Codea and TextWrangler is not on my main computer... I'll try to look it up soon though...

  • IgnatzIgnatz Mod
    edited September 2015 Posts: 5,396

    once it's loaded in Codea, you can use numVerts=m.size (where m is the mesh) to count the vertices

  • edited September 2015 Posts: 2,020

    Yes, use mesh.size or #verts or whatever the name of the table is you assign to vertices. The .obj file will tell you the number of unique points and the number of faces (you could multiply the number of faces by 3 if you exported with a triangulate modifier...), but the relevant number here is the number of vertices once all the faces have been wound, so it's easiest to find this out in Codea, not from looking at the obj file. I usually print the number as I load each model, as it's a useful thing to keep in mind when profiling.

  • Posts: 3

    Greetings guys I find the models they present fascinating, it would be interesting to appreciate more of this type of project, I would like to know about related works as to build a good repository
    personal. It's just that everything that has to do with 3D models for me is a universe to discover. Many times we want to find 3D models for any type of project, such as games, virtual reality, augmented reality, 3D visualization applications and 3D animations. This search engine](https://www.stlfinder.com/ "This search engine") could work to save a lot of time in locating the model that fits your needs and your project.

Sign In or Register to comment.