• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

How to rotate a sprite frame without editing the model?

Hi. I’ve got a question about rendering sprite frames without using the internal MDX camera.

When you render a model to screen coordinates, its X goes to screen width, Y to height, and Z goes into the depth buffer. So when you see it on the screen, it looks like the model was first rotated -90 around Z, then -90 around Y.

Lua:
local fr = BlzCreateFrameByType("SPRITE", "", BlzGetOriginFrame(ORIGIN_FRAME_WORLD_FRAME, 0), "", 0)
BlzFrameSetAbsPoint(fr, FRAMEPOINT_CENTER, 0.4, 0.3)
BlzFrameSetSize(fr, .001, .001)
BlzFrameSetModel(fr, "Units\\Human\\BloodElfDragonHawk\\BloodElfDragonHawk", 0)
BlzFrameSetScale(fr, .0025)

1.jpg

I want to use sprites where the model faces forward. Sure, I could fix this by rotating the model itself, or by using the internal MDX camera, but both ways require reimporting the model. My goal is to do this with existing in-game models, no editing.

There’s no API to rotate sprites, so I’m trying to use camera syntax in FDF. But I’ve hit some problems.

First, if I set up the camera with normal distances (like in MDX portraits), the model just disappears (or more like, it’s huge and right in front of the camera) because the world scale and screen scale are way different, so I have to make the camera/target coordinates thousands of times bigger (like zooming the camera way out).

That sort of works, I mean the model does show up facing forward, but for some reason (maybe because the camera is so far away), there’s a weird depth buffer bug. If the model has multiple geosets, they randomly jump in front of each other and the sprite flickers (see the video).



FDF code:
Code:
Frame "FRAME" "CamTest" {
    SetPoint CENTER, "ConsoleUI", CENTER, 0.0, 0.15,
    Width 0.35,
    Height 0.5,
    Frame "SPRITE" "TestSprite1" {
        SetAllPoints,
        BackgroundArt "Units\Human\Rifleman\Rifleman",
        Camera {
            CameraTarget 18537.772 629.4373 1026.9980,
            CameraFieldOfView 0.35,
            CameraFarZ 19000.0,
            CameraPosition 18538.77 629.47217 1027.0504,
            // CameraRotation 0.0,
            // CameraAoA 0.0
        }
    }
}

Has anyone run into this problem and solved it?

Here’s what I tried:
  • I used FDF flags for the depth buffer, adding the line LayerStyle "NODEPTHTEST|NODEPTHSET", but it didn’t help.
  • I tried adding a light source in FDF. Still flickering.
  • I also messed with sprite scaling. There’s a weird thing: when you scale the sprite frame while using a camera, it also scales the camera position inside the model (see video). I couldn’t get anything useful from this though.

Any ideas?
 
Back
Top