|
@@ -906,12 +906,15 @@ Class Canvas
|
|
DebugAssert( _lighting,"Canvas.AddLight() can only be used while lighting" )
|
|
DebugAssert( _lighting,"Canvas.AddLight() can only be used while lighting" )
|
|
If Not _lighting Return
|
|
If Not _lighting Return
|
|
|
|
|
|
|
|
+ Local lx:=_matrix.i.x * tx + _matrix.j.x * ty + _matrix.t.x
|
|
|
|
+ Local ly:=_matrix.i.y * tx + _matrix.j.y * ty + _matrix.t.y
|
|
|
|
+
|
|
_vp=_lightVB.AddVertices( 4 )
|
|
_vp=_lightVB.AddVertices( 4 )
|
|
If Not _vp Return
|
|
If Not _vp Return
|
|
|
|
|
|
Local op:=New LightOp
|
|
Local op:=New LightOp
|
|
op.light=light
|
|
op.light=light
|
|
- op.lightPos=New Vec2f( tx,ty )
|
|
|
|
|
|
+ op.lightPos=New Vec2f( lx,ly )
|
|
op.textureFilter=light.TextureFilter<>TextureFilter.None ? light.TextureFilter Else _textureFilter
|
|
op.textureFilter=light.TextureFilter<>TextureFilter.None ? light.TextureFilter Else _textureFilter
|
|
op.primOffset=_lightVB.Length-4
|
|
op.primOffset=_lightVB.Length-4
|
|
_lightOps.Push( op )
|
|
_lightOps.Push( op )
|
|
@@ -919,10 +922,10 @@ Class Canvas
|
|
Local vs:=light.Vertices
|
|
Local vs:=light.Vertices
|
|
Local ts:=light.TexCoords
|
|
Local ts:=light.TexCoords
|
|
|
|
|
|
- AddVertex( vs.min.x+tx,vs.min.y+ty,ts.min.x,ts.min.y,tx,ty,_pmcolor )
|
|
|
|
- AddVertex( vs.max.x+tx,vs.min.y+ty,ts.max.x,ts.min.y,tx,ty,_pmcolor )
|
|
|
|
- AddVertex( vs.max.x+tx,vs.max.y+ty,ts.max.x,ts.max.y,tx,ty,_pmcolor )
|
|
|
|
- AddVertex( vs.min.x+tx,vs.max.y+ty,ts.min.x,ts.max.y,tx,ty,_pmcolor )
|
|
|
|
|
|
+ AddVertex( vs.min.x+tx,vs.min.y+ty,ts.min.x,ts.min.y,lx,ly,_pmcolor )
|
|
|
|
+ AddVertex( vs.max.x+tx,vs.min.y+ty,ts.max.x,ts.min.y,lx,ly,_pmcolor )
|
|
|
|
+ AddVertex( vs.max.x+tx,vs.max.y+ty,ts.max.x,ts.max.y,lx,ly,_pmcolor )
|
|
|
|
+ AddVertex( vs.min.x+tx,vs.max.y+ty,ts.min.x,ts.max.y,lx,ly,_pmcolor )
|
|
End
|
|
End
|
|
|
|
|
|
Method AddLight( light:Image,tx:Float,ty:Float,rz:Float )
|
|
Method AddLight( light:Image,tx:Float,ty:Float,rz:Float )
|
|
@@ -968,7 +971,11 @@ Class Canvas
|
|
Local tv:=New Vec2f( tx,ty )
|
|
Local tv:=New Vec2f( tx,ty )
|
|
|
|
|
|
For Local sv:=Eachin caster.Vertices
|
|
For Local sv:=Eachin caster.Vertices
|
|
- _shadowVerts.Push( sv+tv )
|
|
|
|
|
|
+ sv+=tv
|
|
|
|
+ Local lv:=New Vec2f(
|
|
|
|
+ _matrix.i.x * sv.x + _matrix.j.x * sv.y + _matrix.t.x,
|
|
|
|
+ _matrix.i.y * sv.x + _matrix.j.y * sv.y + _matrix.t.y )
|
|
|
|
+ _shadowVerts.Push( lv )
|
|
Next
|
|
Next
|
|
End
|
|
End
|
|
|
|
|
|
@@ -1078,6 +1085,13 @@ Class Canvas
|
|
_drawOp=New DrawOp
|
|
_drawOp=New DrawOp
|
|
End
|
|
End
|
|
|
|
|
|
|
|
+ #rem monkeydoc True if canvas is in lighting mode.
|
|
|
|
+ #end
|
|
|
|
+ Property IsLighting:Bool()
|
|
|
|
+
|
|
|
|
+ Return _lighting
|
|
|
|
+ End
|
|
|
|
+
|
|
#rem monkeydoc Puts the canvas into lighting mode.
|
|
#rem monkeydoc Puts the canvas into lighting mode.
|
|
|
|
|
|
While in lighting mode, you can add lights and shadow casters to the cavas using [[AddLight]] and [[AddShadowCaster]]. Lights and shadows
|
|
While in lighting mode, you can add lights and shadow casters to the cavas using [[AddLight]] and [[AddShadowCaster]]. Lights and shadows
|
|
@@ -1297,6 +1311,7 @@ Class Canvas
|
|
|
|
|
|
'Vertices
|
|
'Vertices
|
|
'
|
|
'
|
|
|
|
+ #rem
|
|
Method AddVertex( x:Float,y:Float,s0:Float,t0:Float,s1:Float,t1:Float,color:UInt )
|
|
Method AddVertex( x:Float,y:Float,s0:Float,t0:Float,s1:Float,t1:Float,color:UInt )
|
|
_vp->position.x=x
|
|
_vp->position.x=x
|
|
_vp->position.y=y
|
|
_vp->position.y=y
|
|
@@ -1307,6 +1322,18 @@ Class Canvas
|
|
_vp->color=color
|
|
_vp->color=color
|
|
_vp+=1
|
|
_vp+=1
|
|
End
|
|
End
|
|
|
|
+ #end
|
|
|
|
+
|
|
|
|
+ Method AddVertex( tx:Float,ty:Float,s0:Float,t0:Float,s1:Float,t1:Float,color:UInt )
|
|
|
|
+ _vp->position.x=_matrix.i.x * tx + _matrix.j.x * ty + _matrix.t.x
|
|
|
|
+ _vp->position.y=_matrix.i.y * tx + _matrix.j.y * ty + _matrix.t.y
|
|
|
|
+ _vp->texCoord0.x=s0
|
|
|
|
+ _vp->texCoord0.y=t0
|
|
|
|
+ _vp->texCoord1.x=s1
|
|
|
|
+ _vp->texCoord1.y=t1
|
|
|
|
+ _vp->color=color
|
|
|
|
+ _vp+=1
|
|
|
|
+ End
|
|
|
|
|
|
Method AddVertex( tx:Float,ty:Float,s0:Float,t0:Float,color:UInt )
|
|
Method AddVertex( tx:Float,ty:Float,s0:Float,t0:Float,color:UInt )
|
|
_vp->position.x=_matrix.i.x * tx + _matrix.j.x * ty + _matrix.t.x
|
|
_vp->position.x=_matrix.i.x * tx + _matrix.j.x * ty + _matrix.t.x
|