Jump to content
  • Advertisement
Sign in to follow this  
PaulCesar

Clanlib Collision (get_collision_point) problem

This topic is 4559 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, This will probably be a very simple answer for some of you more clanlib minded folks (since I cannot sem to find a board anywhere related to the library. The problem im having is simple, for the collision engine (to allow object to be set at the proper point, ie, to land on the ground properly in a physics simulation, i need to know the point of contact. For that there is get_collision_points(), the problem is, apparently it doesent work (at least not for me). The collision works, and goes into the function, but neight object reports any points in the vector returned from get_collision_points(). Here is a quick mockup test I just compiled , so I can point out everything. keep in mind, im not using iterators on the vector for clarity to coders unfamiliar with STL, but familiar enough to help me with clanlib :). Also, I understand this is unoptimized as far as not saving/loading the structures, im doing this for clarity to show you EVERYTHING.
// Create the collision outline for the sprite
CL_CollisionOutline sprite(&test->get_frame_surface(0).get_pixeldata());
CL_CollisionOutline sprite2(&test->get_frame_surface(1).get_pixeldata());
sprite.set_translation(20,20);

std::vector<CL_Pointf> points = sprite.get_collision_points();

if(sprite.collide(sprite2))
{
     // This is fired off
     MessageBox(NULL, "Collision Made", "test", MB_OK);	
     for(int n=0; n<points.size(); n++)
     {
          // This is not
          MessageBox(NULL, "Collision POint Found", "test", MB_OK);
     };


Notice, because the collision passes, i believe I can safely presume the structures were working approprietly. The frame size of the sprite is 48x48, and 20x2 pixels inword undoubteldy collides with the sprite. Thanks in advance for your help guys Richard P. Cesar [Edited by - PaulCesar on November 24, 2005 2:47:27 PM]

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Also, I don't believe collision info is stored by default. You need to

sprite.enable_collision_info(true, true);

before you call sprite.collide.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!