Page 1 of 1
spawn a complicated object
Posted:
Sat Feb 20, 2010 3:03 pm
by canadian joe
is it possible to spawn a complex object? like a polygon. or a shape normally made with the brush tool? if there is than i have a creepy idea for a scene. seriously is there an oncollide code that can do this.
Re: spawn a complicated object
Posted:
Sat Feb 20, 2010 3:05 pm
by KarateBrot
Yes it is. But you can spawn much more complex things than just a polygon. You can for example spawn a whole scene with an onCollide script
For polygons you have to define the surface.
- Code: Select all
scene.addpolygon({ vecs := [[x1, y1],[x2, y2],[x3, y3],...[xn, yn]]; })
That's the basic script. Of course you can also add the spawning position or color or whatever. [xi, yi] is the i-th surface position.
Re: spawn a complicated object
Posted:
Sat Feb 20, 2010 3:09 pm
by canadian joe
is there a script code to spawn a hand shaped thing that would normally be made with a brush tool.
Re: spawn a complicated object
Posted:
Sat Feb 20, 2010 3:12 pm
by KarateBrot
For example:
- Code: Select all
scene.addpolygon({ vecs := [[2,2], [-1,1], [-1,-1], [1,-1]]; pos := [0,0] })
Will spawn a 4-sided polygon at position [0,0]
Check this scene out. Maybe it helps.
Rating: Filesize: 14.76 kB
Comments: 13
Ratings: 20
Well, I thought about it but it's maybe too advanced...
Re: spawn a complicated object
Posted:
Sat Feb 20, 2010 3:15 pm
by canadian joe
Re: spawn a complicated object
Posted:
Sat Feb 20, 2010 3:19 pm
by KarateBrot
Yes, that's a lot of work if you do it by hand and if you have very much surface points. You could make it automatic with a function but that's maybe a bit too advanced.
But what you can do is to make a polygon with your drawing tool. Then you just have to select the polygon and press CTRL + C. In a text editor you have to press CTRL + V and you get all coordinates.
Re: spawn a complicated object
Posted:
Sat Feb 20, 2010 3:23 pm
by canadian joe
that sound much easier. i started doing it be hand and it really is kinda trial and error plus there would be alot o points to made a decent shaped hand.
Re: spawn a complicated object
Posted:
Sat Feb 20, 2010 9:09 pm
by canadian joe
Re: spawn a complicated object
Posted:
Sun Feb 21, 2010 12:10 am
by KarateBrot
are you sure you didn't forget any brackets or commas or something else?
Be sure to make [ ] brackets around all your points => [ [2,2], [-1,1], [-1,-1], [1,-1] ]
Re: spawn a complicated object
Posted:
Sun Feb 21, 2010 9:00 pm
by fox11trot
Re: spawn a complicated object
Posted:
Mon Feb 22, 2010 4:13 am
by Versieon
Actualy, there are two sets of brackets [[ [0,1],[0,0],[1,0],[1,1] ]]
That should work.
And I made a scaner / spawner that reads shapes and spits them out, it uses a polygon spwn code.
Here, I'll upload it.
Re: spawn a complicated object
Posted:
Mon Feb 22, 2010 7:29 am
by KarateBrot
the important thing is to have a 2 dimensional array (an array with arrays in it). two sets of brackets make it a 3 dimensional array. you will get an error message.
Re: spawn a complicated object
Posted:
Tue Feb 23, 2010 4:44 am
by Versieon
Huh, I always have to have two sets, it won't work otherwise,.
Yes, i just checked it.
Look at the scipts for putting the array together, it has 2 at the begining and the end, without it it gives an error message saying not a real list.
Rating: Filesize: 25.52 kB
Comments: 10
Ratings: 4
Re: spawn a complicated object
Posted:
Tue Feb 23, 2010 6:16 am
by KarateBrot
Hmm yeah, indeed. Maybe it has something to do with your use of eval or something different because normally you get an error message if it's not a two-dimensional array. Maybe you have to add an extra pair of brackets because they get removed/ignored somewhere in a function so at the end you get a two-dimensional array and no three-dimensional one. after looking at different error messages with different numbers of brackets i am pretty sure it has something to do with it.
besides: you made a very complicated scripting part. it can be done MUCH easier but nice one for going the complicated way
Re: spawn a complicated object
Posted:
Thu Feb 25, 2010 2:38 am
by canadian joe
for some reason my ctrl+C ctrl+v isn't working anymore. it used to work but now nothing is happeneing
Re: spawn a complicated object
Posted:
Thu Feb 25, 2010 1:59 pm
by Chronos
Some people seem to have that problem. As far as I know, there's no fix.
Re: spawn a complicated object
Posted:
Fri Feb 26, 2010 12:17 am
by canadian joe
it works! now i have a script that spawns a polygon. how do you set it's size?
Re: spawn a complicated object
Posted:
Fri Feb 26, 2010 12:39 am
by Versieon
the vecs that you put in determin the size of the polygon
Re: spawn a complicated object
Posted:
Fri Feb 26, 2010 1:19 am
by KarateBrot
jup you should do that already in the vecs that's the best way. but if you want to scale the polygon you still can multiplicate the vecs with a factor to make the polygon bigger/smaller.
For example to make it double sized
- Code: Select all
scene.addpolygon({ vecs := 2*[[2,2], [-1,1], [-1,-1], [1,-1]]; pos := [0,0] })
Re: spawn a complicated object
Posted:
Fri Feb 26, 2010 2:18 am
by canadian joe