improved PlaneGrid
This commit is contained in:
parent
c9d6774bd3
commit
e95cbb28a4
2
CMCore
2
CMCore
@ -1 +1 @@
|
|||||||
Subproject commit 09d9678e112a84f29dd4ba2165fe25fd91320569
|
Subproject commit 5107b34d1617413c40537502181694f80f82782f
|
@ -72,19 +72,14 @@ private:
|
|||||||
|
|
||||||
struct PlaneGridCreateInfo pgci;
|
struct PlaneGridCreateInfo pgci;
|
||||||
|
|
||||||
pgci.coord[0]=Vector3f(-100,-100,0);
|
pgci.grid_size.width =32;
|
||||||
pgci.coord[1]=Vector3f( 100,-100,0);
|
pgci.grid_size.height=32;
|
||||||
pgci.coord[2]=Vector3f( 100, 100,0);
|
|
||||||
pgci.coord[3]=Vector3f(-100, 100,0);
|
|
||||||
|
|
||||||
pgci.step.x=32;
|
pgci.sub_count.width =8;
|
||||||
pgci.step.y=32;
|
pgci.sub_count.height=8;
|
||||||
|
|
||||||
pgci.side_step.x=8;
|
|
||||||
pgci.side_step.y=8;
|
|
||||||
|
|
||||||
pgci.lum=0.5;
|
pgci.lum=0.5;
|
||||||
pgci.side_lum=1.0;
|
pgci.sub_lum=1.0;
|
||||||
|
|
||||||
ro_plane_grid=CreatePlaneGrid(db,material->GetDefaultVIL(),&pgci);
|
ro_plane_grid=CreatePlaneGrid(db,material->GetDefaultVIL(),&pgci);
|
||||||
|
|
||||||
@ -109,7 +104,7 @@ private:
|
|||||||
Add(material_instance[1],rotate(HGL_RAD_90,0,1,0));
|
Add(material_instance[1],rotate(HGL_RAD_90,0,1,0));
|
||||||
Add(material_instance[2],rotate(HGL_RAD_90,1,0,0));
|
Add(material_instance[2],rotate(HGL_RAD_90,1,0,0));
|
||||||
|
|
||||||
camera->pos=Vector3f(200,200,200);
|
camera->pos=Vector3f(32,32,32);
|
||||||
camera_control->SetTarget(Vector3f(0,0,0));
|
camera_control->SetTarget(Vector3f(0,0,0));
|
||||||
camera_control->Refresh();
|
camera_control->Refresh();
|
||||||
|
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include<hgl/graph/VK.h>
|
#include<hgl/graph/VK.h>
|
||||||
#include<hgl/math/Vector.h>
|
#include<hgl/math/Vector.h>
|
||||||
#include<hgl/type/RectScope.h>
|
#include<hgl/type/RectScope.h>
|
||||||
|
#include<hgl/type/Size2.h>
|
||||||
#include<hgl/color/Color4f.h>
|
#include<hgl/color/Color4f.h>
|
||||||
#include<hgl/graph/AABB.h>
|
#include<hgl/graph/AABB.h>
|
||||||
namespace hgl
|
namespace hgl
|
||||||
@ -59,17 +60,17 @@ namespace hgl
|
|||||||
Primitive *CreateCircle(RenderResource *db,const VIL *vil,const CircleCreateInfo *cci);
|
Primitive *CreateCircle(RenderResource *db,const VIL *vil,const CircleCreateInfo *cci);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 平面网格创建信息
|
* 平面网格创建信息<br>
|
||||||
|
* 会创建一个在XY平面上居中的网格,单个格子尺寸为1。
|
||||||
*/
|
*/
|
||||||
struct PlaneGridCreateInfo
|
struct PlaneGridCreateInfo
|
||||||
{
|
{
|
||||||
Vector3f coord[4];
|
Size2u grid_size; ///<格子数量
|
||||||
Vector2u step;
|
|
||||||
|
|
||||||
Vector2u side_step; //到边界的步数
|
Size2u sub_count; ///<细分格子数量
|
||||||
|
|
||||||
float lum; //一般线条颜色
|
float lum; ///<一般线条颜色
|
||||||
float side_lum; //边界线条颜色
|
float sub_lum; ///<细分及边界线条颜色
|
||||||
};//struct PlaneGridCreateInfo
|
};//struct PlaneGridCreateInfo
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -166,41 +166,44 @@ namespace hgl
|
|||||||
{
|
{
|
||||||
PrimitiveCreater rc(db,vil);
|
PrimitiveCreater rc(db,vil);
|
||||||
|
|
||||||
if(!rc.Init(((pgci->step.x+1)+(pgci->step.y+1))*2))
|
if(!rc.Init(((pgci->grid_size.width+1)+(pgci->grid_size.height+1))*2))
|
||||||
return(nullptr);
|
return(nullptr);
|
||||||
|
|
||||||
AutoDelete<VB3f> vertex=rc.AccessVAD<VB3f>(VAN::Position);
|
AutoDelete<VB3f> vertex=rc.AccessVAD<VB3f>(VAN::Position);
|
||||||
for(uint row=0;row<=pgci->step.x;row++)
|
|
||||||
{
|
|
||||||
float pos=float(row)/float(pgci->step.x);
|
|
||||||
|
|
||||||
vertex->WriteLine( to(pgci->coord[0],pgci->coord[1],pos),
|
const float right=float(pgci->grid_size.width)/2.0f;
|
||||||
to(pgci->coord[3],pgci->coord[2],pos));
|
const float left =-right;
|
||||||
|
|
||||||
|
const float bottom=float(pgci->grid_size.height)/2.0f;
|
||||||
|
const float top =-bottom;
|
||||||
|
|
||||||
|
for(int row=0;row<=pgci->grid_size.height;row++)
|
||||||
|
{
|
||||||
|
vertex->WriteLine( Vector3f(left ,top+row,0),
|
||||||
|
Vector3f(right,top+row,0));
|
||||||
}
|
}
|
||||||
|
|
||||||
for(uint col=0;col<=pgci->step.y;col++)
|
for(int col=0;col<=pgci->grid_size.width;col++)
|
||||||
{
|
{
|
||||||
float pos=float(col)/float(pgci->step.y);
|
vertex->WriteLine(Vector3f(left+col,top, 0),
|
||||||
|
Vector3f(left+col,bottom,0));
|
||||||
vertex->WriteLine(to(pgci->coord[1],pgci->coord[2],pos),
|
|
||||||
to(pgci->coord[0],pgci->coord[3],pos));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoDelete<VB1f> lum=rc.AccessVAD<VB1f>(VAN::Luminance);
|
AutoDelete<VB1f> lum=rc.AccessVAD<VB1f>(VAN::Luminance);
|
||||||
if(lum)
|
if(lum)
|
||||||
{
|
{
|
||||||
for(uint row=0;row<=pgci->step.x;row++)
|
for(int row=0;row<=pgci->grid_size.height;row++)
|
||||||
{
|
{
|
||||||
if((row%pgci->side_step.x)==0)
|
if((row%pgci->sub_count.height)==0)
|
||||||
lum->RepeatWrite(pgci->side_lum,2);
|
lum->RepeatWrite(pgci->sub_lum,2);
|
||||||
else
|
else
|
||||||
lum->RepeatWrite(pgci->lum,2);
|
lum->RepeatWrite(pgci->lum,2);
|
||||||
}
|
}
|
||||||
|
|
||||||
for(uint col=0;col<=pgci->step.y;col++)
|
for(int col=0;col<=pgci->grid_size.width;col++)
|
||||||
{
|
{
|
||||||
if((col%pgci->side_step.y)==0)
|
if((col%pgci->sub_count.width)==0)
|
||||||
lum->RepeatWrite(pgci->side_lum,2);
|
lum->RepeatWrite(pgci->sub_lum,2);
|
||||||
else
|
else
|
||||||
lum->RepeatWrite(pgci->lum,2);
|
lum->RepeatWrite(pgci->lum,2);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user