| 
     
      
      
      From: <Ult...@us...> - 2009-03-14 09:27:44
       
   | 
Revision: 1091
          http://opengate.svn.sourceforge.net/opengate/?rev=1091&view=rev
Author:   Ultrasick
Date:     2009-03-14 09:27:32 +0000 (Sat, 14 Mar 2009)
Log Message:
-----------
removing the +/- 10 pixel drawing. I will use something smarter in the future
Modified Paths:
--------------
    branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/edit_the_face.py
    branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/textures.py
Modified: branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/edit_the_face.py
===================================================================
--- branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/edit_the_face.py	2009-03-14 09:11:26 UTC (rev 1090)
+++ branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/edit_the_face.py	2009-03-14 09:27:32 UTC (rev 1091)
@@ -210,11 +210,11 @@
 			x_end = int(round(screen.geometry.get_distance(plane['vectors'][0]) * 100 * resolution_texture_map * safety_factor))
 			y_end = int(round(screen.geometry.get_distance(plane['vectors'][1]) * 100 * resolution_texture_map * safety_factor))
 
-			for x_pixel_number in range(-10, x_end + 10):
+			for x_pixel_number in range(0, x_end):
 				# get the relative x coordinate
 				x_relative = x_pixel_number/x_end
 
-				for y_pixel_number in range(-10, y_end * (1 - x_relative) + 10):
+				for y_pixel_number in range(0, y_end * (1 - x_relative)):
 					# get the relative y coordinate
 					y_relative = y_pixel_number/y_end
 
Modified: branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/textures.py
===================================================================
--- branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/textures.py	2009-03-14 09:11:26 UTC (rev 1090)
+++ branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/textures.py	2009-03-14 09:27:32 UTC (rev 1091)
@@ -39,11 +39,11 @@
 
 		textures = source.get_model().textures
 
-		category_name = textures[texture[0]]['name']
-		texture_name = textures[texture[0]]['textures'][texture[1]]
+		self.category_name = textures[texture[0]]['name']
+		self.texture_name = textures[texture[0]]['textures'][texture[1]]
 
 		# update the preview image
-		self.preview.set_from_file(path[0] + '/graphic/textures/preview/' + category_name + '/' + texture_name + '.png')
+		self.preview.set_from_file(path[0] + '/graphic/textures/preview/' + self.category_name + '/' + self.texture_name + '.png')
 
 screen.texture_preview = texture_preview(table)
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
     
      
      
      From: <Ult...@us...> - 2009-03-14 10:08:21
       
   | 
Revision: 1092
          http://opengate.svn.sourceforge.net/opengate/?rev=1092&view=rev
Author:   Ultrasick
Date:     2009-03-14 10:08:03 +0000 (Sat, 14 Mar 2009)
Log Message:
-----------
adding function to add and remove textures to a face
Modified Paths:
--------------
    branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/edit_the_face.py
    branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/textures.py
Modified: branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/edit_the_face.py
===================================================================
--- branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/edit_the_face.py	2009-03-14 09:27:32 UTC (rev 1091)
+++ branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/edit_the_face.py	2009-03-14 10:08:03 UTC (rev 1092)
@@ -214,7 +214,7 @@
 				# get the relative x coordinate
 				x_relative = x_pixel_number/x_end
 
-				for y_pixel_number in range(0, y_end * (1 - x_relative)):
+				for y_pixel_number in range(0, y_end * (1 - x_relative) + 10):
 					# get the relative y coordinate
 					y_relative = y_pixel_number/y_end
 
Modified: branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/textures.py
===================================================================
--- branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/textures.py	2009-03-14 09:27:32 UTC (rev 1091)
+++ branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/textures.py	2009-03-14 10:08:03 UTC (rev 1092)
@@ -27,61 +27,55 @@
 
 	def refresh(self, source):
 		texture = source.get_cursor()[0]
+		textures = source.get_model().textures
 
-		try:
-			texture[1]
-		except:
-			# clear the preview image
-			self.preview.clear()
+		if '-' in textures[texture[0]]:
+			temp = textures[texture[0]].split(' - ')
 
