• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

3D Model Viewer

Ralle

Owner
Level 77
Joined
Oct 6, 2004
Messages
10,100
Are you also getting 404's in loading the models in this link?
Code:
http://www.hiveworkshop.com/model_viewer/dev/?s=[[41,-41,377],[315,212],2,0,1,0,[[0,%22178202%22],[1,0,0,0,[0,0,0],[0,0,0,1],0.4,3,1,0],[0,%22Assets/Units/Zerg/Zergling/Zergling.m3%22],[1,2,12,2,[0,0,0],[0,0,0,1],1,-1,-1,1]]]
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Are you also getting 404's in loading the models in this link?
Code:
http://www.hiveworkshop.com/model_viewer/dev/?s=[[41,-41,377],[315,212],2,0,1,0,[[0,%22178202%22],[1,0,0,0,[0,0,0],[0,0,0,1],0.4,3,1,0],[0,%22Assets/Units/Zerg/Zergling/Zergling.m3%22],[1,2,12,2,[0,0,0],[0,0,0,1],1,-1,-1,1]]]

Yes, that scene is no longer valid, since I changed the way things work.

Here's how it looks now:
http://www.hiveworkshop.com/model_v...[1,4,1,12,2,[0,0,0],[0,0,0,1],1,-1,-1,0,{}]]]
It's very long because of the texture overrides (and all the urls are absolute).

Should I add a selection on what instances (and hence models) to save?
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Hmm, can't really tell what the errors are since that's both the compressed JS file and the Firefox console doesn't automatically show the properties of objects, but I am assuming it's the shaders failing for you again for whatever reason.

Try this link and see where exactly the error is http://www.hiveworkshop.com/model_v...[1,4,1,12,2,[0,0,0],[0,0,0,1],1,-1,-1,0,{}]]].
And also look at those objects in the console and see what they contain (the objectType and error properties).
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Bleh, vB keeps ruining the urls.
Code:
http://www.hiveworkshop.com/model_viewer/dev/?custsrc=unpacked_viewer.js&s=[[0%2C0%2C472]%2C[319%2C226]%2C2%2C0%2C1%2C0%2C[[0%2C%22http%3A%2F%2Fwww.hiveworkshop.com%2Fmodel_files%2F7bi4ve%2Fportrait.mdx%22%2C{%22elitesiegetank.blp%22%3A%22http%3A%2F%2Fwww.hiveworkshop.com%2Fforums%2Fapps.php%3Fsection%3Dmodels%26p%3Dgetpng%26id%3D7bi4ve%26file%3DEliteSiegeTank.blp%22%2C%22fireparticle4x4.blp%22%3A%22http%3A%2F%2Fwww.hiveworkshop.com%2Fforums%2Fapps.php%3Fsection%3Dmodels%26p%3Dgetpng%26id%3D7bi4ve%26file%3DFireParticle4x4.blp%22%2C%22elitesiegeengineportrait.blp%22%3A%22http%3A%2F%2Fwww.hiveworkshop.com%2Fforums%2Fapps.php%3Fsection%3Dmodels%26p%3Dgetpng%26id%3D7bi4ve%26file%3DEliteSiegeEnginePortrait.blp%22}]%2C[1%2C0%2Cfalse%2C-1%2C0%2C[0%2C0%2C0]%2C[0%2C0%2C0%2C1]%2C1%2C-1%2C-1%2C0%2C{}]%2C[0%2C%22http%3A%2F%2Fwww.hiveworkshop.com%2Fmodel_files%2F7bi4ve%2Fmodel.mdx%22%2C{%22elitesiegetank.blp%22%3A%22http%3A%2F%2Fwww.hiveworkshop.com%2Fforums%2Fapps.php%3Fsection%3Dmodels%26p%3Dgetpng%26id%3D7bi4ve%26file%3DEliteSiegeTank.blp%22%2C%22fireparticle4x4.blp%22%3A%22http%3A%2F%2Fwww.hiveworkshop.com%2Fforums%2Fapps.php%3Fsection%3Dmodels%26p%3Dgetpng%26id%3D7bi4ve%26file%3DFireParticle4x4.blp%22%2C%22elitesiegeengineportrait.blp%22%3A%22http%3A%2F%2Fwww.hiveworkshop.com%2Fforums%2Fapps.php%3Fsection%3Dmodels%26p%3Dgetpng%26id%3D7bi4ve%26file%3DEliteSiegeEnginePortrait.blp%22}]%2C[1%2C2%2C1%2C0%2C0%2C[0%2C0%2C0]%2C[0%2C0%2C0%2C1]%2C0.5%2C5%2C1%2C0%2C{}]%2C[0%2C%22http%3A%2F%2Fwww.hiveworkshop.com%2Fforums%2Fapps.php%3Fp%3Dmpq_file%26file%3DAssets%2FUnits%2FZerg%2FZergling%2FZergling.m3%22%2C{}]%2C[1%2C4%2C1%2C12%2C2%2C[0%2C0%2C0]%2C[0%2C0%2C0%2C1]%2C1%2C-1%2C-1%2C0%2C{}]]]
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Your browser cached older code, hard refresh it.

