![]() |
Shadowrun: Awakened 29 September 2011 - Build 871
|
00001 /* 00002 Copyright 2005-2010 Intel Corporation. All Rights Reserved. 00003 00004 This file is part of Threading Building Blocks. 00005 00006 Threading Building Blocks is free software; you can redistribute it 00007 and/or modify it under the terms of the GNU General Public License 00008 version 2 as published by the Free Software Foundation. 00009 00010 Threading Building Blocks is distributed in the hope that it will be 00011 useful, but WITHOUT ANY WARRANTY; without even the implied warranty 00012 of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 GNU General Public License for more details. 00014 00015 You should have received a copy of the GNU General Public License 00016 along with Threading Building Blocks; if not, write to the Free Software 00017 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00018 00019 As a special exception, you may use this file as part of a free software 00020 library without restriction. Specifically, if other files instantiate 00021 templates or use macros or inline functions from this file, or you compile 00022 this file and link it with other files to produce an executable, this 00023 file does not by itself cause the resulting executable to be covered by 00024 the GNU General Public License. This exception does not however 00025 invalidate any other reasons why the executable file might be covered by 00026 the GNU General Public License. 00027 */ 00028 00029 /* 00030 The original source for this example is 00031 Copyright (c) 1994-2008 John E. Stone 00032 All rights reserved. 00033 00034 Redistribution and use in source and binary forms, with or without 00035 modification, are permitted provided that the following conditions 00036 are met: 00037 1. Redistributions of source code must retain the above copyright 00038 notice, this list of conditions and the following disclaimer. 00039 2. Redistributions in binary form must reproduce the above copyright 00040 notice, this list of conditions and the following disclaimer in the 00041 documentation and/or other materials provided with the distribution. 00042 3. The name of the author may not be used to endorse or promote products 00043 derived from this software without specific prior written permission. 00044 00045 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS 00046 OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00047 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00048 ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 00049 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00050 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 00051 OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 00052 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 00053 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 00054 OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00055 SUCH DAMAGE. 00056 */ 00057 00058 #include <stdio.h> 00059 #include <stdlib.h> 00060 #include <string.h> 00061 #include "types.h" 00062 #include "api.h" 00063 #include "getargs.h" 00064 00065 void printusage(char **argv) { 00066 fprintf(stderr, "Usage: \n"); 00067 fprintf(stderr, " %s modelfile [options] \n", argv[0]); 00068 fprintf(stderr, "\n"); 00069 fprintf(stderr, "Model file formats supported:\n"); 00070 fprintf(stderr, " filename.dat -- The model files originated with this package.\n"); 00071 fprintf(stderr, " filaname.ac -- AC3D model files.\n"); 00072 fprintf(stderr, " filename.nff -- The NFF scene format used by Eric Haines' SPD.\n"); 00073 fprintf(stderr, "\n"); 00074 fprintf(stderr, "Valid options: (** denotes default behaviour)\n"); 00075 fprintf(stderr, " +D enable run-time display updating (if build supports it) **\n"); 00076 fprintf(stderr, " -D disable run-time display updating\n"); 00077 fprintf(stderr, " -nobounding\n"); 00078 fprintf(stderr, " -boundthresh XXX (** default threshold is 25)\n"); 00079 fprintf(stderr, "\n"); 00080 } 00081 00082 void initoptions(argoptions * opt) { 00083 memset(opt, 0, sizeof(argoptions)); 00084 opt->foundfilename = -1; 00085 opt->useoutfilename = -1; 00086 opt->verbosemode = -1; 00087 opt->antialiasing = -1; 00088 opt->displaymode = -1; 00089 opt->boundmode = -1; 00090 opt->boundthresh = -1; 00091 opt->usecamfile = -1; 00092 } 00093 00094 int useoptions(argoptions * opt, SceneHandle scene) { 00095 if (opt->useoutfilename == 1) { 00096 rt_outputfile(scene, opt->outfilename); 00097 } 00098 00099 if (opt->verbosemode == 1) { 00100 rt_verbose(scene, 1); 00101 } 00102 00103 if (opt->antialiasing != -1) { 00104 /* need new api code for this */ 00105 } 00106 00107 if (opt->displaymode != -1) { 00108 rt_displaymode(scene, opt->displaymode); 00109 } 00110 00111 if (opt->boundmode != -1) { 00112 rt_boundmode(scene, opt->boundmode); 00113 } 00114 00115 if (opt->boundthresh != -1) { 00116 rt_boundthresh(scene, opt->boundthresh); 00117 } 00118 00119 return 0; 00120 } 00121 00122 int getparm(int argc, char **argv, int num, argoptions * opt) { 00123 if (!strcmp(argv[num], "+D")) { 00124 /* turn video on */ 00125 opt->displaymode = RT_DISPLAY_ENABLED; 00126 return 1; 00127 } 00128 if (!strcmp(argv[num], "-D")) { 00129 /* turn video off */ 00130 opt->displaymode = RT_DISPLAY_DISABLED; 00131 return 1; 00132 } 00133 if (!strcmp(argv[num], "-nobounding")) { 00134 /* disable automatic spatial subdivision optimizations */ 00135 opt->boundmode = RT_BOUNDING_DISABLED; 00136 return 1; 00137 } 00138 if (!strcmp(argv[num], "-boundthresh")) { 00139 /* set automatic bounding threshold control value */ 00140 sscanf(argv[num + 1], "%d", &opt->boundthresh); 00141 return 2; 00142 } 00143 00144 /* unknown parameter setting */ 00145 fprintf(stderr, "Unrecognized parameter/option flag: %s\n", argv[num]); 00146 return -1; 00147 } 00148 00149 int getargs(int argc, char **argv, argoptions * opt) { 00150 int i, rc, unknowncnt; 00151 00152 if (opt == NULL) 00153 return -1; 00154 00155 initoptions(opt); 00156 00157 if (argc < 2) { 00158 printusage(argv); 00159 #ifndef DEFAULT_MODELFILE 00160 return -1; 00161 #else 00162 return 0; 00163 #endif//DEFAULT_MODELFILE 00164 } 00165 00166 i = 1; 00167 unknowncnt = 0; 00168 while (i < argc) { 00169 if (argv[i][0] == '-' || argv[i][0] == '+') { 00170 rc = getparm(argc, argv, i, opt); 00171 if (rc != -1) { 00172 i += rc; 00173 } 00174 else { 00175 printusage(argv); 00176 return -1; 00177 } 00178 } 00179 else { 00180 unknowncnt++; 00181 if (unknowncnt > 1) { 00182 fprintf(stderr, "Too many model file names found!\n"); 00183 printusage(argv); 00184 return -1; 00185 } 00186 else { 00187 strcpy(opt->filename, argv[i]); 00188 opt->foundfilename = 1; 00189 i++; 00190 } 00191 } 00192 } 00193 00194 if (opt->foundfilename == -1) { 00195 fprintf(stderr, "Missing model file name!\n"); 00196 printusage(argv); 00197 return -1; 00198 } 00199 00200 return 0; 00201 } 00202 00203 00204
Copyright © 2007-2010 by The Shadowrun: Awakened Team. This work is licensed under the GNU Lesser General Public License 3.