ScePspFVector3 position;
ScePspFVector3 velocity;
+ float radius; //< for collision detection
+
+ public:
+ Entity(Model *model, Texture *texture,
+ ScePspFMatrix4 initial_transform,
+ ScePspFVector3 position,
+ ScePspFVector3 velocity,
+ float radius)
+ :model(model),
+ texture(texture),
+ initial_transform(initial_transform),
+ position(position),
+ velocity(velocity),
+ radius(radius)
+ {}
+
+ void draw() const;
+ void update_position();
+ bool collides(const Entity& other);
};
#endif
{
GFX.init();
- //Model cube("colors-noUV.lob");
- Model cube("data/shipdawhip.lob");
+ Model ship("data/shipdawhip.lob");
Texture texture("data/shipdawhip.ltx");
- //sceKernelDcacheWritebackRange(cube.vertices, cube.num_vertices * sizeof(Vertex));
- //sceKernelDcacheWritebackRange(cube.indices, cube.num_faces * sizeof(unsigned short));
- //sceKernelDcacheWritebackRange(&cube, sizeof(cube));
+
sceKernelDcacheWritebackInvalidateAll();
GFX.perspective(75.0f, 16.0f/9.0f, 0.5f, 1000.0f);
- ScePspFVector3 camera_pos = {10,0,-50};
+ ScePspFVector3 camera_pos = {10,0,-60};
ScePspFVector3 camera_center = {-40, 0, 40};
ScePspFVector3 camera_up = {0, 1, 0};
GFX.look_at(&camera_pos, &camera_center, &camera_up);
sceGumRotateZ(-3.14159f/2.0f);
sceGuColor(GU_COLOR(1.0f,1.0f,1.0f,0.0f));
GFX.bind_texture(texture);
- sceGumDrawArray(GU_TRIANGLES, cube.vtype | GU_TRANSFORM_3D,
- cube.num_faces*3, cube.indices, cube.vertices);
+ GFX.draw_model(ship);
GFX.end_frame();
sceGuTexImage(0, t.width, t.height, t.width, t.pixels);
}
+void Gfx::draw_model(const Model& m)
+{
+ sceGumDrawArray(GU_TRIANGLES, m.vtype | GU_TRANSFORM_3D,
+ m.num_faces*3, m.indices, m.vertices);
+}
+