Quote: "More? You haven't given any code which uses the supposed offending command yet."
Haha, I guess you're right!
Here is the application of the "broken" command:
This is a part of the geometry update function:
TA as v4typ
TB as v4typ
TC as v4typ
TD as v4typ
Rem Write vertex information into 3D data
lock vertexdata for limb ObjID,LmbID,0
cursor = 0
maxv = get vertexdata vertex count()
Rem Texture Vertices
for x = X1 to X2 step res
for y = Y1 to Y2 step res
TA = SMG_Terrain_Data(TerrainID,x-res,y).Texture `: TA.y = SMG_Terrain_Data(TerrainID,x-res,y).Texture.y : TA.z = SMG_Terrain_Data(TerrainID,x-res,y).Texture.z : TA.w = SMG_Terrain_Data(TerrainID,x-res,y).Texture.w
TB = SMG_Terrain_Data(TerrainID,x,y).Texture `: TB.y = SMG_Terrain_Data(TerrainID,x,y).Texture.y : TB.z = SMG_Terrain_Data(TerrainID,x,y).Texture.z : TB.w = SMG_Terrain_Data(TerrainID,x,y).Texture.w
TC = SMG_Terrain_Data(TerrainID,x,y-res).Texture `: TC.y = SMG_Terrain_Data(TerrainID,x,y-res).Texture.y : TC.z = SMG_Terrain_Data(TerrainID,x,y-res).Texture.z : TC.w = SMG_Terrain_Data(TerrainID,x,y-res).Texture.w
TD = SMG_Terrain_Data(TerrainID,x-res,y-res).Texture `: TD.y = SMG_Terrain_Data(TerrainID,x-res,y-res).Texture.y : TD.z = SMG_Terrain_Data(TerrainID,x-res,y-res).Texture.z : TD.w = SMG_Terrain_Data(TerrainID,x-res,y-res).Texture.w
SM_Change_Vertexdata_Quad_TTex( cursor , TA , TB , TC , TD )
inc cursor,6
next y
next x
Rem Position Vertices
cursor = 0
for x = X1 to X2 step res
for y = Y1 to Y2 step res
pA as v3typ : pA.x = (x-res)*SegSize-offx : pA.y = (y)*SegSize-offy : pA.z = SMG_Terrain_Data(TerrainID,x-res ,y ).pos.z
pB as v3typ : pB.x = (x)*SegSize-offx : pB.y = (y)*SegSize-offy : pB.z = SMG_Terrain_Data(TerrainID,x ,y ).pos.z
pC as v3typ : pC.x = (x)*SegSize-offx : pC.y = (y-res)*SegSize-offy : pC.z = SMG_Terrain_Data(TerrainID,x ,y-res ).pos.z
pD as v3typ : pD.x = (x-res)*SegSize-offx : pD.y = (y-res)*SegSize-offy : pD.z = SMG_Terrain_Data(TerrainID,x-res ,y-res ).pos.z
nA as v3typ : nA = SMG_Terrain_Data(TerrainID,x-res,y).nor
nB as v3typ : nB = SMG_Terrain_Data(TerrainID,x,y).nor
nC as v3typ : nC = SMG_Terrain_Data(TerrainID,x,y-res).nor
nD as v3typ : nD = SMG_Terrain_Data(TerrainID,x-res,y-res).nor
SM_Change_Vertexdata_Quad(cursor , pD , nD , pC , nC , pB , nB , pA , nA )
inc cursor,6
next y
next x
unlock vertexdata
This is the code after I decided to somewhat separate the texturing and positioning thinking the vertices could be re-positioned after the destruction caused by 'set vertexdata uv.'
SM_Change_Vertexdata_Quad_TTex( cursor , TA , TB , TC , TD ) is a function that looks like this:
Function SM_Change_Vertexdata_Quad_TTex( cursor as dword , TA as v4typ , TB as v4typ , TC as v4typ , TD as v4typ )
a=2
b=3
Rem First Tri
set vertexdata uv cursor,a,TA.x,TA.y
set vertexdata uv cursor,b,TA.z,TA.w : inc cursor
set vertexdata uv cursor,a,TB.x,TB.y
set vertexdata uv cursor,b,TB.z,TB.w : inc cursor
set vertexdata uv cursor,a,TC.x,TC.y
set vertexdata uv cursor,b,TC.z,TC.w : inc cursor
Rem Second Tri
set vertexdata uv cursor,a,TA.x,TA.y
set vertexdata uv cursor,b,TA.z,TA.w : inc cursor
set vertexdata uv cursor,a,TC.x,TC.y
set vertexdata uv cursor,b,TC.z,TC.w : inc cursor
set vertexdata uv cursor,a,TD.x,TD.y
set vertexdata uv cursor,b,TD.z,TD.w : inc cursor
Rem cursor is not a Global
Endfunction
The positioning part of the function works fine when the texturing isn't done. Also, I have already tried every lock mode; Zero wasn't the solution
. The code you posted did work when the lock mode was set to zero. I disabled my terrain shader and the symptoms went away. My shader is not to blame because the texture coords assigned to it by the initial mesh memblock showed perfect results when the uv vertexdata was left alone. But I relied on DarkBasic to generate the Tangent and Binormals (I think DarkBasic does that). How do I generate them inside the shader? I'm running out of TEXTURE semantics so hopefully it won't take another!
I made a replica function for setting texturecoord vertexdata but put in debug functions to print out the texture and position data before and after the uv coordinate change. It indicated that positions are all set to zero but the texturecoords are supposedly changed correctly!
I attached a picture of the limbs being destroyed by the particular command. They should be where the rigid black gaps are.
Randomnosity is a special influence upon man kind allowing one to think outside the usual bouderies and into a fantastic world created by oneself. Elephants don't cut it