我需要在日志的末尾创build一个汇总表,其中包含一些在类中获取的值。 表格需要以固定宽度格式打印。 我已经有了这样的代码,但是我需要限制string,双精度和整数,以便在代码中硬编码的固定宽度的大小。 所以,假设我想打印一个固定宽度的表格 int,string,double,string int,string,double,string int,string,double,string int,string,double,string and the fixed widths are: 4, 5, 6, 6. 如果一个值超过这个宽度,最后的字符需要被切断。 举个例子: 124891, difference, 22.348, montreal 需要打印的string应该是: 1248 diffe 22.348 montre 我想我需要在构造函数中强制一个string不超过一定数量的字符。 我可能将双精度和整数转换为一个string,所以我可以执行最大宽度要求。 我不知道是哪一种方法,或者如果一个string可以被实例化的行为方式。 使用格式化程序只能帮助打印string的固定格式,但实际上并不会超过最大长度的字符。
在下面的代码中,哈希码总是相同的。 为什么这样? 码: public class BooleanClass { public static void main(String[] args) { Boolean b1 = new Boolean(true); Boolean b2 = new Boolean(false); Boolean b3 = new Boolean(true); Boolean b4 = new Boolean(false); Boolean b5 = new Boolean(false); Boolean b6 = new Boolean(true); System.out.println(b1.hashCode()); System.out.println(b2.hashCode()); System.out.println(b3.hashCode()); System.out.println(b4.hashCode()); System.out.println(b5.hashCode()); System.out.println(b6.hashCode()); } } 输出: 1231 1237 1231 […]
有没有办法打印数字从1到100,而不使用任何循环或条件,如“如果”? 我们可以很容易地使用recursion,但是又有一个if条件。 有没有办法做,而不使用“如果”以及? 也没有重复的打印语句,或包含从1到100的所有数字的单个打印语句。 Java的解决scheme是最好的。
我正在为运行RedHat的服务器devise一个控制台应用程序。 最终用户应该能够运行这个应用程序与他们select的任何terminal。 (例如:Gnometerminal,Putty SSH / Telnet,MS Telnet客户端等)。 在大多数terminal应用程序中没有任何错误,但是当我从MS Telnet会话启动我的程序时,我注意到System.in和System.console()特殊input已经完全搞砸了。 退格键会将^H写入屏幕,其他键写入乱码。 我已经深入了解这一点,我可以让它始终如一地工作,但是我确信我正在做的事情是严重的: if (!System.getenv("TERM").equals("xterm")) { System.out.println("\nWARNING: The TERM type is now set to xterm\n"); final String[] cmd = { "/bin/sh", "-c", "export TERM=xterm" }; Runtime.getRuntime().exec(cmd); } 对于不支持xtermterminal来说,会不会有一个问题? 我注意到,Microsoft Telnet客户端不允许您在开始会话之前将TERMtypes设置为xterm 。 一旦会话开始,然而,设置TERM=xterm似乎解决了这个问题。 大多数控制台应用程序如何解决这个问题?
在用Java编写的OpenOffice / LibreOffice Calc(Spreadsheet)的UNO扩展中,如何确定UDF(电子表格函数)实现中的调用单元? 备注 在Excel / VBA中,这可以通过Application.Caller 获取调用者的主要动机是logging/跟踪/debugging,即将调用单元视为堆栈跟踪的一部分。 应该可以获得这些信息,因为像“ROW()”和“COLUMN()”这样的内build函数确实对调用单元有一定的了解。 使用这种可能性的应用程序(用于Excel)是Obba ,它是电子表格的对象处理程序。 这里的“控制面板”提供了包括调用单元的(Java)exception列表, 即单元是堆栈跟踪的一部分。 看下面的截图: 这也是Apache OpenOffice Bugzilla的function要求
是否有可能在gson中编写一个json反序列化器,首先调用默认行为,然后我可以对我的对象做一些后期处理。 例如: public class FooDeserializer implements JsonDeserializer<Foo> { public Foo deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { Foo foo = context.deserialize(json, typeOfT);//Standard deserialization call????? foo.doSomething(); return foo(); } } 我正在使用GSON 1.3(我不能使用任何其他版本,因为我只能使用公司存储库中的版本) 谢谢
使用Google openidlogin我的应用程序时,出现间歇性错误。 他们发送的链接是http://www.example.com/_ah/login_redir?claimid=www.google.com/accounts/o8/id&continue=http://www.example.com/login2?returl%253Dhttp%25253A%25252F%25252Fwww.example.com%25252Ftest-list-8 。 然后当他们授予访问我的应用程序,有时有一个500错误的url: http://www.example.com/_ah/openid_verify?continue=http://www.example.com/login2?returl%3Dhttp%253A%252F%252Fwww.example.com%252Ftest-list-8%2523additem&gx.rp_st=AEp4C1sATcZr10BWADPx0hXZOeG49Vdr6GjYqvx83JXTTXjEFdqS8KaHIfZD3wmwTNl-wu8r7DMwoQMvWLpqgoV8RtAUigMMjw&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=id_res&openid.op_endpoint=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fud&openid.response_nonce=2011-12-06T20%3A00%3A53ZGU1ZOot7AJ4DGg&openid.return_to=http%3A%2F%2Fwww.example.com%2F_ah%2Fopenid_verify%3Fcontinue%3Dhttp%3A%2F%2Fwww.example.com%2Flogin2%3Freturl%253Dhttp%25253A%25252F%25252Fwww.example.com%25252Ftest-list-8%252523additem%26gx.rp_st%3DAEp4C1sATcZr10BWADPx0hXZOeG49Vdr6GjYqvx83JXTTXjEFdqS8KaHIfZD3wmwTNl-wu8r7DMwoQMvWLpqgoV8RtAUigMMjw&openid.assoc_handle=AMlYA9W4FErBlE7i17Z-YVirs2a0eP_LEjoDRJDVgEq9FhOSKt8xq4HT&openid.signed=op_endpoint%2Cclaimed_id%2Cidentity%2Creturn_to%2Cresponse_nonce%2Cassoc_handle%2Cns.ext1%2Cext1.mode%2Cext1.type.attr0%2Cext1.value.attr0%2Cext1.type.auto2%2Cext1.value.auto2&openid.sig=b7TBbUBO0mgF26qCpAjkS0AYeX8%3D&openid.identity=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%3DAItOawkBkv0HezgbtJVspVv8hxIBizNbHP_4t_M&openid.claimed_id=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%3DAItOawkBkv0HezgbtJVspVv8hxIBizNbHP_4t_M&openid.ns.ext1=http%3A%2F%2Fopenid.net%2Fsrv%2Fax%2F1.0&openid.ext1.mode=fetch_response&openid.ext1.type.attr0=http%3A%2F%2Faxschema.org%2Fcontact%2Femail&openid.ext1.value.attr0=myemail%40gmail.com&openid.ext1.type.auto2=http%3A%2F%2Fwww.google.com%2Faccounts%2Fapi%2Ffederated-login%2Fid&openid.ext1.value.auto2=105848731220363187343 : http://www.example.com/_ah/openid_verify?continue=http://www.example.com/login2?returl%3Dhttp%253A%252F%252Fwww.example.com%252Ftest-list-8%2523additem&gx.rp_st=AEp4C1sATcZr10BWADPx0hXZOeG49Vdr6GjYqvx83JXTTXjEFdqS8KaHIfZD3wmwTNl-wu8r7DMwoQMvWLpqgoV8RtAUigMMjw&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=id_res&openid.op_endpoint=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fud&openid.response_nonce=2011-12-06T20%3A00%3A53ZGU1ZOot7AJ4DGg&openid.return_to=http%3A%2F%2Fwww.example.com%2F_ah%2Fopenid_verify%3Fcontinue%3Dhttp%3A%2F%2Fwww.example.com%2Flogin2%3Freturl%253Dhttp%25253A%25252F%25252Fwww.example.com%25252Ftest-list-8%252523additem%26gx.rp_st%3DAEp4C1sATcZr10BWADPx0hXZOeG49Vdr6GjYqvx83JXTTXjEFdqS8KaHIfZD3wmwTNl-wu8r7DMwoQMvWLpqgoV8RtAUigMMjw&openid.assoc_handle=AMlYA9W4FErBlE7i17Z-YVirs2a0eP_LEjoDRJDVgEq9FhOSKt8xq4HT&openid.signed=op_endpoint%2Cclaimed_id%2Cidentity%2Creturn_to%2Cresponse_nonce%2Cassoc_handle%2Cns.ext1%2Cext1.mode%2Cext1.type.attr0%2Cext1.value.attr0%2Cext1.type.auto2%2Cext1.value.auto2&openid.sig=b7TBbUBO0mgF26qCpAjkS0AYeX8%3D&openid.identity=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%3DAItOawkBkv0HezgbtJVspVv8hxIBizNbHP_4t_M&openid.claimed_id=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%3DAItOawkBkv0HezgbtJVspVv8hxIBizNbHP_4t_M&openid.ns.ext1=http%3A%2F%2Fopenid.net%2Fsrv%2Fax%2F1.0&openid.ext1.mode=fetch_response&openid.ext1.type.attr0=http%3A%2F%2Faxschema.org%2Fcontact%2Femail&openid.ext1.value.attr0=myemail%40gmail.com&openid.ext1.type.auto2=http%3A%2F%2Fwww.google.com%2Faccounts%2Fapi%2Ffederated-login%2Fid&openid.ext1.value.auto2=105848731220363187343 continue= http://www.example.com/_ah/openid_verify?continue=http://www.example.com/login2?returl%3Dhttp%253A%252F%252Fwww.example.com%252Ftest-list-8%2523additem&gx.rp_st=AEp4C1sATcZr10BWADPx0hXZOeG49Vdr6GjYqvx83JXTTXjEFdqS8KaHIfZD3wmwTNl-wu8r7DMwoQMvWLpqgoV8RtAUigMMjw&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=id_res&openid.op_endpoint=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fud&openid.response_nonce=2011-12-06T20%3A00%3A53ZGU1ZOot7AJ4DGg&openid.return_to=http%3A%2F%2Fwww.example.com%2F_ah%2Fopenid_verify%3Fcontinue%3Dhttp%3A%2F%2Fwww.example.com%2Flogin2%3Freturl%253Dhttp%25253A%25252F%25252Fwww.example.com%25252Ftest-list-8%252523additem%26gx.rp_st%3DAEp4C1sATcZr10BWADPx0hXZOeG49Vdr6GjYqvx83JXTTXjEFdqS8KaHIfZD3wmwTNl-wu8r7DMwoQMvWLpqgoV8RtAUigMMjw&openid.assoc_handle=AMlYA9W4FErBlE7i17Z-YVirs2a0eP_LEjoDRJDVgEq9FhOSKt8xq4HT&openid.signed=op_endpoint%2Cclaimed_id%2Cidentity%2Creturn_to%2Cresponse_nonce%2Cassoc_handle%2Cns.ext1%2Cext1.mode%2Cext1.type.attr0%2Cext1.value.attr0%2Cext1.type.auto2%2Cext1.value.auto2&openid.sig=b7TBbUBO0mgF26qCpAjkS0AYeX8%3D&openid.identity=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%3DAItOawkBkv0HezgbtJVspVv8hxIBizNbHP_4t_M&openid.claimed_id=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%3DAItOawkBkv0HezgbtJVspVv8hxIBizNbHP_4t_M&openid.ns.ext1=http%3A%2F%2Fopenid.net%2Fsrv%2Fax%2F1.0&openid.ext1.mode=fetch_response&openid.ext1.type.attr0=http%3A%2F%2Faxschema.org%2Fcontact%2Femail&openid.ext1.value.attr0=myemail%40gmail.com&openid.ext1.type.auto2=http%3A%2F%2Fwww.google.com%2Faccounts%2Fapi%2Ffederated-login%2Fid&openid.ext1.value.auto2=105848731220363187343 : http://www.example.com/_ah/openid_verify?continue=http://www.example.com/login2?returl%3Dhttp%253A%252F%252Fwww.example.com%252Ftest-list-8%2523additem&gx.rp_st=AEp4C1sATcZr10BWADPx0hXZOeG49Vdr6GjYqvx83JXTTXjEFdqS8KaHIfZD3wmwTNl-wu8r7DMwoQMvWLpqgoV8RtAUigMMjw&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=id_res&openid.op_endpoint=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fud&openid.response_nonce=2011-12-06T20%3A00%3A53ZGU1ZOot7AJ4DGg&openid.return_to=http%3A%2F%2Fwww.example.com%2F_ah%2Fopenid_verify%3Fcontinue%3Dhttp%3A%2F%2Fwww.example.com%2Flogin2%3Freturl%253Dhttp%25253A%25252F%25252Fwww.example.com%25252Ftest-list-8%252523additem%26gx.rp_st%3DAEp4C1sATcZr10BWADPx0hXZOeG49Vdr6GjYqvx83JXTTXjEFdqS8KaHIfZD3wmwTNl-wu8r7DMwoQMvWLpqgoV8RtAUigMMjw&openid.assoc_handle=AMlYA9W4FErBlE7i17Z-YVirs2a0eP_LEjoDRJDVgEq9FhOSKt8xq4HT&openid.signed=op_endpoint%2Cclaimed_id%2Cidentity%2Creturn_to%2Cresponse_nonce%2Cassoc_handle%2Cns.ext1%2Cext1.mode%2Cext1.type.attr0%2Cext1.value.attr0%2Cext1.type.auto2%2Cext1.value.auto2&openid.sig=b7TBbUBO0mgF26qCpAjkS0AYeX8%3D&openid.identity=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%3DAItOawkBkv0HezgbtJVspVv8hxIBizNbHP_4t_M&openid.claimed_id=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%3DAItOawkBkv0HezgbtJVspVv8hxIBizNbHP_4t_M&openid.ns.ext1=http%3A%2F%2Fopenid.net%2Fsrv%2Fax%2F1.0&openid.ext1.mode=fetch_response&openid.ext1.type.attr0=http%3A%2F%2Faxschema.org%2Fcontact%2Femail&openid.ext1.value.attr0=myemail%40gmail.com&openid.ext1.type.auto2=http%3A%2F%2Fwww.google.com%2Faccounts%2Fapi%2Ffederated-login%2Fid&openid.ext1.value.auto2=105848731220363187343 returl% http://www.example.com/_ah/openid_verify?continue=http://www.example.com/login2?returl%3Dhttp%253A%252F%252Fwww.example.com%252Ftest-list-8%2523additem&gx.rp_st=AEp4C1sATcZr10BWADPx0hXZOeG49Vdr6GjYqvx83JXTTXjEFdqS8KaHIfZD3wmwTNl-wu8r7DMwoQMvWLpqgoV8RtAUigMMjw&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=id_res&openid.op_endpoint=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fud&openid.response_nonce=2011-12-06T20%3A00%3A53ZGU1ZOot7AJ4DGg&openid.return_to=http%3A%2F%2Fwww.example.com%2F_ah%2Fopenid_verify%3Fcontinue%3Dhttp%3A%2F%2Fwww.example.com%2Flogin2%3Freturl%253Dhttp%25253A%25252F%25252Fwww.example.com%25252Ftest-list-8%252523additem%26gx.rp_st%3DAEp4C1sATcZr10BWADPx0hXZOeG49Vdr6GjYqvx83JXTTXjEFdqS8KaHIfZD3wmwTNl-wu8r7DMwoQMvWLpqgoV8RtAUigMMjw&openid.assoc_handle=AMlYA9W4FErBlE7i17Z-YVirs2a0eP_LEjoDRJDVgEq9FhOSKt8xq4HT&openid.signed=op_endpoint%2Cclaimed_id%2Cidentity%2Creturn_to%2Cresponse_nonce%2Cassoc_handle%2Cns.ext1%2Cext1.mode%2Cext1.type.attr0%2Cext1.value.attr0%2Cext1.type.auto2%2Cext1.value.auto2&openid.sig=b7TBbUBO0mgF26qCpAjkS0AYeX8%3D&openid.identity=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%3DAItOawkBkv0HezgbtJVspVv8hxIBizNbHP_4t_M&openid.claimed_id=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%3DAItOawkBkv0HezgbtJVspVv8hxIBizNbHP_4t_M&openid.ns.ext1=http%3A%2F%2Fopenid.net%2Fsrv%2Fax%2F1.0&openid.ext1.mode=fetch_response&openid.ext1.type.attr0=http%3A%2F%2Faxschema.org%2Fcontact%2Femail&openid.ext1.value.attr0=myemail%40gmail.com&openid.ext1.type.auto2=http%3A%2F%2Fwww.google.com%2Faccounts%2Fapi%2Ffederated-login%2Fid&openid.ext1.value.auto2=105848731220363187343 http://www.example.com/_ah/openid_verify?continue=http://www.example.com/login2?returl%3Dhttp%253A%252F%252Fwww.example.com%252Ftest-list-8%2523additem&gx.rp_st=AEp4C1sATcZr10BWADPx0hXZOeG49Vdr6GjYqvx83JXTTXjEFdqS8KaHIfZD3wmwTNl-wu8r7DMwoQMvWLpqgoV8RtAUigMMjw&openid.ns=http%3A%2F%2Fspecs.openid.net%2Fauth%2F2.0&openid.mode=id_res&openid.op_endpoint=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fud&openid.response_nonce=2011-12-06T20%3A00%3A53ZGU1ZOot7AJ4DGg&openid.return_to=http%3A%2F%2Fwww.example.com%2F_ah%2Fopenid_verify%3Fcontinue%3Dhttp%3A%2F%2Fwww.example.com%2Flogin2%3Freturl%253Dhttp%25253A%25252F%25252Fwww.example.com%25252Ftest-list-8%252523additem%26gx.rp_st%3DAEp4C1sATcZr10BWADPx0hXZOeG49Vdr6GjYqvx83JXTTXjEFdqS8KaHIfZD3wmwTNl-wu8r7DMwoQMvWLpqgoV8RtAUigMMjw&openid.assoc_handle=AMlYA9W4FErBlE7i17Z-YVirs2a0eP_LEjoDRJDVgEq9FhOSKt8xq4HT&openid.signed=op_endpoint%2Cclaimed_id%2Cidentity%2Creturn_to%2Cresponse_nonce%2Cassoc_handle%2Cns.ext1%2Cext1.mode%2Cext1.type.attr0%2Cext1.value.attr0%2Cext1.type.auto2%2Cext1.value.auto2&openid.sig=b7TBbUBO0mgF26qCpAjkS0AYeX8%3D&openid.identity=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%3DAItOawkBkv0HezgbtJVspVv8hxIBizNbHP_4t_M&openid.claimed_id=https%3A%2F%2Fwww.google.com%2Faccounts%2Fo8%2Fid%3Fid%3DAItOawkBkv0HezgbtJVspVv8hxIBizNbHP_4t_M&openid.ns.ext1=http%3A%2F%2Fopenid.net%2Fsrv%2Fax%2F1.0&openid.ext1.mode=fetch_response&openid.ext1.type.attr0=http%3A%2F%2Faxschema.org%2Fcontact%2Femail&openid.ext1.value.attr0=myemail%40gmail.com&openid.ext1.type.auto2=http%3A%2F%2Fwww.google.com%2Faccounts%2Fapi%2Ffederated-login%2Fid&openid.ext1.value.auto2=105848731220363187343 500错误甚至不出现在我的日志中。 这似乎发生了约5-10%的login。
我想知道是否有人有任何build议处理与Apache POI损坏的文件 我试图打开一个文件,并收到此消息: Exception in thread "main" org.apache.poi.hssf.record.RecordInputStream$LeftoverDataException: Initialisation of record 0x1C left 2 bytes remaining still to be read. at org.apache.poi.hssf.record.RecordInputStream.hasNextRecord(RecordInputStream.java:156) at org.apache.poi.hssf.record.RecordFactoryInputStream.nextRecord(RecordFactoryInputStream.java:231) at org.apache.poi.hssf.record.RecordFactory.createRecords(RecordFactory.java:480) at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:301) at org.apache.poi.ss.usermodel.WorkbookFactory.create(WorkbookFactory.java:95) at ExcelImporter.EditFileImportDialog.main(EditFileImportDialog.java:409) 这是一个SSCCE import org.apache.poi.openxml4j.exceptions.InvalidFormatException; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.WorkbookFactory; public class EditFileImportDialog { /* Omitted irrelevent code */ public static void main(String[] args) { File […]
我在使用Eclipse的Android JUnittestingtesting一个使用ActionBarActivity的应用程序时出现了问题,这个应用程序使用了android-support-v7-appcompat。 在模拟器或设备上运行时,似乎一切正常。 我尝试使用一个模拟应用程序在ActivityUnitTestCase和startActivity与ActionBarActivity和改变了值的母版主题-V11等,如在ActionBarCompatbuild议:java.lang.IllegalStateException:您需要使用一个Theme.AppCompat,但它仍然无法正常工作。 你需要使用一个Theme.AppCompat主题(或后代),这个活动也不会给出答案,也就是说,提问的人既没有在他的清单中指定的Theme.AppCompat(我也这么做),也没有真的想要扩展ActionBarActivity(我这样做)。 他的解决scheme是简单地扩展Activity。 我究竟做错了什么? 这是我得到的错误(Junit窗口中的Failure-Trace): java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity. at android.support.v7.app.ActionBarActivityDelegate.onCreate(ActionBarActivityDelegate.java:108) at android.support.v7.app.ActionBarActivityDelegateICS.onCreate(ActionBarActivityDelegateICS.java:57) at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:98) at android.hello.HelloWorldActivity.onCreate(HelloWorldActivity.java:14) at android.app.Activity.performCreate(Activity.java:5104) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080) at android.test.ActivityUnitTestCase.startActivity(ActivityUnitTestCase.java:158) at android.hello.test.HelloWorldActivityTest.setUp(HelloWorldActivityTest.java:26) at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:190) at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:175) at android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:555) at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1661) HelloWorldActivity.java package android.hello; import android.support.v7.app.ActionBar; import android.support.v7.app.ActionBarActivity; import android.app.Activity; import […]
编辑:对于实时绘图,在opengl和opencl之间的“互用性”中开始使用基于jmonkeyengine和jocl的lwjgl,现在可以实时计算和绘制10万个粒子。 也许地狱版本的Jmonkey引擎可以治愈这个drawcall开销问题。 几天来,我一直在Eclipse(java 64位)学习jMonkey引擎(ver:3.0),并尝试使用GeometryBatchFactory.optimize(rootNode);优化场景GeometryBatchFactory.optimize(rootNode); 命令。 没有优化(具有改变球体位置的能力): 好的,只有1-fps源于pci-express带宽+ jvm开销。 通过优化(无法改变球体的位置): 现在即使增加三angular形数字也是29 fps。 Java3D有一个setCapability()方法,它使得一个场景对象能够被优化的forms读写。 jMonkey引擎3.0必须能够这个主题,但我找不到任何痕迹(search教程和示例,失败)。 问题:如何在jMonkey 3.0中设置场景optimized节点的read/write position/rotation/scalefunction? 如果你不能回答第一个问题,你能告诉我为什么我使用优化命令时三angular形数字增加了吗? 我必须创build一个新的方法来访问graphics卡,并自己改变variables(jogl也许?)? 场景信息:16k粒子(16×16分辨率的球体)+ 1分光线(及其4096分辨率的阴影)。 我相信我们可以轻松地通过pci-express在毫秒内发送几千个浮点数。 附加信息:我使用Aparapi-kernels更新粒子位置需要10毫秒(16k * 16k交互来计算力量)(不会改变任何东西在优化模式:()可以aparapi访问这些优化的数据? 对于batchNode.batch(); 优化,这里是1 fps又减less对象数字: 对象数目现在只有几百,但fps仍然在1! 只发送球体位置到GPU,并让它计算顶点位置可能比计算CPU上的顶点,加上巨大的数据发送到CPU更好。 没有人在这里帮忙? 已经尝试过batchNode,但没有足够的帮助。 我不想改变3D API,因为JMonkey人已经改造了车轮,我很满意目前的情况。 只是试图挤一点点的performance(取消阴影提供了百分之百的速度,但质量也很重要!)。 这个Java程序将成为一个小行星撞击现场模拟器(将有select的小行星的大小,质量,速度,angular度)与行进立方体algorithm与LOD(将数百万颗粒)。 Marching-cubesalgorithm会大大减less三angular形数量。 如果你不能给出任何答案的问题,任何行军立方体(或任何O(n)凸包)algorithm的Java将被接受! 数据:x,y,zarrays为源,三angular形条阵为目标(等值面网格点) 谢谢。 以下是一些有关stream的示例(分辨率低得多): 1)由引力引起的立方体形岩体的塌陷: 2)排斥力开始显现出来: 3)排斥力+引力使组形成更加光滑的形状: 4)组形成一个球体(如预期): 5)然后,一个巨大的星体接近: 6)关于触摸: 7)影响的时刻: 在Barnes-Huttalgorithm和截断势能的帮助下,粒子数量将会增加10倍(也许是100倍)。 而不是Marching-Cubesalgorithm,包装nbody的鬼布料可以给出低分辨率的船体(比BH更容易,但需要更多的计算) 鬼布会受nbody影响(重力+排斥),但是nbody不会受到缠绕布料的影响。 Nbody不会被渲染,但布网将被渲染与较低的triange数。 如果MC或以上的工作,这将使程序渲染约200倍的粒子的包装布。