Re: Question about vector object in BGT

2014-12-11 Thread AudioGames . net Forum — Developers room : yukionozawa via Audiogames-reflector


  


Re: Question about vector object in BGT

Hmm, weird thing, but thanks for help.

URL: http://forum.audiogames.net/viewtopic.php?pid=197184#p197184




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Question about vector object in BGT

2014-12-09 Thread AudioGames . net Forum — Developers room : yukionozawa via Audiogames-reflector


  


Question about vector object in BGT

Hi.I want to create vector normalization function in BGT, but have an error. It says that object handle for vector object isnt supported.Is it really impossible to use vectors as parameters or return value? Here is the current script. vector@ normalize(vector@ pv){//Normalizes the specified vectorfloat shrink=1/pv.length();return vector(pv.x*shrink,pv.y*shrink);}void main(){vector test(3,3);vector ret=normalize(test);alert(Result,The normalized test vectors x value is +ret.x+, and y value is +ret.y+);exit();}Im experimenting an advanced object movement that requires a lot of figical calculation.

URL: http://forum.audiogames.net/viewtopic.php?pid=196941#p196941




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Question about vector object in BGT

2014-12-09 Thread AudioGames . net Forum — Developers room : yukionozawa via Audiogames-reflector


  


Question about vector object in BGT

Hi.I want to create vector normalization function in BGT, but have an error. It says that object handle for vector object isnt supported.Is it really impossible to use vectors as parameters or return value? Here is the current script. vector@ normalize(vector@ pv){//Normalizes the specified vectorfloat shrink=1/pv.length();return vector(pv.x*shrink,pv.y*shrink);}void main(){vector test(3,3);vector ret=normalize(test);alert(Result,The normalized test vectors x value is +ret.x+, and y value is +ret.y+);exit();}Im experimenting an advanced object movement that requires a lot of physical calculation.

URL: http://forum.audiogames.net/viewtopic.php?pid=196941#p196941




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Question about vector object in BGT

2014-12-09 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: Question about vector object in BGT

This is a little weird, but I think the vector object is setup to let you bypass handles, by overloading opAssign and opCmp.You can probably remove the [ a-t ] from the function, but if you keep it, this line:vector ret=normalize(test);Probably needs the [ a-t ]:vector@ ret=normalize(test);But I think, for vectors, you can ignore handles entirely.I was confused, originally, but all of these functions appear to work: vector rotate(vector p, vector o, double theta) {
 vector r;
r.x = (cosine(theta) * (p.x-o.x)) - (sine(theta) * (p.y-o.y)) + o.x;
r.y = (sine(theta) * (p.x-o.x)) + (cosine(theta) * (p.y-o.y)) + o.y;
 return r;
 }// Rotate.
vector get_vector(double x, double y, double z=0) {vector ret(x, y, z); return ret;}


vector cross(vector a, vector b) {
 vector c;
c.x = (a.y*b.z) - (a.z*b.y);
c.y = (a.z*b.x) - (a.x*b.z);
c.z = (a.x*b.y) - (a.y*b.x);
 return c;
}

double dot(vector a, vector b) {
return (a.x * b.x) + (a.y * b.y) + (a.z * b.z);
}It does present problems, if, for example, you need a vector to be null. I got around the uncertainty by assigning a vector I would never use to represent null, but this only works if you are sure youll never need that specific vector.

URL: http://forum.audiogames.net/viewtopic.php?pid=196979#p196979




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Question about vector object in BGT

2014-12-09 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: Question about vector object in BGT

Wait. Does bgt not support the c-style pointer dereference?In C/C++, youd handle interoperating between pointres and functions taking and returning by value like this:result = normalize(*vec);
*vec = whatever(some_param1);Does BGT not have an equivalent? Because from where Im standing its a lot better than using a magic vector value. It should at least crash instead of invisibly doing the wrong thing if you accidentally use a null handle, but maybe the language doesnt allow it.

URL: http://forum.audiogames.net/viewtopic.php?pid=196992#p196992




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Question about vector object in BGT

2014-12-09 Thread AudioGames . net Forum — Developers room : CAE_Jones via Audiogames-reflector


  


Re: Question about vector object in BGT

BGTs handles and C-style pointers are different, not in especially clear ways. I think its more analogous to C#, but I havent actually paid enough attention to C# to be sure.Handles function like pointers to objects, and most of the time this is pretty stable: use handles for everything, except initializing the object that you will then attach to a handle.Vectors and arrays can get away with being treated as primitives, for all sorts of fun confusion like the above.

URL: http://forum.audiogames.net/viewtopic.php?pid=197012#p197012




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector

Re: Question about vector object in BGT

2014-12-09 Thread AudioGames . net Forum — Developers room : camlorn via Audiogames-reflector


  


Re: Question about vector object in BGT

I got curious. You can do that operator overloading yourself and it turns out that Bgt has better documentation for Angelscript than the Angelscript manuals. I know because I looked at using Angelscript once (briefly, because I read the manual and it was, shall we say, special).I cant find anything definitive on the semantics of handles, though Im kind of thinking of them as Python-but-with-syntax. Im assuming theyre at least good enough to handle circular references. On account that there seems to be no special new syntax, I think that the problem here might simply be that the function is trying to return by value but is configured to return by reference. The fact that Im a really advanced C++ programmer and cannot definitively answer this question is disturbing me.As for the thing here, though, if its going to be a lot, consider not returning anything by value. You could restructure so that the r
 esult of any vector-to-vector operation puts its answer in the first result or so that all functions take a third parameter. In terms of performance, it might or might not help; measuring is your god when optimizing.But on the other hand-um, well, you can do these calculations in pure Python for hundreds and hundreds of units and still run in realtime, and if youre considering going beyond a certain point you should just use ODE or Box2d and leave BGT because getting that math right is hard even for people who fully understand whats going on. Since Python is actually slower than BGT, or at least as far as I know, Id not worry about it too much.

URL: http://forum.audiogames.net/viewtopic.php?pid=197016#p197016




___
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector