home *** CD-ROM | disk | FTP | other *** search
/ Stars of Shareware: Raytrace & Morphing / SOS-RAYTRACE.ISO / programm / scripts / vivid / backmap / map.bas < prev    next >
Encoding:
BASIC Source File  |  1993-08-30  |  1.6 KB  |  55 lines

  1. REM Program to create VIVID compatible .MAP files
  2. REM *********************************************
  3. REM Paul Smith - Raytech BBS - +44 862 88340
  4. REM *********************************************
  5. REM Raytracing support in the UK !
  6.  
  7. CLS
  8. PRINT "MAP V0.5 by Paul Smith - Raytech BBS - +44 862 88340"
  9. PRINT
  10. PRINT "Creates a smoothly shaded .MAP file for Vivid or Fractint"
  11. PRINT
  12. PRINT
  13. INPUT "Enter output file name :"; F$
  14. INPUT "Enter number of control points :"; P
  15. P = P - 1
  16. DIM CP(P, 4)
  17. FOR D = 0 TO P
  18. IF D = 0 THEN PRINT "Assuming control point at 0": CP(D, 0) = 0: GOTO ASSUME
  19. IF D = P THEN PRINT "Assuming control point at 255": CP(D, 0) = 255: GOTO ASSUME
  20. PRINT "Enter position for control point number"; D;
  21. INPUT ""; CP(D, 0)
  22. ASSUME:
  23. NEXT D
  24. FOR D = 0 TO P
  25. PRINT "Enter R,G,B triple for control point at position"; CP(D, 0);
  26. INPUT ""; CP(D, 1), CP(D, 2), CP(D, 3)
  27. NEXT D
  28.  
  29. REM Sort array into ascending order here if required.
  30. REM At present the program depends on having control points
  31. REM in logical ascending order.
  32.  
  33. OPEN F$ FOR OUTPUT AS #1
  34.  
  35. FOR S = 0 TO P - 1: REM step through segments (i.e. between control points)
  36. SP = CP(S + 1, 0) - CP(S, 0): REM calculate Points in the Segment
  37. RI = (CP(S + 1, 1) - CP(S, 1)) / SP: REM calculate Red Interval for this segment
  38. GI = (CP(S + 1, 2) - CP(S, 2)) / SP: REM calculate Green Interval for this segment
  39. BI = (CP(S + 1, 3) - CP(S, 3)) / SP: REM calculate Blue Interval for this segment
  40.  
  41. FOR N = 0 TO SP - 1: REM step through individual output triples.
  42. PRINT #1, INT(RI * N) + CP(S, 1);
  43. PRINT #1, INT(GI * N) + CP(S, 2);
  44. PRINT #1, INT(BI * N) + CP(S, 3)
  45. NEXT N, S
  46.  
  47. CLOSE #1
  48.  
  49. SYSTEM
  50.  
  51.  
  52.  
  53.  
  54.  
  55.