Skip to content

Commit 54867c3

Browse files
committed
Added line weight and smooth control to Scene and Screen meshes
1 parent 0a4775b commit 54867c3

7 files changed

Lines changed: 47 additions & 6 deletions

File tree

Core/Contents/Include/PolySceneLine.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ namespace Polycode {
4848

4949
void Render();
5050

51+
Number lineWidth;
52+
bool lineSmooth;
53+
5154
protected:
5255

5356
Mesh *mesh;

Core/Contents/Include/PolySceneMesh.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ namespace Polycode {
134134

135135
bool showVertexNormals;
136136

137+
Number lineWidth;
138+
bool lineSmooth;
137139

138140
protected:
139141

Core/Contents/Include/PolyScreenMesh.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ namespace Polycode {
8484
*/
8585
void setTexture(Texture *texture);
8686

87+
/**
88+
* If this is set to true, the lines in wireframe meshes will be anti-aliased if the support is available in the renderer.
89+
*/
90+
bool lineSmooth;
91+
92+
Number lineWidth;
93+
94+
8795
protected:
8896

8997
Mesh *mesh;

Core/Contents/Include/PolyScreenShape.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,11 +107,6 @@ namespace Polycode {
107107
*/
108108
Color strokeColor;
109109

110-
/**
111-
* If this is set to true, the line will be anti-aliased if the support is available in the renderer.
112-
*/
113-
bool lineSmooth;
114-
115110
protected:
116111

117112
Number option1;

Core/Contents/Source/PolySceneLine.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ SceneLine::SceneLine(Vector3 start, Vector3 end) : SceneEntity() {
4242

4343
ignoreParentMatrix = true;
4444

45+
lineWidth = 1.0;
46+
lineSmooth = false;
47+
4548
}
4649

4750
SceneLine::SceneLine(SceneEntity *ent1, SceneEntity *ent2) : SceneEntity() {
@@ -56,6 +59,10 @@ SceneLine::SceneLine(SceneEntity *ent1, SceneEntity *ent2) : SceneEntity() {
5659
mesh->addPolygon(poly);
5760

5861
ignoreParentMatrix = true;
62+
63+
lineWidth = 1.0;
64+
lineSmooth = false;
65+
5966
}
6067

6168
SceneLine::~SceneLine() {
@@ -89,6 +96,10 @@ void SceneLine::Render() {
8996
mesh->arrayDirtyMap[RenderDataArray::VERTEX_DATA_ARRAY] = true;
9097

9198
Renderer *renderer = CoreServices::getInstance()->getRenderer();
99+
100+
renderer->setLineSize(lineWidth);
101+
renderer->setLineSmooth(lineSmooth);
102+
92103
renderer->setTexture(NULL);
93104
renderer->pushDataArrayForMesh(mesh, RenderDataArray::VERTEX_DATA_ARRAY);
94105
renderer->pushDataArrayForMesh(mesh, RenderDataArray::TEXCOORD_DATA_ARRAY);

Core/Contents/Source/PolySceneMesh.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ SceneMesh::SceneMesh(const String& fileName) : SceneEntity(), texture(NULL), mat
4343
lightmapIndex=0;
4444
showVertexNormals = false;
4545
useVertexBuffer = false;
46+
lineSmooth = false;
47+
lineWidth = 1.0;
4648
}
4749

4850
SceneMesh::SceneMesh(Mesh *mesh) : SceneEntity(), texture(NULL), material(NULL) {
@@ -52,7 +54,10 @@ SceneMesh::SceneMesh(Mesh *mesh) : SceneEntity(), texture(NULL), material(NULL)
5254
skeleton = NULL;
5355
lightmapIndex=0;
5456
showVertexNormals = false;
55-
useVertexBuffer = false;
57+
useVertexBuffer = false;
58+
lineSmooth = false;
59+
lineWidth = 1.0;
60+
5661
}
5762

5863
SceneMesh::SceneMesh(int meshType) : texture(NULL), material(NULL) {
@@ -63,6 +68,8 @@ SceneMesh::SceneMesh(int meshType) : texture(NULL), material(NULL) {
6368
lightmapIndex=0;
6469
showVertexNormals = false;
6570
useVertexBuffer = false;
71+
lineSmooth = false;
72+
lineWidth = 1.0;
6673
}
6774

6875
void SceneMesh::setMesh(Mesh *mesh) {
@@ -226,6 +233,9 @@ void SceneMesh::Render() {
226233

227234
Renderer *renderer = CoreServices::getInstance()->getRenderer();
228235

236+
renderer->setLineSize(lineWidth);
237+
renderer->setLineSmooth(lineSmooth);
238+
229239
if(material) {
230240
renderer->applyMaterial(material, localShaderOptions,0);
231241
} else {

Core/Contents/Source/PolyScreenMesh.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,22 @@ using namespace Polycode;
3030

3131
ScreenMesh::ScreenMesh(Mesh *mesh) : ScreenEntity(), texture(NULL) {
3232
this->mesh = mesh;
33+
lineSmooth = false;
34+
lineWidth = 1.0;
3335
}
3436

3537
ScreenMesh::ScreenMesh(const String& fileName) : ScreenEntity(), texture(NULL) {
3638
mesh = new Mesh(fileName);
39+
lineSmooth = false;
40+
lineWidth = 1.0;
41+
3742
}
3843

3944
ScreenMesh::ScreenMesh(int meshType) : ScreenEntity(), texture(NULL) {
4045
mesh = new Mesh(meshType);
46+
lineSmooth = false;
47+
lineWidth = 1.0;
48+
4149
}
4250

4351

@@ -67,6 +75,10 @@ void ScreenMesh::loadTexture(Image *image) {
6775

6876
void ScreenMesh::Render() {
6977
Renderer *renderer = CoreServices::getInstance()->getRenderer();
78+
79+
renderer->setLineSize(lineWidth);
80+
renderer->setLineSmooth(lineSmooth);
81+
7082
renderer->setTexture(texture);
7183
if(mesh->useVertexColors) {
7284
renderer->pushDataArrayForMesh(mesh, RenderDataArray::COLOR_DATA_ARRAY);

0 commit comments

Comments
 (0)