-			# a category has been selected, return
-			return
+			self.category_name = temp[0]
+			self.texture_name = temp[1]
+		else:
+			try:
+				texture[1]
+			except:
+				# clear the preview image
+				self.preview.clear()
 
-		textures = source.get_model().textures
+				# a category has been selected, return
+				return
 
-		self.category_name = textures[texture[0]]['name']
-		self.texture_name = textures[texture[0]]['textures'][texture[1]]
+			self.category_name = textures[texture[0]]['name']
+			self.texture_name = textures[texture[0]]['textures'][texture[1]]
 
 		# update the preview image
 		self.preview.set_from_file(path[0] + '/graphic/textures/preview/' + self.category_name + '/' + self.texture_name + '.png')
 
 screen.texture_preview = texture_preview(table)
 
-class textures_available:
+class textures_used:
 	def __init__(self, parent):
+		# grab the face
+		self.face = model['faces'][window.face_number]
+
 		# create a TreeStore with one string column to use as the model
 		self.treestore = gtk.TreeStore(str)
 
 		# create an array for the textures
 		self.treestore.textures = []
 
-		# add the texture categories and the textures
-		for category_name, category_textures in textures.items():
-			category = self.treestore.append(none, [category_name])
-
-			# insert the category name in the array
-			self.treestore.textures.append({'name' : category_name, 'textures' : []})
-
-			# get the category id
-			category_id = len(self.treestore.textures) - 1
-
-			for texture_name, texture_function in category_textures.items():
-				self.treestore.append(category, [texture_name])
-
-				# add the texture to the array
-				self.treestore.textures[category_id]['textures'].append(texture_name)
-
 		# create the TreeView
 		self.treeview = gtk.TreeView(self.treestore)
-		self.treeview.set_size_request(-1, 100)
-		parent.attach(self.treeview, 0, 1, 1, 2, xpadding = 3)
+		self.treeview.set_size_request(-1, 155)
+		parent.attach(self.treeview, 0, 1, 2, 3, xpadding = 3)
+		self.treeview.set_reorderable(true)
 		self.treeview.show()
 
-		# connect the function to refresh the preview image
+		# connect the functions
 		self.treeview.connect('cursor-changed', screen.texture_preview.refresh)
+		self.treeview.connect('row-activated', self.remove)
 
-		# show "available textures:"
-		self.tvcolumn = gtk.TreeViewColumn('available textures:')
+		# show "used textures:"
+		self.tvcolumn = gtk.TreeViewColumn('used textures:')
 		self.treeview.append_column(self.tvcolumn)
 
 		# create a CellRendererText to render the data
@@ -89,16 +83,51 @@
 		self.tvcolumn.pack_start(self.cell, true)
 		self.tvcolumn.add_attribute(self.cell, 'text', 0)
 
-	def add(self, widget):
-		pass
+		# refresh the list
+		self.refresh()
 
-screen.textures_available = textures_available(table)
+	def add(self, nonsence1 = none, nonsence2 = none, nonsence3 = none):
+		try:
+			screen.texture_preview.category_name
+		except:
+			# no texture has been selected jet, return
+			return
 
-class textures_used:
+		# add the texture
+		self.face['textures'].append(screen.texture_preview.category_name + ' - ' + screen.texture_preview.texture_name)
+
+		# refresh the list
+		self.refresh()
+
+	def remove(self, nonsence1 = none, nonsence2 = none, nonsence3 = none):
+		try:
+			screen.texture_preview.category_name
+		except:
+			# no texture has been selected jet, return
+			return
+
+		if (screen.texture_preview.category_name + ' - ' + screen.texture_preview.texture_name) in self.face['textures']:
+			# remove the texture
+			del(self.face['textures'][self.face['textures'].index(screen.texture_preview.category_name + ' - ' + screen.texture_preview.texture_name)])
+
+			# refresh the list
+			self.refresh()
+
+	def refresh(self):
+		# clear the list
+		self.treestore.clear()
+
+		# add the texture categories and the textures
+		for texture in self.face['textures']:
+			self.treestore.append(none, [texture])
+
+			# add the texture to the array
+			self.treestore.textures.append(texture)
+
+screen.textures_used = textures_used(table)
+
+class textures_available:
 	def __init__(self, parent):
