西昌.何雨锋
[我]
1、关于鼠标究竟击中了谁的问题。
cTV_3DVECTOR vec_n,vec_f;
vec_n.x=xpos;vec_n.y=ypos;vec_n.z=zpos;
vec_f=math1->MoveAroundPoint(&vec_n,2000,90-yangle*180/3.14,-xangle * 180 / 3.14);
得到了两个点,前者为近点,后者为远点.
因为陆地只有一块,所以很好判断是否命中陆地。
col1=land1->AdvancedCollide(&vec_n,&vec_f);
但是mesh与actor往往很多,怎样判断是否击中哪一个?
所以在建立mesh与actor时,用一个全局静态变量递增来生成每个东西的id,这样,在碰撞检测中,可以通过得到碰撞的种类、第几个。
bool Initialize(bool bKeyboard = true , bool bMouse = true);
//初始化,如果input1不初始化,那么它将不接受任何鼠标与键盘消息
bool IsKeyPressed(cCONST_TV_KEY eKey);
//按下某个键
void GetMouseState(int* retRelativeX, int* retRelativeY, bool* retButton1 = NULL, bool* retButton2 = NULL, bool* retButton3 = NULL, bool* retButton4 = NULL, int* retRoll = NULL);
//得到鼠标普通状态
void GetAbsMouseState(int* retAbsoluteX, int* retAbsoluteY, bool* retButton1= NULL, bool* retButton2= NULL, bool* retButton3= NULL, bool* retButton4= NULL, int* retRoll = NULL);
//得到鼠标绝对值状态
void SetMouseSensitivity(float fSensitivity);
//设置鼠标灵敏度
void GetMousePosition(int* retX, int* retY);
//得到鼠标位置
void GetKeyBuffer(cTV_KEYDATA* keyDataArray, int* iNumKeyData);
void SetRepetitionDelay(int iRepetitionDelayInMs, int iRepetitionPeriodInMs = 0);
void GetKeyPressedArray(byte* pKeyArray255Elements);
int GetASCIIFromKey(cCONST_TV_KEY eKey);
void ForceUpdate();
void SetMousePosition(int iX, int iY);
//设置鼠标2维位置
CTVGameControllers* GetControllers();
bool IsMouseButtonPressed(int iButtonId);
void ClearKeyBuffer();
void EnableWindowsKey(bool bEnable = true);
键盘按键列表:
cTV_KEY_0 = 11,
cTV_KEY_1 = 2,
cTV_KEY_2 = 3,
cTV_KEY_3 = 4,
cTV_KEY_4 = 5,
cTV_KEY_5 = 6,
cTV_KEY_6 = 7,
cTV_KEY_7 = 8,
cTV_KEY_8 = 9,
cTV_KEY_9 = 10,
cTV_KEY_A = 30,
cTV_KEY_ABNT_C1 = 115,
cTV_KEY_ABNT_C2 = 126,
cTV_KEY_ADD = 78, //+号
cTV_KEY_APOSTROPHE = 40,
cTV_KEY_APPS = 221,
cTV_KEY_AT = 145,
cTV_KEY_AX = 150,
cTV_KEY_B = 48,
cTV_KEY_BACKSPACE = 14, //回档
cTV_KEY_BACKSLASH = 43,
cTV_KEY_C = 46,
cTV_KEY_CALCULATOR = 161,
cTV_KEY_CAPITAL = 58,
cTV_KEY_CAPSLOCK = 58, //capslock键
cTV_KEY_CIRCUMFLEX = 144,
cTV_KEY_COLON = 146,
cTV_KEY_COMMA = 51,
cTV_KEY_CONVERT = 121,
cTV_KEY_D = 32,
cTV_KEY_DECIMAL = 83,
cTV_KEY_DELETE = 211,
cTV_KEY_DIVIDE = 181,
cTV_KEY_DOWN = 208,
cTV_KEY_DOWNARROW = 208,
cTV_KEY_E = 18,
cTV_KEY_END = 207,
cTV_KEY_EQUALS = 13,
cTV_KEY_ESCAPE = 1,
cTV_KEY_F = 33,
cTV_KEY_F1 = 59,
cTV_KEY_F2 = 60,
cTV_KEY_F3 = 61,
cTV_KEY_F4 = 62,
cTV_KEY_F5 = 63,
cTV_KEY_F6 = 64,
cTV_KEY_F7 = 65,
cTV_KEY_F8 = 66,
cTV_KEY_F9 = 67,
cTV_KEY_F10 = 68,
cTV_KEY_F11 = 87,
cTV_KEY_F12 = 88,
cTV_KEY_F13 = 100,
cTV_KEY_F14 = 101,
cTV_KEY_F15 = 102,
cTV_KEY_G = 34,
cTV_KEY_GRAVE = 41,
cTV_KEY_H = 35,
cTV_KEY_HOME = 199,
cTV_KEY_I = 23,
cTV_KEY_INSERT = 210,
cTV_KEY_J = 36,
cTV_KEY_K = 37,
cTV_KEY_KANA = 112,
cTV_KEY_KANJI = 148,
cTV_KEY_L = 38,
cTV_KEY_ALT_LEFT = 56,
cTV_KEY_LEFTBRACKET = 26,
cTV_KEY_LEFTCONTROL = 29,
cTV_KEY_LEFT = 203,
cTV_KEY_LEFTARROW = 203,
cTV_KEY_LEFTMENU = 56,
cTV_KEY_LEFTSHIFT = 42,
cTV_KEY_LEFTWINDOWS = 219,
cTV_KEY_M = 50,
cTV_KEY_MAIL = 236,
cTV_KEY_MEDIASELECT = 237,
cTV_KEY_MEDIASTOP = 164,
cTV_KEY_MINUS = 12,
cTV_KEY_MULTIPLY = 55,
cTV_KEY_MUTE = 160,
cTV_KEY_MYCOMPUTER = 235,
cTV_KEY_N = 49,
cTV_KEY_NEXT = 209,
cTV_KEY_NEXTTRACK = 153,
cTV_KEY_NOCONVERT = 123,
cTV_KEY_NUMLOCK = 69,
cTV_KEY_NUMPAD0 = 82,
cTV_KEY_NUMPAD1 = 79,
cTV_KEY_NUMPAD2 = 80,
cTV_KEY_NUMPAD3 = 81,
cTV_KEY_NUMPAD4 = 75,
cTV_KEY_NUMPAD5 = 76,
cTV_KEY_NUMPAD6 = 77,
cTV_KEY_NUMPAD7 = 71,
cTV_KEY_NUMPAD8 = 72,
cTV_KEY_NUMPAD9 = 73,
cTV_KEY_NUMPADCOMMA = 179,
cTV_KEY_NUMPADENTER = 156,
cTV_KEY_NUMPADEQUALS = 141,
cTV_KEY_NUMPADMINUS = 74,
cTV_KEY_NUMPADPERIOD = 83,
cTV_KEY_NUMPADPLUS = 78,
cTV_KEY_NUMPADSLASH = 181,
cTV_KEY_NUMPADSTAR = 55,
cTV_KEY_O = 24,
cTV_KEY_OEM_102 = 86,
cTV_KEY_P = 25,
cTV_KEY_PAUSE = 197,
cTV_KEY_PERIOD = 52,
cTV_KEY_PAGEDOWN = 209,
cTV_KEY_PAGEUP = 201,
cTV_KEY_PLAYPAUSE = 162,
cTV_KEY_POWER = 222,
cTV_KEY_PREVTRACK = 144,
cTV_KEY_PRIOR = 201,
cTV_KEY_Q = 16,
cTV_KEY_R = 19,
cTV_KEY_ALT_RIGHT = 184,
cTV_KEY_RIGHTBRACKET = 27,
cTV_KEY_RIGHTCONTROL = 157,
cTV_KEY_RETURN = 28,
cTV_KEY_RIGHT = 205,
cTV_KEY_RIGHTARROW = 205,
cTV_KEY_RIGHTMENU = 184,
cTV_KEY_RIGHTSHIFT = 54,
cTV_KEY_RWIN = 220,
cTV_KEY_S = 31,
cTV_KEY_SCROLL = 70,
cTV_KEY_SEMICOLON = 39,
cTV_KEY_SLASH = 53,
cTV_KEY_SLEEP = 223,
cTV_KEY_SPACE = 57,
cTV_KEY_STOP = 149,
cTV_KEY_SUBTRACT = 74,
cTV_KEY_SYSRQ = 183,
cTV_KEY_T = 20,
cTV_KEY_TAB = 15, //TAB键
cTV_KEY_U = 22,
cTV_KEY_UNDERLINE = 147,
cTV_KEY_UNLABELED = 151,
cTV_KEY_UP = 200,
cTV_KEY_UPARROW = 200,
cTV_KEY_V = 47,
cTV_KEY_VOLUMEDOWN = 174,
cTV_KEY_VOLUMEUP = 176,
cTV_KEY_W = 17,
cTV_KEY_WAKE = 227,
cTV_KEY_WEBBACK = 234,
cTV_KEY_WEBFAVORITES = 230,
cTV_KEY_WEBFORWARD = 233,
cTV_KEY_WEBHOME = 178,
cTV_KEY_WEBREFRESH = 231,
cTV_KEY_WEBSEARCH = 229,
cTV_KEY_WEBSTOP = 232,
cTV_KEY_X = 45,
cTV_KEY_Y = 21,
cTV_KEY_YEN = 125,
cTV_KEY_Z = 44,