[futurebasic] [FB] 3D Object Rendering with Materials

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : October 2001 : Group Archive : Group : All Groups

From: "Ashley Butterworth" <macbse@...>
Date: Wed, 31 Oct 2001
Hi All,
  I have a program ( same as the one in GWorld Blues) that draws in 3D. I have two questions at the moment.

  1. What formula do I use for translating a 3D point to a 2D point? I am currently using:
'3D to 2D Transformation
xOut = (XYZX# + XYZY#*cos(pi#/6)) : yOut = -(XYZZ# + XYZY#*sin(pi#/6))'Screen Coords

  2. I have some world maps that I would like to render onto a sphere. The code below is what I currently use to plot all 3D points. What do I need to do to make a version that will draw the globe. I am using GWorlds and all the coordinates are scalled down from it's real size to screen size before it is passed into this function. The sphere is a real size Earth. All coordinates are in the scale of 1 pixel is 1Km.

local fn PlotXYZ(XYZX#,XYZY#,XYZZ#,xRot#,yRot#,zRot#)
'X Rotation
Y# = XYZY# : Z# = XYZZ#
XYZY# = Y# * cos(xRot#) - Z# * sin(xRot#)
XYZZ# = Y# * sin(xRot#) + Z# * cos(xRot#)

'Y Rotation
X# = XYZX# : Z# = XYZZ#
XYZX# = X# * cos(yRot#) - Z# * sin(yRot#)
XYZZ# = X# * sin(yRot#) + Z# * cos(yRot#)

'Z Rotation
X# = XYZX# : Y# = XYZY#
XYZX# = X# * cos(zRot#) - Y# * sin(zRot#)
XYZY# = X# * sin(zRot#) + Y# * cos(zRot#)

'3D to 2D Transformation
xOut = (XYZX# + XYZY#*cos(pi#/6)) : yOut = -(XYZZ# + XYZY#*sin(pi#/6))'Screen Coords
pen _Map3Bound/275,_Map3Bound/275
plot xOut,yOut
end fn

  Thanks in advance,

  Ashley ~)~

=============================================================
Ashley Butterworth
Email: macbse@...
=============================================================


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com