* [9fans] Attempt at making 3D graphics library
@ 2007-11-24 3:43 Pietro Gagliardi
2007-11-24 6:57 ` Paul Lalonde
` (3 more replies)
0 siblings, 4 replies; 11+ messages in thread
From: Pietro Gagliardi @ 2007-11-24 3:43 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
Hello. I realized that that last /usr/glenda/bin/rc/pull focused on a
rewrite to the system libraries. I decided to start writing a library
to convert 3D coordinates to 2D coordinates based on the data at
http://www.shade.ca/getarticle.asp?i=11. You can find it at /n/
sources/contrib/pietro/3d.bundle. It contains: 3d.h (the header),
3d.c (the library itself), and 3dtest.c (a test program). The test
program doesn't seem to work right. It looks like the 2D coordinates
are way off the charts - the x coordinates are between 500 and 600
for xyz=(5,5,5)! I wonder... This makes the line a stub in the center
of a 1024x768 screen. Plus, the threadmain crashes on threadexitsall.
What's going on?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] Attempt at making 3D graphics library
2007-11-24 3:43 [9fans] Attempt at making 3D graphics library Pietro Gagliardi
@ 2007-11-24 6:57 ` Paul Lalonde
2007-11-24 14:19 ` Pietro Gagliardi
2007-11-24 7:11 ` anyrhine
` (2 subsequent siblings)
3 siblings, 1 reply; 11+ messages in thread
From: Paul Lalonde @ 2007-11-24 6:57 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
It's hard to tell what might be wrong with your transformation if you
don't also show the transformation matrix you are using, including
the camera parameters. What you probably want is for your transform
to go from some world space coordinates (your 5,5,5) to screen
space. It's also not clear if you are expecting device coordinates
(0..1023, 0..767) or normalized coordinates (0..1, 0..1). Your
resulting coordinates aren't too far off for some camera vaguely
pointing at the origin and a device coordinate transformation matrix.
Paul
On 23-Nov-07, at 7:43 PM, Pietro Gagliardi wrote:
> Hello. I realized that that last /usr/glenda/bin/rc/pull focused on
> a rewrite to the system libraries. I decided to start writing a
> library to convert 3D coordinates to 2D coordinates based on the
> data at http://www.shade.ca/getarticle.asp?i=11. You can find it
> at /n/sources/contrib/pietro/3d.bundle. It contains: 3d.h (the
> header), 3d.c (the library itself), and 3dtest.c (a test program).
> The test program doesn't seem to work right. It looks like the 2D
> coordinates are way off the charts - the x coordinates are between
> 500 and 600 for xyz=(5,5,5)! I wonder... This makes the line a stub
> in the center of a 1024x768 screen. Plus, the threadmain crashes on
> threadexitsall. What's going on?
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)
iD8DBQFHR8tTpJeHo/Fbu1wRAsrrAKC6Bmdz31+VYVSEGWRiGRkD133Y7QCgmCzS
56gVAizyJ4ndkHWUIixuJ1k=
=PMob
-----END PGP SIGNATURE-----
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] Attempt at making 3D graphics library
2007-11-24 6:57 ` Paul Lalonde
@ 2007-11-24 14:19 ` Pietro Gagliardi
0 siblings, 0 replies; 11+ messages in thread
From: Pietro Gagliardi @ 2007-11-24 14:19 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
On Nov 24, 2007, at 1:57 AM, Paul Lalonde wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> It's hard to tell what might be wrong with your transformation if
> you don't also show the transformation matrix you are using,
> including the camera parameters. What you probably want is for
> your transform to go from some world space coordinates (your 5,5,5)
> to screen space. It's also not clear if you are expecting device
> coordinates (0..1023, 0..767) or normalized coordinates (0..1,
> 0..1). Your resulting coordinates aren't too far off for some
> camera vaguely pointing at the origin and a device coordinate
> transformation matrix.
>
> Paul
>
>
I was using no transformation matrix. I'm also thinking I'm getting
the screen width and height wrong. Either way, there are formulae in
the middle of that article, reproduced here:
.EQ
x sub { 2d } -> x sub { 3d } * { N over z } + { { screenwidth } over 2 }
.EN
.EQ
y sub { 2d } -> y sub { 3d } * { N over z } + { { screenwidth } over 2 }
.EN
It also says at the top that z=N and because equivalence is
bidirectional that N=z. I do expect device coordinates.
I remember a while back about a discussion on 3D graphics
programming. Andrey said that OpenGL was ported a long time ago but
was never tied to rio or 8 1/2. He also said that it would be doable
but difficult via APE. Unfortunately, I don't know how to program
OpenGL, and by the code I've seen to produce a single object in a
display I'm afraid of approaching it. I was hoping my simple point
conversion mechanism would light a spark. Guess I'll try again later :-)
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] Attempt at making 3D graphics library
2007-11-24 3:43 [9fans] Attempt at making 3D graphics library Pietro Gagliardi
2007-11-24 6:57 ` Paul Lalonde
@ 2007-11-24 7:11 ` anyrhine
2007-11-24 16:42 ` Pietro Gagliardi
2007-11-24 15:57 ` Pietro Gagliardi
2007-12-03 2:54 ` Pietro Gagliardi
3 siblings, 1 reply; 11+ messages in thread
From: anyrhine @ 2007-11-24 7:11 UTC (permalink / raw)
To: 9fans
> I decided to start writing a library
> to convert 3D coordinates to 2D coordinates based on the data at
> http://www.shade.ca/getarticle.asp?i=11. You can find it at /n/
> sources/contrib/pietro/3d.bundle. It contains: 3d.h (the header),
> 3d.c (the library itself), and 3dtest.c (a test program).
did't check the bugs nor the article, so i hope i'm not entirely
off here. there is already libgeometry, described in matrix(2),
will do the job for you. it does what 3d engines do, except
clipping and rendering.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] Attempt at making 3D graphics library
2007-11-24 7:11 ` anyrhine
@ 2007-11-24 16:42 ` Pietro Gagliardi
0 siblings, 0 replies; 11+ messages in thread
From: Pietro Gagliardi @ 2007-11-24 16:42 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
On Nov 24, 2007, at 2:11 AM, anyrhine@gmail.com wrote:
>> I decided to start writing a library
>> to convert 3D coordinates to 2D coordinates based on the data at
>> http://www.shade.ca/getarticle.asp?i=11. You can find it at /n/
>> sources/contrib/pietro/3d.bundle. It contains: 3d.h (the header),
>> 3d.c (the library itself), and 3dtest.c (a test program).
>
> did't check the bugs nor the article, so i hope i'm not entirely
> off here. there is already libgeometry, described in matrix(2),
> will do the job for you. it does what 3d engines do, except
> clipping and rendering.
This library has Point3, which is Point3D with an object w that is
the denominator to (x,y,z) in the final point. I didn't need this, so
I made it 1 in my local copy and changed all Point3Ds to Point3s. The
3D library now uses libgeometry and will have a box drawing facility
the next update.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] Attempt at making 3D graphics library
2007-11-24 3:43 [9fans] Attempt at making 3D graphics library Pietro Gagliardi
2007-11-24 6:57 ` Paul Lalonde
2007-11-24 7:11 ` anyrhine
@ 2007-11-24 15:57 ` Pietro Gagliardi
2007-11-24 16:00 ` andrey mirtchovski
2007-12-03 2:54 ` Pietro Gagliardi
3 siblings, 1 reply; 11+ messages in thread
From: Pietro Gagliardi @ 2007-11-24 15:57 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
I got it all to work now using the 3DMOL code, converted from C++ to C.
mkdir 3d # download
cd 3d
rc /n/sources/contrib/pietro/3d.bundle
8c 3d.c # compile
8c 3dtest.c
8l -o 3dtest *.8
3dtest # run
You can see a cube in the center of the screen. Use q to quit (and
crash, for some threadexitsall-related reason). This could be the
first step to a new 3D engine in C for Plan 9 - or for any system.
I'll give them my regards now.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] Attempt at making 3D graphics library
2007-11-24 15:57 ` Pietro Gagliardi
@ 2007-11-24 16:00 ` andrey mirtchovski
2007-11-24 16:21 ` Pietro Gagliardi
0 siblings, 1 reply; 11+ messages in thread
From: andrey mirtchovski @ 2007-11-24 16:00 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
> Use q to quit (and
> crash, for some threadexitsall-related reason).
that usually means you need a bigger stack for your threads.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] Attempt at making 3D graphics library
2007-11-24 16:00 ` andrey mirtchovski
@ 2007-11-24 16:21 ` Pietro Gagliardi
2007-11-24 22:48 ` Federico G. Benavento
0 siblings, 1 reply; 11+ messages in thread
From: Pietro Gagliardi @ 2007-11-24 16:21 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
On Nov 24, 2007, at 11:00 AM, andrey mirtchovski wrote:
>> Use q to quit (and
>> crash, for some threadexitsall-related reason).
>
> that usually means you need a bigger stack for your threads.
Setting both threads to 4096 stacksize fixed it. I'll note that in my
tutorial. I used one thread to interpret mouse events, since for some
odd reason eresized() is sent through the mouse. :-(
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] Attempt at making 3D graphics library
2007-11-24 16:21 ` Pietro Gagliardi
@ 2007-11-24 22:48 ` Federico G. Benavento
2007-12-30 16:33 ` Pietro Gagliardi
0 siblings, 1 reply; 11+ messages in thread
From: Federico G. Benavento @ 2007-11-24 22:48 UTC (permalink / raw)
To: 9fans
[-- Attachment #1: Type: text/plain, Size: 183 bytes --]
You're not supposed to combine event(2) with thread(2).
See mouse(2).
Federico G. Benavento
---
/bin/fortune:
Steal money you're a thief: steal a country you're a king.
[-- Attachment #2: Type: message/rfc822, Size: 4030 bytes --]
From: Pietro Gagliardi <pietro10@mac.com>
To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>
Subject: Re: [9fans] Attempt at making 3D graphics library
Date: Sat, 24 Nov 2007 11:21:57 -0500
Message-ID: <9BD59CB3-3F41-415B-AC30-39773DDF99C2@mac.com>
On Nov 24, 2007, at 11:00 AM, andrey mirtchovski wrote:
>> Use q to quit (and
>> crash, for some threadexitsall-related reason).
>
> that usually means you need a bigger stack for your threads.
Setting both threads to 4096 stacksize fixed it. I'll note that in my
tutorial. I used one thread to interpret mouse events, since for some
odd reason eresized() is sent through the mouse. :-(
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] Attempt at making 3D graphics library
2007-11-24 22:48 ` Federico G. Benavento
@ 2007-12-30 16:33 ` Pietro Gagliardi
0 siblings, 0 replies; 11+ messages in thread
From: Pietro Gagliardi @ 2007-12-30 16:33 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
Then how do you check for the window resized event? I heard from IRC
#plan9 that resize events are sent through /dev/mouse, so the
following code is the event(2) way of ensuring resize events get done:
for (;;)
if (ecanmouse())
emouse();
On Nov 24, 2007, at 5:48 PM, Federico G. Benavento wrote:
> You're not supposed to combine event(2) with thread(2).
>
> See mouse(2).
>
>
> Federico G. Benavento
>
> ---
> /bin/fortune:
> Steal money you're a thief: steal a country you're a king.
>
> From: Pietro Gagliardi <pietro10@mac.com>
> Date: November 24, 2007 11:21:57 AM EST
> To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>
> Subject: Re: [9fans] Attempt at making 3D graphics library
> Reply-To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu>
>
>
>
> On Nov 24, 2007, at 11:00 AM, andrey mirtchovski wrote:
>
>>> Use q to quit (and
>>> crash, for some threadexitsall-related reason).
>>
>> that usually means you need a bigger stack for your threads.
> Setting both threads to 4096 stacksize fixed it. I'll note that in
> my tutorial. I used one thread to interpret mouse events, since for
> some odd reason eresized() is sent through the mouse. :-(
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [9fans] Attempt at making 3D graphics library
2007-11-24 3:43 [9fans] Attempt at making 3D graphics library Pietro Gagliardi
` (2 preceding siblings ...)
2007-11-24 15:57 ` Pietro Gagliardi
@ 2007-12-03 2:54 ` Pietro Gagliardi
3 siblings, 0 replies; 11+ messages in thread
From: Pietro Gagliardi @ 2007-12-03 2:54 UTC (permalink / raw)
To: Fans of the OS Plan 9 from Bell Labs
Is there any purpose in qball(2) being in the 3D engine instead of my
hit-and-run rotation system which I am unsure of?
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2007-12-30 16:33 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-24 3:43 [9fans] Attempt at making 3D graphics library Pietro Gagliardi
2007-11-24 6:57 ` Paul Lalonde
2007-11-24 14:19 ` Pietro Gagliardi
2007-11-24 7:11 ` anyrhine
2007-11-24 16:42 ` Pietro Gagliardi
2007-11-24 15:57 ` Pietro Gagliardi
2007-11-24 16:00 ` andrey mirtchovski
2007-11-24 16:21 ` Pietro Gagliardi
2007-11-24 22:48 ` Federico G. Benavento
2007-12-30 16:33 ` Pietro Gagliardi
2007-12-03 2:54 ` Pietro Gagliardi
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).