• 🏆 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!

UI: Adding Sprite

Level 7
Joined
Apr 17, 2017
Messages
316
This tutorial will cover the basics of adding a model to your UI and fix model related issues like black and white models.
Tools you need:
Let's start with creating a simple 3d model:
JASS:
library uitest initializer init
 
   function init takes nothing returns nothing
      local framehandle gameUI = BlzGetOriginFrame(ORIGIN_FRAME_GAME_UI, 0) //This is our default Origin Frame, we will use it to create our model frame on top of it.
      local framehandle model = BlzCreateFrameByType("SPRITE", "model", gameUI, "", 0) //This is how you define a frame as a sprite. If you don't have TOC files loaded, you have to use this to create SPRITE.
      call BlzFrameSetAbsPoint(model, FRAMEPOINT_CENTER, 0.4, 0.3) //Positioning our SPRITE frame
      call BlzFrameSetSize(model, 0.001, 0.001) //For in-game models, size is mostly dependant on the size of the model, since in-game models are too big for our frames, we need to reduce its size to fit it into screen otherwise you will get wierd screen blackouts.
      call BlzFrameSetScale(model, 0.001) //We need to reduce our model size.
      call BlzFrameSetModel(model, "units\\human\\HeroPaladin\\HeroPaladin.mdx", 0) //This is pretty self explanatory. 0 here is the animation index that you want to use.For most models, 0 is for stand, 1 is for death animations.
   endfunction
endlibrary
This how our SPRITE looks like in-game:
SPRITE1.gif
This issue happens because of two things:
  • It happens due to shading
  • It happens because your models uses things like HeroGlow and TeamColor in Textures Layer.
Luckily we can fix that issue easily. Open your model using Retera's Model Studio then save it as mdl.

Then open your mdl file on Notepad++. Then edit these:
Textures.png
To this:
Textures2.png
You can change Teamcolor00 and TeamGlow00 to 01(up to 23 I guess). These will change your model's color and glow. Now we need to change the shading options. To do that you need to find Materials Layer and change these:
Materials.png

Note= without setting the layer as unshaded, our model will have black and white parts attached to that layer. So we change it like this:
Materials2.png
Now import the file to your map and change
JASS:
 call BlzFrameSetModel(model, "units\\human\\HeroPaladin\\HeroPaladin.mdx", 0)
to your imported model path.
Now our model should look like this:
IngameModel.png
For those that want the model to be rotated. You can use Oinkerwinkle's Geoset Translation Tool to rotate the model.
 
Last edited:
Level 18
Joined
Jan 1, 2018
Messages
728
JASS:
local framehandle model = BlzCreateFrameByType("SPRITE", "model", gameUI, 0)
Isn't BlzCreateFrameByType supposed to have 5 arguments?
JASS:
native BlzCreateFrameByType takes string typeName, string name, framehandle owner, string inherits, integer createContext returns framehandle
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
Seems a bit niche.

It's also quite short/simple when you take away the introduction elements, you could probably slim down the tutorial to 4 quick steps.

I am still uncertain on my stance on this and might have to go and re-read the rules and whatnot.

However, regardless I have a few suggestions.
To simplify you can combine pictures into a single one, specifically the ones detailing what to edit in notepad++
OR
Can probably just show it in text form which would be more space-efficient.
Might also be easier to divide the tutorial into steps/sections somehow
 
Level 2
Joined
Jun 18, 2021
Messages
5
hi, aeryn, I used your method, but I failed. Can you tell me why? Look forward to your reply.
 

Attachments

  • model.rar
    926.7 KB · Views: 39
Level 7
Joined
Apr 17, 2017
Messages
316
If your model uses a custom camera, you should use that cameraIndex. So your code
JASS:
call BlzFrameSetModel(model, "war3mapImported\\YX16lemh.mdx", 0)
becomes
JASS:
call BlzFrameSetModel(model, "war3mapImported\\YX16lemh.mdx", 1)
I still have no idea how cameras are indexed internally so you have to try which one works.
 
Level 2
Joined
Jun 18, 2021
Messages
5
If your model uses a custom camera, you should use that cameraIndex. So your code
JASS:
call BlzFrameSetModel(model, "war3mapImported\\YX16lemh.mdx", 0)
becomes
JASS:
call BlzFrameSetModel(model, "war3mapImported\\YX16lemh.mdx", 1)
I still have no idea how cameras are indexed internally so you have to try which one works.
Thank you very much for your help,Aeryn, I'll try to use your advice
 
Level 7
Joined
Apr 17, 2017
Messages
316
I don't know if there is a specific tutorial for rotating models but there are tools out there. The one you should be looking for is oinkerwinkle's geoset translation tool or you can talk to Retera. He's made a tool that let's you rotate models easily but I can't share it without his permission. If it's just 1 model I can do it for you.
 
Hello

I need to rotate the model to display it in a sprite frame. With the camera change I still see my model from the top.
The problem is I have never edit models so if you can show me how to do it or a tutorial lin. That should be very nice.
I've already downoad Retera's editor V0.04

