Matrix, Pointer, Struct...

LightStriker

New Member
Reaction score
1
Started the SC2 editor 2 days ago... My first project I want to try is a 3D space ship shooter.

First thing I notice, is the lack of real support out of the box for real vector calcul. Not surprising, SC2 doesn't care much about the third dimension. Same with orientation... It's define as a single float. (an angle). Unit don't really point up or down in SC2.

There's no orientation matrix, no quaternion, and the vector (point) lack most of the basic math function... (Like normalize, dot, cross...)

Surprise! The script support struct... But you can't pass them to or from a function. (Bulk Copy not supported).
You can't also ref them with a pointer. (* , not supported since patch 9)
So... I have an hard time to really understand the use of a struct I can't do much with.
The idea of creating a new struct called Matrix3 and populate a library of function like "Matrix Rotate" is kinda impossible.

So... do I understand I'm kinda stuck for a 3D space shooter or am I missing some key feature that would make my life easier?
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
set global variable to your struct to pass between functions?
 

LightStriker

New Member
Reaction score
1
set global variable to your struct to pass between functions?

You can't copy one array or struct to another one... Only way is to manually deep copy everything. (struct a = b // Bulk Copy not supported)

So, you can't really make a library of function... Everytime you would want call one, you would need to manually copy a boat load of variable to some global structure before being able to call the function, and recopy everything back to local once the function is done. :nuts:

Example... I want to do a multiplication between 2 matrix3. I need 2 global matrix "in", one "out" for the function. I need to manually pass 18 float from my local matrix to the 2 "in" and 9 back to my local from the "out". :eek:
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
wait for vGalaxy that hides all that behind structs that are really classes in disguise?
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
The native type "point" can be used for a 3d vector with:
JASS:
native point Point (fixed x, fixed y); // 1 of the 4 constructors for point

native fixed PointGetX (point p);
native fixed PointGetY (point p);
native fixed PointGetHeight (point p); // PointGetZ

native void  PointSet (point p1, point p2); // PointSetXY
native void  PointSetHeight (point p, fixed inHeight); // PointSetZ

Some 2d stuff:
JASS:
native fixed AngleBetweenPoints (point p1, point p2);
native fixed DistanceBetweenPoints (point p1, point p2);

I don't really know what those do will copy-paste them anyway xD:
JASS:
native int   PointPathingCost (point p1, point p2);
native fixed PointPathingCliffLevel (point p);
native bool  PointPathingPassable (point p);
native bool  PointPathingIsConnected (point p1, point p2);
native point PointReflect (point source, point dest, fixed angle);

You can make your own Dot/Cross product functions.

I am not sure if you can do this:
define vector point; // or is it define point vector or this is not possible xD

// point aka vector
JASS:
vector Normalize(vector v)
{
    fixed x = VectorGetX(v); // aka PointGetX
    fixed y = VectorGetY(v);
    fixed z = VectorGetZ(v);
    fixed length = VectorLength(v); // sqrt(x^2 + etc...)
    vector normal = null;

    x = x / length;
    y = y /length;
    z = z /length;
    normal = Vector(x, y); // 
    VectorSetZ(normal, z);
   
    return normal;
}
 

LightStriker

New Member
Reaction score
1
Yeah, I already did normalize, lenght, and a couple of other vector function with Point. I was just really surprised that a lot of the basic math stuff is absent from Galaxy.

The problem begin when I need something bigger that hold more than just 3 float. Like a rotation matrix or a quaternion.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top