-		# grab the face
-		self.face = model['faces'][window.face_number]
-
 		# create a TreeStore with one string column to use as the model
 		self.treestore = gtk.TreeStore(str)
 
@@ -106,7 +135,7 @@
 		self.treestore.textures = []
 
 		# add the texture categories and the textures
-		for category_name, category_textures in self.face['textures'].items():
+		for category_name, category_textures in textures.items():
 			category = self.treestore.append(none, [category_name])
 
 			# insert the category name in the array
@@ -123,16 +152,16 @@
 
 		# create the TreeView
 		self.treeview = gtk.TreeView(self.treestore)
-		self.treeview.set_size_request(-1, 100)
-		parent.attach(self.treeview, 0, 1, 2, 3, xpadding = 3)
-		self.treeview.set_reorderable(true)
+		self.treeview.set_size_request(-1, 155)
+		parent.attach(self.treeview, 0, 1, 1, 2, xpadding = 3)
 		self.treeview.show()
 
-		# connect the function to refresh the preview image
+		# connect the functions
 		self.treeview.connect('cursor-changed', screen.texture_preview.refresh)
+		self.treeview.connect('row-activated', screen.textures_used.add)
 
 		# show "available textures:"
-		self.tvcolumn = gtk.TreeViewColumn('used textures:')
+		self.tvcolumn = gtk.TreeViewColumn('available textures:')
 		self.treeview.append_column(self.tvcolumn)
 
 		# create a CellRendererText to render the data
@@ -140,11 +169,8 @@
 		self.tvcolumn.pack_start(self.cell, true)
 		self.tvcolumn.add_attribute(self.cell, 'text', 0)
 
-	def remove(self, widget):
-		pass
+screen.textures_available = textures_available(table)
 
-screen.textures_used = textures_used(table)
-
 class tools:
 	def __init__(self, parent):
 		# create an container to limit the height of the toolbar
@@ -169,7 +195,7 @@
 		image.set_from_file(path[0] + '/graphic/buttons/textures/add.png')
 
 		# add the "add texture" button
-		self.bar.append_item('add texture', 'add the selected texture to the face', '', image, screen.textures_available.add)
+		self.bar.append_item('add texture', 'add the selected texture to the face', '', image, screen.textures_used.add)
 
 		# insert a spacer
 		#self.bar.append_space()
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
     
      
      
      From: <Ult...@us...> - 2009-03-14 10:13:22
       
   | 
Revision: 1094
          http://opengate.svn.sourceforge.net/opengate/?rev=1094&view=rev
Author:   Ultrasick
Date:     2009-03-14 10:13:07 +0000 (Sat, 14 Mar 2009)
Log Message:
-----------
now only drawing the added textures
Modified Paths:
--------------
    branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/edit_the_face.py
    branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/textures.py
Modified: branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/edit_the_face.py
===================================================================
--- branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/edit_the_face.py	2009-03-14 10:09:04 UTC (rev 1093)
+++ branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/edit_the_face.py	2009-03-14 10:13:07 UTC (rev 1094)
@@ -193,8 +193,9 @@
 		# create the triangles
 		self.create_triangles()
 
-		# insert a dummy texture
-		self.insert_texture('global - glass')
+		# insert the textures
+		for texture in self.face['textures']:
+			self.insert_texture(texture)
 
 	def insert_texture(self, texture):
 		texture = texture.split(' - ')
Modified: branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/textures.py
===================================================================
--- branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/textures.py	2009-03-14 10:09:04 UTC (rev 1093)
+++ branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/textures.py	2009-03-14 10:13:07 UTC (rev 1094)
@@ -124,6 +124,9 @@
 			# add the texture to the array
 			self.treestore.textures.append(texture)
 
+		# update the big preview image
+		screen.preview.redraw()
+
 screen.textures_used = textures_used(table)
 
 class textures_available:
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 | 
| 
     
      
      
      From: <Ult...@us...> - 2009-03-14 10:37:54
       
   | 
Revision: 1096
          http://opengate.svn.sourceforge.net/opengate/?rev=1096&view=rev
