object.c 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277
  1. /*
  2. Copyright (C) 2005, 2010 - Cryptic Sea
  3. This file is part of Gish.
  4. Gish is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU General Public License
  6. as published by the Free Software Foundation; either version 2
  7. of the License, or (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. See the GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  15. */
  16. void createbox(float position[3],float sizex,float sizey,float mass,float friction)
  17. {
  18. int count,count2;
  19. float vec[3];
  20. memset(&object[numofobjects],0,sizeof(object[numofobjects]));
  21. object[numofobjects].type=2;
  22. object[numofobjects].timetolive=10000;
  23. object[numofobjects].mass=mass;
  24. object[numofobjects].numofparticles=4;
  25. if (sizex>=sizey)
  26. object[numofobjects].radius=sizex*1.5f;
  27. else
  28. object[numofobjects].radius=sizey*1.5f;
  29. object[numofobjects].size[0]=sizex;
  30. object[numofobjects].size[1]=sizey;
  31. object[numofobjects].friction=friction;
  32. count=0;
  33. vec[0]=-sizex*0.5f;
  34. vec[1]=sizey*0.5f;
  35. vec[2]=0.0f;
  36. addvectors(vec,vec,position);
  37. object[numofobjects].particle[count]=numofparticles;
  38. count++;
  39. createparticle(3,vec,NULL,mass*0.25f,-1,10000);
  40. vec[0]=sizex*0.5f;
  41. vec[1]=sizey*0.5f;
  42. vec[2]=0.0f;
  43. addvectors(vec,vec,position);
  44. object[numofobjects].particle[count]=numofparticles;
  45. count++;
  46. createparticle(3,vec,NULL,mass*0.25f,-1,10000);
  47. vec[0]=sizex*0.5f;
  48. vec[1]=-sizey*0.5f;
  49. vec[2]=0.0f;
  50. addvectors(vec,vec,position);
  51. object[numofobjects].particle[count]=numofparticles;
  52. count++;
  53. createparticle(3,vec,NULL,mass*0.25f,-1,10000);
  54. vec[0]=-sizex*0.5f;
  55. vec[1]=-sizey*0.5f;
  56. vec[2]=0.0f;
  57. addvectors(vec,vec,position);
  58. object[numofobjects].particle[count]=numofparticles;
  59. count++;
  60. createparticle(3,vec,NULL,mass*0.25f,-1,10000);
  61. for (count=0;count<object[numofobjects].numofparticles;count++)
  62. for (count2=count+1;count2<object[numofobjects].numofparticles;count2++)
  63. createbond(object[numofobjects].particle[count],object[numofobjects].particle[count2],1,-1);
  64. copyvector(object[numofobjects].position,position);
  65. object[numofobjects].numofcdlines=4;
  66. for (count=0;count<4;count++)
  67. {
  68. object[numofobjects].cdline[count][0]=count;
  69. object[numofobjects].cdline[count][1]=((count+1)&3);
  70. }
  71. object[numofobjects].texcoord[0][0]=0.0f;
  72. object[numofobjects].texcoord[0][1]=0.0f;
  73. object[numofobjects].texcoord[1][0]=1.0f;
  74. object[numofobjects].texcoord[1][1]=0.0f;
  75. object[numofobjects].texcoord[2][0]=1.0f;
  76. object[numofobjects].texcoord[2][1]=1.0f;
  77. object[numofobjects].texcoord[3][0]=0.0f;
  78. object[numofobjects].texcoord[3][1]=1.0f;
  79. object[numofobjects].soundnum[0]=-1;
  80. object[numofobjects].soundnum[1]=-1;
  81. object[numofobjects].soundnum[2]=-1;
  82. object[numofobjects].soundnum[3]=-1;
  83. numofobjects++;
  84. }
  85. void createtarboy(float position[3])
  86. {
  87. int count;
  88. float vec[3];
  89. float angle;
  90. float size;
  91. memset(&object[numofobjects],0,sizeof(object[numofobjects]));
  92. object[numofobjects].type=1;
  93. object[numofobjects].timetolive=10000;
  94. object[numofobjects].radius=1.5f;
  95. object[numofobjects].mass=4.0f;
  96. object[numofobjects].friction=1.2f;
  97. if (numofobjects==0)
  98. object[numofobjects].direction=1;
  99. object[numofobjects].hitpoints=1000;
  100. object[numofobjects].numofparticles=16;
  101. for (count=0;count<16;count++)
  102. {
  103. angle=(float)count*pi/8.0f;
  104. size=0.9f;
  105. if (game.supersize)
  106. size=0.9f*1.25f;
  107. if (game.difficulty==4)
  108. size=0.9f*0.8f;
  109. vec[0]=position[0]+cos(angle)*size;
  110. vec[1]=position[1]-sin(angle)*size;
  111. vec[2]=0.0f;
  112. createparticle(1,vec,NULL,0.25f,numofobjects,10000);
  113. object[numofobjects].particle[count]=numofparticles-1;
  114. }
  115. for (count=0;count<16;count++)
  116. {
  117. createbond(object[numofobjects].particle[((count+1)&15)],object[numofobjects].particle[(count&15)],3,-1);
  118. createbond(object[numofobjects].particle[((count+2)&15)],object[numofobjects].particle[(count&15)],3,-1);
  119. createbond(object[numofobjects].particle[((count+8)&15)],object[numofobjects].particle[(count&15)],2,numofobjects);
  120. }
  121. copyvector(object[numofobjects].position,position);
  122. object[numofobjects].numofcdlines=16;
  123. for (count=0;count<16;count++)
  124. {
  125. object[numofobjects].cdline[count][0]=count;
  126. object[numofobjects].cdline[count][1]=((count+1)&15);
  127. }
  128. object[numofobjects].soundnum[0]=-1;
  129. object[numofobjects].soundnum[1]=-1;
  130. object[numofobjects].soundnum[2]=-1;
  131. object[numofobjects].soundnum[3]=-1;
  132. numofobjects++;
  133. }
  134. void createwheel(float position[3],float sizex,float sizey,float mass,float friction,int anchor)
  135. {
  136. int count;
  137. float vec[3];
  138. float angle;
  139. memset(&object[numofobjects],0,sizeof(object[numofobjects]));
  140. object[numofobjects].type=3;
  141. object[numofobjects].timetolive=10000;
  142. if (sizex>=sizey)
  143. object[numofobjects].radius=sizex*1.25f;
  144. else
  145. object[numofobjects].radius=sizey*1.25f;
  146. object[numofobjects].mass=mass;
  147. object[numofobjects].friction=friction;
  148. object[numofobjects].numofparticles=17;
  149. for (count=0;count<16;count++)
  150. {
  151. angle=(float)count*pi/8.0f;
  152. vec[0]=position[0]+cos(angle)*sizex*0.5f;
  153. vec[1]=position[1]-sin(angle)*sizey*0.5f;
  154. vec[2]=0.0f;
  155. createparticle(3,vec,NULL,mass/20.0f,numofobjects,10000);
  156. object[numofobjects].particle[count]=numofparticles-1;
  157. }
  158. count=16;
  159. if (!anchor)
  160. createparticle(3,position,NULL,mass/5.0f,numofobjects,10000);
  161. else
  162. createparticle(2,position,NULL,mass/5.0f,numofobjects,10000);
  163. object[numofobjects].particle[count]=numofparticles-1;
  164. for (count=0;count<16;count++)
  165. {
  166. createbond(object[numofobjects].particle[((count+1)&15)],object[numofobjects].particle[(count&15)],1,numofobjects);
  167. createbond(object[numofobjects].particle[((count+2)&15)],object[numofobjects].particle[(count&15)],1,numofobjects);
  168. createbond(object[numofobjects].particle[((count+3)&15)],object[numofobjects].particle[(count&15)],1,numofobjects);
  169. //createbond(object[numofobjects].particle[((count+4)&15)],object[numofobjects].particle[(count&15)],1,numofobjects);
  170. //createbond(object[numofobjects].particle[((count+8)&15)],object[numofobjects].particle[(count&15)],1,numofobjects);
  171. createbond(object[numofobjects].particle[16],object[numofobjects].particle[(count&15)],1,numofobjects);
  172. }
  173. copyvector(object[numofobjects].position,position);
  174. object[numofobjects].numofcdlines=16;
  175. for (count=0;count<16;count++)
  176. {
  177. object[numofobjects].cdline[count][0]=count;
  178. object[numofobjects].cdline[count][1]=((count+1)&15);
  179. }
  180. object[numofobjects].soundnum[0]=-1;
  181. object[numofobjects].soundnum[1]=-1;
  182. object[numofobjects].soundnum[2]=-1;
  183. object[numofobjects].soundnum[3]=-1;
  184. numofobjects++;
  185. }
  186. void setupobjecttypes(void)
  187. {
  188. int count;
  189. count=1;
  190. objecttype[count].collide[1]=1;
  191. objecttype[count].collide[2]=1;
  192. objecttype[count].collide[3]=1;
  193. objecttype[count].collide[4]=1;
  194. objecttype[count].collide[5]=1;
  195. objecttype[count].collide[6]=1;
  196. objecttype[count].collide[9]=1;
  197. objecttype[count].collide[10]=1;
  198. objecttype[count].collide[20]=1;
  199. count=2;
  200. objecttype[count].collide[1]=0;
  201. objecttype[count].collide[2]=1;
  202. objecttype[count].collide[3]=1;
  203. objecttype[count].collide[4]=1;
  204. objecttype[count].collide[5]=1;
  205. objecttype[count].collide[6]=1;
  206. objecttype[count].collide[9]=1;
  207. objecttype[count].collide[10]=1;
  208. objecttype[count].collide[20]=1;
  209. count=3;
  210. objecttype[count].collide[1]=0;
  211. objecttype[count].collide[2]=1;
  212. objecttype[count].collide[3]=1;
  213. objecttype[count].collide[4]=1;
  214. objecttype[count].collide[5]=1;
  215. objecttype[count].collide[6]=1;
  216. objecttype[count].collide[9]=1;
  217. objecttype[count].collide[10]=1;
  218. objecttype[count].collide[20]=1;
  219. count=4;
  220. objecttype[count].collide[1]=0;
  221. objecttype[count].collide[2]=1;
  222. objecttype[count].collide[3]=1;
  223. objecttype[count].collide[4]=1;
  224. objecttype[count].collide[5]=1;
  225. objecttype[count].collide[6]=1;
  226. objecttype[count].collide[9]=1;
  227. objecttype[count].collide[10]=1;
  228. objecttype[count].collide[20]=1;
  229. count=5;
  230. objecttype[count].collide[1]=0;
  231. objecttype[count].collide[2]=1;
  232. objecttype[count].collide[3]=1;
  233. objecttype[count].collide[4]=1;
  234. objecttype[count].collide[5]=1;
  235. objecttype[count].collide[6]=1;
  236. objecttype[count].collide[9]=1;
  237. objecttype[count].collide[10]=1;
  238. objecttype[count].collide[20]=1;
  239. count=6;
  240. objecttype[count].collide[1]=0;
  241. objecttype[count].collide[2]=1;
  242. objecttype[count].collide[3]=1;
  243. objecttype[count].collide[4]=1;
  244. objecttype[count].collide[5]=1;
  245. objecttype[count].collide[6]=1;
  246. objecttype[count].collide[9]=1;
  247. objecttype[count].collide[10]=1;
  248. objecttype[count].collide[20]=1;
  249. count=9;
  250. objecttype[count].collide[1]=0;
  251. objecttype[count].collide[2]=1;
  252. objecttype[count].collide[3]=1;
  253. objecttype[count].collide[4]=1;
  254. objecttype[count].collide[5]=1;
  255. objecttype[count].collide[6]=1;
  256. objecttype[count].collide[9]=0;
  257. objecttype[count].collide[10]=0;
  258. objecttype[count].collide[20]=1;
  259. count=10;
  260. objecttype[count].collide[1]=0;
  261. objecttype[count].collide[2]=1;
  262. objecttype[count].collide[3]=1;
  263. objecttype[count].collide[4]=1;
  264. objecttype[count].collide[5]=1;
  265. objecttype[count].collide[6]=1;
  266. objecttype[count].collide[9]=0;
  267. objecttype[count].collide[10]=0;
  268. objecttype[count].collide[20]=1;
  269. count=20;
  270. objecttype[count].collide[1]=0;
  271. objecttype[count].collide[2]=1;
  272. objecttype[count].collide[3]=1;
  273. objecttype[count].collide[4]=1;
  274. objecttype[count].collide[5]=1;
  275. objecttype[count].collide[6]=1;
  276. objecttype[count].collide[9]=1;
  277. objecttype[count].collide[10]=1;
  278. objecttype[count].collide[20]=1;
  279. }
  280. void createrope(int type,int particlenum,int particlenum2,int objectnum,int objectnum2,int texturenum)
  281. {
  282. int count,count2;
  283. int length;
  284. float vec[3],vec2[3];
  285. float mass;
  286. if (type<5)
  287. {
  288. if (type==1)
  289. mass=0.125f;
  290. if (type==2)
  291. mass=0.25f;
  292. if (type==3)
  293. mass=1.0f;
  294. if (type==4)
  295. mass=2.0f;
  296. subtractvectors(vec,particle[particlenum2].position,particle[particlenum].position);
  297. length=vectorlength(vec);
  298. if (length<1)
  299. length=1;
  300. length*=2;
  301. scalevector(vec,vec,1.0f/(float)length);
  302. copyvector(vec2,particle[particlenum].position);
  303. addvectors(vec2,vec2,vec);
  304. createparticle(4,vec2,NULL,mass,-1,10000);
  305. createbond(particlenum,numofparticles-1,4,numofropes);
  306. rope[numofropes].type=type;
  307. rope[numofropes].part1=particlenum;
  308. rope[numofropes].part2=numofparticles-1;
  309. if (type<3)
  310. rope[numofropes].texturenum=360;
  311. else
  312. rope[numofropes].texturenum=361;
  313. numofropes++;
  314. for (count=1;count<length-1;count++)
  315. {
  316. addvectors(vec2,vec2,vec);
  317. createparticle(4,vec2,NULL,mass,-1,10000);
  318. createbond(numofparticles-2,numofparticles-1,4,numofropes);
  319. rope[numofropes].type=type;
  320. rope[numofropes].part1=numofparticles-2;
  321. rope[numofropes].part2=numofparticles-1;
  322. if (type<3)
  323. rope[numofropes].texturenum=360;
  324. else
  325. rope[numofropes].texturenum=361;
  326. numofropes++;
  327. }
  328. createbond(numofparticles-1,particlenum2,4,numofropes);
  329. rope[numofropes].type=type;
  330. rope[numofropes].part1=numofparticles-1;
  331. rope[numofropes].part2=particlenum2;
  332. if (type<3)
  333. rope[numofropes].texturenum=360;
  334. else
  335. rope[numofropes].texturenum=361;
  336. numofropes++;
  337. }
  338. else
  339. {
  340. if (type<10)
  341. createbond(particlenum,particlenum2,7,numofropes);
  342. else
  343. createbond(particlenum,particlenum2,8,numofropes);
  344. if (type<9)
  345. {
  346. if (level.object[objectnum2].type==6 || level.object[objectnum2].type==7)
  347. {
  348. subtractvectors(vec,level.object[objectnum2].position,particle[particlenum].position);
  349. subtractvectors(vec2,particle[particlenum2].position,object[objectnum2].position);
  350. rope[numofropes].range=vectorlength(vec2);
  351. bond[numofbonds-1].length=vectorlength(vec)-rope[numofropes].range;
  352. bond[numofbonds-1].maxlength=vectorlength(vec)-rope[numofropes].range;
  353. }
  354. if (level.object[objectnum2].type>=2 && level.object[objectnum2].type<6)
  355. {
  356. subtractvectors(vec2,level.object[objectnum2].position,object[objectnum].position);
  357. subtractvectors(vec,particle[particlenum2].position,particle[particlenum].position);
  358. if (fabs(vec2[0])>fabs(vec2[1]))
  359. vec[1]=0.0f;
  360. else
  361. vec[0]=0.0f;
  362. normalizevector(vec,vec);
  363. if (type==5 || type==9)
  364. copyvector(vec2,particle[particlenum2].position);
  365. if (type==6 || type==8)
  366. scaleaddvectors(vec2,particle[particlenum2].position,vec,-level.object[objectnum].lightcolor[0]*0.5f);
  367. if (type==7)
  368. scaleaddvectors(vec2,particle[particlenum2].position,vec,-level.object[objectnum].lightcolor[0]);
  369. subtractvectors(vec2,particle[particlenum].position,vec2);
  370. bond[numofbonds-1].length=vectorlength(vec2);
  371. bond[numofbonds-1].maxlength=vectorlength(vec2);
  372. if (type==5)
  373. scaleaddvectors(vec2,particle[particlenum2].position,vec,level.object[objectnum].lightcolor[0]);
  374. if (type==6 || type==8)
  375. scaleaddvectors(vec2,particle[particlenum2].position,vec,level.object[objectnum].lightcolor[0]*0.5f);
  376. if (type==7 || type==9)
  377. copyvector(vec2,particle[particlenum2].position);
  378. subtractvectors(vec2,particle[particlenum].position,vec2);
  379. rope[numofropes].range=(vectorlength(vec2)-bond[numofbonds-1].maxlength)*0.5f;
  380. }
  381. }
  382. rope[numofropes].type=type;
  383. rope[numofropes].part1=particlenum;
  384. rope[numofropes].part2=particlenum2;
  385. rope[numofropes].bondnum=numofbonds-1;
  386. if (type==5)
  387. rope[numofropes].angle=0.0f;
  388. if (type==6)
  389. rope[numofropes].angle=pi/2.0f;
  390. if (type==7)
  391. rope[numofropes].angle=pi;
  392. if (type==8)
  393. rope[numofropes].angle=3.0f*pi/2.0f;
  394. rope[numofropes].cycle=level.object[objectnum].lightcolor[1];
  395. rope[numofropes].cyclelength=level.object[objectnum].lightcolor[2];
  396. rope[numofropes].cyclecount=0.0f;
  397. rope[numofropes].link=level.object[objectnum].link;
  398. if (texturenum==0)
  399. rope[numofropes].texturenum=0;
  400. if (texturenum==1)
  401. rope[numofropes].texturenum=362;
  402. if (texturenum==2)
  403. rope[numofropes].texturenum=362;
  404. if (texturenum==3)
  405. rope[numofropes].texturenum=362;
  406. numofropes++;
  407. }
  408. }
  409. void createanchor(float position[3])
  410. {
  411. int count;
  412. float vec[3];
  413. memset(&object[numofobjects],0,sizeof(object[numofobjects]));
  414. object[numofobjects].type=8;
  415. object[numofobjects].timetolive=10000;
  416. object[numofobjects].radius=1.0f;
  417. object[numofobjects].friction=0.8f;
  418. object[numofobjects].numofparticles=0;
  419. copyvector(vec,position);
  420. vec[0]+=0.00001f;
  421. createparticle(2,position,NULL,10000.0f,numofobjects,10000);
  422. object[numofobjects].particle[0]=numofparticles-1;
  423. copyvector(object[numofobjects].position,position);
  424. object[numofobjects].numofcdlines=0;
  425. object[numofobjects].soundnum[0]=-1;
  426. object[numofobjects].soundnum[1]=-1;
  427. object[numofobjects].soundnum[2]=-1;
  428. object[numofobjects].soundnum[3]=-1;
  429. numofobjects++;
  430. }
  431. void createbutton(float position[3],float mass)
  432. {
  433. int count,count2;
  434. float vec[3];
  435. memset(&object[numofobjects],0,sizeof(object[numofobjects]));
  436. object[numofobjects].type=9;
  437. object[numofobjects].timetolive=10000;
  438. object[numofobjects].friction=0.3f;
  439. object[numofobjects].radius=1.5f;
  440. object[numofobjects].numofparticles=7;
  441. count=0;
  442. vec[0]=position[0]-0.499f;
  443. vec[1]=position[1]+0.5f;
  444. vec[2]=0.0f;
  445. createparticle(3,vec,NULL,mass/16.0f,numofobjects,10000);
  446. object[numofobjects].particle[count]=numofparticles-1;
  447. count++;
  448. vec[0]=position[0]-0.125f;
  449. vec[1]=position[1]+0.75f;
  450. vec[2]=0.0f;
  451. createparticle(3,vec,NULL,mass/16.0f,numofobjects,10000);
  452. object[numofobjects].particle[count]=numofparticles-1;
  453. count++;
  454. vec[0]=position[0]+0.125f;
  455. vec[1]=position[1]+0.75f;
  456. vec[2]=0.0f;
  457. createparticle(3,vec,NULL,mass/16.0f,numofobjects,10000);
  458. object[numofobjects].particle[count]=numofparticles-1;
  459. count++;
  460. vec[0]=position[0]+0.499f;
  461. vec[1]=position[1]+0.5f;
  462. vec[2]=0.0f;
  463. createparticle(3,vec,NULL,mass/16.0f,numofobjects,10000);
  464. object[numofobjects].particle[count]=numofparticles-1;
  465. count++;
  466. vec[0]=position[0]+0.499f;
  467. vec[1]=position[1]-0.125f;
  468. vec[2]=0.0f;
  469. createparticle(3,vec,NULL,mass/16.0f,numofobjects,10000);
  470. object[numofobjects].particle[count]=numofparticles-1;
  471. count++;
  472. vec[0]=position[0]-0.499f;
  473. vec[1]=position[1]-0.125f;
  474. vec[2]=0.0f;
  475. createparticle(3,vec,NULL,mass/16.0f,numofobjects,10000);
  476. object[numofobjects].particle[count]=numofparticles-1;
  477. count++;
  478. vec[0]=position[0];
  479. vec[1]=position[1]-0.125f;
  480. vec[2]=0.0f;
  481. createparticle(2,vec,NULL,1.0f,numofobjects,10000);
  482. object[numofobjects].particle[count]=numofparticles-1;
  483. count++;
  484. for (count=0;count<6;count++)
  485. for (count2=count+1;count2<6;count2++)
  486. createbond(object[numofobjects].particle[count],object[numofobjects].particle[count2],1,numofobjects);
  487. copyvector(object[numofobjects].position,position);
  488. object[numofobjects].numofcdlines=6;
  489. for (count=0;count<6;count++)
  490. {
  491. object[numofobjects].cdline[count][0]=count;
  492. object[numofobjects].cdline[count][1]=((count+1)%6);
  493. }
  494. object[numofobjects].soundnum[0]=-1;
  495. object[numofobjects].soundnum[1]=-1;
  496. object[numofobjects].soundnum[2]=-1;
  497. object[numofobjects].soundnum[3]=-1;
  498. numofobjects++;
  499. }
  500. void createswitch(float position[3],float mass,int rotate)
  501. {
  502. int count,count2;
  503. float vec[3],vec2[3];
  504. float orientation[2][2];
  505. if (rotate==0)
  506. {
  507. orientation[0][0]=1.0f;
  508. orientation[0][1]=0.0f;
  509. orientation[1][0]=0.0f;
  510. orientation[1][1]=1.0f;
  511. }
  512. if (rotate==1)
  513. {
  514. orientation[0][0]=0.0f;
  515. orientation[0][1]=-1.0f;
  516. orientation[1][0]=1.0f;
  517. orientation[1][1]=0.0f;
  518. }
  519. if (rotate==2)
  520. {
  521. orientation[0][0]=-1.0f;
  522. orientation[0][1]=0.0f;
  523. orientation[1][0]=0.0f;
  524. orientation[1][1]=-1.0f;
  525. }
  526. if (rotate==3)
  527. {
  528. orientation[0][0]=0.0f;
  529. orientation[0][1]=-1.0f;
  530. orientation[1][0]=-1.0f;
  531. orientation[1][1]=0.0f;
  532. }
  533. memset(&object[numofobjects],0,sizeof(object[numofobjects]));
  534. object[numofobjects].type=10;
  535. object[numofobjects].timetolive=10000;
  536. object[numofobjects].radius=1.5f;
  537. object[numofobjects].friction=0.3f;
  538. object[numofobjects].rotate=rotate;
  539. object[numofobjects].numofparticles=5;
  540. count=0;
  541. vec[0]=-0.875f;
  542. vec[1]=0.875f;
  543. vec2[0]=position[0]+vec[0]*orientation[0][0]+vec[1]*orientation[1][0];
  544. vec2[1]=position[1]+vec[0]*orientation[0][1]+vec[1]*orientation[1][1];
  545. vec2[2]=0.0f;
  546. createparticle(3,vec2,NULL,mass/8.0f,numofobjects,10000);
  547. object[numofobjects].particle[count]=numofparticles-1;
  548. count++;
  549. vec[0]=0.25f;
  550. vec[1]=0.0f;
  551. vec2[0]=position[0]+vec[0]*orientation[0][0]+vec[1]*orientation[1][0];
  552. vec2[1]=position[1]+vec[0]*orientation[0][1]+vec[1]*orientation[1][1];
  553. vec2[2]=0.0f;
  554. createparticle(3,vec2,NULL,mass/8.0f,numofobjects,10000);
  555. object[numofobjects].particle[count]=numofparticles-1;
  556. count++;
  557. vec[0]=-0.25f;
  558. vec[1]=-0.5f;
  559. vec[2]=0.0f;
  560. vec2[0]=position[0]+vec[0]*orientation[0][0]+vec[1]*orientation[1][0];
  561. vec2[1]=position[1]+vec[0]*orientation[0][1]+vec[1]*orientation[1][1];
  562. vec2[2]=0.0f;
  563. createparticle(3,vec2,NULL,mass/8.0f,numofobjects,10000);
  564. object[numofobjects].particle[count]=numofparticles-1;
  565. count++;
  566. vec[0]=-1.125f;
  567. vec[1]=0.625f;
  568. vec[2]=0.0f;
  569. vec2[0]=position[0]+vec[0]*orientation[0][0]+vec[1]*orientation[1][0];
  570. vec2[1]=position[1]+vec[0]*orientation[0][1]+vec[1]*orientation[1][1];
  571. vec2[2]=0.0f;
  572. createparticle(3,vec2,NULL,mass/8.0f,numofobjects,10000);
  573. object[numofobjects].particle[count]=numofparticles-1;
  574. count++;
  575. vec[0]=0.0f;
  576. vec[1]=-0.25f;
  577. vec[2]=0.0f;
  578. vec2[0]=position[0]+vec[0]*orientation[0][0]+vec[1]*orientation[1][0];
  579. vec2[1]=position[1]+vec[0]*orientation[0][1]+vec[1]*orientation[1][1];
  580. vec2[2]=0.0f;
  581. createparticle(2,vec2,NULL,10000.0f,numofobjects,10000);
  582. object[numofobjects].particle[count]=numofparticles-1;
  583. count++;
  584. for (count=0;count<5;count++)
  585. for (count2=count+1;count2<5;count2++)
  586. createbond(object[numofobjects].particle[count],object[numofobjects].particle[count2],1,numofobjects);
  587. copyvector(object[numofobjects].position,position);
  588. object[numofobjects].numofcdlines=4;
  589. for (count=0;count<4;count++)
  590. {
  591. object[numofobjects].cdline[count][0]=count;
  592. if (rotate!=3)
  593. object[numofobjects].cdline[count][1]=((count+1)&3);
  594. else
  595. object[numofobjects].cdline[count][1]=((count-1)&3);
  596. }
  597. object[numofobjects].texcoord[0][0]=0.0f;
  598. object[numofobjects].texcoord[0][1]=0.0f;
  599. object[numofobjects].texcoord[1][0]=1.0f;
  600. object[numofobjects].texcoord[1][1]=0.0f;
  601. object[numofobjects].texcoord[2][0]=1.0f;
  602. object[numofobjects].texcoord[2][1]=1.0f;
  603. object[numofobjects].texcoord[3][0]=0.0f;
  604. object[numofobjects].texcoord[3][1]=1.0f;
  605. object[numofobjects].soundnum[0]=-1;
  606. object[numofobjects].soundnum[1]=-1;
  607. object[numofobjects].soundnum[2]=-1;
  608. object[numofobjects].soundnum[3]=-1;
  609. numofobjects++;
  610. }
  611. void createbeast(int beasttype,float position[3],float sizex,float sizey,float mass,float friction)
  612. {
  613. int count,count2;
  614. float vec[3];
  615. memset(&object[numofobjects],0,sizeof(object[numofobjects]));
  616. object[numofobjects].type=4;
  617. object[numofobjects].timetolive=10000;
  618. object[numofobjects].beasttype=beasttype;
  619. object[numofobjects].animationnum=beasttype;
  620. object[numofobjects].texturenum=animation[object[numofobjects].animationnum].stand[0];
  621. object[numofobjects].mass=mass;
  622. object[numofobjects].hitpoints=250;
  623. if (beasttype==7 || beasttype==13)
  624. object[numofobjects].hitpoints=15000;
  625. object[numofobjects].size[0]=sizex;
  626. object[numofobjects].size[1]=sizey;
  627. object[numofobjects].numofparticles=4;
  628. if (sizex>=sizey)
  629. object[numofobjects].radius=sizex*1.5f;
  630. else
  631. object[numofobjects].radius=sizey*1.5f;
  632. object[numofobjects].friction=friction;
  633. count=0;
  634. vec[0]=-sizex*0.5f;
  635. vec[1]=sizey*0.5f;
  636. vec[2]=0.0f;
  637. addvectors(vec,vec,position);
  638. object[numofobjects].particle[count]=numofparticles;
  639. count++;
  640. createparticle(3,vec,NULL,mass*0.5f,-1,10000);
  641. vec[0]=sizex*0.5f;
  642. vec[1]=sizey*0.5f;
  643. vec[2]=0.0f;
  644. addvectors(vec,vec,position);
  645. object[numofobjects].particle[count]=numofparticles;
  646. count++;
  647. createparticle(3,vec,NULL,mass*0.5f,-1,10000);
  648. vec[0]=sizex*0.5f;
  649. vec[1]=-sizey*0.5f;
  650. vec[2]=0.0f;
  651. addvectors(vec,vec,position);
  652. object[numofobjects].particle[count]=numofparticles;
  653. count++;
  654. if (beasttype!=12)
  655. createparticle(3,vec,NULL,mass*0.5f,-1,10000);
  656. else
  657. createparticle(2,vec,NULL,mass*0.5f,-1,10000);
  658. vec[0]=-sizex*0.5f;
  659. vec[1]=-sizey*0.5f;
  660. vec[2]=0.0f;
  661. addvectors(vec,vec,position);
  662. object[numofobjects].particle[count]=numofparticles;
  663. count++;
  664. if (beasttype!=12)
  665. createparticle(3,vec,NULL,mass*0.5f,-1,10000);
  666. else
  667. createparticle(2,vec,NULL,mass*0.5f,-1,10000);
  668. for (count=0;count<object[numofobjects].numofparticles;count++)
  669. for (count2=count+1;count2<object[numofobjects].numofparticles;count2++)
  670. createbond(object[numofobjects].particle[count],object[numofobjects].particle[count2],6,numofobjects);
  671. copyvector(object[numofobjects].position,position);
  672. object[numofobjects].numofcdlines=4;
  673. for (count=0;count<4;count++)
  674. {
  675. object[numofobjects].cdline[count][0]=count;
  676. object[numofobjects].cdline[count][1]=((count+1)&3);
  677. }
  678. object[numofobjects].soundnum[0]=-1;
  679. object[numofobjects].soundnum[1]=-1;
  680. object[numofobjects].soundnum[2]=-1;
  681. object[numofobjects].soundnum[3]=-1;
  682. numofobjects++;
  683. }
  684. void createbobble(int beasttype,float position[3],float sizex,float sizey,float mass,float friction)
  685. {
  686. int count,count2;
  687. float vec[3];
  688. memset(&object[numofobjects],0,sizeof(object[numofobjects]));
  689. object[numofobjects].type=4;
  690. object[numofobjects].timetolive=10000;
  691. object[numofobjects].mass=mass;
  692. object[numofobjects].beasttype=beasttype;
  693. if (beasttype==1)
  694. object[numofobjects].texturenum=500;
  695. if (beasttype==2)
  696. object[numofobjects].texturenum=540;
  697. object[numofobjects].numofparticles=6;
  698. if (sizex>=sizey)
  699. object[numofobjects].radius=sizex*1.5f;
  700. else
  701. object[numofobjects].radius=sizey*1.5f;
  702. object[numofobjects].friction=friction;
  703. count=0;
  704. vec[0]=-sizex*0.5f;
  705. vec[1]=sizey*0.5f;
  706. vec[2]=0.0f;
  707. addvectors(vec,vec,position);
  708. object[numofobjects].particle[count]=numofparticles;
  709. count++;
  710. createparticle(3,vec,NULL,mass*0.25f,-1,10000);
  711. vec[0]=sizex*0.5f;
  712. vec[1]=sizey*0.5f;
  713. vec[2]=0.0f;
  714. addvectors(vec,vec,position);
  715. object[numofobjects].particle[count]=numofparticles;
  716. count++;
  717. createparticle(3,vec,NULL,mass*0.25f,-1,10000);
  718. vec[0]=sizex*0.5f;
  719. vec[1]=-sizey*0.5f;
  720. vec[2]=0.0f;
  721. addvectors(vec,vec,position);
  722. object[numofobjects].particle[count]=numofparticles;
  723. count++;
  724. createparticle(3,vec,NULL,mass*0.25f,-1,10000);
  725. vec[0]=-sizex*0.5f;
  726. vec[1]=-sizey*0.5f;
  727. vec[2]=0.0f;
  728. addvectors(vec,vec,position);
  729. object[numofobjects].particle[count]=numofparticles;
  730. count++;
  731. createparticle(3,vec,NULL,mass*0.25f,-1,10000);
  732. vec[0]=-sizex*0.25f;
  733. vec[1]=sizey*0.65f;
  734. vec[2]=0.0f;
  735. addvectors(vec,vec,position);
  736. object[numofobjects].particle[count]=numofparticles;
  737. count++;
  738. createparticle(3,vec,NULL,mass*0.25f,-1,10000);
  739. vec[0]=sizex*0.25f;
  740. vec[1]=sizey*0.65f;
  741. vec[2]=0.0f;
  742. addvectors(vec,vec,position);
  743. object[numofobjects].particle[count]=numofparticles;
  744. count++;
  745. createparticle(3,vec,NULL,mass*0.25f,-1,10000);
  746. for (count=0;count<object[numofobjects].numofparticles;count++)
  747. for (count2=count+1;count2<object[numofobjects].numofparticles;count2++)
  748. createbond(object[numofobjects].particle[count],object[numofobjects].particle[count2],6,numofobjects);
  749. object[numofobjects].numofcdlines=6;
  750. count=0;
  751. object[numofobjects].cdline[count][0]=4;
  752. object[numofobjects].cdline[count][1]=5;
  753. count=1;
  754. object[numofobjects].cdline[count][0]=5;
  755. object[numofobjects].cdline[count][1]=1;
  756. count=2;
  757. object[numofobjects].cdline[count][0]=1;
  758. object[numofobjects].cdline[count][1]=2;
  759. count=3;
  760. object[numofobjects].cdline[count][0]=2;
  761. object[numofobjects].cdline[count][1]=3;
  762. count=4;
  763. object[numofobjects].cdline[count][0]=3;
  764. object[numofobjects].cdline[count][1]=0;
  765. count=5;
  766. object[numofobjects].cdline[count][0]=0;
  767. object[numofobjects].cdline[count][1]=4;
  768. object[numofobjects].soundnum[0]=-1;
  769. object[numofobjects].soundnum[1]=-1;
  770. object[numofobjects].soundnum[2]=-1;
  771. object[numofobjects].soundnum[3]=-1;
  772. numofobjects++;
  773. }
  774. void createhead(float position[3],float sizex,float sizey,float mass,float friction)
  775. {
  776. int count;
  777. float vec[3];
  778. float angle;
  779. memset(&object[numofobjects],0,sizeof(object[numofobjects]));
  780. object[numofobjects].type=5;
  781. object[numofobjects].timetolive=10000;
  782. if (sizex>=sizey)
  783. object[numofobjects].radius=sizex*1.25f;
  784. else
  785. object[numofobjects].radius=sizey*1.25f;
  786. object[numofobjects].mass=mass;
  787. object[numofobjects].texturenum=animation[19].stand[0];
  788. object[numofobjects].friction=friction;
  789. object[numofobjects].numofparticles=8;
  790. for (count=0;count<8;count++)
  791. {
  792. angle=(float)count*pi/4.0f;
  793. vec[0]=position[0]+cos(angle)*sizex*0.5f;
  794. vec[1]=position[1]-sin(angle)*sizey*0.5f;
  795. vec[2]=0.0f;
  796. createparticle(3,vec,NULL,mass/8.0f,numofobjects,10000);
  797. object[numofobjects].particle[count]=numofparticles-1;
  798. }
  799. for (count=0;count<8;count++)
  800. {
  801. createbond(object[numofobjects].particle[((count+1)&7)],object[numofobjects].particle[count],1,numofobjects);
  802. createbond(object[numofobjects].particle[((count+2)&7)],object[numofobjects].particle[count],1,numofobjects);
  803. createbond(object[numofobjects].particle[((count+4)&7)],object[numofobjects].particle[count],1,numofobjects);
  804. }
  805. copyvector(object[numofobjects].position,position);
  806. object[numofobjects].numofcdlines=8;
  807. for (count=0;count<8;count++)
  808. {
  809. object[numofobjects].cdline[count][0]=count;
  810. object[numofobjects].cdline[count][1]=((count+1)&7);
  811. }
  812. object[numofobjects].soundnum[0]=-1;
  813. object[numofobjects].soundnum[1]=-1;
  814. object[numofobjects].soundnum[2]=-1;
  815. object[numofobjects].soundnum[3]=-1;
  816. numofobjects++;
  817. }
  818. void createamber(float position[3])
  819. {
  820. int count;
  821. float vec[3];
  822. float angle;
  823. memset(&object[numofobjects],0,sizeof(object[numofobjects]));
  824. object[numofobjects].type=6;
  825. object[numofobjects].timetolive=10000;
  826. object[numofobjects].radius=1.0f;
  827. object[numofobjects].texturenum=369;
  828. object[numofobjects].friction=0.3f;
  829. object[numofobjects].numofparticles=8;
  830. for (count=0;count<8;count++)
  831. {
  832. angle=(float)count*pi/4.0f;
  833. vec[0]=position[0]+cos(angle)*0.35f;
  834. vec[1]=position[1]-sin(angle)*0.35f;
  835. vec[2]=0.0f;
  836. createparticle(3,vec,NULL,0.125f,numofobjects,10000);
  837. object[numofobjects].particle[count]=numofparticles-1;
  838. }
  839. for (count=0;count<8;count++)
  840. {
  841. createbond(object[numofobjects].particle[((count+1)&7)],object[numofobjects].particle[count],1,numofobjects);
  842. createbond(object[numofobjects].particle[((count+2)&7)],object[numofobjects].particle[count],1,numofobjects);
  843. createbond(object[numofobjects].particle[((count+4)&7)],object[numofobjects].particle[count],1,numofobjects);
  844. }
  845. copyvector(object[numofobjects].position,position);
  846. object[numofobjects].numofcdlines=8;
  847. for (count=0;count<8;count++)
  848. {
  849. object[numofobjects].cdline[count][0]=count;
  850. object[numofobjects].cdline[count][1]=((count+1)&7);
  851. }
  852. object[numofobjects].soundnum[0]=-1;
  853. object[numofobjects].soundnum[1]=-1;
  854. object[numofobjects].soundnum[2]=-1;
  855. object[numofobjects].soundnum[3]=-1;
  856. numofobjects++;
  857. }
  858. void createareaswitch(float position[3],float sizex,float sizey)
  859. {
  860. memset(&object[numofobjects],0,sizeof(object[numofobjects]));
  861. object[numofobjects].type=16;
  862. object[numofobjects].timetolive=10000;
  863. copyvector(object[numofobjects].position,position);
  864. object[numofobjects].size[0]=sizex;
  865. object[numofobjects].size[1]=sizey;
  866. object[numofobjects].soundnum[0]=-1;
  867. object[numofobjects].soundnum[1]=-1;
  868. object[numofobjects].soundnum[2]=-1;
  869. object[numofobjects].soundnum[3]=-1;
  870. numofobjects++;
  871. }
  872. void creategenerator(float position[3],float mass)
  873. {
  874. memset(&object[numofobjects],0,sizeof(object[numofobjects]));
  875. object[numofobjects].type=15;
  876. object[numofobjects].timetolive=10000;
  877. object[numofobjects].mass=mass;
  878. copyvector(object[numofobjects].position,position);
  879. object[numofobjects].radius=2.0f;
  880. object[numofobjects].soundnum[0]=-1;
  881. object[numofobjects].soundnum[1]=-1;
  882. object[numofobjects].soundnum[2]=-1;
  883. object[numofobjects].soundnum[3]=-1;
  884. numofobjects++;
  885. }
  886. void deleteobject(int objectnum)
  887. {
  888. int count;
  889. if (objectnum<0)
  890. return;
  891. if (objectnum>=numofobjects)
  892. return;
  893. for (count=0;count<object[objectnum].numofparticles;count++)
  894. {
  895. particle[object[objectnum].particle[count]].timetolive=1;
  896. particle[object[objectnum].particle[count]].objectnum=-1;
  897. }
  898. for (count=0;count<numofobjects;count++)
  899. if (object[count].link==objectnum)
  900. object[count].link=-1;
  901. for (count=0;count<numofropes;count++)
  902. if (rope[count].link==objectnum)
  903. rope[count].link=-1;
  904. for (count=0;count<numofbonds;count++)
  905. if (bond[count].type!=4 && bond[count].type!=7)
  906. if (bond[count].objectnum==objectnum)
  907. bond[count].objectnum=-1;
  908. deletesound(object[objectnum].soundnum[0]);
  909. deletesound(object[objectnum].soundnum[1]);
  910. deletesound(object[objectnum].soundnum[2]);
  911. deletesound(object[objectnum].soundnum[3]);
  912. numofobjects--;
  913. if (objectnum==numofobjects)
  914. return;
  915. memcpy(&object[objectnum],&object[numofobjects],sizeof(object[objectnum]));
  916. for (count=0;count<object[objectnum].numofparticles;count++)
  917. if (particle[object[objectnum].particle[count]].objectnum!=-1)
  918. particle[object[objectnum].particle[count]].objectnum=objectnum;
  919. for (count=0;count<numofobjects;count++)
  920. if (object[count].link==numofobjects)
  921. object[count].link=objectnum;
  922. for (count=0;count<numofropes;count++)
  923. if (rope[count].link==numofobjects)
  924. rope[count].link=objectnum;
  925. for (count=0;count<numofbonds;count++)
  926. if (bond[count].type!=4 && bond[count].type!=7)
  927. if (bond[count].objectnum==numofobjects)
  928. bond[count].objectnum=objectnum;
  929. for (count=0;count<numofsounds;count++)
  930. if (sound[count].objectnum==numofobjects)
  931. sound[count].objectnum=objectnum;
  932. }
  933. void deleterope(int ropenum)
  934. {
  935. int count;
  936. if (ropenum<0)
  937. return;
  938. if (ropenum>=numofropes)
  939. return;
  940. if (rope[ropenum].type==1)
  941. playsound(3,particle[rope[ropenum].part1].position,NULL,1.0f,0,1.0f,-1,0);
  942. if (rope[ropenum].type==2)
  943. playsound(3,particle[rope[ropenum].part1].position,NULL,1.0f,0,0.75f,-1,0);
  944. if (rope[ropenum].type==3)
  945. playsound(4,particle[rope[ropenum].part1].position,NULL,1.0f,0,1.0f,-1,0);
  946. if (rope[ropenum].type==4)
  947. playsound(4,particle[rope[ropenum].part1].position,NULL,1.0f,0,0.75f,-1,0);
  948. numofropes--;
  949. if (ropenum==numofropes)
  950. return;
  951. memcpy(&rope[ropenum],&rope[numofropes],sizeof(rope[0]));
  952. for (count=0;count<numofbonds;count++)
  953. if (bond[count].type==4 || bond[count].type==7)
  954. if (bond[count].objectnum==numofropes)
  955. bond[count].objectnum=ropenum;
  956. }
  957. void objecttimetolive(void)
  958. {
  959. int count;
  960. count=0;
  961. while (count<numofobjects)
  962. {
  963. if (object[count].timetolive<10000)
  964. object[count].timetolive--;
  965. while (count<numofobjects && object[count].timetolive<0)
  966. {
  967. deleteobject(count);
  968. if (object[count].timetolive<10000)
  969. object[count].timetolive--;
  970. }
  971. count++;
  972. }
  973. }
  974. void createcar(float position[3],float sizex,float sizey,float mass,float friction)
  975. {
  976. int count,count2;
  977. float vec[3];
  978. memset(&object[numofobjects],0,sizeof(object[numofobjects]));
  979. object[numofobjects].type=20;
  980. object[numofobjects].timetolive=10000;
  981. object[numofobjects].mass=mass;
  982. object[numofobjects].numofparticles=4;
  983. if (sizex>=sizey)
  984. object[numofobjects].radius=sizex*1.5f;
  985. else
  986. object[numofobjects].radius=sizey*1.5f;
  987. object[numofobjects].size[0]=sizex;
  988. object[numofobjects].size[1]=sizey;
  989. object[numofobjects].friction=friction;
  990. count=0;
  991. vec[0]=-sizex*0.5f;
  992. vec[1]=sizey*0.5f;
  993. vec[2]=0.0f;
  994. addvectors(vec,vec,position);
  995. object[numofobjects].particle[count]=numofparticles;
  996. count++;
  997. createparticle(6,vec,NULL,mass*0.25f,-1,10000);
  998. vec[0]=sizex*0.5f;
  999. vec[1]=sizey*0.5f;
  1000. vec[2]=0.0f;
  1001. addvectors(vec,vec,position);
  1002. object[numofobjects].particle[count]=numofparticles;
  1003. count++;
  1004. createparticle(6,vec,NULL,mass*0.25f,-1,10000);
  1005. vec[0]=sizex*0.5f;
  1006. vec[1]=-sizey*0.5f;
  1007. vec[2]=0.0f;
  1008. addvectors(vec,vec,position);
  1009. object[numofobjects].particle[count]=numofparticles;
  1010. count++;
  1011. createparticle(6,vec,NULL,mass*0.25f,-1,10000);
  1012. vec[0]=-sizex*0.5f;
  1013. vec[1]=-sizey*0.5f;
  1014. vec[2]=0.0f;
  1015. addvectors(vec,vec,position);
  1016. object[numofobjects].particle[count]=numofparticles;
  1017. count++;
  1018. createparticle(6,vec,NULL,mass*0.25f,-1,10000);
  1019. for (count=0;count<object[numofobjects].numofparticles;count++)
  1020. for (count2=count+1;count2<object[numofobjects].numofparticles;count2++)
  1021. createbond(object[numofobjects].particle[count],object[numofobjects].particle[count2],9,-1);
  1022. copyvector(object[numofobjects].position,position);
  1023. object[numofobjects].numofcdlines=4;
  1024. for (count=0;count<4;count++)
  1025. {
  1026. object[numofobjects].cdline[count][0]=count;
  1027. object[numofobjects].cdline[count][1]=((count+1)&3);
  1028. }
  1029. object[numofobjects].texcoord[0][0]=0.0f;
  1030. object[numofobjects].texcoord[0][1]=0.0f;
  1031. object[numofobjects].texcoord[1][0]=1.0f;
  1032. object[numofobjects].texcoord[1][1]=0.0f;
  1033. object[numofobjects].texcoord[2][0]=1.0f;
  1034. object[numofobjects].texcoord[2][1]=1.0f;
  1035. object[numofobjects].texcoord[3][0]=0.0f;
  1036. object[numofobjects].texcoord[3][1]=1.0f;
  1037. object[numofobjects].soundnum[0]=-1;
  1038. object[numofobjects].soundnum[1]=-1;
  1039. object[numofobjects].soundnum[2]=-1;
  1040. object[numofobjects].soundnum[3]=-1;
  1041. numofobjects++;
  1042. }