Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // --------------------------------------------------------------------------------------
- //
- // Infinity 3D Web browser Web Assembly secure scripting interface example.
- //
- // Hello world in 3D is basically a spinning cube :)
- //
- // --------------------------------------------------------------------------------------
- #include <infinity.h>
- #include <math.h>
- using namespace Infinity;
- class Program
- {
- public:
- Program()
- {
- m_zone = nullptr;
- m_item_node = nullptr;
- }
- uint32_t Init()
- {
- m_zone = new Zone;
- SceneGraph *scene = m_zone->GetScene();
- Node *scene_root = scene->GetRoot();
- m_item_node = scene->CreateNode(scene_root);
- auto item_object = scene->CreateObject(m_item_node);
- auto item_geometry = m_zone->Find("item.xsg");
- item_object->SetGeometry(item_geometry);
- Vector3 v;
- v.x = 0; v.y = 0; v.z = 10;
- m_item_node->SetPosition(v);
- return 1;
- }
- uint32_t Process(float current_time)
- {
- // Spin teh cube :)
- const float radius = 10;
- float speed = 1;
- float angle = speed * current_time;
- Vector3 v;
- v.x = (float) sin(angle);
- v.y = (float) cos(angle);
- v.z = 10;
- m_item_node->SetPosition(v);
- return 1;
- }
- uint32_t Terminate()
- {
- // Zap our stuff here.
- delete m_zone;
- return 1;
- }
- Zone *m_zone;
- Node *m_item_node;
- };
- // Include this after program definition.
- #include <inf_bootstrap.h>
Advertisement
Add Comment
Please, Sign In to add comment