Skip to content

Commit 86f4639

Browse files
author
chris20
committed
Initial import
0 parents  commit 86f4639

File tree

9,553 files changed

+1415983
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

9,553 files changed

+1415983
-0
lines changed

LICENSE

+661
Large diffs are not rendered by default.

changes.txt

+3,163
Large diffs are not rendered by default.

distribution/agpl-3.0.txt

+661
Large diffs are not rendered by default.

distribution/include/Mount1.png

14.7 KB
Loading

distribution/include/Mount2.png

18 KB
Loading

distribution/include/arrays.inc

+215
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,215 @@
1+
// This work is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported License.
2+
// To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/3.0/ or send a
3+
// letter to Creative Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.
4+
5+
// Persistence of Vision Ray Tracer version 3.5 Include File
6+
// File: arrays.inc
7+
// Last updated: May 7 2002
8+
// Description: Array manipulation macros...sorting, resizing, etc.
9+
10+
#ifndef(ARRAYS_INC_TEMP)
11+
#declare ARRAYS_INC_TEMP = version;
12+
#version 3.5;
13+
14+
#ifdef(View_POV_Include_Stack)
15+
#debug "including arrays.inc\n"
16+
#end
17+
18+
// Input: a one dimensional array and a random stream
19+
// Output: a random item from the input array
20+
// Source: variate.inc by Ingo Janssen
21+
#macro Rand_Array_Item(Array, Stream)
22+
#if(dimensions(Array)=1)
23+
Array[floor(rand(Stream)*0.9999999*dimension_size(Array,1))]
24+
#else
25+
#error "The Rand_Array_Item() macro only works for 1D arrays."
26+
#end
27+
#end
28+
29+
30+
#macro Resize_Array(Array, NewSize)
31+
#if(dimensions(Array)=1)
32+
#local NewArray = array[NewSize]
33+
#local C = 0;
34+
#local Max = min(NewSize, dimension_size(Array, 1));
35+
#while (C < Max)
36+
#ifdef (Array[C])
37+
#local NewArray[C] = Array[C];
38+
#end
39+
#local C = C + 1;
40+
#end
41+
#declare Array = NewArray
42+
#else
43+
#error "The Resize_Array() macro only works for 1D arrays."
44+
#end
45+
#end
46+
47+
48+
#macro Reverse_Array(Array)
49+
#if(dimensions(Array)=1)
50+
#local J = 0;
51+
#local N = dimension_size(Array, 1) - 1;
52+
#while(J < N/2)
53+
#local Temp = Array[J];
54+
#local Array[J] = Array[N-J];
55+
#local Array[N-J] = Temp;
56+
#local J = J + 1;
57+
#end
58+
#else
59+
#error "The Reverse_Array() macro only works for 1D arrays."
60+
#end
61+
#end
62+
63+
64+
// #macro Insert_In_Array(Item, DestArray, Index)
65+
// #macro Insert_Array_In_Array(ItemArray, DestArray, Index)
66+
67+
// #macro Append_To_Array(Item, DestArray, Index)
68+
// #macro Append_Array_To_Array(ItemArray, DestArray, Index)
69+
70+
// This macro will compare float values and vector lengths.
71+
// It is intended to be redefined by the user to suit their
72+
// needs, but it should always return true if A is "less than"
73+
// B, otherwise false.
74+
// #macro SortCompare(A, B) (vlength(A) < vlength(B)) #end
75+
// #macro SortCompare(Array, IdxA, IdxB) (vlength(Array[IdxA]) < vlength(Array[IdxB])) #end
76+
#macro Sort_Compare(Array, IdxA, IdxB) (Array[IdxA] < Array[IdxB]) #end
77+
78+
// This macro swaps the data in two locations. The user can
79+
// redefine it, for example to swap additional data along a
80+
// second dimension, keeping columns of data together.
81+
#macro Sort_Swap_Data(Array, IdxA, IdxB)
82+
#local Tmp = Array[IdxA];
83+
#declare Array[IdxA] = Array[IdxB];
84+
#declare Array[IdxB] = Tmp;
85+
#end
86+
87+
88+
// Sort macros slightly modified from QuickSort macros by Juha Nieminen
89+
#macro Sort_Array(Array)
90+
Sort_Partial_Array(Array, 0, dimension_size(Array, 1)-1)
91+
#end
92+
93+
#macro Sort_Partial_Array(Array, FirstInd, LastInd)
94+
ARRAYS_HybridQuickSortStep(Array, FirstInd, LastInd)
95+
ARRAYS_InsertionSort(Array, FirstInd, LastInd)
96+
#end
97+
98+
#declare ARRAYS_QuickSortSeed = seed(0);
99+
100+
#macro ARRAYS_HybridQuickSortStep(Array, FirstInd, LastInd)
101+
#local FInd = FirstInd;
102+
#while(FInd < LastInd-10)
103+
#local RInd = FInd + rand(ARRAYS_QuickSortSeed)*(LastInd - FInd);
104+
Sort_Swap_Data(Array, FInd, RInd)
105+
#local I = FInd-1;
106+
#local J = LastInd+1;
107+
#local Mid = -1;
108+
#while(Mid < 0)
109+
#local J = J-1;
110+
#while(Sort_Compare(Array, FInd, J)) #local J = J-1; #end
111+
#local I = I+1;
112+
#while(Sort_Compare(Array, I, FInd)) #local I = I+1; #end
113+
114+
#if(I < J)
115+
Sort_Swap_Data(Array, I, J)
116+
#else
117+
#local Mid = J;
118+
#end
119+
#end
120+
ARRAYS_HybridQuickSortStep(Array, FInd, Mid)
121+
#local FInd = Mid+1;
122+
#end
123+
#end
124+
125+
#macro ARRAYS_InsertionSort(Array, FirstInd, LastInd)
126+
#local Ind1 = FirstInd+1;
127+
#while(Ind1 <= LastInd)
128+
#local Ind2 = Ind1;
129+
#while(Ind2 > FirstInd)
130+
#local NextInd2 = Ind2-1;
131+
#if(Sort_Compare(Array, Ind2, NextInd2))
132+
Sort_Swap_Data(Array, Ind2, NextInd2)
133+
#local Ind2 = NextInd2;
134+
#else
135+
#local Ind2 = 0;
136+
#end
137+
#end
138+
#local Ind1 = Ind1+1;
139+
#end
140+
#end
141+
142+
#macro ARRAYS_WriteDF3(Array, FileName, BitDepth)
143+
144+
#switch (BitDepth)
145+
#case (8)
146+
#macro ARRAYS_Temp_WriteDF3(ArrayItem)
147+
#ifdef (ArrayItem)
148+
#write(ARRAYS_Temp_File, uint8 ArrayItem * 255)
149+
#else
150+
#write(ARRAYS_Temp_File, uint8 0)
151+
#end
152+
#end
153+
#break
154+
#case (16)
155+
#macro ARRAYS_Temp_WriteDF3(ArrayItem)
156+
#ifdef (ArrayItem)
157+
#write(ARRAYS_Temp_File, uint16be ArrayItem * 65535)
158+
#else
159+
#write(ARRAYS_Temp_File, uint16be 0)
160+
#end
161+
#end
162+
#break
163+
#else
164+
#error "ARRAYS_WriteDF3: bit depth not supported\n"
165+
#end
166+
167+
#switch (dimensions(Array))
168+
#case (1)
169+
#local SizeX = dimension_size(Array,1);
170+
#local SizeY = 1;
171+
#local SizeZ = 1;
172+
#macro ARRAYS_Temp(Arr,IX,IY,IZ) Arr[IX] #end
173+
#break
174+
#case (2)
175+
#local SizeX = dimension_size(Array,1);
176+
#local SizeY = dimension_size(Array,2);
177+
#local SizeZ = 1;
178+
#macro ARRAYS_Temp(Arr,IX,IY,IZ) Arr[IX][IY] #end
179+
#break
180+
#case (3)
181+
#local SizeX = dimension_size(Array,1);
182+
#local SizeY = dimension_size(Array,2);
183+
#local SizeZ = dimension_size(Array,3);
184+
#macro ARRAYS_Temp(Arr,IX,IY,IZ) Arr[IX][IY][IZ] #end
185+
#break
186+
#else
187+
#error "ARRAYS_WriteDF3: number of dimensions not supported\n"
188+
#end
189+
190+
#if ((SizeX > 65535) | (SizeY > 65535) | (SizeZ > 65535))
191+
#error "ARRAYS_WriteDF3: dimension size not supported\n"
192+
#end
193+
#fopen ARRAYS_Temp_File FileName write
194+
#write (ARRAYS_Temp_File, uint16be <SizeX,SizeY,SizeZ>)
195+
#local IndZ = 0;
196+
#while (IndZ < SizeZ)
197+
#local IndY = 0;
198+
#while (IndY < SizeY)
199+
#local IndX = 0;
200+
#while (IndX < SizeX)
201+
ARRAYS_Temp_WriteDF3(ARRAYS_Temp(Array,IndX,IndY,IndZ))
202+
#local IndX = IndX + 1;
203+
#end
204+
#local IndY = IndY + 1;
205+
#end
206+
#local IndZ = IndZ + 1;
207+
#end
208+
#undef ARRAYS_Temp
209+
#undef ARRAYS_Temp_WriteDF3
210+
#fclose ARRAYS_Temp_File
211+
#end
212+
213+
#version ARRAYS_INC_TEMP;
214+
#end
215+

0 commit comments

Comments
 (0)