Get entity's color?
Blitz3D Forums/Blitz3D Programming/Get entity's color?
| ||
Hi all, how do u read the R, G, B, A values of an entity's color? U'd THINK this code I made would work... X_X Any help is GREATLY appreciated! :) |
| ||
Vertex colours are applied separately from entity colour - they're a property of the surface data (and don't actually do anything unless you explicitly set the vertex colour EntityFX flag). There is no built in way to read the entity's overall colour value. Either store it at the same time as you set it, or use the Blitz3D+ DLL: http://www.blitzbasic.com/Community/posts.php?topic=75711 |
| ||
SWEET! Thanks! =D |
| ||
Is the BlitzPlus 3D DLL royalty free? :) |
| ||
Yes. Note that it has nothing to do with BlitzPlus - just has a slightly misleading name. |
| ||
It would be far easier to store it than to include another dll requirement for something so simple. One portable way ( psuedo code ' ish ) edit : this is just one way to do it in portable code, if you already have a type list for your entities that you create it will be even easier to store the rgb entity color in that Global MyEntRed%,MyEntGreen%,MyEntBlue% Type MyEntColor field ent field r%,g%,b% end type Function MyEntityColor(ent,r%,g%,b%) for mec.myentcolor=each myentcolor if mec\ent=ent then entitycolor ent,r,g,b mec\ent=ent mec\r=r mec\g=g mex\b=b return endif next mec.myentcolor = new myentcolor mec\ent=ent mec\r=r mec\g=g mec\b=b entitycolor ent,r,g,b end function Function DeleteEntColor(ent) for mec.myentcolor=each myentcolor if mec\ent=ent then delete mec endif next end funciton Function GetEntityColor(ent) for mec.myentcolor=each myentcolor if mec\ent=ent then MyEntRed%=mec\r MyEntGreen%=Mec\g MyEntBlue%=Mec\b return endif next end function Last edited 2012 |
| ||
While that's certainly one way to do it, there's a much easier way to add any custom properties you like to your entities... NameEntity Every entity can hold a "name" string. Now, some entities will already be using this (anything created in an animation program will probably already have a name used by the animation/hierarchy system to find it from its parent, cf. FindChild). However, you can set this string to whatever you want, so if you aren't using FindChild... store extra properties in it! There are two obvious ways to do this: 1) Create a type containing all the extra fields you want your entity to have. Create an instance of that type when creating the entity, and store the Handle in the entity name. Int->String and back again is pretty fast, so this is very usable. 2) Encode the data directly in the string somehow (perhaps using a string vector or something). Not sure why you would do this over the other option, but it's a cool notion. This also effectively lets you create custom subclasses of Entity, since there's no requirement that two entities share the same set of extensions. (The simplest option of all is to just store the entity in the subclass too, rather than the other way around, but that requires all of your code to be written with an awareness of the new type.) |
| ||
Hmmm.... I see... thanks ALOT, guys! :) |
| ||
The nameentity features is something i used extensively for loading levels in, waypoints etc. Each entity had custom properties stored in the name. I had a program that would let me enter the information easily, then combine it into a string in the editor (I was using ultimate unwrap). This string was stored in the name and saved as a .b3d. Upon loading, it all got extracted, and stored into a type. |
| ||
Does anybody have a save function that actually saves PERFECTLY, ANY object loaded into the scene? im talking any textures, colors, animations, etc.... |