3D Rad - Free 3D game maker - Forum

This forum is now archived!

This forum is locked, and is a read-only version. A new community-ran forum can be found at classdev.net

News:

The 3DRad community can be found at classdev.net.

Pages: [1]

Author Topic: How to Execute a Script Command to every Object I Want (make a Script Rule) ??  (Read 1092 times)

« on: October 30, 2011, 02:07:57 PM »
Guys , I Really would to know a Way to Execute a Script Command , or More Clearly make a Rule to the Script, Not to Repeat the Command at every Object !

For Example :
if I Want to make a Level detail for every SkinMesh in My Game when Only my Character being Closer to them to Improve the Quality of my Game;
it's Simple .. I Will make the Command in a Script for a One and only One SkinMesh !! but .. I've many SkinMeshes more than hundreds-for example , So , I Need to Make a Rule to the Script to Execute the Same Operation to Every SkinMesh I've when the Condition Achieved instead of Repeating the Command , and Manually Renaming the OBJ_X by Every SkinMesh I've in My game ! it's a very hard work to that.

So I Really Want to Know a Way to Execute a Script Command at every Object per Condition ? You know what am Saying !

I Will Tell you also another Example doing that Operation I am talkin' about in 3d Rad :
The Imposter when it Clones a SkinMesh it Clones also every Behavior the SkinMesh Gained it whether a Script Command on it or a Shader , and Such things , but the Only Problem that all the Cloned Objects are only Executed , it's Just a Cloning Operation , I wanna an Execute at Every SkinMesh-for Example-or at every Object etc. even if they're a different SkinMeshes or RigidBodies or Objects in Shape but They Shared in the Same Command and Condition.

Thanks ---
« Last Edit: October 30, 2011, 02:14:29 PM by omarkronos »

jestermon

« Reply #1 on: October 30, 2011, 02:31:28 PM »
int iObjectHandle(int)
   This special function lets you programmatically determine the OBJ_ value of a certain object from its
   position in the 'Object HANDLE' window. The returned value can be passed to functions in place of the actual
   OBJ_ variable.
   int = index of the object to retrieve the handle for, as it appears in the 'Object HANDLE' window (Script editor),
         with zero being the first item, 1 the second and so on. If this parameter is -1 the function returns the
         total number of items in the 'Object HANDLE' window.

