Get map texture
Blitz3D Forums/Blitz3D Beginners Area/Get map texture| 
 | ||
| I recently learned the proper setup to load a world/map and its children/entities. Next thing I need is a way to find the texture and tie effects to it. Like make a certain color invisible or something like that. Let's say I want to find the texture %dev_trans_test.png and I want to make the color blue(0,0,255) completely transparent. How would I approach this? My current map loading code is like this: Function LoadWorld(file$)
	map=LoadAnimMesh(file) 
	If Not map Return
	
	
	world=CreatePivot() 
	meshes=CreatePivot(world)
	renderbrushes=CreateMesh(world) 
	collisionbrushes=CreatePivot(world)
	pointentities=CreatePivot(world) 
	solidentities=CreatePivot(world)
	 
	EntityType collisionbrushes,COLLISIONTYPE_BRUSH
		
	For c=1 To CountChildren(map) 
	
		node=GetChild(map,c) 
		
		classname$=Lower(KeyValue(node,"classname")) 
		DebugLog "Loading "+Chr(34)+classname+Chr(34)+"..." 
		
		Select classname 
				
			; world
			Case "mesh" 
				EntityParent node,meshes 
				EntityType node,COLLISIONTYPE_MESH 
				c=c-1
	
			Case "terrain" 
				EntityParent node,collisionbrushes 
				EntityType node,COLLISIONTYPE_BRUSH, True
				c=c-1
				
			Case "brush" 
				AddMesh node,renderbrushes 
				EntityType node,COLLISIONTYPE_BRUSH 
				EntityAlpha node,0 
				EntityParent node,collisionbrushes 
				c=c-1
			
		      ; info_dev_cam
			Case "info_devcam" 
				
				angles$=keyvalue(node,"angles","0 0 0") 
				pitch#=piece(angles,1," ") 
				yaw#=piece(angles,2," ") 
				roll#=piece(angles,3," ") 
				If cam 
					PositionEntity cam,EntityX(node),EntityY(node),EntityZ(node) 
					RotateEntity cam,pitch,yaw,roll 
				EndIf
			
				
			; item_test 
			Case "item_test" 
				
				angles$=keyvalue(node,"angles","0 0 0") 
				pitch#=piece(angles,1," ") 
				yaw#=piece(angles,2," ") 
				roll#=piece(angles,3," ") 
				
				; Laad de models
				item_test_model = LoadAnimMesh("content\models\item_score\item_score.b3d")
				PositionEntity item_test_model,EntityX(node),EntityY(node),EntityZ(node) 
				RotateEntity item_test_model,pitch,yaw,roll 
				; create the entity
				create_item_test(item_test)	
			
				
	Next
	 
	FreeEntity map 
	Return world 
	
End FunctionIs there anyway i can simply load a texture like I do with map children? Thanks!! | 
| 
 | ||
| Im not sure what exactly you are trying to do. What is "map children"? At a loose guess i assume you have a model and want to load a texture or textures and apply it to parts of it (ie. child meshes) independently correct?? | 
| 
 | ||
| Euhm no, sorry if I was a little unclear. I've build a map (world) in 3D world studio. I placed children, or limbs, for spawnpoints for all the player, enemies, etc. That's what the above code is about. Of course I've given my map textures, now I wish to load up a certain texture and give that special properties. | 
| 
 | ||
| Basically I need a way to get all the textures used on a map-file (.b3d) loaded up in my code, by name, so I can add certan properties to them. Like a texture called '%something.png' would make the color blue (0,0,255) completely transparant or any other kind of effect. I seek a loading system similair to my map limb/children loading code posted above. I hope I make more sense now.... | 
| 
 | ||
| Well, there is the TextureFilter command, that works also for textures loaded with LoadMesh/LoadAnimMesh. If you want something like that yourself, you'll need to get the texturename as follows: surface->brush->texture->texturename surf = GetSurface(mesh, 1) brush = GetSurfaceBrush(surf) tex = GetBrushTexture(brush, 0) print texturename$(tex) The GetBrushTexture example might be helpful: http://www.blitzbasic.com/b3ddocs/command.php?name=GetBrushTexture After finding the name, use Lower$ and Instr to search for a certain substring. | 
| 
 | ||
| You should free the 'got' brush and texture after you've finished with them, otherwise you will get a memory leak. | 
| 
 | ||
| Thanks guys! :D I will see if I can manage to implement it tomorrow and I will post my results. |