Just something I was wondering. What's better, using the scanner object or the script function, iObjectScan()? Let's say it's for placing imposter particles at the bullet hit location.
This forum is now archived!
- Welcome to the archive!
News:
The 3DRad community can be found at classdev.net.
- 3D Rad - Free 3D game maker - Forum >
- General Category >
- 3D Rad - Optimization Tips >
- Scanner object or script function?
Author Topic: Scanner object or script function? (Read 1640 times)
jestermon
You are going to have to script the results anyway. Also every added object has it's message overhead. If it's a simple game, it really does not matter. If it's a more complex game, the script is easier to manage. They both call the same underlying scan function anyway.
You can do a hundred or more different scans from script in a single frame, by calling the function repeatedly - No object to move around - That's my cue. The more I have directly under my script control, the less I have to worry about independent objects.
But then I script everything, so my opinion is very biased.
You can do a hundred or more different scans from script in a single frame, by calling the function repeatedly - No object to move around - That's my cue. The more I have directly under my script control, the less I have to worry about independent objects.
But then I script everything, so my opinion is very biased.
I see. I prefer to script things to, if I can. But what if an enemy character is scanning the scene with 50 rigidbodies? That would mean linking 50 objects to a script.
Or add one scanner and link this one object to the script. Wouldn't that save performance?
Or add one scanner and link this one object to the script. Wouldn't that save performance?
jestermon
The day you get 50 enemy objects to work in 3D Rad, then you can start to worry about complex proximity detection. But dreams are good
If you are using a lot of objects, forget about scanning, the overhead will drag your frame rate to Hades. You would script proximity detection for a game with many objects - It's the only practical way to do it and still have the game run at a decent frame rate.
I'll be uploading a "gravity toy", after this post. It's a script that uses the scanner function to scan for the closets surface of an object, then place a Gforce imposter there. The scanner looks at strategic points, and then uses the closest result. There you will see that you can do amazing things with the scanner function, without the overhead of using the scanner object. Don't worry about the maths, just get a feel for the possibilities.
If you are using a lot of objects, forget about scanning, the overhead will drag your frame rate to Hades. You would script proximity detection for a game with many objects - It's the only practical way to do it and still have the game run at a decent frame rate.
I'll be uploading a "gravity toy", after this post. It's a script that uses the scanner function to scan for the closets surface of an object, then place a Gforce imposter there. The scanner looks at strategic points, and then uses the closest result. There you will see that you can do amazing things with the scanner function, without the overhead of using the scanner object. Don't worry about the maths, just get a feel for the possibilities.
One reason I like the scanner object, is that in using it as a basis for weapons, I can easily adjust the scanner to mimic whichever weapon I like, and since only one weapon is active at any given time, it seems to not cause too much of a problem for me...
The most important thing I have learned about 3d rad over the last few years, is that job 1 is resource economy..Do you really need 50 bad guys? ( I can't think of any game where there are 50 enemies on screen at the same time) Or can we keep reusing 5-6 enemies through simple scripting and asset location?
The most important thing I have learned about 3d rad over the last few years, is that job 1 is resource economy..Do you really need 50 bad guys? ( I can't think of any game where there are 50 enemies on screen at the same time) Or can we keep reusing 5-6 enemies through simple scripting and asset location?
jestermon
Let's compare the the scanner object to the scanner function
Object
8 Messages (Every IN_xx is a message)
Needs to be started before it will return anything
Need to read info from IN_variables (Object, x,y,z location)
Need to link target to script, to compare scanned Object to target
No need to set orientation, since it's linked to 'parent'
Intuitive and easy to use
Still needs a script to start it (If an event is not used), get the results, and do something with the results.
Links to targets set in the scanner object itself. Returns object ID of target to script
Function
Single function call, no messages
Returns info in variables
Need to set center and direction in function call, may require 3 or more 'setup' calls, such as iObjectLocation, iObjectOrientation, iQuaternionLookAt
Can be reused repeatedly, with only link to Objects to test against.
Need to be called for every object to scan against.
Requires medium level scripting knowledge to use properly.
Conclusion
Each has their pros and cons.
Object is easier to use, and more intuitive, but carries a large message overhead.
Function requires more setup info, but more suited to a scripted solution.
Function is much faster, but required setup calls may balance out the overall results.
Both will do the job, the choice is based on your own development method.
Object
8 Messages (Every IN_xx is a message)
Needs to be started before it will return anything
Need to read info from IN_variables (Object, x,y,z location)
Need to link target to script, to compare scanned Object to target
No need to set orientation, since it's linked to 'parent'
Intuitive and easy to use
Still needs a script to start it (If an event is not used), get the results, and do something with the results.
Links to targets set in the scanner object itself. Returns object ID of target to script
Function
Single function call, no messages
Returns info in variables
Need to set center and direction in function call, may require 3 or more 'setup' calls, such as iObjectLocation, iObjectOrientation, iQuaternionLookAt
Can be reused repeatedly, with only link to Objects to test against.
Need to be called for every object to scan against.
Requires medium level scripting knowledge to use properly.
Conclusion
Each has their pros and cons.
Object is easier to use, and more intuitive, but carries a large message overhead.
Function requires more setup info, but more suited to a scripted solution.
Function is much faster, but required setup calls may balance out the overall results.
Both will do the job, the choice is based on your own development method.
My spg file scanner project is a good example of why the script function works so much faster.
http://www.3drad.com/forum/index.php?topic=8207.0
http://www.3drad.com/forum/index.php?topic=8207.0
i'm felling idiot and bit lame becouse of 2 things
1. What does excaly scaner object do?
2. were could it possibly be used?
1. What does excaly scaner object do?
2. were could it possibly be used?
Quote
i'm felling idiot and bit lame becouse of 2 thingsYou're not, because scanners don't exist in real life. They come in different forms like sonar and infrared range finders, or intelligent systems like Kinect (Xbox360).
1. What does excaly scaner object do?
2. were could it possibly be used?
Basically, it works like this.
A ray is cast from a point and finds when the line intersects a rigidbody.
There are two bits of information you receive from a scan.
1.)the location of the hit (Vector3)
2.)the orientation of the hit (Quaternion)
The scanner object also finds the distance from the scan origin to the scan hit.
Imagine you are using some high tech binoculars that read the distance of the thing you are looking at, that would be achieved using the scanner.
So... Let's say I have ten rigidbodies in my scene (more reasonable!) that need to be able to be scanned and where particles will be placed on. If I use a script, I need to link the script to all these objects. If I use a scanner, only the scanner needs to be attacked to the rigidbodies, the script only has to be linked to the scanner.
Right?
Right?
jestermon
So... Let's say I have ten rigidbodies in my scene (more reasonable!) that need to be able to be scanned and where particles will be placed on. If I use a script, I need to link the script to all these objects. If I use a scanner, only the scanner needs to be attacked to the rigidbodies, the script only has to be linked to the scanner.
Right?
Scanner Object
Link to 10 RB's
Link to processing script
Start scanner with script - Every loop to test
Get ID of scanned object - if there is one
Do something
(See attached demo for example)
Scanner Function
Link 10 RB's to script
Scan for each of the 10 RB's Use location and orientation of Cam for params
Get distance to objects - If > 0, then it hit something
Do something.
(With this method you will need to do some complex maths, so the above method is easiest)
so it is like this?:
Scanner object used for something simple and just abit advanced
scanner function used for complex things and requires medium level programing wich i dont hawe
Scanner object used for something simple and just abit advanced
scanner function used for complex things and requires medium level programing wich i dont hawe
jestermon
Just to level the playing field, here's the same kind of demo, but this time using the scanner function. You should get a better grasp between the two of them now.
This demo uses the scanner function, but has a skinmesh attached to the car, pretending to be the scanner. It's a skinmesh and does nothing.
The location and orientation of the skinmesh is used instead of the car's just as an illustration.
This demo uses the scanner function, but has a skinmesh attached to the car, pretending to be the scanner. It's a skinmesh and does nothing.
The location and orientation of the skinmesh is used instead of the car's just as an illustration.
Pages: [1]