aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/extantz/Evas_3D_demo.c
blob: e9265da593c78138177799aaa150563e38285f2d (plain)
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#include "extantz.h"


static void _animateCube(ExtantzStuffs *stuffs)
{
  static float angle = 0.0f;
  static int   frame = 0;
  static int   inc   = 1;
  Evas_3D_Mesh *m;

  eina_accessor_data_get(stuffs->aMesh, 0, (void **) &m);

  angle += 0.5;
  if (angle > 360.0)		angle -= 360.0f;

  frame += inc;
  if (frame >= 20) inc = -1;
  else if (frame <= 0) inc = 1;

  eo_do(stuffs->mesh_node,
    evas_3d_node_orientation_angle_axis_set(angle, 1.0, 1.0, 1.0),
    evas_3d_node_mesh_frame_set(m, frame)
  );
}

static void _animateSphere(ExtantzStuffs *stuffs)
{
  static float earthAngle = 0.0f;

  earthAngle += 0.3;
  if (earthAngle > 360.0)	earthAngle -= 360.0f;
  eo_do(stuffs->mesh_node,
    evas_3d_node_orientation_angle_axis_set(earthAngle, 0.0, 1.0, 0.0)
  );
}

static void _animateSonic(ExtantzStuffs *stuffs)
{
  static int   sonicFrame = 0;
  Evas_3D_Mesh *m;

  eina_accessor_data_get(stuffs->aMesh, 0, (void **) &m);
  sonicFrame += 32;
  if (sonicFrame > 256 * 50)	sonicFrame = 0;
  eo_do(stuffs->mesh_node,
    evas_3d_node_mesh_frame_set(m, sonicFrame)
    );
}

void Evas_3D_Demo_add(globals *ourGlobals)
{
  char buf[PATH_MAX];
  ExtantzStuffs *eStuffs;

  ourGlobals->scene = scenriAdd(ourGlobals->win);

  // TODO - For now lets just pretend we got stuffs sent from our love.
  sprintf(buf, FAKE_UUID);
  eStuffs = addStuffs(buf, "onefang's test bed", 
    "Just a pretend bed with MLP scripts for testing SledjHamr.",
    "12345678-1234-4321-abcd-0123456789ab",
    "onefang%%27s%%20test%%20bed.omg",
    MT_CUBE,
    0.0, 4.0, 10.0,
    1.0, 0.0, 0.0, 0.0
  );
  addMaterial(eStuffs, -1, TT_NORMAL, "normal_lego.png");
  eStuffs->animateStuffs = (aniStuffs) _animateCube;
  stuffsSetup(eStuffs, ourGlobals, ourGlobals->scene, 1);

  sprintf(buf, FAKE_UUID);
  eStuffs = addStuffs(buf, "onefang's left testicle", 
    "Just a pretend world for testing SledjHamr.",
    "12345678-1234-4321-abcd-0123456789ab",
    "earth.omg",
    MT_SPHERE,
    0.0, 0.0, 0.0,
    1.0, 0.0, 0.0, 0.0
  );
  addMaterial(eStuffs, 1, TT_FACE, "EarthDiffuse.png");
  eStuffs->animateStuffs = (aniStuffs) _animateSphere;
  stuffsSetup(eStuffs, ourGlobals, ourGlobals->scene, 2);

  sprintf(buf, FAKE_UUID);
  eStuffs = addStuffs(buf, "Sonic the bed hog.", 
    "Just a pretend avatar for testing SledjHamr.",
    "12345678-1234-4321-abcd-0123456789ab",
    "sonic.md2",
    MT_MESH,
    0.0, 0.0, 0.0,
    -0.7071067811865475, 0.0, 0.0, 0.7071067811865475
  );
  addMaterial(eStuffs, -1, TT_FACE, "sonic.png");
  eStuffs->animateStuffs = (aniStuffs) _animateSonic;
  stuffsSetup(eStuffs, ourGlobals, ourGlobals->scene, 3);
}