本文整理汇总了C++中cpBodySetAngle函数的典型用法代码示例。如果您正苦于以下问题:C++ cpBodySetAngle函数的具体用法?C++ cpBodySetAngle怎么用?C++ cpBodySetAngle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cpBodySetAngle函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: cpBodySetAngle
void Mirror::SetRotationAngle(float a_Angle)
{
//rotate physbodies
cpBodySetAngle(m_pBody, cpFloat(a_Angle));
cpBodySetAngle(m_pReflectBody, cpFloat(a_Angle));
//rotate sprite
m_Sprite.sprite->setRotation( (a_Angle * 180) / 3.14159265f );
}
开发者ID:mileswhiticker,项目名称:mirrors-lasers,代码行数:9,代码来源:Mirror.cpp
示例2: cpv
bool CDynamics2DBoxEntity::MoveTo(const CVector3& c_position,
const CQuaternion& c_orientation,
bool b_check_only) {
SInt32 nCollision;
/* Check whether the box is movable or not */
if(m_cBoxEntity.GetEmbodiedEntity().IsMovable()) {
/* The box is movable */
/* Save body position and orientation */
cpVect tOldPos = m_ptBody->p;
cpFloat fOldA = m_ptBody->a;
/* Move the body to the desired position */
m_ptBody->p = cpv(c_position.GetX(), c_position.GetY());
CRadians cXAngle, cYAngle, cZAngle;
c_orientation.ToEulerAngles(cZAngle, cYAngle, cXAngle);
cpBodySetAngle(m_ptBody, cZAngle.GetValue());
/* Create a shape sensor to test the movement */
/* First construct the vertices */
CVector3 cHalfSize = m_cBoxEntity.GetSize() * 0.5f;
cpVect tVertices[] = {
cpv(-cHalfSize.GetX(), -cHalfSize.GetY()),
cpv(-cHalfSize.GetX(), cHalfSize.GetY()),
cpv( cHalfSize.GetX(), cHalfSize.GetY()),
cpv( cHalfSize.GetX(), -cHalfSize.GetY())
};
/* Then create the shape itself */
cpShape* ptTestShape = cpPolyShapeNew(m_ptBody,
4,
tVertices,
cpvzero);
/* Check if there is a collision */
nCollision = cpSpaceShapeQuery(m_cEngine.GetPhysicsSpace(), ptTestShape, NULL, NULL);
/* Dispose of the sensor shape */
cpShapeFree(ptTestShape);
if(b_check_only || nCollision) {
/* Restore old body state if there was a collision or
it was only a check for movement */
m_ptBody->p = tOldPos;
cpBodySetAngle(m_ptBody, fOldA);
}
else {
/* Update the active space hash if the movement is actual */
cpSpaceReindexShape(m_cEngine.GetPhysicsSpace(), m_ptShape);
}
}
else {
/* The box is not movable, so you can't move it :-) */
nCollision = 1;
}
/* The movement is allowed if there is no collision */
return !nCollision;
}
开发者ID:EduardoFF,项目名称:argos2-RoboNetSim,代码行数:51,代码来源:dynamics2d_box_entity.cpp
示例3: cpBodySetAngle
void RCPBody::setAngle(float a)
{
mAngle = a;
if (mBody) {
cpBodySetAngle(mBody, degToRad(mAngle));
}
}
开发者ID:trsquarelab,项目名称:csscene,代码行数:7,代码来源:rcpbody.cpp
示例4: cpBodySetAngle
void PhysicsBody::setRotation(float rotation)
{
if (!_rotationResetTag)
{
cpBodySetAngle(_info->getBody(), -PhysicsHelper::float2cpfloat((rotation + _rotationOffset) * (M_PI / 180.0f)));
}
}
开发者ID:Janak-Nirmal,项目名称:spritebuilder_cocos2dx_sample,代码行数:7,代码来源:CCPhysicsBody.cpp
示例5: cpBodyInit
cpBody*
cpBodyInit(cpBody *body, cpFloat m, cpFloat i)
{
body->velocity_func = cpBodyUpdateVelocityDefault;
body->position_func = cpBodyUpdatePositionDefault;
cpBodySetMass(body, m);
cpBodySetMoment(body, i);
body->p = cpvzero;
body->v = cpvzero;
body->f = cpvzero;
cpBodySetAngle(body, 0.0f);
body->w = 0.0f;
body->t = 0.0f;
body->v_bias = cpvzero;
body->w_bias = 0.0f;
body->data = NULL;
body->v_limit = (cpFloat)INFINITY;
body->w_limit = (cpFloat)INFINITY;
body->space = NULL;
body->shapesList = NULL;
cpComponentNode node = {NULL, NULL, 0, 0.0f};
body->node = node;
return body;
}
开发者ID:jelowang,项目名称:i51,代码行数:32,代码来源:cpBody.cpp
示例6: erl_element
ETERM *body_copy(ETERM *fromp, ETERM *argp) {
// get the args
ETERM *space_refp = erl_element(1, argp);
ETERM *idp = erl_element(2, argp);
ETERM *from_idp = erl_element(3, argp);
erlmunk_space *s;
int space_id = ERL_REF_NUMBER(space_refp);
HASH_FIND_INT(erlmunk_spaces, &space_id, s);
int body_id = ERL_INT_VALUE(idp);
erlmunk_body *b;
HASH_FIND_INT(s->bodies, &body_id, b);
if (b == NULL)
return NULL;
int from_body_id = ERL_INT_VALUE(from_idp);
erlmunk_body *from_b;
HASH_FIND_INT(s->bodies, &from_body_id, from_b);
// DEBUGF(("copying location from body #%d(%p) to #%d(%p)",
// from_body_id, from_b, body_id, b));
// copy position and angle from the from body
cpBodySetPosition(b->body, cpBodyGetPosition(from_b->body));
cpBodySetAngle(b->body, cpBodyGetAngle(from_b->body));
cpBodySetVelocity(b->body, cpBodyGetVelocity(from_b->body));
return NULL;
}
开发者ID:lrascao,项目名称:erlmunk,代码行数:31,代码来源:erlmunk_space.c
示例7: cpBodyInit
cpBody*
cpBodyInit(cpBody *body, cpFloat m, cpFloat i)
{
body->velocity_func = cpBodyUpdateVelocity;
body->position_func = cpBodyUpdatePosition;
cpBodySetMass(body, m);
cpBodySetMoment(body, i);
body->p = cpvzero;
body->v = cpvzero;
body->f = cpvzero;
cpBodySetAngle(body, 0.0f);
body->w = 0.0f;
body->t = 0.0f;
body->v_bias = cpvzero;
body->w_bias = 0.0f;
body->data = NULL;
// body->active = 1;
return body;
}
开发者ID:JINXSHADYLANE,项目名称:quibble,代码行数:25,代码来源:cpBody.c
示例8: Shell
Shell(cpVect pos, cpVect vel, float angle)
{
cpVect vl[4] = {cpv(0, 0), cpv(0.1, 0), cpv(0.07, 0.3), cpv(0.03, 0.3)};
int vn = sizeof(vl)/sizeof(cpVect);
float mass = cpAreaForPoly(vn, vl, 0) * shell_density;
float moi = cpMomentForPoly(mass, vn, vl, cpv(0, 0), 0);
body = cpBodyNew(mass, moi);
cpshape = cpPolyShapeNew(body, vn, vl, cpTransformIdentity, 0);
cpShapeSetFriction(cpshape, 0.9);
cpVect centroid = cpCentroidForPoly(vn, vl);
shape.setPointCount(vn);
for (int i = 0; i < vn; i++)
{
shape.setPoint(i, sf::Vector2f(vl[i].x, vl[i].y));
}
cpBodySetCenterOfGravity(body, centroid);
cpBodySetPosition(body, pos-centroid);
cpBodySetVelocity(body, vel);
cpBodySetAngle(body, angle);
cpShapeSetCollisionType(cpshape, 2);
cpShapeSetUserData(cpshape, this);
}
开发者ID:cyclohexanamine,项目名称:shipbrain,代码行数:28,代码来源:main.cpp
示例9: add_box
static void
add_box(cpSpace *space)
{
const cpFloat size = 10.0f;
const cpFloat mass = 1.0f;
cpVect verts[] = {
cpv(-size,-size),
cpv(-size, size),
cpv( size, size),
cpv( size,-size),
};
cpFloat radius = cpvlength(cpv(size, size));
cpVect pos = rand_pos(radius);
cpBody *body = cpSpaceAddBody(space, cpBodyNew(mass, cpMomentForPoly(mass, 4, verts, cpvzero, 0.0f)));
body->velocity_func = planetGravityVelocityFunc;
cpBodySetPosition(body, pos);
// Set the box's velocity to put it into a circular orbit from its
// starting position.
cpFloat r = cpvlength(pos);
cpFloat v = cpfsqrt(gravityStrength / r) / r;
cpBodySetVelocity(body, cpvmult(cpvperp(pos), v));
// Set the box's angular velocity to match its orbital period and
// align its initial angle with its position.
cpBodySetAngularVelocity(body, v);
cpBodySetAngle(body, cpfatan2(pos.y, pos.x));
cpShape *shape = cpSpaceAddShape(space, cpPolyShapeNew(body, 4, verts, cpTransformIdentity, 0.0));
cpShapeSetElasticity(shape, 0.0f);
cpShapeSetFriction(shape, 0.7f);
}
开发者ID:Ben-G,项目名称:spritebuilder-angrybirds,代码行数:35,代码来源:Planet.c
示例10: cpv
void CDynamics2DMultiBodyObjectModel::MoveTo(const CVector3& c_position,
const CQuaternion& c_orientation) {
/* Set target position and orientation */
cpVect tBodyPos = cpv(c_position.GetX(), c_position.GetY());
CRadians cXAngle, cYAngle, cZAngle;
c_orientation.ToEulerAngles(cZAngle, cYAngle, cXAngle);
cpFloat tBodyOrient = cZAngle.GetValue();
/* For each body: */
for(size_t i = 0; i < m_vecBodies.size(); ++i) {
/* Set body orientation at anchor */
cpBodySetAngle(m_vecBodies[i].Body,
tBodyOrient + m_vecBodies[i].OffsetOrient);
/* Set body position at anchor */
cpBodySetPos(m_vecBodies[i].Body,
cpvadd(tBodyPos,
cpvrotate(m_vecBodies[i].OffsetPos,
m_vecBodies[i].Body->rot)));
/* Update shape index */
cpSpaceReindexShapesForBody(GetDynamics2DEngine().GetPhysicsSpace(),
m_vecBodies[i].Body);
}
/* Update ARGoS entity state */
UpdateEntityStatus();
}
开发者ID:NavQ,项目名称:argos3,代码行数:25,代码来源:dynamics2d_multi_body_object_model.cpp
示例11: physics_add
void physics_add(Entity ent)
{
PhysicsInfo *info;
if (entitypool_get(pool, ent))
return; /* already has physics */
transform_add(ent);
info = entitypool_add(pool, ent);
info->mass = 1.0;
info->type = PB_DYNAMIC;
/* create, init cpBody */
info->body = cpSpaceAddBody(space, cpBodyNew(info->mass, 1.0));
cpBodySetUserData(info->body, ent); /* for cpBody -> Entity mapping */
cpBodySetPos(info->body, cpv_of_vec2(transform_get_position(ent)));
cpBodySetAngle(info->body, transform_get_rotation(ent));
info->last_dirty_count = transform_get_dirty_count(ent);
/* initially no shapes */
info->shapes = array_new(ShapeInfo);
/* initialize last_pos/last_ang info for kinematic bodies */
info->last_pos = cpBodyGetPos(info->body);
info->last_ang = cpBodyGetAngle(info->body);
info->collisions = NULL;
}
开发者ID:andi2,项目名称:cgame,代码行数:30,代码来源:physics.c
示例12: _update_kinematics
static void _update_kinematics()
{
PhysicsInfo *info;
cpVect pos;
cpFloat ang;
Scalar invdt;
Entity ent;
if (timing_dt <= FLT_EPSILON)
return;
invdt = 1 / timing_dt;
entitypool_foreach(info, pool)
if (info->type == PB_KINEMATIC)
{
ent = info->pool_elem.ent;
/* move to transform */
pos = cpv_of_vec2(transform_get_position(ent));
ang = transform_get_rotation(ent);
cpBodySetPos(info->body, pos);
cpBodySetAngle(info->body, ang);
info->last_dirty_count = transform_get_dirty_count(ent);
/* update linear, angular velocities based on delta */
cpBodySetVel(info->body,
cpvmult(cpvsub(pos, info->last_pos), invdt));
cpBodySetAngVel(info->body, (ang - info->last_ang) * invdt);
cpSpaceReindexShapesForBody(space, info->body);
/* save current state for next computation */
info->last_pos = pos;
info->last_ang = ang;
}
}
开发者ID:andi2,项目名称:cgame,代码行数:35,代码来源:physics.c
示例13: grabObject
static void grabObject(cpBody *body) {
cpVect lp;
lp = cpBodyWorld2Local(body, atlMouseClickPos());
atlCreateMouseJoint(g_Space, body, lp);
cpBodySetAngle(body, M_PI/180);
}
开发者ID:davidreynolds,项目名称:Atlas2D,代码行数:7,代码来源:editor.c
示例14: MachineSystem
void NaiveRotationAlgorithm::stepSystem(SystemInfo *individual)
{
MachineSystem *oldSystem = individual->system;
individual->system = new MachineSystem(*oldSystem); // copy it to stop all the damn bouncing about
delete oldSystem;
cpBody *inputBody = individual->system->partAtPosition(individual->system->inputMachinePosition)->body;
cpBody *outputBody = individual->system->partAtPosition(individual->system->outputMachinePosition)->body;
cpSpace *systemSpace = individual->system->getSpace();
cpConstraint *motor = cpSimpleMotorNew(cpSpaceGetStaticBody(systemSpace), inputBody, M_PI);
cpSpaceAddConstraint(systemSpace, motor);
cpConstraintSetMaxForce(motor, 50000);
for (int i=0; i<simSteps; i++) {
individual->inputValues[i] = (cpBodyGetAngle(inputBody));
cpSpaceStep(systemSpace, 0.1);
individual->outputValues[i] = (cpBodyGetAngle(outputBody));
}
cpSpaceRemoveConstraint(systemSpace, motor);
cpBodySetAngVel(outputBody, 0);
cpBodySetAngle(inputBody, 0);
}
开发者ID:thecodemaiden,项目名称:machine-generator,代码行数:27,代码来源:NaiveRotationAlgorithm.cpp
示例15: __declspec
__declspec( dllexport ) void push( const void * _in, int in_size, void * _out, int out_sz )
{
int index;
Variable *var;
cpBody *body;
cpShape *shape;
index = PEEKINT(INPUT_MEMBLOCK,0);
var = vhGetVariable(&mVariableHandler,index);
switch (var->mType)
{
case VarTypeBody:
body = (cpBody*)var->mPtr;
cpBodySetAngle(body,degToRad(PEEKFLOAT(INPUT_MEMBLOCK,4)));
cpBodySetPos(body,PEEKVECT(INPUT_MEMBLOCK,8));
cpBodySetAngVel(body,degToRad(PEEKFLOAT(INPUT_MEMBLOCK,16)));
cpBodySetVel(body,PEEKVECT(INPUT_MEMBLOCK,20));
break;
case VarTypeShape:
shape = (cpShape*)var->mPtr;
cpShapeSetFriction(shape,PEEKFLOAT(INPUT_MEMBLOCK,4));
cpShapeSetElasticity(shape,PEEKFLOAT(INPUT_MEMBLOCK,8));
cpShapeSetLayers(shape,PEEKUINT(INPUT_MEMBLOCK,12));
cpShapeSetGroup(shape,PEEKUINT(INPUT_MEMBLOCK,16));
break;
}
}
开发者ID:Latexi95,项目名称:cbChipmunk,代码行数:29,代码来源:cbchipmunk.c
示例16: lc_body_newindex
int lc_body_newindex(lua_State *vm){
//userdata, key, data
const char *key = lua_tostring(vm, 2);
cpBody *body = (lc_GetBody(1, vm))->body;
if (strcmp("pos", key) == 0 && lua_istable(vm, 3)){
cpBodySetPos(body, lc_TableTocpVect(3, vm));
}
else if (strcmp("vel", key) == 0 && lua_istable(vm, 3)){
cpBodySetVel(body, lc_TableTocpVect(3, vm));
}
else if (strcmp("angle", key) == 0 || strcmp("radangle", key) == 0){
cpBodySetAngle(body, (cpFloat)lua_tonumber(vm, 3));
}
else if (strcmp("degangle", key) == 0){
cpBodySetAngle(body, ( (cpFloat)lua_tonumber(vm, 3)*(cpFloat)M_PI/(cpFloat)180.f ) );
}
return 0;
}
开发者ID:sixian,项目名称:lunatic-chipmunk,代码行数:18,代码来源:body.c
示例17: landerRotate
void landerRotate(int direction, Lander l) //-1 counterclockwise, 1 clockwise
{
if(abs(l->orientation + direction) >= MAX_ORIENTATION)
return;
l->orientation += direction;
cpBodySetAngle(l->body, radiansFromOrientation(l->orientation));
}
开发者ID:emsoccer,项目名称:DTD-Lunar-Lander,代码行数:9,代码来源:lander.c
示例18: cpBodyUpdatePosition
void
cpBodyUpdatePosition(cpBody *body, cpFloat dt)
{
body->p = cpvadd(body->p, cpvmult(cpvadd(body->v, body->v_bias), dt));
cpBodySetAngle(body, body->a + (body->w + body->w_bias)*dt);
body->v_bias = cpvzero;
body->w_bias = 0.0f;
}
开发者ID:JINXSHADYLANE,项目名称:quibble,代码行数:9,代码来源:cpBody.c
示例19: cpBodySetAngle
void LinkerAgent::UpdateFromEngine()
{
DJVector2 djPosition = m_pSprite->GetPosition();
float djAngle = m_pSprite->GetRotation();
cpVect cpPosition;
cpPosition.x = (float) djPosition.x();
cpPosition.y = (float) -djPosition.y();
cpBodySetAngle(m_pBody, djAngle);
cpBodySetPos(m_pBody, cpPosition);
}
开发者ID:vanminhle246,项目名称:Physics2Engine,代码行数:10,代码来源:LinkerAgent.cpp
示例20: cpBodySetAngle
void RigidBody2D::CopyBodyData(cpBody* from, cpBody* to)
{
cpBodySetAngle(to, cpBodyGetAngle(from));
cpBodySetAngularVelocity(to, cpBodyGetAngularVelocity(from));
cpBodySetCenterOfGravity(to, cpBodyGetCenterOfGravity(from));
cpBodySetForce(to, cpBodyGetForce(from));
cpBodySetPosition(to, cpBodyGetPosition(from));
cpBodySetTorque(to, cpBodyGetTorque(from));
cpBodySetVelocity(to, cpBodyGetVelocity(from));
}
开发者ID:Gawaboumga,项目名称:NazaraEngine,代码行数:10,代码来源:RigidBody2D.cpp
注:本文中的cpBodySetAngle函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论