So set up a loop something like this. . .
int i;
for(i=0;i<iObjectHandle(-1);i++){ //-1 gives total linked objects
   iObjectHide(iObjectHandle(i); //process each linked object
}

Keep in mind 91 is the maximum objects the script can see, even if you link 200.

An imposter is an exact copy of the master, and will animate if the master animates. It uses the master as it's template. If you want unique control of each mesh, you need to add an object for every one you need.
« Last Edit: October 30, 2011, 02:34:44 PM by jestermon »
« Reply #2 on: October 31, 2011, 07:10:26 AM »
@jestermon : Thanks very much for these information
, It was very useful for me , I shall try it at the end of this week

But another small question : what's the 'for' function You Written in the Script , Please Explain to me what shall it do in C++ Language ?

--Thanks Again--
« Reply #3 on: October 31, 2011, 07:21:57 AM »
Quote
But another small question : what's the 'for' function You Written in the Script , Please Explain to me what shall it do in C++ Language ?


if you were really  a c coder omar, you'd immediately recognize the for/next loop in Jestermon's code...

it's not a function... this is a universal fundamental construct that appears in many programming languages... it's used to loop (iterate) through arrays and such... or to simply repeat a set of instructions a given number of times...

if you're gonna mess around with object handles and the like... maybe you should take a few days and get up to speed with some fundamental programming concepts... either in c, c++, BASIC, or AngelScript...

whichever you're most comfortable with...

--Mike
« Last Edit: October 31, 2011, 07:28:16 AM by Mike Hense »
« Reply #4 on: October 31, 2011, 11:12:47 AM »
@Mike : first, thanx for Describing to me that Code? Mike;

Second , I am not a Professional 'C' Coder Actually , but I Studied a Part of its Basics Shortly from a Book , soon-when I finish my Last Year in School and Pass-I will Specialize in Programming and Coding, but for now I  Learned only a Part of a C++ Basics which are Enough in using 3dRad Script,and for sure some of Physique and Mathematics Laws, However I Appreciate your help and Advise.
oh ! You forgot also to Learn the High Level Shading Language as well ,XD

--Thanks Again for Helping me , I'll do my best--
« Reply #5 on: October 31, 2011, 11:47:04 AM »
guilty as charged... i'm HLSL coder...

but i can go into HLSL code and make changes to modify an existing shader... why... because i've got a pretty solid grasp of certain fundamental programming things... variables, data types, constructs, etc...

that's what i was trying to get across to you...

you don't need to have experience in c++ or be a professional c programmer in order to recognize a for/next loop whenever you see one...

that's the point i was trying to get you to see... get familiar and comfortable with the fundamentals, and you'll be able to code in pretty much anything once you learn the syntax...


--Mike
« Reply #6 on: October 31, 2011, 01:02:35 PM »
HLSL is quite hard to start with if you got no programming experience, since you need several inputs from the engine to get it to work, but it's very fun you get to work.
You can also use editors like ShaderFX or Rendermonkey, but they need to be converted to RAD (variables and matrices), and you are limited to the variables and matrices RAD is able to broadcast to the shaders.

You can also use the shaderpak1 , they are quite "changeable" through functions :


ALL SHADERS:
1. You can finetune RGB color to texture by a simple script using iShaderFloat3Set(OBJ_0,"cColor",floatR,floatG.floatB) and link to skinmesh.
2. You can repeat uvmap via "Bump texture Tiles" in the skinmesh dialog
3. You can mirror UV by a simple script using iShaderFloatSet(OBJ_0,"MirrorUV",1) and link to skinmesh. (1.09 only)
4. You can tune global alpha for all shaders by using iShaderFloatSet(OBJ_0,"cAlpha",float) and link to skinmesh. (1.09 only)
5. you can tune emissive factor for all shaders by using iShaderFloatSet(OBJ_0,"cEmissive",float) and link to skinmesh. (1.09 only)

You can also control the skinmesh dialog options by script
1. iShaderFloatSet(OBJ_X, "TileCount", float");
2. iShaderFloatSet(OBJ_X, "environmentMapBlend", float);

How to UVW animate any shader example :
Code: [Select]
float x,z=0.0f;
void Main()
{
  x+=0.001;  //speed in x dir
  z+=0.001;  //speed in z dir
  iShaderFloat2Set(OBJ_X, "UVW",x,z);
}


Glossy Shaders:
1. You can finetune glossiness by a simple script using iShaderFloatSet(OBJ_0,"cGloss",float) and link to skinmesh.

Bumpy shaders
1. You can set bump height via "Bump Amplitude" in the skinmesh dialog
2. Or by script : iShaderFloatSet(OBJ_X, "bumpScale", float);
« Reply #7 on: November 01, 2011, 07:10:07 AM »
@Mike : thanx very much bro for the advise , I'll do my best, for coding is a very amusement work when one gets deeper to it.

@shadmar : Completely true what you've said because that happened to me Really when I tried to Convert a Shader from RenderMonkey to 3dRad System >> shader's Folder . It did appeared in the SkinMesh Shader Menu , but with no Applying ! Just it dis-appeared my SkinMesh !! As you said I should know how to deal with Defining shader's Variables in 3DRad

I Saw a useful tutorial also in here in 3drad topics about Learning how to Define a Shader to 3DRad's Script.

--anyway Thanks for you both for Redirecting me--

Wait my Next Topic soon.
« Reply #8 on: November 01, 2011, 07:57:55 AM »
good luck... 

sounds like you'll do just fine...


--Mike
Pages: [1]