Welcome Guest [Log In] [Register]
We hope you enjoy your visit.


You're currently viewing the Ultimate 3D Community as a guest. This means that you can only read posts, but can not create posts or topics by yourself. To be able to post you need to register. Then you can participate in the community active and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.

Join our community!

If you are already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
Find the normal in a collision-I've read the help; file and many examples
Topic Started: Nov 15 2007, 10:32 PM (312 Views)
Eansis
Member Avatar
ghost
[ *  *  *  *  *  * ]
GetRayTracingNormal()
HOW DO YOU RETRIEVE VECTOR DATA FROM A MODEL?


And I am still clueless as to what to do. I have here in my code:
dist=GetDistanceToModel(model.id,x,y,z+height,rotx,roty)
normal=GetRayTracingNormal()

I have no idea what to do. normal keeps returning zero. I set it to negative 1 and it just returns how many normals I have created. I used GetObjectTransformation(model.id) and it just sets it to 1. I honestly have no clue what to do...I read the help file about vectors and it is all "geek" to me. And I am a geek...Its not that I don't understand it, it just seems like the help file is missing a lot of stuff. For example, it has a variable called: "RayTracingNormalIDOut" which is undefined. Just like the mythical "GetDistanceToLevel." Stuff like that frustrates me.

I tried the collision example on the main page and it crashed my videocard :( I even set Ultimate3DOptions to ("",32,"",2) and is STILL crashed my videocard. I also tried copying and pasting the code, with no luck. This is all very frustrating to me. :( I tried the racing example and it to is too complex for my non-existent vector competence. I tried copying and pasting the code and scripts from that as well, and that too didn't work.
VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY

Til'c
 
Things will not calm down Daniel Jackson. They will infact calm up.
Offline Profile Quote Post Goto Top
 
skarik
Member Avatar
kitten eating scum
[ *  *  *  *  *  * ]
Here's an example if it's that bad.

About your video card, if it crashed, you probably would wait about 10 minutes for windows to reboot. It's unlikely your video card crashed. Your program probably did the crashing. And I have had my video card crash before, so I know.
Blog|EHS
Offline Profile Quote Post Goto Top
 
Dr. Best
Member Avatar
Administrator
[ *  *  *  *  *  * ]
Calm down now, to avoid another warning level increasement in future. You don't need to set your text size to 14 to get me to read it.

You are using GetRayTracingNormal(...) wrongly and you obviously haven't understood GetVector(...). The correct use would be:
Code:
 
var distance,ray_tracing_normal,ray_tracing_normal_x,ray_tracing_normal_y,ray_tracing_normal_z;
distance=GetDistanceToModel(model.id,x,y,z+height,rotx,roty);
ray_tracing_normal=GetRayTracingNormal(-1);
ray_tracing_normal_x=GetVector(ray_tracing_normal,1);
ray_tracing_normal_y=GetVector(ray_tracing_normal,2);
ray_tracing_normal_z=GetVector(ray_tracing_normal,3);
ReleaseVector(ray_tracing_normal);

The return value of GetRayTracingNormal(...) is a vector id. Vectors are structures that are made up of three floating point values. How do you get to the idea, that one variable could contain a complete vector? To get the three floating point values from a vector id you need to use GetVector(...). All this is being explained in the help file.

VectorIDOut (which is what you mean by RayTracingNormalIDOut) has the comment see above in it's description. If you had seen above you would have found a very precise description of this parameter:
Help file
 
Almost every matrix or vector calculation function takes a parameter that's called OutputMatrixID or OutputVectorID. To avoid endless repetitions I'm gonna explain how this parameter works only once now.

OutputMatrixID / OutputVectorID
The ID of the matrix or the vector you want the result of the function to be written to. If you don't want to overwrite an existing matrix or vector you can pass -1 instead. Then Ultimate 3D will create a new matrix or vector and will return the ID of this matrix or vector. You have to save this ID. When you don't need this matrix or vector anymore you have to release the matrix or vector using ReleaseMatrix(MatrixID) or ReleaseVector(VectorID). Else the matrix or vector won't get deleted and Ultimate 3D will tell you about too many matrices or vectors being created after a while.


And GetDistanceToLevel(...) has a nice description, too:
Help file
 
Before we can start making collision detection for complete levels we need a script with syntax like this.
Code:
 
GetDistanceToLevel(
RayOriginX, RayOriginY, RayOriginZ,
RayDirectionLongitude, RayDirectionLatitude
)


The desired result is that this script returns the distance from the ray origin to the intersection point with the closest object. Of course, it would be a waste of computing time to perform a ray tracing test for absolutely every object in the scene, so you should limit it to the objects that really need a collision detection. It makes sense to set up a variable called somewhat like check_collision for all model and terrain objects that need a collision detection. Here's an exemplary implementation of this script, assuming that check_collision has been set up.
Code:
 
// GetDistanceToLevel(RayOriginX, RayOriginY, RayOriginZ,
// RayDirectionLongitude, RayDirectionLatitude)
// This function returns the distance to the closest point at which
// the given ray meets some object.
global.min_distance=GetDistanceToAnyPrimitive(argument0,argument1,argument2,
argument3,argument4);
with(all){
if(u3d_type==1 && check_collision==true){
global.distance=GetDistanceToModel(id,argument0,argument1,argument2,
argument3,argument4);
if(global.min_distance>global.distance){
global.min_distance=global.distance;
}
}
if(u3d_type==5 && check_collision==true){
global.distance=GetDistanceToTerrain(id,argument0,argument1,argument2,
argument3,argument4);
if(global.min_distance>global.distance){
global.min_distance=global.distance;
}
}
}
return global.min_distance;


All your understanding problems occur only because you have not read the help file completely. If you had you would have seen the description of OutputVectorID, GetVector(...) and GetDistanceToLevel(...). This is the last time I help you with a problem like this. If you pose any further questions that are just necessary because you haven't read the help file properly, especially if you do it in a way like this, I will simply ignore them.
Offline Profile Quote Post Goto Top
 
Eansis
Member Avatar
ghost
[ *  *  *  *  *  * ]
I didn't know large font was against the rules, but since you requested it I won't use large font anymore. Anyway, thanks for helping me out, I understand it now. Also, I read the entire help file section about vectors and collisions..its not that I didn't read, its that I didn't understand. It is the layout of the help file, some of it seems confusing to me. All of us have different brains. To you, creating a DirectX API DLL for GM is possible, for me it would be confusing as heck. Keep in mind that you wrote the help file, so you will obviously understand it. If you were to ask all of the members here if they understood the GetNormal functions only a small fraction of them would return yes. Just some helpful critism, you might want to make the help file a bit more understandable to newbies, don't take that the wrong way, but I think it would help more people understand U3d. If something in the helpfile doesn't make sense to me, someone who knows a bit about computers, it probably wouldn't make sense to an average Joe who doesn't know what an IP address is.

Skarik-my videocard crashed. I've ran other u3d games before, they all made my monitor go black, after 15 seconds my monitor returned and a message saying "ATI has corrected a videocard failure" appeared, or I had to reboot, and at startup a message saying "Windows has crashed due to Radeon 9250 failure" (or something like that.) Anyway thanks for the example.
VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY

Til'c
 
Things will not calm down Daniel Jackson. They will infact calm up.
Offline Profile Quote Post Goto Top
 
Dr. Best
Member Avatar
Administrator
[ *  *  *  *  *  * ]
You complied about particular scripts, parameters and variables not being defined at all and that's what I mostly criticized. If you download the *.chm version of the help file you can do a search in it, which is the easiest way to find such "undefined" scripts, parameters and variables. You should have done this before posting this topic. And regarding the understandability of the help file I have something on my backhand which will most likely improve this. Just wait a couple of weeks.
Offline Profile Quote Post Goto Top
 
Eansis
Member Avatar
ghost
[ *  *  *  *  *  * ]
Well, as for the undefined variables, I did a search and still couldn't find GetDistanceToLevel or RayTracingIDOut...
VOTE FOR BUDDY ROEMER HE'S A STRAIGHTFORWARD, DOWN TO EARTH AMERICAN GUY WHO ISN'T PART OF THE BIGBROTHER CONSPIRACY

Til'c
 
Things will not calm down Daniel Jackson. They will infact calm up.
Offline Profile Quote Post Goto Top
 
« Previous Topic · Questions about Ultimate 3D · Next Topic »
Add Reply