1 /* $Id: OpeningView.cpp,v 1.5 2002/11/04 14:24:52 nan Exp $ */
2 
3 // Copyright (C) 2000, 2002  $B?@Fn(B $B5H9((B(Kanna Yoshihiro)
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
18 
19 #include "ttinc.h"
20 #include "OpeningView.h"
21 #include "Player.h"
22 #include "Opening.h"
23 
24 
OpeningView()25 OpeningView::OpeningView() {
26 }
27 
~OpeningView()28 OpeningView::~OpeningView() {
29 }
30 
31 bool
Init(Opening * opening)32 OpeningView::Init( Opening *opening ) {
33   m_opening = opening;
34 
35   return true;
36 }
37 
38 bool
Redraw()39 OpeningView::Redraw() {
40   GLfloat light_intensity_amb[] = { 0.6F, 0.6F, 0.6F, 1.0F };
41   GLfloat light_intensity_dif[] = { 1.0F, 1.0F, 1.0F, 1.0F };
42 
43   long phrase, mod;
44 
45   m_opening->GetPhrase( phrase, mod );
46 
47   if ( phrase < 56 ) {
48   } else if ( phrase < 64 ) {
49     light_intensity_amb[0] *= (3200-m_opening->GetCount())/400.0F;
50     light_intensity_amb[1] *= (3200-m_opening->GetCount())/400.0F;
51     light_intensity_amb[2] *= (3200-m_opening->GetCount())/400.0F;
52     light_intensity_dif[0] *= (3200-m_opening->GetCount())/400.0F;
53     light_intensity_dif[1] *= (3200-m_opening->GetCount())/400.0F;
54     light_intensity_dif[2] *= (3200-m_opening->GetCount())/400.0F;
55   } else if ( phrase < 72 ) {
56     if ( phrase >= 68 && mod > 20 ) {
57       /*
58       light_intensity_amb[0] *= (10-mod)/10.0F;
59       light_intensity_amb[1] *= (10-mod)/10.0F;
60       light_intensity_amb[2] *= (10-mod)/10.0F;
61       light_intensity_dif[0] *= (10-mod)/10.0F;
62       light_intensity_dif[1] *= (10-mod)/10.0F;
63       light_intensity_dif[2] *= (10-mod)/10.0F;
64       */
65     } else {
66       light_intensity_amb[0] *= 0.0F;
67       light_intensity_amb[1] *= 0.0F;
68       light_intensity_amb[2] *= 0.0F;
69       light_intensity_dif[0] *= 0.0F;
70       light_intensity_dif[1] *= 0.0F;
71       light_intensity_dif[2] *= 0.0F;
72     }
73   }
74 
75   glLightfv(GL_LIGHT0, GL_AMBIENT, light_intensity_amb);
76   glLightfv(GL_LIGHT0, GL_DIFFUSE, light_intensity_dif);
77   glLightfv(GL_LIGHT0, GL_SPECULAR, light_intensity_dif);
78 
79   m_opening->GetThePlayer()->m_View->Redraw();
80   m_opening->GetComPlayer()->m_View->Redraw();
81 
82   if ( phrase >= 200 && phrase < 232 )
83     m_opening->m_telop[0]->GetView()->Redraw();
84 
85   return true;
86 }
87 
88 bool
RedrawAlpha()89 OpeningView::RedrawAlpha() {
90   m_opening->GetThePlayer()->m_View->RedrawAlpha();
91   m_opening->GetComPlayer()->m_View->RedrawAlpha();
92 
93   long phrase, mod;
94 
95   m_opening->GetPhrase( phrase, mod );
96 
97   if ( phrase >= 200 && phrase < 232 )
98     m_opening->m_telop[0]->GetView()->RedrawAlpha();
99 
100   return true;
101 }
102