Ejemplo n.º 1
0
void picking_sphere_create(float radius, struct PickingSphere* sphere) {
    pivot_create(NULL, NULL, &sphere->pivot);

    sphere->picked = false;
    vec_copy4f((Vec4f){0.0f, 0.0f, 0.0f, 1.0f}, sphere->ray);

    sphere->radius = radius;
    sphere->front = -FLT_MAX;
    sphere->back = -FLT_MAX;
}
Ejemplo n.º 2
0
struct Pivot* pivot_combine(const struct Pivot* pivot1, const struct Pivot* pivot2, struct Pivot* r) {
    Vec4f concat_position = {0};
    vec_add(pivot1->position, pivot2->position, concat_position);

    Quat concat_orientation = {0};
    quat_mul(pivot1->orientation, pivot2->orientation, concat_orientation);

    pivot_create(concat_position, concat_orientation, r);

    return r;
}
Ejemplo n.º 3
0
static void entity_create(const char* name, Color color, struct Vbo* vbo, struct Ibo* ibo, struct CollisionEntity* entity) {
    entity->name = name;

    pivot_create(NULL, NULL, &entity->pivot);

    solid_cube_create(1.0f, color, &entity->solid);
    solid_cube_create(1.0f, color, &entity->optimized_solid);
    solid_optimize((struct Solid*)&entity->optimized_solid);
    vbo_mesh_create_from_solid((struct Solid*)&entity->optimized_solid, vbo, ibo, &entity->vbo_mesh);

    halfedgemesh_create(&entity->hemesh);
    halfedgemesh_append(&entity->hemesh, (struct Solid*)&entity->solid);
    halfedgemesh_optimize(&entity->hemesh);

    picking_sphere_create(1.0f, &entity->picking_sphere);
    pivot_attach(&entity->picking_sphere.pivot, &entity->pivot);
}
Ejemplo n.º 4
0
void shape_convex_create(const struct HalfEdgeMesh* mesh, struct ShapeConvex* convex) {
    pivot_create(NULL, NULL, &convex->base_shape.pivot);
    convex->base_shape.instance = SHAPE_CONVEX;

    convex->mesh = mesh;
}
Ejemplo n.º 5
0
void shape_sphere_create(float radius, struct ShapeSphere* sphere) {
    pivot_create(NULL, NULL, &sphere->base_shape.pivot);
    sphere->base_shape.instance = SHAPE_SPHERE;

    sphere->radius = radius;
}