Просмотр исходного кода

Added line weight and smooth control to Scene and Screen meshes

Ivan Safrin 13 лет назад
Родитель
Сommit
54867c3ef4

+ 3 - 0
Core/Contents/Include/PolySceneLine.h

@@ -48,6 +48,9 @@ namespace Polycode {
 						
 			void Render();
 			
+			Number lineWidth;
+			bool lineSmooth;				
+			
 		protected:		
 		
 			Mesh *mesh;

+ 2 - 0
Core/Contents/Include/PolySceneMesh.h

@@ -134,6 +134,8 @@ namespace Polycode {
 			
 			bool showVertexNormals;
 			
+			Number lineWidth;
+			bool lineSmooth;	
 		
 		protected:
 		

+ 8 - 0
Core/Contents/Include/PolyScreenMesh.h

@@ -84,6 +84,14 @@ namespace Polycode {
 			*/						
 			void setTexture(Texture *texture);
 			
+			/**
+			* If this is set to true, the lines in wireframe meshes will be anti-aliased if the support is available in the renderer.
+			*/			
+			bool lineSmooth;
+			
+			Number lineWidth;
+			
+			
 		protected:
 		
 			Mesh *mesh;

+ 0 - 5
Core/Contents/Include/PolyScreenShape.h

@@ -107,11 +107,6 @@ namespace Polycode {
 			*/
 			Color strokeColor;
 			
-			/**
-			* If this is set to true, the line will be anti-aliased if the support is available in the renderer.
-			*/			
-			bool lineSmooth;
-			
 		protected:
 		
 			Number option1;

+ 11 - 0
Core/Contents/Source/PolySceneLine.cpp

@@ -42,6 +42,9 @@ SceneLine::SceneLine(Vector3 start, Vector3 end) : SceneEntity() {
 	
 	ignoreParentMatrix = true;
 	
+	lineWidth = 1.0;
+	lineSmooth = false;
+	
 }
 
 SceneLine::SceneLine(SceneEntity *ent1, SceneEntity *ent2) : SceneEntity() {
@@ -56,6 +59,10 @@ SceneLine::SceneLine(SceneEntity *ent1, SceneEntity *ent2) : SceneEntity() {
 	mesh->addPolygon(poly);
 	
 	ignoreParentMatrix = true;
+	
+	lineWidth = 1.0;
+	lineSmooth = false;
+	
 }
 
 SceneLine::~SceneLine() {
@@ -89,6 +96,10 @@ void SceneLine::Render() {
 	mesh->arrayDirtyMap[RenderDataArray::VERTEX_DATA_ARRAY] = true;
 	
 	Renderer *renderer = CoreServices::getInstance()->getRenderer();
+	
+	renderer->setLineSize(lineWidth);
+	renderer->setLineSmooth(lineSmooth);
+	
 	renderer->setTexture(NULL);	
 	renderer->pushDataArrayForMesh(mesh, RenderDataArray::VERTEX_DATA_ARRAY);
 	renderer->pushDataArrayForMesh(mesh, RenderDataArray::TEXCOORD_DATA_ARRAY);	

+ 11 - 1
Core/Contents/Source/PolySceneMesh.cpp

@@ -43,6 +43,8 @@ SceneMesh::SceneMesh(const String& fileName) : SceneEntity(), texture(NULL), mat
 	lightmapIndex=0;
 	showVertexNormals = false;
 	useVertexBuffer = false;
+	lineSmooth = false;
+	lineWidth = 1.0;
 }
 
 SceneMesh::SceneMesh(Mesh *mesh) : SceneEntity(), texture(NULL), material(NULL) {
@@ -52,7 +54,10 @@ SceneMesh::SceneMesh(Mesh *mesh) : SceneEntity(), texture(NULL), material(NULL)
 	skeleton = NULL;
 	lightmapIndex=0;
 	showVertexNormals = false;	
-	useVertexBuffer = false;	
+	useVertexBuffer = false;
+	lineSmooth = false;
+	lineWidth = 1.0;
+		
 }
 
 SceneMesh::SceneMesh(int meshType) : texture(NULL), material(NULL) {
@@ -63,6 +68,8 @@ SceneMesh::SceneMesh(int meshType) : texture(NULL), material(NULL) {
 	lightmapIndex=0;
 	showVertexNormals = false;	
 	useVertexBuffer = false;	
+	lineSmooth = false;
+	lineWidth = 1.0;	
 }
 
 void SceneMesh::setMesh(Mesh *mesh) {
@@ -226,6 +233,9 @@ void SceneMesh::Render() {
 	
 	Renderer *renderer = CoreServices::getInstance()->getRenderer();
 	
+	renderer->setLineSize(lineWidth);
+	renderer->setLineSmooth(lineSmooth);
+	
 	if(material) {
 		renderer->applyMaterial(material, localShaderOptions,0);
 	} else {

+ 12 - 0
Core/Contents/Source/PolyScreenMesh.cpp

@@ -30,14 +30,22 @@ using namespace Polycode;
 
 ScreenMesh::ScreenMesh(Mesh *mesh) : ScreenEntity(), texture(NULL) {
 	this->mesh = mesh;
+	lineSmooth = false;
+	lineWidth = 1.0;
 }
 
 ScreenMesh::ScreenMesh(const String& fileName) : ScreenEntity(), texture(NULL) {
 	mesh = new Mesh(fileName);
+	lineSmooth = false;
+	lineWidth = 1.0;
+	
 }
 
 ScreenMesh::ScreenMesh(int meshType) : ScreenEntity(), texture(NULL) {
 	mesh = new Mesh(meshType);
+	lineSmooth = false;
+	lineWidth = 1.0;
+	
 }
 
 
@@ -67,6 +75,10 @@ void ScreenMesh::loadTexture(Image *image) {
 
 void ScreenMesh::Render() {	
 	Renderer *renderer = CoreServices::getInstance()->getRenderer();
+	
+	renderer->setLineSize(lineWidth);
+	renderer->setLineSmooth(lineSmooth);
+	
 	renderer->setTexture(texture);
 	if(mesh->useVertexColors) {
 		renderer->pushDataArrayForMesh(mesh, RenderDataArray::COLOR_DATA_ARRAY);