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
equivalent variables in U3D
Topic Started: Oct 11 2008, 04:38 PM (420 Views)
MakeGamer6.1
Newbie
[ * ]
I need to know equivalent variables for xfrom yfrom zfrom xto yto zto angle from the function
d3d_set_projection_ext(xfrom,yfrom,zfrom,xto,yto,zto,xup,yup,zup,angle,aspect,znear,zfar)
in U3D.I've already tried using xfrom=camera.x yfrom=camera.y zfrom=camera.z xto=player.x yto=player.y zto=player.z+player.height angle=camera.viewORcamera.rotatex(The camera is following the player with prespective set to two), but the script, which requare this variables, didn't work properly.
Offline Profile Quote Post Goto Top
 
Eansis
Member Avatar
ghost
[ *  *  *  *  *  * ]
You must set the camera's roty to point_direction()-90
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
 
MakeGamer6.1
Newbie
[ * ]
Do you mean roty=point_direction(x,y,player.x,player.y)-90 and angle=camera.roty?
Offline Profile Quote Post Goto Top
 
MysteriXYZ
Member Avatar
Master Matrix Masher
[ *  *  *  *  *  * ]
MakeGamer6.1
Oct 11 2008, 04:45 PM
Do you mean roty=point_direction(x,y,player.x,player.y)-90 and angle=camera.roty?
When the camera is following an object, you cannot use rotx or roty to rotate it; use rotatex and rotatey instead.

What you need for angle is the horizontal viewing angle, but camera.view is twice the vertical viewing angle. The value you need is given by:
Code:
 
aspect=camera.v_width/camera.v_height;
angle=radtodeg(arctan(tan(degtorad(camera.view/4))*aspect)*2);

U3D is like candy; after extensive consumption, it's Best to brush.
Offline Profile Quote Post Goto Top
 
MakeGamer6.1
Newbie
[ * ]
So v_width and v_height are view_width and view_height so I should use view_wview[0] and view_hview[0]?
Offline Profile Quote Post Goto Top
 
MysteriXYZ
Member Avatar
Master Matrix Masher
[ *  *  *  *  *  * ]
MakeGamer6.1
Oct 11 2008, 05:47 PM
So v_width and v_height are view_width and view_height so I should use view_wview[0] and view_hview[0]?
camera.v_width and camera.v_height are by default set to view_wview[0] and view_hview[0] respectively, yes, but if you want to use split screen for example, you would set them to smaller values.
So just use camera.v_width and camera.v_height.
U3D is like candy; after extensive consumption, it's Best to brush.
Offline Profile Quote Post Goto Top
 
MakeGamer6.1
Newbie
[ * ]
This doesnt work either.
Offline Profile Quote Post Goto Top
 
MysteriXYZ
Member Avatar
Master Matrix Masher
[ *  *  *  *  *  * ]
Maybe you should give more info about what exactly you're trying to do. Saying that "it doesn't work" isn't very clear.
U3D is like candy; after extensive consumption, it's Best to brush.
Offline Profile Quote Post Goto Top
 
MakeGamer6.1
Newbie
[ * ]
Excuse me for the incoviniance.Tepi from the gmc made code which defines a point on a xy plane in 3d by clicking on it with the mouse in ortho.To say it more simple, if you are playing a 3d strategy game and click on the terrain to move the unit, this is the right script.Here it is:
Quote:
 

var xfrom, yfrom, zfrom, xto, yto, zto, FOV, X1, Y1, X2, Y2, Z2, d, l, h, v,aspect;
xfrom = camera.x; yfrom = camera.y; zfrom=camera. z;
xto = oigr.x; yto = oigr.y; zto = oigr.z+oigr.height;
h = view_wview[0]; v = view_hview[0]; FOV = camera.rotatey;
camera.rotatey=0;
X1 = yto-yfrom;
Y1 = -(xto-xfrom);
d = sqrt(sqr(yto-yfrom)+sqr(xto-xfrom));
X1 /= d; Y1 /= d;
X2 = -(xto-xfrom)*(zto-zfrom);
Y2 = -(yto-yfrom)*(zto-zfrom);
Z2 = sqr(yto-yfrom)+sqr(xto-xfrom);
l = sqrt(sqr(xto-xfrom)+sqr(yto-yfrom)+sqr(zto-zfrom));
d *= l; X2 /= d; Y2 /= d; Z2 /= d;
d = tan(degtorad(FOV/2))/(v/2);
X2 = d*(X1*(h/2-mouse_x) + X2*(v/2-mouse_y))+(xto-xfrom)/l;
Y2 = d*(Y1*(h/2-mouse_x) + Y2*(v/2-mouse_y))+(yto-yfrom)/l;
Z2 = d*Z2*(v/2-mouse_y)+(zto-zfrom)/l;
X = xfrom-X2*zfrom/Z2;
Y = yfrom-Y2*zfrom/Z2;

Default FOV is 41(that angle argument).But since I'm using U3D, I need a way to calculate it and there isn't any success so far.oigr is the player object.
Offline Profile Quote Post Goto Top
 
skarik
Member Avatar
kitten eating scum
[ *  *  *  *  *  * ]
You don't actually need that. You just can use the collision functions (the ray tracing) and one of MystXYZ's examples that does EXACTLY what Tepi's example does. I've seen it on the GMC here and there, so I get what you're saying.

The Topic:
http://forum.ultimate3d.org/topic/173872/1/
Blog|EHS
Offline Profile Quote Post Goto Top
 
MysteriXYZ
Member Avatar
Master Matrix Masher
[ *  *  *  *  *  * ]
And here's a script that you could use instead of the one you have:
Code:
 
//GetPointOnTerrain(TerrainHeight)
//Calculates the coordinates under the mouse cursor on the plane parallel to
//the XY-plane at the given TerrainHeight.
var X,Y,Z,CamToPos,CamHeight,HeightCoord,NoPoint,Scale;

X=mouse_x-view_xview[0];
Y=mouse_y-view_yview[0];
//get the screen coordinates of the position on the terrain
CamToPos=ScreenCoordToVector(-1,X,Y,0);
CamHeight=camera.z-argument0;
HeightCoord=GetVector(CamToPos,3);
NoPoint=false;
//if the terrain goes through the camera or is very close to it, the user
//would have a hard time clicking on the desired spot
if (abs(CamHeight) < .001) NoPoint=true;
//the user cannot click off the terrain
if (HeightCoord == 0) or (sign(HeightCoord) == sign(CamHeight))
NoPoint=true;
if NoPoint
{
ReleaseVector(CamToPos);
exit;
}
Scale=CamHeight/HeightCoord;
CalculateVectorScalarProduct(CamToPos,CamToPos,Scale);
X=GetVector(CamToPos,1)+camera.x;
Y=GetVector(CamToPos,2)+camera.y;
ReleaseVector(CamToPos);
U3D is like candy; after extensive consumption, it's Best to brush.
Offline Profile Quote Post Goto Top
 
« Previous Topic · Questions about Ultimate 3D · Next Topic »
Add Reply