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

[Mapping] Using 3d points within World Editor

Level 13
Joined
Nov 7, 2014
Messages
571
Using 3d points within World Editor

The Warcraft III [The Frozen Throne]'s map editor (WE, World Editor) has a tool palette from which the Terrain Palette, Doodad Palette, Unit Palette, Region Palette and the Camera Palette can be accesed.
This means that WE has first class support for terraining, doodads, units, regions and cameras, but no points, unlike the Starcraft 2 map editor.
With that said, we can repurpose one of the tool palette's objects and turn it into a 3d point. The one that I think is best suited is the Camera object.

We can see the camera objects within WE when the Camera Palette is active or when the View/Camera Objects setting is enabled. We can turn a camera into a 3d point by changing a few of it's properties:

top-of-mountain-png.245869


The important ones are: Target X, Target Y, Z Offset, Angle of Attack (AoA) and Distance. I recommend that you use 270.00 for AoA and 100 for distance this would make the camera point downwards and make it small.
The Target X, Taget Y and Z Offset would of course be our point's X, Y and Z coordinates respectively.

When we create a camera object with the Camera Palette, WE will make it accessable to us by generating some Jass2 code:

JASS:
globals
    camerasetup gg_cam_Top_of_Mountain = null
endglobals

function CreateCameras takes nothing returns nothing

    set gg_cam_Top_of_Mountain = CreateCameraSetup()
    call CameraSetupSetField(gg_cam_Top_of_Mountain, CAMERA_FIELD_ZOFFSET, 0.0, 0.0)
    call CameraSetupSetField(gg_cam_Top_of_Mountain, CAMERA_FIELD_ROTATION, 90.0, 0.0)
    call CameraSetupSetField(gg_cam_Top_of_Mountain, CAMERA_FIELD_ANGLE_OF_ATTACK, 270.0, 0.0)
    call CameraSetupSetField(gg_cam_Top_of_Mountain, CAMERA_FIELD_TARGET_DISTANCE, 100.0, 0.0)
    call CameraSetupSetField(gg_cam_Top_of_Mountain, CAMERA_FIELD_ROLL, 0.0, 0.0)
    call CameraSetupSetField(gg_cam_Top_of_Mountain, CAMERA_FIELD_FIELD_OF_VIEW, 120.0, 0.0)
    call CameraSetupSetField(gg_cam_Top_of_Mountain, CAMERA_FIELD_FARZ, 101.0, 0.0)
    call CameraSetupSetDestPosition(gg_cam_Top_of_Mountain, 439.0, 306.5, 0.0)

endfunction

We can see that cameras are represented by the type camerasetup. Also note the name of the global variable that WE assigned to our camera: it is the one we used in the Camera Palette but space characters were replaced by underscores and it has the prefix: gg_cam_

The way we can get the x, y and z coordinates from the camera object is:
JASS:
globals
    location loc = Location(0.0, 0.0)
    real px
    real py
    real pz
endglobals

...

set px = CameraSetupGetDestPositionX(gg_cam_Top_of_Mountain)
set py = CameraSetupGetDestPositionY(gg_cam_Top_of_Mountain)
call MoveLocation(loc, px, py)
set pz = CameraSetupGetField(gg_cam_Top_of_Mountain, CAMERA_FIELD_ZOFFSET) + GetLocationZ(loc)

...

And there you have it, 3d points within WE which have first class spupport and are easy to use via script.
 

Attachments

  • top-of-mountain.png
    top-of-mountain.png
    389.7 KB · Views: 279
WE will make it accessable to us by generating some Jass2 code:
Isnt such code like shown auto generated internaly when you create a camera?

I'm not very sure how/where you will use the 3D camera point.
It's actually only for scripts, and not for you to work in editor? (like from title I assumed "Using 3d points within World Editor").
Can you add example what to do with it?

Or is it only how to get x/y/z of a set up camera with scripts?
 
Top