1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

3D Model Viewer

Discussion in 'Site Discussion' started by GhostWolf, Mar 24, 2014.

  1. GhostWolf

    GhostWolf

    Joined:
    Jul 29, 2007
    Messages:
    4,836
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    Latest version is
    4.0.21
    .

    Added support to reading and writing most of the internal map files, technically allowing any kind of editing, but so far without any easy to use API, just raw data.
    Just as an example of how it can be used, I created a function that applies a heigtmap image to a map's terrain, which someone asked for.

    Fixed many issues with MDX rendering, some of which were introduced in version 4 due to the whole overhaul of the rendering code.
    Most models should look a lot more correct now, especially more complex ones.

    Attached two comparison images from the unit tests, although they don't quite capture the changes.
     

    Attached Files:

  2. pyf

    pyf

    Joined:
    Mar 21, 2016
    Messages:
    2,381
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    @Dr Super Good & @GhostWolf : about your 'Power of 2' discussion:

    Warcraft 3 was officially designed to run on a 8 MB 3D video card (TNT, i810, Voodoo 3, Rage 128 equivalent or better) with DirectX8.1 support. I suspect that at least one of these video cards does not support power of two textures.


    Quoting a small part of this post from Gamedev.net:

    " [...] My problem is that I face severe graphics card limitations. I have a voodoo 3 2000, it supports a maximum texture size of 256x256 (OUCH!!), 3 multitexture layers, no pixel shaders, no vertex shaders, only power of two textures, 16 megs video RAM limit. [...]"


    Voodoo3 - Architecture and performance - Wikipedia
    (please also see their API compliance)
     
    Last edited: Dec 5, 2017
  3. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,592
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Except WC3 does not enforce the limit... Both TGA and BLP files can be loaded as non power of 2 textures. Further more TGA files are not even subject to a maximum texture size limit like BLP files are (one can easily load a 1920*1080 sized TGA as a texture in WC3). Although it might have been the case that such textures were highly bug prone in the past, that is certainly not the case anymore as all modern supported GPUs support larger than 512*512 textures and non power of 2 textures.
     
  4. pyf

    pyf

    Joined:
    Mar 21, 2016
    Messages:
    2,381
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    Just answering your questions here. Power of two textures allow Warcraft 3 to run and look as intended, on the video hardware it was officially designed for in 2002.

    3D accelerator video cards from the mid-1990s up until the early 2000s were designed that way iirc. That is as simple as that. Therefore, all the textures found in video games had then to be power of two textures, in order to comply with the technical limitations of the 3D hardware of their day.

    Fine, but I am guessing that the results would be... sub-optimal on some of the video hardware the game was originally designed to run on. I am guessing there would be visual glitches / artifacts, or the textures may not load, or they may look blurry, or the game engine might eventually simply crash when trying to load such textures.
     
    Last edited: Dec 5, 2017
  5. GhostWolf

    GhostWolf

    Joined:
    Jul 29, 2007
    Messages:
    4,836
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    Maybe in the future I will move to WebGL 2 (based on OpenGL ES 3), which supports NPOT textures with mipmapping etc.
    Regardless, this isn't very relevant.
     
  6. GhostWolf

    GhostWolf

    Joined:
    Jul 29, 2007
    Messages:
    4,836
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    Does anyone know what exactly a line-emitter particle emitter is?
    It is used in the Thunderclap Caster model to make a circle of particles.
    Without it being set, the particles are spawned randomly.
    Are the rules for this known? (e.g. does it simply disable randomness, or is there more to it)


    Doesn't matter.
     
  7. pyf

    pyf

    Joined:
    Mar 21, 2016
    Messages:
    2,381
    Resources:
    2
    Tutorials:
    2
    Resources:
    2
    For the record, even 3D accelerator video cards from the mid-late 1990s could have support for texture size larger than 256*256.

    iirc, a lousy SiS 6326 AGP video card supported 512*512 textures, while an even more lousy S3 ViRGE DX PCI video card supported 1024*1024 textures iirc. The problem was that such video cards had other severe technical limitations (and sometimes also buggy drivers). Therefore, they were not really suitable for decent hardware accelerated 3D gaming.

    The only ones from that era which were recommended (and suited) for 3D gaming were the 3Dfx Voodoo series of video cards (Voodoo and Voodoo 2). And both of them had a texture size limit of 256*256, by design. Same for Voodoo 3 video cards.

    ... and of course, none of the video cards mentioned above had Non power of 2 texture support afaik.
     
    Last edited: Dec 8, 2017
  8. GhostWolf

    GhostWolf

    Joined:
    Jul 29, 2007
    Messages:
    4,836
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    Latest version is
    4.0.25
    .
    • Texture wrap modes are now used.
    • The line-emitter flag of particle emitters is now supported. Previously all particle emitters were line emitters.
    • Fixed the width/length handling of particle emitters.
    • Tail particles are working again, and are a lot more correct than they were in the past.
    • The repeat value of particle emitters is now used.
    Many models should look more correct.
     
  9. Hayate

    Hayate

    Joined:
    Oct 20, 2010
    Messages:
    2,606
    Resources:
    65
    Models:
    50
    Icons:
    14
    Spells:
    1
    Resources:
    65
    Is there A possibilities to have the Model Viewer to Renders the Warcraft Model Animation into TGA or PNG sequence with Alpha?
    And Able to make the View to Follow an Camera In real time (For Turntable use, while having the animation played)
     
  10. GhostWolf

    GhostWolf

    Joined:
    Jul 29, 2007
    Messages:
    4,836
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    The ModelViewer class offers a toBlob(callback) method.
    You can save the given blob as an image with standard JavaScript.
    E.g. something along the lines of:
    Code (Javascript):

    viewer.toBlob((blob) => {
        let url = URL.createObjectURL(blob);
    });
     
    You can get all sorts of different scripts that allow to download urls easily. For the unit tester, I use this simple function:
    Code (Javascript):

    function downloadUrl(url, name) {
        let a = document.createElement('a');

        a.href = url;
        a.download = `${name}.png`;
     
        a.dispatchEvent(new MouseEvent('click'));
    }
     
    You get full control over the viewer with the update(), render(), and updateAndRender() methods.
    This means you can indeed move frame by frame and take screenshots if you desire.
    It is a bit troublesome that toBlob() is asynchronous, so you cannot run this kind of code in a simple loop. I thought about changing it to promises at some point, which will allow you to effectively have this code:
    Code (Javascript):

    async function record(viewer, frames) {
        for (let i = 0; i < frames; i++) {
            viewer.updateAndRender();

            // Note the async/await!
            let url = URL.createObjectURL(await viewer.toBlob());

            downloadUrl(url, `frame_${i}`);
          }
    }
     
    I have done this in the past to make the auto-generated gif's of models when I made that demo gallery client that no one liked.
    There isn't any code currently for this, however I won't mind making a quick implementation if you want. The actual recording really just takes the above tiny function if I change to promises from callbacks. The actual work here is the UI to let you select animations and what or what not to record, a way to move the camera, and so on. If I'll do it, I am not going to spend a lot of time at all on any kind of proper UI.

    I am not sure what you mean by the second part.
    If you mean just rotating the model or having the camera rotate around the model, you can do both with standard node operations.
     
    Last edited: Mar 29, 2018
  11. Hayate

    Hayate

    Joined:
    Oct 20, 2010
    Messages:
    2,606
    Resources:
    65
    Models:
    50
    Icons:
    14
    Spells:
    1
    Resources:
    65
    Hmm.... Would be great if you could do a quick implement, does the generated image will have Alpha? (Or Transparency)
    Sorry if I am asking stupid question because I dont understand too much :p

    for the camera part i guess is just what you say

    Btw, How do I even use all these?
     
  12. GhostWolf

    GhostWolf

    Joined:
    Jul 29, 2007
    Messages:
    4,836
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    The model viewer is a JS library. You use it like any other JS library.

    To be honest, considering recent events, I don't know if I'll do this.
     
  13. Hayate

    Hayate

    Joined:
    Oct 20, 2010
    Messages:
    2,606
    Resources:
    65
    Models:
    50
    Icons:
    14
    Spells:
    1
    Resources:
    65
    What kind of recent event? o_O
     
  14. GhostWolf

    GhostWolf

    Joined:
    Jul 29, 2007
    Messages:
    4,836
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    Here's a basic demo. If you want more control, someone else can waste their time.
    Drag a model anywhere to load it.
    Press space to start/stop recording.
    Left/right arrows keys to change animations.
    Mouse to rotate and zoom.
    The whole canvas is recorded, so you'd probably want to resize your browser tab to something small.

    I looked into making the background transparent, but it will never result in what you think it will, because of all of the different blending happening with the different material layers.
     
  15. Hayate

    Hayate

    Joined:
    Oct 20, 2010
    Messages:
    2,606
    Resources:
    65
    Models:
    50
    Icons:
    14
    Spells:
    1
    Resources:
    65
    Hmm so the transparent background will not work? Or it just looks very different?

    Because the biggeest reason i ask for this is for the alpha part :/
     
  16. moyackx

    moyackx

    Joined:
    Feb 15, 2006
    Messages:
    791
    Resources:
    7
    Maps:
    4
    Spells:
    2
    Tutorials:
    1
    Resources:
    7
    Tested and the browser sends an error message because there's no more processing capabilities, and I'm working in a good PC.

    Using Chrome latest version.
     
  17. GhostWolf

    GhostWolf

    Joined:
    Jul 29, 2007
    Messages:
    4,836
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    While I can remove the background, it will not result in the clean image you have in mind. Things like team glows, particle emitters, and so on, use blending modes that will look bad with no background. For team glows, for example, you will see all of the black surrounding the glows themselves too overlayed one above another.
    If you want consistent blending, the background needs the default alpha=1.
    It might be possible to color-key, but I doubt it will be very consistent due to the blending, you'll need thresholds and might get false positives.

    For turntable, use the up/down arrow keys to add speed in the counter-clockwise/clockwise directions respectively.

    As to errors, as always, post a log, say what you did, etc....
     

    Attached Files:

    Last edited: Mar 30, 2018
  18. bobadoo2

    bobadoo2

    Joined:
    Nov 10, 2010
    Messages:
    80
    Resources:
    2
    Maps:
    2
    Resources:
    2
    How do I zoom out with the 3d model viewer when viewing models??? 50% of the time the models are huge and I'm so zoomed in I can't see and I try rotating and sliding...it reminds me of this joke; a pirate walks in to a bar holding a steering wheel in front of him. A guy asks what are you doing holding a ships steering wheel, and he replies: it's driving me nuts!
     
  19. Hayate

    Hayate

    Joined:
    Oct 20, 2010
    Messages:
    2,606
    Resources:
    65
    Models:
    50
    Icons:
    14
    Spells:
    1
    Resources:
    65
    Damn sounds like a no hope then, i guess i will have to live with this, thank you very much

    This one is just asking the possibilities,
    What about rendering the image that have the stuff that have particle seperate in each layer? Perhaps in psd, or other file format? That way i could convert those individual layer into black and white and use it as an alpha channel for the glow itself

    Of course, just a possibilities, it sounds too complicated already.

    I am planning to use after effect to composite the image, if by any chance you have an idea with this piece of information, then would be great, but just saying.

    Ive been using magos with green background to key out the models, but as i work with more models, the models are getting colorful that it uses both green, red and blue, and i have no idea what color i can use to to key it
     
    Last edited: Mar 30, 2018
  20. GhostWolf

    GhostWolf

    Joined:
    Jul 29, 2007
    Messages:
    4,836
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    It depends on what client, but generally speaking the mouse scroll should do it.

    Yeah, that's the issue with color keying. I experimented with it, but there isn't any actual rule that I could think of. This is due to how things like team glows are blended, which is not based on alpha but rather on color.
    Being able to split layers would require to change the whole way the viewer renders things to be very specific for this.

    Forgot to mention, to record a single frame you can press the enter key.