/Edit

Added an option to add new instances from the list of loaded models in the Instances tab.
Also fixed the options tab, it is now set correctly if non-default values are loaded from a scene.
 
Last edited:
Level 29
Joined
Jul 29, 2007
Messages
5,174
Instances that are not visible (and their owning models) wont be saved anymore. All the previous links I posted are invalid, since the scene structure changed again...hopefully this is the last time (for now).

Code:
http://www.hiveworkshop.com/model_viewer/dev/?s=%5B%5B100%2C2%2C396%5D%2C%5B311%2C228%5D%2C2%2C0%2C1%2C0%2C%5B%5B0%2C2%2C%22http%3A%2F%2Fwww.hiveworkshop.com%2Fmodel_files%2F7bi4ve%2Fmodel.mdx%22%2C%7B%22elitesiegetank.blp%22%3A%22http%3A%2F%2Fwww.hiveworkshop.com%2Fforums%2Fapps.php%3Fsection%3Dmodels%26p%3Dgetpng%26id%3D7bi4ve%26file%3DEliteSiegeTank.blp%22%2C%22fireparticle4x4.blp%22%3A%22http%3A%2F%2Fwww.hiveworkshop.com%2Fforums%2Fapps.php%3Fsection%3Dmodels%26p%3Dgetpng%26id%3D7bi4ve%26file%3DFireParticle4x4.blp%22%2C%22elitesiegeengineportrait.blp%22%3A%22http%3A%2F%2Fwww.hiveworkshop.com%2Fforums%2Fapps.php%3Fsection%3Dmodels%26p%3Dgetpng%26id%3D7bi4ve%26file%3DEliteSiegeEnginePortrait.blp%22%7D%5D%2C%5B1%2C3%2C2%2C0%2C0%2C%5B0%2C0%2C0%5D%2C%5B0%2C0%2C0%2C1%5D%2C0.3%2C5%2C1%2C0%2C%7B%7D%5D%2C%5B0%2C4%2C%22http%3A%2F%2Fwww.hiveworkshop.com%2Fforums%2Fapps.php%3Fp%3Dmpq_file%26file%3DAssets%2FUnits%2FZerg%2FZergling%2FZergling.m3%22%2C%7B%7D%5D%2C%5B1%2C5%2C4%2C12%2C0%2C%5B0%2C0%2C0%5D%2C%5B0%2C0%2C0%2C-1%5D%2C1%2C-1%2C-1%2C0%2C%7B%7D%5D%5D%5D
 
