Does raycasting suited on this?
How? I need the ray to be perpendicular to the camera. Meaning it should only cast a straight line directly to the camera so that I know if it is behind or now.
Any idea how to it efficiently?
Does raycasting suited on this?
How? I need the ray to be perpendicular to the camera. Meaning it should only cast a straight line directly to the camera so that I know if it is behind or now.
Any idea how to it efficiently?
The ZBuffer normally solves this problem. However you can do occlusion testing as well. There are several ways to do occlusion culling and some approaches depend on your API of choice.
If this is for 3D picking then you can usually create a list of objects that were hit by casting your ray into 3 space and then pick the closest one to the camera.
I'm using Ogre3d. I tried many things. I don't know how to get the origin of the ray and test if it is behind the object.
I'm confused. I tried to google it but don't get a pretty good results.
Yes the 3D picking is already solve by getting the cameratoray function in ogre3d then cast a ray from that mouse coordinates.
My problem is if I should cast a ray or a plane or whatever it should be..
Yes ZBuffer solves it in opengl but in ogre I don't know how to do it. They said I should cast a ray, but where should be the origin? It should not be a center of the window because it doesn't work right.
Sorry if my english is not so good. I hope you understand what I mean
Thank you
Sarah
If this is for 3D picking the origin of the ray is the click point. You must convert it to a 3D ray.I don't know how to get the origin of the ray and test if it is behind the object.
Not sure I understand this. I've never heard of casting a plane into 3D space.My problem is if I should cast a ray or a plane or whatever it should be..
Tell me what it is you are trying to do and then I will have a baseline from which to help you. If I don't understand the problem I can't very well help you.
I have a tree and an object in 3D world. The projection is orthographic and the camera is ( 0, 100, 0 ) facing the main terrain isometrically. (I don't know if this is the right word but it looks like isometric. I'm not the main developer on this project so I can't give you some picture because I'm not in his house right now.)
Here's what I'm trying to do, I have many trees and building. I want when my character is behind these static objects, they become transparent so that my character become visible to the user.
I tried casting a ray that from the camera but it has some flaws. check the pic below.
http://img580.imageshack.us/img580/5099/44089570.png
So I tried to cast a ray from the target but I don't know where should it headed/direction because the camera has only a certain point(the center of the screen).
http://img580.imageshack.us/img580/6789/35378468.png
Red: Ray
Black: Building/Trees
Yellow: Character
Thank you
Sarah
Last edited by sarah22; 05-01-2010 at 11:16 AM.
I don't use Ogre very much. But here's an idea:
Code:1)Make a ray 2)Set the origin to camera x, y, z 3)Set the direction to the angle from the camera to the character *does the vector for direction have to be a unit vector? I don't know. *if so, divide each part by the magnitude of the vector to get a unit vector 4)Test for collisions with the ray *if the collision has a distance less than the distance from the camera to the character then there is something in front of the character *keep checking until you get to the character (in case multiple buildings are between the two)
Consider this post signed
I don't get what you mean in #3..
Is it I'm solving the arctan() ? But that just give me an angle? The api here states that I should put a vector there and those vector are in Float. So what should I do?
OGRE: Ogre::Ray Class Reference - OGRE Documentation
OGRE: Ogre::Vector3 Class Reference - OGRE Documentation
I'm sorry but I didn't understand what you mean there.
Thank you very much for the help
Sarah
Oh, I solved this one already. What I did was this.
First, I subtract the camera position and camera target to get a vector then normalized it and plugged it on the ray as the direction and the origin will be the target/object.
Resulting a ray casted from the target which is always perpendicular to the screen/near/camera plane or whatever you call it. But if you know what you call it. tell me. lol
Thank you
Sarah