1 |
2 |
specular |
//=======================================================================
|
2 |
|
|
// Project Monophony
|
3 |
|
|
// Wire-Frame 3D Graphics Accelerator IP Core
|
4 |
|
|
//
|
5 |
|
|
// File:
|
6 |
|
|
// main_hand.c
|
7 |
|
|
//
|
8 |
|
|
// Abstract:
|
9 |
|
|
// Hand animation sample (without skinning).
|
10 |
|
|
//
|
11 |
|
|
// Author:
|
12 |
|
|
// Kenji Ishimaru (kenji.ishimaru@prtissimo.com)
|
13 |
|
|
//
|
14 |
|
|
//======================================================================
|
15 |
|
|
//
|
16 |
|
|
// Copyright (c) 2015, Kenji Ishimaru
|
17 |
|
|
// All rights reserved.
|
18 |
|
|
//
|
19 |
|
|
// Redistribution and use in source and binary forms, with or without
|
20 |
|
|
// modification, are permitted provided that the following conditions are met:
|
21 |
|
|
//
|
22 |
|
|
// -Redistributions of source code must retain the above copyright notice,
|
23 |
|
|
// this list of conditions and the following disclaimer.
|
24 |
|
|
// -Redistributions in binary form must reproduce the above copyright notice,
|
25 |
|
|
// this list of conditions and the following disclaimer in the documentation
|
26 |
|
|
// and/or other materials provided with the distribution.
|
27 |
|
|
//
|
28 |
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
29 |
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
30 |
|
|
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
31 |
|
|
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
32 |
|
|
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
33 |
|
|
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
34 |
|
|
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
35 |
|
|
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
36 |
|
|
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
37 |
|
|
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
38 |
|
|
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
39 |
|
|
//
|
40 |
|
|
// Revision History
|
41 |
|
|
|
42 |
|
|
#include <stdio.h>
|
43 |
|
|
#include <unistd.h>
|
44 |
|
|
#include <system.h>
|
45 |
|
|
#include "mp_lib.h"
|
46 |
|
|
#include "mp_hwdep.h"
|
47 |
|
|
|
48 |
|
|
#include "hand_full.h"
|
49 |
|
|
|
50 |
|
|
void mp_loop() {
|
51 |
|
|
static float transY = 0.0f;
|
52 |
|
|
static int cframe = 1;
|
53 |
|
|
static float cScale = 4.0;
|
54 |
|
|
int i,j;
|
55 |
|
|
int frame = 0;
|
56 |
|
|
int mat_index = 0;
|
57 |
|
|
mpClearColor(0.0, 0.25, 0.5);
|
58 |
|
|
mpViewport(640, 480);
|
59 |
|
|
mpMatrixMode(MP_PROJECTION);
|
60 |
|
|
mpLoadIdentity();
|
61 |
|
|
mpPerspective(30.0, 4.0 / 3.0, 1, 100);
|
62 |
|
|
mpMatrixMode(MP_MODELVIEW);
|
63 |
|
|
mpLoadIdentity();
|
64 |
|
|
mpLookAt(0, 0, 1, 0, 0, -100, 0, 1, 0);
|
65 |
|
|
mpTranslate(0.0,0.0,-10);
|
66 |
|
|
mpTranslate(-1.0,2.0,0.0);
|
67 |
|
|
mpScale(10.0,10.0,10.0);
|
68 |
|
|
//mpRotatef(180.0,1,0,0);
|
69 |
|
|
while(1) {
|
70 |
|
|
printf("frame %d\n",frame++);
|
71 |
|
|
mpClear();
|
72 |
|
|
mpRenderColor(1.0,0.85,0.85);
|
73 |
|
|
for (j=0; j<num_of_draws;j++) {
|
74 |
|
|
mpMatrixMode(MP_MODELVIEW);
|
75 |
|
|
mpPushMatrix();
|
76 |
|
|
mat_index = weight_matrix_reference[j][0];
|
77 |
|
|
mpMultMatrix ((matrix_index[mat_index])[cframe]);
|
78 |
|
|
mpVertexPointer(vtx_array_index[j]);
|
79 |
|
|
mpDrawArrays(num_of_tri_array_index[j]*3);
|
80 |
|
|
mpPopMatrix();
|
81 |
|
|
}
|
82 |
|
|
cframe++;
|
83 |
|
|
if (cframe >= num_of_frames) cframe = 1;
|
84 |
|
|
mpSwapBuffers();
|
85 |
|
|
}
|
86 |
|
|
}
|
87 |
|
|
|
88 |
|
|
int main()
|
89 |
|
|
{
|
90 |
|
|
|
91 |
|
|
printf("Hello from Nios II!\n");
|
92 |
|
|
buffer_clear(0x00000000,0);
|
93 |
|
|
buffer_clear(0x00000000,1);
|
94 |
|
|
mpInit();
|
95 |
|
|
mp_loop();
|
96 |
|
|
return 0;
|
97 |
|
|
}
|