Last edited:
Level 29
Joined
Jul 29, 2007
Messages
5,174
Changed the scene format again.
Overrided textures get saved properly now, and the hierarchy is self-sufficient (it doesn't matter anymore what the viewer already has loaded, previously pre-loaded models could screw a loaded scene).
Should I add a "Load" button to load scenes dynamically? not sure if this is useful.

Code:
http://www.hiveworkshop.com/model_viewer/dev/?s=%5B%5B61%2C-22%2C215%5D%2C%5B313%2C291%5D%2C2%2C0%2C1%2C0%2C%5B%5B0%2C%22http%3A%2F%2Fwww.hiveworkshop.com%2Fmodel_files%2F7bi4ve%2Fmodel.mdx%22%2C%7B%22fireparticle4x4.blp%22%3A%22http%3A%2F%2Fwww.hiveworkshop.com%2Fforums%2Fapps.php%3Fsection%3Dmodels%26p%3Dgetpng%26id%3D7bi4ve%26file%3DFireParticle4x4.blp%22%2C%22elitesiegetank.blp%22%3A%22http%3A%2F%2Fwww.hiveworkshop.com%2Fforums%2Fapps.php%3Fsection%3Dmodels%26p%3Dgetpng%26id%3D7bi4ve%26file%3DEliteSiegeTank.blp%22%7D%5D%2C%5B1%2C%22http%3A%2F%2Fwww.hiveworkshop.com%2Fforums%2Fapps.php%3Fp%3Dmpq_file%26file%3DAssets%2FUnits%2FZerg%2FZergling%2FZergling.m3%22%2C%7B%7D%5D%5D%2C%5B%5B2%2C0%2C0%2C0%2C%5B0%2C0%2C0%5D%2C%5B0%2C0%2C0%2C1%5D%2C0.3%2C3%2C1%2C1%2C%7B%22replaceabletextures%2Fteamcolor%2Fteamcolor00.blp%22%3A%22http%3A%2F%2Fwww.hiveworkshop.com%2Fforums%2Fapps.php%3Fp%3Dmpq_file%26file%3DReplaceableTextures%2FTeamColor%2FTeamColor01.blp%22%2C%22replaceabletextures%2Fteamglow%2Fteamglow00.blp%22%3A%22http%3A%2F%2Fwww.hiveworkshop.com%2Fforums%2Fapps.php%3Fp%3Dmpq_file%26file%3DReplaceableTextures%2FTeamGlow%2FTeamGlow01.blp%22%7D%5D%2C%5B3%2C1%2C12%2C2%2C%5B0%2C0%2C0%5D%2C%5B0%2C0%2C0%2C-1%5D%2C1%2C-1%2C-1%2C4%2C%7B%7D%5D%5D%5D

If a fatal error is encountered (as in, your browser/computer doesn't have the requirements to run the viewer), it will be shown instead of the user interface, with suggestions on how to solve the issue.

Still not sure where to show non fatal errors.
 
Last edited:

Ralle

Owner
Level 77
Joined
Oct 6, 2004
Messages
10,100
Nice fix. It works. I can finally see the zergling breakdancing with a siege engine stuck to its antennae.

Although, is the texture supposed to look like this?
attachment.php
 

Attachments

  • Screen Shot 2014-04-20 at 3.23.57 PM.png
    Screen Shot 2014-04-20 at 3.23.57 PM.png
    557.5 KB · Views: 203
Level 29
Joined
Jul 29, 2007
Messages
5,174
Huh? I thought you simply extracted all of the MPQs to a directory. If you keep extracting files it just takes more processing (not sure how big the SC2 MPQs are, but the WC3 ones are tiny so space isn't an issue no matter what server you have).

What I would have done is extract everything in the same directory structure as the MPQs, then batch convert all the images to pngs while keeping the originals, and then you just fetch it normally.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
No, it's pretty random and always while I am testing other things, so I never looked too much into it.

On a side note, I fixed some issues with Warcraft 3 particle emitters type 2, and an issue with Starcraft 2 splitbody animations.

/Edit

Fixed more issues with particle emitters type 2, they should now match Warcraft 3...in most cases (?).
 
Last edited:
Level 29
Joined
Jul 29, 2007
Messages
5,174
Started implementing ray casting, it's currently only implemented for MDX spheres (and scales are not taken into consideration).

Here's an example, use the middle mouse key (as in press the scroll) to select an instance.
Code:
http://www.hiveworkshop.com/model_viewer/dev/?s=[[84,25,601],[-45,25],2,1,1,0,[[0,%22http://www.hiveworkshop.com/model_files/7bi4ve/model.mdx%22,{%22fireparticle4x4.blp%22:%22http://www.hiveworkshop.com/forums/apps.php%3Fsection%3Dmodels%26p%3Dgetpng%26id%3D7bi4ve%26file%3DFireParticle4x4.blp%22,%22elitesiegetank.blp%22:%22http://www.hiveworkshop.com/forums/apps.php%3Fsection%3Dmodels%26p%3Dgetpng%26id%3D7bi4ve%26file%3DEliteSiegeTank.blp%22}]],[[1,0,0,0,[200,0,0],[0,0,0,1],1,-1,-1,1,{}],[2,0,0,0,[0,200,0],[0,0,0,1],1,-1,-1,0,{}],[3,0,0,0,[0,-200,0],[0,0,0,1],1,-1,-1,6,{}],[4,0,0,0,[-200,0,0],[0,0,0,1],1,-1,-1,2,{}]]]

Should I bother with making general 3D modeling -like controls, like shortcuts to go into move/rotate/scale modes? Forcing axes? etc.
 
Last edited:
Level 29
Joined
Jul 29, 2007
Messages
5,174
Dropped the ray casting and implemented color picking instead.
Color picking means rendering all the models, each with a unique color, and then checking what the pixel color under the mouse is.
This is a little slower, but incredibly easy to implement, and is pixel-accurate (not that this matters, but many models don't provide decent bounding shapes in the first place).

Portraits are now hidden by default.

The public viewer has been updated.
Be sure to hard refresh (Ctrl + F5) or clear up the browser's cache.
 
Last edited:
Level 29
Joined
Jul 29, 2007
Messages
5,174
I didn't put the functionality to remove models (beside saving the scene and loading it again), because I am not sure in what case it's needed. The resources taken by a model are pretty slim to begin with.

As to the speed, I removed it because it was useless and mostly buggy.
To make it work with emitters, there need to be as many particles as can be spawned in the fastest speed, which can grab more resources than the model itself.
For example, a particle emitter type 2 with a maximum spawn rate of 500 will need 2500 particles for the x5 speed. Granted, this is nothing for your GPU memory-wise (540KB), but since particle emitters are the slowest part of the viewer by a huge margin, because of the big loops, it isn't worth it.
Maybe one day I'll find a way to optimize the particle emitters, and then we'll see (kind of hard with the limitations of WebGL).
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
Added DXT decoders for DDS images.
This means that if your device doesn't support DXT compressed textures (used by Starcraft 2 models), they will be manually decompressed locally and used as normal textures, instead of failing to load.
This mostly affects mobile devices or old graphics cards.
 
I don't know if this is a bug.
But take this http://www.hiveworkshop.com/forums/models-530/blackhand-250052/ as an example.
The viewer loads both the Blackhand.mdx and the Model.mdx, both are showing the model.
So if one of them is issued an animation fx. attack, the other will obscure the vision.
I know you can simply hide one of them, but is it possible to just have one of them loaded?

Also, same model. The texture seems to be missing. Can that be solved?
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
If a model in a resource is named portrait.mdx it is hidden by default. Otherwise, how would I know which model to show and which to hide?
About loading - no, every resource in a resource thread is loaded. This was both requested (for portraits), and it fits with SC2 resources which may contain multiple arbitrary models (not that there are many resources there...).
In the future the visibility flags should be sent by the server instead of just arbitrarily hiding portrait.mdx, though I am not sure what Ralle would do with it.

There is indeed an error with the texture loading, I'll go look for it.
 
If a model in a resource is named portrait.mdx it is hidden by default. Otherwise, how would I know which model to show and which to hide?

I don't know man. I'm the one asking questions, and I am in no position to answer any :)
I wrote because I thought you might be able to do something about it. Don't take it as an attack.
 
Level 14
Joined
Jul 27, 2007
Messages
793
I don't know if somebody has already expressed the same opinion (haven't read all 6 pages worth of posts) but I think that the animation speed is an useful feature, especially if you want to check long animation sequences quickly (e.g. Build animation for buildings).

Anyway, I'm happy to see that somebody's improving the model viewer! Keep it up & thank you! :)
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
I don't know if somebody has already expressed the same opinion (haven't read all 6 pages worth of posts) but I think that the animation speed is an useful feature, especially if you want to check long animation sequences quickly (e.g. Build animation for buildings).

