Ejemplo n.º 1
0
void Animation::render(int xaxis, int yaxis, const Graphics::Bitmap &work, double scalex, double scaley){
    if (getState().position >= frames.size()){
        return;
    }

    Mugen::Effects effects = frames[getState().position]->effects;
    effects.scalex = scalex;
    effects.scaley = scaley;

    renderFrame(frames[getState().position], xaxis, yaxis, work, effects);

#if 0
    // Modify with frame adjustment
    const int placex = xaxis+frames[position]->xoffset;
    const int placey = yaxis+frames[position]->yoffset;
    try{
        frames[position]->sprite->render(placex,placey,work,frames[position]->effects);
        
        if (showDefense){
            renderCollision( frames[position]->defenseCollision, work, xaxis, yaxis, Bitmap::makeColor( 0,255,0 ) );
        }

        if (showOffense){
            renderCollision( frames[position]->attackCollision, work, xaxis, yaxis,  Bitmap::makeColor( 255,0,0 ) );
        }
    } catch (const LoadException & e){
        Global::debug(0) << "Error loading sprite: " << e.getReason() << endl;
        /* FIXME: do something sensible here */
        frames[position]->sprite = 0;
    }
#endif
}
Ejemplo n.º 2
0
void Animation::renderFrame(Frame * frame, int xaxis, int yaxis, const Graphics::Bitmap & work, const Mugen::Effects & effects){
    
    frame->render(xaxis, yaxis, work, effects);

    if (showDefense){
        renderCollision(getDefenseBoxes(effects.facing, effects.scalex, effects.scaley), work, xaxis, yaxis, Graphics::makeColor(0, 255, 0));
    }

    if (showOffense){
        renderCollision(getAttackBoxes(effects.facing, effects.scalex, effects.scaley), work, xaxis, yaxis, Graphics::makeColor(255,0,0 ));
    }
}
Ejemplo n.º 3
0
void RenderObject::renderCall()
{

	//RenderObjectLayer *rlayer = core->getRenderObjectLayer(getTopLayer());

	if (positionSnapTo)
		this->position = *positionSnapTo;

	position += offset;

#ifdef BBGE_BUILD_DIRECTX
	if (!RENDEROBJECT_FASTTRANSFORM)
		core->getD3DMatrixStack()->Push();
#endif

#ifdef BBGE_BUILD_OPENGL
	if (!RENDEROBJECT_FASTTRANSFORM)
		glPushMatrix();
	if (!RENDEROBJECT_SHAREATTRIBUTES)
	{
		glPushAttrib(GL_ALL_ATTRIB_BITS);
	}
#endif


	if (!RENDEROBJECT_FASTTRANSFORM)
	{
		if (layer != LR_NONE)
		{
			RenderObjectLayer *l = &core->renderObjectLayers[layer];
			if (l->followCamera != NO_FOLLOW_CAMERA)
			{
				followCamera = l->followCamera;
			}
		}
		if (followCamera!=0 && !parent)
		{
			if (followCamera == 1)
			{
#ifdef BBGE_BUILD_OPENGL
			 	glLoadIdentity();
				glScalef(core->globalResolutionScale.x, core->globalResolutionScale.y,0);
				glTranslatef(position.x, position.y, position.z);
				if (isfh())
				{
					glDisable(GL_CULL_FACE);
					glRotatef(180, 0, 1, 0);
				}

				if (core->mode == Core::MODE_3D)
				{
					glRotatef(rotation.x+rotationOffset.x, 1, 0, 0);
					glRotatef(rotation.y+rotationOffset.y, 0, 1, 0);
				}

				glRotatef(rotation.z+rotationOffset.z, 0, 0, 1);
#endif
#ifdef BBGE_BUILD_DIRECTX
				core->getD3DMatrixStack()->LoadIdentity();
				core->scaleMatrixStack(core->globalResolutionScale.x, core->globalResolutionScale.y,0);
				core->translateMatrixStack(position.x, position.y, 0);
				if (isfh())
				{
					//HACK: disable cull ->
					core->getD3DMatrixStack()->RotateAxisLocal(&D3DXVECTOR3(0, 1, 0), D3DXToRadian(180));
				}
				core->rotateMatrixStack(rotation.z + rotationOffset.z);
#endif
			}
			else
			{
				Vector pos = getFollowCameraPosition();

#ifdef BBGE_BUILD_OPENGL
				glTranslatef(pos.x, pos.y, pos.z);
				if (isfh())
				{
					glDisable(GL_CULL_FACE);
					glRotatef(180, 0, 1, 0);
				}
				if (core->mode == Core::MODE_3D)
				{
					glRotatef(rotation.x+rotationOffset.x, 1, 0, 0);
					glRotatef(rotation.y+rotationOffset.y, 0, 1, 0);
				}
				glRotatef(rotation.z+rotationOffset.z, 0, 0, 1);
#endif
#ifdef BBGE_BUILD_DIRECTX
				core->translateMatrixStack(pos.x, pos.y, 0);
				if (isfh())
				{
					//HACK: disable cull ->
					core->getD3DMatrixStack()->RotateAxisLocal(&D3DXVECTOR3(0, 1, 0), D3DXToRadian(180));
				}
				core->rotateMatrixStack(rotation.z + rotationOffset.z);
#endif
			}
		}
		else
		{

#ifdef BBGE_BUILD_OPENGL
			glTranslatef(position.x, position.y, position.z);
#endif
#ifdef BBGE_BUILD_DIRECTX
			core->translateMatrixStack(position.x, position.y, 0);
#endif

#ifdef BBGE_BUILD_OPENGL
			if (RenderObject::renderPaths && position.data && position.data->path.getNumPathNodes() > 0)
			{
				glLineWidth(4);
				glEnable(GL_BLEND);
				
				int i = 0;
				glColor4f(1.0f, 1.0f, 1.0f, 0.5f);
				glBindTexture(GL_TEXTURE_2D, 0);

				glBegin(GL_LINES);
				for (i = 0; i < position.data->path.getNumPathNodes()-1; i++)
				{
					glVertex2f(position.data->path.getPathNode(i)->value.x-position.x, position.data->path.getPathNode(i)->value.y-position.y);
					glVertex2f(position.data->path.getPathNode(i+1)->value.x-position.x, position.data->path.getPathNode(i+1)->value.y-position.y);
				}
				glEnd();

				glPointSize(20);
				glBegin(GL_POINTS);
				glColor4f(0.5,0.5,1,1);
				for (i = 0; i < position.data->path.getNumPathNodes(); i++)
				{
					glVertex2f(position.data->path.getPathNode(i)->value.x-position.x, position.data->path.getPathNode(i)->value.y-position.y);
				}
				glEnd();
			}
#endif
#ifdef BBGE_BUILD_OPENGL

			if (core->mode == Core::MODE_3D)
			{
				glRotatef(rotation.x+rotationOffset.x, 1, 0, 0);
				glRotatef(rotation.y+rotationOffset.y, 0, 1, 0);
			}

			glRotatef(rotation.z+rotationOffset.z, 0, 0, 1); 
			if (isfh())
			{
				glDisable(GL_CULL_FACE);
				glRotatef(180, 0, 1, 0);
			}
#endif
#ifdef BBGE_BUILD_DIRECTX
			//core->getD3DMatrixStack()->RotateAxisLocal(&D3DXVECTOR3(0, 0, 1), rotation.z+rotationOffset.z);
			core->rotateMatrixStack(rotation.z + rotationOffset.z);
			if (isfh())
			{
				//HACK: disable cull
				core->getD3DDevice()->SetRenderState(D3DRS_CULLMODE, D3DCULL_NONE);
				//core->getD3DMatrixStack()->Scale(-1, 1, 1);
				//core->applyMatrixStackToWorld();
				core->getD3DMatrixStack()->RotateAxisLocal(&D3DXVECTOR3(0, 1, 0), D3DXToRadian(180));
				//core->applyMatrixStackToWorld();
			}
#endif
		}
				
#ifdef BBGE_BUILD_OPENGL	
		glTranslatef(beforeScaleOffset.x, beforeScaleOffset.y, beforeScaleOffset.z);
		if (core->mode == Core::MODE_3D)
			glScalef(scale.x, scale.y, scale.z);
		else
			glScalef(scale.x, scale.y, 1);
		glTranslatef(internalOffset.x, internalOffset.y, internalOffset.z);
#endif
#ifdef BBGE_BUILD_DIRECTX
		core->translateMatrixStack(beforeScaleOffset.x, beforeScaleOffset.y, 0);
		core->scaleMatrixStack(scale.x, scale.y, 1);
		core->translateMatrixStack(internalOffset.x, internalOffset.y, 0);

		core->applyMatrixStackToWorld();
#endif


		//glDisable(GL_CULL_FACE);
		/* Never set anywhere.  --achurch
		if (renderOrigin)
		{
#ifdef BBGE_BUILD_OPENGL
			  glBegin(GL_TRIANGLES);
				glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
				glVertex3f(0.0f, 5.0f, 0.0f);
				glVertex3f(50.0f, 0.0f, 0.0f);
				glVertex3f(0.0f, -5.0f, 0.0f);

				glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
				glVertex3f(0.0f, 0.0f, 5.0f);
				glVertex3f(0.0f, 50.0f, 0.0f);
				glVertex3f(0.0f, 0.0f, -5.0f);

				glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
				glVertex3f(5.0f, 0.0f, 0.0f);
				glVertex3f(0.0f, 0.0f, 50.0f);
				glVertex3f(-5.0f, 0.0f, 0.0f);
			glEnd();
#endif
		}
		*/
	}

	for (Children::iterator i = children.begin(); i != children.end(); i++)
	{
		if (!(*i)->isDead() && (*i)->renderBeforeParent)
			(*i)->render();
	}


	//if (useColor)
	{
#ifdef BBGE_BUILD_OPENGL
		if (rlayer)
			glColor4f(color.x * rlayer->color.x, color.y * rlayer->color.y, color.z * rlayer->color.z, alpha.x*alphaMod);
		else
			glColor4f(color.x, color.y, color.z, alpha.x*alphaMod);
#elif defined(BBGE_BUILD_DIRECTX)
		core->setColor(color.x, color.y, color.z, alpha.x*alphaMod);
#endif
	}
	
	if (texture)
	{

#ifdef BBGE_BUILD_OPENGL
		if (texture->textures[0] != lastTextureApplied || repeatTexture != lastTextureRepeat)
		{
			texture->apply(repeatTexture);
			lastTextureRepeat = repeatTexture;
			lastTextureApplied = texture->textures[0];
		}
#endif
#ifdef BBGE_BUILD_DIRECTX
		texture->apply(repeatTexture);
#endif
	}
	else
	{
		if (lastTextureApplied != 0 || repeatTexture != lastTextureRepeat)
		{
#ifdef BBGE_BUILD_OPENGL
			glBindTexture(GL_TEXTURE_2D, 0);
#endif
#ifdef BBGE_BUILD_DIRECTX
			core->bindTexture(0, 0);
#endif
			lastTextureApplied = 0;
			lastTextureRepeat = repeatTexture;
		}
	}
	
	applyBlendType();


	bool doRender = true;
	int pass = renderPass;
	if (core->currentLayerPass != RENDER_ALL && renderPass != RENDER_ALL)
	{
		RenderObject *top = getTopParent();
		if (top)
		{
			if (top->overrideRenderPass != OVERRIDE_NONE)
				pass = top->overrideRenderPass;
		}

		doRender = (core->currentLayerPass == pass);
	}

	if (renderCollisionShape)
		renderCollision();

	if (doRender)
		onRender();

		//collisionShape.render();
	if (!RENDEROBJECT_SHAREATTRIBUTES)
	{
		glPopAttrib();
	}

	for (Children::iterator i = children.begin(); i != children.end(); i++)
	{
		if (!(*i)->isDead() && !(*i)->renderBeforeParent)
			(*i)->render();
	}


	if (!RENDEROBJECT_FASTTRANSFORM)
	{
#ifdef BBGE_BUILD_OPENGL
		glPopMatrix();
#endif
#ifdef BBGE_BUILD_DIRECTX
		core->getD3DMatrixStack()->Pop();
		core->applyMatrixStackToWorld();
#endif
	}


	position -= offset;

	if (integerizePositionForRender)
	{
		position = savePosition;
	}
}