游戏开发论坛

 找回密码
 立即注册
搜索
查看: 10482|回复: 10

?????????????

[复制链接]

12

主题

21

帖子

21

积分

注册会员

Rank: 2

积分
21
发表于 2007-9-15 10:41:00 | 显示全部楼层 |阅读模式
??Ogre???????????????????
?darkangel01??[??]???????????????????????????????????????????????

???darkangle01????

???????????????????????????

?????????Vector3 v3;???Vector4 v4(v3);

???????????????????????
Camera* cam=mSceneMgr->getCamera(&quotlayerCam");
Matrix4 viewMatrix=cam->getViewMatrix();
Matrix4 projectMatrix=cam->getProjectionMatrix();

???????????
Vector4 temp=viewMatrix*projectMatrix*v4;
?????
Vector3 ScreenPos=Vector3(v4.x/v4.w,v4.y/v4.w,v4.z/v4.w);

?????x,y???????-1,+1?????0?1?????
float x=ScreenPos.x/2+0.5
float y=-ScreenPos.y/2+0.5


1. Vector4 temp=viewMatrix*projectMatrix*v4;???Vector3 ScreenPos=Vector3(v4.x/v4.w,v4.y/v4.w,v4.z/v4.w);??????temp
2. ???temp??????????????

2

主题

49

帖子

49

积分

注册会员

Rank: 2

积分
49
发表于 2007-9-15 15:33:00 | 显示全部楼层

Re:?????????????

?Ogre????????????????????
???????????? XD


???????? ????????????
?????
Vector4 temp = (projectMatrix*viewMatrix)*v4;
Vector3 ScreenPos = Vector3(temp.x/temp.w,temp.y/temp.w,temp.z/temp.w);
(???]??C?y? ????????e)

?? ?????????
float x=ScreenPos.x/2+0.5
float y=-ScreenPos.y/2+0.5
?2?????????rojectMatrix ?????2???2???
??????????r??????
???????f ???sse???6?

[em20]

55

主题

331

帖子

337

积分

中级会员

Rank: 3Rank: 3

积分
337
发表于 2007-9-15 21:00:00 | 显示全部楼层

Re: ?????????????


  1. bool OgreProject(    double objx, double objy, double objz,
  2.                      const Matrix4& viewMat,
  3.                      const Matrix4& projMat,
  4.                      const RenderWindow* rm,
  5.                      double* winx, double* winy, double* winz)
  6. {
  7.         Matrix4 viewMatrix = viewMat;
  8.         Matrix4 projMatrix = projMat;

  9.         Vector4 in = Vector4(objx, objy, objz, 1.0);
  10.         Vector4 out;

  11.         out = viewMatrix * in;
  12.         in = projMatrix * out;

  13.         if(in.w == 0.0) return false;

  14.         in.x /= in.w;
  15.         in.y /= in.w;
  16.         in.z /= in.w;

  17.         // Map x, y and z to range 0-1
  18.         in.x = in.x * 0.5 + 0.5;
  19.         in.y = in.y * 0.5 + 0.5;
  20.         in.z = in.z * 0.5 + 0.5;

  21.         // Map x,y to viewport
  22.         in.x = in.x * rm->getWidth();
  23.         in.y = (1 - in.y) * rm->getHeight();

  24.         *winx = in.x;
  25.         *winy = in.y;
  26.         *winz = in.z;

  27.         return true;
  28. }
复制代码



good luck to u  @_@



4

主题

27

帖子

27

积分

注册会员

Rank: 2

积分
27
发表于 2007-9-16 11:08:00 | 显示全部楼层

Re: Re:?????????????

123776: Re:?????????????

?Ogre????????????????????
???????????? XD


???????? ????..


??????????

????????????

2

主题

49

帖子

49

积分

注册会员

Rank: 2

积分
49
发表于 2007-9-16 13:15:00 | 显示全部楼层

Re: Re: Re:?????????????

darkangel01: Re: Re:?????????????



??????????

????????????



                Matrix4 viewMatrix = mCamera->getViewMatrix();
                Matrix4 projectMatrix = mCamera->getProjectionMatrix();
                Matrix4 eyeMatrix = (Matrix4(0.5,0,0,0.5, 0,-0.5,0,0.5, 0,0,1,0, 0,0,0,1)*(projectMatrix*viewMatrix));
                Vector4 temp = eyeMatrix*v4;
                Vector3 ScreenPos = Vector3(temp.x/temp.w,temp.y/temp.w,temp.z/temp.w);

2

主题

429

帖子

435

积分

中级会员

Rank: 3Rank: 3

积分
435
发表于 2007-9-16 15:12:00 | 显示全部楼层

Re: Re: Re: Re:?????????????

123776: Re: Re: Re:?????????????

Matrix4 viewMatrix = mCamera->getViewMatrix();
Matrix4 projectMatrix = mCamera->getProjectionMatrix();
Matrix4 eyeMatrix = (Matrix4(0.5,0,0,0.5, 0,-0.5,0,0.5, 0,0,1,0, 0,0,0,1)*(projectMatrix*viewMatrix));
Vector4 temp = eyeMatrix*v4;
Vector3 ScreenPos = Vector3(temp.x/temp.w,temp.y/temp.w,temp.z/temp.w);


?????

2

主题

49

帖子

49

积分

注册会员

Rank: 2

积分
49
发表于 2007-9-16 15:56:00 | 显示全部楼层

Re: Re: Re: Re: Re:?????????????

Enigmaya: Re: Re: Re: Re:?????????????



?????


???1?????? ?????Q!!
MATRIX??????

4

主题

27

帖子

27

积分

注册会员

Rank: 2

积分
27
发表于 2007-9-17 09:09:00 | 显示全部楼层

Re:?????????????

????????????????

42

主题

137

帖子

137

积分

注册会员

Rank: 2

积分
137
发表于 2007-9-18 11:00:00 | 显示全部楼层

Re:?????????????

???123776?!!

6

主题

11

帖子

15

积分

新手上路

Rank: 1

积分
15
发表于 2007-11-9 19:42:00 | 显示全部楼层

Re: ?????????????

????????????????????????????

??????????????????????????????

?????//??????????????????????????????

1???????????? vecView ??
?camera->getRayToViewport().getDirection()(???????)??

2???????????????????????????????3D??????

3?????3D???????????????????????????
?Vector3 vecTarget = posTarget - posCamera?.

4.?????????????????????????????? 3D ???????? PT?????????? 3D ?? PV?

5?? PT ? PV ?????????????????????????? vecView ? vecTarget ?????.  ????????????????????? 2D ?????????????????????????????????

6????????????????????????????????????????????? Vector3.Y ????????????????????????????????????????????????? Y ???????

7??? X ??????? ?????????????????????????????????????????????????????????? vecView?vecTarget ????????????????????????? Y ????????????
===============================================

???????????????
? ??????????????? ?????????

????????????
??
???
?????????????
?????????


==============================
?????????
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

作品发布|文章投稿|广告合作|关于本站|游戏开发论坛 ( 闽ICP备17032699号-3 )

GMT+8, 2025-8-7 22:28

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表