فهرست منبع

Meshes now use direct arrays for vertex information storage making rendering faster and meshes take up less space, removed Vertex class, update codebase to work with new changes, removed old GLES1 files

Ivan Safrin 11 سال پیش
والد
کامیت
a9b5d1ece3
42فایلهای تغییر یافته به همراه1042 افزوده شده و 2530 حذف شده
  1. 2 2
      Core/Contents/CMakeLists.txt
  2. 10 2
      Core/Contents/Include/PolyBezierCurve.h
  3. 2 2
      Core/Contents/Include/PolyFontGlyphSheet.h
  4. 0 143
      Core/Contents/Include/PolyGLES1Renderer.h
  5. 0 57
      Core/Contents/Include/PolyGLES1Texture.h
  6. 1 4
      Core/Contents/Include/PolyGLRenderer.h
  7. 3 1
      Core/Contents/Include/PolyGLVertexBuffer.h
  8. 2 0
      Core/Contents/Include/PolyGlobals.h
  9. 63 78
      Core/Contents/Include/PolyMesh.h
  10. 1 2
      Core/Contents/Include/PolyRay.h
  11. 104 0
      Core/Contents/Include/PolyRenderDataArray.h
  12. 3 9
      Core/Contents/Include/PolyRenderer.h
  13. 9 2
      Core/Contents/Include/PolySceneMesh.h
  14. 0 200
      Core/Contents/Include/PolyVertex.h
  15. 1 0
      Core/Contents/Include/Polycode.h
  16. 0 88
      Core/Contents/Include/PolyiPhoneCore.h
  17. 35 1
      Core/Contents/Source/PolyBezierCurve.cpp
  18. 2 1
      Core/Contents/Source/PolyFontGlyphSheet.cpp
  19. 0 719
      Core/Contents/Source/PolyGLES1Renderer.cpp
  20. 0 86
      Core/Contents/Source/PolyGLES1Texture.cpp
  21. 67 231
      Core/Contents/Source/PolyGLRenderer.cpp
  22. 42 173
      Core/Contents/Source/PolyGLVertexBuffer.cpp
  23. 390 279
      Core/Contents/Source/PolyMesh.cpp
  24. 17 10
      Core/Contents/Source/PolyParticleEmitter.cpp
  25. 4 4
      Core/Contents/Source/PolyRay.cpp
  26. 54 0
      Core/Contents/Source/PolyRenderDataArray.cpp
  27. 0 12
      Core/Contents/Source/PolyRenderer.cpp
  28. 6 8
      Core/Contents/Source/PolySceneImage.cpp
  29. 11 11
      Core/Contents/Source/PolySceneLine.cpp
  30. 57 48
      Core/Contents/Source/PolySceneMesh.cpp
  31. 10 10
      Core/Contents/Source/PolySceneSprite.cpp
  32. 3 2
      Core/Contents/Source/PolyTextMesh.cpp
  33. 0 120
      Core/Contents/Source/PolyVertex.cpp
  34. 0 90
      Core/Contents/Source/PolyiPhoneCore.cpp
  35. 12 18
      IDE/Contents/Source/PolycodeEntityEditor.cpp
  36. 5 4
      IDE/Contents/Source/PolycodeFrame.cpp
  37. 46 42
      IDE/Contents/Source/PolycodeSpriteEditor.cpp
  38. 0 3
      IDE/Contents/Source/TransformGizmo.cpp
  39. 3 2
      Modules/Contents/3DPhysics/Source/PolyCollisionSceneEntity.cpp
  40. 12 11
      Modules/Contents/UI/Source/PolyUIColorBox.cpp
  41. 28 33
      Modules/Contents/UI/Source/PolyUIElement.cpp
  42. 37 22
      Tools/Contents/polyimport/Source/polyimport.cpp

+ 2 - 2
Core/Contents/CMakeLists.txt

