- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试用一堆尸体制作一个布娃娃。我想用什么样的关节来连接它们?距离关节?
最佳答案
C# API 应该与 AS3.0 非常相似,看看 AS3.0 Flash Implementation Samples :
这里是示例布娃娃的代码:
/*
* Copyright (c) 2006-2007 Erin Catto http://www.gphysics.com
*
* This software is provided 'as-is', without any express or implied
* warranty. In no event will the authors be held liable for any damages
* arising from the use of this software.
* Permission is granted to anyone to use this software for any purpose,
* including commercial applications, and to alter it and redistribute it
* freely, subject to the following restrictions:
* 1. The origin of this software must not be misrepresented; you must not
* claim that you wrote the original software. If you use this software
* in a product, an acknowledgment in the product documentation would be
* appreciated but is not required.
* 2. Altered source versions must be plainly marked as such, and must not be
* misrepresented as being the original software.
* 3. This notice may not be removed or altered from any source distribution.
*/
package TestBed{
import Box2D.Dynamics.*;
import Box2D.Collision.*;
import Box2D.Collision.Shapes.*;
import Box2D.Dynamics.Joints.*;
import Box2D.Dynamics.Contacts.*;
import Box2D.Common.*;
import Box2D.Common.Math.*;
public class TestRagdoll extends Test{
public function TestRagdoll(){
// Set Text field
Main.m_aboutText.text = "Ragdolls";
var circ:b2CircleShape;
var box:b2PolygonShape;
var bd:b2BodyDef = new b2BodyDef();
var jd:b2RevoluteJointDef = new b2RevoluteJointDef();
var fixtureDef:b2FixtureDef = new b2FixtureDef();
// Add 5 ragdolls along the top
for (var i:int = 0; i < 2; i++){
var startX:Number = 70 + Math.random() * 20 + 480 * i;
var startY:Number = 20 + Math.random() * 50;
// BODIES
// Set these to dynamic bodies
bd.type = b2Body.b2_dynamicBody;
// Head
circ = new b2CircleShape( 12.5 / m_physScale );
fixtureDef.shape = circ;
fixtureDef.density = 1.0;
fixtureDef.friction = 0.4;
fixtureDef.restitution = 0.3;
bd.position.Set(startX / m_physScale, startY / m_physScale);
var head:b2Body = m_world.CreateBody(bd);
head.CreateFixture(fixtureDef);
//if (i == 0){
head.ApplyImpulse(new b2Vec2(Math.random() * 100 - 50, Math.random() * 100 - 50), head.GetWorldCenter());
//}
// Torso1
box = new b2PolygonShape();
box.SetAsBox(15 / m_physScale, 10 / m_physScale);
fixtureDef.shape = box;
fixtureDef.density = 1.0;
fixtureDef.friction = 0.4;
fixtureDef.restitution = 0.1;
bd.position.Set(startX / m_physScale, (startY + 28) / m_physScale);
var torso1:b2Body = m_world.CreateBody(bd);
torso1.CreateFixture(fixtureDef);
// Torso2
box = new b2PolygonShape();
box.SetAsBox(15 / m_physScale, 10 / m_physScale);
fixtureDef.shape = box;
bd.position.Set(startX / m_physScale, (startY + 43) / m_physScale);
var torso2:b2Body = m_world.CreateBody(bd);
torso2.CreateFixture(fixtureDef);
// Torso3
box.SetAsBox(15 / m_physScale, 10 / m_physScale);
fixtureDef.shape = box;
bd.position.Set(startX / m_physScale, (startY + 58) / m_physScale);
var torso3:b2Body = m_world.CreateBody(bd);
torso3.CreateFixture(fixtureDef);
// UpperArm
fixtureDef.density = 1.0;
fixtureDef.friction = 0.4;
fixtureDef.restitution = 0.1;
// L
box = new b2PolygonShape();
box.SetAsBox(18 / m_physScale, 6.5 / m_physScale);
fixtureDef.shape = box;
bd.position.Set((startX - 30) / m_physScale, (startY + 20) / m_physScale);
var upperArmL:b2Body = m_world.CreateBody(bd);
upperArmL.CreateFixture(fixtureDef);
// R
box = new b2PolygonShape();
box.SetAsBox(18 / m_physScale, 6.5 / m_physScale);
fixtureDef.shape = box;
bd.position.Set((startX + 30) / m_physScale, (startY + 20) / m_physScale);
var upperArmR:b2Body = m_world.CreateBody(bd);
upperArmR.CreateFixture(fixtureDef);
// LowerArm
fixtureDef.density = 1.0;
fixtureDef.friction = 0.4;
fixtureDef.restitution = 0.1;
// L
box = new b2PolygonShape();
box.SetAsBox(17 / m_physScale, 6 / m_physScale);
fixtureDef.shape = box;
bd.position.Set((startX - 57) / m_physScale, (startY + 20) / m_physScale);
var lowerArmL:b2Body = m_world.CreateBody(bd);
lowerArmL.CreateFixture(fixtureDef);
// R
box = new b2PolygonShape();
box.SetAsBox(17 / m_physScale, 6 / m_physScale);
fixtureDef.shape = box;
bd.position.Set((startX + 57) / m_physScale, (startY + 20) / m_physScale);
var lowerArmR:b2Body = m_world.CreateBody(bd);
lowerArmR.CreateFixture(fixtureDef);
// UpperLeg
fixtureDef.density = 1.0;
fixtureDef.friction = 0.4;
fixtureDef.restitution = 0.1;
// L
box = new b2PolygonShape();
box.SetAsBox(7.5 / m_physScale, 22 / m_physScale);
fixtureDef.shape = box;
bd.position.Set((startX - 8) / m_physScale, (startY + 85) / m_physScale);
var upperLegL:b2Body = m_world.CreateBody(bd);
upperLegL.CreateFixture(fixtureDef);
// R
box = new b2PolygonShape();
box.SetAsBox(7.5 / m_physScale, 22 / m_physScale);
fixtureDef.shape = box;
bd.position.Set((startX + 8) / m_physScale, (startY + 85) / m_physScale);
var upperLegR:b2Body = m_world.CreateBody(bd);
upperLegR.CreateFixture(fixtureDef);
// LowerLeg
fixtureDef.density = 1.0;
fixtureDef.friction = 0.4;
fixtureDef.restitution = 0.1;
// L
box = new b2PolygonShape();
box.SetAsBox(6 / m_physScale, 20 / m_physScale);
fixtureDef.shape = box;
bd.position.Set((startX - 8) / m_physScale, (startY + 120) / m_physScale);
var lowerLegL:b2Body = m_world.CreateBody(bd);
lowerLegL.CreateFixture(fixtureDef);
// R
box = new b2PolygonShape();
box.SetAsBox(6 / m_physScale, 20 / m_physScale);
fixtureDef.shape = box;
bd.position.Set((startX + 8) / m_physScale, (startY + 120) / m_physScale);
var lowerLegR:b2Body = m_world.CreateBody(bd);
lowerLegR.CreateFixture(fixtureDef);
// JOINTS
jd.enableLimit = true;
// Head to shoulders
jd.lowerAngle = -40 / (180/Math.PI);
jd.upperAngle = 40 / (180/Math.PI);
jd.Initialize(torso1, head, new b2Vec2(startX / m_physScale, (startY + 15) / m_physScale));
m_world.CreateJoint(jd);
// Upper arm to shoulders
// L
jd.lowerAngle = -85 / (180/Math.PI);
jd.upperAngle = 130 / (180/Math.PI);
jd.Initialize(torso1, upperArmL, new b2Vec2((startX - 18) / m_physScale, (startY + 20) / m_physScale));
m_world.CreateJoint(jd);
// R
jd.lowerAngle = -130 / (180/Math.PI);
jd.upperAngle = 85 / (180/Math.PI);
jd.Initialize(torso1, upperArmR, new b2Vec2((startX + 18) / m_physScale, (startY + 20) / m_physScale));
m_world.CreateJoint(jd);
// Lower arm to upper arm
// L
jd.lowerAngle = -130 / (180/Math.PI);
jd.upperAngle = 10 / (180/Math.PI);
jd.Initialize(upperArmL, lowerArmL, new b2Vec2((startX - 45) / m_physScale, (startY + 20) / m_physScale));
m_world.CreateJoint(jd);
// R
jd.lowerAngle = -10 / (180/Math.PI);
jd.upperAngle = 130 / (180/Math.PI);
jd.Initialize(upperArmR, lowerArmR, new b2Vec2((startX + 45) / m_physScale, (startY + 20) / m_physScale));
m_world.CreateJoint(jd);
// Shoulders/stomach
jd.lowerAngle = -15 / (180/Math.PI);
jd.upperAngle = 15 / (180/Math.PI);
jd.Initialize(torso1, torso2, new b2Vec2(startX / m_physScale, (startY + 35) / m_physScale));
m_world.CreateJoint(jd);
// Stomach/hips
jd.Initialize(torso2, torso3, new b2Vec2(startX / m_physScale, (startY + 50) / m_physScale));
m_world.CreateJoint(jd);
// Torso to upper leg
// L
jd.lowerAngle = -25 / (180/Math.PI);
jd.upperAngle = 45 / (180/Math.PI);
jd.Initialize(torso3, upperLegL, new b2Vec2((startX - 8) / m_physScale, (startY + 72) / m_physScale));
m_world.CreateJoint(jd);
// R
jd.lowerAngle = -45 / (180/Math.PI);
jd.upperAngle = 25 / (180/Math.PI);
jd.Initialize(torso3, upperLegR, new b2Vec2((startX + 8) / m_physScale, (startY + 72) / m_physScale));
m_world.CreateJoint(jd);
// Upper leg to lower leg
// L
jd.lowerAngle = -25 / (180/Math.PI);
jd.upperAngle = 115 / (180/Math.PI);
jd.Initialize(upperLegL, lowerLegL, new b2Vec2((startX - 8) / m_physScale, (startY + 105) / m_physScale));
m_world.CreateJoint(jd);
// R
jd.lowerAngle = -115 / (180/Math.PI);
jd.upperAngle = 25 / (180/Math.PI);
jd.Initialize(upperLegR, lowerLegR, new b2Vec2((startX + 8) / m_physScale, (startY + 105) / m_physScale));
m_world.CreateJoint(jd);
}
// Add stairs on the left, these are static bodies so set the type accordingly
bd.type = b2Body.b2_staticBody;
fixtureDef.density = 0.0;
fixtureDef.friction = 0.4;
fixtureDef.restitution = 0.3;
for (var j:int = 1; j <= 10; j++) {
box = new b2PolygonShape();
box.SetAsBox((10*j) / m_physScale, 10 / m_physScale);
fixtureDef.shape = box;
bd.position.Set((10*j) / m_physScale, (150 + 20*j) / m_physScale);
head = m_world.CreateBody(bd);
head.CreateFixture(fixtureDef);
}
// Add stairs on the right
for (var k:int = 1; k <= 10; k++){
box = new b2PolygonShape();
box.SetAsBox((10 * k) / m_physScale, 10 / m_physScale);
fixtureDef.shape = box;
bd.position.Set((640-10*k) / m_physScale, (150 + 20*k) / m_physScale);
head = m_world.CreateBody(bd);
head.CreateFixture(fixtureDef);
}
box = new b2PolygonShape();
box.SetAsBox(30 / m_physScale, 40 / m_physScale);
fixtureDef.shape = box;
bd.position.Set(320 / m_physScale, 320 / m_physScale);
head = m_world.CreateBody(bd);
head.CreateFixture(fixtureDef);
}
//======================
// Member Data
//======================
}
}
关于C# XNA Box2d : What kind of joints for a ragdoll?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2263146/
我正在使用MySQL。在我的数据库中,我有以下表格: A student table 。该表的主键是sid . A high_school table 。主键是 hid . A university
我正在使用MySQL。在我的数据库中,我有以下表格: A student table 。该表的主键是sid . A high_school table 。主键是 hid . A university
我通过 Python 3.7 使用 OpenCV。我有一组看起来像这样的单色图像: 我想在这些图像上找到所有“关节点”,其中“关节点” - 是两个木板的每个交叉点的中心(1 像素)。这些“关节”大致由
如何在关节js中的克隆关节元素上触发pointerdown/dragstart?当工具箱纸上触发 pointerdown 事件时,会触发 toolBoxPointerDown。当 _this.pape
我正在两篇论文之间实现拖放操作。但是由于我的 html 正文中有两篇论文,所以我坚持拖动元素的偏移量与光标位置的同步。我对 css 的经验非常少,这可能会导致问题元素的定位。 用例:- 用户单击纸 2
我是 Joint JS 的新手,无法动态设置以下元素的宽度和高度属性: var rect = new joint.shapes.basic.Rect({ position: { x: 100,
我有这样的数据库结构: TBL_A | TBL_B | TBL_C | TBL_D | TBL_E -------+---------+---------+---------+-----
我才刚刚开始学习组合,所以对我来说还是有点模糊。我想创建一个自定义的 Publisher,它将使用 CLLocationManager 来公开当前用户位置。我希望它以这样的方式工作,即 locatio
我正在开发一款让玩家围绕行星运行的游戏。我正在使用 PrismaticJoint 让玩家靠近和远离行星,我通过旋转玩家 (bodyB) 所连接的中心点主体(关节的 bodyA)来围绕玩家运行。我通过启
我有一个需要 SKPhysicsJointFixed.joint 的小游戏,它一切正常,除了一个事实,即关节处于事件状态时,即 10 秒,会使 Sprite 速度减慢,速度似乎是 Sprite 速度的
这是我的设置: SKScene 有一个名为 world 的节点 在这个世界上,我附加了另一个节点:车辆 我将三个节点附加到这辆车上;一个 body 和两个轮子 轮子通过指定 anchor 的 SKPh
以下代码出现错误 - 物理关节数组似乎具有 PKPhysicsJoint 类。有人知道如何在 Swift 中迭代关节吗? documentation确实说 physicsBody.joints 应该返
我想做的是为端口和路径创建一个带有自定义类的元素,这样我就可以添加一个带有自定义路径的元素和我自己的端口标记。这样当我创建一个元素时,我将传递动态路径它的形状就像路径类的元素一样,而且我也从 Port
我正在研究 JointJS API。但是我想防止元素从它们的原始位置移动。你能建议我一些 JointJS 的特性或 CSS 的任何一般特性,我可以用它来使我的对象不可移动。 我不能在论文或 paper
因此,当我继续构建 Autowiring 脚本时,我遇到了我预计难以解决的三个问题中的第二个。这可能是一个非常简单的答案:但脚本本身非常容易使用,首先点击“生成代理定位器”,然后点击“构建脊柱关节”:
我在两个物体(一个球体和一个盒子)之间有一个铰接点。我想知道当球体用旋转电机围绕盒子旋转时如何避免球体进入盒子内部。 这是沿 x 轴旋转时球体进入盒子内部的快照: 两个物体都有物理特性,并且都在机器人
我正在尝试用一堆尸体制作一个布娃娃。我想用什么样的关节来连接它们?距离关节? 最佳答案 C# API 应该与 AS3.0 非常相似,看看 AS3.0 Flash Implementation Samp
我在 joint.js 中有一个 FSA,我需要使状态(圆圈)从圆圈底部开始按特定比例半填充,例如 1/2 或 1/6。棘手的部分是它需要完成两次 - 一个更大的半填充和一个更小的半填充。 这就是我想
在我的 SQL 数据库中有以下表(简化): 表格博客: +----+----------------------+----------+ | ID | Date | T
我正处于 MS3D 解析器的规划阶段,正在查看 specs我看到顶点结构有一个 boneId 变量。 “骨头”是关节的同义词吗?那么,那个 boneId 变量是关节数组的索引吗?如果不是,那么什么是骨
我是一名优秀的程序员,十分优秀!