LOGO-L> Shuttle in UCBLogo 
Author Message
 LOGO-L> Shuttle in UCBLogo

;Hello Brian Harvey
;Here is the Shuttle Example which George Mills supplied with
;MSWLogo.The only modification needed to run it under UCBLogo was
;to add the setxyz procedure.
;the example uses the same shuttle.3dv data file, since timemilli
;is not supported by UCBLogo it was commented.
;Best Regards
;Mhelhefny
;---------------------------------------
to go
; This example is modefied to run under UCBLogo, originally it is
; supplied as an example of MSWLogo , thanks to George Mills.
; it uses the same file shuttle.3dv for data needed to draw.
; (Mhelhefny)
; ...............................................
; This is a MSWLogo 3D example where I have written a simple ".3DV"
; file viewer. 3DV is a simple public domain format for 3D Vectors.
;
; Do not confuse how this "Shuttle" database was built.
;   The vectors were not built with MSWLogo (although they could be).
; Do not confuse how you "normally" build 3D objects in MSWLogo.
;   You normally build 3D object just like you always built them
;   in 2D, by moving the turtle around.
;
; This example was just done for a completeness test. The data is
; absolute and uses SETXYZ for all drawing. No turtle.
;
; It's a good example of how to use file and Array operations.
;
; It's also an example of seeing how I took "foreign" data from the
; internet and used it in logo. There is TONS of "data" out their.
; Mars weather statistics, continental drift statistics, etc. that
; can be used for all sorts of projects.
;
shuttle
end

to object_display
local "vtx
local "cmd
repeat :commands ~
   [
   ; Get a command. Format [VertexIndex Color] Color = 0 means "Move"
   make "cmd (item repcount :command)

   ; Get the vertex. Format [X Y Z]
   make "vtx (item (item 1 :cmd) :vertex)

   ; If color 0 then Move else Draw (I'm ingoring the color, not RGB Yuck)
   ifelse (item 2 :cmd) = 0 [pu] [pd]
ifelse repcount>403 [setpc 6][setpc 4]
   ; Move or draw to the vertex
   setxyz (item 1 :vtx)/ 85 (item 2 :vtx)/ 85 (item 3 :vtx)/ 85
   ]
end

to object_load :file
; Start in known state
closeall

; Open Vectors Commands
openread :file
setread :file

; Get # of vertices (1st record of file)
make "vertices first readlist

; Now build a "Vertex" array based on # of vertices
make "vertex (array :vertices 1)

; Now read in each "Vertex". Format [X Y Z]
repeat :vertices [setitem repcount :vertex readlist]

; Get # of "commands" (comes after all vertices)
make "commands first readlist

; Now build a "Command" array based on # of commands
make "command (array :commands 1)

; Now read in each "Command". Format [Vertex_Index Color]
repeat :commands [setitem repcount :command readlist]

; Done
setread []
close :file
end

to setxyz :a :b :c
;library procedure
setxy (:a- :c)*cos 30 :b- (:a+ :c)*sin 30
end

to shuttle
local "start
local "finish
ht
cs

; Load Shuttle Vectors
object_load "shuttle.3dv

; Time and Display Shuttle
cs
;make "start timemilli
object_display
;make "finish (timemilli - :start) / 600

; It takes about 3 seconds on a P133
;show (sentence :commands "3D "Commands "in :finish "seconds)
end
;-------------------------------------------------
---------------------------------------------------------------





Tue, 25 Apr 2000 03:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. LOGO-L> Orginal Shuttle (SETXYZ) Example

2. LOGO-L> 3D SHUTTLE

3. LOGO-L> GUI for UCBLogo

4. LOGO-L> About UCBlogo

5. LOGO-L> pure glass shapes in UCBLogo

6. LOGO-L> About UCBlogo

7. LOGO-L> 3d extensions to UCBLogo

8. LOGO-L> setxyz and screw in UCBLogo

9. LOGO-L> ellipsoid and paraboloid in UCBLogo

10. LOGO-L> 3d isometric code in UCBLogo

11. LOGO-L> the snail in UCBLogo

12. LOGO-L> 3 d extensions to UCBLogo

 

 
Powered by phpBB® Forum Software