improved and fixed CreatePlane

This commit is contained in:
HuYingzhuo(hugo/hyzboy) 2023-10-13 19:21:04 +08:00
parent a58589f01f
commit 7788459109
2 changed files with 4 additions and 22 deletions

View File

@ -78,23 +78,10 @@ namespace hgl
*/ */
Primitive *CreatePlaneGrid(RenderResource *db,const VIL *vil,const PlaneGridCreateInfo *pgci); Primitive *CreatePlaneGrid(RenderResource *db,const VIL *vil,const PlaneGridCreateInfo *pgci);
struct PlaneCreateInfo
{
Vector2f tile;
public:
PlaneCreateInfo()
{
tile.x=1.0f;
tile.y=1.0f;
}
};//struct PlaneCreateInfo
/** /**
* () * ()
*/ */
Primitive *CreatePlane(RenderResource *db,const VIL *vil,const PlaneCreateInfo *pci); Primitive *CreatePlane(RenderResource *db,const VIL *vil);
struct CubeCreateInfo struct CubeCreateInfo
{ {

View File

@ -212,7 +212,7 @@ namespace hgl
return rc.Finish("PlaneGrid"); return rc.Finish("PlaneGrid");
} }
Primitive *CreatePlane(RenderResource *db,const VIL *vil,const PlaneCreateInfo *pci) Primitive *CreatePlane(RenderResource *db,const VIL *vil)
{ {
const float xy_vertices [] = { -0.5f,-0.5f,0.0f, +0.5f,-0.5f,0.0f, +0.5f,+0.5f,0.0f, -0.5f,+0.5f,0.0f }; const float xy_vertices [] = { -0.5f,-0.5f,0.0f, +0.5f,-0.5f,0.0f, +0.5f,+0.5f,0.0f, -0.5f,+0.5f,0.0f };
float xy_tex_coord[] = { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f }; float xy_tex_coord[] = { 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f };
@ -235,19 +235,14 @@ namespace hgl
{ {
AutoDelete<VB3f> tangent=rc.AccessVAD<VB3f>(VAN::Tangent); AutoDelete<VB3f> tangent=rc.AccessVAD<VB3f>(VAN::Tangent);
tangent->RepeatWrite(xy_tangent,4); if(tangent)tangent->RepeatWrite(xy_tangent,4);
} }
{ {
AutoDelete<VB2f> tex_coord=rc.AccessVAD<VB2f>(VAN::TexCoord); AutoDelete<VB2f> tex_coord=rc.AccessVAD<VB2f>(VAN::TexCoord);
if(tex_coord) if(tex_coord)
{ tex_coord->Write(xy_tex_coord,4);
xy_tex_coord[2]=xy_tex_coord[4]=pci->tile.x;
xy_tex_coord[5]=xy_tex_coord[7]=pci->tile.y;
tex_coord->Write(xy_tex_coord);
}
} }
return rc.Finish("Plane"); return rc.Finish("Plane");