FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Polygon worldVertices error?

 
Post new topic   Reply to topic     Forum Index -> Blaze
View previous topic :: View next topic  
Author Message
mike



Joined: 28 Dec 2008
Posts: 34

PostPosted: Sat Mar 21, 2009 11:02 am    Post subject: Polygon worldVertices error? Reply with quote

I kept getting object exception error whenever i made a call to worldVertices. I changed the code by adding one parameter to the function and it seemed to fix it but im not sure if its the correct way to do it.

Code:
    bzVec2[] worldVertices(bzBody rBody) {

        bzVec2[] worldVertices;
        worldVertices.length = m_vertices.length;

        bzXForm xf = rBody.xf; //I think i was getting the error here

        for (int i = 0; i < m_vertices.length; i++) {
            worldVertices[i] = bzMul(xf, m_vertices[i]);
        }
        return worldVertices;
    }
Back to top
View user's profile Send private message
zzzzrrr



Joined: 17 Feb 2007
Posts: 139
Location: Washington, DC

PostPosted: Sat Mar 21, 2009 11:52 am    Post subject: Re: Polygon worldVertices error? Reply with quote

mike wrote:
I kept getting object exception error whenever i made a call to worldVertices. I changed the code by adding one parameter to the function and it seemed to fix it but im not sure if its the correct way to do it.


Is your shape attached to a rigid body? If not, you should do it like so:
Code:

    auto rBody = world.createBody(bodyDef);
    auto shape = cast(bzPolygon) rBody.createShape(shapeDef);
    bzVec2[] worldVerts = shape.worldVertices;
Back to top
View user's profile Send private message
mike



Joined: 28 Dec 2008
Posts: 34

PostPosted: Sat Mar 21, 2009 2:38 pm    Post subject: Reply with quote

I had rBody[0].createShape(shapeDef[0]); to have the shape attached to the body and then i had bzPolygon test1 = new bzPolygon(shapeDef[0]); and then i called the worldvertices.

I didn't know you had to cast the shape to a polygon.

Thanks for the help. It works properly now.
Back to top
View user's profile Send private message
zzzzrrr



Joined: 17 Feb 2007
Posts: 139
Location: Washington, DC

PostPosted: Sat Mar 21, 2009 3:01 pm    Post subject: Reply with quote

mike wrote:
then i had bzPolygon test1 = new bzPolygon(shapeDef[0])


I would not recommend creating shapes this way. The preferred method is:

Code:
 rBody.createShape(shapeDef);


Quote:
Thanks for the help. It works properly now.


great, anytime!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Blaze All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group