void Renderer::RenderScene(const core::Scene& scene)
{
  SetCurrentCamera(*scene.camera());
  for (auto& entity : scene.entities()) {
    RenderEntity(*entity);
  }
}
示例#2
0
////////////////////////////////////////
//		PRIVATE UTILITY FUNCTIONS
////////////////////////////////////////
void RenderComponent::_ReceiveLocalMessage(CompMessage* message)
{
	switch(message->GetType())
	{
	case ENTITY_RENDER:
		{
			RenderEntity();
		}
		break;
	}

}
示例#3
0
文件: main.cpp 项目: andyfriesen/ika
/*
 * This could probably use some optimization.  Every time we draw the map,
 * we do n filter operations, then n sort operations.  huuurk.
 * Maybe keep the entity linked list y sorted at all times by reordering
 * whenever a y value changes.  That's only O(n) as opposed to O(nlogn) or
 * whatever unholy growth rate this is.
 *
 * Update: meh.  Sorting doesn't seem to be a bottleneck.
 */
void Engine::RenderEntities(uint layerIndex) {
    CDEBUG("renderentities");
    std::vector<Entity*>     drawlist;
    const Point res = video->GetResolution();
    const Map::Layer* layer = map.GetLayer(layerIndex);

    int xw = (xwin * layer->parallax.mulx / layer->parallax.divx) - layer->x;
    int yw = (ywin * layer->parallax.muly / layer->parallax.divy) - layer->y;

    // first, get a list of entities onscreen
    uint width, height;
    for (EntityList::iterator i = entities.begin(); i != entities.end(); i++) {
        Entity* e = *i;
        const Sprite* sprite = e->sprite;

        if (e->layerIndex != layerIndex)    continue;   // wrong layer
        if (!sprite)                        continue;   // no sprite? @_x

        width = sprite->Width();
        height = sprite->Height();

        // get the coodinates at which the sprite would be drawn
        int x = e->x - sprite->nHotx + layer->x - xw;
        int y = e->y - sprite->nHoty + layer->y - yw;

        if (x + width > 0 && y + height > 0 &&
            x < res.x     && y < res.y      &&
            e->isVisible
        ) {
            drawlist.push_back(e);                                                          // the entity is onscreen, tag it.
        }
    }

    if (!drawlist.empty()) {
        // Sort them by y value. (see the CompareEntity functor above)
        std::sort(drawlist.begin(), drawlist.end(), CompareEntities());

        video->SetBlendMode(Video::Normal);
        for (std::vector<Entity*>::iterator j = drawlist.begin(); j != drawlist.end(); j++) {
#if 0
            const Entity* e = *j;
            const Sprite* s = e->sprite;
            int x = e->x - xwin - s->nHotx + layer->x;
            int y = e->y - ywin - s->nHoty + layer->y;

            DrawEntity(e, x, y);
#else
            RenderEntity(*j);
#endif
        }
    }
}
示例#4
0
void SkyBoxShader::RenderTree(OctreeNode* renderTree, ID3D11Device* currDevice, ID3D11DeviceContext* deviceContext, ShaderData* drawData)
{
	OctreeNode* currentNode = renderTree;
	D3DXMATRIX wvpMatrix;

	if(!mEffect)
	{
		std::cerr << "Render Error: SkyBox Shader Uninitialised!" << std::endl;
		return;
	}

	setInputLayout(deviceContext);

	while(currentNode != 0)
	{
		if(currentNode->mCurrentEntities)
		{
			for(int i = 0; i < currentNode->mCurrentEntities; i++)
			{
				if(currentNode->mNodeContents[i])
				{
					RenderEntity(currentNode->mNodeContents[i], currDevice, deviceContext, drawData);
				}
			}
		}

		for(int i = 0; i < 8; i++)
		{
			if(currentNode->mChildNodes[i])
			{
				RenderTree(currentNode->mChildNodes[i], currDevice, deviceContext, drawData);
			}
			else
			{
				currentNode = 0;
			}
		}

		currentNode = 0;
	}
}