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

Added static constructor proxies for overloaded constructors for Lua bindings access

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

+ 15 - 0
Core/Contents/Include/PolyColor.h

@@ -69,6 +69,21 @@ namespace Polycode {
 			*/															
 			Color(unsigned int hex);
 		
+			/**
+			* Create from 0-255 integer data.
+			* @param r Red value 0-255.
+			* @param g Green value 0-255.
+			* @param b Blue value 0-255.
+			* @param a Alpha value 0-255.									
+			*/		
+			static Color ColorWithInts(int r,int g, int b, int a);
+			
+			/**
+			* Create from integer color.
+			* @param hex Integer color value.
+			*/			
+			static Color ColorWithHex(unsigned int hex);
+		
 			virtual ~Color();
 			
 			/** 

+ 10 - 2
Core/Contents/Include/PolyImage.h

@@ -46,7 +46,7 @@ namespace Polycode {
 			* @param height Height of the image to create.			
 			* @param type Type of image to create. Can be IMAGE_RGBA or IMAGE_RGB.
 			*/ 			
-			Image(int width, int height, int type = IMAGE_RGBA);
+			Image(int width, int height, int type = Image::IMAGE_RGBA);
 			
 			/**
 			* Create an image of specified size and type and set its contents from the specified buffer.
@@ -55,7 +55,15 @@ namespace Polycode {
 			* @param height Height of the image to create.			
 			* @param type Type of image to create. Can be IMAGE_RGBA or IMAGE_RGB.
 			*/ 						
-			Image(char *data, int width, int height, int type = IMAGE_RGBA);
+			Image(char *data, int width, int height, int type = Image::IMAGE_RGBA);
+			
+			/**
+			* Create a blank image of specified size and type.
+			* @param width Width of the image to create.
+			* @param height Height of the image to create.			
+			* @param type Type of image to create. Can be IMAGE_RGBA or IMAGE_RGB.
+			*/ 			
+			static Image *BlankImage(int width, int height, int type = Image::IMAGE_RGBA);
 			
 			/**
 			* Create an image from another image.

+ 6 - 0
Core/Contents/Include/PolyMesh.h

@@ -129,6 +129,12 @@ namespace Polycode {
 			*/
 			Mesh(const String& fileName);
 
+			/**
+			* Construct from a mesh loaded from a file.
+			* @param fileName Path to mesh file.
+			*/			
+			static Mesh *MeshFromFileName(String& fileName);
+
 			virtual ~Mesh();
 			
 			/**

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

@@ -40,7 +40,21 @@ namespace Polycode {
 			* @param ent2 Ending entity.
 			*/
 			SceneLine(SceneEntity *ent1, SceneEntity *ent2);
+			
+			/**
+			* Constructs the line with two taraget positions.
+			* @param start Starting position.
+			* @param end Ending position.
+			*/			
 			SceneLine(Vector3 start, Vector3 end);
+
+			/**
+			* Constructs the line with two taraget positions.
+			* @param start Starting position.
+			* @param end Ending position.
+			*/						
+			static SceneLine *SceneLineWithPositions(Vector3 start, Vector3 end);			
+			
 			virtual ~SceneLine();
 			
 			void setStart(Vector3 start);

+ 9 - 3
Core/Contents/Include/PolySceneMesh.h

@@ -46,7 +46,7 @@ namespace Polycode {
 			
 			/**
 			* Construct an empty scene mesh with the specified type.
-			* @param meshType Mesh type to create. Possible values are: Mesh::QUAD_MESH, Mesh::TRI_MESH, Mesh::TRIFAN_MESH, Mesh::TRISTRIP_MESH, Mesh::LINE_MESH, Mesh::POINT_MESH.
+			* @param meshType Mesh type to create. See Mesh for possible values.
 			*/			
 			SceneMesh(int meshType);		
 			
@@ -56,10 +56,16 @@ namespace Polycode {
 			SceneMesh(Mesh *mesh);
 			
 			/**
-			* Static wrapper for Lua
-			*/
+			* Construct scene mesh from an existing Mesh instance.
+			*/			
 			static SceneMesh *SceneMeshFromMesh(Mesh *mesh);
 			
+			/**
+			* Construct an empty scene mesh with the specified type.
+			* @param meshType Mesh type to create. See Mesh for possible values.
+			*/						
+			static SceneMesh *SceneMeshWithType(int meshType);
+						
 			virtual ~SceneMesh();
 			
 			void Render();

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

@@ -40,6 +40,8 @@ class ScreenEntityInstance : public ScreenEntity {
 	public:
 		ScreenEntityInstance(const String& fileName);
 		ScreenEntityInstance();
+		
+		static ScreenEntityInstance *BlankScreenEntityInstance();
 
 		~ScreenEntityInstance();
 	

+ 13 - 2
Core/Contents/Include/PolyScreenImage.h

@@ -45,11 +45,22 @@ namespace Polycode {
 		
 		/**
 		 * Create screen image from Texture.
-		 * @param image Texture to create from.
+		 * @param texture Texture to create from.
 		 */		
 		ScreenImage(Texture *texture);		
 		
-
+		/**
+		* Create screen image from Image.
+		* @param image Image to create from.
+		*/				
+		static ScreenImage* ScreenImageWithImage(Image *image);
+		
+		/**
+		 * Create screen image from Texture.
+		 * @param texture Texture to create from.
+		 */				
+		static ScreenImage* ScreenImageWithTexture(Texture *texture);
+		
 		virtual ~ScreenImage();
 		
 		virtual Entity *Clone(bool deepClone, bool ignoreEditorOnly);

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

@@ -51,6 +51,11 @@ namespace Polycode {
 			void setStart(Vector2 point);
 			void setEnd(Vector2 point);
 						
+			/**
+			* Create a line between two entities. It's automatically updated every frame to follow the entities.
+			* @target1 Starting target.
+			* @target2 Ending target.
+			*/							
 			static ScreenLine *ScreenLineBetweenEntities(ScreenEntity* target1, ScreenEntity* target2);			
 
 			void Update();

+ 7 - 1
Core/Contents/Include/PolyScreenMesh.h

@@ -52,8 +52,14 @@ namespace Polycode {
 			*/
 			ScreenMesh(int meshType);
 			
-			// Static constructor wrappers for bindings
+			/**
+			* Create an empty screen mesh of specified type. See Mesh for available mesh types.
+			*/
 			static ScreenMesh *ScreenMeshWithType(int meshType);
+			
+			/**
+			* Creates the screen mesh from existing Mesh.
+			*/			
 			static ScreenMesh *ScreenMeshWithMesh(Mesh *mesh);
 						
 			virtual ~ScreenMesh();

+ 9 - 0
Core/Contents/Include/PolyScreenSprite.h

@@ -64,6 +64,15 @@ class _PolyExport ScreenSprite : public ScreenShape
 		* @param spriteWidth Pixel height of each sprite cell.		
 		*/
 		ScreenSprite(const String& fileName, Number spriteWidth, Number spriteHeight);
+		
+		/**
+		* Create a sprite from a spritesheet image of specified size.
+		* @param fileName Image file to load spritesheet from.
+		* @param spriteWidth Pixel width of each sprite cell.
+		* @param spriteWidth Pixel height of each sprite cell.		
+		*/		
+		static ScreenSprite* ScreenSpriteFromImageFile(const String& fileName, Number spriteWidth, Number spriteHeight);
+		
 		virtual ~ScreenSprite();
 		
 		virtual Entity *Clone(bool deepClone, bool ignoreEditorOnly);

+ 9 - 0
Core/Contents/Include/PolySkeleton.h

@@ -141,7 +141,16 @@ namespace Polycode {
 			* @param fileName Skeleton file to load.
 			*/
 			Skeleton(const String& fileName);
+
+			/**
+			* Construct a blank skeleton.
+			*/			
 			Skeleton();
+
+			/**
+			* Construct a blank skeleton.
+			*/			
+			static Skeleton *BlankSkeleton();
 			
 			/**
 			* Loads a new skeleton from file.

+ 9 - 0
Core/Contents/Source/PolyColor.cpp

@@ -45,6 +45,15 @@ Color::Color(unsigned int hex) {
 	setColorHex(hex);
 }
 
+Color Color::ColorWithInts(int r,int g, int b, int a) {
+	return Color(r,g,b,a);
+}
+
+Color Color::ColorWithHex(unsigned int hex) {
+	return Color(hex);
+}
+
+
 void Color::setColorHexRGB(unsigned int hex) {
 
 //	int tr = (hex >> 24) & 0xFF;

+ 5 - 0
Core/Contents/Source/PolyImage.cpp

@@ -46,6 +46,11 @@ Image::Image(const String& fileName) : imageData(NULL) {
 	}
 }
 
+Image *Image::BlankImage(int width, int height, int type) {
+		return new Image(width, height, type);
+}
+
+
 void Image::setPixelType(int type) {
 	imageType = type;
 	switch(imageType) {

+ 3 - 0
Core/Contents/Source/PolyMesh.cpp

@@ -56,6 +56,9 @@ namespace Polycode {
 		useVertexColors = false;				
 	}
 	
+	Mesh *Mesh::MeshFromFileName(String& fileName) {
+		return new Mesh(fileName);
+	}
 	
 	Mesh::~Mesh() {
 		clearMesh();

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

@@ -65,6 +65,10 @@ SceneLine::SceneLine(SceneEntity *ent1, SceneEntity *ent2) : SceneEntity() {
 	
 }
 
+SceneLine *SceneLine::SceneLineWithPositions(Vector3 start, Vector3 end) {
+	return new SceneLine(start, end);
+}
+
 SceneLine::~SceneLine() {
 	delete mesh;
 }

+ 4 - 0
Core/Contents/Source/PolySceneMesh.cpp

@@ -39,6 +39,10 @@ SceneMesh *SceneMesh::SceneMeshFromMesh(Mesh *mesh) {
 	return new SceneMesh(mesh);
 }
 
+SceneMesh *SceneMesh::SceneMeshWithType(int meshType) {
+	return new SceneMesh(meshType);
+}
+
 SceneMesh::SceneMesh(const String& fileName) : SceneEntity(), texture(NULL), material(NULL), skeleton(NULL), localShaderOptions(NULL) {
 	mesh = new Mesh(fileName);
 	bBoxRadius = mesh->getRadius();

+ 4 - 0
Core/Contents/Source/PolyScreenEntityInstance.cpp

@@ -25,6 +25,10 @@
 
 using namespace Polycode;
 
+ScreenEntityInstance *ScreenEntityInstance::BlankScreenEntityInstance() {
+	return new ScreenEntityInstance();
+}
+
 ScreenEntityInstance::ScreenEntityInstance(const String& fileName) : ScreenEntity() {
 	rootEntity = NULL;
 	setPositionMode(ScreenEntity::POSITION_CENTER);

+ 8 - 0
Core/Contents/Source/PolyScreenImage.cpp

@@ -28,6 +28,14 @@
 
 using namespace Polycode;
 
+ScreenImage* ScreenImage::ScreenImageWithImage(Image *image) {
+	return new ScreenImage(image);
+}
+
+ScreenImage* ScreenImage::ScreenImageWithTexture(Texture *texture) {
+	return new ScreenImage(texture);	
+}
+
 ScreenImage::ScreenImage(const String& fileName) : ScreenShape(ScreenShape::SHAPE_RECT,1,1) {
 	loadTexture(fileName);
 	

+ 4 - 0
Core/Contents/Source/PolyScreenSprite.cpp

@@ -30,6 +30,10 @@
 using std::vector;
 using namespace Polycode;
 
+ScreenSprite* ScreenSprite::ScreenSpriteFromImageFile(const String& fileName, Number spriteWidth, Number spriteHeight) {
+	return new ScreenSprite(fileName, spriteWidth, spriteHeight);
+}
+
 ScreenSprite::ScreenSprite(const String& fileName) : ScreenShape(ScreenShape::SHAPE_RECT, 1, 1) {
 
 	currentFrame = 0;

+ 4 - 0
Core/Contents/Source/PolySkeleton.cpp

@@ -31,6 +31,10 @@
 
 using namespace Polycode;
 
+Skeleton *Skeleton::BlankSkeleton() {
+	return new Skeleton();
+}
+
 Skeleton::Skeleton(const String& fileName) : SceneEntity() {
 	loadSkeleton(fileName);
 	currentAnimation = NULL;