comparison engine/core/view/camera.cpp @ 661:e3140f01749d

* Merged the light branch back into trunk. * Modified the demos so they work with the new loaders and setting.
author helios2000@33b003aa-7bff-0310-803a-e67f0ece8222
date Fri, 05 Nov 2010 15:21:10 +0000
parents 07b1cf8e92b5
children e8a799239384
comparison
equal deleted inserted replaced
660:b0733d998d0f 661:e3140f01749d
103 m_pipeline(), 103 m_pipeline(),
104 m_updated(false), 104 m_updated(false),
105 m_renderbackend(renderbackend), 105 m_renderbackend(renderbackend),
106 m_ipool(ipool), 106 m_ipool(ipool),
107 m_apool(apool), 107 m_apool(apool),
108 m_layer_to_instances() { 108 m_layer_to_instances(),
109 m_lighting(false),
110 m_light_colors() {
109 111
110 m_viewport = viewport; 112 m_viewport = viewport;
111 m_map_observer = new MapObserver(this); 113 m_map_observer = new MapObserver(this);
112 m_map = 0; 114 m_map = 0;
113 Location location; 115 Location location;
628 delete m_cache[layer]; 630 delete m_cache[layer];
629 m_cache.erase(layer); 631 m_cache.erase(layer);
630 m_layer_to_instances.erase(layer); 632 m_layer_to_instances.erase(layer);
631 } 633 }
632 634
635 void Camera::setLightingColor(float red, float green, float blue, float alpha) {
636 m_lighting = true;
637 m_light_colors.clear();
638 m_light_colors.push_back(red);
639 m_light_colors.push_back(green);
640 m_light_colors.push_back(blue);
641 m_light_colors.push_back(alpha);
642 }
643
644 std::vector<float> Camera::getLightingColor() {
645 if(m_light_colors.empty()) {
646 for(int colors = 0; colors != 4; ++colors) {
647 m_light_colors.push_back(1.0f);
648 }
649 }
650 return m_light_colors;
651 }
652
653 void Camera::resetLightingColor() {
654 m_lighting = false;
655 m_renderbackend->resetLighting();
656 }
657
633 void Camera::render() { 658 void Camera::render() {
634 Transform transform = NormalTransform; 659 Transform transform = NormalTransform;
635 if(m_iswarped) 660 if(m_iswarped)
636 transform = WarpedTransform; 661 transform = WarpedTransform;
637 m_iswarped = false; 662 m_iswarped = false;
643 } 668 }
644 //if ((!map->isChanged()) && (!m_iswarped) && (cammove == ScreenPoint(0,0,0))) { 669 //if ((!map->isChanged()) && (!m_iswarped) && (cammove == ScreenPoint(0,0,0))) {
645 // return; 670 // return;
646 //} 671 //}
647 672
673 if (m_renderbackend->getLightingModel() != 0) {
674 m_renderbackend->resetStencilBuffer(0);
675 if (m_lighting) {
676 m_renderbackend->setLighting(m_light_colors[0], m_light_colors[1], m_light_colors[2], m_light_colors[3]);
677 }
678 }
679
648 if(m_backendSDL) { 680 if(m_backendSDL) {
649 m_renderbackend->pushClipArea(getViewPort()); 681 m_renderbackend->pushClipArea(getViewPort());
650 } else { 682 } else {
651 m_renderbackend->pushClipArea(getViewPort(), testRenderedViewPort()); 683 m_renderbackend->pushClipArea(getViewPort(), testRenderedViewPort());
652 } 684 }
685
653 // update each layer 686 // update each layer
654 // m_layer_to_instances.clear(); 687 // m_layer_to_instances.clear();
688
655 const std::list<Layer*>& layers = map->getLayers(); 689 const std::list<Layer*>& layers = map->getLayers();
656 std::list<Layer*>::const_iterator layer_it = layers.begin(); 690 std::list<Layer*>::const_iterator layer_it = layers.begin();
657 for (;layer_it != layers.end(); ++layer_it) { 691 for (;layer_it != layers.end(); ++layer_it) {
658 LayerCache* cache = m_cache[*layer_it]; 692 LayerCache* cache = m_cache[*layer_it];
659 if(!cache) { 693 if(!cache) {
669 if ((*r_it)->isActivedLayer(*layer_it)) { 703 if ((*r_it)->isActivedLayer(*layer_it)) {
670 (*r_it)->render(this, *layer_it, instances_to_render); 704 (*r_it)->render(this, *layer_it, instances_to_render);
671 } 705 }
672 } 706 }
673 } 707 }
708
709 if (m_lighting) {
710 m_renderbackend->resetLighting();
711 }
712
674 m_renderbackend->popClipArea(); 713 m_renderbackend->popClipArea();
675 resetUpdates(); 714 resetUpdates();
676 m_updated = true; 715 m_updated = true;
677 } 716 }
678 717