Results 1 to 5 of 5

Thread: Multiple CL_CollisionOutline Objects and another minor question

  1. #1

    Smile Multiple CL_CollisionOutline Objects and another minor question

    Hello, I am new to ClanLib SDK, and I have some questions about CollsionDetection System, and if someone could be so kind to help me

    1. If I have 100 objects of the same type, I don't think it's a good idea to create for everyone a CL_CollisionObject for every object ? It will be just a waste of memory... I was to thinking to use just one CL_CollisionObject for every type of object, but there is a problem then I need to check collision between two objects of the same type ( collision will always return true ). Some advice about this ?

    2. About CL_CollisionOutline constuctor:
    CL_CollisionOutline (const CL_StringRef &resource_id, CL_ResourceManager *manager)
    , can't find more about this, does this mean that we can store *.out files inside a resource file ? If yes, what are the tags for this?

    And one more question, what "Apple OpenGL ES 2.0 initial support" from "ClanLib 2.3.0 Release Notes" means ? will we be able to compile our code for iOS devices ?

    Tnx everyone who can help me a bit with these questions

  2. #2
    ClanLib Developer
    Join Date
    May 2007


    I think ClanLib requires some better examples using CL_Collision.

    1) A moving object colliding with a static background (which can be extrapolated to 2 objects moving - since A+a_delta == B + b_delta - is the same as A + a_delta - b_delta == B)
    This can be tricky to the programmer, since if the object is fast (eg 8 pixels), it may pass through the collision area (eg 7 pixels width)

    2) Basic collision using multiple objects

    3) Collision using animated CL_Sprites

    Until then (if someone creates some examples)

    See -
    Also Tests/Displays/Collision (in the source package)

    Ref iOS devices, see

    A developer got it to work, the modifications were merged in. But I don't know if it currently works. (if he is reading this, i'm sure he'll reply)

  3. #3


    So what about collisionOutline constructor ? Can I create a outline from xml resource file? Or it is used to take a png file from resource?

  4. #4
    ClanLib Developer
    Join Date
    May 2007


    Sorry, I don't know. I have never used CL_Collision in my own code.

    Have a look inside CL_Collision code.

    Unless someone else can help

  5. #5
    ClanLib Developer
    Join Date
    Sep 2006
    Bergen, Norway


    Use the source, Luke!

    CL_CollisionOutline::CL_CollisionOutline(const CL_StringRef &resource_id, CL_ResourceManager *manager)
    	resource = manager->get_resource(resource_id);
    	if (resource.get_type() != "collisionoutline")
    		throw CL_Exception(cl_format("Resource '%1' is not of type 'collisionoutline'", resource_id));
    so, first thing we notice is that the resource type has to be collisionoutline.

    	data = CL_SharedPtr<CL_ResourceData_CollisionOutline>(new CL_ResourceData_CollisionOutline(resource));
    secondly, the rest of the interesting code is separated into a class called CL_ResourceData_CollisionOutline.

    CL_ResourceData_CollisionOutline::CL_ResourceData_CollisionOutline(CL_Resource &resource)
    	CL_String filename = resource.get_element().get_attribute("file");
    	int alpha_limit = CL_StringHelp::text_to_int( (resource.get_element().get_attribute("alpha_value", "128")));
    	CL_String accuracy_str = resource.get_element().get_attribute("accuracy", "medium");
    	CL_OutlineAccuracy accuracy;
    	if(accuracy_str == "high")
    		accuracy = accuracy_high;
    	else if(accuracy_str == "medium")
    		accuracy = accuracy_medium;
    	else if(accuracy_str == "low")
    		accuracy = accuracy_low;
    	else if(accuracy_str == "poor")
    		accuracy = accuracy_poor;
    		accuracy = accuracy_raw;
    	CL_CollisionOutline_Generic *outline;
    	if (filename.length() >= 3 && filename.substr(filename.length()-3, 3) == "out" )
    		outline = new CL_CollisionOutline_Generic(
    			new CL_OutlineProviderFile(filename, resource.get_manager().get_directory(resource)), accuracy_raw);
    		CL_PixelBuffer pbuf = CL_ImageProviderFactory::load(filename, resource.get_manager().get_directory(resource), "");
    		outline = new CL_CollisionOutline_Generic(
    			new CL_OutlineProviderBitmap(pbuf, alpha_limit), accuracy );
    	CL_CollisionOutline *collision_outline_tmp = 
    		new CL_CollisionOutline(outline->contours, outline->width, outline->height);
    We can now easily read what kind of structure it expects from the xml:

    file = filename, which can be a .out file, or an image.
    alpha_limit = alpha limit used for extracting if its an image.
    accuracy = high, medium, low, poor or raw accuracy if its an image.

    <collisionoutline file="mysprite.col"/>
    <collisionoutline file="mysprite.png" accuracy="medium" alpha_limit="128"/>

Similar Threads

  1. Beginners Question regarding CL_CollisionOutline & collide
    By Unfixab1e in forum Official ClanLib SDK Forums
    Replies: 5
    Last Post: 12-21-2009, 09:47 AM
  2. Drawing 2D objects in a 3D space
    By rombust in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 05-15-2009, 05:55 PM
  3. Minor update to logger
    By CrazyFrazee in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 01-25-2009, 09:31 PM
  4. Minor reference error
    By mikael in forum Novashell Game Creation System
    Replies: 1
    Last Post: 07-09-2008, 11:12 PM
  5. Question about CL_CollisionOutline
    By n-palmer in forum Official ClanLib SDK Forums
    Replies: 5
    Last Post: 09-20-2006, 02:38 PM



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts