コード例 #1
0
void StateFollowRoute::action()
{
	updateDeltaTime();

	// Get a path from the state owner's position to the first point in the route
	std::vector<irr::core::vector3df> path = pathUtil->returnPath(&stateOwner->getPosition(), &(route.at(pointToVisit).first));

	// If there is a path to the next point
	if (!path.empty() && path.size() > 1)
	{
		// Move to it
		if (stateOwner->getPosition().getDistanceFrom(path.at(1)) > offset)
		{
			// Call callback method - boolean is false, not waiting at a point
			callbackFunction(&std::make_pair(false, &path.at(1)));
		}
		// If the point is reached
		else
		{
			// Callback method - boolean is true, waiting at a point
			callbackFunction(&std::make_pair(true, &path.at(1)));

			// Increase timer
			timer += frameDeltaTime;

			// Wait for an amount of time if specified
			if (timer >= route.at(pointToVisit).second)
			{
				if (++pointToVisit >= route.size())
					pointToVisit = 0;
				timer = 0;
			}
		}
	}
}
コード例 #2
0
ファイル: input.cpp プロジェクト: KIAaze/iteam_hacking
void GP2DInputHandler::handleFPJoystickInputEvents() {
    gp2dInt32 device, button, value, state;
    GP2DJoyEvent::GP2DJoyAxis axis;
    axis = static_cast<GP2DJoyEvent::GP2DJoyAxis>(m_event.jaxis.axis);
    button = m_event.jbutton.button;
    value = m_event.jaxis.value;
    state = m_event.jbutton.state;
    device = -1;

    if(m_event.type == SDL_JOYAXISMOTION){
        device = m_event.jaxis.which;
    }
    if(m_event.type == SDL_JOYBUTTONDOWN || m_event.type == SDL_JOYBUTTONUP){
        device = m_event.jbutton.which;
    }

    GP2DJoyEvent event(device, axis, value, button, state);

    if(m_event.type == SDL_JOYBUTTONDOWN){
        map<gp2dInt32, void(*)(void)>::iterator it_basic;
        it_basic = m_mapBasicJoyButtonDown.find(button);
        if(it_basic != m_mapBasicJoyButtonDown.end()){
                void (*callbackFunction)(void);
                callbackFunction = it_basic->second;
                callbackFunction();
        }
    } else if(m_event.type == SDL_JOYBUTTONUP){
        map<gp2dInt32, void(*)(void)>::iterator it_basic;
        it_basic = m_mapBasicJoyButtonUp.find(button);
        if(it_basic != m_mapBasicJoyButtonUp.end()){
                void (*callbackFunction)(void);
                callbackFunction = it_basic->second;
                callbackFunction();
        }
    }
    else if(m_event.type == SDL_JOYAXISMOTION){
        map<gp2dInt32, void(*)(gp2dInt32)>::iterator it_basic;
        it_basic = m_mapBasicJoyAxisChange.find(axis);
        if(it_basic != m_mapBasicJoyAxisChange.end()){
                void (*callbackFunction)(gp2dInt32);
                callbackFunction = it_basic->second;
                callbackFunction(value);
        }
    }
}
コード例 #3
0
ファイル: input.cpp プロジェクト: KIAaze/iteam_hacking
void GP2DInputHandler::handleFPMouseInputEvents() {
    GP2DMouseEvent::GP2DMouseButton button;
    button = static_cast<GP2DMouseEvent::GP2DMouseButton>(m_event.button.button);
    
    // yes, there is, now issue the callbacks. 
    int x = m_event.motion.x;
    int y = m_event.motion.y;
    
    GP2DMouseEvent event(x, y, button);
    
    if(m_event.type == SDL_MOUSEBUTTONDOWN) {
        map<GP2DMouseEvent::GP2DMouseButton, void(*)(GP2DMouseEvent&)>::iterator it;
        it = m_mapBasicMouseDown.find(button);
        
        if(it != m_mapBasicMouseDown.end()) {
            void (*callbackFunction)(GP2DMouseEvent&);
            callbackFunction = it->second;
            callbackFunction(event);
        }
    } else if(m_event.type == SDL_MOUSEBUTTONUP) {
        map<GP2DMouseEvent::GP2DMouseButton, void(*)(GP2DMouseEvent&)>::iterator it;
        it = m_mapBasicMouseUp.find(button);
        
        if(it != m_mapBasicMouseUp.end()) {
            void (*callbackFunction)(GP2DMouseEvent&);
            callbackFunction = it->second;
            callbackFunction(event);
        }
    } else if (m_event.type == SDL_MOUSEMOTION) {
        set<void(*)(GP2DMouseEvent&)>::iterator it;
        for (it = m_setBasicMouseMove.begin(); it != m_setBasicMouseMove.end(); it++) {
            // *it is a function pointer
            if(*it != NULL) {
                (*it)(event); // call the callback function with a param.
            }
        }
    }
}
コード例 #4
0
void drawRecurse(void (*callbackFunction)(ObjectAddress), SceneGraphNode* node,bool preTransform){
#ifndef XSICONVERT

	FloatVector3d pos,rot,scale;

	if(node->object.type==OBJECT){

		if(node->object.object->envelopes.size()>0){
			pos=node->object.object->basePos;
			rot=node->object.object->baseRot;
			scale=node->object.object->baseScale;
		}else{
			pos=node->object.object->pos;
			rot=node->object.object->rot;
			scale=node->object.object->scale;
		}

	}else if(node->object.type==NULL3D){
		pos=node->object.null->pos;
		rot=node->object.null->rot;
		scale=node->object.null->scale;
	}else if(node->object.type==IK_ROOT){
		pos=node->object.ikRoot->pos;
		rot=node->object.ikRoot->rot;
		scale=node->object.ikRoot->scale;
	}else if(node->object.type==IK_JOINT){
		pos=node->object.ikJoint->pos;
		rot=node->object.ikJoint->rot;
		scale=node->object.ikJoint->scale;
	}else if(node->object.type==IK_EFFECTOR){
		pos=FloatVector3d();
		rot=FloatVector3d();
		scale=FloatVector3d(1,1,1);
	}else if(node->object.type==LIGHT){
		pos=node->object.light->pos;
		rot=node->object.light->rot;
		scale=node->object.light->scale;
	}else{

	}

	if(node->draw && !preTransform){

		if(node->object.type==OBJECT){
			if(node->object.object->envelopeVerticesCount>1){
			
				for(int i=0; i<node->object.object->envelopeVerticesCount; i++){
					node->object.object->drawCurrentEnvelope=i;
					callbackFunction(node->object);
				}
			}else{
				callbackFunction(node->object);
			}
		}else{
			callbackFunction(node->object);
		}
	}

#ifndef SOFTWARE_TRANSFORMS

	glMatrixMode(GL_MODELVIEW);
	glPushMatrix();

	glTranslatef(pos.x,pos.y,pos.z);
	glRotatef(rot.z,0.0f,0.0f,1.0f);
	glRotatef(rot.y,0.0f,1.0f,0.0f);
	glRotatef(rot.x,1.0f,0.0f,0.0f);
	glScalef(scale.x,scale.y,scale.z);

	if(node->object.type==IK_EFFECTOR){
		IkRoot* r=node->object.ikEffector->root;

		if(r->sceneGraphNode!=node->parent){
			//we only really care where the root is
			//so if the root isn't our parent, we need to trace to the root
			//argh


			glMatrixMode(GL_MODELVIEW);
			glPushMatrix();

			glLoadIdentity();
			level->camera->transform();
			sceneGraph.modelviewTransform(&sceneGraph.root,r->sceneGraphNode);


		}

		for(int i=0; i<r->joints.size(); i++){

			IkJoint* j=r->joints[i];

			glRotatef(j->rot.z,0.0f,0.0f,1.0f);
			glRotatef(j->rot.y,0.0f,1.0f,0.0f);
			glRotatef(j->rot.x,1.0f,0.0f,0.0f);
			glScalef(j->scale.x,j->scale.y,j->scale.z);

			glTranslatef(j->length,0,0);
			

		}
	}

#endif

	if(node->draw && preTransform){

		if(node->object.type==OBJECT){
			if(node->object.object->envelopeVerticesCount>1){
			
				for(int i=0; i<node->object.object->envelopeVerticesCount; i++){
					node->object.object->drawCurrentEnvelope=i;
					callbackFunction(node->object);
				}
			}else{
				callbackFunction(node->object);
			}
		}else{
			callbackFunction(node->object);
		}
	}

	Array<SortItem> sortids;

	FloatVector3d p;
	
	for(int i=0; i<node->children.size(); i++){
		if(node->children[i].object.type==OBJECT){
			p=node->children[i].object.object->box.center()-level->camera->pos;
			sortids.pushBack(SortItem(i,math.dotProduct(p,p)));
		}else{
			sortids.pushBack(SortItem(i,0));
		}
	}

	Array<int> res=sort.sort(sortids,true);

	for(int i=0; i<res.size(); i++){
		drawRecurse(callbackFunction,&node->children[res[i]],preTransform);
	}
	
	if(node->object.type==IK_EFFECTOR){
		IkRoot* r=node->object.ikEffector->root;

		if(r->sceneGraphNode!=node->parent){
			glPopMatrix();
		}
	}

#ifndef SOFTWARE_TRANSFORMS
	glPopMatrix(); 
#endif
#endif
}
コード例 #5
0
void StateAttack::action()
{
	callbackFunction(callbackParameter);
}
コード例 #6
0
ファイル: CallHandler.hpp プロジェクト: Vladoudidou/mockeur
 /**
  * Returns the stored value for the given arguments. It may be some logic (a function called with these arguments)
  * @param args The instance of arguments
  *
  * @return The stored value for the given arguments.
  */
 ReturnType value(ArgumentTypes ... args)
 {
     return callbackFunction(args...);
 }
コード例 #7
0
void Game::Update()
{
	if (cameraUpdate)
	{
		s16 x = Maths::UnsignedModulus(cameraPos.GetX(), 0x200);
		s16 y = Maths::UnsignedModulus(cameraPos.GetY(), 0x200);
		*BG3HOFS = x;
		*BG3VOFS = y;
		*BG1HOFS = x;
		*BG1VOFS = y;
		*BG2HOFS = x;
		*BG2VOFS = y;
		if (layer0Included)
		{
			*BG0HOFS = x;
			*BG0VOFS = y;
		}
	}
	if (doFade)
	{
		doFade = false;
		doFade2 = true;
	}
	else if (doFade2)
	{
		if (numFrames != 0)
		{
			currentAlpha += alphaSteps;
			DoFade();
			numFrames--;
		}
		else
		{
			doFade = false;
			doFade2 = false;
			memset32(currentPalette, 0, (sizeof(u16) * 512) >> 2);
			delete[] currentPalette;
			currentPalette = NULL;
			if (targetPalette)
			{
				SetPalette(targetPalette);
				if ((u32)targetPalette < 0x02040000 && (u32)targetPalette >= 0x02000000)
				{
					memset32(targetPalette, 0, (sizeof(u16) * 512) >> 2);
					delete[] targetPalette;
				}
			}
			targetPalette = NULL;
			if (callbackFunction)
			{
				callbackFunction();
				callbackFunction = NULL;
			}
			if (doCallback)
			{
				if (doExitCallback)
				{
					GameModeManager::RunExitCallback();
				}
				else
				{
					GameModeManager::RunEnterCallback();
				}
			}
			if (!paletteWriteDetected)
			{
				doCallback = false;
				doExitCallback = false;
				fade256 = false;
			}
			paletteWriteDetected = false;
		}
	}