Thnaks for your help
You need Mdlvis 1.41 and War3 Model Editor, not Retera's model studio.

Make a helper bone in Magos and set it as a parent of the root bone. Then you rotate the helper bone with the sequence manager in Mdlvis.
 
Level 17
Joined
Oct 10, 2011
Messages
462
ok I've created a new bone, I've opened the editor to select it but wich coords should I gave to it? I think I have to rotate the model around ZX axis to make it face the top. But in this editor I don't see anything to do that.

And second problem in my sprite there is a very flashy glow that cover the full screen when th sprite show the model, d you know how to remove that?
 
Last edited:
Level 7
Joined
Nov 6, 2019
Messages
186
So i thought this would be to have sprites only 5, as a class selection screen, i got the model to show on the CustomUI, however it form top down facing right.

So i know to edit and rotate the model, however the editor will not open the mdl i extracted from the Retera's Model Studio, as suggested in this Thread

i already dont know how to edit models, and add bone, like FeelsGoodMan said, but cant get editor to open it to start with to even try and figure it out.

Gets: Unable To Load ""File Location"", unknown token "NumParticleEmittersPopcorn" in "Model"!

Now i did see you say particle have to be removed, but when extracting originally they particles was unticked, and if that not enough dunno how to remove particles from Retera.

EDIT: so lol i downloaded a model from Hive and edited to do some testing, after rotating and such, and now it is messy i guess you could say :p

image_2022-06-24_174426942.png


Unsure how i broke it like this, but its pretty funny.
 
Last edited:
Level 7
Joined
Apr 17, 2017
Messages
316
So i thought this would be to have sprites only 5, as a class selection screen, i got the model to show on the CustomUI, however it form top down facing right.

So i know to edit and rotate the model, however the editor will not open the mdl i extracted from the Retera's Model Studio, as suggested in this Thread

i already dont know how to edit models, and add bone, like FeelsGoodMan said, but cant get editor to open it to start with to even try and figure it out.

Gets: Unable To Load ""File Location"", unknown token "NumParticleEmittersPopcorn" in "Model"!

Now i did see you say particle have to be removed, but when extracting originally they particles was unticked, and if that not enough dunno how to remove particles from Retera.

EDIT: so lol i downloaded a model from Hive and edited to do some testing, after rotating and such, and now it is messy i guess you could say :p

View attachment 401833

Unsure how i broke it like this, but its pretty funny.
Could you provide link to model?
If you managed to rotate the model correctly, i guess it might have something to do with new patch.
 
Level 7
Joined
Nov 6, 2019
Messages
186
100% i did it wrong, lol wasnt sure what i was doing anywho.

i gotta figure it out if i wana add 5 in total and maybe more in future.

One thing am unsure about, is if you to export rotate and import, wont you need like 2 dif models per one you adding, so one for the sprite other for playable hero.

so doubles the map size.
 

Attachments

  • BEFarstriderSelection.rar
    2.3 MB · Views: 8
Level 17
Joined
Oct 10, 2011
Messages
462
I have the same problem, I don't know how to add bones, rotates, ...
to display sprites in frames.

My models are bugged I try to display them on a sprite but they are displayed really far away from the target location in the bottom of the screen...
Do you know a way to put them in the correct frame?

My map is already very heavy so if it will double the size I'm not sure that it is the good way in my case.
 
Level 7
Joined
Nov 6, 2019
Messages
186
@Rigborn - ok so how do you rotate a Model to face forward on a sprite Properly?

Now your post says to rotate, but doesn’t say how to rotate properly.
 
Level 18
Joined
Oct 17, 2012
Messages
820
To expand on the rotation part of this short tutorial via Retera's Model Studio:
  1. Create a new bone.
  2. Position the new bone at the origin (x: 0, y: 0, z: 0) of the model.
  3. Place all bones, expect for the ones that are already under one, under your new bone (That is set your new bone as their parent).
  4. Create a new Global Sequence and have it last for only one frame.
  5. Within the Global Sequence, rotate only the new bone and every other bone will follow.
    • You would want the model lying down and its feet facing the left in the model view under the Editing Tab of Model Studio.
    • The Global Sequence will apply to all your model animations.
That's it. You can see how it looks in game after following Rigborn's tutorial and the short how-to from above in the image below.
 

Attachments

  • Sprite.jpg
    Sprite.jpg
    99.4 KB · Views: 37
Last edited:
You need Mdlvis 1.41 and War3 Model Editor, not Retera's model studio.

Make a helper bone in Magos and set it as a parent of the root bone. Then you rotate the helper bone with the sequence manager in Mdlvis.
I wonder if we can do anything with the particle emitters. They should be deleted BUT we need them as hell, because Infernals are not Infernals without fire particles. Maybe u have some Sprites working with emitters somehow in the Acolyte project? 🙏 @FeelsGoodMan
 

Attachments

  • Warcraft_III_2024-02-27_17-15-20.mp4
    14.2 MB
Last edited:
Top