我正在网格中旋转骨架的骨骼,以获得低聚3D图形.在顶点着色器上它的应用就像这样.
GLSL:
vec4 vert1 = (bone_matrix[index1]*vertex_in)*weight;
vec4 vert2 = (bone_matrix[index2]*vertex_in)*(1-weight);
gl_Position = vert1+vert2;
Run Code Online (Sandbox Code Playgroud)
bone_matrix[index1]是一个骨骼的矩阵,是另一个骨骼bone_matrix[index2]的矩阵. weight指定vertex_in这些骨头的成员资格.问题是重量越接近.5,当施加旋转时,肘部的直径越大.我用大约10,000个顶点圆柱形状(带有梯度的重量)对它进行了测试.结果看起来像弯曲花园软管.
我从这些来源获得了加权方法.它实际上是我能找到的唯一方式:
http://www.opengl.org/wiki/Skeletal_Animation
http://ogldev.atspace.co.uk/www/tutorial38/tutorial38.html
http://blenderecia.orgfree.com /blender/skinning_proposal.pdf

左边是形状如何开始,中间是上面方程如何旋转它,右边是我的目标.中间点是加权的0.5.弯曲度越大越好,180度直径为零.
因此,考虑到我可能没有考虑的选项或其他选项,其他人如何避免这种捏合效应?
编辑: 我已经使用四元数工作SLERP,但我选择不使用它,因为GLSL本身不支持它.我不能像汤姆所描述的那样让几何SLERP工作.我让NLERP在前90度工作,所以我在每个关节之间增加了一个"骨头".因此,为了将前臂弯曲40度,我将肘部和前臂各弯曲20度.这消除了挤压效应,代价是加倍骨量,这不是理想的解决方案.
JTextPane text;
text.setText("somewords <img src=\"file:///C:/filepath/fire.png\" text=\"[fire1]\" title=\"[fire2]\" alt=\"[fire3]\" style=\"width:11px;height:11px;\"> otherwords");
Run Code Online (Sandbox Code Playgroud)
给我这个
,这是预期的.但是当我突出显示它并复制粘贴它时,我会得到"somewords otherwords".在复制时在Firefox中完成的同样的事情将粘贴"somewords [fire3] otherwords"(它替代alt文本用于图像).有没有办法在复制alt文本时复制此行为,或者复制图片的任何其他指示?我猜它不是内置功能,所以我可能需要知道的是应该重载以模仿这种行为.
它用于输出/聊天窗口,因此重要的是当用户引用它时它包含图像(如表情)
更新:成功覆盖copyAction方法......现在怎么办?
// (should) allow copying of alt text in place of images
class CustomEditorKit extends HTMLEditorKit {
Action[] modifiedactions;
CustomEditorKit() {
int whereat=-1;
modifiedactions=super.getActions();
for(int k=0;k<super.getActions().length;k++) {
if(super.getActions()[k] instanceof CopyAction) //find where they keep the copyaction
{
whereat=k;
modifiedactions[whereat]=new CustomCopyAction(); //and replace it with a different one
}
}
}
@Override
public Action[] getActions() {
return modifiedactions; //returns the modified version instead of defaultActions …Run Code Online (Sandbox Code Playgroud) 所以基本上如果我把JPanels放在一个JPanel使用的内部GridBagLayout并且我限制了大小setPreferredSize,最终它达到了无法容纳所有这些的点,并且它展示了附图中显示的行为:
我正在制作手风琴.这只是一个展示我遇到的问题的例子.手风琴的每个部分都可以单独打开,它们具有任意大小,可以随时添加.它很容易达到所有单个面板的高度,并将它们与总高度进行比较,但是当添加太多时,它表现出我所展示的嘎吱嘎吱的行为.这也缩小了高度,因此更难以确定何时发生嘎吱嘎吱声.我必须缓存高度,并以某种方式预先计算新部件的高度.最终目标是在添加新面板并且没有足够空间时移除旧面板.
有没有一种简单的方法来确定如果它没有受到限制会有什么高度,或者可能是一种支持的方法来检测何时发生这样的嘎吱嘎吱(所以我可以在再次涂漆之前快速将其稀释)?使得GridBagLayout行为像其他布局一样并且溢出到Hammerspace而不是压缩的选项也会起作用.
代码例如:
import java.awt.*;
import java.awt.event.*;
import javaisms.out;
import javax.swing.*;
public class FoldDrag extends JLayeredPane {
public TexturedPanel backingPanel = new TexturedPanel(new GridBagLayout(),"data/gui/grayerbricks.png");
static JPanel windowbase=new JPanel();
static JPanel restrictedpanel=new JPanel(new GridBagLayout());
GridBagConstraints gbc = new GridBagConstraints();
public FoldDrag() {
JButton addpan = new JButton("Add things");
windowbase.add(addpan);
windowbase.add(restrictedpanel);
restrictedpanel.setBackground(Color.red);
restrictedpanel.setPreferredSize(new Dimension(200,200));
gbc.weighty=1;
gbc.weightx=1;
gbc.gridx=0;
gbc.gridy=0;
gbc.gridheight=1;
gbc.gridwidth=1;
gbc.fill=GridBagConstraints.HORIZONTAL;
addpan.addActionListener(new ActionListener() {
int number=0;
@Override …Run Code Online (Sandbox Code Playgroud)