c# - XNA Texturing issue -
ok, i've been trying lot of new things lately, , i've had few stopping points. decided leave 3d because figured didn't , couldn't understand coding involved, i'm pretty @ math though, figured give shot.
i'm trying learn 3d xna in c#, i've worked out 2d , wish move on, problem (in opinion) basic of 3d shapes, cube, run problems, after exporting cube blender (after 7th try >_>) , importing xna, cant texture correctly show on cube, downloaded cube model sample source code file, , attempted use that, , default texture, , still have problems.
basically, code draw cube is:
foreach (modelmesh mesh in model.meshes) { graphicsdevice.rasterizerstate = rasterizerstate.cullclockwise; foreach (basiceffect effect in mesh.effects) { effect.textureenabled = true; //effect.texture = texture; effect.world = world; effect.view = view; effect.projection = projection; effect.lightingenabled = false; } mesh.draw(); }
the renderstate , lightingenabled new, attempting fix if myself, when use own texture, texture looks being stretched, , isnt showing entire image on cube, faces same, not wrapping it.
also, see faces rotate cube like:
position -= new vector3(0, 0.00f, 0.0100f); angley += 0.01f; anglez += 0.01f; world = matrix.createscale(1.5f) * matrix.createrotationz(anglez) * matrix.createrotationy(angley) * matrix.createtranslation(position);
the z change test theory.
the default texture sandish texture, im not sure if streatching, because solid color, box seems oddly represented (it looks though can see through near faces, , im looking @ backs of opposing ones)
im hoping can give me hand, seems should simpler seems be, draw simple textured cube, , of tutorials online older versions of xna, code doesnt match up, , lost when trying replace current code (on tutorials create cube in code, rather model.)
anyways, answers.
edit drawing cube createorthographic makes correct (the first 1 uses perspective) still no texture love :(
edit2 when use cube stretched, when use 1 source, solid color.
edit3
i have gotten answer sooner had mentioned displaying fps using font/spritebatch, when working out why wouldnt work, , comparing sample did work, found it, now, know how make work?
to myself, , else encountering problem >.<
are using:
spritebatch.begin()
to in code? if so, screwing way program renders in 3d, check out link (for pre xna 4.0):
http://blogs.msdn.com/b/shawnhar/archive/2006/11/13/spritebatch-and-renderstates.aspx
and link if using xna 4.0:
the line in particular fixed issue was:
graphicsdevice.samplerstates[0] = samplerstate.linearwrap;
adding before foreach loop fixed problem me, may need try other lines in article
to else reading this, luck xna dreams :d
Comments
Post a Comment