MagiCam! Free-Form Camera Controls and Utilities!

This bundle is marked as pending. It has not been reviewed by a staff member yet.

MagiCam!


A Free-Form camera system for Wacraft 3 Reforged!

Toggleable Controls! Drag and Drop and Wheel to fly with the camera across your map!

Also contains a mathematically perfect implementation of World2Screen! No magic numbers! We cracked it!

But first, check out the video reel!




The map provided is just for illustrative purposes, and for you to grab the triggers if you wish.
Shoutout to Situ and the collaborators for the amazing MagicForest-Terrain template!


TODO:
:: Allow for the Camera to be pushed
:: An out-of-the-box integrated WASD movement system! For the ultimate WoW feels!
:: Efficient raycasting for the Screen2World.
:: Your suggestions (maybe)
Contents

MagiCam by ModdieMads (Map)

Very nice! The camera movement is quite smooth!

I dabbled into this problem myself for an evening after finishing my mouse library. Since I wanted to reproduce exactly the WoW camera, which doesn't move while you're turning the camera, I spent most of the time trying to cage the mouse and still detect mouse movement. If you want to look at my solution, here. My solution works relatively well, but then it just goes completely nuts out of nowhere. Haven't figured out why, and, since you're working on this problem as well, I'm not gonna continue with it, so feel free to scavenge it for the mouse cage solution if you want to implement that as well.

Even when the Mouse event works, the raycasting is so shoddy on uneven terrain that the Camera gets inevitably bumpy.
:: :: - A great deal of smoothing was deployed, but perfect smoothness requires perfect terrain
That is because you're not accurately returning the terrain height. The GetLocationZ function does not return the height of the terrain geometry, which you want to get for determining the mouse position. The terrain geometry of each 128x128 tile is divided into two triangles, but the GetLocationZ function returns a curved plane. If you want a more accurate (and faster) result, you should use my GetTerrainZ function.

-- And so my third attempt began. To calculate a virtual camera in the most brass-tacks way that I know how.

-- A point, a plane, and lines firing from the world to the camera, burning a pixel on the screen exactly where they pierce the view plane.
-- A point, a plane, and lines firing from the world to the camera, burning a pixel on the screen exactly where they pierce the view plane.
-- A point, a plane, and lines firing from the world to the camera, burning a pixel on the screen exactly where they pierce the view plane.
Yes, the easiest approach, in my opinion, is thinking of the screen as a pinhole camera and calculating the point on the screen where a ray of light would hit from the mouse position. But an additional annoyance is that the y-coordinate of the point where perpendicular rays hit the screen appears to be changing with the angle of attack.

-- But in WC3, it's the other way around. A good way to prove this is to use the GUI action Rotate Camera Around Point.
-- You will see the camera rotating, but its Rotation field DOESN'T CHANGE!
-- Yes, it is as bad as you're thinking. That function is just changing both the camera position (in wc3, the Camera Eye) and the Cam Target.
-- Yes, it is emulating a rotation, WITHOUT USING THE ROTATION FIELDS!!!!!
-- This creates problems.
Ok, this is stupid, but is that such a big problem? Can't you adjust the camera with the rotation field instead of using that function?

-- And also Tangents, notoriously difficult to calculate, which we now know is done in wc3 by bluntly doing Sin(x)/Cos(x).
-- Yes, you read that right. It compounds the error in Sin(x) with the error in Cos(x) and then amplifies it with a division operation.
That would be true for the Tan native, but not for the Lua incorporated function, or not?

-- Something I need to clarify: these vector functions are all designed for immutability.
-- Meaning they spawn a new vector (a table, in lua) with each operation.
-- This is almost a crime, and any game that uses such strategy will probably get in trouble.
-- However, since the main purpose of this code is to showcase and conceptualize, it won't be a big problem.
Just don't use vectors. :prazz: Does something like this really need to be its own function?
Lua:
    local function Vec3Subtract(vecTo, vecFrom)
        return {vecTo[1]-vecFrom[1], vecTo[2]-vecFrom[2], vecTo[3]-vecFrom[3]};
    end
Just my personal pet peeve. I think all these mini functions make understanding someone else's code very difficult.

Lua:
    local function AcosSafe(rad1)
        return math.acos(Clamp(rad1,-1.0,1.0))
    end
