# Help with Poly() and Vecpoints() in Scasm

## Recommended Posts

Hi allI am trying to understand the relationship between the Points() & Poly() commands and Vecpoints() command, It's the Vector's that I am struggling with!!!Points( 0 0 790 10 ; 0 7 790 -4 ; 1 -6 790 -4 ; 2 0 593 10 ; 3 7 593 -4 ; 4 -6 593 -4 ; 5 )Poly( -30083 0 12986 4.10 5 3 0 2 )Poly( 30083 0 -12986 -4.10 5 3 0 2 )I understand that the 5,3,0,2 refers to the point's, I think!!!The second entry is 'Double sided'It's the first four No's which I am struggling with, I think they are (vx vz vy len)The 'Len'= length or distance in refpoints, may be Scale factor and Floating Points, are all similar terms (4.10) I don't understandIt's the vx and vy and their relationship, (-30083 0 12986) the vz=0 because it involves height, I think!!!I believe that these two commands might be better replaced by, Vecpoint() and shadedTexPoly() comands, although I could be wrong!!!sorry if it seems complicated, I may need explicit explanationAppreciate any advice, trying to ensure that the coding I use is efficient on frame rates.RegardsDave

##### Share on other sites
 Help AVSIM continue to serve you!Please donate today!

Hi Dave,Although it is difficult without a diagram, I will try to explain the numbers, using only words.The Points() in your example declares the position in space of 6 points. The first one will be referred to as point #0 and the last one as point #5. The coordinates are in "RefPoint Units". Before the points there must exist a RefPoint() instruction. The Lat/Lon/Alt in the RefPoint determine the center (the origin) of the coordinate system. I normally understand the argument in RefPoint() called Scale as the "measurement unit in meters". If, for example, Scale=0.1 (unit is 1 decimeter) your first point has coordinates of 0, 79 and 1 meter, meaning;0 meters to the east of refpoint79 meters to the height (spelling?) of refpoint1 meter to the north of refpointNow the Poly(). If you had something like Poly( 5 3 0 2 ) you would be defining solely a polygon made of points 5 3 0 2. Normally all points in a more than 3-point polygon, should be all in the same plane. In fact FS divides such polygons in triangles and some triangles could be visible, some not, for the reasons explained later. (A side note: if you use a graphic/CAD tool to make objects and you are using FS2k2 floating point instructions - not the ones you refer in your post - try to make triangles yourself for maximum frame rates. If you have a rectangle, make 2 triangles, or at least check how your CAD tool divides the rectangle in triangles!)Well you have 4 points that define a polygon. Now you need to specify from which region of the 3D world, your polygon is to be seen. In FS every polygon has a "separation plane" associated with it, which is a plane dividing the 3D world in 2 halves. If you are in one half world you will see the polygon (better saying: FS will draw it). If you are in the other half world you will not see the polygon. This is very useful if the "separation plane" contains the polygon (so the 4 points should be complanar!) because you can make one-side only visible polygons. If you are in the wrong side of the world, the polygon is not drawn and FS does not take time with it, because as soon as it reads the part describeing the "separation plane" it jumps to the next polygon.How to define the "separation plane"? With a vector and a distance! A vector defines an infinite number of planes that are perpendicular to it (all these planes are parallel). -30083 0 12986 are the coordinates of the vector. They define a direction. The numbers could be as well:-15041 0 6493but your numbers are normalized so that the the vector has a norm of 32767 (maximum representation in 16 bits).Before explaining the distance, let me say that your vector is horizontal (no Z) and points to (has a heading) of more or less 300 degrees. Now the distance. Imagine the vector apllied in the origin. Now, in the sense (spelling? way pointed?) of the vector (heading of 300) measure 4.1 decimeters from the origin (remember I assumed a scale of 0.1). Make a tick there. Now consider the plane perpendicular to the vector passing on that tick. That is a unique plane (!) and it is the "separation plane" that I refer to in the begining. That plane divides the 3D world in 2 halves. If you are in one of these halves, the polygon will be drawn! Which? Answer: the one pointed to by the vector.Therefore if you look "horizontally" your polygon will be seen when your heading is 210 to 390 (and if you are in the right part of the world that your Poly defines).I hope that is useful,Kind Regards, Luis

##### Share on other sites

Just want to add to the excellent info of Luis an answer to the last part of the question.It is not possible to use VecPoints() and ShadedPoly() instead of the instructions you know use.The difference between ShadedPoly and Poly is that FS will display a object made with VecPoints/ShadedPoly more smooth then one made with Points/Poly. So if you make a cilinder with 8 sides for example it would still look almost smooth.To make it even more confusing :), a ShadedPoly also has a vector just like the Poly you mentioned. So it makes no difference from that point of view.Arno

##### Share on other sites

Thanks Guys, in particular to the in depth explanation, I will print these out and eat them and feed back with the bits I'm still lost on, there will still be some, I bet!!!!Thanks againDave

##### Share on other sites

