|
2 registered members (Grant, AndrewAMD),
911
guests, and 9
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: mouse_dir3d in ISOMETRIC mode wont work well
[Re: jcl]
#298876
11/18/09 16:38
11/18/09 16:38
|
Joined: Feb 2006
Posts: 52
carlpa
Junior Member
|
Junior Member
Joined: Feb 2006
Posts: 52
|
The vec_for_screen is more than slightly off. The degree of error seems to depend on the (world) distance between the object and the camera. I assume this is due to the fact that ISOMETRIC "flattens" what is a curved surface. The greater the distance from the camera, the larger the distortion due to flattening. The screen is the plane stretched to fit on the curved world surface. Hence, the "error" in using ISOMETRIC. One fix wculd be a function which takes the values generated by vec_for_screen and automatically makes the correction.
Researcher & clinician. A6, A7, & A8 First computer a Commodore Pet
|
|
|
Re: mouse_dir3d in ISOMETRIC mode wont work well
[Re: jcl]
#299742
11/26/09 15:49
11/26/09 15:49
|
Joined: Oct 2004
Posts: 4,134 Netherlands
Joozey
OP
Expert
|
OP
Expert
Joined: Oct 2004
Posts: 4,134
Netherlands
|
Ah yes, that makes sense. Thanks! If people stumble on the same problem, this works:
VECTOR mouse_click;
void mouseTo3D() {
while (1) {
if (mouse_left) {
vec_set (mouse_click, mouse_dir3d); //get direction vector from mouse to world
vec_normalize(mouse_click, 4000); //give it a large distance for tracing
vec_add (mouse_click, mouse_pos3d); //calculate from camera mouse in 3d position
c_trace (mouse_pos3d, mouse_click, IGNORE_MODELS); //trace from isometric 3d mouse position to clicked position (= mouse position + 4000 in depth)
vec_set( mouse_click, target );
ent_create ("warlock.mdl", mouse_click, NULL); //accurate warlock placement!
}
wait(1);
}
}
Click and join the 3dgs irc community! Room: #3dgs
|
|
|
|