Quan Posted March 27, 2010 Share Posted March 27, 2010 I have moved onto using scene files and the LE Editor to build my levels but I am struggling to work out how I can pick a entity and change its properties from inside Blitzmax on the fly. I have a directional light called sunlight which I would like to rotate and turn on / off etc. In the past I have just been creating a light in Blitzmax which is fine because I know what it is called but I can't seem to work out how I would find the sunlight entity from inside the loaded scene. Can anyone help me or point me to a example on the wiki. Thanks Quote BMax 1.38 * Leadwerks 2.4 * Unity 3.0 Pro * Intel Core 2 Duo 6600 - Win7 64bit - ATI 4870 Link to comment Share on other sites More sharing options...
Flexman Posted March 27, 2010 Share Posted March 27, 2010 After scene = LoadScene(....) call a function that uses an iterator to go through all the entities and process them as you wish. The following code (not tested as I hacked it out from a failing memory) should be enough to demonstrate one solution. It goes through all the scene entities, finds one that's called 'light_directional_1' (use any name you have assigned in the editor), it creates a pivot object and parents the directional light to it. You can then rotate the pivot to rotate the light, hence move the apparent sun position across the sky. ' CREATE A PIVOT FOR ROTATING THE SUN ENTITY ' Global sunpivot:TPivot ' ASSUMES scene IS GLOBAL AND MAP HAS BEEN LOADED ' Function ProcessSceneInfo(scene:TEntity) Local entity:TEntity Local name:String; For entity = EachIn scene.kids name = entity.GetKey("name", "") Select name ' FIND OR SUN USE THE NAME OF THE DIRECTIONAL LIGHT HERE ' Case "light_directional_1" sunpivot = CreatePivot() ; entity.SetParent(sunpivot) ; End Select Next End Function And you can use this as the basis to do other useful things. Quote 6600 2.4G / GTX 460 280.26 / 4GB Windows 7 Author: GROME Terrain Modeling for Unity, UDK, Ogre3D from PackT Tricubic Studios Ltd. ~ Combat Helo Link to comment Share on other sites More sharing options...
Quan Posted March 27, 2010 Author Share Posted March 27, 2010 This is what I was after. Thanks Quote BMax 1.38 * Leadwerks 2.4 * Unity 3.0 Pro * Intel Core 2 Duo 6600 - Win7 64bit - ATI 4870 Link to comment Share on other sites More sharing options...
cassius Posted March 27, 2010 Share Posted March 27, 2010 I use this routine For Local e:TEntity = EachIn CurrentWorld().Entities Select GetEntityKey(e, "Name") Quote amd quad core 4 ghz / geforce 660 ti 2gb / win 10 Blender,gimp,silo2,ac3d,,audacity,Hexagon / using c++ Link to comment Share on other sites More sharing options...
Quan Posted March 28, 2010 Author Share Posted March 28, 2010 Works like a charm, thanks again. I still have a load more questions but I'll have a play for a bit and see what I can work out first. Quote BMax 1.38 * Leadwerks 2.4 * Unity 3.0 Pro * Intel Core 2 Duo 6600 - Win7 64bit - ATI 4870 Link to comment Share on other sites More sharing options...
Quan Posted March 29, 2010 Author Share Posted March 29, 2010 I am still a bit stuck when it comes to changing a entities properties inside a scene from Blitz max. Working with the sun idea, what I would like to do is change the colors during the day. I have tried doing e.color = Vec4(1,0,0,1) inside the selection loop but this ended up changing nothing visually and is probably going about it the wrong way. Quote BMax 1.38 * Leadwerks 2.4 * Unity 3.0 Pro * Intel Core 2 Duo 6600 - Win7 64bit - ATI 4870 Link to comment Share on other sites More sharing options...
Quan Posted March 29, 2010 Author Share Posted March 29, 2010 After playing some more I have changed the code a bit by making sunlight:TEntity = e after which I can turn the sunlight, hide it etc. But I still can't seem to change its color with EntityColor. I think I know why because its now a TEntity instead of a TLight but I have no idea how to convert it. But my understanding of how things work increasing quite quickly. Quote BMax 1.38 * Leadwerks 2.4 * Unity 3.0 Pro * Intel Core 2 Duo 6600 - Win7 64bit - ATI 4870 Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.