public void CreateAllBuffer(Device device, Vector3 center, float radius) { if (first) { CreateAxieLinesBuffer(device, center, radius); arrows[0].CreateAllBuffer(device, AxisArrow.Point_To_X_Axis(center, radius)); arrows[1].CreateAllBuffer(device, AxisArrow.Point_To_Y_Axis(center, radius)); arrows[2].CreateAllBuffer(device, AxisArrow.Point_To_Z_Axis(center, radius)); //只有第一次创建时才更新center,radius this.center = center; this.radius = radius; this.first = false; } else { //非首次创建,则始终使用参考模型的center、radius CreateAxieLinesBuffer(device, this.center, this.radius); arrows[0].CreateAllBuffer(device, AxisArrow.Point_To_X_Axis(this.center, this.radius)); arrows[1].CreateAllBuffer(device, AxisArrow.Point_To_Y_Axis(this.center, this.radius)); arrows[2].CreateAllBuffer(device, AxisArrow.Point_To_Z_Axis(this.center, this.radius)); } }
Vector3 center; //始终保存参考模型的center public CoordAxies() { first = true; arrows = new AxisArrow[3]; arrows[0] = new AxisArrow(Color.Red); arrows[1] = new AxisArrow(Color.Green); arrows[2] = new AxisArrow(Color.Blue); }