Madcap

Members
  • Content count

    13
  • Joined

  • Last visited

Community Reputation

122 Neutral

About Madcap

  • Rank
    Member

Personal Information

  • Interests
    Programming
  1. Developement alone need help and Tips

    Bullet Physics is pretty easy and a good place to start for object collision, using primitives or simplified convex shapes. It's dead simple to integrate and get going with. I'd recommend it as a place to start .
  2. Passing Script Objects

    Thanks. It turns out that I can just pass the first script object to the constructor of the second object (setargobject) by it's classname in AS, which gives me direct access to the variables of that instance. I'll just have to be careful that the first exists and figure out a way for the second to fetch the object that it needs. Edit: CScriptHandle and casting has made it easy to fetch a generic ref (script object) from the C++ object handle. I think this will work.
  3. Passing Script Objects

    Hi again, I have one C++ class (registered as a reference in angelscript) that creates and executes a unique script which finally stores a few variables in the script object (class). The C++ object is stored in C++ (unordered map, for now) and the C++ class stores the asIscriptobject. I have another class set up the same way. This other class calls a C++ function which executes its own unique script, and in that script function it calls a C++ function to get a reference to the first C++ object. How would I get access within the second script to the first script object, so I can access the variables stored in that script object?
  4. Global Operator

    OK, I put all the binary operators that deal with the member property into their classes. The few funny ones remaining will have to stay outside. However, they're only used to simplify a few expressions in the matrices and quaternion classes, so it's doubtful that they will be needed on the scripting side. In fact, what confused me is that I put them in the class source file based on their return type when I wrote them long ago, when they should really be put in a source on their own or where they are actually used. I'll carry on registering them all (the first couple went OK). Thanks for your help.
  5. Global Operator

    After coming out of hibernation I realised that I forgot to actually register the global one. The script appears to be treating floats, including written numbers (eg. 2.0f), like an Obj. The one opSub actually setup takes only an Obj. I get syntax error when I try and write the same bit of math in raw C++. So if I used "obj = obj2 - 2.0f - obj3 - 10.0f" in script, it will call that one method operator and pass 2.0f or 10.0f to the Obj parameter. Say Obj is a Vec2, then both floats are set to 2.0f or 10.0f. For this test the result is the same. I believe it's using "asBEHAVE_CONSTRUCT, "void f(const float)" to assign the Obj in the operator parameter. This will break things later on, since it needs to be a lot more strict about what is being passed.
  6. Blank Programmer.

    I find once you've mastered one language and programming in general, picking up another language is simple. Of course, you will forget things if you've been away from a language for a while which is why you should keep your old sources close by. Research and experimentation... it never ends, it only drives you mad.
  7. Global Operator

    Thanks, I think that worked. It's giving me the correct sum. RegisterGlobalFunction("const Obj opSub(const float &in)", asFUNCTIONPR(operator-, (const float &, const Obj &), const Obj), asCALL_CDECL_OBJLAST) I'm using a static member function in each class to register each class. I had to take the above code out of that method because it was pointing to the member operator I also set up: const Obj operator - (const Obj &v) const; RegisterObjectMethod("Obj", "const Obj opSub(const Obj &in) const", asMETHODPR(Obj, operator-, (const Obj &) const, const Obj), asCALL_THISCALL) I'll put it in with the overridable construct functions under a private namespace. I might put all the binary ops relating to this object in there, to keep things neat and save me from having to recode them in C++.
  8. Global Operator

    They're outside the class because it was easier to implement them to work with all the other classes in the same group that interact with each other. Anyway, I put one of them into the class and got it to work after I registered the assignment operator. I'll do some testing and see how it works. I'm curious why I can't register an operator as a global function, though. I use these classes to write out some complex math, and there are cases where I use three or more binary operator functions, like so: const Obj operator - (const Obj &a, const Obj &b); const Obj operator - (const Obj &a, const float &b); const Obj operator - (const float &a, const Obj &b); Using only one parameter, like they are as class members, would cause problems when trying to override an operator, because two would have the same signature. Maybe I can have some binary ops in the class and the remaining outside. I don't think I will need every conceivable scenario on the scripting side, but any suggestions to get this to all work at both ends would be appreciated. Basically: const Obj operator - (const float &a, const Obj &b); Isn't using the member properties, since it's just a single float subtracted by an Obj then returning the sum as Obj. I don't know where else to put it other than outside of the class.
  9. Global Operator

    I'm setting up a class as a value type using "asOBJ_VALUE | asOBJ_POD | asGetTypeTraits<Obj>()" flags in the registerobjecttype function. I've set up the object properties, methods, override methods and the operators. However, some operators for this object type are global and take the two parameters. I'm trying to register them as global functions with this (C++ operator prototype is beneath too: RegisterGlobalFunction("const Obj opMul(const Obj &in, const Obj &in)", asFUNCTIONPR(operator*, (const Obj&, const Obj&), const Obj, asCALL_CDECL); const Obj operator * (const Obj &a, const Obj &b); And while I'm not getting any syntax errors, and that it appears to register without errors, it doesn't work in script: These 'global;' operators are for the "val * val" and the member operators use the assignment "*=". Also, I had to add the "asGetTypeTraits<Obj>()" flag so I can use the return by value that the global operator uses.
  10. Reference Counting Problem

    I just felt it was easier to share the math classes and pass objects to and from the scripts as pointers, whilst storing some of them in the scripts. The problem I was having is the added 4 bytes from the counter. Considering the openGL function takes a float pointer and that I would normally do the selection to build this array of data in the rendering loop, I decided I could probably just use a Union. Something like this: union { struct { float x, y, z; }; struct { float array[3]; }; }; I can then just use obj.array and push that into a float array to then pass to openGL. I'll look into some of your suggestions (I've only had a few days with AS).
  11. I have a 1st class honours degree in game technology, but this only really helped me function in a professional environment and to address everything there was to know (AI, Engines, Research, Design, Pitching, Programming (multiple languages), Scripting, Maya, creating games in teams etc etc). You know, that horrid thing called "team work" which those who work alone and in the dark tend to hate. I had many years of experience with C++ and OpenGL, so I went into it with a lot of knowledge. Plus I've worked extensively on the older Unreal Engines. For graphics programming I am self taught, but then what's the difference between learning something through an assignment or casually reading books and internet articles? It's the same thing except the latter may take a little longer. It basically depends on your willingness to learn and how much self-discipline you have.
  12. How do i access the sound buffer for win32 ?

    XAudio is pretty easy to set up and use compared to the old DirectSound. However, if you want something easy and portable then there are things like OpenAL or the still maintained OpenAL Soft. Anything more powerful usually costs money.
  13. Reference Counting Problem

    Hi, I wish to register my math classes with Angelscript and use reference counting to manage the memory. However, the problem I have with this is the need to add an integer to the class to keep track of the number of references to the object used (addref/release methods). The reason for this is that my math classes work with OpenGL, so when I pass an array (pointer) of matrices or vectors, they will work directly with opengl shader programs. Adding an integer would break this and was wondering if there's a way to solve this problem without using external reference counters which would need a lookup and slow the whole thing down. I'm hoping somebody can help me overcome this problem. Thanks. C++