关于java3d旋转特效的信息
今天给各位分享java3d旋转特效的知识,其中也会对进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:
- 1、Java3D 想实现旋转和平移效果,不知道setRotation中的quat4f里的参数都是什么意思。
- 2、怎样在java3d里面实现 自动旋转效果?
- 3、java3D的问题…我要利用java3d绘制一个地球可以自转的动画…
- 4、一张图片可以随意360°旋转 是用什么原理?
- 5、java怎么做图片旋转3D立体效果
- 6、java怎么画出 3D 效果的图像?
Java3D 想实现旋转和平移效果,不知道setRotation中的quat4f里的参数都是什么意思。
从几何上来说,绕着哪个坐标轴转动,那个坐标就不用改变动,其他坐标会做相应改变
怎样在java3d里面实现 自动旋转效果?
查看点就是个3维向量
计算移动的时候把方向也一并计算就好了
JAVA 3D不熟悉 以前搞Direct3D的 也忘光了
java3D的问题…我要利用java3d绘制一个地球可以自转的动画…
import java.applet.Applet;
import java.awt.*;
import com.sun.j3d.utils.applet.MainFrame;
import com.sun.j3d.utils.universe.*;
import javax.media.j3d.*;
import javax.vecmath.*;
import static java.lang.Math.*;
import com.sun.j3d.utils.behaviors.mouse.*;
public class Ball11 extends Applet
{
private float vert[]=new float[30000];
private Color3f color[]=new Color3f[30000];
public BranchGroup createSceneGraph(){
BranchGroup objRoot=new BranchGroup();//分支组
BoundingSphere bounds=new BoundingSphere(new Point3d(),100.0);
Color3f bgColor=new Color3f(1.0f,1.0f,1.0f);
Background bg=new Background(bgColor);//背景颜色
bg.setApplicationBounds(bounds);//背景范围
objRoot.addChild(bg);
//添加平行光
DirectionalLight lightD1=new DirectionalLight();
lightD1.setInfluencingBounds(new BoundingSphere());
Vector3f direction=new Vector3f(2.5f,8.0f,-1.0f);
Color3f color1=new Color3f(1.0f,0.0f,0.0f);
direction.normalize();
lightD1.setDirection(direction);
lightD1.setColor(color1);
objRoot.addChild(lightD1);
//初始化
pointinit();
//添加运输组
TransformGroup trans=new TransformGroup();
trans.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
trans.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
objRoot.addChild(trans);
Shape3D shape=new Shape3D();
QuadArray qArray=new QuadArray(30000,QuadArray.COORDINATES|QuadArray.COLOR_3);
qArray.setCoordinates(0,vert);
qArray.setColors(0,color);
PolygonAttributes pa=new PolygonAttributes();
pa.setCullFace(PolygonAttributes.CULL_NONE);
shape.setGeometry(qArray);
Appearance app=new Appearance();
app.setPolygonAttributes(pa);
shape.setAppearance(app);
trans.addChild(shape);
//添加鼠标事件
MouseRotate rotate=new MouseRotate();
rotate.setTransformGroup(trans);
objRoot.addChild(rotate);
rotate.setSchedulingBounds(bounds);
MouseZoom zoom=new MouseZoom();
zoom.setTransformGroup(trans);
objRoot.addChild(zoom);
zoom.setSchedulingBounds(bounds);
MouseTranslate translate=new MouseTranslate();
translate.setTransformGroup(trans);
objRoot.addChild(translate);
translate.setSchedulingBounds(bounds);
objRoot.compile();
return objRoot;
}
public void pointinit(){
int i=0;
for(double a=0;a=2*Math.PI;a+=0.09){
for(double b=0;b=Math.PI;b+=0.1){
vert[i]=(float)Math.sin(b)*(float)cos(a);i++;
vert[i]=(float)Math.sin(a)*(float)sin(b);i++;
vert[i]=(float)Math.cos(b);i++;
vert[i]=(float)Math.sin(b)*(float)cos(a+0.1);i++;
vert[i]=(float)Math.sin(a+0.1)*(float)sin(b);i++;
vert[i]=(float)Math.cos(b+0.1);i++;
vert[i]=(float)Math.sin(b+0.1)*(float)cos(a+0.1);i++;
vert[i]=(float)Math.sin(a+0.1)*(float)sin(b+0.1);i++;
vert[i]=(float)Math.cos(b+0.1);i++;
vert[i]=(float)Math.sin(b+0.1)*(float)cos(a);i++;
vert[i]=(float)Math.sin(a)*(float)sin(b+0.1);i++;
vert[i]=(float)Math.cos(b+0.1);i++;
}
}
for(i=0;i30000;i++){
color[i]=new Color3f(0.4f,0.0f,0.5f);
}
}
public Ball11(){
setLayout(new BorderLayout());
GraphicsConfiguration config=SimpleUniverse.getPreferredConfiguration();
Canvas3D c=new Canvas3D(config);
add("Center",c);
BranchGroup scene=createSceneGraph();
SimpleUniverse u=new SimpleUniverse(c);
u.getViewingPlatform().setNominalViewingTransform();
u.addBranchGraph(scene);
}
public static void main(String[] args){
long time1=System.nanoTime();
new MainFrame(new Ball11(),400,400);
long time2=System.nanoTime();
System.out.println("用时为: "+(time2-time1)/1000000000.0 + " 秒");
}
}
一张图片可以随意360°旋转 是用什么原理?
这应该是利用3d计算机图形学做的,可以用javascript或java语言做, 用javascript的话自己要处理投影变换,很麻烦,推荐用java3d做,先用3Dmax做好模型,再用java3d,java3d可以直接加载3Dmax模型,做好的程序可以直接用applet嵌入到网页中。楼主搜下java3d吧,很好学的
jpg格式的图片可以用啊,你在3DMax里把它作为材质贴图贴到模型上。另外我估计apple 那个网站的效果是用javascript实现的,我估计他的原理是这样的:先用摄像机拍一个手机旋转360度的一个视频片段,然后把视频中的每一帧提取出来形成一个图片,在javascript检测到鼠标滑动的事件时让图片一张一张的顺序显示。这样就形成了动画
java怎么做图片旋转3D立体效果
style type="text/css"
#show{position:relative;margin:20px auto;width:800px;}
.item{position:absolute;height:40px;width:60px;background:#999999;border:1px solid #eeeeee;cursor:pointer;}/style
input id="l" type="button" value="left" / input id="r" type="button" value="right" /
div id="show"
div class="item"1/div
div class="item"2/div
div class="item"3/div
div class="item"4/div
div class="item"5/div
div class="item"6/div
div class="item"7/div
div class="item"8/div
div class="item"9/div
div class="item"0/div
div class="item"a/div
div class="item"b/div
div class="item"1/div
div class="item"2/div
div class="item"3/div
/div
script
var len;
var showerObj;
var listObj;
var showerWidth=800;
var showerHeight=400;
var r;
var cR=0;
var ccR=0;
var timer=0;
window.onload=function(){
showerObj=document.getElementById("show");
listObj=showerObj.getElementsByTagName("div");
len=listObj.length;
r=Math.PI/180*360/len;
for(var i=0;ilen;i++){
var item=listObj[i];
item.style.top=showerHeight/2+Math.sin(r*i)*showerWidth/2-20+"px";
item.style.left=showerWidth/2+Math.cos(r*i)*showerWidth/2-30+"px";
item.rotate=(r*i+2*Math.PI)%(2*Math.PI);
item.onclick=function(){
cR=Math.PI/2-this.rotate;
timer || (timer=setInterval(rotate,10));
}
}
var rX=showerObj.offsetLeft+showerWidth/2;
var ry=showerObj.offsetTop+showerHeight/2;
var rotate=function(){
ccR=(ccR+2*Math.PI)%(2*Math.PI);
if(cR-ccR0) cR=cR+2*Math.PI;
if(cR-ccRMath.PI){
ccR=ccR+(cR-ccR)/19;
}else{
ccR=ccR-(2*Math.PI+ccR-cR)/19;
}
if(Math.abs((cR+2*Math.PI)%(2*Math.PI)-(ccR+2*Math.PI)%(2*Math.PI))Math.PI/720){
ccR=cR;
clearInterval(timer);
timer=0;
}
for(var i=0;ilen;i++){
var item=listObj[i];
var w,h;
var sinR=Math.sin(r*i+ccR);
var cosR=Math.cos(r*i+ccR);
w=60+0.6*60*sinR;
h=(40+0.6*40*sinR);
item.style.cssText +=";width:"+w+"px;height:"+h+"px;top:"+parseInt(showerHeight/2+sinR*showerWidth/2/3-w/2)+"px;left:"+parseInt(showerWidth/2+cosR*showerWidth/2-h/2)+"px;z-index:"+parseInt(showerHeight/2+sinR*showerWidth/2/3-w/2)+";";
}
}
document.getElementById("l").onclick=function(){
cR=(cR+r+2*Math.PI)%(2*Math.PI);
timer || (timer=setInterval(rotate,10));
}
document.getElementById("r").onclick=function(){
cR=(cR-r+2*Math.PI)%(2*Math.PI);
timer || (timer=setInterval(rotate,10));
}
rotate();
}
/script
java怎么画出 3D 效果的图像?
可参考 孙博文 的一本书 分形算法与程序设计: Java实现 里面有3D的内容
貌似要下载 JAVA3D 的msi安装包 解压后得到jar包 JAVA 3D已经被淘汰 可能有点难找
用Java3D编程就行了 你先把那书上关于3D的代码 稍微看一下 编程的思路也就是 先建立一个场景(有光) 然后空间描点 画线 着色 之类的 可以参考具体的Java 3D 的书 貌似大多是英文的
编程也可以参考官方API文档
java3d旋转特效的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于、java3d旋转特效的信息别忘了在本站进行查找喔。
发布于:2022-11-26,除非注明,否则均为
原创文章,转载请注明出处。