| 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: |
- Pages:
- 1
- 2
| Ray tracing problem; *changed the name when changing the subject* | |
|---|---|
| Tweet Topic Started: Apr 18 2009, 03:04 PM (885 Views) | |
| Ogeon | Apr 18 2009, 03:04 PM Post #1 |
|
Member
![]() ![]() ![]() ![]()
|
Hello 3D-friends! I have tried to find this out by both searching the forum and reading the documentation: how do I get the direction of the normal? I know how to get the x, y, z of the normal, but not the longitude and latitude. The reason is that I want to make a ray shoot out from the camera and be randomly reflected by the face of the object and move on to an other object and so on... There may be a simple explanation, but I can't find it. |
| Do you expect a signature? Forget it! | |
![]() |
|
| Gandalf20000 | Apr 18 2009, 03:56 PM Post #2 |
![]()
Geek
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
In the manual, look up these two functions: CalculateVectorLongitude(); CalculateVectorLatitude(); |
![]() |
|
| skarik | Apr 18 2009, 07:53 PM Post #3 |
|
kitten eating scum
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
My goodness, that's awesome. Like infinite combine balls in a room. |
| Blog|EHS | |
![]() |
|
| Ogeon | Apr 19 2009, 10:43 AM Post #4 |
|
Member
![]() ![]() ![]() ![]()
|
@Gandalf20000: Thanks. Even if one reads the manual, one can allways miss things... Now let's see if I will manage to do this. @skarik: Allmost what I thougt, but at the same time not. I'm trying to make a path tracer for GM. I know it will be slower than a "real" one, but it's cool to say that it's possible and it's just for fun. |
| Do you expect a signature? Forget it! | |
![]() |
|
| Bazza | Apr 19 2009, 12:21 PM Post #5 |
|
Forum God
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
er do you want it to be an accurate bounce or just an random bounce to infinity? |
| My instinct is to hide in this barrel, like the wily fish. | |
![]() |
|
| Ogeon | Apr 19 2009, 12:34 PM Post #6 |
|
Member
![]() ![]() ![]() ![]()
|
I want it to be a "difuse" bounce, so I need the normal to make the ray go in a random direction from the surface. Then it will check if it hits an other object and so on until it reaches max depth or hit nothing. I would like to know if ray tracing work with the plane primitives or just models. |
| Do you expect a signature? Forget it! | |
![]() |
|
| Bazza | Apr 19 2009, 12:58 PM Post #7 |
|
Forum God
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
to my knowledge it works with both primitives and models |
| My instinct is to hide in this barrel, like the wily fish. | |
![]() |
|
| Ogeon | Apr 19 2009, 01:13 PM Post #8 |
|
Member
![]() ![]() ![]() ![]()
|
The reason I ask is that it doesn't seem to find a hit. I made it return white if it hits an object and the resulting image is all black. I even tried to make it respond by ending the game when it detected a hit, but no... |
| Do you expect a signature? Forget it! | |
![]() |
|
| Ogeon | Apr 19 2009, 02:51 PM Post #9 |
|
Member
![]() ![]() ![]() ![]()
|
(I changed the name of the topic to make it fit the subject) If i run the game and check the variables it allways reurn 0 on the x, y and z of the normals. That's reasonable when it doesn't find any collition at all. May it be because the function ScreenCoordToVector(n,xx,yy,camera) return a vector with id=0, but with x, y and z at (0, 0, 0) and longitude=0 and latitude=0? Does anyone know why? |
| Do you expect a signature? Forget it! | |
![]() |
|
| Bazza | Apr 19 2009, 02:59 PM Post #10 |
|
Forum God
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
oh so your not using CheckRayIntersection(object id,x,y,z,rotx,roty,room index) but ScreenCoordToVector(); may i ask what your passing for the xx and yy vars? |
| My instinct is to hide in this barrel, like the wily fish. | |
![]() |
|
| Ogeon | Apr 19 2009, 05:11 PM Post #11 |
|
Member
![]() ![]() ![]() ![]()
|
I think I might have got it all wrong (appearently). Here is my code for checking from camera:
I have never used ray tracing before. I hope that you or someone else can help me. |
| Do you expect a signature? Forget it! | |
![]() |
|
| Bazza | Apr 19 2009, 05:42 PM Post #12 |
|
Forum God
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
whats the first call to ScreenCoord to vector supposed to accomplish |
| My instinct is to hide in this barrel, like the wily fish. | |
![]() |
|
| skarik | Apr 19 2009, 06:17 PM Post #13 |
|
kitten eating scum
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Your code and maths are fine, but your logic is not. I don't have any logic to give at the moment, so I can't help. |
| Blog|EHS | |
![]() |
|
| MysteriXYZ | Apr 19 2009, 09:34 PM Post #14 |
|
Master Matrix Masher
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
A couple of mistakes here:A VectorID parameter is either -1 (when you wish to create a new vector and have its id returned), or the id of a previously created vector, which is then filled with new data. So let's say you already initialized vector n in some Create Event like this: then you should write: (As you see, I also added ".number" to "camera", since that's what the CameraIndex parameter needs to be.) After normalizing that vector and getting its direction, you can immediately trace a ray from the camera (no need to get the components of n). And then you are forgetting something important: you need to scale n by dist, and add its components to the camera coordinates. This will give you the location of the point where the ray has intersected your level. Then you can trace a ray from that location, in the direction of the normal vector (you don't need its components, only longitude & latitude), and repeat the above procedure. Ad nauseam .Do the ray tracing in the direction of a normal recursively (in a script that calls itself) after the first trace from the camera. The recursion stops when the ray intersects nothing. I may post some code later if you need it. |
| U3D is like candy; after extensive consumption, it's Best to brush. | |
![]() |
|
| ashrat3000 | Apr 19 2009, 09:36 PM Post #15 |
|
u3d raytracer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
A couple things you need to double check: Make sure that n in ScreenCoordToVector(..) has been initialized as a vector with n = CreateVector(...) Also, make sure all your models have SetObjectSoliditiy(1,0) called. As for the logic, I dont really see much of a problem... hmm.. EDIT: damn, mystery beat me to it. Edited by ashrat3000, Apr 19 2009, 09:36 PM.
|
|
그대를 사랑해 | |
![]() |
|
| Go to Next Page | |
| « Previous Topic · Questions about Ultimate 3D · Next Topic » |
- Pages:
- 1
- 2





![]](http://z1.ifrm.com/static/1/pip_r.png)




.
10:21 AM Jul 11