Add PhysicsEffects to Extras. The build is only tested on Windows and Android.
The Android/NEON optimized version of Physics Effects is thanks to Graham Rhodes and Anthony Hamilton, See Issue 587
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Physics Effects is open software; you can redistribute it and/or
|
||||
modify it under the terms of the BSD License.
|
||||
|
||||
Physics Effects is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the BSD License for more details.
|
||||
|
||||
A copy of the BSD License is distributed with
|
||||
Physics Effects under the filename: physics_effects_license.txt
|
||||
*/
|
||||
|
||||
#define NUM_BOX_VTX 36
|
||||
#define NUM_BOX_IDX 36
|
||||
const float box_vtx[] = {
|
||||
-0.500000f,-0.500000f,-0.500000f,0.000000f,0.000000f,-1.000000f,
|
||||
-0.500000f,0.500000f,-0.500000f,0.000000f,0.000000f,-1.000000f,
|
||||
0.500000f,0.500000f,-0.500000f,0.000000f,0.000000f,-1.000000f,
|
||||
-0.500000f,-0.500000f,-0.500000f,0.000000f,0.000000f,-1.000000f,
|
||||
0.500000f,0.500000f,-0.500000f,0.000000f,0.000000f,-1.000000f,
|
||||
0.500000f,-0.500000f,-0.500000f,0.000000f,0.000000f,-1.000000f,
|
||||
-0.500000f,-0.500000f,-0.500000f,0.000000f,-1.000000f,0.000000f,
|
||||
0.500000f,-0.500000f,-0.500000f,0.000000f,-1.000000f,0.000000f,
|
||||
0.500000f,-0.500000f,0.500000f,0.000000f,-1.000000f,0.000000f,
|
||||
-0.500000f,-0.500000f,-0.500000f,0.000000f,-1.000000f,0.000000f,
|
||||
0.500000f,-0.500000f,0.500000f,0.000000f,-1.000000f,0.000000f,
|
||||
-0.500000f,-0.500000f,0.500000f,0.000000f,-1.000000f,0.000000f,
|
||||
-0.500000f,-0.500000f,-0.500000f,-1.000000f,0.000000f,0.000000f,
|
||||
-0.500000f,-0.500000f,0.500000f,-1.000000f,0.000000f,0.000000f,
|
||||
-0.500000f,0.500000f,0.500000f,-1.000000f,0.000000f,0.000000f,
|
||||
-0.500000f,-0.500000f,-0.500000f,-1.000000f,0.000000f,0.000000f,
|
||||
-0.500000f,0.500000f,0.500000f,-1.000000f,0.000000f,0.000000f,
|
||||
-0.500000f,0.500000f,-0.500000f,-1.000000f,0.000000f,0.000000f,
|
||||
-0.500000f,-0.500000f,0.500000f,0.000000f,0.000000f,1.000000f,
|
||||
0.500000f,-0.500000f,0.500000f,0.000000f,0.000000f,1.000000f,
|
||||
0.500000f,0.500000f,0.500000f,0.000000f,0.000000f,1.000000f,
|
||||
-0.500000f,-0.500000f,0.500000f,0.000000f,0.000000f,1.000000f,
|
||||
0.500000f,0.500000f,0.500000f,0.000000f,0.000000f,1.000000f,
|
||||
-0.500000f,0.500000f,0.500000f,0.000000f,0.000000f,1.000000f,
|
||||
-0.500000f,0.500000f,-0.500000f,0.000000f,1.000000f,0.000000f,
|
||||
-0.500000f,0.500000f,0.500000f,0.000000f,1.000000f,0.000000f,
|
||||
0.500000f,0.500000f,0.500000f,0.000000f,1.000000f,0.000000f,
|
||||
-0.500000f,0.500000f,-0.500000f,0.000000f,1.000000f,0.000000f,
|
||||
0.500000f,0.500000f,0.500000f,0.000000f,1.000000f,0.000000f,
|
||||
0.500000f,0.500000f,-0.500000f,0.000000f,1.000000f,0.000000f,
|
||||
0.500000f,-0.500000f,-0.500000f,1.000000f,0.000000f,0.000000f,
|
||||
0.500000f,0.500000f,-0.500000f,1.000000f,0.000000f,0.000000f,
|
||||
0.500000f,0.500000f,0.500000f,1.000000f,0.000000f,0.000000f,
|
||||
0.500000f,-0.500000f,-0.500000f,1.000000f,0.000000f,0.000000f,
|
||||
0.500000f,0.500000f,0.500000f,1.000000f,0.000000f,0.000000f,
|
||||
0.500000f,-0.500000f,0.500000f,1.000000f,0.000000f,0.000000f,
|
||||
};
|
||||
const unsigned short box_idx[] = {
|
||||
0,1,2,
|
||||
3,4,5,
|
||||
6,7,8,
|
||||
9,10,11,
|
||||
12,13,14,
|
||||
15,16,17,
|
||||
18,19,20,
|
||||
21,22,23,
|
||||
24,25,26,
|
||||
27,28,29,
|
||||
30,31,32,
|
||||
33,34,35,
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Physics Effects is open software; you can redistribute it and/or
|
||||
modify it under the terms of the BSD License.
|
||||
|
||||
Physics Effects is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the BSD License for more details.
|
||||
|
||||
A copy of the BSD License is distributed with
|
||||
Physics Effects under the filename: physics_effects_license.txt
|
||||
*/
|
||||
|
||||
#ifndef __COMMON_H__
|
||||
#define __COMMON_H__
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
|
||||
// Platform specific
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
#endif /* __COMMON_H__ */
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Physics Effects is open software; you can redistribute it and/or
|
||||
modify it under the terms of the BSD License.
|
||||
|
||||
Physics Effects is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the BSD License for more details.
|
||||
|
||||
A copy of the BSD License is distributed with
|
||||
Physics Effects under the filename: physics_effects_license.txt
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "ctrl_func.h"
|
||||
|
||||
int keyState[2][BTN_NUM] = {0};
|
||||
int keySw = 0;
|
||||
|
||||
void ctrl_init()
|
||||
{
|
||||
keySw = 0;
|
||||
}
|
||||
|
||||
void ctrl_release()
|
||||
{
|
||||
}
|
||||
|
||||
void ctrl_update()
|
||||
{
|
||||
}
|
||||
|
||||
ButtonStatus ctrl_button_pressed(ButtonID btnId)
|
||||
{
|
||||
if(keyState[1-keySw][btnId] && !keyState[keySw][btnId]) {
|
||||
return BTN_STAT_DOWN;
|
||||
}
|
||||
else if(keyState[1-keySw][btnId] && keyState[keySw][btnId]) {
|
||||
return BTN_STAT_KEEP;
|
||||
}
|
||||
else if(!keyState[1-keySw][btnId] && keyState[keySw][btnId]) {
|
||||
return BTN_STAT_UP;
|
||||
}
|
||||
|
||||
return BTN_STAT_NONE;
|
||||
}
|
||||
|
||||
void ctrl_set_screen_size(int w,int h)
|
||||
{
|
||||
}
|
||||
|
||||
void ctrl_get_cursor_position(int &cursorX,int &cursorY)
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Physics Effects is open software; you can redistribute it and/or
|
||||
modify it under the terms of the BSD License.
|
||||
|
||||
Physics Effects is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the BSD License for more details.
|
||||
|
||||
A copy of the BSD License is distributed with
|
||||
Physics Effects under the filename: physics_effects_license.txt
|
||||
*/
|
||||
|
||||
#ifndef __CTRL_FUNC_H__
|
||||
#define __CTRL_FUNC_H__
|
||||
|
||||
enum ButtonID {
|
||||
BTN_SCENE_RESET=0,
|
||||
BTN_SCENE_NEXT,
|
||||
BTN_SIMULATION,
|
||||
BTN_STEP,
|
||||
BTN_UP,
|
||||
BTN_DOWN,
|
||||
BTN_LEFT,
|
||||
BTN_RIGHT,
|
||||
BTN_ZOOM_IN,
|
||||
BTN_ZOOM_OUT,
|
||||
BTN_PICK,
|
||||
BTN_NUM
|
||||
};
|
||||
|
||||
enum ButtonStatus {
|
||||
BTN_STAT_NONE = 0,
|
||||
BTN_STAT_DOWN,
|
||||
BTN_STAT_UP,
|
||||
BTN_STAT_KEEP
|
||||
};
|
||||
|
||||
void ctrl_init();
|
||||
void ctrl_release();
|
||||
void ctrl_update();
|
||||
|
||||
void ctrl_set_screen_size(int w,int h);
|
||||
void ctrl_get_cursor_position(int &cursorX,int &cursorY);
|
||||
|
||||
ButtonStatus ctrl_button_pressed(ButtonID btnId);
|
||||
|
||||
#endif /* __CTRL_FUNC_H__ */
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Physics Effects is open software; you can redistribute it and/or
|
||||
modify it under the terms of the BSD License.
|
||||
|
||||
Physics Effects is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the BSD License for more details.
|
||||
|
||||
A copy of the BSD License is distributed with
|
||||
Physics Effects under the filename: physics_effects_license.txt
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "ctrl_func.h"
|
||||
|
||||
int keyState[2][BTN_NUM] = {0};
|
||||
int keySw = 0;
|
||||
|
||||
void ctrl_init()
|
||||
{
|
||||
keySw = 0;
|
||||
}
|
||||
|
||||
void ctrl_release()
|
||||
{
|
||||
}
|
||||
|
||||
void ctrl_update()
|
||||
{
|
||||
keyState[keySw][BTN_SCENE_RESET] = GetAsyncKeyState(VK_F1);
|
||||
keyState[keySw][BTN_SCENE_NEXT] = GetAsyncKeyState(VK_F2);
|
||||
keyState[keySw][BTN_SIMULATION] = GetAsyncKeyState(VK_F3);
|
||||
keyState[keySw][BTN_STEP] = GetAsyncKeyState(VK_F4);
|
||||
keyState[keySw][BTN_UP] = GetAsyncKeyState(VK_UP);
|
||||
keyState[keySw][BTN_DOWN] = GetAsyncKeyState(VK_DOWN);
|
||||
keyState[keySw][BTN_LEFT] = GetAsyncKeyState(VK_LEFT);
|
||||
keyState[keySw][BTN_RIGHT] = GetAsyncKeyState(VK_RIGHT);
|
||||
keyState[keySw][BTN_ZOOM_IN] = GetAsyncKeyState(VK_INSERT);
|
||||
keyState[keySw][BTN_ZOOM_OUT] = GetAsyncKeyState(VK_DELETE);
|
||||
keyState[keySw][BTN_PICK] = GetAsyncKeyState(VK_LBUTTON);
|
||||
keySw = 1-keySw;
|
||||
}
|
||||
|
||||
ButtonStatus ctrl_button_pressed(ButtonID btnId)
|
||||
{
|
||||
if(keyState[1-keySw][btnId] && !keyState[keySw][btnId]) {
|
||||
return BTN_STAT_DOWN;
|
||||
}
|
||||
else if(keyState[1-keySw][btnId] && keyState[keySw][btnId]) {
|
||||
return BTN_STAT_KEEP;
|
||||
}
|
||||
else if(!keyState[1-keySw][btnId] && keyState[keySw][btnId]) {
|
||||
return BTN_STAT_UP;
|
||||
}
|
||||
|
||||
return BTN_STAT_NONE;
|
||||
}
|
||||
|
||||
void ctrl_set_screen_size(int w,int h)
|
||||
{
|
||||
}
|
||||
|
||||
void ctrl_get_cursor_position(int &cursorX,int &cursorY)
|
||||
{
|
||||
HWND hWnd = ::GetActiveWindow();
|
||||
|
||||
POINT pnt;
|
||||
RECT rect;
|
||||
::GetCursorPos(&pnt);
|
||||
::ScreenToClient(hWnd,&pnt);
|
||||
::GetClientRect(hWnd,&rect);
|
||||
cursorX = pnt.x - (rect.right - rect.left) / 2;
|
||||
cursorY = (rect.bottom-rect.top) / 2 - pnt.y;
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Physics Effects is open software; you can redistribute it and/or
|
||||
modify it under the terms of the BSD License.
|
||||
|
||||
Physics Effects is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the BSD License for more details.
|
||||
|
||||
A copy of the BSD License is distributed with
|
||||
Physics Effects under the filename: physics_effects_license.txt
|
||||
*/
|
||||
|
||||
#define NUM_CYLINDER_VTX 68
|
||||
#define NUM_CYLINDER_IDX 192
|
||||
const float cylinder_vtx[] = {
|
||||
-1.0f,0.0f,0.0f, -1.0f,0.0f,0.0f,
|
||||
-1.0f,-0.923879f,-0.382683f, -1.0f,0.0f,0.0f,
|
||||
-1.0f,-1.0f,1.62921e-007f, -1.0f,0.0f,0.0f,
|
||||
-1.0f,-0.707107f,-0.707107f, -1.0f,0.0f,0.0f,
|
||||
-1.0f,-0.382683f,-0.923879f, -1.0f,0.0f,0.0f,
|
||||
-1.0f,0.0f,-1.0f, -1.0f,0.0f,0.0f,
|
||||
-1.0f,0.382684f,-0.923879f, -1.0f,0.0f,0.0f,
|
||||
-1.0f,0.707107f,-0.707107f, -1.0f,0.0f,0.0f,
|
||||
-1.0f,0.92388f,-0.382683f, -1.0f,0.0f,0.0f,
|
||||
-1.0f,1.0f,-1.62921e-007f, -1.0f,0.0f,0.0f,
|
||||
-1.0f,0.92388f,0.382683f, -1.0f,0.0f,0.0f,
|
||||
-1.0f,0.707107f,0.707107f, -1.0f,0.0f,0.0f,
|
||||
-1.0f,0.382684f,0.92388f, -1.0f,0.0f,0.0f,
|
||||
-1.0f,1.50996e-007f,1.0f, -1.0f,0.0f,0.0f,
|
||||
-1.0f,-0.382683f,0.92388f, -1.0f,0.0f,0.0f,
|
||||
-1.0f,-0.707107f,0.707107f, -1.0f,0.0f,0.0f,
|
||||
-1.0f,-0.92388f,0.382683f, -1.0f,0.0f,0.0f,
|
||||
1.0f,0.0f,0.0f, 1.0f,0.0f,0.0f,
|
||||
1.0f,-1.0f,0.0f, 1.0f,0.0f,0.0f,
|
||||
1.0f,-0.92388f,-0.382683f, 1.0f,0.0f,0.0f,
|
||||
1.0f,-0.707107f,-0.707107f, 1.0f,0.0f,0.0f,
|
||||
1.0f,-0.382684f,-0.92388f, 1.0f,0.0f,0.0f,
|
||||
1.0f,-1.19209e-007f,-1.0f, 1.0f,0.0f,0.0f,
|
||||
1.0f,0.382683f,-0.92388f, 1.0f,0.0f,0.0f,
|
||||
1.0f,0.707107f,-0.707107f, 1.0f,0.0f,0.0f,
|
||||
1.0f,0.923879f,-0.382684f, 1.0f,0.0f,0.0f,
|
||||
1.0f,1.0f,-3.13917e-007f, 1.0f,0.0f,0.0f,
|
||||
1.0f,0.92388f,0.382683f, 1.0f,0.0f,0.0f,
|
||||
1.0f,0.707107f,0.707106f, 1.0f,0.0f,0.0f,
|
||||
1.0f,0.382684f,0.923879f, 1.0f,0.0f,0.0f,
|
||||
1.0f,0.0f,1.0f, 1.0f,0.0f,0.0f,
|
||||
1.0f,-0.382684f,0.923879f, 1.0f,0.0f,0.0f,
|
||||
1.0f,-0.707107f,0.707107f, 1.0f,0.0f,0.0f,
|
||||
1.0f,-0.92388f,0.382683f, 1.0f,0.0f,0.0f,
|
||||
-1.0f,-1.0f,1.62921e-007f, 0.0f,-1.0f,0.0f,
|
||||
1.0f,-0.92388f,-0.382683f, 0.0f,-0.92388f,-0.382683f,
|
||||
1.0f,-1.0f,0.0f, 0.0f,-1.0f,0.0f,
|
||||
-1.0f,-0.923879f,-0.382683f, 0.0f,-0.92388f,-0.382683f,
|
||||
1.0f,-0.707107f,-0.707107f, 0.0f,-0.707107f,-0.707107f,
|
||||
-1.0f,-0.707107f,-0.707107f, 0.0f,-0.707107f,-0.707107f,
|
||||
1.0f,-0.382684f,-0.92388f, 0.0f,-0.382684f,-0.92388f,
|
||||
-1.0f,-0.382683f,-0.923879f, 0.0f,-0.382683f,-0.92388f,
|
||||
1.0f,-1.19209e-007f,-1.0f, 0.0f,0.0f,-1.0f,
|
||||
-1.0f,0.0f,-1.0f, 0.0f,0.0f,-1.0f,
|
||||
-1.0f,0.0f,-1.0f, 0.0f,0.0f,-1.0f,
|
||||
1.0f,0.382683f,-0.92388f, 0.0f,0.382683f,-0.92388f,
|
||||
1.0f,-1.19209e-007f,-1.0f, 0.0f,0.0f,-1.0f,
|
||||
-1.0f,0.382684f,-0.923879f, 0.0f,0.382683f,-0.92388f,
|
||||
1.0f,0.707107f,-0.707107f, 0.0f,0.707107f,-0.707107f,
|
||||
-1.0f,0.707107f,-0.707107f, 0.0f,0.707107f,-0.707107f,
|
||||
1.0f,0.923879f,-0.382684f, 0.0f,0.923879f,-0.382684f,
|
||||
-1.0f,0.92388f,-0.382683f, 0.0f,0.923879f,-0.382684f,
|
||||
1.0f,1.0f,-3.13917e-007f, 0.0f,1.0f,-2.03489e-007f,
|
||||
-1.0f,1.0f,-1.62921e-007f, 0.0f,1.0f,-2.13162e-007f,
|
||||
1.0f,0.92388f,0.382683f, 0.0f,0.92388f,0.382683f,
|
||||
-1.0f,0.92388f,0.382683f, 0.0f,0.92388f,0.382683f,
|
||||
1.0f,0.707107f,0.707106f, 0.0f,0.707107f,0.707107f,
|
||||
-1.0f,0.707107f,0.707107f, 0.0f,0.707107f,0.707107f,
|
||||
1.0f,0.382684f,0.923879f, 0.0f,0.382684f,0.923879f,
|
||||
-1.0f,0.382684f,0.92388f, 0.0f,0.382684f,0.923879f,
|
||||
1.0f,0.0f,1.0f, 0.0f,0.0f,1.0f,
|
||||
-1.0f,1.50996e-007f,1.0f, 0.0f,0.0f,1.0f,
|
||||
1.0f,-0.382684f,0.923879f, 0.0f,-0.382684f,0.92388f,
|
||||
-1.0f,-0.382683f,0.92388f, 0.0f,-0.382683f,0.92388f,
|
||||
1.0f,-0.707107f,0.707107f, 0.0f,-0.707107f,0.707107f,
|
||||
-1.0f,-0.707107f,0.707107f, 0.0f,-0.707107f,0.707107f,
|
||||
1.0f,-0.92388f,0.382683f, 0.0f,-0.92388f,0.382683f,
|
||||
-1.0f,-0.92388f,0.382683f, 0.0f,-0.92388f,0.382683f,
|
||||
};
|
||||
const unsigned short cylinder_idx[] = {
|
||||
0,1,2,
|
||||
0,3,1,
|
||||
0,4,3,
|
||||
0,5,4,
|
||||
0,6,5,
|
||||
0,7,6,
|
||||
0,8,7,
|
||||
0,9,8,
|
||||
0,10,9,
|
||||
0,11,10,
|
||||
0,12,11,
|
||||
0,13,12,
|
||||
0,14,13,
|
||||
0,15,14,
|
||||
0,16,15,
|
||||
0,2,16,
|
||||
17,18,19,
|
||||
17,19,20,
|
||||
17,20,21,
|
||||
17,21,22,
|
||||
17,22,23,
|
||||
17,23,24,
|
||||
17,24,25,
|
||||
17,25,26,
|
||||
17,26,27,
|
||||
17,27,28,
|
||||
17,28,29,
|
||||
17,29,30,
|
||||
17,30,31,
|
||||
17,31,32,
|
||||
17,32,33,
|
||||
17,33,18,
|
||||
34,35,36,
|
||||
34,37,35,
|
||||
37,38,35,
|
||||
37,39,38,
|
||||
39,40,38,
|
||||
39,41,40,
|
||||
41,42,40,
|
||||
41,43,42,
|
||||
44,45,46,
|
||||
44,47,45,
|
||||
47,48,45,
|
||||
47,49,48,
|
||||
49,50,48,
|
||||
49,51,50,
|
||||
51,52,50,
|
||||
51,53,52,
|
||||
53,54,52,
|
||||
53,55,54,
|
||||
55,56,54,
|
||||
55,57,56,
|
||||
57,58,56,
|
||||
57,59,58,
|
||||
59,60,58,
|
||||
59,61,60,
|
||||
61,62,60,
|
||||
61,63,62,
|
||||
63,64,62,
|
||||
63,65,64,
|
||||
65,66,64,
|
||||
65,67,66,
|
||||
67,36,66,
|
||||
67,34,36,
|
||||
};
|
||||
@@ -0,0 +1,241 @@
|
||||
/*
|
||||
Applied Research Associates Inc. (c)2011
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Applied Research Associates Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <jni.h>
|
||||
#include "physicseffects-android.h"
|
||||
#include "../render_func.h"
|
||||
#include "../perf_func.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Java_pfx_renderingsupport_PhysicsEffectsRenderer_nativePhysicsEffectsInit
|
||||
//
|
||||
/// Implementation of JNI function to initilize the simulation and start the
|
||||
/// first scene.
|
||||
///
|
||||
/// @param env Pointer to JNI environment
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
Java_pfx_renderingsupport_PhysicsEffectsRenderer_nativePhysicsEffectsInit( JNIEnv* env )
|
||||
{
|
||||
init();
|
||||
sceneChange();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Java_pfx_renderingsupport_PhysicsEffectsRenderer_nativePhysicsEffectsSimulate
|
||||
//
|
||||
/// Implementation of JNI function to update the simulation and view parameters,
|
||||
/// perform one simulation step, and redraw the scene.
|
||||
///
|
||||
/// @param env Pointer to JNI environment
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
Java_pfx_renderingsupport_PhysicsEffectsRenderer_nativePhysicsEffectsSimulate( JNIEnv* env )
|
||||
{
|
||||
update();
|
||||
physics_simulate();
|
||||
render();
|
||||
perf_sync();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Java_pfx_renderingsupport_PhysicsEffectsRenderer_nativePhysicsEffectsUpdate
|
||||
//
|
||||
/// Implementation of JNI function to update the camera view and simulation
|
||||
/// parameters.
|
||||
///
|
||||
/// @param env Pointer to JNI environment
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
Java_pfx_renderingsupport_PhysicsEffectsRenderer_nativePhysicsEffectsUpdate( JNIEnv* env )
|
||||
{
|
||||
update();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Java_pfx_renderingsupport_PhysicsEffectsRenderer_nativePhysicsEffectsPhysStep
|
||||
//
|
||||
/// Implementation of JNI function to perform one simulation step.
|
||||
///
|
||||
/// @param env Pointer to JNI environment
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
Java_pfx_renderingsupport_PhysicsEffectsRenderer_nativePhysicsEffectsPhysStep( JNIEnv* env )
|
||||
{
|
||||
physics_simulate();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Java_pfx_renderingsupport_PhysicsEffectsRenderer_nativePhysicsEffectsRender
|
||||
//
|
||||
/// Implementation of JNI function to render the scene.
|
||||
///
|
||||
/// @param env Pointer to JNI environment
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
Java_pfx_renderingsupport_PhysicsEffectsRenderer_nativePhysicsEffectsRender( JNIEnv* env )
|
||||
{
|
||||
render();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeSceneChange
|
||||
//
|
||||
/// Implementation of JNI function to change to the next scene.
|
||||
///
|
||||
/// @param env Pointer to JNI environment
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeSceneChange( JNIEnv* env )
|
||||
{
|
||||
sceneChange();
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeCameraUp
|
||||
//
|
||||
/// Implementation of JNI function to tilt the camera up
|
||||
///
|
||||
/// @param env Pointer to JNI environment
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeCameraUp( JNIEnv* env )
|
||||
{
|
||||
float angX, angY, r;
|
||||
render_get_view_angle(angX, angY, r);
|
||||
|
||||
angX -= 0.05f;
|
||||
if(angX < -1.4f) angX = -1.4f;
|
||||
if(angX > -0.01f) angX = -0.01f;
|
||||
|
||||
render_set_view_angle(angX, angY, r);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeCameraDown
|
||||
//
|
||||
/// Implementation of JNI function to tilt the camera down
|
||||
///
|
||||
/// @param env Pointer to JNI environment
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeCameraDown( JNIEnv* env )
|
||||
{
|
||||
float angX, angY, r;
|
||||
render_get_view_angle(angX, angY, r);
|
||||
|
||||
angX += 0.05f;
|
||||
if(angX < -1.4f) angX = -1.4f;
|
||||
if(angX > -0.01f) angX = -0.01f;
|
||||
|
||||
render_set_view_angle(angX, angY, r);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeCameraLeft
|
||||
//
|
||||
/// Implementation of JNI function to tilt the camera left
|
||||
///
|
||||
/// @param env Pointer to JNI environment
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeCameraLeft( JNIEnv* env )
|
||||
{
|
||||
float angX, angY, r;
|
||||
render_get_view_angle(angX, angY, r);
|
||||
|
||||
angY -= 0.05f;
|
||||
|
||||
render_set_view_angle(angX, angY, r);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeCameraRight
|
||||
//
|
||||
/// Implementation of JNI function to tilt the camera right
|
||||
///
|
||||
/// @param env Pointer to JNI environment
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeCameraRight( JNIEnv* env )
|
||||
{
|
||||
float angX, angY, r;
|
||||
render_get_view_angle(angX, angY, r);
|
||||
|
||||
angY += 0.05f;
|
||||
|
||||
render_set_view_angle(angX, angY, r);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeCameraZoomOut
|
||||
//
|
||||
/// Implementation of JNI function to dolly the camera away from scene,
|
||||
/// effectively zooming out.
|
||||
///
|
||||
/// @param env Pointer to JNI environment
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeCameraZoomOut( JNIEnv* env )
|
||||
{
|
||||
float angX, angY, r;
|
||||
render_get_view_angle(angX, angY, r);
|
||||
|
||||
r *= 1.1f;
|
||||
if(r > 500.0f) r = 500.0f;
|
||||
|
||||
render_set_view_angle(angX, angY, r);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeCameraZoomIn
|
||||
//
|
||||
/// Implementation of JNI function to dolly the camera towards scene,
|
||||
/// effectively zooming in.
|
||||
///
|
||||
/// @param env Pointer to JNI environment
|
||||
//----------------------------------------------------------------------------
|
||||
void
|
||||
Java_pfx_renderingsupport_PhysicsEffectsGLSurfaceView_nativeCameraZoomIn( JNIEnv* env )
|
||||
{
|
||||
float angX, angY, r;
|
||||
render_get_view_angle(angX, angY, r);
|
||||
|
||||
r *= 0.9f;
|
||||
if(r < 1.0f) r = 1.0f;
|
||||
|
||||
render_set_view_angle(angX, angY, r);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,40 @@
|
||||
/*
|
||||
Applied Research Associates Inc. (c)2011
|
||||
|
||||
Redistribution and use in source and binary forms,
|
||||
with or without modification, are permitted provided that the
|
||||
following conditions are met:
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Applied Research Associates Inc nor the names
|
||||
of its contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef PHYSICSEFFECTS_ANDROID_H
|
||||
#define PHYSICSEFFECTS_ANDROID_H
|
||||
|
||||
// The following C++ functions must be provided by the
|
||||
// sample application.
|
||||
extern int init();
|
||||
extern void render(void);
|
||||
extern void sceneChange();
|
||||
extern void update(void);
|
||||
extern void physics_simulate();
|
||||
|
||||
#endif // !PHYSICSEFFECTS_ANDROID_H
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Physics Effects is open software; you can redistribute it and/or
|
||||
modify it under the terms of the BSD License.
|
||||
|
||||
Physics Effects is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the BSD License for more details.
|
||||
|
||||
A copy of the BSD License is distributed with
|
||||
Physics Effects under the filename: physics_effects_license.txt
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "perf_func.h"
|
||||
|
||||
void perf_init()
|
||||
{
|
||||
}
|
||||
|
||||
void perf_release()
|
||||
{
|
||||
}
|
||||
|
||||
void perf_push_marker(char *str)
|
||||
{
|
||||
}
|
||||
|
||||
void perf_pop_marker()
|
||||
{
|
||||
}
|
||||
|
||||
void perf_sync()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Physics Effects is open software; you can redistribute it and/or
|
||||
modify it under the terms of the BSD License.
|
||||
|
||||
Physics Effects is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the BSD License for more details.
|
||||
|
||||
A copy of the BSD License is distributed with
|
||||
Physics Effects under the filename: physics_effects_license.txt
|
||||
*/
|
||||
|
||||
#ifndef __PERF_FUNC_H__
|
||||
#define __PERF_FUNC_H__
|
||||
|
||||
void perf_init();
|
||||
void perf_release();
|
||||
void perf_push_marker(char *str);
|
||||
void perf_pop_marker();
|
||||
void perf_sync();
|
||||
|
||||
#endif /* __PERF_FUNC_H__ */
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Physics Effects is open software; you can redistribute it and/or
|
||||
modify it under the terms of the BSD License.
|
||||
|
||||
Physics Effects is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the BSD License for more details.
|
||||
|
||||
A copy of the BSD License is distributed with
|
||||
Physics Effects under the filename: physics_effects_license.txt
|
||||
*/
|
||||
|
||||
#include "common.h"
|
||||
#include "perf_func.h"
|
||||
|
||||
void perf_init()
|
||||
{
|
||||
}
|
||||
|
||||
void perf_release()
|
||||
{
|
||||
}
|
||||
|
||||
void perf_push_marker(char *str)
|
||||
{
|
||||
}
|
||||
|
||||
void perf_pop_marker()
|
||||
{
|
||||
}
|
||||
|
||||
void perf_sync()
|
||||
{
|
||||
}
|
||||
@@ -0,0 +1,486 @@
|
||||
/*
|
||||
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Physics Effects is open software; you can redistribute it and/or
|
||||
modify it under the terms of the BSD License.
|
||||
|
||||
Physics Effects is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the BSD License for more details.
|
||||
|
||||
A copy of the BSD License is distributed with
|
||||
Physics Effects under the filename: physics_effects_license.txt
|
||||
*/
|
||||
|
||||
#include "render_func.h"
|
||||
|
||||
#include "box.h"
|
||||
#include "sphere.h"
|
||||
#include "cylinder.h"
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <GLES/gl.h>
|
||||
|
||||
// local variables
|
||||
static int screen_width,screen_height;
|
||||
static PfxMatrix4 g_pMat,g_vMat;
|
||||
static PfxVector3 g_viewPos,g_lightPos,g_viewTgt;
|
||||
static float lightRadius,lightRadX,lightRadY;
|
||||
static float viewRadius,viewRadX,viewRadY,viewHeight;
|
||||
|
||||
static unsigned short *box_wire_idx;
|
||||
static unsigned short *sphere_wire_idx;
|
||||
static unsigned short *cylinder_wire_idx;
|
||||
|
||||
#define MAX_MESH 5
|
||||
|
||||
static struct MeshBuff {
|
||||
float *vtx;
|
||||
float *nml;
|
||||
int numVtx;
|
||||
unsigned short *idx;
|
||||
unsigned short *wire_idx;
|
||||
int numIdx;
|
||||
} meshBuff[MAX_MESH];
|
||||
int numMesh;
|
||||
|
||||
void render_init()
|
||||
{
|
||||
screen_width = DISPLAY_WIDTH;
|
||||
screen_height = DISPLAY_HEIGHT;
|
||||
|
||||
// initalize matrix
|
||||
g_pMat = PfxMatrix4::perspective(3.1415f/4.0f, (float)screen_width/(float)screen_height,0.1f, 1000.0f);
|
||||
|
||||
// initalize parameters
|
||||
lightRadius = 40.0f;
|
||||
lightRadX = -0.6f;
|
||||
lightRadY = 0.6f;
|
||||
viewRadius = 40.0f;
|
||||
viewRadX = -0.01f;
|
||||
viewRadY = 0.0f;
|
||||
viewHeight = 1.0f;
|
||||
|
||||
g_viewTgt = PfxVector3(0.0f,viewHeight,0.0f);
|
||||
|
||||
box_wire_idx = new unsigned short [NUM_BOX_IDX*2];
|
||||
sphere_wire_idx = new unsigned short [NUM_SPHERE_IDX*2];
|
||||
cylinder_wire_idx = new unsigned short [NUM_CYLINDER_IDX*2];
|
||||
|
||||
for(int i=0;i<NUM_BOX_IDX/3;i++) {
|
||||
box_wire_idx[i*6 ] = box_idx[i*3 ];
|
||||
box_wire_idx[i*6+1] = box_idx[i*3+1];
|
||||
box_wire_idx[i*6+2] = box_idx[i*3+1];
|
||||
box_wire_idx[i*6+3] = box_idx[i*3+2];
|
||||
box_wire_idx[i*6+4] = box_idx[i*3+2];
|
||||
box_wire_idx[i*6+5] = box_idx[i*3 ];
|
||||
}
|
||||
|
||||
for(int i=0;i<NUM_SPHERE_IDX/3;i++) {
|
||||
sphere_wire_idx[i*6 ] = sphere_idx[i*3 ];
|
||||
sphere_wire_idx[i*6+1] = sphere_idx[i*3+1];
|
||||
sphere_wire_idx[i*6+2] = sphere_idx[i*3+1];
|
||||
sphere_wire_idx[i*6+3] = sphere_idx[i*3+2];
|
||||
sphere_wire_idx[i*6+4] = sphere_idx[i*3+2];
|
||||
sphere_wire_idx[i*6+5] = sphere_idx[i*3 ];
|
||||
}
|
||||
|
||||
for(int i=0;i<NUM_CYLINDER_IDX/3;i++) {
|
||||
cylinder_wire_idx[i*6 ] = cylinder_idx[i*3 ];
|
||||
cylinder_wire_idx[i*6+1] = cylinder_idx[i*3+1];
|
||||
cylinder_wire_idx[i*6+2] = cylinder_idx[i*3+1];
|
||||
cylinder_wire_idx[i*6+3] = cylinder_idx[i*3+2];
|
||||
cylinder_wire_idx[i*6+4] = cylinder_idx[i*3+2];
|
||||
cylinder_wire_idx[i*6+5] = cylinder_idx[i*3 ];
|
||||
}
|
||||
|
||||
numMesh = 0;
|
||||
}
|
||||
|
||||
void render_release()
|
||||
{
|
||||
delete [] box_wire_idx;
|
||||
delete [] sphere_wire_idx;
|
||||
delete [] cylinder_wire_idx;
|
||||
|
||||
if(numMesh > 0) {
|
||||
for(int i=0;i<numMesh;i++) {
|
||||
if(meshBuff[i].vtx) delete [] meshBuff[i].vtx;
|
||||
if(meshBuff[i].nml) delete [] meshBuff[i].nml;
|
||||
if(meshBuff[i].idx) delete [] meshBuff[i].idx;
|
||||
if(meshBuff[i].wire_idx) delete [] meshBuff[i].wire_idx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void render_begin()
|
||||
{
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glFrontFace(GL_CCW);
|
||||
glDepthFunc(GL_LESS);
|
||||
glCullFace(GL_BACK);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_CULL_FACE);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glMultMatrixf((GLfloat*)&g_pMat);
|
||||
|
||||
// create view matrix
|
||||
g_viewPos =
|
||||
PfxMatrix3::rotationY(viewRadY) *
|
||||
PfxMatrix3::rotationX(viewRadX) *
|
||||
PfxVector3(0,0,viewRadius);
|
||||
|
||||
g_lightPos =
|
||||
PfxMatrix3::rotationY(lightRadY) *
|
||||
PfxMatrix3::rotationX(lightRadX) *
|
||||
PfxVector3(0,0,lightRadius);
|
||||
|
||||
PfxMatrix4 viewMtx = PfxMatrix4::lookAt(PfxPoint3(g_viewTgt + g_viewPos),PfxPoint3(g_viewTgt),PfxVector3(0,1,0));
|
||||
|
||||
g_vMat = g_pMat * viewMtx;
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glMultMatrixf((GLfloat*)&viewMtx);
|
||||
}
|
||||
|
||||
void render_end()
|
||||
{
|
||||
}
|
||||
|
||||
void render_debug_begin()
|
||||
{
|
||||
glDepthMask(GL_FALSE);
|
||||
}
|
||||
|
||||
void render_debug_end()
|
||||
{
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
|
||||
void render_get_view_angle(float &angleX,float &angleY,float &radius)
|
||||
{
|
||||
angleX = viewRadX;
|
||||
angleY = viewRadY;
|
||||
radius = viewRadius;
|
||||
}
|
||||
|
||||
void render_set_view_angle(float angleX,float angleY,float radius)
|
||||
{
|
||||
viewRadX = angleX;
|
||||
viewRadY = angleY;
|
||||
viewRadius = radius;
|
||||
}
|
||||
|
||||
void render_sphere(
|
||||
const PfxTransform3 &transform,
|
||||
const PfxVector3 &color,
|
||||
const PfxFloatInVec &radius)
|
||||
{
|
||||
PfxMatrix4 wMtx = PfxMatrix4(transform) * PfxMatrix4::scale(PfxVector3(radius));
|
||||
|
||||
glPushMatrix();
|
||||
glMultMatrixf((GLfloat*)&wMtx);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glVertexPointer(3,GL_FLOAT,24,sphere_vtx);
|
||||
|
||||
glColor4f(color[0], color[1], color[2], 1.0);
|
||||
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||
glPolygonOffset(1.0f,1.0f);
|
||||
glDrawElements(GL_TRIANGLES,NUM_SPHERE_IDX,GL_UNSIGNED_SHORT,sphere_idx);
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
|
||||
glColor4f(0.0f,0.0f,0.0f, 1.0);
|
||||
glDrawElements(GL_LINES,NUM_SPHERE_IDX*2,GL_UNSIGNED_SHORT,sphere_wire_idx);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void render_box(
|
||||
const PfxTransform3 &transform,
|
||||
const PfxVector3 &color,
|
||||
const PfxVector3 &halfExtent)
|
||||
{
|
||||
PfxMatrix4 wMtx = PfxMatrix4(transform) * PfxMatrix4::scale(2.0f*halfExtent);
|
||||
|
||||
glPushMatrix();
|
||||
glMultMatrixf((GLfloat*)&wMtx);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glVertexPointer(3,GL_FLOAT,24,box_vtx);
|
||||
|
||||
glColor4f(color[0], color[1], color[2], 1.0);
|
||||
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||
glPolygonOffset(1.0f,1.0f);
|
||||
glDrawElements(GL_TRIANGLES,NUM_BOX_IDX,GL_UNSIGNED_SHORT,box_idx);
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
|
||||
glColor4f(0.0f,0.0f,0.0f, 1.0);
|
||||
glDrawElements(GL_LINES,NUM_BOX_IDX*2,GL_UNSIGNED_SHORT,box_wire_idx);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void render_cylinder(
|
||||
const PfxTransform3 &transform,
|
||||
const PfxVector3 &color,
|
||||
const PfxFloatInVec &radius,
|
||||
const PfxFloatInVec &halfLength)
|
||||
{
|
||||
PfxVector3 scale(halfLength,radius,radius);
|
||||
|
||||
PfxMatrix4 wMtx = PfxMatrix4(transform) * PfxMatrix4::scale(scale);
|
||||
|
||||
glPushMatrix();
|
||||
glMultMatrixf((GLfloat*)&wMtx);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glVertexPointer(3,GL_FLOAT,24,cylinder_vtx);
|
||||
|
||||
glColor4f(color[0], color[1], color[2], 1.0);
|
||||
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||
glPolygonOffset(1.0f,1.0f);
|
||||
glDrawElements(GL_TRIANGLES,NUM_CYLINDER_IDX,GL_UNSIGNED_SHORT,cylinder_idx);
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
|
||||
glColor4f(0.0f,0.0f,0.0f,1.0);
|
||||
glDrawElements(GL_LINES,NUM_CYLINDER_IDX*2,GL_UNSIGNED_SHORT,cylinder_wire_idx);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void render_capsule(
|
||||
const PfxTransform3 &transform,
|
||||
const PfxVector3 &color,
|
||||
const PfxFloatInVec &radius,
|
||||
const PfxFloatInVec &halfLength)
|
||||
{
|
||||
PfxTransform3 tr1 = PfxTransform3::translation(PfxVector3(-halfLength,0.0f,0.0f));
|
||||
PfxTransform3 tr2 = PfxTransform3::translation(PfxVector3(halfLength,0.0f,0.0f));
|
||||
|
||||
render_sphere(transform*tr1,color,radius);
|
||||
render_sphere(transform*tr2,color,radius);
|
||||
|
||||
render_cylinder(transform,color,radius,halfLength);
|
||||
}
|
||||
|
||||
int render_init_mesh(
|
||||
const float *vtx,unsigned int vtxStrideBytes,
|
||||
const float *nml,unsigned int nmlStrideBytes,
|
||||
const unsigned short *tri,unsigned int triStrideBytes,
|
||||
int numVtx,int numTri)
|
||||
{
|
||||
assert(numMesh<MAX_MESH);
|
||||
|
||||
MeshBuff &buff = meshBuff[numMesh++];
|
||||
buff.vtx = new float [3*numVtx];
|
||||
buff.nml = new float [3*numVtx];
|
||||
buff.idx = new unsigned short [numTri*3];
|
||||
buff.wire_idx = new unsigned short [numTri*6];
|
||||
buff.numIdx = numTri*3;
|
||||
buff.numVtx = numVtx;
|
||||
|
||||
for(int i=0;i<numVtx;i++) {
|
||||
const float *v = (float*)((uintptr_t)vtx + vtxStrideBytes * i);
|
||||
const float *n = (float*)((uintptr_t)nml + nmlStrideBytes * i);
|
||||
buff.vtx[i*3 ] = v[0];
|
||||
buff.vtx[i*3+1] = v[1];
|
||||
buff.vtx[i*3+2] = v[2];
|
||||
buff.nml[i*3 ] = n[0];
|
||||
buff.nml[i*3+1] = n[1];
|
||||
buff.nml[i*3+2] = n[2];
|
||||
}
|
||||
|
||||
for(int i=0;i<numTri;i++) {
|
||||
const unsigned short *idx = (unsigned short*)((uintptr_t)tri + triStrideBytes * i);
|
||||
buff.idx[i*3 ] = idx[0];
|
||||
buff.idx[i*3+1] = idx[1];
|
||||
buff.idx[i*3+2] = idx[2];
|
||||
buff.wire_idx[i*6 ] = buff.idx[i*3 ];
|
||||
buff.wire_idx[i*6+1] = buff.idx[i*3+1];
|
||||
buff.wire_idx[i*6+2] = buff.idx[i*3+1];
|
||||
buff.wire_idx[i*6+3] = buff.idx[i*3+2];
|
||||
buff.wire_idx[i*6+4] = buff.idx[i*3+2];
|
||||
buff.wire_idx[i*6+5] = buff.idx[i*3 ];
|
||||
}
|
||||
|
||||
return numMesh-1;
|
||||
}
|
||||
|
||||
void render_mesh(
|
||||
const PfxTransform3 &transform,
|
||||
const PfxVector3 &color,
|
||||
int meshId)
|
||||
{
|
||||
assert(meshId>=0&&meshId<MAX_MESH);
|
||||
|
||||
MeshBuff &buff = meshBuff[meshId];
|
||||
|
||||
PfxMatrix4 wMtx = PfxMatrix4(transform);
|
||||
|
||||
glPushMatrix();
|
||||
glMultMatrixf((GLfloat*)&wMtx);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glVertexPointer(3,GL_FLOAT,0,buff.vtx);
|
||||
|
||||
glColor4f(color[0], color[1], color[2], 1.0);
|
||||
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||
glPolygonOffset(1.0f,1.0f);
|
||||
glDrawElements(GL_TRIANGLES,buff.numIdx,GL_UNSIGNED_SHORT,buff.idx);
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
|
||||
glColor4f(0.0f,0.0f,0.0f,1.0);
|
||||
glDrawElements(GL_LINES,buff.numIdx*2,GL_UNSIGNED_SHORT,buff.wire_idx);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void render_resize(int width,int height)
|
||||
{
|
||||
glViewport(0,0,width,height);
|
||||
g_pMat = PfxMatrix4::perspective(3.1415f/4.0f, (float)width/(float)height,0.1f, 1000.0f);
|
||||
screen_width = width;
|
||||
screen_height = height;
|
||||
}
|
||||
|
||||
void render_debug_point(
|
||||
const PfxVector3 &position,
|
||||
const PfxVector3 &color)
|
||||
{
|
||||
glColor4f(color[0], color[1], color[2], 1.0);
|
||||
|
||||
glPointSize(5.0f);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3,GL_FLOAT,16,(float*)&position);
|
||||
glDrawArrays(GL_POINTS,0,1);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glPointSize(1.0f);
|
||||
}
|
||||
|
||||
void render_debug_line(
|
||||
const PfxVector3 &position1,
|
||||
const PfxVector3 &position2,
|
||||
const PfxVector3 &color)
|
||||
{
|
||||
glColor4f(color[0], color[1], color[2], 1.0);
|
||||
|
||||
const PfxVector3 points[2] = {
|
||||
position1,
|
||||
position2,
|
||||
};
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3,GL_FLOAT,16,(float*)points);
|
||||
glDrawArrays(GL_LINES,0,2);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
void render_debug_box(
|
||||
const PfxVector3 ¢er,
|
||||
const PfxVector3 &extent,
|
||||
const PfxVector3 &color)
|
||||
{
|
||||
const PfxVector3 points[8] = {
|
||||
center + mulPerElem(PfxVector3(-1,-1,-1),extent),
|
||||
center + mulPerElem(PfxVector3(-1,-1, 1),extent),
|
||||
center + mulPerElem(PfxVector3( 1,-1, 1),extent),
|
||||
center + mulPerElem(PfxVector3( 1,-1,-1),extent),
|
||||
center + mulPerElem(PfxVector3(-1, 1,-1),extent),
|
||||
center + mulPerElem(PfxVector3(-1, 1, 1),extent),
|
||||
center + mulPerElem(PfxVector3( 1, 1, 1),extent),
|
||||
center + mulPerElem(PfxVector3( 1, 1,-1),extent),
|
||||
};
|
||||
|
||||
const unsigned short indices[] = {
|
||||
0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7,
|
||||
};
|
||||
|
||||
glColor4f(color[0], color[1], color[2], 1.0);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3,GL_FLOAT,16,(float*)points);
|
||||
glDrawElements(GL_LINES,24,GL_UNSIGNED_SHORT,indices);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
PfxVector3 render_get_world_position(const PfxVector3 &screenPos)
|
||||
{
|
||||
PfxMatrix4 mvp,mvpInv;
|
||||
mvp = g_vMat;
|
||||
mvpInv = inverse(mvp);
|
||||
|
||||
PfxVector4 wp(screenPos,1.0f);
|
||||
|
||||
wp[0] /= (0.5f * (float)screen_width);
|
||||
wp[1] /= (0.5f * (float)screen_height);
|
||||
|
||||
float w = mvpInv[0][3] * wp[0] +
|
||||
mvpInv[1][3] * wp[1] +
|
||||
mvpInv[2][3] * wp[2] +
|
||||
mvpInv[3][3];
|
||||
|
||||
wp = mvpInv * wp;
|
||||
wp /= w;
|
||||
|
||||
return wp.getXYZ();
|
||||
}
|
||||
|
||||
PfxVector3 render_get_screen_position(const PfxVector3 &worldPos)
|
||||
{
|
||||
PfxVector4 sp(worldPos,1.0f);
|
||||
|
||||
PfxMatrix4 mvp;
|
||||
mvp = g_vMat;
|
||||
|
||||
sp = mvp * sp;
|
||||
sp /= sp[3];
|
||||
sp[0] *= (0.5f * (float)screen_width);
|
||||
sp[1] *= (0.5f * (float)screen_height);
|
||||
|
||||
return sp.getXYZ();
|
||||
}
|
||||
|
||||
void render_get_screent_size(int &width,int &height)
|
||||
{
|
||||
width = screen_width;
|
||||
height = screen_height;
|
||||
}
|
||||
|
||||
void render_get_view_target(PfxVector3 &targetPos)
|
||||
{
|
||||
targetPos = g_viewTgt;
|
||||
}
|
||||
|
||||
void render_set_view_target(const PfxVector3 &targetPos)
|
||||
{
|
||||
g_viewTgt = targetPos;
|
||||
}
|
||||
|
||||
void render_get_view_radius(float &radius)
|
||||
{
|
||||
radius = viewRadius;
|
||||
}
|
||||
|
||||
void render_set_view_radius(float radius)
|
||||
{
|
||||
viewRadius = radius;
|
||||
}
|
||||
@@ -0,0 +1,106 @@
|
||||
/*
|
||||
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Physics Effects is open software; you can redistribute it and/or
|
||||
modify it under the terms of the BSD License.
|
||||
|
||||
Physics Effects is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the BSD License for more details.
|
||||
|
||||
A copy of the BSD License is distributed with
|
||||
Physics Effects under the filename: physics_effects_license.txt
|
||||
*/
|
||||
|
||||
#ifndef __RENDER_FUNC_H__
|
||||
#define __RENDER_FUNC_H__
|
||||
|
||||
#include "common.h"
|
||||
#include "physics_effects.h"
|
||||
|
||||
using namespace sce::PhysicsEffects;
|
||||
|
||||
#define DISPLAY_WIDTH 640
|
||||
#define DISPLAY_HEIGHT 480
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Draw Primitives
|
||||
|
||||
void render_init();
|
||||
void render_release();
|
||||
void render_begin();
|
||||
void render_end();
|
||||
|
||||
void render_sphere(
|
||||
const PfxTransform3 &transform,
|
||||
const PfxVector3 &color,
|
||||
const PfxFloatInVec &radius);
|
||||
|
||||
void render_box(
|
||||
const PfxTransform3 &transform,
|
||||
const PfxVector3 &color,
|
||||
const PfxVector3 &halfExtent);
|
||||
|
||||
void render_cylinder(
|
||||
const PfxTransform3 &transform,
|
||||
const PfxVector3 &color,
|
||||
const PfxFloatInVec &radius,
|
||||
const PfxFloatInVec &halfLength);
|
||||
|
||||
void render_capsule(
|
||||
const PfxTransform3 &transform,
|
||||
const PfxVector3 &color,
|
||||
const PfxFloatInVec &radius,
|
||||
const PfxFloatInVec &halfLength);
|
||||
|
||||
int render_init_mesh(
|
||||
const float *vtx,unsigned int vtxStrideBytes,
|
||||
const float *nml,unsigned int nmlStrideBytes,
|
||||
const unsigned short *tri,unsigned int triStrideBytes,
|
||||
int numVtx,int numTri);
|
||||
|
||||
void render_mesh(
|
||||
const PfxTransform3 &transform,
|
||||
const PfxVector3 &color,
|
||||
int meshId);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Debug Drawing
|
||||
|
||||
void render_debug_begin();
|
||||
void render_debug_end();
|
||||
|
||||
void render_debug_point(
|
||||
const PfxVector3 &position,
|
||||
const PfxVector3 &color);
|
||||
|
||||
void render_debug_line(
|
||||
const PfxVector3 &position1,
|
||||
const PfxVector3 &position2,
|
||||
const PfxVector3 &color);
|
||||
|
||||
void render_debug_box(
|
||||
const PfxVector3 ¢er,
|
||||
const PfxVector3 &extent,
|
||||
const PfxVector3 &color);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Render Parameter
|
||||
|
||||
void render_get_view_angle(float &angleX,float &angleY,float &radius);
|
||||
void render_set_view_angle(float angleX,float angleY,float radius);
|
||||
void render_resize(int width,int height);
|
||||
|
||||
void render_get_view_target(PfxVector3 &targetPos);
|
||||
void render_set_view_target(const PfxVector3 &targetPos);
|
||||
void render_get_view_radius(float &radius);
|
||||
void render_set_view_radius(float radius);
|
||||
|
||||
void render_get_screent_size(int &width,int &height);
|
||||
|
||||
PfxVector3 render_get_world_position(const PfxVector3 &screenPos);
|
||||
PfxVector3 render_get_screen_position(const PfxVector3 &worldPos);
|
||||
|
||||
#endif /* __RENDER_FUNC_H__ */
|
||||
@@ -0,0 +1,491 @@
|
||||
/*
|
||||
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Physics Effects is open software; you can redistribute it and/or
|
||||
modify it under the terms of the BSD License.
|
||||
|
||||
Physics Effects is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the BSD License for more details.
|
||||
|
||||
A copy of the BSD License is distributed with
|
||||
Physics Effects under the filename: physics_effects_license.txt
|
||||
*/
|
||||
|
||||
#include "render_func.h"
|
||||
|
||||
#include <gl/gl.h>
|
||||
|
||||
#include "box.h"
|
||||
#include "sphere.h"
|
||||
#include "cylinder.h"
|
||||
|
||||
// context
|
||||
HDC hDC;
|
||||
HGLRC hRC;
|
||||
|
||||
// local variables
|
||||
static int screen_width,screen_height;
|
||||
static PfxMatrix4 g_pMat,g_vMat;
|
||||
static PfxVector3 g_viewPos,g_lightPos,g_viewTgt;
|
||||
static float lightRadius,lightRadX,lightRadY;
|
||||
static float viewRadius,viewRadX,viewRadY,viewHeight;
|
||||
|
||||
static unsigned short *box_wire_idx;
|
||||
static unsigned short *sphere_wire_idx;
|
||||
static unsigned short *cylinder_wire_idx;
|
||||
|
||||
#define MAX_MESH 5
|
||||
|
||||
static struct MeshBuff {
|
||||
float *vtx;
|
||||
float *nml;
|
||||
int numVtx;
|
||||
unsigned short *idx;
|
||||
unsigned short *wire_idx;
|
||||
int numIdx;
|
||||
} meshBuff[MAX_MESH];
|
||||
int numMesh;
|
||||
|
||||
void render_init()
|
||||
{
|
||||
screen_width = DISPLAY_WIDTH;
|
||||
screen_height = DISPLAY_HEIGHT;
|
||||
|
||||
// initalize matrix
|
||||
g_pMat = PfxMatrix4::perspective(3.1415f/4.0f, (float)screen_width/(float)screen_height,0.1f, 1000.0f);
|
||||
|
||||
// initalize parameters
|
||||
lightRadius = 40.0f;
|
||||
lightRadX = -0.6f;
|
||||
lightRadY = 0.6f;
|
||||
viewRadius = 40.0f;
|
||||
viewRadX = -0.01f;
|
||||
viewRadY = 0.0f;
|
||||
viewHeight = 1.0f;
|
||||
|
||||
g_viewTgt = PfxVector3(0.0f,viewHeight,0.0f);
|
||||
|
||||
box_wire_idx = new unsigned short [NUM_BOX_IDX*2];
|
||||
sphere_wire_idx = new unsigned short [NUM_SPHERE_IDX*2];
|
||||
cylinder_wire_idx = new unsigned short [NUM_CYLINDER_IDX*2];
|
||||
|
||||
for(int i=0;i<NUM_BOX_IDX/3;i++) {
|
||||
box_wire_idx[i*6 ] = box_idx[i*3 ];
|
||||
box_wire_idx[i*6+1] = box_idx[i*3+1];
|
||||
box_wire_idx[i*6+2] = box_idx[i*3+1];
|
||||
box_wire_idx[i*6+3] = box_idx[i*3+2];
|
||||
box_wire_idx[i*6+4] = box_idx[i*3+2];
|
||||
box_wire_idx[i*6+5] = box_idx[i*3 ];
|
||||
}
|
||||
|
||||
for(int i=0;i<NUM_SPHERE_IDX/3;i++) {
|
||||
sphere_wire_idx[i*6 ] = sphere_idx[i*3 ];
|
||||
sphere_wire_idx[i*6+1] = sphere_idx[i*3+1];
|
||||
sphere_wire_idx[i*6+2] = sphere_idx[i*3+1];
|
||||
sphere_wire_idx[i*6+3] = sphere_idx[i*3+2];
|
||||
sphere_wire_idx[i*6+4] = sphere_idx[i*3+2];
|
||||
sphere_wire_idx[i*6+5] = sphere_idx[i*3 ];
|
||||
}
|
||||
|
||||
for(int i=0;i<NUM_CYLINDER_IDX/3;i++) {
|
||||
cylinder_wire_idx[i*6 ] = cylinder_idx[i*3 ];
|
||||
cylinder_wire_idx[i*6+1] = cylinder_idx[i*3+1];
|
||||
cylinder_wire_idx[i*6+2] = cylinder_idx[i*3+1];
|
||||
cylinder_wire_idx[i*6+3] = cylinder_idx[i*3+2];
|
||||
cylinder_wire_idx[i*6+4] = cylinder_idx[i*3+2];
|
||||
cylinder_wire_idx[i*6+5] = cylinder_idx[i*3 ];
|
||||
}
|
||||
|
||||
numMesh = 0;
|
||||
}
|
||||
|
||||
void render_release()
|
||||
{
|
||||
delete [] box_wire_idx;
|
||||
delete [] sphere_wire_idx;
|
||||
delete [] cylinder_wire_idx;
|
||||
|
||||
if(numMesh > 0) {
|
||||
for(int i=0;i<numMesh;i++) {
|
||||
if(meshBuff[i].vtx) delete [] meshBuff[i].vtx;
|
||||
if(meshBuff[i].nml) delete [] meshBuff[i].nml;
|
||||
if(meshBuff[i].idx) delete [] meshBuff[i].idx;
|
||||
if(meshBuff[i].wire_idx) delete [] meshBuff[i].wire_idx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void render_begin()
|
||||
{
|
||||
wglMakeCurrent(hDC, hRC);
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
|
||||
glFrontFace(GL_CCW);
|
||||
glDepthFunc(GL_LESS);
|
||||
glCullFace(GL_BACK);
|
||||
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glEnable(GL_CULL_FACE);
|
||||
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
glLoadIdentity();
|
||||
glMultMatrixf((GLfloat*)&g_pMat);
|
||||
|
||||
// create view matrix
|
||||
g_viewPos =
|
||||
PfxMatrix3::rotationY(viewRadY) *
|
||||
PfxMatrix3::rotationX(viewRadX) *
|
||||
PfxVector3(0,0,viewRadius);
|
||||
|
||||
g_lightPos =
|
||||
PfxMatrix3::rotationY(lightRadY) *
|
||||
PfxMatrix3::rotationX(lightRadX) *
|
||||
PfxVector3(0,0,lightRadius);
|
||||
|
||||
PfxMatrix4 viewMtx = PfxMatrix4::lookAt(PfxPoint3(g_viewTgt + g_viewPos),PfxPoint3(g_viewTgt),PfxVector3(0,1,0));
|
||||
|
||||
g_vMat = g_pMat * viewMtx;
|
||||
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
glLoadIdentity();
|
||||
glMultMatrixf((GLfloat*)&viewMtx);
|
||||
}
|
||||
|
||||
void render_end()
|
||||
{
|
||||
SwapBuffers(hDC);
|
||||
}
|
||||
|
||||
void render_debug_begin()
|
||||
{
|
||||
glDepthMask(GL_FALSE);
|
||||
}
|
||||
|
||||
void render_debug_end()
|
||||
{
|
||||
glDepthMask(GL_TRUE);
|
||||
}
|
||||
|
||||
void render_get_view_angle(float &angleX,float &angleY,float &radius)
|
||||
{
|
||||
angleX = viewRadX;
|
||||
angleY = viewRadY;
|
||||
radius = viewRadius;
|
||||
}
|
||||
|
||||
void render_set_view_angle(float angleX,float angleY,float radius)
|
||||
{
|
||||
viewRadX = angleX;
|
||||
viewRadY = angleY;
|
||||
viewRadius = radius;
|
||||
}
|
||||
|
||||
void render_sphere(
|
||||
const PfxTransform3 &transform,
|
||||
const PfxVector3 &color,
|
||||
const PfxFloatInVec &radius)
|
||||
{
|
||||
PfxMatrix4 wMtx = PfxMatrix4(transform) * PfxMatrix4::scale(PfxVector3(radius));
|
||||
|
||||
glPushMatrix();
|
||||
glMultMatrixf((GLfloat*)&wMtx);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glVertexPointer(3,GL_FLOAT,24,sphere_vtx);
|
||||
|
||||
glColor3fv((float*)&color);
|
||||
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||
glPolygonOffset(1.0f,1.0f);
|
||||
glDrawElements(GL_TRIANGLES,NUM_SPHERE_IDX,GL_UNSIGNED_SHORT,sphere_idx);
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
|
||||
glColor3f(0.0f,0.0f,0.0f);
|
||||
glDrawElements(GL_LINES,NUM_SPHERE_IDX*2,GL_UNSIGNED_SHORT,sphere_wire_idx);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void render_box(
|
||||
const PfxTransform3 &transform,
|
||||
const PfxVector3 &color,
|
||||
const PfxVector3 &halfExtent)
|
||||
{
|
||||
PfxMatrix4 wMtx = PfxMatrix4(transform) * PfxMatrix4::scale(2.0f*halfExtent);
|
||||
|
||||
glPushMatrix();
|
||||
glMultMatrixf((GLfloat*)&wMtx);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glVertexPointer(3,GL_FLOAT,24,box_vtx);
|
||||
|
||||
glColor3fv((float*)&color);
|
||||
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||
glPolygonOffset(1.0f,1.0f);
|
||||
glDrawElements(GL_TRIANGLES,NUM_BOX_IDX,GL_UNSIGNED_SHORT,box_idx);
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
|
||||
glColor3f(0.0f,0.0f,0.0f);
|
||||
glDrawElements(GL_LINES,NUM_BOX_IDX*2,GL_UNSIGNED_SHORT,box_wire_idx);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void render_cylinder(
|
||||
const PfxTransform3 &transform,
|
||||
const PfxVector3 &color,
|
||||
const PfxFloatInVec &radius,
|
||||
const PfxFloatInVec &halfLength)
|
||||
{
|
||||
PfxVector3 scale(halfLength,radius,radius);
|
||||
|
||||
PfxMatrix4 wMtx = PfxMatrix4(transform) * PfxMatrix4::scale(scale);
|
||||
|
||||
glPushMatrix();
|
||||
glMultMatrixf((GLfloat*)&wMtx);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glVertexPointer(3,GL_FLOAT,24,cylinder_vtx);
|
||||
|
||||
glColor3fv((float*)&color);
|
||||
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||
glPolygonOffset(1.0f,1.0f);
|
||||
glDrawElements(GL_TRIANGLES,NUM_CYLINDER_IDX,GL_UNSIGNED_SHORT,cylinder_idx);
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
|
||||
glColor3f(0.0f,0.0f,0.0f);
|
||||
glDrawElements(GL_LINES,NUM_CYLINDER_IDX*2,GL_UNSIGNED_SHORT,cylinder_wire_idx);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void render_capsule(
|
||||
const PfxTransform3 &transform,
|
||||
const PfxVector3 &color,
|
||||
const PfxFloatInVec &radius,
|
||||
const PfxFloatInVec &halfLength)
|
||||
{
|
||||
PfxTransform3 tr1 = PfxTransform3::translation(PfxVector3(-halfLength,0.0f,0.0f));
|
||||
PfxTransform3 tr2 = PfxTransform3::translation(PfxVector3(halfLength,0.0f,0.0f));
|
||||
|
||||
render_sphere(transform*tr1,color,radius);
|
||||
render_sphere(transform*tr2,color,radius);
|
||||
|
||||
render_cylinder(transform,color,radius,halfLength);
|
||||
}
|
||||
|
||||
int render_init_mesh(
|
||||
const float *vtx,unsigned int vtxStrideBytes,
|
||||
const float *nml,unsigned int nmlStrideBytes,
|
||||
const unsigned short *tri,unsigned int triStrideBytes,
|
||||
int numVtx,int numTri)
|
||||
{
|
||||
assert(numMesh<MAX_MESH);
|
||||
|
||||
MeshBuff &buff = meshBuff[numMesh++];
|
||||
buff.vtx = new float [3*numVtx];
|
||||
buff.nml = new float [3*numVtx];
|
||||
buff.idx = new unsigned short [numTri*3];
|
||||
buff.wire_idx = new unsigned short [numTri*6];
|
||||
buff.numIdx = numTri*3;
|
||||
buff.numVtx = numVtx;
|
||||
|
||||
for(int i=0;i<numVtx;i++) {
|
||||
const float *v = (float*)((uintptr_t)vtx + vtxStrideBytes * i);
|
||||
const float *n = (float*)((uintptr_t)nml + nmlStrideBytes * i);
|
||||
buff.vtx[i*3 ] = v[0];
|
||||
buff.vtx[i*3+1] = v[1];
|
||||
buff.vtx[i*3+2] = v[2];
|
||||
buff.nml[i*3 ] = n[0];
|
||||
buff.nml[i*3+1] = n[1];
|
||||
buff.nml[i*3+2] = n[2];
|
||||
}
|
||||
|
||||
for(int i=0;i<numTri;i++) {
|
||||
const unsigned short *idx = (unsigned short*)((uintptr_t)tri + triStrideBytes * i);
|
||||
buff.idx[i*3 ] = idx[0];
|
||||
buff.idx[i*3+1] = idx[1];
|
||||
buff.idx[i*3+2] = idx[2];
|
||||
buff.wire_idx[i*6 ] = buff.idx[i*3 ];
|
||||
buff.wire_idx[i*6+1] = buff.idx[i*3+1];
|
||||
buff.wire_idx[i*6+2] = buff.idx[i*3+1];
|
||||
buff.wire_idx[i*6+3] = buff.idx[i*3+2];
|
||||
buff.wire_idx[i*6+4] = buff.idx[i*3+2];
|
||||
buff.wire_idx[i*6+5] = buff.idx[i*3 ];
|
||||
}
|
||||
|
||||
return numMesh-1;
|
||||
}
|
||||
|
||||
void render_mesh(
|
||||
const PfxTransform3 &transform,
|
||||
const PfxVector3 &color,
|
||||
int meshId)
|
||||
{
|
||||
assert(meshId>=0&&meshId<MAX_MESH);
|
||||
|
||||
MeshBuff &buff = meshBuff[meshId];
|
||||
|
||||
PfxMatrix4 wMtx = PfxMatrix4(transform);
|
||||
|
||||
glPushMatrix();
|
||||
glMultMatrixf((GLfloat*)&wMtx);
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glVertexPointer(3,GL_FLOAT,0,buff.vtx);
|
||||
|
||||
glColor3fv((float*)&color);
|
||||
glEnable(GL_POLYGON_OFFSET_FILL);
|
||||
glPolygonOffset(1.0f,1.0f);
|
||||
glDrawElements(GL_TRIANGLES,buff.numIdx,GL_UNSIGNED_SHORT,buff.idx);
|
||||
glDisable(GL_POLYGON_OFFSET_FILL);
|
||||
|
||||
glColor3f(0.0f,0.0f,0.0f);
|
||||
glDrawElements(GL_LINES,buff.numIdx*2,GL_UNSIGNED_SHORT,buff.wire_idx);
|
||||
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
|
||||
glPopMatrix();
|
||||
}
|
||||
|
||||
void render_resize(int width,int height)
|
||||
{
|
||||
glViewport(0,0,width,height);
|
||||
g_pMat = PfxMatrix4::perspective(3.1415f/4.0f, (float)width/(float)height,0.1f, 1000.0f);
|
||||
screen_width = width;
|
||||
screen_height = height;
|
||||
}
|
||||
|
||||
void render_debug_point(
|
||||
const PfxVector3 &position,
|
||||
const PfxVector3 &color)
|
||||
{
|
||||
glColor4fv((float*)&color);
|
||||
|
||||
glPointSize(5.0f);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3,GL_FLOAT,16,(float*)&position);
|
||||
glDrawArrays(GL_POINTS,0,1);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
glPointSize(1.0f);
|
||||
}
|
||||
|
||||
void render_debug_line(
|
||||
const PfxVector3 &position1,
|
||||
const PfxVector3 &position2,
|
||||
const PfxVector3 &color)
|
||||
{
|
||||
glColor4fv((float*)&color);
|
||||
|
||||
const PfxVector3 points[2] = {
|
||||
position1,
|
||||
position2,
|
||||
};
|
||||
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3,GL_FLOAT,16,(float*)points);
|
||||
glDrawArrays(GL_LINES,0,2);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
void render_debug_box(
|
||||
const PfxVector3 ¢er,
|
||||
const PfxVector3 &extent,
|
||||
const PfxVector3 &color)
|
||||
{
|
||||
const PfxVector3 points[8] = {
|
||||
center + mulPerElem(PfxVector3(-1,-1,-1),extent),
|
||||
center + mulPerElem(PfxVector3(-1,-1, 1),extent),
|
||||
center + mulPerElem(PfxVector3( 1,-1, 1),extent),
|
||||
center + mulPerElem(PfxVector3( 1,-1,-1),extent),
|
||||
center + mulPerElem(PfxVector3(-1, 1,-1),extent),
|
||||
center + mulPerElem(PfxVector3(-1, 1, 1),extent),
|
||||
center + mulPerElem(PfxVector3( 1, 1, 1),extent),
|
||||
center + mulPerElem(PfxVector3( 1, 1,-1),extent),
|
||||
};
|
||||
|
||||
const unsigned short indices[] = {
|
||||
0,1,1,2,2,3,3,0,4,5,5,6,6,7,7,4,0,4,1,5,2,6,3,7,
|
||||
};
|
||||
|
||||
glColor4fv((float*)&color);
|
||||
glEnableClientState(GL_VERTEX_ARRAY);
|
||||
glVertexPointer(3,GL_FLOAT,16,(float*)points);
|
||||
glDrawElements(GL_LINES,24,GL_UNSIGNED_SHORT,indices);
|
||||
glDisableClientState(GL_VERTEX_ARRAY);
|
||||
}
|
||||
|
||||
PfxVector3 render_get_world_position(const PfxVector3 &screenPos)
|
||||
{
|
||||
PfxMatrix4 mvp,mvpInv;
|
||||
mvp = g_vMat;
|
||||
mvpInv = inverse(mvp);
|
||||
|
||||
PfxVector4 wp(screenPos,1.0f);
|
||||
|
||||
wp[0] /= (0.5f * (float)screen_width);
|
||||
wp[1] /= (0.5f * (float)screen_height);
|
||||
|
||||
float w = mvpInv[0][3] * wp[0] +
|
||||
mvpInv[1][3] * wp[1] +
|
||||
mvpInv[2][3] * wp[2] +
|
||||
mvpInv[3][3];
|
||||
|
||||
wp = mvpInv * wp;
|
||||
wp /= w;
|
||||
|
||||
return wp.getXYZ();
|
||||
}
|
||||
|
||||
PfxVector3 render_get_screen_position(const PfxVector3 &worldPos)
|
||||
{
|
||||
PfxVector4 sp(worldPos,1.0f);
|
||||
|
||||
PfxMatrix4 mvp;
|
||||
mvp = g_vMat;
|
||||
|
||||
sp = mvp * sp;
|
||||
sp /= sp[3];
|
||||
sp[0] *= (0.5f * (float)screen_width);
|
||||
sp[1] *= (0.5f * (float)screen_height);
|
||||
|
||||
return sp.getXYZ();
|
||||
}
|
||||
|
||||
void render_get_screent_size(int &width,int &height)
|
||||
{
|
||||
width = screen_width;
|
||||
height = screen_height;
|
||||
}
|
||||
|
||||
void render_get_view_target(PfxVector3 &targetPos)
|
||||
{
|
||||
targetPos = g_viewTgt;
|
||||
}
|
||||
|
||||
void render_set_view_target(const PfxVector3 &targetPos)
|
||||
{
|
||||
g_viewTgt = targetPos;
|
||||
}
|
||||
|
||||
void render_get_view_radius(float &radius)
|
||||
{
|
||||
radius = viewRadius;
|
||||
}
|
||||
|
||||
void render_set_view_radius(float radius)
|
||||
{
|
||||
viewRadius = radius;
|
||||
}
|
||||
209
Extras/PhysicsEffects/sample/api_physics_effects/common/sphere.h
Normal file
209
Extras/PhysicsEffects/sample/api_physics_effects/common/sphere.h
Normal file
@@ -0,0 +1,209 @@
|
||||
/*
|
||||
Physics Effects Copyright(C) 2010 Sony Computer Entertainment Inc.
|
||||
All rights reserved.
|
||||
|
||||
Physics Effects is open software; you can redistribute it and/or
|
||||
modify it under the terms of the BSD License.
|
||||
|
||||
Physics Effects is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
See the BSD License for more details.
|
||||
|
||||
A copy of the BSD License is distributed with
|
||||
Physics Effects under the filename: physics_effects_license.txt
|
||||
*/
|
||||
|
||||
#define NUM_SPHERE_VTX 67
|
||||
#define NUM_SPHERE_IDX 360
|
||||
const float sphere_vtx[] = {
|
||||
0.000000f,-1.000000f,0.000000f,0.000000f,-1.000000f,0.000000f,
|
||||
0.500000f,-0.866025f,0.000000f,0.500000f,-0.866025f,0.000000f,
|
||||
0.433013f,-0.866025f,0.250000f,0.433013f,-0.866025f,0.250000f,
|
||||
0.250000f,-0.866025f,0.433013f,0.250000f,-0.866025f,0.433013f,
|
||||
-0.000000f,-0.866025f,0.500000f,-0.000000f,-0.866025f,0.500000f,
|
||||
-0.250000f,-0.866025f,0.433013f,-0.250000f,-0.866025f,0.433013f,
|
||||
-0.433013f,-0.866025f,0.250000f,-0.433013f,-0.866025f,0.250000f,
|
||||
-0.500000f,-0.866025f,-0.000000f,-0.500000f,-0.866025f,-0.000000f,
|
||||
-0.433013f,-0.866025f,-0.250000f,-0.433013f,-0.866025f,-0.250000f,
|
||||
-0.250000f,-0.866025f,-0.433013f,-0.250000f,-0.866025f,-0.433013f,
|
||||
0.000000f,-0.866025f,-0.500000f,0.000000f,-0.866025f,-0.500000f,
|
||||
0.250000f,-0.866025f,-0.433013f,0.250000f,-0.866025f,-0.433013f,
|
||||
0.433013f,-0.866025f,-0.250000f,0.433013f,-0.866025f,-0.250000f,
|
||||
0.500000f,-0.866025f,0.000000f,0.500000f,-0.866025f,0.000000f,
|
||||
0.866025f,-0.500000f,0.000000f,0.866025f,-0.500000f,0.000000f,
|
||||
0.750000f,-0.500000f,0.433013f,0.750000f,-0.500000f,0.433013f,
|
||||
0.433013f,-0.500000f,0.750000f,0.433013f,-0.500000f,0.750000f,
|
||||
-0.000000f,-0.500000f,0.866025f,-0.000000f,-0.500000f,0.866025f,
|
||||
-0.433013f,-0.500000f,0.750000f,-0.433013f,-0.500000f,0.750000f,
|
||||
-0.750000f,-0.500000f,0.433013f,-0.750000f,-0.500000f,0.433013f,
|
||||
-0.866025f,-0.500000f,-0.000000f,-0.866025f,-0.500000f,-0.000000f,
|
||||
-0.750000f,-0.500000f,-0.433013f,-0.750000f,-0.500000f,-0.433013f,
|
||||
-0.433013f,-0.500000f,-0.750000f,-0.433013f,-0.500000f,-0.750000f,
|
||||
0.000000f,-0.500000f,-0.866025f,0.000000f,-0.500000f,-0.866025f,
|
||||
0.433013f,-0.500000f,-0.750000f,0.433013f,-0.500000f,-0.750000f,
|
||||
0.750000f,-0.500000f,-0.433012f,0.750000f,-0.500000f,-0.433012f,
|
||||
0.866025f,-0.500000f,0.000000f,0.866025f,-0.500000f,0.000000f,
|
||||
1.000000f,0.000000f,0.000000f,1.000000f,0.000000f,0.000000f,
|
||||
0.866025f,0.000000f,0.500000f,0.866025f,0.000000f,0.500000f,
|
||||
0.500000f,0.000000f,0.866025f,0.500000f,0.000000f,0.866025f,
|
||||
-0.000000f,0.000000f,1.000000f,-0.000000f,0.000000f,1.000000f,
|
||||
-0.500000f,0.000000f,0.866025f,-0.500000f,0.000000f,0.866025f,
|
||||
-0.866025f,0.000000f,0.500000f,-0.866025f,0.000000f,0.500000f,
|
||||
-1.000000f,0.000000f,-0.000000f,-1.000000f,0.000000f,-0.000000f,
|
||||
-0.866025f,0.000000f,-0.500000f,-0.866025f,0.000000f,-0.500000f,
|
||||
-0.500000f,0.000000f,-0.866025f,-0.500000f,0.000000f,-0.866025f,
|
||||
0.000000f,0.000000f,-1.000000f,0.000000f,0.000000f,-1.000000f,
|
||||
0.500000f,0.000000f,-0.866025f,0.500000f,0.000000f,-0.866025f,
|
||||
0.866026f,0.000000f,-0.500000f,0.866026f,0.000000f,-0.500000f,
|
||||
1.000000f,0.000000f,0.000000f,1.000000f,0.000000f,0.000000f,
|
||||
0.866025f,0.500000f,0.000000f,0.866025f,0.500000f,0.000000f,
|
||||
0.750000f,0.500000f,0.433013f,0.750000f,0.500000f,0.433013f,
|
||||
0.433013f,0.500000f,0.750000f,0.433013f,0.500000f,0.750000f,
|
||||
-0.000000f,0.500000f,0.866025f,-0.000000f,0.500000f,0.866025f,
|
||||
-0.433013f,0.500000f,0.750000f,-0.433013f,0.500000f,0.750000f,
|
||||
-0.750000f,0.500000f,0.433013f,-0.750000f,0.500000f,0.433013f,
|
||||
-0.866025f,0.500000f,-0.000000f,-0.866025f,0.500000f,-0.000000f,
|
||||
-0.750000f,0.500000f,-0.433013f,-0.750000f,0.500000f,-0.433013f,
|
||||
-0.433013f,0.500000f,-0.750000f,-0.433013f,0.500000f,-0.750000f,
|
||||
0.000000f,0.500000f,-0.866025f,0.000000f,0.500000f,-0.866025f,
|
||||
0.433013f,0.500000f,-0.750000f,0.433013f,0.500000f,-0.750000f,
|
||||
0.750000f,0.500000f,-0.433012f,0.750000f,0.500000f,-0.433012f,
|
||||
0.866025f,0.500000f,0.000000f,0.866025f,0.500000f,0.000000f,
|
||||
0.500000f,0.866025f,0.000000f,0.500000f,0.866025f,0.000000f,
|
||||
0.433013f,0.866025f,0.250000f,0.433013f,0.866025f,0.250000f,
|
||||
0.250000f,0.866025f,0.433013f,0.250000f,0.866025f,0.433013f,
|
||||
-0.000000f,0.866025f,0.500000f,-0.000000f,0.866025f,0.500000f,
|
||||
-0.250000f,0.866025f,0.433013f,-0.250000f,0.866025f,0.433013f,
|
||||
-0.433013f,0.866025f,0.250000f,-0.433013f,0.866025f,0.250000f,
|
||||
-0.500000f,0.866025f,-0.000000f,-0.500000f,0.866025f,-0.000000f,
|
||||
-0.433013f,0.866025f,-0.250000f,-0.433013f,0.866025f,-0.250000f,
|
||||
-0.250000f,0.866025f,-0.433013f,-0.250000f,0.866025f,-0.433013f,
|
||||
0.000000f,0.866025f,-0.500000f,0.000000f,0.866025f,-0.500000f,
|
||||
0.250000f,0.866025f,-0.433013f,0.250000f,0.866025f,-0.433013f,
|
||||
0.433013f,0.866025f,-0.250000f,0.433013f,0.866025f,-0.250000f,
|
||||
0.500000f,0.866025f,0.000000f,0.500000f,0.866025f,0.000000f,
|
||||
0.000000f,1.000000f,0.000000f,0.000000f,1.000000f,0.000000f,
|
||||
};
|
||||
const unsigned short sphere_idx[] = {
|
||||
0,1,2,
|
||||
0,2,3,
|
||||
0,3,4,
|
||||
0,4,5,
|
||||
0,5,6,
|
||||
0,6,7,
|
||||
0,7,8,
|
||||
0,8,9,
|
||||
0,9,10,
|
||||
0,10,11,
|
||||
0,11,12,
|
||||
0,12,13,
|
||||
1,14,15,
|
||||
15,2,1,
|
||||
2,15,16,
|
||||
16,3,2,
|
||||
3,16,17,
|
||||
17,4,3,
|
||||
4,17,18,
|
||||
18,5,4,
|
||||
5,18,19,
|
||||
19,6,5,
|
||||
6,19,20,
|
||||
20,7,6,
|
||||
7,20,21,
|
||||
21,8,7,
|
||||
8,21,22,
|
||||
22,9,8,
|
||||
9,22,23,
|
||||
23,10,9,
|
||||
10,23,24,
|
||||
24,11,10,
|
||||
11,24,25,
|
||||
25,12,11,
|
||||
12,25,26,
|
||||
26,13,12,
|
||||
14,27,28,
|
||||
28,15,14,
|
||||
15,28,29,
|
||||
29,16,15,
|
||||
16,29,30,
|
||||
30,17,16,
|
||||
17,30,31,
|
||||
31,18,17,
|
||||
18,31,32,
|
||||
32,19,18,
|
||||
19,32,33,
|
||||
33,20,19,
|
||||
20,33,34,
|
||||
34,21,20,
|
||||
21,34,35,
|
||||
35,22,21,
|
||||
22,35,36,
|
||||
36,23,22,
|
||||
23,36,37,
|
||||
37,24,23,
|
||||
24,37,38,
|
||||
38,25,24,
|
||||
25,38,39,
|
||||
39,26,25,
|
||||
27,40,41,
|
||||
41,28,27,
|
||||
28,41,42,
|
||||
42,29,28,
|
||||
29,42,43,
|
||||
43,30,29,
|
||||
30,43,44,
|
||||
44,31,30,
|
||||
31,44,45,
|
||||
45,32,31,
|
||||
32,45,46,
|
||||
46,33,32,
|
||||
33,46,47,
|
||||
47,34,33,
|
||||
34,47,48,
|
||||
48,35,34,
|
||||
35,48,49,
|
||||
49,36,35,
|
||||
36,49,50,
|
||||
50,37,36,
|
||||
37,50,51,
|
||||
51,38,37,
|
||||
38,51,52,
|
||||
52,39,38,
|
||||
40,53,54,
|
||||
54,41,40,
|
||||
41,54,55,
|
||||
55,42,41,
|
||||
42,55,56,
|
||||
56,43,42,
|
||||
43,56,57,
|
||||
57,44,43,
|
||||
44,57,58,
|
||||
58,45,44,
|
||||
45,58,59,
|
||||
59,46,45,
|
||||
46,59,60,
|
||||
60,47,46,
|
||||
47,60,61,
|
||||
61,48,47,
|
||||
48,61,62,
|
||||
62,49,48,
|
||||
49,62,63,
|
||||
63,50,49,
|
||||
50,63,64,
|
||||
64,51,50,
|
||||
51,64,65,
|
||||
65,52,51,
|
||||
54,53,66,
|
||||
55,54,66,
|
||||
56,55,66,
|
||||
57,56,66,
|
||||
58,57,66,
|
||||
59,58,66,
|
||||
60,59,66,
|
||||
61,60,66,
|
||||
62,61,66,
|
||||
63,62,66,
|
||||
64,63,66,
|
||||
65,64,66,
|
||||
};
|
||||
Reference in New Issue
Block a user