As promised, I'm back, all!!!!I understand the broad concept that you are trying to explain, its the finer details that I don't understand, hope that isn't a contradition!!!Do the numbers (-30083 0 12986) draw a line that determines the seperation plane. I don't understand the relationship of the numbers to one another------------------------------------------------------------------->30083 0 12986 are the coordinates of the vector. They define a >direction. The numbers could be as well:>-15041 0 6493-------------------------------------------------------------------assumably the No's (15041 0 6493) draw a line at a different angleHow would I ensure that the poly is visable from both sidesI should tress I use FSDS v1, but am trying to learn my own code writingIt seems we could talk for ever about differnt comands and their effect on frame ratesI have read the tutorial at Mat's site by Andreas Klisch, but more often than not, I find myself staring at the scacmd1-3 doc's.Here is some simple code=====================================================================bjId( 0013CC70 0013CC6E 00517344 4D416412 ) LibObj( PWR 100 SIZE 0 SCALE 0.1 TYPE 0x203 NAME HEDGE ) LoadBitmap( 0 6 E0 16 64 16 hedge.bmp ) VecPoints( a 0 -5 0 1 ; 0 -5 10 1 ; 1 5 10 1 ; 2 5 0 1 ; 3 ) ShadedTexPoly( m 0 0 32767 0.00 000 000 000 ; 0 001 000 255 ; 1 002 255 255 ; 2 003 255 000 ; 3 ) :endEndObj ; End of LibraryObject=====================================================================Please excuse the formattingobviously the "a" is in for automactic calculation of vectors, but what might be the manual No's. Are their enough commands for the polygon to be double sided!!!!I would aapreciate further support, think Iam ccompiling Bgl's in my sleep at the moment, trial and error experiemtsRegardsDave

##### Share on other sites

>Do the numbers (-30083 0 12986) draw a line that determines >the seperation plane. I don't understand the relationship >of the numbers to one another There are the vector of the polygon. See it as a line perpendicular on the polygon. And they determine which part of the polygon is visible (by pointing in that direction).For the vectors of the VecPoints it's ofcourse a bit different (it are points then and not polygons, but the idea is the same).>assumably the No's (15041 0 6493) draw a line at a different >angle If you meant to write (-15041 0 6493) then the angle is the same (only the values are divided by 2). Without the minus there is ofcourse a difference.For double sided polygons you need to repeat the ShadedTexPoly. So you would get:

`ShadedTexPoly( m 0 0 32767	0.00 000 000 000; 0 001 000 255; 1 002 255 255; 2 003 255 000; 3 ) ShadedTexPoly( m 0 0 -32767	0.00 000 000 000; 0 001 000 255; 1 002 255 255; 2 003 255 000; 3 )`

for a both sided version.And don't forget the Return after the label :end, you need to end a library object with a Return.And maybe it is better if you start learning the new FP commands instead of these old ones?Arno

##### Share on other sites

Thanks Arno>assumably the No's (15041 0 6493) draw a line at a different VecPoints( m 0-7 0 0 -32767 0 0 ; 0-7 10 0 -18790 26843 0 ; 1 7 10 0 18790 26843 0 ; 2 7 0 0 32767 0 0 ; 3)sorry about formattingI understand what the numbers represent, as you explained, its what -32767 means to -18790 and like wise to 26843Are the first two minus numbers (-32767/-18790) related to the -7 co-ordinates, or is this just coincidentalWhat are the Fp commands, is this to do Gmax?Thanks for the tipsDave

##### Share on other sites

>I understand what the numbers represent, as you explained, >its what -32767 means to -18790 and like wise to 26843Not sure what you mean here. You must have a normalized vector and the length of the vector should always be 32767 (that's the maximum value of an integer in SCASM). If you do (18790^2+26843^2)^0.5 then you'll see that that is also 32767.>Are the first two minus numbers (-32767/-18790) related to >the -7 co-ordinates, or is this just coincidental Can be coincidence. You could have a negative coordinate, but still want the vector pointing to the other side.>What are the Fp commands, is this to do Gmax? That are the new floating point commands from Fs2002. GMax also makes them (in BGLC), but you can also make them with SCASM. FSDS2 for example also produces them. If all rumours are true then you will only be able to use them in the future, so I think it is better to invest in them now :).Arno

##### Share on other sites

Hi ArnoUnderstanding the formula that you explained, has helped to understand what these numbers represent. However, I think my ability to create these vectors, manually, myself, are beyond my ability. But having a better understanding, has to help!!!Thanks for the explanation of the Fp commands, I looked at the Scasm doc's and could only find new28x.doc, which I don't think refers to these commands you refer toI would appreciate any links to these new commands, is it in the SDK?thanks for your continued supportDave

##### Share on other sites

You have found the correct document :).To draw polygons with the new commands you would need the following commands:VertexList, MaterialList, TextureList, SetMaterial, DrawTriList.Arno

##### Share on other sites

thanks Arno, that was quick!also see their is reference, in the SDK, to fpthanks again

##### Share on other sites

Yes, there also is a FP SDK, but that is more of help if you want to write the code in BGLC.Arno

## Create an account

Register a new account

• Tom Allensworth,
Founder of AVSIM Online

• ### Hot Spots

• Flight Simulation's Premier Resource!

AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!