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: Scanner object or script function?  (Read 1640 times)

« on: November 24, 2011, 12:44:18 PM »
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.
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0

jestermon

« Reply #1 on: November 24, 2011, 10:59:15 PM »
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.
« Reply #2 on: November 26, 2011, 02:18:21 AM »
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?
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0

jestermon

« Reply #3 on: November 26, 2011, 02:47:44 AM »
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 :D
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.
« Last Edit: November 26, 2011, 02:52:18 AM by jestermon »
« Reply #4 on: November 26, 2011, 01:26:07 PM »
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?

jestermon

« Reply #5 on: November 26, 2011, 01:51:59 PM »
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.
« Last Edit: November 26, 2011, 02:08:53 PM by jestermon »
« Reply #6 on: November 26, 2011, 03:02:16 PM »
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
« Last Edit: November 26, 2011, 03:08:53 PM by Rush3Fan »
« Reply #7 on: November 26, 2011, 03:25:13 PM »
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?
::=::Look at this ::=::
Rally game

The most important thing that happens, you usualy miss it , but after sometime you will remember
 
even if you didint noticed. Go forward and never look back
« Reply #8 on: November 26, 2011, 08:50:26 PM »
Quote
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?
You'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).

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.





« Reply #9 on: November 27, 2011, 03:00:12 AM »
cool! now i know :D
::=::Look at this ::=::
Rally game

The most important thing that happens, you usualy miss it , but after sometime you will remember
 
even if you didint noticed. Go forward and never look back
« Reply #10 on: November 27, 2011, 03:02:51 AM »
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?
Rocket Rumble, a 3D Rad puzzle game:
http://www.3drad.com/forum/index.php?topic=9896.0
« Reply #11 on: November 27, 2011, 03:05:26 AM »
I think yes becouse it will be able to scan all 10 rigidbodys right?
::=::Look at this ::=::
Rally game

The most important thing that happens, you usualy miss it , but after sometime you will remember
 
even if you didint noticed. Go forward and never look back

jestermon

« Reply #12 on: November 27, 2011, 03:36:01 AM »
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)
« Last Edit: November 27, 2011, 03:50:03 AM by jestermon »
« Reply #13 on: November 27, 2011, 04:23:26 AM »
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
::=::Look at this ::=::
Rally game

The most important thing that happens, you usualy miss it , but after sometime you will remember
 
even if you didint noticed. Go forward and never look back

jestermon

« Reply #14 on: November 27, 2011, 04:33:37 AM »
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.

Pages: [1]