Article View: comp.lang.c
Article #1592Re: [p.i.c] ships flyin and faitin
From: Ross Finlayson
Date: Mon, 16 Nov 2026 20:10
Date: Mon, 16 Nov 2026 20:10
116 lines
4890 bytes
4890 bytes
On 11/16/2026 11:37 AM, fir wrote:
> i toy with this 3d rasterizer and get some 3d ships (kinda like
> aeroplanes/jets but in space) and want to code them interesting flying
> behaviours
>
> maybe some will have some thoughts on it (then i eventually my try some
> ideas and post a video how it work)
>
> the api you need to code such behaviour is quite simple for example some
> basic algortihm that work is
>
> void FlyPass2(int i)
> {
> float3 player_pos=PlayerPos();
> float3 to_player=sub(player_pos,bag[i].p.pos);
> float distance=length(to_player);
> if(distance<0.001f) return;
> normalize(&to_player);
>
> if(bag[i].combat_state!='approach' && bag[i].combat_state!='pass'
> && bag[i].combat_state!='turn') bag[i].combat_state='approach';
>
> if(bag[i].combat_state=='approach')
> {
> YawPitchAccelerate(i,to_player,30/3);
> if(distance<20*150) bag[i].combat_state='pass';
> }
>
> if(bag[i].combat_state=='pass')
> {
> YawPitchAccelerate(i,to_player,60/3);
> if(distance<20*70) bag[i].combat_state='turn';
> }
>
> if(bag[i].combat_state=='turn')
> {
> float3 direction=mul(to_player,-1.0f);
> YawPitchAccelerate(i, direction, 45/3);
>
> if(distance>20*600) bag[i].combat_state='approach';
> }
> }
>
>
> if c would have basic vector arithmetic it would look better
>
> 20*600 mean 600 meters as the world 1.0 unit is like 5 cm
>
> 45/3 means 45 m/s speed -as its about 60 fps so 45/3*60 = 45*20 (45
> meters/s)
>
> YawPitchAccelerate(i, direction, 45/3);
>
> do most work it just make ship starting to yaw-pitch into given
> direction and accelerate/deacce;erate for given speed
>
> (it is handled by simple 'engine' which has limited angular and linear
> acceleration and there is also dumping factor)..
>
> here above it uses its max accelerations but eventually value from
> 0.0..1.0 can be passed if ships qould be said only use parts of its max
> accalarations
>
>
> i need good ideas what such ships can do..i not yet thought on this
> seriously (becouse it took me a time to build this setup and see what is
> the ground around that
>
> ship eventually also can make 'roll' moves and strafe moves (though im
> not sure those strafe moves i defined well, also by acceleration +
> dumping..it may be bad approach)
>
>
> one of interesting tiny algorithm i tested it yet this
>
>
>
> void Patrol(int i,float3 *points,int point_count,float speed,float
> arrival_distance)
> {
> if(!points || point_count<=0) return;
>
> int point=(int)bag[i].mode;
>
> if(point<0 || point>=point_count) point=0;
>
> float3 destination=points[point];
> float3 direction=sub(destination,bag[i].p.pos);
>
> if(length(direction)<arrival_distance)
> {
> point++;
> if(point>=point_count) point=0;
>
> bag[i].mode=(unsigned)point;
> destination=points[point];
> }
>
> FlyToward(i,destination,speed);
> }
>
>
> it just take array of 3d points and if near some then it turn to another
> and it in fact looks well...but i need some more
The "Master Execution Scheduler" with about 250+ programs
is off a bunch of main-frame scheduling routines, about
the roll-ups and the parts in carts and takt-fully.
It doesn't even have a unit of time more granular than "day",
"mdays".
Not my business.
Technical Details
Message-ID:
<CIOcna7g5YWC_mb3nZ2dnZfqnPaznMt6@giganews.com>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-4.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mailReferences:
<11dfm1u$3rhtq$1@dont-email.me>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srv.newsdeef.eu!weretis.net!feeder9.news.weretis.net!border-2.nntp.ord.giganews.com!nntp.giganews.com!Xl.tags.giganews.com!local-4.nntp.ord.giganews.com!news.giganews.com.POSTED!not-for-mail NNTP-Posting-Date: Mon, 16 Nov 2026 20:10:07 +0000 Subject: Re: [p.i.c] ships flyin and faitin Newsgroups: comp.lang.c References: <11dfm1u$3rhtq$1@dont-email.me> From: Ross Finlayson <ross.a.finlayson@gmail.com> Date: Mon, 16 Nov 2026 12:10:07 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <11dfm1u$3rhtq$1@dont-email.me> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <CIOcna7g5YWC_mb3nZ2dnZfqnPaznMt6@giganews.com> Lines: 116 X-Usenet-Provider: http://www.giganews.com X-Trace: sv3-9NbozU+C1oc9WK9PhXdV1R82hkpw5Y0sZXCt6MshzYERfWprQcrM3jIdg8OVWVld9v1Va2jKzEN7hrV!jPUDr2DD2kxolM9qInu+b8Voeqz4Jt/LP2+ZMCf+/JVJVE4RHgLQMDWqt6HYKy3es3BtNjruAwx3 X-Complaints-To: abuse@giganews.com X-DMCA-Notifications: http://www.giganews.com/info/dmca.html X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40