Hot to create a colored triangle?
BlitzMax Forums/BlitzMax Programming/Hot to create a colored triangle?
| ||
I know DrawPoly command - but how to color each corner of this polygon? I mean this is doable in OpenGl/DirectX (but if i can use this directly - i do not need blitzmax). But why is this not done in blitzmax? I think this should added to next update. |
| ||
Are you asking 'how to' do it, whether Bmax already does it or whether we think it should do it? If I wanted to set each vertex colour I would use the TD3D7Max2DDriver 'Setcolor' method as a template. The drawframe method would also be helpful. Not sure whether this helps as I'm not sure what you want to do. |
| ||
He wants a different color for each corner of the triangle and to have it smooth/gauraud shaded. You cannot do this in Max without writing your own triangle code in GL or DX. |
| ||
You can use my Textured Poly module and pass a NULL image. You have full access to the Vertex Color, Alpha and Normals. The full source is there so you might just want to pick the bits you need. http://www.modules.indiepath.com |
| ||
that Textured Poly is usefull, thanks |
| ||
I think this is useful and should included to blitzmax... |
| ||
I readed BlitzMax-Sources... I wish i never seen this:Method DrawPoly( xy#[],handlex#,handley#,tx#,ty# ) If xy.length<6 Or (xy.length&1) Return Local segs=xy.length/2 Local vrts#[]=New Float[segs*4] Local c:Int Ptr=Int Ptr(Float Ptr(vrts)) For Local i=0 Until Len xy Step 2 Local x#=xy[i+0]+handlex Local y#=xy[i+1]+handley vrts[i*2+0]=x*ix+y*iy+tx vrts[i*2+1]=x*jx+y*jy+ty c[i*2+3]=drawcolor Next If SetActiveFrame(Null) device.DrawPrimitive(D3DPT_TRIANGLEFAN,D3DFVF_XYZ|D3DFVF_DIFFUSE,vrts,segs,0) EndIf End Method This code create Float-Data (but 2x more than needed). Why? Part of this is not directly used, but one part is used for color. But colors are integers, so that a float-pointer is converted to integer-pointer - and then a integer value is assigned to "Float-Data". Crazy. |
| ||
Indiepath, I downloaded texturedpoly.mod and I noticed that line 193: PrimaryDevice.device.DrawPrimitive(RenderType,D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE|D3DFVF_TEX1,xyuv,segs,0) needs to be changed to this: D3D7GraphicsDriver().Direct3DDevice7().DrawPrimitive(RenderType,D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_DIFFUSE|D3DFVF_TEX1,xyuv,segs,0) Otherwise module won't compile. -AF |
| ||
@MrCredo: Have you tried to simplify the code you don't like and does it work ? I think there may be a reason for the *ugly* code in the data structure directX expects, but I have no deeper knowledge of handling the beast DirectX. |
| ||
Thanks Artic...I was screwing around with that mod and couldn't make it work. This was exactly what I needed. :-) |