Board index » delphi » HELP with 3D Graphics !

HELP with 3D Graphics !

Hello out there ...

This is a problem that I have been trying to solve for a long, long time.
I am trying to create 3D graphics like in a CAD program - In which I
define a points (X,Y,Z) coordinates and then calculate the points (X,Y)
location on the screen in relation to rotation of the (X,Y,Z) accesses.
The Equations I got were very complicated (Sin,Cos...) and do not work !

Does any body know the Equations I am looking for ? Were can I find them?

The truth is out there...

                                        Thanks Lesley.

 

Re:HELP with 3D Graphics !


On Mon, 27 May 1996 16:37:25 GMT, les...@techunix.technion.ac.il

Quote
(Price Lesley) wrote:

>Hello out there ...

>This is a problem that I have been trying to solve for a long, long time.
>I am trying to create 3D graphics like in a CAD program - In which I
>define a points (X,Y,Z) coordinates and then calculate the points (X,Y)
>location on the screen in relation to rotation of the (X,Y,Z) accesses.
>The Equations I got were very complicated (Sin,Cos...) and do not work !

>Does any body know the Equations I am looking for ? Were can I find them?

>The truth is out there...

>                                    Thanks Lesley.

Hi!
Try these: NewX:=(OldX*Des)/(OldZ+Des);
                     NewY:=(OldY*Des)(OldZ+Des);

Des is a const that defines the location of the Observor.
Const Des=512 should work fine.

when you plot the pixel, make the (0,0,0) point at the middle of the
screen: (MidX+X,MidY-Y).

That's all there is to it!!

Basically you just divide x and y with the z coordinate, and thus as z
grows, the object is further away.

Hope it helps, and if you want i also got some codes...
Ravid Rosen-Tal
ra...@ibm.net

Re:HELP with 3D Graphics !


Quote
On Mon, 27 May 1996, Price Lesley wrote:

> Hello out there ...

> This is a problem that I have been trying to solve for a long, long time.
> I am trying to create 3D graphics like in a CAD program - In which I
> define a points (X,Y,Z) coordinates and then calculate the points (X,Y)
> location on the screen in relation to rotation of the (X,Y,Z) accesses.
> The Equations I got were very complicated (Sin,Cos...) and do not work !

> Does any body know the Equations I am looking for ? Were can I find them?

> The truth is out there...

>                                    Thanks Lesley.

3D transformation functions
---------------------------

Let there is a screen and a point of view, and the distance between them
in pixels is E (which may be f.ex., 256 or 512 - comparable with screen
dimensions). Then, if you have a point (X,Y,Z) somewhere behind the
screen, the transformation is performed as follows:

         X * E                     Y * E
  X' = ---------    and     Y' = ---------
         Z + E                     Z + E

Now, Pascal code:

uses
  Graph,    { for PutPixel }
  Objects;  { for LongMul and LongDiv }

const
  E = 256;

function DeepX(X, Z: Integer): Integer;
begin
  if Z >= -(E div 2)
    DeepX := LongDiv(LongMul(X, E), Z + E)
  else
    DeepX := X * 2;  { protected from divide overflow }
end;

function DeepY(Y, Z: Integer): Integer;
begin
  if Z >= -(E div 2)
    DeepY := LongDiv(LongMul(Y, E), Z + E)
  else
    DeepY := Y * 2;  { protected from divide overflow }
end;

procedure Put3dPixel(X, Y, Z, Color: Integer);
begin
  PutPixel(DeepX(X, Z), DeepY(Y, Z), Color);
end;

I've written a unit with many other useful (and very fast!) transformation
functions, such as scaling, rotation, distance comparison, etc.,
everything in integers. If you are interested in it, contact me at
ho...@jerewan1.yerphi.am.

Bye,
Hovik.

Re:HELP with 3D Graphics !


In article <Ds2ouD....@discus.technion.ac.il>
           les...@techunix.technion.ac.il "Price Lesley" writes:

Quote

> Hello out there ...

Hello in there? (Is it dark where you are?)

Quote

> This is a problem that I have been trying to solve for a long, long time.
> I am trying to create 3D graphics like in a CAD program - In which I
> define a points (X,Y,Z) coordinates and then calculate the points (X,Y)
> location on the screen in relation to rotation of the (X,Y,Z) accesses.
> The Equations I got were very complicated (Sin,Cos...) and do not work !

> Does any body know the Equations I am looking for ? Were can I find them?

> The truth is out there...

But only when it isn't cold, otherwise it's in here in the warm!

Quote
>                                         Thanks Lesley.

Still, seriously, I think I can help a little.
I have a set of documentation bit's 'n' bobs called the PCGPE.
It is currently in version 1.0 and is avalable from:

 ftp://ftp.teeri.oulu.fi/pub/msdos/programming/gpe/

(If i'm not mistaken.)

This contains many useful graphics & sound information, including
two or three bits on 3d, and even a TUTE which includes all sorts
of VGA info in Pascal.

Good luck, and keep me posted!

--
Daniel Silverstone
..Tag! You're it!

Re:HELP with 3D Graphics !


Thank you for coming to my rescue...

I am really interested in your UNIT, it is probably just what I am looking
for. If you are willing to Email it to me I would be grateful.

My Email Address is: les...@tx.technion.ac.il

Thanks Lesley.

P.S.
If you do decide to Email the file across, don't forget to compress
and BinHex it.

Re:HELP with 3D Graphics !


In article <Ds2ouD....@discus.technion.ac.il>, les...@techunix.technion.ac.il
says...

Quote

>Hello out there ...

>This is a problem that I have been trying to solve for a long, long time.
>I am trying to create 3D graphics like in a CAD program - In which I
>define a points (X,Y,Z) coordinates and then calculate the points (X,Y)
>location on the screen in relation to rotation of the (X,Y,Z) accesses.
>The Equations I got were very complicated (Sin,Cos...) and do not work !

>Does any body know the Equations I am looking for ? Were can I find them?

>The truth is out there...

>                                        Thanks Lesley.

You might want to make Z a function of size, for instance, if we have a line,
coming at ya from an angle, you mage bigger and bigger dots as Z gets larger
or whatever.

I cant figure em out off the top of my head, but try drawing a picture of a
cube, and trigonometry will definitely be involed.  Try asking a teacher if
your in school
--
thec...@iconn.net
"It can't rain all the time"
RSA ENCRYPTION IN 3 LINES OF PERL
---------------------------------------------------------
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)

Other Threads