PageRenderTime 59ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/matlab_tools/Converted/kgbindtexture.m

http://github.com/aludnam/MATLAB
Objective C | 188 lines | 185 code | 3 blank | 0 comment | 54 complexity | 318420ae20ed39e97d07a7957d5bedf9 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. %kgbindtexture 'Assign a Texture to a Geometry Object'
  2. % This MatLab function was automatically generated by a converter (KhorosToMatLab) from the Khoros gbindtexture.pane file
  3. %
  4. % Parameters:
  5. % InputFile: i 'Input Geometry Object ', required: 'input geometry object'
  6. % InputFile: i2 'Input Texture Object ', required: 'texture object to be bound'
  7. % OutputFile: o 'Output Geometry Object', required: 'output geometry object with bound texture'
  8. %
  9. % Example: o = kgbindtexture({i, i2}, {'i','';'i2','';'o',''})
  10. %
  11. % Khoros helpfile follows below:
  12. %
  13. % PROGRAM
  14. % gbindtexture - Assign a Texture to a Geometry Object
  15. %
  16. % DESCRIPTION
  17. % .I gbindtexture
  18. % This module "binds" a texture to an object. The rendered object
  19. % will then be rendered such as to have the texture "draped" over it's
  20. % surface, in the case of 2d textures. Texture binding is necessary
  21. % before the renderer will do the texture mapping. A single texture
  22. % may be bound to multiple objects, but a given object may have only
  23. % one texture bound to it.
  24. %
  25. %
  26. %
  27. % EXAMPLES
  28. %
  29. % "SEE ALSO"
  30. % gcreate2dtex
  31. %
  32. % RESTRICTIONS
  33. %
  34. % REFERENCES
  35. %
  36. % COPYRIGHT
  37. % Copyright (C) 1996,1997 , The Regents of the University of California. All rights reserved.
  38. %
  39. function varargout = kgbindtexture(varargin)
  40. if nargin ==0
  41. Inputs={};arglist={'',''};
  42. elseif nargin ==1
  43. Inputs=varargin{1};arglist={'',''};
  44. elseif nargin ==2
  45. Inputs=varargin{1}; arglist=varargin{2};
  46. else error('Usage: [out1,..] = kgbindtexture(Inputs,arglist).');
  47. end
  48. if size(arglist,2)~=2
  49. error('arglist must be of form {''ParameterTag1'',value1;''ParameterTag2'',value2}')
  50. end
  51. narglist={'i', '__input';'i2', '__input';'o', '__output'};
  52. maxval={0,0,0};
  53. minval={0,0,0};
  54. istoggle=[0,0,0];
  55. was_set=istoggle * 0;
  56. paramtype={'InputFile','InputFile','OutputFile'};
  57. % identify the input arrays and assign them to the arguments as stated by the user
  58. if ~iscell(Inputs)
  59. Inputs = {Inputs};
  60. end
  61. NumReqOutputs=1; nextinput=1; nextoutput=1;
  62. for ii=1:size(arglist,1)
  63. wasmatched=0;
  64. for jj=1:size(narglist,1)
  65. if strcmp(arglist{ii,1},narglist{jj,1}) % a given argument was matched to the possible arguments
  66. wasmatched = 1;
  67. was_set(jj) = 1;
  68. if strcmp(narglist{jj,2}, '__input')
  69. if (nextinput > length(Inputs))
  70. error(['Input ' narglist{jj,1} ' has no corresponding input!']);
  71. end
  72. narglist{jj,2} = 'OK_in';
  73. nextinput = nextinput + 1;
  74. elseif strcmp(narglist{jj,2}, '__output')
  75. if (nextoutput > nargout)
  76. error(['Output nr. ' narglist{jj,1} ' is not present in the assignment list of outputs !']);
  77. end
  78. if (isempty(arglist{ii,2}))
  79. narglist{jj,2} = 'OK_out';
  80. else
  81. narglist{jj,2} = arglist{ii,2};
  82. end
  83. nextoutput = nextoutput + 1;
  84. if (minval{jj} == 0)
  85. NumReqOutputs = NumReqOutputs - 1;
  86. end
  87. elseif isstr(arglist{ii,2})
  88. narglist{jj,2} = arglist{ii,2};
  89. else
  90. if strcmp(paramtype{jj}, 'Integer') & (round(arglist{ii,2}) ~= arglist{ii,2})
  91. error(['Argument ' arglist{ii,1} ' is of integer type but non-integer number ' arglist{ii,2} ' was supplied']);
  92. end
  93. if (minval{jj} ~= 0 | maxval{jj} ~= 0)
  94. if (minval{jj} == 1 & maxval{jj} == 1 & arglist{ii,2} < 0)
  95. error(['Argument ' arglist{ii,1} ' must be bigger or equal to zero!']);
  96. elseif (minval{jj} == -1 & maxval{jj} == -1 & arglist{ii,2} > 0)
  97. error(['Argument ' arglist{ii,1} ' must be smaller or equal to zero!']);
  98. elseif (minval{jj} == 2 & maxval{jj} == 2 & arglist{ii,2} <= 0)
  99. error(['Argument ' arglist{ii,1} ' must be bigger than zero!']);
  100. elseif (minval{jj} == -2 & maxval{jj} == -2 & arglist{ii,2} >= 0)
  101. error(['Argument ' arglist{ii,1} ' must be smaller than zero!']);
  102. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} < minval{jj})
  103. error(['Argument ' arglist{ii,1} ' must be bigger than ' num2str(minval{jj})]);
  104. elseif (minval{jj} ~= maxval{jj} & arglist{ii,2} > maxval{jj})
  105. error(['Argument ' arglist{ii,1} ' must be smaller than ' num2str(maxval{jj})]);
  106. end
  107. end
  108. end
  109. if ~strcmp(narglist{jj,2},'OK_out') & ~strcmp(narglist{jj,2},'OK_in')
  110. narglist{jj,2} = arglist{ii,2};
  111. end
  112. end
  113. end
  114. if (wasmatched == 0 & ~strcmp(arglist{ii,1},''))
  115. error(['Argument ' arglist{ii,1} ' is not a valid argument for this function']);
  116. end
  117. end
  118. % match the remaining inputs/outputs to the unused arguments and test for missing required inputs
  119. for jj=1:size(narglist,1)
  120. if strcmp(paramtype{jj}, 'Toggle')
  121. if (narglist{jj,2} ==0)
  122. narglist{jj,1} = '';
  123. end;
  124. narglist{jj,2} = '';
  125. end;
  126. if ~strcmp(narglist{jj,2},'__input') && ~strcmp(narglist{jj,2},'__output') && istoggle(jj) && ~ was_set(jj)
  127. narglist{jj,1} = '';
  128. narglist{jj,2} = '';
  129. end;
  130. if strcmp(narglist{jj,2}, '__input')
  131. if (minval{jj} == 0) % meaning this input is required
  132. if (nextinput > size(Inputs))
  133. error(['Required input ' narglist{jj,1} ' has no corresponding input in the list!']);
  134. else
  135. narglist{jj,2} = 'OK_in';
  136. nextinput = nextinput + 1;
  137. end
  138. else % this is an optional input
  139. if (nextinput <= length(Inputs))
  140. narglist{jj,2} = 'OK_in';
  141. nextinput = nextinput + 1;
  142. else
  143. narglist{jj,1} = '';
  144. narglist{jj,2} = '';
  145. end;
  146. end;
  147. else
  148. if strcmp(narglist{jj,2}, '__output')
  149. if (minval{jj} == 0) % this is a required output
  150. if (nextoutput > nargout & nargout > 1)
  151. error(['Required output ' narglist{jj,1} ' is not stated in the assignment list!']);
  152. else
  153. narglist{jj,2} = 'OK_out';
  154. nextoutput = nextoutput + 1;
  155. NumReqOutputs = NumReqOutputs-1;
  156. end
  157. else % this is an optional output
  158. if (nargout - nextoutput >= NumReqOutputs)
  159. narglist{jj,2} = 'OK_out';
  160. nextoutput = nextoutput + 1;
  161. else
  162. narglist{jj,1} = '';
  163. narglist{jj,2} = '';
  164. end;
  165. end
  166. end
  167. end
  168. end
  169. if nargout
  170. varargout = cell(1,nargout);
  171. else
  172. varargout = cell(1,1);
  173. end
  174. global KhorosRoot
  175. if exist('KhorosRoot') && ~isempty(KhorosRoot)
  176. w=['"' KhorosRoot];
  177. else
  178. if ispc
  179. w='"C:\Program Files\dip\khorosBin\';
  180. else
  181. [s,w] = system('which cantata');
  182. w=['"' w(1:end-8)];
  183. end
  184. end
  185. [varargout{:}]=callKhoros([w 'gbindtexture" '],Inputs,narglist);