ModelInstance* mi = modelManager->getModelInstance("f:\\blender\\sign.zppz"); if (mi) { mi->matrix = Matrix::translation(2, 4.25f ,3) * Matrix::yrotation(0.3f); mi->outlineMeshInstance->color = Vector(0, 1, 0); } //... use model ... modelManager->releaseModelInstance(mi);This loads a model and its textures, and sets up shaders for it. It will be culled if offscreen, and its flags will be altered if it is under the mouse cursor. No resources are loaded in duplicate, all memory is taken care of, minimal state changes during render. Control over attributes is done by changing members of mi.
//in NetworkMessage class NetworkMessage* clone() { char* data; int length; NetworkMessage* instance = getInstance(); //pure virtual pack(data, length); //pack this class into data instance->unpack(data, length); //unpack data into the new instance, sweeeet delete[] data; return instance; }A better long term solution would be to still do the reference counting but store sequence numbers separately, gotta keep things moving along though.
<object name="cow" type="projectile" /> <object name="catapultButton"> <regular action="blink" param="10,20" /> <touch action="trigger" param="remoteTriggerCatapult" /> </object> <object name="remoteTriggerCatapult"> <apply action="hold" param="projectile" /> <trigger action="run" /> </object> <object name="selfTriggerCatapult"> <apply action="hold" param="projectile" /> <touch action="trigger" param="selfTriggerCatapult" /> <trigger action="run" /> </object>Parameters are just a string which will be parsed differently depending on the action, eg. the hold action may do nothing if the type of object being applied to it is not correct. In the last case there, after getting a cow you would need to click the catapult twice: once to put the cow in (apply) then once again (touch, because now you are carrying nothing) to set it off. This could be changed to a one-click action by changing the 'trigger' action into an 'apply' element as well. Adding another trigger to the button could set off both catapults, in this way actions can be chained and branched etc.
int main(int argc, char* argv[]) { char* data; int length; unsigned long sin_addr, clientSinAddr = 0; char* hostname; unsigned short port; UdpSocket s; s.bindTo(fakeServerPort, true); s.setBlocking(true); while (true) { s.recvDgramFrom(data, length, sin_addr, hostname, port); printf("Received dgram from %s : %d, Length = %d\n", hostname, port, length); MINISOCK_SLEEP(300); if (port != realServerPort) {//message from client clientSinAddr = sin_addr; s.sendDgramTo(data, length, "localhost", realServerPort); } else {//message from server if (clientSinAddr) s.sendDgramTo(data, length, clientSinAddr, clientPort); } delete[] data; } return 0; }Of course there's a bit more work to do to handle multiple clients but as a start it's great for getting an idea of how someone would feel at playing at a given ping rate