You can save the trigonometric function to local variables to make them faster, and you won't have to write math. everywhere.

-- this is interesting.
-- This function is creating the risen terrain on the map borders.
-- This is done because when the mouse is not over some terrain, WC3 won't tell me where the mouse is.
-- So, we rise the terrain's borders like a cradle, in the hopes of reducing the amount of times the raycasting fail.

-- I guess this helps, like... 25%? Maybe less...
I think you could just tell mapmakers to put giant cliffs with alpha tiles around their map. Terrain deformations should be avoided if possible.
:peek:

Looks very promising indeed! :psmile: I'll have to dig myself deeper into your algorithm to say anything profound about it.
 
Last edited:
Level 9
Joined
Jun 28, 2023
Messages
51
Version 1.2 - [MAJOR IMPROVEMENTS]

  • Integrated my MagiMouse system into it! It's now 10x more stable, smooth and reliable.
  • Improved the World2Screen algorithm to remove all magic numbers! It has been cracked!
  • Added NEW custom frame tech that allows for frames to NOT capture key presses when focused!
  • Added a bunch of mouse controls and quality of life stuff!
 
Level 4
Joined
Jan 16, 2013
Messages
16
- Camera mouse controls are inverted.

- Having to click control in the demo is extremely uncomfortable. So is being unable to right-click to move during the camera test.

- Would be informative if the demo map demonstrated how this camera system reacts to drastic height changes, something extremely common in WoW-like maps.

- Camera easing is visibly slow, what parameter controls it?

- WASD controls would be nice.

- Errors upon importing, re-assigning the target unit, and testing the map:
 

Attachments

  • Desktop 04-03-2025 22-35-23-331.jpg
    Desktop 04-03-2025 22-35-23-331.jpg
    185 KB · Views: 9
Level 9
Joined
Jun 28, 2023
Messages
51
- Camera mouse controls are inverted.

- Having to click control in the demo is extremely uncomfortable. So is being unable to right-click to move during the camera test.

- Would be informative if the demo map demonstrated how this camera system reacts to drastic height changes, something extremely common in WoW-like maps.

- Camera easing is visibly slow, what parameter controls it?

- WASD controls would be nice.

- Errors upon importing, re-assigning the target unit, and testing the map:
Thanks for the feedback!
- The camera controls are not inverted, they are responding to the dragging motion of the mouse. Thats the convention that most Apple/Adobe products use. But I agree that a checkbox could help in accomodating all users.

- There's a significant problem in WC3 regarding the mouse-wheel event, so "blocking" the clicks while controlling the camera was the only viable solution. That's also why there's a toggle to use the camera, so that you can switch between modes by just holding a key. I may have overstimated people's pinky strength, so I will add a hard-toggle to solve this issue.

- There are parameters in the code (identifiable by the _STRENGTH suffix) that control the magnitude of the camera controls

- WASD would be nice indeed, also a whole lotta work.

- Error is because your test map is in JASS. This is a Lua resource.
 
Level 4
Joined
Jan 16, 2013
Messages
16
- There's a significant problem in WC3 regarding the mouse-wheel event, so "blocking" the clicks while controlling the camera was the only viable solution. That's also why there's a toggle to use the camera, so that you can switch between modes by just holding a key. I may have overstimated people's pinky strength, so I will add a hard-toggle to solve this issue.

- WASD would be nice indeed, also a whole lotta work.

- Error is because your test map is in JASS. This is a Lua resource.
Is it even feasible to expect a WoW-grade camera and controls system in wc3?
This drastically changes how I have to build the map, I was expecting your system to be the solution, but I understand that no one is a magician and can make things that cannot happen, happen.

What do I have to import/do to make this Lua system work?

Thank you for your efforts and your response, I know you wanted to release this for a long time.
 
Level 9
Joined
Jun 28, 2023
Messages
51
What do I have to import/do to make this Lua system work?
The install instructions are in the MagiCam script file in the test-map. I will add them to this post soon.

Is it even feasible to expect a WoW-grade camera and controls system in wc3?
This drastically changes how I have to build the map, I was expecting your system to be the solution, but I understand that no one is a magician and can make things that cannot happen, happen.
It's actually super easy, barely an inconvenience. Full WoW controls will be available on the incoming update.
 
Top