Quick Question regarding t2dShapeVector
by Glenn Thomas · in Torque Game Builder · 02/11/2012 (9:22 am) · 2 replies
This is regarding me needing clarification about the method setPolyCustom. I'm trying to draw shapes through scripting but the parameters that I pass to the method seem to be a quite painstaking process for shapes with a lot of vertices.
For instance if I wanted to draw a square:
I would think I'd have to pass the x,y coordinate of each of the vertices to the method and then the method would draw the shape.
the method looks like this: setPolyCustom ( %vertexCount, %polygon )
%vertexCount is an integer obviously, so my square would be 4, unless we start at zero and in that case it would be 3(Please clarify).
%polygon is a list though and this is where I get confused
I sure it's similar to the method getPosition() where the values are separated by spaces. (0 0) - where the first zero is the x position and the second is the y position. so to set something's position it would look like %obj.setPosition(100,-100).
so how do I set my square up?
I assume %obj.setPolyCustom(4, 100, 100, 100, -100, -100, -100, -100, 100)
which is %obj.setPolyCustom(4, x1, y1, x2, y2, x3, y3, x4, y4)
or
another way to say it is v1(100, 100), v2(100, -100), v3(-100, -100), v4(-100, 100). This should draw a square clockwise if I'm correct
(hopefully my shape never has 100 vertices).
The reason I brought the clockwise reference up is because if I don't draw the shape either clockwise or counter clockwise will it mess up?
such as cutting across the plane diagonally?
So to condense everything I'm asking if this is the correct way at going about this
if it is it may be a painstaking process to retrieve a specific vertex utilizing getWord() for an shape with more than ten vertices.
Oh since we're on topic it would be beneficial to add this example to the documentation:
%obj.setPolyCustom(4, x1, y1, x2, y2, x3, y3, x4, y4);
For instance if I wanted to draw a square:
I would think I'd have to pass the x,y coordinate of each of the vertices to the method and then the method would draw the shape.
the method looks like this: setPolyCustom ( %vertexCount, %polygon )
%vertexCount is an integer obviously, so my square would be 4, unless we start at zero and in that case it would be 3(Please clarify).
%polygon is a list though and this is where I get confused
I sure it's similar to the method getPosition() where the values are separated by spaces. (0 0) - where the first zero is the x position and the second is the y position. so to set something's position it would look like %obj.setPosition(100,-100).
so how do I set my square up?
I assume %obj.setPolyCustom(4, 100, 100, 100, -100, -100, -100, -100, 100)
which is %obj.setPolyCustom(4, x1, y1, x2, y2, x3, y3, x4, y4)
or
another way to say it is v1(100, 100), v2(100, -100), v3(-100, -100), v4(-100, 100). This should draw a square clockwise if I'm correct
(hopefully my shape never has 100 vertices).
The reason I brought the clockwise reference up is because if I don't draw the shape either clockwise or counter clockwise will it mess up?
such as cutting across the plane diagonally?
So to condense everything I'm asking if this is the correct way at going about this
if it is it may be a painstaking process to retrieve a specific vertex utilizing getWord() for an shape with more than ten vertices.
Oh since we're on topic it would be beneficial to add this example to the documentation:
%obj.setPolyCustom(4, x1, y1, x2, y2, x3, y3, x4, y4);
Associate Charlie Patterson
Default Studio Name
%obj.setPolyCustom(4, "1 1 1 -1 -1 -1 -1 1");
%obj.setSize(100, 100);
It doesn't look like it matters if you go clockwise or counter. You'll just have to try that out to be sure. :P