Anyway, I'm happy to see that somebody's improving the model viewer! Keep it up & thank you! :)

Refer to http://www.hiveworkshop.com/forums/site-discussion-97/3d-model-viewer-249793/index6.html#post2517709

Actually I am wrong, the animation speed doesn't have to change the amount of particles (just their lifespan), I will re-implement it.

/Edit
Thanks to Ralle, texture paths are now correct, and no weird model duplicates are loaded anymore.
In addition, I added a BLP decoder that loads BLPs instead of requiring the server to send PNGs. I wonder if anyone will notice the difference.
 
Last edited:
Level 29
Joined
Jul 29, 2007
Messages
5,174
Reimplemented the animation speed option, it's in the Options tab.
It was added to the scene structure, so any previous scene is invalid again.

Changed the location of the per-instance visibility to the left of the instance name, this makes it much easier to hide/show instances.

Made a big optimization to particle emitters, and a nice optimization also to the general sequence data getter (affects pretty much the whole viewer).
 
Last edited:
Level 29
Joined
Jul 29, 2007
Messages
5,174
As it turns out, all my nice code, that cached values to avoid repeatedly sending the same information to the graphics card, is actually the biggest bottleneck in the viewer.
It appears that adding indirection in JavaScript isn't worth the caching.

So...I am in the process of tearing most of it, which involves almost every piece of code in the viewer.
Right now it works more than twice as fast.

I hope I do not introduce new bugs, but do report if you notice anything.

Fun test links (open at your own risk, they are heavy):
http://www.hiveworkshop.com/model_v...[65,0,5,0,[650,0,0],[0,0,0,1],1,-1,-1,0,{}]]] (MDX, many instances, lots of particles)
http://www.hiveworkshop.com/model_v...65,0,5,0,[650,0,0],[0,0,0,-1],1,-1,-1,0,{}]]] (M3, lots of instances)
 
Last edited:
Level 29
Joined
Jul 29, 2007
Messages
5,174
The M3 vertices chunk isn't parsed anymore but rather just read as bytes, and the vertices are instead parsed in the shaders.
This means that parsing Starcraft 2 models is quite a bit faster, and the data sent to the graphics card is reduced by 60% (32 bytes per vertex instead of 80).

The MDX geosets are now uploaded to the graphics card in a better way, which reduces their size by 37.5% (25 bytes per vertex instead of 40).

In addition, added greatly needed optimizations to the binary reader, so parsing both MDX and M3 files is much faster in general.

Firefox on Mac still doesn't work.

We'll just have to wait and let the Firefox people fix their browser (our issue was marked as duplicate to that one, in case you didn't see).
 
Last edited:
Top