43 void stageCollisionTests::_initTest_2()
45 for(
unsigned i=0; i<9; i++) _d[i].setNextDomain(_d + i + 1);
46 laPivot::colliderRange(_d + 0, 10);
48 for(
unsigned i=0; i<10; i++)
53 _d[i].addLine( _dln[i].origin, _dln[i].end(), laPoint3(0,-
M_UNIT,0), NULL);
63 pr->styleSet( laColor(255,0,0) );
66 if(pi->key(KEY_LEFT)) _ln[0].origin.x( _ln[0].
origin.x() - 0.5 * pt->delta() );
67 if(pi->key(KEY_RIGHT)) _ln[0].origin.x( _ln[0].
origin.x() + 0.5 * pt->delta() );
68 if(pi->key(KEY_UP)) _ln[0].origin.y( _ln[0].
origin.y() - 0.5 * pt->delta() );
69 if(pi->key(KEY_DOWN)) _ln[0].origin.y( _ln[0].
origin.y() + 0.5 * pt->delta() );
72 if(pi->key(KEY_1)) a += 2 * pt->delta();
73 if(pi->key(KEY_2)) a -= 2 * pt->delta();
75 _ln[0].
vector.y( cos(a) * M_UNIT * 2 );
77 laCollisionScenario col;
78 col.pFirstDomain = _d;
80 col.ptPosition = laPoint3();
81 col.ptVector = laPoint3(0, M_UNIT, 0);
83 laCollider::collideLineWithDomain(_ln[0], &col, 3, M_FALSE);
87 laLine2 v(col.ptCausing, col.ptCausing + col.ptVector);
89 pr->styleSet( laColor(0,150,0) );
92 laLine2 vm(col.ptCausing, col.ptCausing + col.ptModifiedVector);
94 pr->styleSet( laColor(0,255,0) );
103 void stageCollisionTests::_initTest_1()
105 for(
unsigned i=0; i<9; i++) _d[i].setNextDomain(_d + i + 1);
106 laPivot::colliderRange(_d + 0, 1);
108 for(
unsigned i=0; i<10; i++)
109 _dln[i].build_v(
laPoint2((i+2)*M_UNIT*1.5, M_UNIT*10),
110 laPoint2(M_UNIT, M_UNIT*(rand()%10/10.0 - 0.5)));
118 pr->styleSet( laColor(255,0,0) );
120 for(
unsigned i=0; i<10; i++)
122 pr->styleSet( laColor(255,0,0) );
126 if(_dln[i].intersection( _ln[0], &k, &k_ln))
128 pr->
font(
"plain")->ctlSize(M_UNIT*0.2);
129 pr->
font(
"plain")->draw( _dln[i].origin,
"True");
131 pr->styleSet( laColor(255,0,0) );
135 if( (k>=0) && (k<=1) )
137 if( (k_ln>=0) && (k_ln<=1) ) pr->styleSet( laColor(0,255,0) );
139 ptIntersect.draw(pr);
145 if(pi->key(KEY_LEFT)) _ln[0].origin.x( _ln[0].
origin.x() - 0.5 * pt->delta() );
146 if(pi->key(KEY_RIGHT)) _ln[0].origin.x( _ln[0].
origin.x() + 0.5 * pt->delta() );
147 if(pi->key(KEY_UP)) _ln[0].origin.y( _ln[0].
origin.y() - 0.5 * pt->delta() );
148 if(pi->key(KEY_DOWN)) _ln[0].origin.y( _ln[0].
origin.y() + 0.5 * pt->delta() );
151 if(pi->key(KEY_1)) a += 2 * pt->delta();
152 if(pi->key(KEY_2)) a -= 2 * pt->delta();
153 _ln[0].
vector.x( sin(a) * M_UNIT * 2 );
154 _ln[0].
vector.y( cos(a) * M_UNIT * 2 );
160 stageCollisionTests::stageCollisionTests(
void) {}
162 void stageCollisionTests::onInit()
164 ::laSystemIntegrator::getEnvironment()->setTitle(
"Test Mode");
169 void stageCollisionTests::onFini() { }
170 void stageCollisionTests::onActivate() {}
171 void stageCollisionTests::onDeactivate() { }
177 double w = ::laSystemIntegrator::getSettings()->graphics_resolution_w;
178 double h = ::laSystemIntegrator::getSettings()->graphics_resolution_h;
180 if(pi->key(KEY_ESCAPE)) ::laSystemIntegrator::getEnvironment()->terminate();
181 pr->styleBackground( laColor() );
186 pr->transScale( laPoint3( w/(M_UNIT * 20), h/( M_UNIT * 15), 1 ) );
190 _doTest_2(pr, pi, pt);
laFont * font(char *strName)
Get a font renderer.
void draw(class laRenderer *r, laPoint2 &pos)
Draw the line ( primarily for debug purposes )
virtual void modeTexture(M_BOOL bOn)=0
Enable/disable texturing.
#define M_UNIT
Unit of 1 meter.
void build_v(const laPoint2 &a, const laPoint2 &v)
Build a line from an end-point and a vector.
void at(double k, laPoint2 *ppt) const
Get point at 1/k lenght (returns in user-specified pointer)
laPoint2 vector
Vector ( not normalized, so k = [0;1] traces the whole line segment )
virtual void modeBlend(M_BOOL bOn)=0
Enable/disable alpha blending (opacity)
Virtual interface for the Engine graphics renderer.
laPoint2 origin
Point of origin.
virtual void modeInterface()=0
Switch to interface rendering (2D projection mode)
virtual void modeLight(M_BOOL bOn)=0
Enable/disable lighting.