Author:   Ultrasick
Date:     2009-03-14 10:37:50 +0000 (Sat, 14 Mar 2009)
Log Message:
-----------
fixed a bug: not always the fastest way to draw the texture had been chosen (especially when the face was a triangle)
fixed a bug: the textures were drawn twice
Modified Paths:
--------------
    branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/edit_the_face.py
    branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/textures.py
Modified: branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/edit_the_face.py
===================================================================
--- branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/edit_the_face.py	2009-03-14 10:19:14 UTC (rev 1095)
+++ branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/edit_the_face.py	2009-03-14 10:37:50 UTC (rev 1096)
@@ -72,10 +72,25 @@
 		# return the plane
 		return plane
 
+	def get_shortest_combination(self, triangle):
+		# calculate lengths for each vertice as the offset
+		combination_1 = self.get_distance(self.get_vector(triangle[0], triangle[1])) + self.get_distance(self.get_vector(triangle[0], triangle[2]))
+		combination_2 = self.get_distance(self.get_vector(triangle[1], triangle[0])) + self.get_distance(self.get_vector(triangle[1], triangle[2]))
+		combination_3 = self.get_distance(self.get_vector(triangle[2], triangle[0])) + self.get_distance(self.get_vector(triangle[2], triangle[1]))
+
+		if combination_2==min(combination_1, combination_2, combination_3):
+			# reorder the vertices
+			triangle = [triangle[1], triangle[0], triangle[2]]
+		elif combination_3==min(combination_1, combination_2, combination_3):
+			# reorder the vertices
+			triangle = [triangle[2], triangle[0], triangle[1]]
+
+		return triangle
+
 	def get_triangles(self, vertices):
 		# check if there are only 3 vertices
 		if len(vertices)==3:
-			return [vertices]
+			return [self.get_shortest_combination(vertices)]
 
 		# create an array for the triangles
 		triangles = []
@@ -103,25 +118,9 @@
 
 		# get the shortest combination
 		for i, triangle in enumerate(triangles):
-			# calculate lengths for each vertice as the offset
-			combination_1 = self.get_distance(self.get_vector(triangle[0], triangle[1])) + self.get_distance(self.get_vector(triangle[0], triangle[2]))
-			combination_2 = self.get_distance(self.get_vector(triangle[1], triangle[0])) + self.get_distance(self.get_vector(triangle[1], triangle[2]))
-			combination_3 = self.get_distance(self.get_vector(triangle[2], triangle[0])) + self.get_distance(self.get_vector(triangle[2], triangle[1]))
+			# update the triangle
+			triangles[i] = self.get_shortest_combination(triangle)
 
-			if combination_2==min(combination_1, combination_2, combination_3):
-				# reorder the vertices
-				triangle = [triangle[1], triangle[0], triangle[2]]
-
-				# update the triangle
-				triangles[i] = triangle
-
-			elif combination_3==min(combination_1, combination_2, combination_3):
-				# reorder the vertices
-				triangle = [triangle[2], triangle[0], triangle[1]]
-
-				# update the triangle
-				triangles[i] = triangle
-
 		return triangles
 
 	def get_vector(self, vertice_1, vertice_2):
Modified: branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/textures.py
===================================================================
--- branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/textures.py	2009-03-14 10:19:14 UTC (rev 1095)
+++ branches/ogEditor/data/modules/texturizer/scripts/screens/project/canvas/frames/textures.py	2009-03-14 10:37:50 UTC (rev 1096)
@@ -84,7 +84,7 @@
 		self.tvcolumn.add_attribute(self.cell, 'text', 0)
 
 		# refresh the list
-		self.refresh()
+		self.refresh(true)
 
 	def add(self, nonsence1 = none, nonsence2 = none, nonsence3 = none):
 		try:
@@ -113,7 +113,7 @@
 			# refresh the list
 			self.refresh()
 
-	def refresh(self):
+	def refresh(self, fast = false):
 		# clear the list
 		self.treestore.clear()
 
@@ -124,8 +124,9 @@
 			# add the texture to the array
 			self.treestore.textures.append(texture)
 
-		# update the big preview image
-		screen.preview.redraw()
+		if fast==false:
+			# update the big preview image
+			screen.preview.redraw()
 
 screen.textures_used = textures_used(table)
 
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
 |