![]() |
(2009-05-14 10:21:41) |
一定要等么…… |
![]() |
老鼠赛跑 (2009-05-14 10:39:24) |
package { //flash engine import flash.utils.*; import flash.display.Sprite; import flash.events.*; import flash.ui.*; //wow engine import fr.seraf.wow.primitive.*; import fr.seraf.wow.core.WOWEngine; import fr.seraf.wow.core.data.WVector; //sandy engine import sandy.core.Scene3D; import sandy.core.data.*; import sandy.core.scenegraph.*; import sandy.materials.*; import sandy.materials.attributes.*; import sandy.primitive.*; public class Example030 extends Sprite { private var wow:WOWEngine; private var sphere01:WSphere; private var bound:WBoundArea; private var sphereS:Sphere; private var cube:Box; private var scene:Scene3D; private var camera:Camera3D; public function Example030() { //create an instance of the physic engine wow=new WOWEngine(); // SELECTIVE is better for dealing with lots of little particles colliding, wow.collisionResponseMode = wow.SELECTIVE; // gravity -- particles of varying masses are affected the same wow.addMasslessForce(new WVector(0,2,0)); //create a sphere sphere01 = new WSphere(0,0,0,25,false,1,1,1); sphere01.elasticity=1; sphere01.friction=0; sphere01.py = -150; wow.addParticle(sphere01); bound = new WBoundArea(190,200,190); bound.setPosition(0,0,0); bound.elasticity=1; bound.friction=0; wow.setBoundArea(bound); // Sandy code camera = new Camera3D( 600, 600 ); camera.z = -400; var root:Group = createScene(); scene = new Scene3D( "scene", this, camera, root ); stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressedHandler); stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMovedHandler); addEventListener( Event.ENTER_FRAME, enterFrameHandler ); } private function createScene():Group { // Create the root Group var g:Group = new Group(); // Create a cube so we have something to show sphereS = new Sphere( "theSphere", 25,10,10); var materialAttr:MaterialAttributes = new MaterialAttributes( new LineAttributes( 0.5, 0x2111BB, 0.4 ), new LightAttributes( true, 0.1) ) var material:Material = new ColorMaterial( 0xFFCC33, 1, materialAttr ); material.lightingEnable = true; var app:Appearance = new Appearance( material ); sphereS.appearance = app; sphereS.useSingleContainer = false; sphereS.x = 0; sphereS.y = 150; sphereS.z = 0; // the box cube = new Box( "theBox", 200, 200, 180, PrimitiveMode.QUAD, 1 ); cube.enableBackFaceCulling = false; cube.useSingleContainer = false; // We need to add the cube to the group g.addChild( sphereS ); g.addChild(cube); return g; } private function mouseMovedHandler(event:MouseEvent):void { cube.rotateZ=(600/2-event.stageX)/15; cube.rotateX=(600/2-event.stageY)/15; bound.setRotation (-(600/2-event.stageY)/15,0,-(600/2-event.stageX)/15); } private function keyPressedHandler(event:KeyboardEvent):void { switch(event.keyCode) { case Keyboard.SPACE: sphereS.x = 0; sphereS.y = 150; sphereS.z = 0; sphere01.px = 0; sphere01.py = -150; sphere01.pz = 0; break; } } private function enterFrameHandler( event : Event ):void { //run the engine once wow.step() //get the position sphereS.x = sphere01.px; sphereS.y = -sphere01.py; sphereS.z = sphere01.pz; scene.render(); } } } |
![]() |
老鼠赛跑 (2009-05-14 10:39:46) |
更多教程 http://www.flashsandy.org/tutorials/3.0 |
![]() |
juessy (2009-05-14 11:13:37) |
楼上的一会看 自己有试了几个教程上面说的.但是都达不到我的要求 比较郁闷的是我要的功能不知道在哪啊 就是想去找API.功能说明这些. 对了上次去看http://seraf.mediabox.fr/wow-engine/as3-3d-physics-engine-wow-engine/ 貌似是var1,现在是var2的啊. 怎么回事?还是我看错了.难道这么快就升级了 ?? |
![]() |
juessy (2009-05-14 11:16:14) |
郁闷哦.没和PV3D的啊? 都是sandy 的.看了很吃力.还是先把pv3d的搞的差不多了再去看其他引擎吧 |
![]() |
juessy (2009-05-14 11:18:25) |
对了.是这样的.我这有个DAE模型 我只要弄成有重力的.和一个它做在的平面发生下落碰撞就好了 告诉我是哪些类或是那些属性方法等.如果有API的话那就最好拉~ |
![]() |
DDM君 (2009-05-14 21:36:18) |
可以用球体嘛,大概准确就行了。 |
![]() |
老鼠赛跑 (2009-05-14 21:49:20) |
sandy 和 pv3d差不多的。 |
![]() |
老鼠赛跑 (2009-05-14 22:09:33) |
jiglibflash是为Flash 3D开发的物理引擎,支援常见的3D引擎,包括PV3D、Away3D,由於写起来是直接使用3D座标,所以撰写方便,也支援不规则模形的物件,比我之前看过的WOW引擎功能多很多 |
![]() |
DDM君 (2009-05-15 17:51:47) |
对,而且jiglib的进展很快。本来我们这里的成员kevinwong君也要加入协作jiglib的开发,不过由于其刚好更换新工作很忙就搁浅了。 |
![]() |
juessy (2009-05-16 09:34:53) |
我现在就是用这个 让我郁闷的是.我在做个赛车的游戏 我写那些运动算法..在jiglib里封装了个JCar...基本把我辛辛苦苦写出来的算法都覆盖了..而且因为是做物理模型的.所以又比我写的多了很多功能.比如各个轮胎的几个摩擦系数...看的我又崩溃了... |
![]() |
juessy (2009-05-16 09:37:35) |
因为我要弄漂移效果,本来还没打算是弄像跑跑那样比较理想的 还是像极品飞车这样比较接近真实的甩尾 看到里面封装的那些参数..哎.看的我都懒的再写了..改改用吧.. |
![]() |
DDM君 (2009-05-17 09:40:01) |
呵呵,juessy很不错啊,玩漂移了~(不要在文二路撞死路人哦,不然会上新闻,呵呵,开个玩笑) 一般赛车游戏都不会用物理引擎的,甩尾等等一般都是自己写的几个主要物理算法而已。因为物理引擎不好控制。(‘侠盗猎车GTO’的车是物理引擎的,所以很难控制是否翻车,但那个主要元素也不是赛车) |
![]() |
juessy (2009-05-18 09:46:17) |
对~ 我就是想完全模仿真实效果 (翻车了减车子耐久~哈哈..然后去修理.修理一次满耐久.但减耐久上限..等等) 基本设计思路都出来了..想想就兴奋呐 .就差怎么实现了..一开始很郁闷.好多属性不熟悉,现在好多了.就是磨合磨合.一些细节要搞懂 |
![]() |
DDM君 (2009-05-18 23:10:37) |
呵呵,很棒的想法啊,已经是个完整的游戏了。 物理引擎都是靠控制外部力(force)来控制受力的物体,比较麻烦。 |
![]() |
juessy (2009-05-19 16:09:35) |
还是搞的不太懂 上面那段代码还是jiglib的一个DEMO我改了点代码来的 主要是为了实验各个参数的作用 现在还是有一大部分没弄懂 哎..慢慢磨吧 |
|
|