Been stuck on this challange for a while.
Im trying to change effect or texture on a Quad(2 tiangles) at runtime.
My Quad class containg the VertexPositionNormalTexture information to draw the quad.
This works as intended, and texture/light/ambient are all ok.
The Quad also containg information about what Texture or effect should be used
I’ve tried a couple of different ways to solve this. Is there a perticular order to do this.
Psudo code:
BE1 = BasicEffect // Stone texture
BE2 = BasicEffect // Wood texture
TestEff = BasicEffect // This will be Equal to BE1 or BE2 at runtime
For each Quad
If Quad.Region = 1 then
TestEff = BE1
Else
TestEff = BE2
End IF
Dim VPNT(5) As VertexPositionNormalTexture (Gets information from quad and creates both triangles)
For Each Eff As EffectPass In TestEff.CurrentTechnique.Passes
Eff.Apply()
TestEff.World = Camera.World
TestEff.View = Camera.View
TestEff.Projection = Camera.Projection
Next
GraphicsDevice.DrawUserPrimitives(Of VertexPositionNormalTexture)(PrimitiveType.TriangleList, VPNT, 0, 2)
Next
When I try this, its only using the last Effect used, on all faces. Also tried to set TestEff.Texture = another texture, same result.
I guess one or both approches should be possible, but need some other command/code here as well.
The last Project I did in MG had all Components in different class instances, With their own Draw metode. That worked as it was intended.
Some guidence would be very helpful
Zellpop