@@ -44,6 +44,7 @@ SET(polycore_SRCS
     Source/PolyQuaternionCurve.cpp
     Source/PolyQuaternionCurve.cpp
     Source/PolyRectangle.cpp
     Source/PolyRectangle.cpp
     Source/PolyRenderer.cpp
     Source/PolyRenderer.cpp
+    Source/PolyRenderDataArray.cpp
     Source/PolyResource.cpp
     Source/PolyResource.cpp
     Source/PolyResourceManager.cpp
     Source/PolyResourceManager.cpp
     Source/PolyScene.cpp
     Source/PolyScene.cpp
@@ -71,7 +72,6 @@ SET(polycore_SRCS
     Source/PolyVector2.cpp
     Source/PolyVector2.cpp
     Source/PolyVector3.cpp
     Source/PolyVector3.cpp
     Source/PolyVector4.cpp
     Source/PolyVector4.cpp
-    Source/PolyVertex.cpp
     Source/tinystr.cpp
     Source/tinystr.cpp
     Source/tinyxml.cpp
     Source/tinyxml.cpp
     Source/tinyxmlerror.cpp
     Source/tinyxmlerror.cpp
@@ -133,6 +133,7 @@ SET(polycore_HDRS
     Include/PolyQuaternion.h
     Include/PolyQuaternion.h
     Include/PolyRectangle.h
     Include/PolyRectangle.h
     Include/PolyRenderer.h
     Include/PolyRenderer.h
+    Include/PolyRenderDataArray.h
     Include/PolyResource.h
     Include/PolyResource.h
     Include/PolyResourceManager.h
     Include/PolyResourceManager.h
     Include/PolyScene.h
     Include/PolyScene.h
@@ -160,7 +161,6 @@ SET(polycore_HDRS
     Include/PolyVector2.h
     Include/PolyVector2.h
     Include/PolyVector3.h
     Include/PolyVector3.h
     Include/PolyVector4.h
     Include/PolyVector4.h
-    Include/PolyVertex.h
     Include/tinystr.h
     Include/tinystr.h
     Include/tinyxml.h
     Include/tinyxml.h
     Include/PolySocket.h
     Include/PolySocket.h

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

@@ -29,7 +29,6 @@
 #include "PolyVector2.h"
 #include "PolyVector2.h"
 #include <vector>
 #include <vector>
 
 
-
 namespace Polycode {
 namespace Polycode {
 
 
 	/** 
 	/** 
@@ -177,6 +176,9 @@ namespace Polycode {
 		*/
 		*/
 		void removePoint(BezierPoint *point);
 		void removePoint(BezierPoint *point);
         
         
+        void setHeightCacheResolution(Number resolution);
+        void rebuildHeightCache();
+        
         /**
         /**
         * The point after which new control points should be added. If NULL, new control points are added to the end of the curve.
         * The point after which new control points should be added. If NULL, new control points are added to the end of the curve.
         */
         */
@@ -188,12 +190,18 @@ namespace Polycode {
          */
          */
         Number evaluationAccuracy;
         Number evaluationAccuracy;
         
         
-        void recalculateDistances();        
+        void recalculateDistances();
+        
+        static bool cacheHeightValues;
+        static unsigned int defaultHeightCacheResolution;
 		
 		
 		protected:
 		protected:
         
         
+            unsigned int heightCacheResolution;
             std::vector<BezierPoint*> controlPoints;
             std::vector<BezierPoint*> controlPoints;
             std::vector<Number> distances;
             std::vector<Number> distances;
+        
+            std::vector<Number> heightCache;
 		
 		
             Number minX;
             Number minX;
             Number maxX;
             Number maxX;

+ 2 - 2
Core/Contents/Include/PolyFontGlyphSheet.h

@@ -3,7 +3,7 @@
 #include "PolyGlobals.h"
 #include "PolyGlobals.h"
 #include "ft2build.h"
 #include "ft2build.h"
 #include "PolyString.h"
 #include "PolyString.h"
-#include "PolyVertex.h"
+#include "PolyVector2.h"
 #include <vector>
 #include <vector>
 #include <map>
 #include <map>
 #include <set>
 #include <set>
@@ -70,7 +70,7 @@ namespace Polycode {
 
 
 			/** Used by TextMesh to generate the vertices for the given text into the vertex array.
 			/** Used by TextMesh to generate the vertices for the given text into the vertex array.
 				@return the next index after that which was used */
 				@return the next index after that which was used */
-			int renderStringVertices(String text, std::vector<Vertex*>& vertices, int index = 0);
+			//int renderStringVertices(String text, std::vector<Vertex*>& vertices, int index = 0);
 
 
 			Texture* getTexture() { return texture; }
 			Texture* getTexture() { return texture; }
 
 

+ 0 - 143
Core/Contents/Include/PolyGLES1Renderer.h

@@ -1,143 +0,0 @@
-/*
-Copyright (C) 2011 by Ivan Safrin
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-
-#pragma once
-#include "PolyString.h"
-#include "PolyLogger.h"
-#include "PolyGlobals.h"
-#include "PolyRenderer.h"
-#include "PolyTexture.h"
-#include "PolyGLES1Texture.h"
-#include "PolyCubemap.h"
-#include "PolyFixedShader.h"
-#include "PolyMesh.h"
-
-#include <OpenGLES/ES1/gl.h>
-#include <OpenGLES/ES1/glext.h>
-#include <glu.h>
-
-namespace Polycode {
-	class _PolyExport OpenGLES1Renderer : public Renderer {
-		
-	public:
-		
-		OpenGLES1Renderer();
-		virtual ~OpenGLES1Renderer();
-		
-		void Resize(int xRes, int yRes);
-		void BeginRender();
-		void EndRender();
-		
-		Cubemap *createCubemap(Texture *t0, Texture *t1, Texture *t2, Texture *t3, Texture *t4, Texture *t5);
-		Texture *createTexture(unsigned int width, unsigned int height, char *textureData, bool clamp, int type=Image::IMAGE_RGBA);
-		Texture *createFramebufferTexture(unsigned int width, unsigned int height);
-		void createRenderTextures(Texture **colorBuffer, Texture **depthBuffer, int width, int height);
-		
-		void enableAlphaTest(bool val);
-		
-		void createVertexBufferForMesh(Mesh *mesh);
-		void drawVertexBuffer(VertexBuffer *buffer);		
-		
-		void bindFrameBufferTexture(Texture *texture);
-		void unbindFramebuffers();
-		
-		void setOrthoMode();
-		void setPerspectiveMode();
-		
-		void enableBackfaceCulling(bool val);
-		void setViewportSize(int w, int h, Number fov=45.0f);
-		
-		void setLineSmooth(bool val);		
-		
-		void loadIdentity();
-		void setClearColor(Number r, Number g, Number b);
-		
-		void setTexture(Texture *texture);		
-		void draw2DPolygon(Polygon *polygon);
-		void draw2DVertex(Vertex *vertex);
-		
-		void renderToTexture(Texture *targetTexture);		
-		void renderZBufferToTexture(Texture *targetTexture);
-		void clearScreen(bool clearColor = true, bool clearDepth = true);
-		
-		void translate2D(Number x, Number y);
-		void rotate2D(Number angle);
-		void scale2D(Vector2 *scale);
-		
-		void setLineSize(Number lineSize);
-		
-		void setVertexColor(Number r, Number g, Number b, Number a);
-		
-		void setBlendingMode(int blendingMode);
-		
-		void enableLighting(bool enable);	
-		void enableFog(bool enable);
-		void setFogProperties(int fogMode, Color color, Number density, Number startDepth, Number endDepth);		
-		
-		void draw3DPolygon(Polygon *polygon);
-		void draw3DVertex(Vertex *vertex, Vector2 *faceUV);
-		void draw3DVertex2UV(Vertex *vertex, Vector2 *faceUV1, Vector2 *faceUV2);
-		void draw3DLine(Vector3 origin, Vector3 direction, Number length, Color color);
-		
-		virtual void setNormal(const Vector3 &normal);
-		
-		void translate3D(Vector3 *position);
-		void translate3D(Number x, Number y, Number z);
-		void scale3D(Vector3 *scale);
-		
-		Matrix4 getProjectionMatrix();
-		Matrix4 getModelviewMatrix();		
-		void setModelviewMatrix(Matrix4 m);	
-		void multModelviewMatrix(Matrix4 m);
-		
-		void enableDepthTest(bool val);		
-		void drawScreenQuad(Number qx, Number qy);
-		
-		void beginRenderOperation(int meshType);
-		void endRenderOperation();
-		
-		void pushMatrix();
-		void popMatrix();
-		
-		bool test2DCoordinate(Number x, Number y, Polygon *poly, const Matrix4 &matrix, bool billboardMode);
-		
-		void setFOV(Number fov);
-		
-		Vector3 Unproject(Number x, Number y);
-		
-		void clearShader();
-		void applyMaterial(Material *material,  ShaderBinding *localOptions, unsigned int shaderIndex);
-		
-	protected:
-				
-		GLuint defaultFramebuffer, colorRenderbuffer;		
-		
-		Number nearPlane;
-		Number farPlane;
-		
-		GLfloat sceneProjectionMatrix[16];
-		
-		
-	};
-}
-

+ 0 - 57
Core/Contents/Include/PolyGLES1Texture.h

@@ -1,57 +0,0 @@
-/*
-Copyright (C) 2011 by Ivan Safrin
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-
-#pragma once
-#include "PolyString.h"
-#include "PolyGlobals.h"
-#include "PolyTexture.h"
-#include "PolyGLES1Renderer.h"
-
-#include <OpenGLES/ES1/gl.h>
-#include <OpenGLES/ES1/glext.h>
-
-namespace Polycode {
-	
-	class _PolyExport OpenGLES1Texture : public Texture {
-	public:
-		OpenGLES1Texture(unsigned int width, unsigned int height);
-		OpenGLES1Texture(unsigned int width, unsigned int height, char *textureData, bool clamp, int filteringMode);
-		virtual ~OpenGLES1Texture();
-		
-		void recreateFromImageData();
-		
-		GLuint getTextureID();
-		GLuint getFrameBufferID();
-		
-		void setGLInfo(GLuint textureID, GLuint frameBufferID);
-		
-		void setTextureData(char *data);
-		
-	private:
-		
-		int filteringMode;
-		GLuint textureID;
-		GLuint frameBufferID;
-	};
-	
-}

+ 1 - 4
Core/Contents/Include/PolyGLRenderer.h

@@ -126,10 +126,7 @@ namespace Polycode {
 		void cullFrontFaces(bool val);
 		void cullFrontFaces(bool val);
 				
 				
 		void pushRenderDataArray(RenderDataArray *array);
 		void pushRenderDataArray(RenderDataArray *array);
-		RenderDataArray *createRenderDataArrayForMesh(Mesh *mesh, int arrayType);
-		RenderDataArray *createRenderDataArray(int arrayType);
-		void setRenderArrayData(RenderDataArray *array, Number *arrayData);
-		void drawArrays(int drawType);		
+		void drawArrays(int drawType, IndexDataArray *indexArray);
 				
 				
 		void setProjectionOrtho(Number xSize=0.0f, Number ySize=0.0f, Number near=-256.0f, Number far=256.0f, bool centered = false);
 		void setProjectionOrtho(Number xSize=0.0f, Number ySize=0.0f, Number near=-256.0f, Number far=256.0f, bool centered = false);
         void setProjectionMatrix(Matrix4 matrix);
         void setProjectionMatrix(Matrix4 matrix);

+ 3 - 1
Core/Contents/Include/PolyGLVertexBuffer.h

@@ -50,6 +50,7 @@ namespace Polycode {
 		GLuint getNormalBufferID();
 		GLuint getNormalBufferID();
 		GLuint getColorBufferID();
 		GLuint getColorBufferID();
 		GLuint getTangentBufferID();
 		GLuint getTangentBufferID();
+		GLuint getIndexBufferID();
 				
 				
 	protected:
 	protected:
 		
 		
@@ -57,7 +58,8 @@ namespace Polycode {
 		GLuint texCoordBufferID;
 		GLuint texCoordBufferID;
 		GLuint normalBufferID;
 		GLuint normalBufferID;
 		GLuint colorBufferID;	
 		GLuint colorBufferID;	
-		GLuint tangentBufferID;				
+		GLuint tangentBufferID;
+        GLuint indexBufferID;
 	};
 	};
 	
 	
 }
 }

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

@@ -30,6 +30,8 @@ THE SOFTWARE.
 #define POLYCODE_VERSION_STRING "0.8.4a_dev"
 #define POLYCODE_VERSION_STRING "0.8.4a_dev"
 
 
 #define COMPILE_GL_RENDERER
 #define COMPILE_GL_RENDERER
+typedef float PolyRendererVertexType;
+typedef unsigned int PolyRendererIndexType;
 
 
 #ifdef _WINDOWS
 #ifdef _WINDOWS
 	#define WIN32_LEAN_AND_MEAN
 	#define WIN32_LEAN_AND_MEAN

+ 63 - 78
Core/Contents/Include/PolyMesh.h

@@ -22,19 +22,17 @@ THE SOFTWARE.
  
  
 #pragma once
 #pragma once
 #include "PolyGlobals.h"
 #include "PolyGlobals.h"
-#include "PolyVertex.h"
+#include "PolyRenderDataArray.h"
+#include "PolyColor.h"
+#include "PolyVector3.h"
+#include "PolyVector2.h"
+#include <vector>
 
 
 class OSFILE;
 class OSFILE;
 
 
 namespace Polycode {
 namespace Polycode {
 	
 	
 	class String;
 	class String;
-
-	class _PolyExport VertexSorter : public PolyBase {
-		public:
-			Vertex *target;
-			bool operator() (Vertex *v1,Vertex *v2) { return (v1->distance(*target)<v2->distance(*target));}
-	};	
 	
 	
 	class _PolyExport VertexBuffer : public PolyBase {
 	class _PolyExport VertexBuffer : public PolyBase {
 		public:	
 		public:	
@@ -42,60 +40,21 @@ namespace Polycode {
 			virtual ~VertexBuffer(){}
 			virtual ~VertexBuffer(){}
 		
 		
 			int getVertexCount() const { return vertexCount;}
 			int getVertexCount() const { return vertexCount;}
+			int getIndexCount() const { return indexCount;}
 		
 		
 			int verticesPerFace;
 			int verticesPerFace;
 			int meshType;
 			int meshType;
 		protected:
 		protected:
-		int vertexCount;
+            int vertexCount;
+            int indexCount;
 			
 			
 	};
 	};
-	
-	/**
-	* Render data array.
-	*/
-	class _PolyExport RenderDataArray : public PolyBase {
-	public:		
-		int arrayType;
-		int stride;
-		int size;
-		void *arrayPtr;
-		void *rendererData;
-		int count;
-		
-		/**
-		* Vertex position array.
-		*/
-		static const int VERTEX_DATA_ARRAY = 0;
-		
-		/**
-		* Vertex color array.
-		*/		
-		static const int COLOR_DATA_ARRAY = 1;		
-		
-		/**
-		* Vertex normal array.
-		*/				
-		static const int NORMAL_DATA_ARRAY = 2;				
-
-		/**
-		* Vertex texture coordinate array.
-		*/						
-		static const int TEXCOORD_DATA_ARRAY = 3;
-		
-		/**
-		* Tangent vector array.
-		*/				
-		static const int TANGENT_DATA_ARRAY = 4;				
-		
-		
-	};
 		
 		
-
 	typedef struct {
 	typedef struct {
 		float x;
 		float x;
 		float y;
 		float y;
 		float z;
 		float z;
-		float w;		
+		float w;
 	} Vector4_struct;
 	} Vector4_struct;
 	
 	
 	typedef struct {
 	typedef struct {
@@ -155,6 +114,8 @@ namespace Polycode {
 			void saveToFile(const String& fileName, bool writeNormals = true, bool writeTangents = true, bool writeColors = true, bool writeBoneWeights = true, bool writeUVs = true, bool writeSecondaryUVs = false);
 			void saveToFile(const String& fileName, bool writeNormals = true, bool writeTangents = true, bool writeColors = true, bool writeBoneWeights = true, bool writeUVs = true, bool writeSecondaryUVs = false);
 
 
 			void loadFromFile(OSFILE *inFile);
 			void loadFromFile(OSFILE *inFile);
+
+        
 			void saveToFile(OSFILE *outFile, bool writeNormals = true, bool writeTangents = true, bool writeColors = true, bool writeBoneWeights = true, bool writeUVs = true, bool writeSecondaryUVs = false);
 			void saveToFile(OSFILE *outFile, bool writeNormals = true, bool writeTangents = true, bool writeColors = true, bool writeBoneWeights = true, bool writeUVs = true, bool writeSecondaryUVs = false);
 			
 			
 			
 			
@@ -256,16 +217,37 @@ namespace Polycode {
 			* Recenters the mesh with all vertices being as equidistant from origin as possible.
 			* Recenters the mesh with all vertices being as equidistant from origin as possible.
 			*/
 			*/
 			Vector3 recenterMesh();
 			Vector3 recenterMesh();
+
+            void setVertexAtOffset(unsigned int offset, Number x, Number y, Number z);
+        
+            void addVertexWithUVAndNormal(Number x, Number y, Number z, Number u, Number v, Number nx, Number ny, Number nz);
 		
 		
-            Vertex *addVertex(Number x, Number y, Number z, Number u, Number v);
+            void addTexCoord(Number u, Number v);
+            void addTexCoord2(Number u, Number v);
         
         
-            Vertex *addVertex(Number x, Number y, Number z);
-			
-            void addVertex(Vertex *vertex);
+            void addTangent(Number x, Number y, Number z);
         
         
-            Vertex *getVertex(unsigned int index) const;
+            void addVertexWithUV(Number x, Number y, Number z, Number u, Number v);
+        
+            void addVertex(Number x, Number y, Number z);
+        
+            void addNormal(Number nx, Number ny, Number nz);
+            void addNormal(const Vector3 &n);
+
+            void addBoneAssignments(Number b1Weight, unsigned int b1Index, Number b2Weight, unsigned int b2Index, Number b3Weight, unsigned int b3Index, Number b4Weight, unsigned int b4Index);
+        
+            void addColor(Number r, Number g, Number b, Number a);
+            void addColor(const Color &color);
+        
+        
+            Vector3 getVertexPosition(unsigned int vertexOffset);
+        
+            Vector3 getVertexPositionAtIndex(unsigned int index);
+
+            Vector2 getVertexTexCoord(unsigned int vertexOffset);
+        
+            Vector2 getVertexTexCoordAtIndex(unsigned int index);
         
         
-            Vertex *getIndexedVertex(unsigned int index) const;
         
         
 			/**
 			/**
 			* Sets the vertex buffer for the mesh.
 			* Sets the vertex buffer for the mesh.
@@ -311,9 +293,6 @@ namespace Polycode {
 			*/ 
 			*/ 
 			void setMeshType(int newType);
 			void setMeshType(int newType);
 
 
-			void dirtyArray(unsigned int arrayIndex);
-			void dirtyArrays();
-
 			inline unsigned int getIndexGroupSize() {
 			inline unsigned int getIndexGroupSize() {
 				switch (meshType) {
 				switch (meshType) {
 				case QUAD_MESH: return 4;
 				case QUAD_MESH: return 4;
@@ -368,19 +347,8 @@ namespace Polycode {
 			* Line loop based mesh.
 			* Line loop based mesh.
 			*/									
 			*/									
 			static const int LINE_LOOP_MESH = 7;
 			static const int LINE_LOOP_MESH = 7;
-		
-		
-			/**
-			* Render array dirty map. If any of these are flagged as dirty, the renderer will rebuild them from the mesh data. See RenderDataArray for types of render arrays.
-			* @see RenderDataArray
-			*/
-			bool arrayDirtyMap[16];
-			
-			/**
-			* Render arrays. See RenderDataArray for types of render arrays.
-			* @see RenderDataArray			
-			*/			
-			RenderDataArray *renderDataArrays[16];
+        
+        
 		
 		
 			/**
 			/**
 			* If set to true, the renderer will use the vertex colors instead of entity color transform to render this mesh.
 			* If set to true, the renderer will use the vertex colors instead of entity color transform to render this mesh.
@@ -408,19 +376,36 @@ namespace Polycode {
 			int removeUnusedVertices();
 			int removeUnusedVertices();
         
         
             unsigned int getIndexCount();
             unsigned int getIndexCount();
-            unsigned int getIndexAt(unsigned int index);
         
         
             void subdivideToRadius(Number radius, int subdivisions);
             void subdivideToRadius(Number radius, int subdivisions);
-
+        
+            static Vector3 calculateFaceTangent(const Vector3 &v1, const Vector3 &v2, const Vector3 &v3, const Vector2 &texCoord1, const Vector2 &texCoord2, const Vector2 &texCoord3);
+        
+            void normalizeBoneWeights();
+        
+            VertexDataArray vertexPositionArray;
+            VertexDataArray vertexColorArray;
+            VertexDataArray vertexNormalArray;
+            VertexDataArray vertexTexCoordArray;
+            VertexDataArray vertexTexCoord2Array;
+            VertexDataArray vertexTangentArray;
+        
+            VertexDataArray vertexBoneWeightArray;
+            IndexDataArray vertexBoneIndexArray;
+        
+            IndexDataArray indexArray;
+        
         protected:
         protected:
         
         
-            Vector3 calculateFaceTangent(Vertex *v1, Vertex *v2, Vertex *v3);
+            void loadFromFileV2(OSFILE *inFile);
+            void loadFromFileLegacyV1(OSFILE *inFile);
+
+            void writeVertexBlock(VertexDataArray *array, OSFILE *outFile);
+            void writeIndexBlock(IndexDataArray *array, OSFILE *outFile);
         
         
             VertexBuffer *vertexBuffer;
             VertexBuffer *vertexBuffer;
             bool meshHasVertexBuffer;
             bool meshHasVertexBuffer;
             int meshType;
             int meshType;
-        
-            std::vector<unsigned int> indices;
-            std::vector <Vertex*> vertices;
+
 	};
 	};
 }
 }

+ 1 - 2
Core/Contents/Include/PolyRay.h

@@ -24,7 +24,6 @@
 #include "PolyGlobals.h"
 #include "PolyGlobals.h"
 #include "PolyVector3.h"
 #include "PolyVector3.h"
 #include "PolyMatrix4.h"
 #include "PolyMatrix4.h"
-#include "PolyVertex.h"
 
 
 namespace Polycode {
 namespace Polycode {
 
 
@@ -41,7 +40,7 @@ namespace Polycode {
 			Vector3 planeIntersectPoint(const Vector3 &planeNormal, Number planeDistance) const;
 			Vector3 planeIntersectPoint(const Vector3 &planeNormal, Number planeDistance) const;
 			Ray tranformByMatrix(const Matrix4& matrix) const;
 			Ray tranformByMatrix(const Matrix4& matrix) const;
 			
 			
-			bool polygonIntersect(Vertex *v1, Vertex *v2, Vertex *v3) const;
+			bool polygonIntersect(const Vector3 &v1, const Vector3 &v2, const Vector3 &v3) const;
 		
 		
 			Vector3 origin;
 			Vector3 origin;
 			Vector3 direction;
 			Vector3 direction;

+ 104 - 0
Core/Contents/Include/PolyRenderDataArray.h

@@ -0,0 +1,104 @@
+/*
+ Copyright (C) 2014 by Ivan Safrin
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ */
+
+#pragma once
+#include "PolyGlobals.h"
+#include <vector>
+
+namespace Polycode {
+    
+    class RenderDataArray : public PolyBase {
+    public:
+        
+        RenderDataArray(unsigned int type);
+        unsigned int type;
+        virtual void *getArrayData();
+        virtual unsigned int getDataSize();
+        
+        /**
+         * Vertex position array.
+         */
+        static const int VERTEX_DATA_ARRAY = 0;
+        
+        /**
+         * Vertex color array.
+         */
+        static const int COLOR_DATA_ARRAY = 1;
+        
+        /**
+         * Vertex normal array.
+         */
+        static const int NORMAL_DATA_ARRAY = 2;
+        
+        /**
+         * Vertex texture coordinate array.
+         */
+        static const int TEXCOORD_DATA_ARRAY = 3;
+        
+        /**
+         * Tangent array.
+         */
+        static const int TANGENT_DATA_ARRAY = 4;
+        
+        /**
+         * Bone weight array.
+         */
+        static const int BONE_WEIGHT_DATA_ARRAY = 5;
+        
+        /**
+         * Bone weight array.
+         */
+        static const int BONE_INDEX_DATA_ARRAY = 6;
+        
+        /**
+         * Index data array.
+         */
+        static const int INDEX_DATA_ARRAY = 7;
+        
+        /**
+         * Secondary texture coordinate array.
+         */
+        static const int TEXCOORD2_DATA_ARRAY = 8;
+        
+    };
+
+    class VertexDataArray : public RenderDataArray {
+    public:
+        VertexDataArray(unsigned int type) : RenderDataArray(type) {
+        }
+        
+        std::vector<PolyRendererVertexType> data;
+        virtual void *getArrayData();
+        virtual unsigned int getDataSize();
+    };
+
+    class IndexDataArray : public RenderDataArray {
+    public:
+        IndexDataArray(unsigned int type) : RenderDataArray(type) {
+        }
+        
+        std::vector<PolyRendererIndexType> data;
+        virtual void *getArrayData();
+        virtual unsigned int getDataSize();
+    };
+
+}

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

@@ -39,6 +39,7 @@ namespace Polycode {
 	class PolycodeShaderModule;
 	class PolycodeShaderModule;
 	class Polygon;
 	class Polygon;
 	class RenderDataArray;
 	class RenderDataArray;
+    class IndexDataArray;
 	class ShaderBinding;
 	class ShaderBinding;
 	class Texture;
 	class Texture;
 	class VertexBuffer;
 	class VertexBuffer;
@@ -82,8 +83,6 @@ namespace Polycode {
 	*
 	*
 	* The renderer should only be accessed from the CoreServices singleton. Renderer operations should only be called from within Render methods of entities so that they can be properly managed.
 	* The renderer should only be accessed from the CoreServices singleton. Renderer operations should only be called from within Render methods of entities so that they can be properly managed.
 	*
 	*
-	* @see http://www.glprogramming.com/red/
-	* @see http://nehe.gamedev.net/tutorial/lessons_01__05/22004/
 	*/
 	*/
 	class _PolyExport Renderer : public PolyBase {
 	class _PolyExport Renderer : public PolyBase {
 	public:
 	public:
@@ -136,14 +135,9 @@ namespace Polycode {
 			
 			
 		
 		
 		virtual void setVertexColor(Number r, Number g, Number b, Number a) = 0;
 		virtual void setVertexColor(Number r, Number g, Number b, Number a) = 0;
-		
-		void pushDataArrayForMesh(Mesh *mesh, int arrayType);
-		
+				
 		virtual void pushRenderDataArray(RenderDataArray *array) = 0;
 		virtual void pushRenderDataArray(RenderDataArray *array) = 0;
-		virtual RenderDataArray *createRenderDataArrayForMesh(Mesh *mesh, int arrayType) = 0;
-		virtual RenderDataArray *createRenderDataArray(int arrayType) = 0;
-		virtual void setRenderArrayData(RenderDataArray *array, Number *arrayData) = 0;
-		virtual void drawArrays(int drawType) = 0;
+		virtual void drawArrays(int drawType, IndexDataArray *indexArray) = 0;
 		
 		
 		virtual void translate3D(const Vector3 &position) = 0;
 		virtual void translate3D(const Vector3 &position) = 0;
 		virtual void translate3D(Number x, Number y, Number z) = 0;
 		virtual void translate3D(Number x, Number y, Number z) = 0;

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

@@ -24,6 +24,7 @@ THE SOFTWARE.
 #include "PolyGlobals.h"
 #include "PolyGlobals.h"
 #include "PolyEntity.h"
 #include "PolyEntity.h"
 #include "PolyShader.h"
 #include "PolyShader.h"
+#include "PolyRenderDataArray.h"
 
 
 namespace Polycode {
 namespace Polycode {
 
 
@@ -239,8 +240,7 @@ namespace Polycode {
             /**
             /**
              * If this flag is set to false, backface culling is disabled when rendering this entity, rendering both sides of each face. Set to true by default.
              * If this flag is set to false, backface culling is disabled when rendering this entity, rendering both sides of each face. Set to true by default.
              */
              */
-            bool backfaceCulled;	
-        
+            bool backfaceCulled;
 			
 			
 		protected:
 		protected:
 		
 		
@@ -251,5 +251,12 @@ namespace Polycode {
 			Skeleton *skeleton;
 			Skeleton *skeleton;
 			ShaderBinding *localShaderOptions;
 			ShaderBinding *localShaderOptions;
             String fileName;
             String fileName;
+        
+    
+            VertexDataArray skeletalVertexPositions;
+            VertexDataArray skeletalVertexNormals;
+        
+        
+        
 	};
 	};
 }
 }

+ 0 - 200
Core/Contents/Include/PolyVertex.h

@@ -1,200 +0,0 @@
-/*
- Copyright (C) 2011 by Ivan Safrin
- 
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- 
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
- 
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
-*/
-
-#pragma once
-#include "PolyGlobals.h"
-#include "PolyVector3.h"
-#include "PolyVector2.h"
-#include "PolyColor.h"
-#include <vector>
-
-namespace Polycode {
-
-	class Bone;
-	
-	/**
-	* Bone assignment.
-	*/ 
-	class _PolyExport BoneAssignment {
-		public:
-			BoneAssignment(){
-				bone = NULL;
-			}
-			/**
-			* Id of the bone assigned.
-			*/
-			unsigned int boneID;
-			
-			/**
-			* Assignment weight.
-			*/
-			Number weight;
-			
-			/**
-			* Assigned bone.
-			*/			
-			Bone *bone;
-	};
-
-	/**
-	* A mesh vertex.
-	*/
-	class _PolyExport Vertex : public Vector3 {
-		public:
-		
-			/**
-			* Default constructor.
-			*/
-			Vertex();
-			
-			/**
-			* Initialize with position.
-			* @param pos_x Position x.
-			* @param pos_y Position y.
-			* @param pos_z Position z.			
-			*/						
-			Vertex(Number x, Number y, Number z);			
-			
-			/**
-			* Initialize with position and normal.
-			* @param pos_x Position x.
-			* @param pos_y Position y.
-			* @param pos_z Position z.			
-			* @param nor_x Normal x.
-			* @param nor_y Normal y.
-			* @param nor_z Normal z.						
-			*/			
-			Vertex(Number pos_x, Number pos_y, Number pos_z, Number nor_x, Number nor_y, Number nor_z);
-			
-			/**
-			* Initialize with position and normal and texture coordinates.
-			* @param pos_x Position x.
-			* @param pos_y Position y.
-			* @param pos_z Position z.			
-			* @param nor_x Normal x.
-			* @param nor_y Normal y.
-			* @param nor_z Normal z.						
-			* @param u Horizontal texture coordinate.
-			* @param v Vertical texture coordinate.			
-			*/						
-			Vertex(Number pos_x, Number pos_y, Number pos_z, Number nor_x, Number nor_y, Number nor_z, Number u, Number v);		
-			
-			/**
-			* Initialize with position and texture coordinates.
-			* @param pos_x Position x.
-			* @param pos_y Position y.
-			* @param pos_z Position z.			
-			* @param u Horizontal texture coordinate.
-			* @param v Vertical texture coordinate.			
-			*/									
-			Vertex(Number x, Number y, Number z, Number u, Number v);
-			
-			virtual ~Vertex();
-			
-			/**
-			* Assign a bone to the vertex by bone id.
-			* @param boneID The bone id.
-			* @param boneWeight Normalized weight of the bone assignment.
-			*/ 
-			void addBoneAssignment(unsigned int boneID, Number boneWeight);
-			
-			/**
-			* Get total number of bone assignments.
-			* @return Number of bone assignments.
-			*/
-			int getNumBoneAssignments();
-			
-			/**
-			* Get bone assignment at index.
-			* @param Index of bone assignment.
-			* @return Bone assignment at index.
-			*/			
-			BoneAssignment *getBoneAssignment(unsigned int index);
-			
-			/**
-			* Normalizes all current weight assignments.
-			*/
-			void normalizeWeights();
-			
-			/**
-			* Returns the texture coordinates.
-			* @return Texture coordinates.
-			*/
-			Vector2 getTexCoord();
-			
-			/**
-			* Sets the texture coordinates.
-			* @param u New horizontal texture coordinate.
-			* @param v New vertical texture coordinate.			
-			*/
-			void setTexCoord(Number u, Number v);
-
-			Vector2 getSecondaryTexCoord();
-            void setSecondaryTexCoord(Number u, Number v);
-        
-			/**
-			* Sets the normal
-			* @param x Normal x.
-			* @param y Normal y.
-			* @param z Normal z.			
-			*/			
-			void setNormal(Number x, Number y, Number z);
-
-			/**
-			* Rest normal.
-			*/
-			Vector3 restNormal;
-			
-			/**
-			* Rest position.
-			*/			
-			Vector3 restPosition;
-
-			/**
-			* Vertex normal.
-			*/
-			Vector3 normal;
-
-			/**
-			* Vertex tangent.
-			*/
-			Vector3 tangent;
-			
-			/**
-			* Vertex color.
-			*/
-			Color vertexColor;		
-			
-			/**
-			* Texture coordinates
-			*/
-			Vector2 texCoord;
-			Vector2 secondaryTexCoord;
-        
-			bool useVertexColor;
-				
-		protected:
-		
-			std::vector <BoneAssignment*> boneAssignments;
-		
-	};
-}

+ 1 - 0
Core/Contents/Include/Polycode.h

@@ -48,6 +48,7 @@
 #include "PolyQuaternionCurve.h"
 #include "PolyQuaternionCurve.h"
 #include "PolyRectangle.h"
 #include "PolyRectangle.h"
 #include "PolyRenderer.h"
 #include "PolyRenderer.h"
+#include "PolyRenderDataArray.h"
 #include "PolyCoreServices.h"
 #include "PolyCoreServices.h"
 #include "PolyImage.h"
 #include "PolyImage.h"
 #include "PolyLabel.h"
 #include "PolyLabel.h"

+ 0 - 88
Core/Contents/Include/PolyiPhoneCore.h

@@ -1,88 +0,0 @@
-/*
-Copyright (C) 2011 by Ivan Safrin
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in
-all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
-THE SOFTWARE.
-*/
-
-#pragma once
-#include "PolyString.h"
-#include "PolyGlobals.h"
-#include "PolyCore.h"
-#include "PolyRectangle.h"
-#include <vector>
-
-using std::vector;
-
-namespace Polycode {
-	
-	class _PolyExport PosixMutex : public CoreMutex {
-	public:
-		pthread_mutex_t pMutex;
-	};
-	
-	class iPhoneEvent {
-	public:
-		int eventGroup;
-		int eventCode;
-		
-		int mouseX;
-		int mouseY;
-		
-		PolyKEY keyCode;
-		wchar_t unicodeChar;
-		
-		char mouseButton;
-		
-		static const int EVENTBASE_PLATFORMEVENT = 0x300;
-		static const int INPUT_EVENT = EVENTBASE_PLATFORMEVENT+0;
-	};
-	
-	class _PolyExport IPhoneCore : public Core {
-		
-	public:
-		
-		IPhoneCore(int frameRate);
-		virtual ~IPhoneCore();
-		
-		void enableMouse(bool newval);
-		unsigned int getTicks();		
-		bool Update();		
-		void setVideoMode(int xRes, int yRes, bool fullScreen, int aaLevel);		
-		void createThread(Threaded *target);				
-		
-		void lockMutex(CoreMutex *mutex);
-		void unlockMutex(CoreMutex *mutex);
-		CoreMutex *createMutex();		
-		
-		void checkEvents();
-		
-		vector<Rectangle> getVideoModes();
-		
-		int lastMouseY;
-		int lastMouseX;		
-		
-		CoreMutex *eventMutex;
-		
-		vector<iPhoneEvent> osxEvents;
-		
-	private:
-		
-		
-	};
-}

+ 35 - 1
Core/Contents/Source/PolyBezierCurve.cpp

@@ -24,6 +24,8 @@
 
 
 using namespace Polycode;
 using namespace Polycode;
 
 
+bool BezierCurve::cacheHeightValues = false;
+unsigned int BezierCurve::defaultHeightCacheResolution = 512;
 
 
 BezierPoint::BezierPoint(Number p1x, Number p1y, Number p1z, Number p2x, Number p2y, Number p2z, Number p3x, Number p3y, Number p3z) {
 BezierPoint::BezierPoint(Number p1x, Number p1y, Number p1z, Number p2x, Number p2y, Number p2z, Number p3x, Number p3y, Number p3z) {
 	p1.x = p1x;
 	p1.x = p1x;
@@ -41,6 +43,7 @@ BezierCurve::BezierCurve(){
 	insertPoint = NULL;
 	insertPoint = NULL;
 	evaluationAccuracy = 0.01;
 	evaluationAccuracy = 0.01;
     distancesDirty =  false;
     distancesDirty =  false;
+    heightCacheResolution = defaultHeightCacheResolution;
 }
 }
 
 
 void BezierCurve::clearControlPoints() {
 void BezierCurve::clearControlPoints() {
@@ -125,7 +128,22 @@ void BezierCurve::recalculateDistances() {
     minX = getPointAt(0.0).x;
     minX = getPointAt(0.0).x;
     maxX = getPointAt(1.0).x;
     maxX = getPointAt(1.0).x;
     midX = getPointAt(0.5).x;
     midX = getPointAt(0.5).x;
+
+    if(cacheHeightValues) {
+        rebuildHeightCache();
+    }
+}
+
+void BezierCurve::rebuildHeightCache() {
+    heightCache.clear();
+    
+    Number xSize = maxX - minX;
     
     
+    for(int i=0; i < heightCacheResolution; i++) {
+        Number xVal = minX + (xSize * ((Number)i)/((Number)heightCacheResolution));
+        Number heightValue = getPointAt(getTValueAtX(xVal)).y;
+        heightCache.push_back(heightValue);
+    }
 }
 }
 
 
 Vector3 BezierCurve::getPointBetween(Number a, BezierPoint *bp1, BezierPoint *bp2) {
 Vector3 BezierCurve::getPointBetween(Number a, BezierPoint *bp1, BezierPoint *bp2) {
@@ -140,7 +158,23 @@ Vector3 BezierCurve::getPointBetween(Number a, BezierPoint *bp1, BezierPoint *bp
 }
 }
 
 
 Number BezierCurve::getYValueAtX(Number x) {
 Number BezierCurve::getYValueAtX(Number x) {
-    return getPointAt(getTValueAtX(x)).y;
+    if(cacheHeightValues) {
+        if(distancesDirty) {
+            recalculateDistances();
+        }
+        unsigned int cacheIndex = (x-minX/(maxX-minX)) * ((Number) heightCacheResolution);
+        if(cacheIndex > heightCacheResolution-1) {
+            cacheIndex = heightCacheResolution-1;
+        }
+        return heightCache[cacheIndex];
+    } else {
+        return getPointAt(getTValueAtX(x)).y;
+    }
+}
+
+void BezierCurve::setHeightCacheResolution(Number resolution) {
+    heightCacheResolution = resolution;
+    distancesDirty = true;
 }
 }
 
 
 Number BezierCurve::getTValueAtX(Number x) {
 Number BezierCurve::getTValueAtX(Number x) {

+ 2 - 1
Core/Contents/Source/PolyFontGlyphSheet.cpp

@@ -273,6 +273,7 @@ void FontGlyphSheet::buildGlyphs(std::set<wchar_t> characters) {
 	for (glyph_list_t::iterator it = glyphData.begin(); it != glyphData.end(); it++) delete *it;
 	for (glyph_list_t::iterator it = glyphData.begin(); it != glyphData.end(); it++) delete *it;
 }
 }
 
 
+/*
 int FontGlyphSheet::renderStringVertices(String textIn, std::vector<Vertex*>& vertices, int index) {
 int FontGlyphSheet::renderStringVertices(String textIn, std::vector<Vertex*>& vertices, int index) {
 	textIn.getWDataWithEncoding(String::ENCODING_UTF8);
 	textIn.getWDataWithEncoding(String::ENCODING_UTF8);
 	std::wstring& text = textIn.w_contents;
 	std::wstring& text = textIn.w_contents;
@@ -322,5 +323,5 @@ int FontGlyphSheet::renderStringVertices(String textIn, std::vector<Vertex*>& ve
 	return index;
 	return index;
 }
 }
 
 
-
+*/
 
 

+ 0 - 719
Core/Contents/Source/PolyGLES1Renderer.cpp

@@ -1,719 +0,0 @@
-/*
- Copyright (C) 2011 by Ivan Safrin
- 
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- 
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
- 
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
-*/
-
-#include "PolyGLES1Renderer.h"
-
-using namespace Polycode;
-
-OpenGLES1Renderer::OpenGLES1Renderer() : Renderer() {	
-	nearPlane = 0.1f;
-	farPlane = 1000.0f;
-	
-	glGenFramebuffersOES(1, &defaultFramebuffer);
-	glGenRenderbuffersOES(1, &colorRenderbuffer);
-	glBindFramebufferOES(GL_FRAMEBUFFER_OES, defaultFramebuffer);
-	glBindRenderbufferOES(GL_RENDERBUFFER_OES, colorRenderbuffer);
-	glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, colorRenderbuffer);
-	
-}
-
-void OpenGLES1Renderer::Resize(int xRes, int yRes) {
-
-	this->xRes = xRes;
-	this->yRes = yRes;
-	glClearColor(clearColor.r, clearColor.g, clearColor.b, clearColor.a);
-	glClearDepthf(1.0f);
-	
-    glMatrixMode(GL_PROJECTION);
-    glLoadIdentity();
-	gluPerspective(fov,(GLfloat)xRes/(GLfloat)yRes,nearPlane,farPlane);
-	glViewport(0, 0, xRes, yRes);
-	setScissorBox(0, 0, xRex, yRes);
-	
-	glMatrixMode(GL_MODELVIEW);
-	glLineWidth(1);
-	glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-	
-	glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
-	glEnable(GL_BLEND);
-	glShadeModel(GL_SMOOTH);
-	glDepthFunc( GL_LEQUAL );
-	
-	glEnable(GL_DEPTH_TEST);
-	
-	glLineWidth(1.0f);	
-	glEnable(GL_LINE_SMOOTH);
-	
-	GLint numBuffers = 0;
-//	glGetIntegerv(GL_MAX_DRAW_BUFFERS, &numBuffers);	
-}
-
-void OpenGLES1Renderer::enableAlphaTest(bool val) {
-	if(val) {
-		glAlphaFunc ( GL_GREATER, 0.01) ;
-		glEnable ( GL_ALPHA_TEST ) ;		
-	} else {
-		glDisable( GL_ALPHA_TEST ) ;
-	}
-}
-
-void OpenGLES1Renderer::setLineSmooth(bool val) {
-	if(val)
-		glEnable(GL_LINE_SMOOTH);
-	else
-		glDisable(GL_LINE_SMOOTH);
-}
-
-void OpenGLES1Renderer::setFOV(Number fov) {
-	this->fov = fov;
-	glMatrixMode(GL_PROJECTION);
-	glLoadIdentity();
-	gluPerspective(fov,(GLfloat)xRes/(GLfloat)yRes,nearPlane,farPlane);	
-	glViewport(0, 0, xRes, yRes);
-	glScissor(0, 0, xRes, yRes);
-	glMatrixMode(GL_MODELVIEW);	
-}
-
-void OpenGLES1Renderer::setViewportSize(int w, int h, Number fov) {
-	glMatrixMode(GL_PROJECTION);
-	glLoadIdentity();
-	gluPerspective(fov,(GLfloat)w/(GLfloat)h,nearPlane,farPlane);
-	glViewport(0, 0, w, h);
-	glScissor(0, 0, w, h);
-	glMatrixMode(GL_MODELVIEW);
-}
-
-Vector3 OpenGLES1Renderer::Unproject(Number x, Number y) {
-	Vector3 coords;
-	GLfloat wx, wy, wz;
-	GLfloat cx, cy, cz;
-	
-	GLfloat mv[16];
-	glGetFloatv( GL_MODELVIEW_MATRIX, mv );
-	
-	GLfloat proj[16];
-	glGetFloatv( GL_PROJECTION_MATRIX, proj );
-	
-	GLint vp[4];
-	glGetIntegerv( GL_VIEWPORT, vp );
-	
-	wx = ( Number ) x;
-	wy = ( Number ) vp[3] - ( Number ) y;
-	glReadPixels( x, wy, 1, 1, GL_DEPTH_COMPONENT16_OES, GL_FLOAT, &wz );
-	
-	gluUnProject((GLdouble)wx, (GLdouble)wy, (GLdouble)wz, (GLdouble*)mv, (GLdouble*)proj, vp, (GLdouble*)&cx, (GLdouble*)&cy, (GLdouble*)&cz );
-	
-	coords = Vector3( cx, cy, cz );
-	
-	return coords;
-	
-}
-
-bool OpenGLES1Renderer::test2DCoordinate(Number x, Number y, Poly::Polygon *poly, const Matrix4 &matrix, bool billboardMode) {
-	GLfloat nearPlane[3],farPlane[3];
-	
-	GLfloat mv[16];
-	Matrix4 camInverse = cameraMatrix.Inverse();	
-	Matrix4 cmv;
-	cmv.identity();
-	cmv = cmv * camInverse;
-	
-	for(int i=0; i < 16; i++) {
-		mv[i] = cmv.ml[i];
-	}
-	
-	GLint vp[4];
-	glGetIntegerv( GL_VIEWPORT, vp );
-	
-	gluUnProject((GLdouble)x, (GLdouble)yRes - y, 0.0, (GLdouble*)mv, (GLdouble*)sceneProjectionMatrix, vp, (GLdouble*)&nearPlane[0], (GLdouble*)&nearPlane[1], (GLdouble*)&nearPlane[2]);
-	gluUnProject((GLdouble)x, (GLdouble)yRes - y, 1.0, (GLdouble*)mv, (GLdouble*)sceneProjectionMatrix, vp,  (GLdouble*)&farPlane[0], (GLdouble*)&farPlane[1], (GLdouble*)&farPlane[2]);
-	
-	Vector3 nearVec(nearPlane[0], nearPlane[1], nearPlane[2]);
-	Vector3 farVec(farPlane[0], farPlane[1], farPlane[2]);
-	
-	Vector3 dirVec = farVec - nearVec;	
-	dirVec.Normalize();
-	
-	Vector3 hitPoint;
-	
-	Matrix4 fullMatrix = matrix;
-	
-	if(poly->getVertexCount() == 3) {
-		return rayTriangleIntersect(Vector3(0,0,0), dirVec, fullMatrix * (*poly->getVertex(0)), fullMatrix  * (*poly->getVertex(1)), fullMatrix *  (*poly->getVertex(2)), &hitPoint);
-	} else if(poly->getVertexCount() == 4) {
-		return (rayTriangleIntersect(Vector3(0,0,0), dirVec, fullMatrix * (*poly->getVertex(2)), fullMatrix  * (*poly->getVertex(1)), fullMatrix *  (*poly->getVertex(0)), &hitPoint) ||
-				rayTriangleIntersect(Vector3(0,0,0), dirVec, fullMatrix * (*poly->getVertex(0)), fullMatrix  * (*poly->getVertex(3)), fullMatrix *  (*poly->getVertex(2)), &hitPoint));
-	} else {
-		return false;
-	}
-}
-
-void OpenGLES1Renderer::enableDepthTest(bool val) {
-	//	if(val)
-	//		glEnable(GL_DEPTH_TEST);
-	//	else
-	//		glDisable(GL_DEPTH_TEST);
-	if(val)
-		glDepthMask(GL_TRUE);
-	else
-		glDepthMask(GL_FALSE);
-	
-}
-
-void OpenGLES1Renderer::setModelviewMatrix(Matrix4 m) {
-	glLoadMatrixf(m.ml);
-}
-
-void OpenGLES1Renderer::multModelviewMatrix(Matrix4 m) {
-	//	glMatrixMode(GL_MODELVIEW);
-	glMultMatrixf(m.ml);
-}
-
-void OpenGLES1Renderer::enableLighting(bool enable) {
-	lightingEnabled = enable;
-}
-
-void OpenGLES1Renderer::setLineSize(Number lineSize) {
-	glLineWidth(lineSize);
-}
-
-void OpenGLES1Renderer::createVertexBufferForMesh(Mesh *mesh) {
-//	OpenGLVertexBuffer *buffer = new OpenGLVertexBuffer(mesh);
-//	mesh->setVertexBuffer(buffer);
-}
-
-void OpenGLES1Renderer::drawVertexBuffer(VertexBuffer *buffer) {
-	/*
-	OpenGLVertexBuffer *glVertexBuffer = (OpenGLVertexBuffer*)buffer;
-	
-	glEnableClientState(GL_VERTEX_ARRAY);		
-	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
-	glEnableClientState(GL_NORMAL_ARRAY);	
-	//	glEnableClientState(GL_COLOR_ARRAY);		
-	
-	//	glBindBufferARB( GL_ARRAY_BUFFER_ARB, glVertexBuffer->getColorBufferID());
-	//	glTexCoordPointer( 4, GL_FLOAT, 0, (char *) NULL );	
-	glBindBufferARB( GL_ARRAY_BUFFER_ARB, glVertexBuffer->getVertexBufferID());
-	glVertexPointer( 3, GL_FLOAT, 0, (char *) NULL );	
-	glBindBufferARB( GL_ARRAY_BUFFER_ARB, glVertexBuffer->getNormalBufferID());
-	glNormalPointer(GL_FLOAT, 0, (char *) NULL );			
-	glBindBufferARB( GL_ARRAY_BUFFER_ARB, glVertexBuffer->getTextCoordBufferID());
-	glTexCoordPointer( 2, GL_FLOAT, 0, (char *) NULL );
-	
-	glDrawArrays( GL_TRIANGLES, 0, buffer->getVertexCount() );
-	
-	glDisableClientState( GL_VERTEX_ARRAY);	
-	glDisableClientState( GL_TEXTURE_COORD_ARRAY );		
-	glDisableClientState( GL_NORMAL_ARRAY );
-	//	glDisableClientState( GL_COLOR_ARRAY );	
-	 */
-}
-
-void OpenGLES1Renderer::enableFog(bool enable) {
-	if(enable)
-		glEnable(GL_FOG);
-	else {
-		glDisable(GL_FOG);
-		glClearColor(clearColor.r, clearColor.g, clearColor.b, clearColor.a);
-	}
-}
-
-void OpenGLES1Renderer::setBlendingMode(int blendingMode) {
-	switch(blendingMode) {
-		case BLEND_MODE_NORMAL:
-			glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-			break;
-		case BLEND_MODE_LIGHTEN:
-			glBlendFunc (GL_SRC_ALPHA, GL_ONE);
-			break;
-		case BLEND_MODE_COLOR:
-			glBlendFunc (GL_DST_COLOR, GL_ONE);
-			break;
-		default:
-			glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
-			break;
-	}
-	glEnable(GL_BLEND);
-}
-
-Matrix4 OpenGLES1Renderer::getProjectionMatrix() {
-	Number m[16];
-	glGetFloatv( GL_PROJECTION_MATRIX, m);
-	return Matrix4(m);
-}
-
-Matrix4 OpenGLES1Renderer::getModelviewMatrix() {
-	Number m[16];
-    glGetFloatv( GL_MODELVIEW_MATRIX, m);
-	return Matrix4(m);
-}
-
-void OpenGLES1Renderer::renderZBufferToTexture(Texture *targetTexture) {
-	//	OpenGLES1Texture *glTexture = (OpenGLES1Texture*)targetTexture;
-	//	glBindTexture (GL_TEXTURE_2D, glTexture->getTextureID());
-	//	glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, 0, 0, targetTexture->getWidth(), targetTexture->getHeight(), 0);	
-}
-
-void OpenGLES1Renderer::renderToTexture(Texture *targetTexture) {
-	OpenGLES1Texture *glTexture = (OpenGLES1Texture*)targetTexture;
-	glBindTexture (GL_TEXTURE_2D, glTexture->getTextureID());
-	glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 0, 0, targetTexture->getWidth(), targetTexture->getHeight(), 0);	
-	
-}
-
-void OpenGLES1Renderer::setFogProperties(int fogMode, Color color, Number density, Number startDepth, Number endDepth) {
-	switch(fogMode) {
-		case FOG_LINEAR:
-			glFogx(GL_FOG_MODE, GL_LINEAR);
-			break;
-		case FOG_EXP:
-			glFogx(GL_FOG_MODE, GL_EXP);
-			break;
-		case FOG_EXP2:
-			glFogx(GL_FOG_MODE, GL_EXP2);
-			break;
-		default:
-			glFogx(GL_FOG_MODE, GL_LINEAR);
-			break;
-	}
-	
-	GLfloat fogColor[4]= {color.r, color.g, color.b, color.a};
-	glFogfv(GL_FOG_COLOR, fogColor);
-	glFogf(GL_FOG_DENSITY, density);
-	glHint(GL_FOG_HINT, GL_DONT_CARE);
-	glFogf(GL_FOG_START, startDepth);
-	glFogf(GL_FOG_END, endDepth);
-	glClearColor(color.r, color.g, color.b, color.a);
-}
-
-void OpenGLES1Renderer::setOrthoMode() {
-	setBlendingMode(BLEND_MODE_NORMAL);
-	if(!orthoMode) {
-		glDisable(GL_LIGHTING);
-		glMatrixMode(GL_PROJECTION);
-		glDisable(GL_CULL_FACE);
-		glPushMatrix();
-		glLoadIdentity();
-		glOrthox(0.0f,xRes,yRes,0,-1.0f,1.0f);
-		//		glOrtho(0.0f,2500.0f,2500.0f,0,-1.0f,1.0f);
-		orthoMode = true;
-	}
-	glMatrixMode(GL_MODELVIEW);	
-	glLoadIdentity();
-}
-
-void OpenGLES1Renderer::enableBackfaceCulling(bool val) {
-	if(val)
-		glEnable(GL_CULL_FACE);
-	else
-		glDisable(GL_CULL_FACE);
-}
-
-void OpenGLES1Renderer::setPerspectiveMode() {
-	setBlendingMode(BLEND_MODE_NORMAL);
-	if(orthoMode) {
-		if(lightingEnabled) {
-		}
-		glEnable (GL_DEPTH_TEST);
-		glEnable(GL_CULL_FACE);
-		glMatrixMode( GL_PROJECTION );
-		glPopMatrix();
-		glMatrixMode( GL_MODELVIEW );
-		orthoMode = false;
-	}
-	glLoadIdentity();
-	
-	glGetFloatv( GL_PROJECTION_MATRIX, sceneProjectionMatrix);
-	currentTexture = NULL;
-}
-
-void OpenGLES1Renderer::BeginRender() {
-	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-	glLoadIdentity();
-	currentTexture = NULL;
-}
-
-void OpenGLES1Renderer::setClearColor(Number r, Number g, Number b) {
-	clearColor.setColor(r,g,b,1.0f);
-	glClearColor(r,g,b,0.0f);
-}
-
-void OpenGLES1Renderer::translate3D(Vector3 *position) {
-	glTranslatef(position->x, position->y, position->z);
-}
-
-void OpenGLES1Renderer::translate3D(Number x, Number y, Number z) {
-	glTranslatef(x, y, z);
-}
-
-void OpenGLES1Renderer::scale3D(Vector3 *scale) {
-	glScalef(scale->x, scale->y, scale->z);
-}
-
-void OpenGLES1Renderer::bindFrameBufferTexture(Texture *texture) {
-	/*
-	if(currentFrameBufferTexture) {
-		previousFrameBufferTexture = currentFrameBufferTexture;
-	}
-	OpenGLES1Texture *glTexture = (OpenGLES1Texture*)texture;
-	
-	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, glTexture->getFrameBufferID());
-	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-	
-	currentFrameBufferTexture = texture;
-	 */
-}
-
-void OpenGLES1Renderer::unbindFramebuffers() {
-	/*
-	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);	
-	currentFrameBufferTexture = NULL;
-	if(previousFrameBufferTexture) {
-		bindFrameBufferTexture(previousFrameBufferTexture);
-		previousFrameBufferTexture = NULL;
-	}
-	 */
-}
-
-
-void OpenGLES1Renderer::createRenderTextures(Texture **colorBuffer, Texture **depthBuffer, int width, int height) {
-	/*
-	Logger::log("generating fbo textures %d %d\n", colorBuffer, depthBuffer);	
-	
-	GLuint depthTexture,colorTexture;
-	GLenum status;
-	GLuint frameBufferID;
-	
-	glGenFramebuffersEXT(1, &frameBufferID);   
-	
-	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frameBufferID);     	
-	glGenTextures(1,&colorTexture);
-	glBindTexture(GL_TEXTURE_2D,colorTexture);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-	glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-	glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);	
-	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
-	
-	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, colorTexture, 0);
-	
-	status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
-	if(status == GL_FRAMEBUFFER_COMPLETE_EXT) {
-		Logger::log("color fbo generation successful\n");
-	} else {
-		Logger::log("color fbo generation failed\n");	
-	}
-	
-	if(colorBuffer) {
-		OpenGLES1Texture *colorBufferTexture = new OpenGLES1Texture(width, height);
-		colorBufferTexture->setGLInfo(colorTexture, frameBufferID);
-		*colorBuffer = ((Texture*)colorBufferTexture);
-	}
-	
-	if(depthBuffer) {
-		glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, frameBufferID);     
-		glGenTextures(1,&depthTexture);
-		glBindTexture(GL_TEXTURE_2D,depthTexture);
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-		glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
-		glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
-		
-		//	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE,GL_COMPARE_R_TO_TEXTURE);
-		//	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);	
-		glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE);	
-		
-		glTexImage2D(GL_TEXTURE_2D,0,GL_DEPTH_COMPONENT,width,height,0,GL_DEPTH_COMPONENT,GL_UNSIGNED_BYTE,0);
-		
-		glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, depthTexture, 0);
-		
-		status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
-		
-		if(status == GL_FRAMEBUFFER_COMPLETE_EXT) {
-			Logger::log("depth fbo generation successful\n");
-		} else {
-			Logger::log("depth fbo generation failed\n");	
-		}
-		
-		OpenGLES1Texture *depthBufferTexture = new OpenGLES1Texture(width, height);
-		depthBufferTexture->setGLInfo(depthTexture, frameBufferID);	
-		*depthBuffer = ((Texture*)depthBufferTexture);		
-	}
-	
-    glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
-*/
-}
-
-Texture *OpenGLES1Renderer::createFramebufferTexture(unsigned int width, unsigned int height) {
-	OpenGLES1Texture *newTexture = new OpenGLES1Texture(width, height);	
-	return newTexture;
-}
-
-Cubemap *OpenGLES1Renderer::createCubemap(Texture *t0, Texture *t1, Texture *t2, Texture *t3, Texture *t4, Texture *t5) {
-//	OpenGLCubemap *newCubemap = new OpenGLCubemap(t0,t1,t2,t3,t4,t5);
-//	return newCubemap;
-	return NULL;
-}
-
-Texture *OpenGLES1Renderer::createTexture(unsigned int width, unsigned int height, char *textureData, bool clamp, int type) {
-	OpenGLES1Texture *newTexture = new OpenGLES1Texture(width, height, textureData, clamp, textureFilteringMode);	
-	return newTexture;
-}
-
-void OpenGLES1Renderer::clearScreen(bool clearColor, bool clearDepth) {
-	GLbitfield mask = 0;
-	if (clearColor) {
-		mask |= GL_COLOR_BUFFER_BIT;
-	}
-	if (clearDepth) {
-		mask |= GL_DEPTH_BUFFER_BIT;
-	}
-	if (mask) {
-		glClear(mask);
-	}
-}
-
-void OpenGLES1Renderer::applyMaterial(Material *material,  ShaderBinding *localOptions,unsigned int shaderIndex) {
-	if(!material->getShader(shaderIndex) || !shadersEnabled) {
-		setTexture(NULL);
-		return;
-	}
-	
-	FixedShaderBinding *fBinding;
-	
-	switch(material->getShader(shaderIndex)->getType()) {
-		case Shader::FIXED_SHADER:
-			//			FixedShader *fShader = (FixedShader*)material->getShader();
-			fBinding = (FixedShaderBinding*)material->getShaderBinding(shaderIndex);
-			setTexture(fBinding->getDiffuseTexture());
-			//			setTexture(fShader->getDiffuseTexture());
-			break;
-		case Shader::CG_SHADER:		
-			break;
-	}
-}
-
-void OpenGLES1Renderer::clearShader() {
-	currentMaterial = NULL;
-}
-
-void OpenGLES1Renderer::setTexture(Texture *texture) {
-	if(texture == NULL) {
-		glDisable(GL_TEXTURE_2D);
-		return;
-	}
-	
-	if(renderMode == RENDER_MODE_NORMAL) {
-		glEnable (GL_TEXTURE_2D);
-		if(currentTexture != texture) {			
-			OpenGLES1Texture *glTexture = (OpenGLES1Texture*)texture;
-			glBindTexture (GL_TEXTURE_2D, glTexture->getTextureID());
-		}
-	} else {
-		glDisable(GL_TEXTURE_2D);
-	}
-	
-	currentTexture = texture;
-}
-
-void OpenGLES1Renderer::beginRenderOperation(int meshType) {
-	/*
-	switch(meshType) {
-		case Mesh::TRI_MESH:
-			switch(renderMode) {
-				case RENDER_MODE_NORMAL:
-					Begin(GL_TRIANGLES);
-					break;
-				case RENDER_MODE_WIREFRAME:
-					glBegin(GL_LINE_LOOP);
-					break;
-			}
-			break;
-		case Mesh::TRIFAN_MESH:
-			switch(renderMode) {
-				case RENDER_MODE_NORMAL:
-					glBegin(GL_TRIANGLE_FAN);
-					break;
-				case RENDER_MODE_WIREFRAME:
-					glBegin(GL_LINE_LOOP);
-					break;
-			}
-			break;
-		case Mesh::QUAD_MESH:
-			switch(renderMode) {
-				case RENDER_MODE_NORMAL:
-					glBegin(GL_QUADS);
-					break;
-				case RENDER_MODE_WIREFRAME:
-					glBegin(GL_LINE_LOOP);
-					break;
-			}
-			break;
-		case Mesh::LINE_MESH:
-			glBegin(GL_LINES);
-			break;			
-	}
-	 */
-}
-
-void OpenGLES1Renderer::pushMatrix() {
-	glPushMatrix();
-}
-
-void OpenGLES1Renderer::popMatrix() {
-	glPopMatrix();
-}
-
-
-void OpenGLES1Renderer::endRenderOperation() {
-//	glEnd();
-}
-
-void OpenGLES1Renderer::draw3DPolygon(Poly::Polygon *polygon) {
-	unsigned int vCount = polygon->getVertexCount();
-	for(int i=0; i < vCount; i++) {
-		if(polygon->usesFaceUV())
-			draw3DVertex(polygon->getVertex(i), polygon->getTexCoord(i));			
-		else
-			draw3DVertex(polygon->getVertex(i), NULL);
-	}
-}
-
-void OpenGLES1Renderer::draw3DVertex2UV(Vertex *vertex, Vector2 *faceUV1, Vector2 *faceUV2) {
-	/*
-	if(vertex->useVertexColor)
-		glColor4f(vertex->vertexColor.r, vertex->vertexColor.g, vertex->vertexColor.b, vertex->vertexColor.a);
-	
-	if(currentTexture || currentMaterial) {
-		glMultiTexCoord4x(GL_TEXTURE0, faceUV1->x, faceUV1->y,0,0);
-		glMultiTexCoord4x(GL_TEXTURE1, faceUV2->x, faceUV2->y,0,0);
-	}
-	
-	//	glNormal3f(vertex->normal->x, vertex->normal->y, vertex->normal->z);
-	glVertex3f(vertex->x, vertex->y, vertex->z);
-	 */
-}
-
-void OpenGLES1Renderer::setNormal(const Vector3 &normal) {
-	glNormal3f(normal.x, normal.y, normal.z);	
-}
-
-void OpenGLES1Renderer::draw3DVertex(Vertex *vertex, Vector2 *faceUV) {
-	/*
-	if(vertex->useVertexColor)
-		glColor4f(vertex->vertexColor.r, vertex->vertexColor.g, vertex->vertexColor.b, vertex->vertexColor.a);
-	
-	if(currentTexture || currentMaterial) {
-		if(faceUV != NULL)
-			glTexCoord2f(faceUV->x, faceUV->y);
-		else
-			glTexCoord2f(vertex->getTexCoord()->x, vertex->getTexCoord()->y);
-	}
-	
-	//	glNormal3f(vertex->normal->x, vertex->normal->y, vertex->normal->z);
-	glVertex3f(vertex->x, vertex->y, vertex->z);
-	 */
-}
-
-void OpenGLES1Renderer::drawScreenQuad(Number qx, Number qy) {
-	/*
-	setOrthoMode();
-	
-	Number xscale = qx/((Number)getXRes()) * 2.0f;
-	Number yscale = qy/((Number)getYRes()) * 2.0f;
-	
-	glBegin(GL_QUADS);
-	glColor4f(1.0f,1.0f,1.0f,1.0f);
-	
-	glTexCoord2f(0.0f, 1.0f);
-	glVertex2f(-1, -1+(1.0f*yscale));
-	
-	glTexCoord2f(0.0f, 0.0f);
-	glVertex2f(-1.0f, -1.0f);
-	
-	glTexCoord2f(1.0f, 0.0f);
-	glVertex2f(-1+(1.0f*xscale), -1.0f);
-	
-	glTexCoord2f(1.0f, 1.0f);
-	glVertex2f(-1+(1.0f*xscale), -1+(1.0f*yscale));
-	glEnd();
-	setPerspectiveMode();
-	 */
-}
-
-void OpenGLES1Renderer::draw2DVertex(Vertex *vertex) {
-	/*
-	//	glColor4f(0,0,0,0);
-	if(vertex->useVertexColor)
-		glColor4f(vertex->vertexColor.r, vertex->vertexColor.g, vertex->vertexColor.b, vertex->vertexColor.a);
-	if(currentTexture)
-		glTexCoord2f(vertex->getTexCoord()->x+currentTexture->getScrollOffsetX(), vertex->getTexCoord()->y+currentTexture->getScrollOffsetY());
-	glVertex2f(vertex->x, vertex->y);
-	 */
-}
-
-void OpenGLES1Renderer::draw3DLine(Vector3 origin, Vector3 direction, Number length, Color color)  {
-	/*
-	glColor4f(color.r,color.g,color.b,color.a);	
-	//	glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
-	glVertex3f(origin.x, origin.y, origin.z);
-	
-	Vector3 lineEnd = origin + (direction * length);
-	glVertex3f(lineEnd.x, lineEnd.y, lineEnd.z);
-	 */
-}
-
-void OpenGLES1Renderer::translate2D(Number x, Number y) {
-	glTranslatef(x, y, 0.0f);
-}
-
-void OpenGLES1Renderer::scale2D(Vector2 *scale) {
-	glScalef(scale->x, scale->y, 1.0f);
-}
-
-void OpenGLES1Renderer::loadIdentity() {
-	setBlendingMode(BLEND_MODE_NORMAL);
-	glMatrixMode(GL_MODELVIEW);
-	glLoadIdentity();
-}
-
-void OpenGLES1Renderer::rotate2D(Number angle) {
-	glRotatef(angle, 0.0f, 0.0f, 1.0f);
-}
-
-void OpenGLES1Renderer::setVertexColor(Number r, Number g, Number b, Number a) {
-	glColor4f(r,g,b,a);
-}
-
-void OpenGLES1Renderer::draw2DPolygon(Poly::Polygon *polygon) {
-	unsigned int vCount = polygon->getVertexCount();
-	for(int i=0; i < vCount; i++) {
-		draw2DVertex(polygon->getVertex(i));
-	}
-}
-
-void OpenGLES1Renderer::EndRender() {
-}
-
-OpenGLES1Renderer::~OpenGLES1Renderer() {
-	
-}

+ 0 - 86
Core/Contents/Source/PolyGLES1Texture.cpp

@@ -1,86 +0,0 @@
-/*
- Copyright (C) 2011 by Ivan Safrin
- 
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- 
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
- 
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
-*/
-
-#include "PolyGLES1Texture.h"
-
-using namespace Polycode;
-
-OpenGLES1Texture::OpenGLES1Texture(unsigned int width, unsigned int height, char *textureData, bool clamp, int filteringMode) : Texture(width, height, textureData,clamp) {
-	this->filteringMode = filteringMode;
-	recreateFromImageData();
-}
-
-void OpenGLES1Texture::recreateFromImageData() {
-	glGenTextures(1, &textureID);
-	glBindTexture(GL_TEXTURE_2D, textureID);
-	if(clamp) {
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-	} else {
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
-		glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);	
-	}
-	switch(filteringMode) {
-		case Renderer::TEX_FILTERING_LINEAR:
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
-			break;
-		case Renderer::TEX_FILTERING_NEAREST:
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);		
-			break;
-	}	
-	
-	if(textureData)
-		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, textureData);	
-}
-
-OpenGLES1Texture::OpenGLES1Texture(unsigned int width, unsigned int height) : Texture(width, height, NULL ,true) {
-	
-}
-
-void OpenGLES1Texture::setGLInfo(GLuint textureID, GLuint frameBufferID) {
-	this->textureID = textureID;
-	this->frameBufferID = frameBufferID;
-}
-
-void OpenGLES1Texture::setTextureData(char *data) {
-	/*
-	glBindTexture(GL_TEXTURE_2D, textureID);
-	glDrawBuffer(GL_AUX0);
-	glDrawPixels(width, height, GL_RGBA, GL_UNSIGNED_BYTE, data);
-	glReadBuffer(GL_AUX0);
-	//	glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, 128, 128, 0);
-	 */
-}
-
-OpenGLES1Texture::~OpenGLES1Texture() {
-	glDeleteTextures(1, &textureID);
-}
-
-GLuint OpenGLES1Texture::getFrameBufferID() {
-	return frameBufferID;
-}
-
-GLuint OpenGLES1Texture::getTextureID() {
-	return textureID;
-}

+ 67 - 231
Core/Contents/Source/PolyGLRenderer.cpp

@@ -392,26 +392,33 @@ void OpenGLRenderer::drawVertexBuffer(VertexBuffer *buffer, bool enableColorBuff
 	OpenGLVertexBuffer *glVertexBuffer = (OpenGLVertexBuffer*)buffer;
 	OpenGLVertexBuffer *glVertexBuffer = (OpenGLVertexBuffer*)buffer;
 
 
 	glEnableClientState(GL_VERTEX_ARRAY);		
 	glEnableClientState(GL_VERTEX_ARRAY);		
-	glEnableClientState(GL_TEXTURE_COORD_ARRAY);
-	glEnableClientState(GL_NORMAL_ARRAY);	
-	
-	if(enableColorBuffer)  {
-		glEnableClientState(GL_COLOR_ARRAY);				
-		
+    glBindBufferARB( GL_ARRAY_BUFFER_ARB, glVertexBuffer->getVertexBufferID());
+	glVertexPointer( 3, GL_FLOAT, 0, (char *) NULL );
+
+	if(enableColorBuffer && glVertexBuffer->getColorBufferID() != -1)  {
+		glEnableClientState(GL_COLOR_ARRAY);
 		glBindBufferARB( GL_ARRAY_BUFFER_ARB, glVertexBuffer->getColorBufferID());
 		glBindBufferARB( GL_ARRAY_BUFFER_ARB, glVertexBuffer->getColorBufferID());
 		glColorPointer( 4, GL_FLOAT, 0, (char *) NULL );	
 		glColorPointer( 4, GL_FLOAT, 0, (char *) NULL );	
 	}
 	}
-	glBindBufferARB( GL_ARRAY_BUFFER_ARB, glVertexBuffer->getVertexBufferID());
-	glVertexPointer( 3, GL_FLOAT, 0, (char *) NULL );	
-	glBindBufferARB( GL_ARRAY_BUFFER_ARB, glVertexBuffer->getNormalBufferID());
-	glNormalPointer(GL_FLOAT, 0, (char *) NULL );			
-	glBindBufferARB( GL_ARRAY_BUFFER_ARB, glVertexBuffer->getTextCoordBufferID());
-	glTexCoordPointer( 2, GL_FLOAT, 0, (char *) NULL );
-
-	glBindBufferARB( GL_ARRAY_BUFFER_ARB, glVertexBuffer->getTangentBufferID());	
-	glEnableVertexAttribArrayARB(6);	
-	glVertexAttribPointer(6, 3, GL_FLOAT, 0, 0,  (char *)NULL);
-	
+    
+    if(glVertexBuffer->getNormalBufferID() != -1) {
+        glEnableClientState(GL_NORMAL_ARRAY);
+        glBindBufferARB( GL_ARRAY_BUFFER_ARB, glVertexBuffer->getNormalBufferID());
+        glNormalPointer(GL_FLOAT, 0, (char *) NULL );
+    }
+    
+    if(glVertexBuffer->getTextCoordBufferID() != -1) {
+        glEnableClientState(GL_TEXTURE_COORD_ARRAY);
+        glBindBufferARB( GL_ARRAY_BUFFER_ARB, glVertexBuffer->getTextCoordBufferID());
+        glTexCoordPointer( 2, GL_FLOAT, 0, (char *) NULL );
+    }
+    
+    if(glVertexBuffer->getTangentBufferID() != -1) {
+        glBindBufferARB( GL_ARRAY_BUFFER_ARB, glVertexBuffer->getTangentBufferID());
+        glEnableVertexAttribArrayARB(6);	
+        glVertexAttribPointer(6, 3, GL_FLOAT, 0, 0,  (char *)NULL);
+	}
+    
 	GLenum mode = GL_TRIANGLES;
 	GLenum mode = GL_TRIANGLES;
 	
 	
 	switch(buffer->meshType) {
 	switch(buffer->meshType) {
@@ -438,15 +445,19 @@ void OpenGLRenderer::drawVertexBuffer(VertexBuffer *buffer, bool enableColorBuff
 			break;
 			break;
 	}	
 	}	
 	
 	
-	glDrawArrays( mode, 0, buffer->getVertexCount() );
-	
-	glDisableClientState( GL_VERTEX_ARRAY);	
+    if(glVertexBuffer->getIndexBufferID() != -1) {
+        glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, glVertexBuffer->getIndexBufferID());
+        glDrawElements(mode, glVertexBuffer->getIndexCount(), GL_UNSIGNED_INT, (void*)0);
+        glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
+    } else {
+        glDrawArrays( mode, 0, buffer->getVertexCount() );
+	}
+    
+    glDisableVertexAttribArrayARB(6);
+	glDisableClientState( GL_VERTEX_ARRAY);
 	glDisableClientState( GL_TEXTURE_COORD_ARRAY );		
 	glDisableClientState( GL_TEXTURE_COORD_ARRAY );		
 	glDisableClientState( GL_NORMAL_ARRAY );
 	glDisableClientState( GL_NORMAL_ARRAY );
-	
-	if(enableColorBuffer) {
-		glDisableClientState( GL_COLOR_ARRAY );	
-	}
+	glDisableClientState( GL_COLOR_ARRAY );
 }
 }
 
 
 void OpenGLRenderer::enableScissor(bool val) {
 void OpenGLRenderer::enableScissor(bool val) {
@@ -845,231 +856,48 @@ void OpenGLRenderer::popMatrix() {
 }
 }
 
 
 void OpenGLRenderer::pushRenderDataArray(RenderDataArray *array) {
 void OpenGLRenderer::pushRenderDataArray(RenderDataArray *array) {
-		
 	
 	
-	switch(array->arrayType) {
+	switch(array->type) {
 		case RenderDataArray::VERTEX_DATA_ARRAY:
 		case RenderDataArray::VERTEX_DATA_ARRAY:
 			glEnableClientState(GL_VERTEX_ARRAY);
 			glEnableClientState(GL_VERTEX_ARRAY);
 			glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0);
 			glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0);
-			glVertexPointer(array->size, GL_FLOAT, 0, array->arrayPtr);
-			verticesToDraw = array->count;
+			glVertexPointer(3, GL_FLOAT, 0, array->getArrayData());
+			verticesToDraw = array->getDataSize() / 3;
 		break;
 		break;
-		case RenderDataArray::COLOR_DATA_ARRAY:		
-			glColorPointer(array->size, GL_FLOAT, 0, array->arrayPtr);			
+		case RenderDataArray::COLOR_DATA_ARRAY:
+            if(array->getDataSize() != verticesToDraw * 4) {
+                return;
+            }
+			glColorPointer(4, GL_FLOAT, 0, array->getArrayData());
 			glEnableClientState(GL_COLOR_ARRAY);
 			glEnableClientState(GL_COLOR_ARRAY);
 		break;
 		break;
 		case RenderDataArray::TEXCOORD_DATA_ARRAY:
 		case RenderDataArray::TEXCOORD_DATA_ARRAY:
+            if(array->getDataSize() != verticesToDraw * 2) {
+                return;
+            }
 			glEnableClientState(GL_TEXTURE_COORD_ARRAY);						
 			glEnableClientState(GL_TEXTURE_COORD_ARRAY);						
 			glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0);			
 			glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0);			
-			glTexCoordPointer(array->size, GL_FLOAT, 0, array->arrayPtr);
+			glTexCoordPointer(2, GL_FLOAT, 0, array->getArrayData());
 		break;
 		break;
 		case RenderDataArray::NORMAL_DATA_ARRAY:
 		case RenderDataArray::NORMAL_DATA_ARRAY:
+            if(array->getDataSize() != verticesToDraw * 3) {
+                return;
+            }
 			glEnableClientState(GL_NORMAL_ARRAY);	
 			glEnableClientState(GL_NORMAL_ARRAY);	
 			glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0);			
 			glBindBufferARB( GL_ARRAY_BUFFER_ARB, 0);			
-			glNormalPointer(GL_FLOAT, 0, array->arrayPtr);	
+			glNormalPointer(GL_FLOAT, 0, array->getArrayData());
 		break;
 		break;
 		case RenderDataArray::TANGENT_DATA_ARRAY:
 		case RenderDataArray::TANGENT_DATA_ARRAY:
+            if(array->getDataSize() != verticesToDraw * 3) {
+                return;
+            }
 			glEnableVertexAttribArrayARB(6);		
 			glEnableVertexAttribArrayARB(6);		
-			glVertexAttribPointer(6, array->size, GL_FLOAT, 0, 0, array->arrayPtr);
+			glVertexAttribPointer(6, 3, GL_FLOAT, 0, 0, array->getArrayData());
 		break;
 		break;
 		
 		
 	}
 	}
 }
 }
 
 
-RenderDataArray *OpenGLRenderer::createRenderDataArrayForMesh(Mesh *mesh, int arrayType) {
-	RenderDataArray *newArray = createRenderDataArray(arrayType);
-		
-	newArray->count = 0;
-	long bufferOffset = 0;
-	GLfloat* buffer = NULL;
-    
-    Vertex *vertex;
-    if(mesh->indexedMesh) {
-        
-        unsigned int indexCount = mesh->getIndexCount();
-        
-        switch (arrayType) {
-            case RenderDataArray::VERTEX_DATA_ARRAY:
-            {
-                buffer = (GLfloat*)malloc(indexCount * sizeof(GLfloat) * 3);
-                for(int i=0; i < indexCount; i++) {
-                    vertex = mesh->getIndexedVertex(i);
-                    buffer[bufferOffset+0] = vertex->x;
-                    buffer[bufferOffset+1] = vertex->y;
-                    buffer[bufferOffset+2] = vertex->z;
-                    bufferOffset += 3;
-                    newArray->count++;
-                }
-            }
-                break;
-            case RenderDataArray::COLOR_DATA_ARRAY:
-            {
-                buffer = (GLfloat*)malloc(indexCount * sizeof(GLfloat) * 4);
-                for(int i=0; i < indexCount; i++) {
-                    vertex = mesh->getIndexedVertex(i);
-                    buffer[bufferOffset+0] = vertex->vertexColor.r;
-                    buffer[bufferOffset+1] = vertex->vertexColor.g;
-                    buffer[bufferOffset+2] = vertex->vertexColor.b;
-                    buffer[bufferOffset+3] = vertex->vertexColor.a;
-                    bufferOffset += 4;
-                }
-            }
-                break;
-            case RenderDataArray::NORMAL_DATA_ARRAY:
-            {
-                buffer = (GLfloat*)malloc(indexCount * sizeof(GLfloat) * 3);
-                for(int i=0; i < indexCount; i++) {
-                    vertex = mesh->getIndexedVertex(i);
-                    buffer[bufferOffset+0] = vertex->normal.x;
-                    buffer[bufferOffset+1] = vertex->normal.y;
-                    buffer[bufferOffset+2] = vertex->normal.z;
-                    bufferOffset += 3;                    
-                }
-                
-            }
-                break;
-            case RenderDataArray::TANGENT_DATA_ARRAY:
-            {
-                buffer = (GLfloat*)malloc(indexCount * sizeof(GLfloat) * 3);
-                
-                for(int i=0; i < indexCount; i++) {
-                    vertex = mesh->getIndexedVertex(i);
-                    buffer[bufferOffset+0] = vertex->tangent.x;
-                    buffer[bufferOffset+1] = vertex->tangent.y;
-                    buffer[bufferOffset+2] = vertex->tangent.z;
-                    bufferOffset += 3;
-                }
-            }
-                break;
-            case RenderDataArray::TEXCOORD_DATA_ARRAY:
-            {
-                buffer = (GLfloat*)malloc(indexCount * sizeof(GLfloat) * 2);
-                for(int i=0; i < indexCount; i++) {
-                    vertex = mesh->getIndexedVertex(i);
-                    buffer[bufferOffset+0] = vertex->getTexCoord().x;
-                    buffer[bufferOffset+1] = vertex->getTexCoord().y;
-                    bufferOffset += 2;
-                }
-            }
-                break;
-            default:
-            break;
-        }
-        
-    } else {
-        unsigned int vertexCount = mesh->getVertexCount();
-        
-        switch (arrayType) {
-            case RenderDataArray::VERTEX_DATA_ARRAY:
-            {
-                buffer = (GLfloat*)malloc(vertexCount * sizeof(GLfloat) * 3);
-                for(int i=0; i < vertexCount; i++) {
-                    vertex = mesh->getVertex(i);
-                    buffer[bufferOffset+0] = vertex->x;
-                    buffer[bufferOffset+1] = vertex->y;
-                    buffer[bufferOffset+2] = vertex->z;
-                    bufferOffset += 3;
-                    newArray->count++;
-                }
-            }
-                break;
-            case RenderDataArray::COLOR_DATA_ARRAY:
-            {
-                buffer = (GLfloat*)malloc(vertexCount * sizeof(GLfloat) * 4);
-                for(int i=0; i < vertexCount; i++) {
-                    vertex = mesh->getVertex(i);
-                    buffer[bufferOffset+0] = vertex->vertexColor.r;
-                    buffer[bufferOffset+1] = vertex->vertexColor.g;
-                    buffer[bufferOffset+2] = vertex->vertexColor.b;
-                    buffer[bufferOffset+3] = vertex->vertexColor.a;
-                    bufferOffset += 4;
-                }
-            }
-                break;
-            case RenderDataArray::NORMAL_DATA_ARRAY:
-            {
-                buffer = (GLfloat*)malloc(vertexCount * sizeof(GLfloat) * 3);
-                for(int i=0; i < vertexCount; i++) {
-                    vertex = mesh->getVertex(i);
-                    buffer[bufferOffset+0] = vertex->normal.x;
-                    buffer[bufferOffset+1] = vertex->normal.y;
-                    buffer[bufferOffset+2] = vertex->normal.z;
-                    bufferOffset += 3;
-                }
-  
-            }
-                break;
-            case RenderDataArray::TANGENT_DATA_ARRAY:
-            {
-                buffer = (GLfloat*)malloc(vertexCount * sizeof(GLfloat) * 3);
-                
-                for(int i=0; i < vertexCount; i++) {
-                    vertex = mesh->getVertex(i);
-                    buffer[bufferOffset+0] = vertex->tangent.x;
-                    buffer[bufferOffset+1] = vertex->tangent.y;
-                    buffer[bufferOffset+2] = vertex->tangent.z;
-                    bufferOffset += 3;
-                }
-            }
-                break;		
-            case RenderDataArray::TEXCOORD_DATA_ARRAY:
-            {
-                buffer = (GLfloat*)malloc(vertexCount * sizeof(GLfloat) * 2);
-                for(int i=0; i < vertexCount; i++) {
-                    vertex = mesh->getVertex(i);
-                    buffer[bufferOffset+0] = vertex->getTexCoord().x;
-                    buffer[bufferOffset+1] = vertex->getTexCoord().y;
-                    bufferOffset += 2;
-                }			
-            }
-            break;
-            default:
-            break;
-        }
-    }
-    
-	if(buffer != NULL) {
-		free(newArray->arrayPtr);
-		newArray->arrayPtr = buffer;		
-	}
-	
-	return newArray;
-}
-
-RenderDataArray *OpenGLRenderer::createRenderDataArray(int arrayType) {
-	RenderDataArray *newArray = new RenderDataArray();
-	newArray->arrayType = arrayType;
-	newArray->arrayPtr = malloc(1);
-	newArray->stride = 0;
-	newArray->count = 0;
-	
-	switch (arrayType) {
-		case RenderDataArray::VERTEX_DATA_ARRAY:
-			newArray->size = 3;
-			break;
-		case RenderDataArray::COLOR_DATA_ARRAY:
-			newArray->size = 4;
-			break;			
-		case RenderDataArray::NORMAL_DATA_ARRAY:
-			newArray->size = 3;
-			break;	
-		case RenderDataArray::TANGENT_DATA_ARRAY:
-			newArray->size = 3;
-			break;														
-		case RenderDataArray::TEXCOORD_DATA_ARRAY:
-			newArray->size = 2;
-			break;									
-		default:
-			break;
-	}
-	
-	return newArray;
-}
-
-void OpenGLRenderer::setRenderArrayData(RenderDataArray *array, Number *arrayData) {
-	
-}
-
 void OpenGLRenderer::setWireframePolygonMode(bool val) {
 void OpenGLRenderer::setWireframePolygonMode(bool val) {
     if(val) {
     if(val) {
         glPolygonMode( GL_FRONT_AND_BACK, GL_LINE);
         glPolygonMode( GL_FRONT_AND_BACK, GL_LINE);
@@ -1078,7 +906,7 @@ void OpenGLRenderer::setWireframePolygonMode(bool val) {
     }
     }
 }
 }
 
 
-void OpenGLRenderer::drawArrays(int drawType) {
+void OpenGLRenderer::drawArrays(int drawType, IndexDataArray *indexArray) {
 	
 	
 	GLenum mode = GL_TRIANGLES;
 	GLenum mode = GL_TRIANGLES;
 	
 	
@@ -1106,14 +934,22 @@ void OpenGLRenderer::drawArrays(int drawType) {
 		break;
 		break;
 	}
 	}
 	
 	
-	glDrawArrays( mode, 0, verticesToDraw);	
-	
+    if(indexArray) {
+        if(indexArray->getDataSize() > 0) {
+            glBindBufferARB( GL_ELEMENT_ARRAY_BUFFER_ARB, 0);            
+            glDrawElements(mode, indexArray->getDataSize(), GL_UNSIGNED_INT, indexArray->getArrayData());
+        }
+    } else {
+        glDrawArrays( mode, 0, verticesToDraw);
+	}
+    
 	verticesToDraw = 0;
 	verticesToDraw = 0;
 		
 		
 	glDisableClientState( GL_VERTEX_ARRAY);	
 	glDisableClientState( GL_VERTEX_ARRAY);	
 	glDisableClientState( GL_TEXTURE_COORD_ARRAY );		
 	glDisableClientState( GL_TEXTURE_COORD_ARRAY );		
 	glDisableClientState( GL_NORMAL_ARRAY );
 	glDisableClientState( GL_NORMAL_ARRAY );
-	glDisableClientState( GL_COLOR_ARRAY );		
+	glDisableClientState( GL_COLOR_ARRAY );
+    glDisableVertexAttribArrayARB(6);
 }
 }
 
 
 void OpenGLRenderer::drawScreenQuad(Number qx, Number qy) {
 void OpenGLRenderer::drawScreenQuad(Number qx, Number qy) {

+ 42 - 173
Core/Contents/Source/PolyGLVertexBuffer.cpp

@@ -47,200 +47,65 @@ extern PFNGLGETBUFFERPOINTERVARBPROC glGetBufferPointervARB;
 #endif
 #endif
 
 
 OpenGLVertexBuffer::OpenGLVertexBuffer(Mesh *mesh) : VertexBuffer() {
 OpenGLVertexBuffer::OpenGLVertexBuffer(Mesh *mesh) : VertexBuffer() {
-	glGenBuffersARB(1, &vertexBufferID);
-	glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertexBufferID);
 	
 	
-	meshType = mesh->getMeshType();
+    vertexBufferID = -1;
+    texCoordBufferID = -1;
+    normalBufferID = -1;
+    colorBufferID = -1;
+    tangentBufferID = -1;
+    indexBufferID = -1;
     
     
-    Vertex *vertex;
-    
-    if(mesh->indexedMesh) {
-        
-        long bufferOffset = 0;
-        int bufferSize = mesh->getIndexCount() * sizeof(GLfloat) * 3;
-        GLfloat *buffer = (GLfloat*)malloc(bufferSize);
-        
-        vertexCount = 0;
-        for(int i=0; i < mesh->getIndexCount(); i++) {
-            vertexCount++;
-            vertex = mesh->getIndexedVertex(i);
-            buffer[bufferOffset+0] = vertex->x;
-            buffer[bufferOffset+1] = vertex->y;
-            buffer[bufferOffset+2] = vertex->z;
-            bufferOffset += 3;
-        }
-        glBufferDataARB(GL_ARRAY_BUFFER_ARB, bufferSize, buffer, GL_STATIC_DRAW_ARB);
-        free(buffer);
-        
-        glGenBuffersARB(1, &texCoordBufferID);
-        glBindBufferARB(GL_ARRAY_BUFFER_ARB, texCoordBufferID);
-        
-        
-        
-        bufferOffset = 0;
-        bufferSize = mesh->getIndexCount() * sizeof(GLfloat) * 2;
-        buffer = (GLfloat*)malloc(bufferSize);
-        
-        for(int i=0; i < mesh->getIndexCount(); i++) {
-            vertex = mesh->getIndexedVertex(i);
-            buffer[bufferOffset+0] = vertex->getTexCoord().x;
-            buffer[bufferOffset+1] = vertex->getTexCoord().y;
-            bufferOffset += 2;
-        }
-        
-        glBufferDataARB(GL_ARRAY_BUFFER_ARB, bufferSize, buffer, GL_STATIC_DRAW_ARB);
-        free(buffer);
-        
-        glGenBuffersARB(1, &normalBufferID);
-        glBindBufferARB(GL_ARRAY_BUFFER_ARB, normalBufferID);
-        
-        bufferSize = mesh->getIndexCount() * sizeof(GLfloat) * 3;
-        bufferOffset = 0;
-        buffer = (GLfloat*)malloc(bufferSize);
-        
-        for(int i=0; i < mesh->getIndexCount(); i++) {
-            vertex = mesh->getIndexedVertex(i);
-            buffer[bufferOffset+0] = vertex->normal.x;
-            buffer[bufferOffset+1] = vertex->normal.y;
-            buffer[bufferOffset+2] = vertex->normal.z;
-            bufferOffset += 3;
-        }
-        
-        glBufferDataARB(GL_ARRAY_BUFFER_ARB, bufferSize, buffer, GL_STATIC_DRAW_ARB);
-        free(buffer);
-        
-        glGenBuffersARB(1, &tangentBufferID);
-        glBindBufferARB(GL_ARRAY_BUFFER_ARB, tangentBufferID);
-        
-        bufferSize = mesh->getIndexCount() * sizeof(GLfloat) * 3;
-        bufferOffset = 0;
-        buffer = (GLfloat*)malloc(bufferSize);
-        
-        for(int i=0; i < mesh->getIndexCount(); i++) {
-            vertex = mesh->getIndexedVertex(i);
-            buffer[bufferOffset+0] = vertex->tangent.x;
-            buffer[bufferOffset+1] = vertex->tangent.y;
-            buffer[bufferOffset+2] = vertex->tangent.z;
-            bufferOffset += 3;
-        }
-        
-        glBufferDataARB(GL_ARRAY_BUFFER_ARB, bufferSize, buffer, GL_STATIC_DRAW_ARB);
-        free(buffer);
-        
-        glGenBuffersARB(1, &colorBufferID);
-        glBindBufferARB(GL_ARRAY_BUFFER_ARB, colorBufferID);
-        
-        bufferSize = mesh->getIndexCount() * sizeof(GLfloat) * 4;
-        bufferOffset = 0;
-        buffer = (GLfloat*)malloc(bufferSize);
-        
-        for(int i=0; i < mesh->getIndexCount(); i++) {
-            vertex = mesh->getIndexedVertex(i);
-            buffer[bufferOffset+0] = vertex->vertexColor.r;
-            buffer[bufferOffset+1] = vertex->vertexColor.g;
-            buffer[bufferOffset+2] = vertex->vertexColor.b;
-            buffer[bufferOffset+3] = vertex->vertexColor.a;
-            bufferOffset += 4;
-        }
-        
-        glBufferDataARB(GL_ARRAY_BUFFER_ARB, bufferSize, buffer, GL_STATIC_DRAW_ARB);
-        free(buffer);
-    } else {
     
     
+	meshType = mesh->getMeshType();
+    vertexCount = mesh->vertexPositionArray.getDataSize() / 3;
 
 
-        long bufferOffset = 0;
-        int bufferSize = mesh->getVertexCount() * sizeof(GLfloat) * 3;
-        GLfloat *buffer = (GLfloat*)malloc(bufferSize);
-        
-        vertexCount = 0;
-        for(int i=0; i < mesh->getVertexCount(); i++) {
-            vertexCount++;
-            buffer[bufferOffset+0] = mesh->getVertex(i)->x;
-            buffer[bufferOffset+1] = mesh->getVertex(i)->y;
-            buffer[bufferOffset+2] = mesh->getVertex(i)->z;
-            bufferOffset += 3;
-        }
-        glBufferDataARB(GL_ARRAY_BUFFER_ARB, bufferSize, buffer, GL_STATIC_DRAW_ARB);
-        free(buffer);
+	glGenBuffersARB(1, &vertexBufferID);
+	glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertexBufferID);
+    
+    glBufferDataARB(GL_ARRAY_BUFFER_ARB, mesh->vertexPositionArray.getDataSize() * sizeof(PolyRendererVertexType), mesh->vertexPositionArray.getArrayData(), GL_STATIC_DRAW_ARB);
 
 
+    
+    if(mesh->vertexTexCoordArray.getDataSize() == vertexCount * 2) {
         glGenBuffersARB(1, &texCoordBufferID);
         glGenBuffersARB(1, &texCoordBufferID);
         glBindBufferARB(GL_ARRAY_BUFFER_ARB, texCoordBufferID);
         glBindBufferARB(GL_ARRAY_BUFFER_ARB, texCoordBufferID);
-        
-        
-        
-        bufferOffset = 0;
-        bufferSize = mesh->getVertexCount() * sizeof(GLfloat) * 2;
-        buffer = (GLfloat*)malloc(bufferSize);
-        
-        for(int i=0; i < mesh->getVertexCount(); i++) {
-            buffer[bufferOffset+0] = mesh->getVertex(i)->getTexCoord().x;
-            buffer[bufferOffset+1] = mesh->getVertex(i)->getTexCoord().y;
-            bufferOffset += 2;
-        }
-        
-        glBufferDataARB(GL_ARRAY_BUFFER_ARB, bufferSize, buffer, GL_STATIC_DRAW_ARB);
-        free(buffer);
-        
+            
+        glBufferDataARB(GL_ARRAY_BUFFER_ARB,  mesh->vertexTexCoordArray.getDataSize() * sizeof(PolyRendererVertexType), mesh->vertexTexCoordArray.getArrayData(), GL_STATIC_DRAW_ARB);
+    }
+    
+    if(mesh->vertexNormalArray.getDataSize() == vertexCount * 3) {
         glGenBuffersARB(1, &normalBufferID);
         glGenBuffersARB(1, &normalBufferID);
         glBindBufferARB(GL_ARRAY_BUFFER_ARB, normalBufferID);
         glBindBufferARB(GL_ARRAY_BUFFER_ARB, normalBufferID);
-        
-        bufferSize = mesh->getVertexCount() * sizeof(GLfloat) * 3;
-        bufferOffset = 0;
-        buffer = (GLfloat*)malloc(bufferSize);
-        
-        for(int i=0; i < mesh->getVertexCount(); i++) {
-            buffer[bufferOffset+0] = mesh->getVertex(i)->normal.x;
-            buffer[bufferOffset+1] = mesh->getVertex(i)->normal.y;
-            buffer[bufferOffset+2] = mesh->getVertex(i)->normal.z;
-            bufferOffset += 3;
-        }
-        
-        glBufferDataARB(GL_ARRAY_BUFFER_ARB, bufferSize, buffer, GL_STATIC_DRAW_ARB);
-        free(buffer);	
-
+        glBufferDataARB(GL_ARRAY_BUFFER_ARB,  mesh->vertexNormalArray.getDataSize() * sizeof(PolyRendererVertexType), mesh->vertexNormalArray.getArrayData(), GL_STATIC_DRAW_ARB);
+    }
+    
+    if(mesh->vertexTangentArray.getDataSize() == vertexCount * 3) {
         glGenBuffersARB(1, &tangentBufferID);
         glGenBuffersARB(1, &tangentBufferID);
         glBindBufferARB(GL_ARRAY_BUFFER_ARB, tangentBufferID);
         glBindBufferARB(GL_ARRAY_BUFFER_ARB, tangentBufferID);
         
         
-        bufferSize = mesh->getVertexCount() * sizeof(GLfloat) * 3;
-        bufferOffset = 0;
-        buffer = (GLfloat*)malloc(bufferSize);
-        
-        for(int i=0; i < mesh->getVertexCount(); i++) {
-            buffer[bufferOffset+0] = mesh->getVertex(i)->tangent.x;
-            buffer[bufferOffset+1] = mesh->getVertex(i)->tangent.y;
-            buffer[bufferOffset+2] = mesh->getVertex(i)->tangent.z;
-            bufferOffset += 3;
-        }
-        
-        glBufferDataARB(GL_ARRAY_BUFFER_ARB, bufferSize, buffer, GL_STATIC_DRAW_ARB);
-        free(buffer);	
-        
+        glBufferDataARB(GL_ARRAY_BUFFER_ARB,  mesh->vertexTangentArray.getDataSize() * sizeof(PolyRendererVertexType), mesh->vertexTangentArray.getArrayData(), GL_STATIC_DRAW_ARB);
+    }
+    
+    if(mesh->vertexTangentArray.getDataSize() == vertexCount * 4) {
         glGenBuffersARB(1, &colorBufferID);
         glGenBuffersARB(1, &colorBufferID);
         glBindBufferARB(GL_ARRAY_BUFFER_ARB, colorBufferID);
         glBindBufferARB(GL_ARRAY_BUFFER_ARB, colorBufferID);
-        
-        bufferSize = mesh->getVertexCount() * sizeof(GLfloat) * 4;
-        bufferOffset = 0;
-        buffer = (GLfloat*)malloc(bufferSize);
-        
-        for(int i=0; i < mesh->getVertexCount(); i++) {
-            buffer[bufferOffset+0] = mesh->getVertex(i)->vertexColor.r;
-            buffer[bufferOffset+1] = mesh->getVertex(i)->vertexColor.g;
-            buffer[bufferOffset+2] = mesh->getVertex(i)->vertexColor.b;
-            buffer[bufferOffset+3] = mesh->getVertex(i)->vertexColor.a;
-            bufferOffset += 4;
-        }
-        
-        glBufferDataARB(GL_ARRAY_BUFFER_ARB, bufferSize, buffer, GL_STATIC_DRAW_ARB);
-        free(buffer);
+            
+        glBufferDataARB(GL_ARRAY_BUFFER_ARB,  mesh->vertexColorArray.getDataSize() * sizeof(PolyRendererVertexType), mesh->vertexColorArray.getArrayData(), GL_STATIC_DRAW_ARB);
+    }
+    
+    if(mesh->indexedMesh && mesh->indexArray.getDataSize() > 0) {
+        glGenBuffersARB(1, &indexBufferID);
+        glBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, indexBufferID);
+        glBufferDataARB(GL_ELEMENT_ARRAY_BUFFER_ARB,  mesh->indexArray.getDataSize() * sizeof(PolyRendererIndexType), mesh->indexArray.getArrayData(), GL_STATIC_DRAW_ARB);
+        indexCount = mesh->indexArray.getDataSize();
     }
     }
-	
 }
 }
 
 
 OpenGLVertexBuffer::~OpenGLVertexBuffer() {
 OpenGLVertexBuffer::~OpenGLVertexBuffer() {
 	glDeleteBuffersARB(1, &vertexBufferID);
 	glDeleteBuffersARB(1, &vertexBufferID);
 	glDeleteBuffersARB(1, &texCoordBufferID);
 	glDeleteBuffersARB(1, &texCoordBufferID);
 	glDeleteBuffersARB(1, &normalBufferID);
 	glDeleteBuffersARB(1, &normalBufferID);
-	glDeleteBuffersARB(1, &colorBufferID);	
+	glDeleteBuffersARB(1, &colorBufferID);
+	glDeleteBuffersARB(1, &indexBufferID);
 }
 }
 
 
 GLuint OpenGLVertexBuffer::getColorBufferID() {
 GLuint OpenGLVertexBuffer::getColorBufferID() {
@@ -262,3 +127,7 @@ GLuint OpenGLVertexBuffer::getVertexBufferID() {
 GLuint OpenGLVertexBuffer::getTangentBufferID() {
 GLuint OpenGLVertexBuffer::getTangentBufferID() {
 	return tangentBufferID;
 	return tangentBufferID;
 }
 }
+
+GLuint OpenGLVertexBuffer::getIndexBufferID() {
+    return indexBufferID;
+}

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 390 - 279
Core/Contents/Source/PolyMesh.cpp


+ 17 - 10
Core/Contents/Source/PolyParticleEmitter.cpp

@@ -210,7 +210,8 @@ void SceneParticleEmitter::rebuildParticles() {
                 if(particlesInWorldSpace) {
                 if(particlesInWorldSpace) {
                     vertexPosition = inverseMatrix * vertexPosition;
                     vertexPosition = inverseMatrix * vertexPosition;
                 }
                 }
-                mesh->addVertex(vertexPosition.x, vertexPosition.y, vertexPosition.z, 0.5, 0.5)->vertexColor = particles[i].color;
+                mesh->addVertexWithUV(vertexPosition.x, vertexPosition.y, vertexPosition.z, 0.5, 0.5);
+                mesh->addColor(particles[i].color);
             }
             }
         }
         }
         break;
         break;
@@ -245,20 +246,24 @@ void SceneParticleEmitter::rebuildParticles() {
                         
                         
                         indexOffset = mesh->getVertexCount();
                         indexOffset = mesh->getVertexCount();
                         
                         
+                        // TODO: fix
+                        /*
                         for(int v=0; v <  sourceMeshes[meshIndex]->getVertexCount(); v++) {
                         for(int v=0; v <  sourceMeshes[meshIndex]->getVertexCount(); v++) {
                             Vertex *sv = sourceMeshes[meshIndex]->getVertex(v);
                             Vertex *sv = sourceMeshes[meshIndex]->getVertex(v);
+                            
                             Vector3 vpos = Vector3(sv->x, sv->y, sv->z) * finalParticleSize;
                             Vector3 vpos = Vector3(sv->x, sv->y, sv->z) * finalParticleSize;
                             vpos = q.applyTo(vpos);
                             vpos = q.applyTo(vpos);
                             
                             
                             vpos += particlePosition;
                             vpos += particlePosition;
-                            Vertex *newV = mesh->addVertex(vpos.x, vpos.y, vpos.z, sv->texCoord.x, sv->texCoord.y);
-                            newV->vertexColor = vertexColor;
-                            newV->normal = q.applyTo(sv->normal);
+                            mesh->addVertexWithUV(vpos.x, vpos.y, vpos.z, sv->texCoord.x, sv->texCoord.y);
+                            mesh->addColor(vertexColor);
+                            mesh->addNormal(q.applyTo(sv->normal);
                         }
                         }
                         
                         
                         for(int v=0; v < sourceMeshes[meshIndex]->getIndexCount(); v++) {
                         for(int v=0; v < sourceMeshes[meshIndex]->getIndexCount(); v++) {
                             mesh->addIndex(indexOffset + sourceMeshes[meshIndex]->getIndexAt(v));
                             mesh->addIndex(indexOffset + sourceMeshes[meshIndex]->getIndexAt(v));
                         }
                         }
+                         */
                     }
                     }
                     
                     
                 } else {
                 } else {
@@ -267,22 +272,26 @@ void SceneParticleEmitter::rebuildParticles() {
                     Vector3 vertexPosition = Vector3(-finalParticleSize, -finalParticleSize, 0.0);
                     Vector3 vertexPosition = Vector3(-finalParticleSize, -finalParticleSize, 0.0);
                     vertexPosition = q.applyTo(vertexPosition);
                     vertexPosition = q.applyTo(vertexPosition);
                     vertexPosition = cameraMatrix.rotateVector(vertexPosition);
                     vertexPosition = cameraMatrix.rotateVector(vertexPosition);
-                    mesh->addVertex(particlePosition.x+vertexPosition.x, particlePosition.y+vertexPosition.y, particlePosition.z+vertexPosition.z, 0.0, 0.0)->vertexColor = vertexColor;
+                    mesh->addVertexWithUV(particlePosition.x+vertexPosition.x, particlePosition.y+vertexPosition.y, particlePosition.z+vertexPosition.z, 0.0, 0.0);
+                    mesh->addColor(vertexColor);
                     
                     
                     vertexPosition = Vector3(finalParticleSize, -finalParticleSize, 0.0);
                     vertexPosition = Vector3(finalParticleSize, -finalParticleSize, 0.0);
                     vertexPosition = q.applyTo(vertexPosition);
                     vertexPosition = q.applyTo(vertexPosition);
                     vertexPosition = cameraMatrix.rotateVector(vertexPosition);
                     vertexPosition = cameraMatrix.rotateVector(vertexPosition);
-                    mesh->addVertex(particlePosition.x+vertexPosition.x, particlePosition.y+vertexPosition.y, particlePosition.z+vertexPosition.z, 1.0, 0.0)->vertexColor = vertexColor;
+                    mesh->addVertexWithUV(particlePosition.x+vertexPosition.x, particlePosition.y+vertexPosition.y, particlePosition.z+vertexPosition.z, 1.0, 0.0);
+                    mesh->addColor(vertexColor);
 
 
                     vertexPosition = Vector3(finalParticleSize, finalParticleSize, 0.0);
                     vertexPosition = Vector3(finalParticleSize, finalParticleSize, 0.0);
                     vertexPosition = q.applyTo(vertexPosition);
                     vertexPosition = q.applyTo(vertexPosition);
                     vertexPosition = cameraMatrix.rotateVector(vertexPosition);
                     vertexPosition = cameraMatrix.rotateVector(vertexPosition);
-                    mesh->addVertex(particlePosition.x+vertexPosition.x, particlePosition.y+vertexPosition.y, particlePosition.z+vertexPosition.z, 1.0, 1.0)->vertexColor = vertexColor;
+                    mesh->addVertexWithUV(particlePosition.x+vertexPosition.x, particlePosition.y+vertexPosition.y, particlePosition.z+vertexPosition.z, 1.0, 1.0);
+                    mesh->addColor(vertexColor);
 
 
                     vertexPosition = Vector3(-finalParticleSize, finalParticleSize, 0.0);
                     vertexPosition = Vector3(-finalParticleSize, finalParticleSize, 0.0);
                     vertexPosition = q.applyTo(vertexPosition);
                     vertexPosition = q.applyTo(vertexPosition);
                     vertexPosition = cameraMatrix.rotateVector(vertexPosition);
                     vertexPosition = cameraMatrix.rotateVector(vertexPosition);
-                    mesh->addVertex(particlePosition.x+vertexPosition.x, particlePosition.y+vertexPosition.y, particlePosition.z+vertexPosition.z, 0.0, 1.0)->vertexColor = vertexColor;
+                    mesh->addVertexWithUV(particlePosition.x+vertexPosition.x, particlePosition.y+vertexPosition.y, particlePosition.z+vertexPosition.z, 0.0, 1.0);
+                    mesh->addColor(vertexColor);
                 }
                 }
 
 
             }
             }
@@ -290,8 +299,6 @@ void SceneParticleEmitter::rebuildParticles() {
             break;
             break;
             
             
     }
     }
-  
-    mesh->dirtyArrays();
     
     
     if(useVertexBuffer) {
     if(useVertexBuffer) {
 		CoreServices::getInstance()->getRenderer()->createVertexBufferForMesh(mesh);
 		CoreServices::getInstance()->getRenderer()->createVertexBufferForMesh(mesh);

+ 4 - 4
Core/Contents/Source/PolyRay.cpp

@@ -55,13 +55,13 @@ Vector3 Ray::planeIntersectPoint(const Vector3 &planeNormal, Number planeDistanc
 	 return origin + direction * (-distanceToOrigin / direction.dot(planeNormal));
 	 return origin + direction * (-distanceToOrigin / direction.dot(planeNormal));
 }
 }
 
 
-bool Ray::polygonIntersect(Vertex *v1, Vertex *v2, Vertex *v3) const {
+bool Ray::polygonIntersect(const Vector3 &v1, const Vector3 &v2, const Vector3 &v3) const {
 
 
     Number t,u,v;
     Number t,u,v;
 	t = 0; u = 0; v = 0;
 	t = 0; u = 0; v = 0;
 
 
-	Vector3 edge1 = (*(Vector3*)v2) - (*(Vector3*)v3);
-	Vector3 edge2 = (*(Vector3*)v1) - (*(Vector3*)v3);
+	Vector3 edge1 = v2 - v3;
+	Vector3 edge2 = v1 - v3;
 
 
 	Vector3 tvec, pvec, qvec;
 	Vector3 tvec, pvec, qvec;
 	Number det, inv_det;
 	Number det, inv_det;
@@ -74,7 +74,7 @@ bool Ray::polygonIntersect(Vertex *v1, Vertex *v2, Vertex *v3) const {
 
 
 	inv_det = 1.0f / det;
 	inv_det = 1.0f / det;
 
 
-	tvec = origin - (*(Vector3*)v3);
+	tvec = origin - v3;
 
 
 	u = tvec.dot(pvec) * inv_det;
 	u = tvec.dot(pvec) * inv_det;
 	if (u < -0.001f || u > 1.001f)
 	if (u < -0.001f || u > 1.001f)

+ 54 - 0
Core/Contents/Source/PolyRenderDataArray.cpp

@@ -0,0 +1,54 @@
+/*
+ Copyright (C) 2014 by Ivan Safrin
+ 
+ Permission is hereby granted, free of charge, to any person obtaining a copy
+ of this software and associated documentation files (the "Software"), to deal
+ in the Software without restriction, including without limitation the rights
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ copies of the Software, and to permit persons to whom the Software is
+ furnished to do so, subject to the following conditions:
+ 
+ The above copyright notice and this permission notice shall be included in
+ all copies or substantial portions of the Software.
+ 
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ THE SOFTWARE.
+ */
+
+#include "PolyRenderDataArray.h"
+
+using namespace Polycode;
+
+RenderDataArray::RenderDataArray(unsigned int type) {
+    this->type = type;
+}
+
+void *RenderDataArray::getArrayData() {
+    return NULL;
+}
+
+unsigned int RenderDataArray::getDataSize() {
+    return 0;
+}
+
+void *VertexDataArray::getArrayData() {
+    return (void*) data.data();
+}
+
+unsigned int VertexDataArray::getDataSize() {
+    return data.size();
+}
+
+
+void *IndexDataArray::getArrayData() {
+    return (void*) data.data();
+}
+
+unsigned int IndexDataArray::getDataSize() {
+    return data.size();
+}

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

@@ -275,18 +275,6 @@ void Renderer::setRendererShaderParams(Shader *shader, ShaderBinding *binding) {
 	}
 	}
 }
 }
 
 
-void Renderer::pushDataArrayForMesh(Mesh *mesh, int arrayType) {
-	if(mesh->arrayDirtyMap[arrayType] == true || mesh->renderDataArrays[arrayType] == NULL) {
-		if(mesh->renderDataArrays[arrayType] != NULL) {
-			free(mesh->renderDataArrays[arrayType]->arrayPtr);
-			delete mesh->renderDataArrays[arrayType];
-		}
-		mesh->renderDataArrays[arrayType] = createRenderDataArrayForMesh(mesh, arrayType);
-		mesh->arrayDirtyMap[arrayType] = false;
-	}
-	pushRenderDataArray(mesh->renderDataArrays[arrayType]);
-}
-
 void Renderer::applyMaterial(Material *material,  ShaderBinding *localOptions,unsigned int shaderIndex, bool forceMaterial) {
 void Renderer::applyMaterial(Material *material,  ShaderBinding *localOptions,unsigned int shaderIndex, bool forceMaterial) {
     
     
     if(overrideMaterial) {
     if(overrideMaterial) {

+ 6 - 8
Core/Contents/Source/PolySceneImage.cpp

@@ -23,7 +23,6 @@
 #include "PolySceneImage.h"
 #include "PolySceneImage.h"
 #include "PolyMesh.h"
 #include "PolyMesh.h"
 #include "PolyTexture.h"
 #include "PolyTexture.h"
-#include "PolyVertex.h"
 
 
 using namespace Polycode;
 using namespace Polycode;
 
 
@@ -102,13 +101,12 @@ void SceneImage::setImageCoordinates(Number x, Number y, Number width, Number he
 	Number wFloat = width * pixelSizeX;
 	Number wFloat = width * pixelSizeX;
 	Number hFloat = height * pixelSizeY;
 	Number hFloat = height * pixelSizeY;
 
 
-    mesh->getVertex(0)->setTexCoord(xFloat, yFloat - hFloat);
-    mesh->getVertex(1)->setTexCoord(xFloat + wFloat, yFloat - hFloat);
-    mesh->getVertex(2)->setTexCoord(xFloat + wFloat, yFloat);
-    mesh->getVertex(3)->setTexCoord(xFloat, yFloat);
-
-	mesh->arrayDirtyMap[RenderDataArray::VERTEX_DATA_ARRAY] = true;
-	mesh->arrayDirtyMap[RenderDataArray::TEXCOORD_DATA_ARRAY] = true;
+    mesh->vertexTexCoordArray.data.clear();
+    
+    mesh->addTexCoord(xFloat, yFloat - hFloat);
+    mesh->addTexCoord(xFloat + wFloat, yFloat - hFloat);
+    mesh->addTexCoord(xFloat + wFloat, yFloat);
+    mesh->addTexCoord(xFloat, yFloat);
 	
 	
 	rebuildTransformMatrix();
 	rebuildTransformMatrix();
 	matrixDirty = true;
 	matrixDirty = true;

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

@@ -89,7 +89,7 @@ void SceneCurve::Update() {
         
         
         for(Number offset=0.0; offset <= 1.0; offset += step) {
         for(Number offset=0.0; offset <= 1.0; offset += step) {
             Vector3 pt = curve->getPointAt(offset);
             Vector3 pt = curve->getPointAt(offset);
-            mesh->addVertex(pt.x, pt.y, pt.z, offset, 0.0);
+            mesh->addVertexWithUV(pt.x, pt.y, pt.z, offset, 0.0);
             
             
             bBox.x = max(bBox.x,(Number)fabs(pt.x));
             bBox.x = max(bBox.x,(Number)fabs(pt.x));
             bBox.y = max(bBox.y,(Number)fabs(pt.y));
             bBox.y = max(bBox.y,(Number)fabs(pt.y));
@@ -99,7 +99,6 @@ void SceneCurve::Update() {
     }
     }
     
     
     setLocalBoundingBox(bBox * 2.0);
     setLocalBoundingBox(bBox * 2.0);
-    mesh->dirtyArray(RenderDataArray::VERTEX_DATA_ARRAY);
 }
 }
 
 
 SceneLine::SceneLine(Vector3 start, Vector3 end) : SceneMesh(Mesh::LINE_MESH) {
 SceneLine::SceneLine(Vector3 start, Vector3 end) : SceneMesh(Mesh::LINE_MESH) {
@@ -120,9 +119,8 @@ SceneLine::SceneLine(Entity *ent1, Entity *ent2) : SceneMesh(Mesh::LINE_MESH) {
 }
 }
 
 
 void SceneLine::initLine() {
 void SceneLine::initLine() {
-	mesh->addVertex(0,0,0,0,0);
-	mesh->addVertex(0,0,0,1,0);
-	mesh->arrayDirtyMap[RenderDataArray::TEXCOORD_DATA_ARRAY] = true;		
+	mesh->addVertexWithUV(0,0,0,0,0);
+	mesh->addVertexWithUV(0,0,0,1,0);
 }
 }
 
 
 SceneLine *SceneLine::SceneLineWithPositions(Vector3 start, Vector3 end) {
 SceneLine *SceneLine::SceneLineWithPositions(Vector3 start, Vector3 end) {
@@ -144,18 +142,20 @@ void SceneLine::Update(){
 
 
 	Vector3 v1;
 	Vector3 v1;
 	Vector3 v2;
 	Vector3 v2;
+
+    mesh->vertexPositionArray.data.clear();
 	
 	
 	if(ent1 != NULL && ent2 != NULL) {
 	if(ent1 != NULL && ent2 != NULL) {
 		v1 = ent1->getConcatenatedMatrix().getPosition();
 		v1 = ent1->getConcatenatedMatrix().getPosition();
 		v2 = ent2->getConcatenatedMatrix().getPosition();
 		v2 = ent2->getConcatenatedMatrix().getPosition();
-        mesh->getVertex(0)->set(v1.x,v1.y,v1.z);
-        mesh->getVertex(1)->set(v2.x,v2.y,v2.z);
+        
+        mesh->addVertex(v1.x,v1.y,v1.z);
+        mesh->addVertex(v2.x,v2.y,v2.z);
 	} else {
 	} else {
 		v1 = start;
 		v1 = start;
 		v2 = end;
 		v2 = end;
-        mesh->getVertex(0)->set(v1.x,v1.y*yAdjust,v1.z);
-        mesh->getVertex(1)->set(v2.x,v2.y*yAdjust,v2.z);
+        mesh->addVertex(v1.x,v1.y*yAdjust,v1.z);
+        mesh->addVertex(v2.x,v2.y*yAdjust,v2.z);
+
 	}
 	}
-	
-	mesh->arrayDirtyMap[RenderDataArray::VERTEX_DATA_ARRAY] = true;
 }
 }

+ 57 - 48
Core/Contents/Source/PolySceneMesh.cpp

@@ -43,7 +43,7 @@ SceneMesh *SceneMesh::SceneMeshWithType(int meshType) {
 	return new SceneMesh(meshType);
 	return new SceneMesh(meshType);
 }
 }
 
 
-SceneMesh::SceneMesh(const String& fileName) : Entity(), texture(NULL), material(NULL), skeleton(NULL), localShaderOptions(NULL), mesh(NULL) {
+SceneMesh::SceneMesh(const String& fileName) : Entity(), texture(NULL), material(NULL), skeleton(NULL), localShaderOptions(NULL), mesh(NULL), skeletalVertexPositions(RenderDataArray::VERTEX_DATA_ARRAY), skeletalVertexNormals(RenderDataArray::NORMAL_DATA_ARRAY) {
     loadFromFile(fileName);
     loadFromFile(fileName);
 	useVertexBuffer = false;
 	useVertexBuffer = false;
 	lineSmooth = false;
 	lineSmooth = false;
@@ -59,7 +59,7 @@ SceneMesh::SceneMesh(const String& fileName) : Entity(), texture(NULL), material
 	alphaTest = false;
 	alphaTest = false;
 }
 }
 
 
-SceneMesh::SceneMesh(Mesh *mesh) : Entity(), texture(NULL), material(NULL), skeleton(NULL), localShaderOptions(NULL) {
+SceneMesh::SceneMesh(Mesh *mesh) : Entity(), texture(NULL), material(NULL), skeleton(NULL), localShaderOptions(NULL), skeletalVertexPositions(RenderDataArray::VERTEX_DATA_ARRAY), skeletalVertexNormals(RenderDataArray::NORMAL_DATA_ARRAY) {
 	this->mesh = mesh;
 	this->mesh = mesh;
 	setLocalBoundingBox(mesh->calculateBBox());
 	setLocalBoundingBox(mesh->calculateBBox());
 	useVertexBuffer = false;
 	useVertexBuffer = false;
@@ -76,7 +76,7 @@ SceneMesh::SceneMesh(Mesh *mesh) : Entity(), texture(NULL), material(NULL), skel
 	alphaTest = false;
 	alphaTest = false;
 }
 }
 
 
-SceneMesh::SceneMesh(int meshType) : texture(NULL), material(NULL), skeleton(NULL), localShaderOptions(NULL) {
+SceneMesh::SceneMesh(int meshType) : texture(NULL), material(NULL), skeleton(NULL), localShaderOptions(NULL), skeletalVertexPositions(RenderDataArray::VERTEX_DATA_ARRAY), skeletalVertexNormals(RenderDataArray::NORMAL_DATA_ARRAY) {
 	mesh = new Mesh(meshType);
 	mesh = new Mesh(meshType);
 	setLocalBoundingBox(mesh->calculateBBox());
 	setLocalBoundingBox(mesh->calculateBBox());
 	useVertexBuffer = false;	
 	useVertexBuffer = false;	
@@ -234,12 +234,6 @@ Skeleton *SceneMesh::loadSkeleton(const String& fileName) {
 
 
 void SceneMesh::setSkeleton(Skeleton *skeleton) {
 void SceneMesh::setSkeleton(Skeleton *skeleton) {
 	this->skeleton = skeleton;
 	this->skeleton = skeleton;
-    for(int i=0; i < mesh->getVertexCount(); i++) {
-        Vertex *vertex = mesh->getVertex(i);
-        for(int j=0; j < vertex->getNumBoneAssignments(); j++) {
-            vertex->getBoneAssignment(j)->bone = skeleton->getBone(vertex->getBoneAssignment(j)->boneID);
-        }
-    }
 }
 }
 
 
 void SceneMesh::setLineWidth(Number newWidth) {
 void SceneMesh::setLineWidth(Number newWidth) {
@@ -256,56 +250,71 @@ Skeleton *SceneMesh::getSkeleton() {
 
 
 void SceneMesh::renderMeshLocally() {
 void SceneMesh::renderMeshLocally() {
 	Renderer *renderer = CoreServices::getInstance()->getRenderer();
 	Renderer *renderer = CoreServices::getInstance()->getRenderer();
+
 	
 	
-	if(skeleton) {	
-		for(int i=0; i < mesh->getVertexCount(); i++) {
-            Vertex *vert = mesh->getVertex(i);
-            Vector3 norm;
+	if(skeleton) {
+        
+        skeletalVertexPositions.data.clear();
+        skeletalVertexNormals.data.clear();
+        
+		for(int i=0; i < mesh->vertexPositionArray.data.size()/3; i++) {
             
             
+            Vector3 norm;
             Vector3 tPos;
             Vector3 tPos;
-
-            for(int b =0; b < vert->getNumBoneAssignments(); b++) {
-                BoneAssignment *bas = vert->getBoneAssignment(b);
-                Bone *bone = bas->bone;
-                if(bone) {
-                    
-                    Matrix4 restMatrix = bone->getRestMatrix();
-                    Matrix4 finalMatrix = bone->getFinalMatrix();
+            
+            for(int b=0; b < 4; b++) {
+            
+                PolyRendererVertexType boneWeight = mesh->vertexBoneWeightArray.data[(i*4)+b];
+                
+                if(boneWeight > 0.0) {
                     
                     
-                    Vector3 vec = restMatrix * vert->restPosition;
-                    tPos += finalMatrix * vec * (bas->weight);
+                    Bone *bone = skeleton->getBone(mesh->vertexBoneIndexArray.data[(i*4)+b]);
+                        
+                    Vector3 restVert(mesh->vertexPositionArray.data[i*3], mesh->vertexPositionArray.data[(i*3)+1], mesh->vertexPositionArray.data[(i*3)+2]);
+                                         
+                    Vector3 vec = bone->restMatrix * restVert;
+                    tPos += bone->finalMatrix * vec * (boneWeight);
+                        
+                    Vector3 nvec(mesh->vertexNormalArray.data[i*3], mesh->vertexNormalArray.data[(i*3)+1], mesh->vertexNormalArray.data[(i*3)+2]);
                     
                     
-                    Vector3 nvec = vert->restNormal;
-                    nvec = restMatrix.rotateVector(nvec);
-                    nvec = finalMatrix.rotateVector(nvec);
+                    nvec = bone->restMatrix.rotateVector(nvec);
+                    nvec = bone->finalMatrix.rotateVector(nvec);
                     
                     
-                    norm += nvec * (bas->weight);
+                    norm += nvec * (boneWeight);
                 }
                 }
-            }					
-            
-        
-            vert->x = tPos.x;
-            vert->y = tPos.y;
-            vert->z = tPos.z;				
+            }
+
+            skeletalVertexPositions.data.push_back(tPos.x);
+            skeletalVertexPositions.data.push_back(tPos.y);
+            skeletalVertexPositions.data.push_back(tPos.z);
         
         
             norm.Normalize();
             norm.Normalize();
-            vert->setNormal(norm.x, norm.y, norm.z);
+            
+            skeletalVertexNormals.data.push_back(norm.x);
+            skeletalVertexNormals.data.push_back(norm.y);
+            skeletalVertexNormals.data.push_back(norm.z);
         }
         }
-        mesh->arrayDirtyMap[RenderDataArray::VERTEX_DATA_ARRAY] = true;
-        mesh->arrayDirtyMap[RenderDataArray::NORMAL_DATA_ARRAY] = true;
-        mesh->arrayDirtyMap[RenderDataArray::TANGENT_DATA_ARRAY] = true;
+        
+        renderer->pushRenderDataArray(&skeletalVertexPositions);
+        renderer->pushRenderDataArray(&skeletalVertexNormals);
+        
+    } else {
+        renderer->pushRenderDataArray(&mesh->vertexPositionArray);
+        renderer->pushRenderDataArray(&mesh->vertexNormalArray);
     }
     }
     
     
-	renderer->pushDataArrayForMesh(mesh, RenderDataArray::VERTEX_DATA_ARRAY);
-	renderer->pushDataArrayForMesh(mesh, RenderDataArray::NORMAL_DATA_ARRAY);		
-	renderer->pushDataArrayForMesh(mesh, RenderDataArray::TANGENT_DATA_ARRAY);			
-	renderer->pushDataArrayForMesh(mesh, RenderDataArray::TEXCOORD_DATA_ARRAY);	
-
+    renderer->pushRenderDataArray(&mesh->vertexTangentArray);
+    renderer->pushRenderDataArray(&mesh->vertexTexCoordArray);
+    
 	if(mesh->useVertexColors) {
 	if(mesh->useVertexColors) {
-		renderer->pushDataArrayForMesh(mesh, RenderDataArray::COLOR_DATA_ARRAY);
+		renderer->pushRenderDataArray(&mesh->vertexColorArray);
 	}
 	}
-	
-	renderer->drawArrays(mesh->getMeshType());
+    
+    if(mesh->indexedMesh) {
+        renderer->drawArrays(mesh->getMeshType(), &mesh->indexArray);
+    } else {
+        renderer->drawArrays(mesh->getMeshType(), NULL);
+    }
 }
 }
 
 
 void SceneMesh::cacheToVertexBuffer(bool cache) {
 void SceneMesh::cacheToVertexBuffer(bool cache) {
@@ -329,7 +338,7 @@ bool SceneMesh::customHitDetection(const Ray &ray) {
     if(mesh->indexedMesh) {
     if(mesh->indexedMesh) {
         for(int i=0; i < mesh->getIndexCount(); i+=3) {
         for(int i=0; i < mesh->getIndexCount(); i+=3) {
             if(i+2 < mesh->getIndexCount()) {
             if(i+2 < mesh->getIndexCount()) {
-                if(transformedRay.polygonIntersect(mesh->getIndexedVertex(i), mesh->getIndexedVertex(i+1), mesh->getIndexedVertex(i+2))) {
+                if(transformedRay.polygonIntersect(mesh->getVertexPositionAtIndex(i), mesh->getVertexPositionAtIndex(i+1), mesh->getVertexPositionAtIndex(i+2))) {
                     return true;
                     return true;
                 }
                 }
             }
             }
@@ -338,13 +347,13 @@ bool SceneMesh::customHitDetection(const Ray &ray) {
     } else {
     } else {
         for(int i=0; i < mesh->getVertexCount(); i+=3) {
         for(int i=0; i < mesh->getVertexCount(); i+=3) {
             if(i+2 < mesh->getVertexCount()) {
             if(i+2 < mesh->getVertexCount()) {
-               if(transformedRay.polygonIntersect(mesh->getVertex(i), mesh->getVertex(i+1), mesh->getVertex(i+2))) {
+               if(transformedRay.polygonIntersect(mesh->getVertexPosition(i), mesh->getVertexPosition(i+1), mesh->getVertexPosition(i+2))) {
                     return true;
                     return true;
                 }
                 }
             }
             }
         }
         }
     }
     }
-	
+
 	return false;
 	return false;
 }
 }
 
 

+ 10 - 10
Core/Contents/Source/PolySceneSprite.cpp

@@ -405,23 +405,25 @@ void SpriteState::rebuildStateMeshes() {
         meshOffset.x -= frameWidth * frame.anchorPoint.x;
         meshOffset.x -= frameWidth * frame.anchorPoint.x;
         meshOffset.y += frameHeight * frame.anchorPoint.y;
         meshOffset.y += frameHeight * frame.anchorPoint.y;
         
         
-        frameMesh->addVertex(meshOffset.x+-frameWidth*0.5, meshOffset.y+frameHeight*0.5, 0.0, frame.coordinates.x, 1.0-frame.coordinates.y)->setNormal(0.0, 0.0, 1.0);
-        frameMesh->addVertex(meshOffset.x+-frameWidth*0.5, meshOffset.y+frameHeight*0.5-frameHeight, 0.0, frame.coordinates.x, 1.0-frame.coordinates.y  - frame.coordinates.h)->setNormal(0.0, 0.0, 1.0);
-        frameMesh->addVertex(meshOffset.x+-frameWidth*0.5+frameWidth, meshOffset.y+frameHeight*0.5-frameHeight, 0.0, frame.coordinates.x+frame.coordinates.w, 1.0- frame.coordinates.y  - frame.coordinates.h)->setNormal(0.0, 0.0, 1.0);
-        frameMesh->addVertex(meshOffset.x+-frameWidth*0.5+frameWidth, meshOffset.y+frameHeight*0.5, 0.0, frame.coordinates.x+frame.coordinates.w, 1.0-frame.coordinates.y)->setNormal(0.0, 0.0, 1.0);
+        frameMesh->addVertexWithUVAndNormal(meshOffset.x+-frameWidth*0.5, meshOffset.y+frameHeight*0.5, 0.0, frame.coordinates.x, 1.0-frame.coordinates.y, 0.0, 0.0, 1.0);
+        frameMesh->addVertexWithUVAndNormal(meshOffset.x+-frameWidth*0.5, meshOffset.y+frameHeight*0.5-frameHeight, 0.0, frame.coordinates.x, 1.0-frame.coordinates.y  - frame.coordinates.h, 0.0, 0.0, 1.0);
+        frameMesh->addVertexWithUVAndNormal(meshOffset.x+-frameWidth*0.5+frameWidth, meshOffset.y+frameHeight*0.5-frameHeight, 0.0, frame.coordinates.x+frame.coordinates.w, 1.0- frame.coordinates.y  - frame.coordinates.h, 0.0, 0.0, 1.0);
+        frameMesh->addVertexWithUVAndNormal(meshOffset.x+-frameWidth*0.5+frameWidth, meshOffset.y+frameHeight*0.5, 0.0, frame.coordinates.x+frame.coordinates.w, 1.0-frame.coordinates.y, 0.0, 0.0, 1.0);
         
         
         
         
         for(int j=0; j < 4; j++) {
         for(int j=0; j < 4; j++) {
-            Vertex *vertex = frameMesh->getVertex(j);
-            Number val = fabs(vertex->x);
+
+            Vector3 vertex(frameMesh->vertexPositionArray.data[j], frameMesh->vertexPositionArray.data[j+1], frameMesh->vertexPositionArray.data[j+2]);
+            
+            Number val = fabs(vertex.x);
             if(val > largestFrameBoundingBox.x) {
             if(val > largestFrameBoundingBox.x) {
                 largestFrameBoundingBox.x = val;
                 largestFrameBoundingBox.x = val;
             }
             }
-            val = fabs(vertex->y);
+            val = fabs(vertex.y);
             if(val > largestFrameBoundingBox.y) {
             if(val > largestFrameBoundingBox.y) {
                 largestFrameBoundingBox.y = val;
                 largestFrameBoundingBox.y = val;
             }
             }
-            val = fabs(vertex->z);
+            val = fabs(vertex.z);
             if(val > largestFrameBoundingBox.z) {
             if(val > largestFrameBoundingBox.z) {
                 largestFrameBoundingBox.z = val;
                 largestFrameBoundingBox.z = val;
             }
             }
@@ -431,8 +433,6 @@ void SpriteState::rebuildStateMeshes() {
         frameMesh->addIndexedFace(2,3);
         frameMesh->addIndexedFace(2,3);
         frameMesh->addIndexedFace(3,0);
         frameMesh->addIndexedFace(3,0);
         
         
-        frameMesh->dirtyArrays();
-        
         frameMeshes.push_back(frameMesh);
         frameMeshes.push_back(frameMesh);
     }
     }
     
     

+ 3 - 2
Core/Contents/Source/PolyTextMesh.cpp

@@ -24,9 +24,9 @@ void TextMesh::setText(const String &text) {
 }
 }
 
 
 void TextMesh::rebuild() {
 void TextMesh::rebuild() {
-	arrayDirtyMap[RenderDataArray::VERTEX_DATA_ARRAY] = true;
-	arrayDirtyMap[RenderDataArray::TEXCOORD_DATA_ARRAY] = true;
 
 
+    // TODO: FIX
+/*
 	if (text == "" || font == NULL) {
 	if (text == "" || font == NULL) {
 		for (std::vector<Vertex*>::iterator it = vertices.begin(); it != vertices.end(); it++) delete *it;
 		for (std::vector<Vertex*>::iterator it = vertices.begin(); it != vertices.end(); it++) delete *it;
 		vertices.clear();
 		vertices.clear();
@@ -40,6 +40,7 @@ void TextMesh::rebuild() {
 		}
 		}
 		vertices.resize(last);
 		vertices.resize(last);
 	}
 	}
+ */
 }
 }
 
 
 
 

+ 0 - 120
Core/Contents/Source/PolyVertex.cpp

@@ -1,120 +0,0 @@
-/*
- Copyright (C) 2011 by Ivan Safrin
- 
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- 
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
- 
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
-*/
-
-#include "PolyVertex.h"
-
-using namespace Polycode;
-
-Vertex::Vertex() : Vector3(0,0,0) {
-	texCoord = Vector2(0,0);	
-	normal = Vector3(0,0,0);
-	useVertexColor = false;
-}
-
-Vertex::Vertex(Number pos_x, Number pos_y, Number pos_z, Number nor_x, Number nor_y, Number nor_z) : Vector3(pos_x, pos_y, pos_z) {
-	normal = Vector3(nor_x, nor_y, nor_z);
-	texCoord = Vector2(0,0);
-	useVertexColor = false;
-	restPosition.set(pos_x, pos_y, pos_z);
-}
-
-Vertex::Vertex(Number pos_x, Number pos_y, Number pos_z, Number nor_x, Number nor_y, Number nor_z, Number u, Number v): Vector3(pos_x, pos_y, pos_z) {
-	normal = Vector3(nor_x, nor_y, nor_z);
-	texCoord = Vector2(u,v);
-	useVertexColor = false;
-	restPosition.set(pos_x, pos_y, pos_z);	
-}
-
-Vertex::Vertex(Number x, Number y, Number z) : Vector3(x,y,z) {
-	useVertexColor = false;
-	restPosition.set(x, y, z);
-}
-
-Vertex::Vertex(Number x, Number y, Number z, Number u, Number v) : Vector3(x,y,z) {
-	texCoord = Vector2(u,v);	
-	useVertexColor = false;
-	restPosition.set(x, y, z);
-}
-
-void Vertex::addBoneAssignment(unsigned int boneID, Number boneWeight) {
-	BoneAssignment *newBas = new BoneAssignment();
-	newBas->boneID = boneID;
-	if(boneWeight > 1)
-		boneWeight = 1;
-	if(boneWeight < 0)
-		boneWeight = 0;
-		
-	newBas->weight = boneWeight;
-	boneAssignments.push_back(newBas);
-}
-
-void Vertex::setNormal(Number x, Number y, Number z) {
-	normal.x = x;
-	normal.y = y;
-	normal.z = z;	
-}
-
-void Vertex::normalizeWeights() {
-	Number allWeights = 0;
-//	if(boneAssignments.size() == 1)
-//		if(boneAssignments[0]->weight < 1)
-//			return;
-			
-	for(int i =0 ;i < boneAssignments.size(); i++) {
-		allWeights += boneAssignments[i]->weight;
-	}
-	
-	for(int i =0 ;i < boneAssignments.size(); i++) {
-		boneAssignments[i]->weight *= 1.0f/allWeights;
-	}	
-}
-
-int Vertex::getNumBoneAssignments() {
-	return boneAssignments.size();
-}
-
-BoneAssignment *Vertex::getBoneAssignment(unsigned int index) {
-	return boneAssignments[index];
-}
-
-Vertex::~Vertex() {
-//	delete normal;
-//	delete texCoord;
-}
-
-Vector2 Vertex::getTexCoord() {
-	return texCoord;
-}
-
-void Vertex::setTexCoord(Number u, Number v) {
-	texCoord.x = u;
-	texCoord.y = v;
-}
-
-Vector2 Vertex::getSecondaryTexCoord() {
-	return secondaryTexCoord;
-}
-
-void Vertex::setSecondaryTexCoord(Number u, Number v) {
-	secondaryTexCoord.x = u;
-	secondaryTexCoord.y = v;
-}

+ 0 - 90
Core/Contents/Source/PolyiPhoneCore.cpp

@@ -1,90 +0,0 @@
-/*
- Copyright (C) 2011 by Ivan Safrin
- 
- Permission is hereby granted, free of charge, to any person obtaining a copy
- of this software and associated documentation files (the "Software"), to deal
- in the Software without restriction, including without limitation the rights
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- copies of the Software, and to permit persons to whom the Software is
- furnished to do so, subject to the following conditions:
- 
- The above copyright notice and this permission notice shall be included in
- all copies or substantial portions of the Software.
- 
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- THE SOFTWARE.
-*/
-
-#include "PolyiPhoneCore.h"
-
-using namespace Polycode;
-
-long getThreadID() {
-	return (long)pthread_self();
-}
-
-IPhoneCore::IPhoneCore(int frameRate) : Core(480, 320, true, 0, frameRate) {
-	
-}
-
-IPhoneCore::~IPhoneCore() {
-	
-}
-
-void IPhoneCore::enableMouse(bool newval) {
-	
-}
-
-unsigned int IPhoneCore::getTicks() {
-	return 0;
-}
-
-bool IPhoneCore::Update() {
-	return running;
-}
-
-void IPhoneCore::setVideoMode(int xRes, int yRes, bool fullScreen, int aaLevel) {
-	
-}
-
-void *PosixThreadFunc(void *data) {
-	Threaded *target = static_cast<Threaded*>(data);
-	target->runThread();
-	return NULL;
-}
-
-void IPhoneCore::createThread(Threaded *target) {
-	pthread_t thread;
-	pthread_create( &thread, NULL, PosixThreadFunc, (void*)target);
-}
-
-void IPhoneCore::lockMutex(CoreMutex *mutex) {
-	PosixMutex *m = (PosixMutex*) mutex;
-	pthread_mutex_lock(&m->pMutex);	
-}
-
-void IPhoneCore::unlockMutex(CoreMutex *mutex) {
-	PosixMutex *m = (PosixMutex*) mutex;
-	pthread_mutex_unlock(&m->pMutex);
-}
-
-CoreMutex *IPhoneCore::createMutex() {
-	PosixMutex *mutex = new PosixMutex();	
-	pthread_mutex_init(&mutex->pMutex, NULL);
-	return mutex;
-}
-
-void IPhoneCore::checkEvents() {
-	
-}
-
-vector<Rectangle> IPhoneCore::getVideoModes() {
-	vector<Rectangle> modes;
-	
-	return modes;
-}

+ 12 - 18
IDE/Contents/Source/PolycodeEntityEditor.cpp

@@ -274,9 +274,6 @@ void CurveDisplay::Update() {
     controlPoints->setLocalBoundingBox(controlPoints->getMesh()->calculateBBox());
     controlPoints->setLocalBoundingBox(controlPoints->getMesh()->calculateBBox());
     controlPointLines->setLocalBoundingBox(controlPointLines->getMesh()->calculateBBox());
     controlPointLines->setLocalBoundingBox(controlPointLines->getMesh()->calculateBBox());
     
     
-    mainPoints->getMesh()->dirtyArray(RenderDataArray::VERTEX_DATA_ARRAY);
-    controlPoints->getMesh()->dirtyArray(RenderDataArray::VERTEX_DATA_ARRAY);
-    controlPointLines->getMesh()->dirtyArray(RenderDataArray::VERTEX_DATA_ARRAY);
 }
 }
 
 
 LightDisplay::LightDisplay(SceneLight *light) : Entity() {
 LightDisplay::LightDisplay(SceneLight *light) : Entity() {
@@ -328,11 +325,10 @@ void LightDisplay::Update() {
        	spotSpot->getMesh()->setMeshType(Mesh::LINE_LOOP_MESH);
        	spotSpot->getMesh()->setMeshType(Mesh::LINE_LOOP_MESH);
         
         
         spotLightSize *= 0.5;
         spotLightSize *= 0.5;
-        fovMesh->getVertex(1)->set(sin(PI/2.0)*spotLightSize, cos(PI/2.0)*spotLightSize, -distance);
-        fovMesh->getVertex(2)->set(sin(PI)*spotLightSize, cos(PI)*spotLightSize, -distance);
-        fovMesh->getVertex(3)->set(sin(PI + (PI/2.0))*spotLightSize, cos(PI + (PI/2.0))*spotLightSize, -distance);
-        fovMesh->getVertex(4)->set(sin(PI*2.0)*spotLightSize, cos(PI*2.0)*spotLightSize, -distance);
-         fovMesh->dirtyArray(RenderDataArray::VERTEX_DATA_ARRAY);
+        fovMesh->setVertexAtOffset(1, sin(PI/2.0)*spotLightSize, cos(PI/2.0)*spotLightSize, -distance);
+        fovMesh->setVertexAtOffset(2, sin(PI)*spotLightSize, cos(PI)*spotLightSize, -distance);
+        fovMesh->setVertexAtOffset(3, sin(PI + (PI/2.0))*spotLightSize, cos(PI + (PI/2.0))*spotLightSize, -distance);
+        fovMesh->setVertexAtOffset(4, sin(PI*2.0)*spotLightSize, cos(PI*2.0)*spotLightSize, -distance);
         fovSceneMesh->setLocalBoundingBox(fovMesh->calculateBBox());
         fovSceneMesh->setLocalBoundingBox(fovMesh->calculateBBox());
     } else {
     } else {
         spotSpot->enabled = false;
         spotSpot->enabled = false;
@@ -401,11 +397,10 @@ void CameraDisplay::Update() {
             break;
             break;
         }
         }
         
         
-        fovMesh->getVertex(1)->set(-xPos, yPos, zPos);
-        fovMesh->getVertex(2)->set(xPos, yPos, zPos);
-        fovMesh->getVertex(3)->set(xPos, -yPos, zPos);
-        fovMesh->getVertex(4)->set(-xPos, -yPos, zPos);
-        fovMesh->dirtyArray(RenderDataArray::VERTEX_DATA_ARRAY);
+        fovMesh->setVertexAtOffset(1, -xPos, yPos, zPos);
+        fovMesh->setVertexAtOffset(2, xPos, yPos, zPos);
+        fovMesh->setVertexAtOffset(3, xPos, -yPos, zPos);
+        fovMesh->setVertexAtOffset(4, -xPos, -yPos, zPos);
     } else {
     } else {
         Number fovRad = (90+camera->getFOV()/2.0) * TORADIANS;
         Number fovRad = (90+camera->getFOV()/2.0) * TORADIANS;
         Number displayScale = 3.0;
         Number displayScale = 3.0;
@@ -413,11 +408,10 @@ void CameraDisplay::Update() {
         Number yPos = xPos * 0.5625;
         Number yPos = xPos * 0.5625;
         Number zPos = -sin(fovRad) * displayScale * 0.5;
         Number zPos = -sin(fovRad) * displayScale * 0.5;
         
         
-        fovMesh->getVertex(1)->set(-xPos, yPos, zPos);
-        fovMesh->getVertex(2)->set(xPos, yPos, zPos);
-        fovMesh->getVertex(3)->set(xPos, -yPos, zPos);
-        fovMesh->getVertex(4)->set(-xPos, -yPos, zPos);
-        fovMesh->dirtyArray(RenderDataArray::VERTEX_DATA_ARRAY);
+        fovMesh->setVertexAtOffset(1, -xPos, yPos, zPos);
+        fovMesh->setVertexAtOffset(2, xPos, yPos, zPos);
+        fovMesh->setVertexAtOffset(3, xPos, -yPos, zPos);
+        fovMesh->setVertexAtOffset(4, -xPos, -yPos, zPos);
     }
     }
 }
 }
 
 

+ 5 - 4
IDE/Contents/Source/PolycodeFrame.cpp

@@ -319,12 +319,13 @@ void EditCurve::updateCurve() {
 	
 	
 	interval += interval/CURVE_SIZE;
 	interval += interval/CURVE_SIZE;
 	normInterval += normInterval/CURVE_SIZE;
 	normInterval += normInterval/CURVE_SIZE;
-		
-	for(int i=0; i < CURVE_SIZE; i++) {
-		visMesh->getMesh()->getVertex(i)->set(targetCurve->getPointAt(normInterval * i).x * 300, targetCurve->getPointAt(normInterval * i).y * 100.0, 0.0);
+
+    visMesh->getMesh()->vertexPositionArray.data.clear();
+    
+	for(int i=0; i < CURVE_SIZE; i++) {        
+        visMesh->getMesh()->addVertex(targetCurve->getPointAt(normInterval * i).x * 300, targetCurve->getPointAt(normInterval * i).y * 100.0, 0.0);
 	}
 	}
 	
 	
-	visMesh->getMesh()->arrayDirtyMap[RenderDataArray::VERTEX_DATA_ARRAY] = true;
     visMesh->setBlendingMode(Renderer::BLEND_MODE_NORMAL);
     visMesh->setBlendingMode(Renderer::BLEND_MODE_NORMAL);
 }
 }
 
 

+ 46 - 42
IDE/Contents/Source/PolycodeSpriteEditor.cpp

@@ -238,10 +238,10 @@ void SpriteSheetEditor::Update() {
     for(int i=0; i < sprite->getNumFrames(); i++){
     for(int i=0; i < sprite->getNumFrames(); i++){
         SpriteFrame frame = sprite->getSpriteFrame(i);
         SpriteFrame frame = sprite->getSpriteFrame(i);
         
         
-        mesh->addVertex(frame.coordinates.x, -frame.coordinates.y, 0.0, frame.coordinates.x, frame.coordinates.y);
-        mesh->addVertex(frame.coordinates.x+frame.coordinates.w, -frame.coordinates.y, 0.0, frame.coordinates.x+frame.coordinates.w, frame.coordinates.y);
-        mesh->addVertex(frame.coordinates.x+frame.coordinates.w, -frame.coordinates.y - frame.coordinates.h, 0.0, frame.coordinates.x+frame.coordinates.w, frame.coordinates.y + frame.coordinates.h);
-        mesh->addVertex(frame.coordinates.x, -frame.coordinates.y - frame.coordinates.h, 0.0, frame.coordinates.x, frame.coordinates.y + frame.coordinates.h);
+        mesh->addVertexWithUV(frame.coordinates.x, -frame.coordinates.y, 0.0, frame.coordinates.x, frame.coordinates.y);
+        mesh->addVertexWithUV(frame.coordinates.x+frame.coordinates.w, -frame.coordinates.y, 0.0, frame.coordinates.x+frame.coordinates.w, frame.coordinates.y);
+        mesh->addVertexWithUV(frame.coordinates.x+frame.coordinates.w, -frame.coordinates.y - frame.coordinates.h, 0.0, frame.coordinates.x+frame.coordinates.w, frame.coordinates.y + frame.coordinates.h);
+        mesh->addVertexWithUV(frame.coordinates.x, -frame.coordinates.y - frame.coordinates.h, 0.0, frame.coordinates.x, frame.coordinates.y + frame.coordinates.h);
         mesh->addIndexedFace(offset+0,offset+1);
         mesh->addIndexedFace(offset+0,offset+1);
         mesh->addIndexedFace(offset+1,offset+2);
         mesh->addIndexedFace(offset+1,offset+2);
         mesh->addIndexedFace(offset+2,offset+3);
         mesh->addIndexedFace(offset+2,offset+3);
@@ -249,10 +249,10 @@ void SpriteSheetEditor::Update() {
         offset += 4;
         offset += 4;
         
         
         if(hasSelectedID(frame.frameID)) {
         if(hasSelectedID(frame.frameID)) {
-            meshSelected->addVertex(frame.coordinates.x, -frame.coordinates.y, 0.0, frame.coordinates.x, frame.coordinates.y);
-            meshSelected->addVertex(frame.coordinates.x+frame.coordinates.w, -frame.coordinates.y, 0.0, frame.coordinates.x+frame.coordinates.w, frame.coordinates.y);
-            meshSelected->addVertex(frame.coordinates.x+frame.coordinates.w, -frame.coordinates.y - frame.coordinates.h, 0.0, frame.coordinates.x+frame.coordinates.w, frame.coordinates.y + frame.coordinates.h);
-            meshSelected->addVertex(frame.coordinates.x, -frame.coordinates.y - frame.coordinates.h, 0.0, frame.coordinates.x, frame.coordinates.y + frame.coordinates.h);
+            meshSelected->addVertexWithUV(frame.coordinates.x, -frame.coordinates.y, 0.0, frame.coordinates.x, frame.coordinates.y);
+            meshSelected->addVertexWithUV(frame.coordinates.x+frame.coordinates.w, -frame.coordinates.y, 0.0, frame.coordinates.x+frame.coordinates.w, frame.coordinates.y);
+            meshSelected->addVertexWithUV(frame.coordinates.x+frame.coordinates.w, -frame.coordinates.y - frame.coordinates.h, 0.0, frame.coordinates.x+frame.coordinates.w, frame.coordinates.y + frame.coordinates.h);
+            meshSelected->addVertexWithUV(frame.coordinates.x, -frame.coordinates.y - frame.coordinates.h, 0.0, frame.coordinates.x, frame.coordinates.y + frame.coordinates.h);
             meshSelected->addIndexedFace(offsetSelected+0,offsetSelected+1);
             meshSelected->addIndexedFace(offsetSelected+0,offsetSelected+1);
             meshSelected->addIndexedFace(offsetSelected+1,offsetSelected+2);
             meshSelected->addIndexedFace(offsetSelected+1,offsetSelected+2);
             meshSelected->addIndexedFace(offsetSelected+2,offsetSelected+3);
             meshSelected->addIndexedFace(offsetSelected+2,offsetSelected+3);
@@ -266,10 +266,10 @@ void SpriteSheetEditor::Update() {
      
      
         SpriteFrame frame = frameToAdd;
         SpriteFrame frame = frameToAdd;
         
         
-        mesh->addVertex(frame.coordinates.x, -frame.coordinates.y, 0.0, frame.coordinates.x, frame.coordinates.y);
-        mesh->addVertex(frame.coordinates.x+frame.coordinates.w, -frame.coordinates.y, 0.0, frame.coordinates.x+frame.coordinates.w, frame.coordinates.y);
-        mesh->addVertex(frame.coordinates.x+frame.coordinates.w, -frame.coordinates.y - frame.coordinates.h, 0.0, frame.coordinates.x+frame.coordinates.w, frame.coordinates.y + frame.coordinates.h);
-        mesh->addVertex(frame.coordinates.x, -frame.coordinates.y - frame.coordinates.h, 0.0, frame.coordinates.x, frame.coordinates.y + frame.coordinates.h);
+        mesh->addVertexWithUV(frame.coordinates.x, -frame.coordinates.y, 0.0, frame.coordinates.x, frame.coordinates.y);
+        mesh->addVertexWithUV(frame.coordinates.x+frame.coordinates.w, -frame.coordinates.y, 0.0, frame.coordinates.x+frame.coordinates.w, frame.coordinates.y);
+        mesh->addVertexWithUV(frame.coordinates.x+frame.coordinates.w, -frame.coordinates.y - frame.coordinates.h, 0.0, frame.coordinates.x+frame.coordinates.w, frame.coordinates.y + frame.coordinates.h);
+        mesh->addVertexWithUV(frame.coordinates.x, -frame.coordinates.y - frame.coordinates.h, 0.0, frame.coordinates.x, frame.coordinates.y + frame.coordinates.h);
         mesh->addIndexedFace(offset+0,offset+1);
         mesh->addIndexedFace(offset+0,offset+1);
         mesh->addIndexedFace(offset+1,offset+2);
         mesh->addIndexedFace(offset+1,offset+2);
         mesh->addIndexedFace(offset+2,offset+3);
         mesh->addIndexedFace(offset+2,offset+3);
@@ -278,10 +278,6 @@ void SpriteSheetEditor::Update() {
 
 
     }
     }
     
     
-    
-    mesh->dirtyArrays();
-    meshSelected->dirtyArrays();
-    
 }
 }
 
 
 void SpriteSheetEditor::handleEvent(Event *event) {
 void SpriteSheetEditor::handleEvent(Event *event) {
@@ -1019,10 +1015,17 @@ void SpriteStateEditBar::refreshBar() {
             vertexColor = Color(1.0, 0.8, 0.0, 1.0);
             vertexColor = Color(1.0, 0.8, 0.0, 1.0);
         }
         }
         
         
-        meshTicks->addVertex(frameOffset, 0.0, 0.0, 0.0, 0.0)->vertexColor = vertexColor;
-        meshTicks->addVertex(frameOffset, 0.0-frameTickHeight, 0.0, 0.0, 1.0)->vertexColor = vertexColor;
-        meshTicks->addVertex(frameOffset+frameSize-frameGapSize, -frameTickHeight, 0.0, 1.0, 1.0)->vertexColor = vertexColor;
-        meshTicks->addVertex(frameOffset+frameSize-frameGapSize, 0.0, 0.0, 1.0, 0.0)->vertexColor = vertexColor;
+        meshTicks->addVertexWithUV(frameOffset, 0.0, 0.0, 0.0, 0.0);
+        meshTicks->addColor(vertexColor);
+        
+        meshTicks->addVertexWithUV(frameOffset, 0.0-frameTickHeight, 0.0, 0.0, 1.0);
+        meshTicks->addColor(vertexColor);
+        
+        meshTicks->addVertexWithUV(frameOffset+frameSize-frameGapSize, -frameTickHeight, 0.0, 1.0, 1.0);
+        meshTicks->addColor(vertexColor);
+        
+        meshTicks->addVertexWithUV(frameOffset+frameSize-frameGapSize, 0.0, 0.0, 1.0, 0.0);
+        meshTicks->addColor(vertexColor);
         
         
         
         
         meshTicks->addIndexedFace(offset+0,offset+1);
         meshTicks->addIndexedFace(offset+0,offset+1);
@@ -1047,10 +1050,10 @@ void SpriteStateEditBar::refreshBar() {
         
         
         if(drawIcon) {
         if(drawIcon) {
         
         
-            mesh->addVertex(frameOffset+iconOffset, -frameTickHeight-frameTickGap-iconOffset, 0.0, frame.coordinates.x, 1.0-frame.coordinates.y);
-            mesh->addVertex(frameOffset+iconOffset, -frameTickHeight-frameTickGap-iconFrameHeight-iconOffset, 0.0, frame.coordinates.x, 1.0-frame.coordinates.y  - frame.coordinates.h);
-            mesh->addVertex(frameOffset+iconFrameWidth+iconOffset, -frameTickHeight-frameTickGap-iconFrameHeight-iconOffset, 0.0, frame.coordinates.x+frame.coordinates.w, 1.0- frame.coordinates.y  - frame.coordinates.h);
-            mesh->addVertex(frameOffset+iconFrameWidth+iconOffset, -frameTickHeight-frameTickGap-iconOffset, 0.0, frame.coordinates.x+frame.coordinates.w, 1.0-frame.coordinates.y);
+            mesh->addVertexWithUV(frameOffset+iconOffset, -frameTickHeight-frameTickGap-iconOffset, 0.0, frame.coordinates.x, 1.0-frame.coordinates.y);
+            mesh->addVertexWithUV(frameOffset+iconOffset, -frameTickHeight-frameTickGap-iconFrameHeight-iconOffset, 0.0, frame.coordinates.x, 1.0-frame.coordinates.y  - frame.coordinates.h);
+            mesh->addVertexWithUV(frameOffset+iconFrameWidth+iconOffset, -frameTickHeight-frameTickGap-iconFrameHeight-iconOffset, 0.0, frame.coordinates.x+frame.coordinates.w, 1.0- frame.coordinates.y  - frame.coordinates.h);
+            mesh->addVertexWithUV(frameOffset+iconFrameWidth+iconOffset, -frameTickHeight-frameTickGap-iconOffset, 0.0, frame.coordinates.x+frame.coordinates.w, 1.0-frame.coordinates.y);
             
             
             mesh->addIndexedFace(offsetIcon+0,offsetIcon+1);
             mesh->addIndexedFace(offsetIcon+0,offsetIcon+1);
             mesh->addIndexedFace(offsetIcon+1,offsetIcon+2);
             mesh->addIndexedFace(offsetIcon+1,offsetIcon+2);
@@ -1068,10 +1071,17 @@ void SpriteStateEditBar::refreshBar() {
             bgFrameColor = Color(1.0, 0.5, 0.5, 1.0);
             bgFrameColor = Color(1.0, 0.5, 0.5, 1.0);
         }
         }
         
         
-        meshBg->addVertex(frameOffset, -frameTickHeight-frameTickGap, 0.0, 0.0, 0.0)->vertexColor = bgFrameColor;
-        meshBg->addVertex(frameOffset, -frameTickHeight-frameTickGap-frameHeight, 0.0, 0.0, 1.0)->vertexColor = bgFrameColor;
-        meshBg->addVertex(frameOffset+frameSize-gapSize, -frameTickHeight-frameTickGap-frameHeight, 0.0, 1.0, 1.0)->vertexColor = bgFrameColor;
-        meshBg->addVertex(frameOffset+frameSize-gapSize, -frameTickHeight-frameTickGap, 0.0, 1.0, 0.0)->vertexColor = bgFrameColor;
+        meshBg->addVertexWithUV(frameOffset, -frameTickHeight-frameTickGap, 0.0, 0.0, 0.0);
+        meshBg->addColor(bgFrameColor);
+        
+        meshBg->addVertexWithUV(frameOffset, -frameTickHeight-frameTickGap-frameHeight, 0.0, 0.0, 1.0);
+        meshBg->addColor(bgFrameColor);
+        
+        meshBg->addVertexWithUV(frameOffset+frameSize-gapSize, -frameTickHeight-frameTickGap-frameHeight, 0.0, 1.0, 1.0);
+        meshBg->addColor(bgFrameColor);
+        
+        meshBg->addVertexWithUV(frameOffset+frameSize-gapSize, -frameTickHeight-frameTickGap, 0.0, 1.0, 0.0);
+        meshBg->addColor(bgFrameColor);
 
 
         
         
         meshBg->addIndexedFace(offset+0,offset+1);
         meshBg->addIndexedFace(offset+0,offset+1);
@@ -1086,10 +1096,10 @@ void SpriteStateEditBar::refreshBar() {
         Number gripOffset = (frameHeight-24.0) / 2.0;
         Number gripOffset = (frameHeight-24.0) / 2.0;
         
         
         if(drawGrip) {
         if(drawGrip) {
-            meshGrips->addVertex(frameOffset+frameSize-gapSize-gripWidth, -frameTickHeight-frameTickGap-gripOffset, 0.0, 0.0, 0.0);
-            meshGrips->addVertex(frameOffset+frameSize-gapSize-gripWidth, -frameTickHeight-frameTickGap-gripHeight-gripOffset, 0.0, 0.0, 1.0);
-            meshGrips->addVertex(frameOffset+frameSize-gapSize, -frameTickHeight-frameTickGap-gripHeight-gripOffset, 0.0, 1.0, 1.0);
-            meshGrips->addVertex(frameOffset+frameSize-gapSize, -frameTickHeight-frameTickGap-gripOffset, 0.0, 1.0, 0.0);
+            meshGrips->addVertexWithUV(frameOffset+frameSize-gapSize-gripWidth, -frameTickHeight-frameTickGap-gripOffset, 0.0, 0.0, 0.0);
+            meshGrips->addVertexWithUV(frameOffset+frameSize-gapSize-gripWidth, -frameTickHeight-frameTickGap-gripHeight-gripOffset, 0.0, 0.0, 1.0);
+            meshGrips->addVertexWithUV(frameOffset+frameSize-gapSize, -frameTickHeight-frameTickGap-gripHeight-gripOffset, 0.0, 1.0, 1.0);
+            meshGrips->addVertexWithUV(frameOffset+frameSize-gapSize, -frameTickHeight-frameTickGap-gripOffset, 0.0, 1.0, 0.0);
             
             
             meshGrips->addIndexedFace(offsetGrip+0,offsetGrip+1);
             meshGrips->addIndexedFace(offsetGrip+0,offsetGrip+1);
             meshGrips->addIndexedFace(offsetGrip+1,offsetGrip+2);
             meshGrips->addIndexedFace(offsetGrip+1,offsetGrip+2);
@@ -1103,10 +1113,6 @@ void SpriteStateEditBar::refreshBar() {
         
         
     }
     }
     
     
-    mesh->dirtyArrays();
-    meshBg->dirtyArrays();
-    meshTicks->dirtyArrays();
-    
     scroller->setContentSize(frameOffset+frameSize, getHeight());
     scroller->setContentSize(frameOffset+frameSize, getHeight());
 }
 }
 
 
@@ -1721,18 +1727,16 @@ void SpritePreview::Update() {
     frame.coordinates.w = bBoxNorm.x * spriteScale;
     frame.coordinates.w = bBoxNorm.x * spriteScale;
     frame.coordinates.h = bBoxNorm.y * spriteScale;
     frame.coordinates.h = bBoxNorm.y * spriteScale;
     
     
-    bbBoxMesh->addVertex(-bBox.x * 0.5, bBox.y * 0.5, 0.0, frame.coordinates.x, frame.coordinates.y);
-    bbBoxMesh->addVertex((-bBox.x * 0.5)+bBox.x, bBox.y * 0.5, 0.0, frame.coordinates.x+frame.coordinates.w, frame.coordinates.y);
-    bbBoxMesh->addVertex((-bBox.x * 0.5)+bBox.x, bBox.y * 0.5 - bBox.y, 0.0, frame.coordinates.x+frame.coordinates.w, frame.coordinates.y + frame.coordinates.h);
-    bbBoxMesh->addVertex(-bBox.x * 0.5, bBox.y * 0.5 - bBox.y, 0.0, frame.coordinates.x, frame.coordinates.y + frame.coordinates.h);
+    bbBoxMesh->addVertexWithUV(-bBox.x * 0.5, bBox.y * 0.5, 0.0, frame.coordinates.x, frame.coordinates.y);
+    bbBoxMesh->addVertexWithUV((-bBox.x * 0.5)+bBox.x, bBox.y * 0.5, 0.0, frame.coordinates.x+frame.coordinates.w, frame.coordinates.y);
+    bbBoxMesh->addVertexWithUV((-bBox.x * 0.5)+bBox.x, bBox.y * 0.5 - bBox.y, 0.0, frame.coordinates.x+frame.coordinates.w, frame.coordinates.y + frame.coordinates.h);
+    bbBoxMesh->addVertexWithUV(-bBox.x * 0.5, bBox.y * 0.5 - bBox.y, 0.0, frame.coordinates.x, frame.coordinates.y + frame.coordinates.h);
     
     
     bbBoxMesh->addIndexedFace(0,1);
     bbBoxMesh->addIndexedFace(0,1);
     bbBoxMesh->addIndexedFace(1,2);
     bbBoxMesh->addIndexedFace(1,2);
     bbBoxMesh->addIndexedFace(2,3);
     bbBoxMesh->addIndexedFace(2,3);
     bbBoxMesh->addIndexedFace(3,0);
     bbBoxMesh->addIndexedFace(3,0);
     
     
-    bbBoxMesh->dirtyArrays();
-    
     sprite->setScale(spriteScale, spriteScale, 1.0);
     sprite->setScale(spriteScale, spriteScale, 1.0);
 
 
 }
 }

+ 0 - 3
IDE/Contents/Source/TransformGizmo.cpp

@@ -265,7 +265,6 @@ TransformGizmo::TransformGizmo(Scene *targetScene, Camera *targetCamera) : Entit
 	yLine = new SceneMesh(Mesh::LINE_MESH);
 	yLine = new SceneMesh(Mesh::LINE_MESH);
 	yLine->getMesh()->addVertex(0.0, 0.0, 0.0);
 	yLine->getMesh()->addVertex(0.0, 0.0, 0.0);
 	yLine->getMesh()->addVertex(0.0, 1.0, 0.0);
 	yLine->getMesh()->addVertex(0.0, 1.0, 0.0);
-	yLine->getMesh()->dirtyArrays();
 	yLine->depthTest = false;
 	yLine->depthTest = false;
 	yLine->setColor(0.0, 1.0, 0.0, 1.0);
 	yLine->setColor(0.0, 1.0, 0.0, 1.0);
     yLine->setLocalBoundingBox(yLine->getMesh()->calculateBBox());
     yLine->setLocalBoundingBox(yLine->getMesh()->calculateBBox());
@@ -275,7 +274,6 @@ TransformGizmo::TransformGizmo(Scene *targetScene, Camera *targetCamera) : Entit
 	xLine = new SceneMesh(Mesh::LINE_MESH);
 	xLine = new SceneMesh(Mesh::LINE_MESH);
 	xLine->getMesh()->addVertex(0.0, 0.0, 0.0);
 	xLine->getMesh()->addVertex(0.0, 0.0, 0.0);
 	xLine->getMesh()->addVertex(1.0, 0.0, 0.0);
 	xLine->getMesh()->addVertex(1.0, 0.0, 0.0);
-	xLine->getMesh()->dirtyArrays();
 	xLine->depthTest = false;
 	xLine->depthTest = false;
 	xLine->setColor(1.0, 0.0, 0.0, 1.0);
 	xLine->setColor(1.0, 0.0, 0.0, 1.0);
     xLine->setLocalBoundingBox(xLine->getMesh()->calculateBBox());
     xLine->setLocalBoundingBox(xLine->getMesh()->calculateBBox());
@@ -285,7 +283,6 @@ TransformGizmo::TransformGizmo(Scene *targetScene, Camera *targetCamera) : Entit
 	zLine = new SceneMesh(Mesh::LINE_MESH);
 	zLine = new SceneMesh(Mesh::LINE_MESH);
 	zLine->getMesh()->addVertex(0.0, 0.0, 0.0);
 	zLine->getMesh()->addVertex(0.0, 0.0, 0.0);
 	zLine->getMesh()->addVertex(0.0, 0.0, 1.0);
 	zLine->getMesh()->addVertex(0.0, 0.0, 1.0);
-	zLine->getMesh()->dirtyArrays();
 	zLine->depthTest = false;
 	zLine->depthTest = false;
 	zLine->setColor(0.0, 0.0, 1.0, 1.0);
 	zLine->setColor(0.0, 0.0, 1.0, 1.0);
     zLine->setLocalBoundingBox(zLine->getMesh()->calculateBBox());
     zLine->setLocalBoundingBox(zLine->getMesh()->calculateBBox());

+ 3 - 2
Modules/Contents/3DPhysics/Source/PolyCollisionSceneEntity.cpp

@@ -131,8 +131,9 @@ btCollisionShape *CollisionEntity::createCollisionShape(Entity *entity, int type
 			if(sceneMesh != NULL) {
 			if(sceneMesh != NULL) {
 				btConvexHullShape *hullShape = new btConvexHullShape();
 				btConvexHullShape *hullShape = new btConvexHullShape();
                 Mesh *mesh = sceneMesh->getMesh();
                 Mesh *mesh = sceneMesh->getMesh();
-				for(int i=0; i < mesh->getVertexCount(); i++) {
-                    hullShape->addPoint(btVector3((btScalar)mesh->getVertex(i)->x, (btScalar)mesh->getVertex(i)->y,(btScalar)mesh->getVertex(i)->z));
+				for(int i=0; i < mesh->vertexPositionArray.data.size()-2; i += 3) {
+                    
+                    hullShape->addPoint(btVector3((btScalar)mesh->vertexPositionArray.data[i], (btScalar)mesh->vertexPositionArray.data[i+1],mesh->vertexPositionArray.data[i+2]));
 				}				
 				}				
 				collisionShape = hullShape;
 				collisionShape = hullShape;
 				
 				

+ 12 - 11
Modules/Contents/UI/Source/PolyUIColorBox.cpp

@@ -65,12 +65,11 @@ UIColorPicker::UIColorPicker() : UIWindow(L"", 300, 240) {
 	mainColorRect->setHeight(mainFrame->getWidth());
 	mainColorRect->setHeight(mainFrame->getWidth());
 	mainColorRect->setDepth(0.001);
 	mainColorRect->setDepth(0.001);
 		
 		
-	mainColorRect->getMesh()->addVertex(-mainFrame->getWidth()/2,mainFrame->getHeight()/2.0,0,0,0);
-	mainColorRect->getMesh()->addVertex(mainFrame->getWidth()/2,mainFrame->getHeight()/2.0,0, 1, 0);
-	mainColorRect->getMesh()->addVertex(mainFrame->getWidth()/2,-mainFrame->getHeight()/2.0,0, 1, 1);
-	mainColorRect->getMesh()->addVertex(-mainFrame->getWidth()/2,-mainFrame->getHeight()/2.0,0,0,1);
+	mainColorRect->getMesh()->addVertexWithUV(-mainFrame->getWidth()/2,mainFrame->getHeight()/2.0,0,0,0);
+	mainColorRect->getMesh()->addVertexWithUV(mainFrame->getWidth()/2,mainFrame->getHeight()/2.0,0, 1, 0);
+	mainColorRect->getMesh()->addVertexWithUV(mainFrame->getWidth()/2,-mainFrame->getHeight()/2.0,0, 1, 1);
+	mainColorRect->getMesh()->addVertexWithUV(-mainFrame->getWidth()/2,-mainFrame->getHeight()/2.0,0,0,1);
 	
 	
-	mainColorRect->getMesh()->dirtyArrays();
 	mainColorRect->backfaceCulled = false;	
 	mainColorRect->backfaceCulled = false;	
 
 
 	mainColorRect->setAnchorPoint(-1.0, -1.0, 0.0);
 	mainColorRect->setAnchorPoint(-1.0, -1.0, 0.0);
@@ -266,12 +265,14 @@ void UIColorPicker::updateSelectedColor(bool updateTextFields, bool updateHue, b
 	hueCol.setColorHSV(currentH, 1.0, 1.0);
 	hueCol.setColorHSV(currentH, 1.0, 1.0);
 	hueCol.a = colorAlpha;
 	hueCol.a = colorAlpha;
 
 
-	mainColorRect->getMesh()->getVertex(0)->vertexColor = Color((Number)1,(Number)1,(Number)1,colorAlpha);
-	mainColorRect->getMesh()->getVertex(1)->vertexColor = hueCol;
-	mainColorRect->getMesh()->getVertex(2)->vertexColor = Color((Number)0,(Number)0,(Number)0,colorAlpha);
-	mainColorRect->getMesh()->getVertex(3)->vertexColor = Color((Number)0,(Number)0,(Number)0,colorAlpha);
-	mainColorRect->getMesh()->arrayDirtyMap[RenderDataArray::COLOR_DATA_ARRAY] = true;				
-			
+    
+    mainColorRect->getMesh()->vertexColorArray.data.clear();
+    
+    mainColorRect->getMesh()->addColor(Color((Number)1,(Number)1,(Number)1,colorAlpha));
+    mainColorRect->getMesh()->addColor(hueCol);
+    mainColorRect->getMesh()->addColor(Color((Number)0,(Number)0,(Number)0,colorAlpha));
+    mainColorRect->getMesh()->addColor(Color((Number)0,(Number)0,(Number)0,colorAlpha));
+    
 	if(updateHue) {
 	if(updateHue) {
 		hueSelector->setPositionY(hueFrame->getPosition().y + hueFrame->getHeight() - ((currentH/360.0) * hueFrame->getHeight()));
 		hueSelector->setPositionY(hueFrame->getPosition().y + hueFrame->getHeight() - ((currentH/360.0) * hueFrame->getHeight()));
 		lastHueSelectorPosition = hueSelector->getPosition().y;
 		lastHueSelectorPosition = hueSelector->getPosition().y;

+ 28 - 33
Modules/Contents/UI/Source/PolyUIElement.cpp

@@ -168,7 +168,7 @@ UIRect::UIRect(Number width, Number height) : UIElement() {
 }
 }
 
 
 void UIRect::setImageCoordinates(Number x, Number y, Number width, Number height, Number imageScale) {
 void UIRect::setImageCoordinates(Number x, Number y, Number width, Number height, Number imageScale) {
-    Vertex *vertex;
+
 	Number pixelSizeX = 1/imageWidth;
 	Number pixelSizeX = 1/imageWidth;
 	Number pixelSizeY = 1/imageHeight;
 	Number pixelSizeY = 1/imageHeight;
 
 
@@ -183,24 +183,21 @@ void UIRect::setImageCoordinates(Number x, Number y, Number width, Number height
 	Number wFloat = width * pixelSizeX * imageScale;
 	Number wFloat = width * pixelSizeX * imageScale;
 	Number hFloat = height * pixelSizeY * imageScale;
 	Number hFloat = height * pixelSizeY * imageScale;
 
 
-	vertex = rectMesh->getVertex(0);
-	vertex->set(-whalf,-hhalf,0);
-	vertex->setTexCoord(xFloat, (1.0-yFloat) - hFloat);
+    rectMesh->vertexPositionArray.data.clear();
+    rectMesh->vertexTexCoordArray.data.clear();
+    
+	rectMesh->addVertex(-whalf,-hhalf,0);
+	rectMesh->addTexCoord(xFloat, (1.0-yFloat) - hFloat);
 
 
-	vertex = rectMesh->getVertex(1);
-	vertex->set(-whalf+width,-hhalf,0);
-	vertex->setTexCoord(xFloat + wFloat, (1.0-yFloat) - hFloat);
+	rectMesh->addVertex(-whalf+width,-hhalf,0);
+	rectMesh->addTexCoord(xFloat + wFloat, (1.0-yFloat) - hFloat);
 
 
-	vertex = rectMesh->getVertex(2);
-	vertex->set(-whalf+width,-hhalf+height,0);
-	vertex->setTexCoord(xFloat + wFloat, 1.0-yFloat);
+	rectMesh->addVertex(-whalf+width,-hhalf+height,0);
+	rectMesh->addTexCoord(xFloat + wFloat, 1.0-yFloat);
 
 
-	vertex = rectMesh->getVertex(3);
-	vertex->set(-whalf,-hhalf+height,0);	
-	vertex->setTexCoord(xFloat, 1.0-yFloat);
+	rectMesh->addVertex(-whalf,-hhalf+height,0);
+	rectMesh->addTexCoord(xFloat, 1.0-yFloat);
 
 
-	rectMesh->arrayDirtyMap[RenderDataArray::VERTEX_DATA_ARRAY] = true;
-	rectMesh->arrayDirtyMap[RenderDataArray::TEXCOORD_DATA_ARRAY] = true;	
 	rebuildTransformMatrix();
 	rebuildTransformMatrix();
 	matrixDirty = true;
 	matrixDirty = true;
 }
 }
@@ -224,10 +221,10 @@ void UIRect::initRect(Number width, Number height) {
 	Number whalf = width/2.0f;
 	Number whalf = width/2.0f;
 	Number hhalf = height/2.0f;
 	Number hhalf = height/2.0f;
 				
 				
-	rectMesh->addVertex(-whalf,-hhalf,0,0,0);
-	rectMesh->addVertex(-whalf+width,-hhalf,0, 1, 0);
-	rectMesh->addVertex(-whalf+width,-hhalf+height,0, 1, 1);
-	rectMesh->addVertex(-whalf,-hhalf+height,0,0,1);
+	rectMesh->addVertexWithUV(-whalf,-hhalf,0,0,0);
+	rectMesh->addVertexWithUV(-whalf+width,-hhalf,0, 1, 0);
+	rectMesh->addVertexWithUV(-whalf+width,-hhalf+height,0, 1, 1);
+	rectMesh->addVertexWithUV(-whalf,-hhalf+height,0,0,1);
 }
 }
 
 
 UIRect::~UIRect() {
 UIRect::~UIRect() {
@@ -250,9 +247,11 @@ Texture *UIRect::getTexture() {
 void UIRect::Render() {
 void UIRect::Render() {
 	renderer->clearShader();
 	renderer->clearShader();
 	renderer->setTexture(texture);
 	renderer->setTexture(texture);
-	renderer->pushDataArrayForMesh(rectMesh, RenderDataArray::VERTEX_DATA_ARRAY);
-	renderer->pushDataArrayForMesh(rectMesh, RenderDataArray::TEXCOORD_DATA_ARRAY);	
-	renderer->drawArrays(Mesh::QUAD_MESH);
+    
+    renderer->pushRenderDataArray(&rectMesh->vertexPositionArray);
+    renderer->pushRenderDataArray(&rectMesh->vertexTexCoordArray);
+
+	renderer->drawArrays(Mesh::QUAD_MESH, NULL);
 }
 }
 
 
 void UIRect::Resize(Number width, Number height) {
 void UIRect::Resize(Number width, Number height) {
@@ -262,17 +261,13 @@ void UIRect::Resize(Number width, Number height) {
 
 
 	Number whalf = width/2.0f;
 	Number whalf = width/2.0f;
 	Number hhalf = height/2.0f;
 	Number hhalf = height/2.0f;
-	Vertex *vertex;
-
-	vertex = rectMesh->getVertex(0);
-	vertex->set(-whalf,-hhalf,0);			
-	vertex = rectMesh->getVertex(1);
-	vertex->set(-whalf+width,-hhalf,0);			
-	vertex = rectMesh->getVertex(2);
-	vertex->set(-whalf+width,-hhalf+height,0);			
-	vertex = rectMesh->getVertex(3);
-	vertex->set(-whalf,-hhalf+height,0);				
-	rectMesh->arrayDirtyMap[RenderDataArray::VERTEX_DATA_ARRAY] = true;	
+
+    rectMesh->vertexPositionArray.data.clear();
+
+    rectMesh->addVertex(-whalf,-hhalf,0);
+    rectMesh->addVertex(-whalf+width,-hhalf,0);
+    rectMesh->addVertex(-whalf+width,-hhalf+height,0);
+    rectMesh->addVertex(-whalf,-hhalf+height,0);
 }
 }
 
 
 UIImage::UIImage(String imagePath, int width, int height) : UIRect(imagePath, width, height) {
 UIImage::UIImage(String imagePath, int width, int height) : UIRect(imagePath, width, height) {

+ 37 - 22
Tools/Contents/polyimport/Source/polyimport.cpp

@@ -106,36 +106,44 @@ void addToMesh(String prefix, Polycode::Mesh *tmesh, const struct aiScene *sc, c
 		//apply_material(sc->mMaterials[mesh->mMaterialIndex]);
 		//apply_material(sc->mMaterials[mesh->mMaterialIndex]);
         
         
 		for (t = 0; t < mesh->mNumVertices; ++t) {
 		for (t = 0; t < mesh->mNumVertices; ++t) {
-            Vertex *vertex = new Vertex();
+
+            Vector3 vPosition;
+            
             int index = t;
             int index = t;
             if(mesh->mColors[0] != NULL) {
             if(mesh->mColors[0] != NULL) {
-                vertex->vertexColor.setColorRGBA(mesh->mColors[0][index].r, mesh->mColors[0][index].g, mesh->mColors[0][index].b, mesh->mColors[0][index].a);
+                tmesh->addColor(mesh->mColors[0][index].r, mesh->mColors[0][index].g, mesh->mColors[0][index].b, mesh->mColors[0][index].a);
             }
             }
 
 
             if(mesh->mTangents != NULL)  {
             if(mesh->mTangents != NULL)  {
-                if(swapZY)
-                    vertex->tangent = Vector3(mesh->mTangents[index].x, mesh->mTangents[index].z, -mesh->mTangents[index].y);
-                else
-                    vertex->tangent = Vector3(mesh->mTangents[index].x, mesh->mTangents[index].y, mesh->mTangents[index].z);
+                if(swapZY) {
+                    tmesh->addTangent(mesh->mTangents[index].x, mesh->mTangents[index].z, -mesh->mTangents[index].y);
+                } else {
+                    tmesh->addTangent(mesh->mTangents[index].x, mesh->mTangents[index].y, mesh->mTangents[index].z);
+                }
             }
             }
 
 
             if(mesh->mNormals != NULL)  {
             if(mesh->mNormals != NULL)  {
-                if(swapZY)
-                    vertex->setNormal(mesh->mNormals[index].x, mesh->mNormals[index].z, -mesh->mNormals[index].y);
-                else
-                    vertex->setNormal(mesh->mNormals[index].x, mesh->mNormals[index].y, mesh->mNormals[index].z);
+                if(swapZY) {
+                    tmesh->addNormal(mesh->mNormals[index].x, mesh->mNormals[index].z, -mesh->mNormals[index].y);
+                } else {
+                    tmesh->addNormal(mesh->mNormals[index].x, mesh->mNormals[index].y, mesh->mNormals[index].z);
+                }
             }
             }
 
 
             if(mesh->HasTextureCoords(0))
             if(mesh->HasTextureCoords(0))
             {
             {
-                vertex->setTexCoord(mesh->mTextureCoords[0][index].x, mesh->mTextureCoords[0][index].y);
+                tmesh->addTexCoord(mesh->mTextureCoords[0][index].x, mesh->mTextureCoords[0][index].y);
             }
             }
 
 
             if(mesh->HasTextureCoords(1))
             if(mesh->HasTextureCoords(1))
             {
             {
-                vertex->setSecondaryTexCoord(mesh->mTextureCoords[1][index].x, mesh->mTextureCoords[1][index].y);
+                tmesh->addTexCoord2(mesh->mTextureCoords[1][index].x, mesh->mTextureCoords[1][index].y);
             }
             }
 
 
+            int numAssignments = 0;
+            
+            float weights[4] = {0.0, 0.0, 0.0, 0.0};
+            unsigned int boneIds[4] = {0, 0, 0 ,0};
             
             
             for( unsigned int a = 0; a < mesh->mNumBones; a++) {
             for( unsigned int a = 0; a < mesh->mNumBones; a++) {
                 aiBone* bone = mesh->mBones[a];
                 aiBone* bone = mesh->mBones[a];
@@ -143,29 +151,36 @@ void addToMesh(String prefix, Polycode::Mesh *tmesh, const struct aiScene *sc, c
 
 
                 for( unsigned int b = 0; b < bone->mNumWeights; b++) {
                 for( unsigned int b = 0; b < bone->mNumWeights; b++) {
                     if(bone->mWeights[b].mVertexId == index) {
                     if(bone->mWeights[b].mVertexId == index) {
-                        vertex->addBoneAssignment(boneIndex, bone->mWeights[b].mWeight);
+                        if(numAssignments < 4) {
+                            weights[numAssignments] = bone->mWeights[b].mWeight;
+                            boneIds[numAssignments] = boneIndex;
+                            numAssignments++;
+                        }
                         hasWeights = true;
                         hasWeights = true;
                     }
                     }
                 }
                 }
             }
             }
+            
+            
+            tmesh->addBoneAssignments(weights[0], boneIds[0], weights[1], boneIds[1], weights[2], boneIds[2], weights[3], boneIds[3]);
 
 
             if(swapZY) {
             if(swapZY) {
-					vertex->set(mesh->mVertices[index].x, mesh->mVertices[index].z, -mesh->mVertices[index].y);
+					vPosition.set(mesh->mVertices[index].x, mesh->mVertices[index].z, -mesh->mVertices[index].y);
             } else {
             } else {
-                vertex->set(mesh->mVertices[index].x, mesh->mVertices[index].y, mesh->mVertices[index].z);
+                vPosition.set(mesh->mVertices[index].x, mesh->mVertices[index].y, mesh->mVertices[index].z);
             }
             }
             
             
-            if(fabs(vertex->x) > bBox.x) {
-                bBox.x = fabs(vertex->x);
+            if(fabs(vPosition.x) > bBox.x) {
+                bBox.x = fabs(vPosition.x);
             }
             }
-            if(fabs(vertex->y) > bBox.y) {
-                bBox.y = fabs(vertex->y);
+            if(fabs(vPosition.y) > bBox.y) {
+                bBox.y = fabs(vPosition.y);
             }
             }
-            if(fabs(vertex->z) > bBox.z) {
-                bBox.z = fabs(vertex->z);
+            if(fabs(vPosition.z) > bBox.z) {
+                bBox.z = fabs(vPosition.z);
             }
             }
             
             
-            tmesh->addVertex(vertex);
+            tmesh->addVertex(vPosition.x, vPosition.y, vPosition.z);
 		}
 		}
         
         
 
 

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است