.Newton Wrapper for Blitz3D
Blitz3D Forums/Blitz3D Userlibs/.Newton Wrapper for Blitz3D
| ||
Version 0-9-6 is here: (320 kb) http://www.amt-lab.com/newton/newton.zip http://itmbin.nm.ru/newton/newton.zip (mirror) Features: - primitives: boxes, spheres, cylindres, cones, capsules - convex hulls of dynamic objects - concave geometry of dynamic objects (compound) - any concave geometry of static objects - blitz terrains - materials with different friction, elasticity and softness - standart joints: ball, hinge, slider, corkscrew, up-vector, plane - suspension, vehicle joints, dry-roll-friction joint - Archimed's force calculation - Magnet force - RayCast is like LinePick but more faster. - can be used as advanced collision detection library (without simulation) screen: ![]() |
| ||
This is awesome. Some of the demos (vehicles) freeze up sometimes. Is this free or just a demo for something we can purchase, like JV-ODE's demos that time out? Newton is great, Newton+B3D is fantastic. Good work. Thanks, |
| ||
Looks interesting. The '11 NewtonVehicle.bb' demo didn't respond to steering/thrust/brake input from the mouse, though. I assume this wrapper is a commercial project. How much will it cost? |
| ||
Nice demos. I'd like to add this to my collection of tools. Nice work Itmbin, how much ? |
| ||
According to their website it's USD$19.95 Not bad for a solidly implemented Physics lib. |
| ||
The forum for the wrapper is at: http://www.amt-lab.com/forum/forums.php?forum=19 The purchase link is: https://www.plimus.com/jsp/buynow.jsp?contractId=1684727 |
| ||
Yes, function phWorldStep (it provides physical simulation) is limited to 2000 calls without a license key. By entering the license key the limit will be discarded. You can acquire a license key here https://www.plimus.com/jsp/buynow.jsp?contractId=1684727 Bill Stanbrook, in this demo the vehicle is speeded up by left mouse, is handled by moving the mouse :) . Does it work? :) |
| ||
Bill Stanbrook, in this demo the vehicle is speeded up by left mouse, is handled by moving the mouse :) . Does it work? :) Yes, but it seems to chew through those 2000 calls in about 3 seconds and then it freezes up. Works fine with the licence key entered. |
| ||
What version of Newton is wrapped? Will the wrapper be updated to support future version of Newton ? Will there be a charge for wrapper updates ? thanks |
| ||
1. Newton Game Dynamics SDK 1.53 2. Of course, when a new version is released, wrapper will be recompiled (each new version usually has improvements in simulation speed). Additional features will be added as far as possible. 3. Next version of wrapper can be used with the same license key, so there will no additional charges. The NewtonSDK is based on callback functions. They are not supported by Blitz3D, so I have to change the internal interface of functions. I've decided to make it like ODE. |
| ||
phBodyGetSleep%(body%) Return sleeping state of body. If it returns 1 body is disabled (sleep), if it returns 0 body is enabled (not sleep). This function appears to be working just the opposite of what is documented ie. 0=sleep, 1=not sleep. phWorldSetSolverModel This function not documented. Just going thru it and trying stuff out, I've got camels floating in the water so I better get back to them. 8) |
| ||
I found the billiard simulation to run well on 2.4 ghz, but really slow on 1.2ghz, and was unable to get the billiard balls to sleep after adding code to enable it. I was able to speed up the simulation by repeating the worldstep line 3 times, but wondered why you used .05 time step when documentation says it will clamp at .016 ? Also can the number of contacts be set per body ? |
| ||
I coded ODE version of dominos (not fully tuned) seems to kick newtons ass. Newton has it's uses and maybe I need to learn more about how to tune Newton. Ode version: ; ############################################################################### ; # JV-ODE - Dominator # ; # Code by Jim Williams (VIP3R) , Modified by wayneg # ; # Devious Codeworks - Copyright © 2006 # ; ############################################################################### AppTitle "JV-ODE - Dominator / use mouse to push/pull" Include "JV-ODE.bb" Graphics3D 800,600,0,2 ;Graphics3D 1440,900,2 Type ODEGeom Field body Field geom Field mesh End Type Global Toggle=0 ; ################################################################################ ; ### Setup ODE Global World=dWorldCreate() Global Space=dHashSpaceCreate(0) Global ContactGroup=dJointGroupCreate(0) dWorldSetAutoDisableFlag(World,1) dWorldSetGravity(World,0,-0.98,0) dContactSetMode(dContactBounce) dContactSetBounce(0) dContactSetMu(90) ; High Performance Settings ; Causes objects to settle down and sleep faster dWorldSetAutoDisableLinearThreshold (World, .3) dWorldSetAutoDisableAngularThreshold (World, .3) dWorldSetAutoDisableSteps (World,16) dContactSetMaxContacts(8) dWorldSetQuickStepNumIterations (World,20) ; default 20 ; ### Create light Global Light=CreateLight() RotateEntity Light,45,-90,0 LightColor Light,255,255,255 AmbientLight 130,130,130 ; ### Create camera Global Camera=CreateCamera() CameraClsColor Camera,0,0,0 CameraRange Camera,1,1000 PositionEntity Camera,0,20,-50 RotateEntity Camera,30,0,0 ; ### Create plane dCreatePlane(Space,0,1,0,0) Plane=CreatePlane() EntityAlpha Plane,0.8 PlaneTexture=CreateTexture(128,128,9) ClsColor 0,200,80 Cls Color 255,255,255 Rect 0,0,64,64,1 Rect 64,64,64,64,1 CopyRect 0,0,128,128,0,0,BackBuffer(),TextureBuffer(PlaneTexture) ScaleTexture PlaneTexture,20,20 EntityTexture Plane,PlaneTexture,0,0 Mirror=CreateMirror() addobject() ; ################################################################################################### While Not KeyHit(1) ; Calculate Time If T=0 Then T=MilliSecs() T=MilliSecs() ; Run Physics every 20ms ( APROX 50/sec ) If T > Time3 + 20 Then Time3=T UpdateKeys() PTime=MilliSecs() UpdateGeoms() For i=1 To 2 dSpaceCollide(Space,World,ContactGroup) dWorldQuickStep(World,.2) dJointGroupEmpty(ContactGroup) Next PhysicsTime#=MilliSecs()-PTime End If RenderWorld Text 0,0,"JV-ODE Version "+dGetVersion() Text 0,15,"Physics Time:"+PhysicsTime Flip Wend dJointGroupDestroy(ContactGroup) dSpaceDestroy(Space) dWorldDestroy(World) dCloseODE() End ; ################################################################################################### Function UpdateKeys() If MouseDown(1)=1 CameraPick(Camera,MouseX(),MouseY()) If PickedEntity() For ode.ODEGeom=Each ODEGeom If ode\mesh=PickedEntity() dBodyEnable(ode\body) dBodyAddForce ode\body,-200*PickedNX#(),-200*PickedNY#(),-200*PickedNZ#() End If Next End If End If If MouseDown(2)=1 CameraPick(Camera,MouseX(),MouseY()) If PickedEntity() For ode.ODEGeom=Each ODEGeom If ode\mesh=PickedEntity() dBodyEnable(ode\body) dBodyAddForce ode\body,200*PickedNX#(),200*PickedNY#(),200*PickedNZ#() End If Next End If End If End Function ; ################################################################################################### Function AddObject() For i=1 To 200 radius# = 10+i/10.0 ugol# = ugol# + 120.0/radius xp# = radius*Sin(ugol) zp# = radius*Cos(ugol) ode.ODEGeom=New ODEGeom ode\body=dBodyCreate(World) dBodySetRotation(ode\body,0,120-ugol,0) dBodySetPosition(ode\body,xp,1.6,zp) dBodySetAutoDisableFlag(ode\body,1) ode\geom=dCreateBox(Space,1.5,3,.7) dGeomSetBody(ode\geom,ode\body) ode\mesh=CreateCube() ScaleMesh ode\mesh,1.5*.5,3*.5,.7*.5 EntityColor ode\mesh,Rand(255),Rand(255),Rand(255) EntityAlpha ode\mesh,1 EntityShininess ode\mesh,0.7 EntityPickMode ode\mesh,2 mass=dMassCreate() dMassSetBoxTotal(mass,300,1.5,3,.7) dBodySetMass(ode\body,mass) dMassDestroy(mass) Next End Function ; ################################################################################################### Function UpdateGeoms() For ode.ODEGeom=Each ODEGeom If dBodyIsEnabled(ode\body) RotateEntity ode\mesh,dGeomGetPitch#(ode\geom),dGeomGetYaw#(ode\geom),dGeomGetRoll#(ode\geom) PositionEntity ode\mesh,dGeomGetPositionX#(ode\geom),dGeomGetPositionY#(ode\geom),dGeomGetPositionZ#(ode\geom) Else dGeomContactSetMu(ode\geom,20) End If Next End Function ; ################################################################################################### |
| ||
phBodyGetSleep%(body%) - fixed. You're right, i've mixed up it. phWorldSetSolverModel, phWorldSetFrictionModel and phWorldMagnetize were added to help. phWorldSetSolverModel(model%) Set solver model of simulation. - model=0 is the exact mode. This is good for application where precision is more important than speed, ex: realistic simulation. - model=1 is the adaptive mode, the solver is not as exact but the simulation will still maintain a high degree of accuracy. This mode is good for applications were a good degree of stability is important but not as important as speed. - Model>=2 is the Linear mode. The solver will not try to reduce the joints relative acceleration errors to below some limit, instead it will perform up to n passes over the joint configuration each time reducing the acceleration error, but it will terminate when the number of passes is exhausted regardless of the error magnitude. In general this is the fastest mode and is is good for applications where speed is the only important factor, ex: video games. phWorldSetFrictionModel(model%) Set friction model of simulation. - model = 0 is the exact model. Friction forces are calculated in each frame. This model is good for applications where precision is more important than speed, ex: realistic simulation. - model = 1 is the adaptive model. Here values from previous frames are used to determine the maximum friction values of the current frame. This is about 10% faster than the exact model however it may introduce strange friction behaviors. For example a bouncing object tumbling down a ramp will act as a friction less object because the contacts do not have continuity. In general each time a new contact is generated the friction value is zero, only if the contact persist a non zero friction values is used. The second effect is that if a normal force is very strong, and if the contact is suddenly destroyed, a very strong friction force will be generated at the contact point making the object react in a non-familiar way. phWorldMagnetize(x#,y#,z#,r#,a0#,a1#,a2#,max#) Add magnet force to the bodies in the world. The magnet is at point (x#,y#,z#), the maximum distance of magnet force is r#, the force is equal to f# = a0# + a1#/dist + a2#/dist/dist (dist is the distance between magnet and the body) and limited to max# value. About large timestep (0.05). I've used it to be sure of maximum timestep :) "Also can the number of contacts be set per body ?" - What contacts do you mean? The number of collision contacts can only be readed from the engine and can't be set. About domino. Your ODE-code takes about 2-5 ms, Newton code takes about 1-10 ms. And I must notice that Newton solver becames a bit slower when there is a large island in the scene. Island is the group of connected bodies. So 4 towers of 5 cubes are faster that 2 towers of 10 cubes. It is newton weakness and I can't do anything in the wrapper. |
| ||
Thanks for the response and information Itmbin. Always good to get feedback from the wrapper builder. 8) Newton makes the water simulation easy. The boat has a nice feel to it, but I keep wanting to go over land, I don't know why I do that. I dunked the camels and they responded like I expected, fun. I still can't believe the smoke going around the lumber, perhaps a house fire simulator for the pyro's out there? hehe I liked the way you wrapped the primitives. It simplifies building and visualization, I think ODE wrapper should copy this feature. You've made Newton really easy for ODE users to test the waters. Ball joint cloth, hehe I'm almost ready to give you $20 for all these wonderful sample programs I get to play with. I do wish the simulation would run just a bit longer like 2 or 3 times. I'm still playing with the Newton, and really enjoy all the examples I've tried, Nice work Itmbin! |
| ||
Great work! Spring Suspension Vehicle I can't find this joints documentation |
| ||
You're welcome :) Lyon, they will be added to the documentation soon. |
| ||
Aren't these the same guys that tried to rip off Blitz3d as their own product? |
| ||
Chroma, hmm, no... 2All: There are some videos on YouTube http://youtube.com/watch?v=X60qWijyKfY http://youtube.com/watch?v=CZxRkytlnq0 http://youtube.com/watch?v=3wewtI4CZEk http://youtube.com/watch?v=rFl5dslWNSo showing epimeison's fps demo based on newton. |
| ||
some of filax easytok example looks better |
| ||
The ease of coding shown in the examples makes this a very attractive library. The results are excellent, and fully featured as far as I can see. Excellent work! |
| ||
Ragdoll demo? |
| ||
Yeah :) http://amt-lab.com/forum/topic.php?forum=19&topic=2 Here is the ragdoll demo with the model of QuickSilver. Screen: ![]() Direct link: http://itmbin.nm.ru/newton/ragdoll.zip |
| ||
Why i can't paid via paypal ? |
| ||
i checked that. what you do, itmbin is illegal. you're breaking the law! the original newton engine is open source, and if you are selling a wrapper, it is against the law! are you actually thinking when you are doing things? |
| ||
Ha-ha-ha :) The Newton creators realy forbid to do the wrapper? Realy will not sell Newton, he will sell only its wrapper! You foolish or envy - one of two things. p.s. If you has done wrapper and has spent half of the year of its time... You has wanted to get for its labour payment? |
| ||
What? Wait a second, are you sure about that Devils Child? Isn't ODE also an open source project? Does that mean JVODE is also illegal? I think you must be mistaken. You're most likely forbidden from redistributing the original library as your own work. But a wrapper is a significant piece of work in its own right, and I do believe it's legal to charge for that. I would rather make a nominal payment to help Itmbin pay the rent so he can spend more time supporting this library, than demand everything be freeware. |
| ||
This is a great wrapper and well worth the price he charged for his labor. Yes if it is illegal to make a wrapper for newton and ode then there a several people that may be in the wrong because their a several wrappers for different engine. |
| ||
Newton is outstanding, and this wrapper and the examples are very well done. This gives us B3d users another quality physics engine to choose from. I use JV-ODE currently, but can easily see myself using Newton for some of my simulations. I really like how easily it handles water. I wish the demo ran longer so I could play more with it, but that aside it's great. I'd buy it today, but I'm looking at buying BMAX, 3D World Studio, Gile, and a few others. Great job ItmBin, you do quality work, and above all you finish the job. -Future Customer |
| ||
Itmbin, is there like a module so this can be useds with Blitzmax? |
| ||
http://www.newtondynamics.com/SDKLicense.html http://www.ode.org/ode-license.html |
| ||
Cool, another one. No im really off-track. Someone make a comparison chart. |
| ||
I reccomend this wrapper alot, is very easy to use. Speedwise, i can't compare it as i have done no tests. |
| ||
From the Newton License "4) The LICENSEE may not redistribute the SOFTWARE, except as part of a compiled software program that is not itself a physics library." This basically means that if you have made a game or some kind of tool(not a physicslib) that utilize the Newton API, you may distribute the Newton.dll or statically link to it. However the wrapper combined with the newton API can be considered a physics library thus violating the license. So the only valid option(AFAIK) is to distribute the wrapper alone and let the developers download the Newton API themselves. To make this possible I'm afraid statically linking to the Newton API is not allowed. |
| ||
Sweenie I just went to your site and IE popped up a message saying it was trying to 'access information not under its control'. Shortly thereafter I get an alert saying that 'ie_updater1.exe' is trying to access the internet!(from my documents and settings folder). Know anything about that? |
| ||
If you mean the freewebs site I'm actually amazed that it's still up and running. If haven't done anything to it since the last newspost(june 2004 something) I'm gonna try to shut it down because the alert you described sounds suspicous and the wrappers on the site are very outdated anyway. [EDIT] There, it's done. If you still interested in Tokamak check the bottom of this thread... http://www.blitzbasic.com/Community/posts.php?topic=36626 |
| ||
Cool. |
| ||
Getting back to Newton. I'm finding that occasionally raycast fails even though the ray is definitely intersecting pickable geometry. There's no pattern to it but that the terrain mesh is relatively large (can be up to 4096 x 4096), although the polys are not that big in themselves. The solution is to repick with slightly offset co-ords, which seems to work, but is this just a fact of life with raycasting systems that they occasionally fail on larger meshes? |
| ||
but is this just a fact of life with raycasting systems that they occasionally fail on larger meshes A good raycasting routine should never fail like that, unless there is something wrong with the geometry. One thing I noticed when i was fiddling with a raycast-routine in c++ was that if I enabled too many optimizing flags the precision of the raycast got worse. Raycasting involves alot of precise math and taking shortcuts when doing floatingpoint calculations isn't a good idea. Anyway, maybe it's not the issue here but keep in mind that raycasts won't go further than the Newtonworld's bounds. If your mesh is 4096x4096 are the bounds set to the same? |
| ||
See for yorself! who is who! here are some tests I've made: PhysX vs Newton vs ODE http://www.blitzbasic.com/Community/posts.php?topic=68966 |
| ||
The ONLY way for a newbee to choose a physic engine is.... EXAMPLES EXAMPLES AND EXAMPLES. Documentation and support are "welcomes" too. ;-) ;-) JP |
| ||
you posted that in 2 other topics. whats the point? (p.s. you did not yet post in the Tomak topic.) |
| ||
"you posted that in 2 other topics. whats the point?". You to. And..... Ho! Agent_J. ;-) |
| ||
'A good raycasting routine should never fail like that, unless there is something wrong with the geometry.' I suspect what's going on is that my terrain geometry is exported with the vertices unwelded and just occasionally the (vertical) raycast intersects exactly at the join between two polys. If I offset the x/z co-ords just slightly, I then get a result. |
| ||
QUOTE - Lyon (Posted 6 months ago) "Great work! Spring Suspension Vehicle I can't find this joints documentation" QUOTE - Itmbin (Posted 6 months ago) "You're welcome :) Lyon, they will be added to the documentation soon. " ItmBin, are we still going to get an updated help doc that adds the joint information Lyon is talking about? Thanks for any help there! |
| ||
Hi, I've purchased Newton from the purchase link already. I tested Newton & key with B3D it worked fine, but when I tried to tested it with VC++ Newton stop working after 2,000 calls. I used ZJP's .cpp and sample file. Anything you guys can help me out? Thank you, |
| ||
Works well with my license Key. Compiled with DevCPP MAybe a PB with VC++. I'M not a C/C++ guru, but, try this modification in the include file char *license_key >> const char *license_key typedef void(WINAPI *DLL_phWorldCreate)(int plane, const char *license_key); Keep me in the loop ;-) |
| ||
ZJP, I got the solution. My key contain \ back slash, which C specially take care of it. So, I make it \\ double. then the problem gone. Would you kindly put a comment in your code? to help others avoid this problem. BTW, I love you work and things you contributed to this community. Cheers, |
| ||
"My key contain \ back slash, which C specially take care of it. So, I make it \\ double. then the problem gone...." This is my second solution/option... ;-) "Would you kindly put a comment in your code?" A sort of "Do not forget to double the '\' if is present in the licence key string.." Help need here. Remenber, i'm a french people. JP Edit : Code archive updated. Thx |
| ||
hehehe, still no updates to the docs for the joints mentioned by Lyon? |
| ||
Yes a doc update will be sweet :) |
| ||
huh? what happened to http://www.amt-lab.com/ ?? |
| ||
. |
| ||
The lab was encountering some problem of chemical explosion, all the scientists die, some experimental animals mutated to be extremely destructive. Those mutated animals was destroying the earth, like the wildfire in Californaia and El Nino etc. No on ever know things gone so wrong till now. |
| ||
Anyone have any updated info on this? I would love to pick up this lib but alas... |
| ||
What info are you after, stayne? You can download the lib from:- http://itmbin.nm.ru/newton/newton.zip Just look for the 'newton.zip' link near the top of the page. The zip file contains fairly comprehensive demos and a help file which show how to use the wrapper. You can buy a key to unlock the lib from:- https://www.plimus.com/jsp/buynow.jsp?contractId=1684727 Add the key into the second parameter of the command, phWorldCreate(True,"your license key"). |
| ||
Thanks Bill. A bit ago I downloaded the lib, made the purchase and got my key. I entered the key as you described and the lib still locks up at 2000 steps. I even tried the key with the demos. Very strange. ps: no there aren't any \'s in the key I received. |
| ||
Stayne, I tried using my key with the download available from http://itmbin.nm.ru/newton/newton.zip and didn't get any lockup at the expected point with the boat.bb demo with the key in place, so presumably the issue you're having is with the key rather than the download. I'd suggest you double check that you copy-pasted the key correctly. If you can't find an error there, then your best bet is probably to try contacting Itmbin at the email address supplied in the purchase email from Plimus. The address I have for him is sg0@... (you will need to be logged in to see the email address properly). If you can't get in touch with Itmbin, try contacting Plimus for a new working key, or failing that, a refund. |
| ||
Yes it must be the key and I've emailed Itmbin about it. Thanks a bunch for the assistance Bill. |
| ||
Sussed. A question mark wasn't copying/pasting. Dang that long reg key :). |
| ||
Supeb Work I tried your wrapper, work well Here a piece of code Blitz3D - Newton with Waypoint and smooth turning I put my code. If you want you can add and distribute the following code into your Wrapper sample codes. My negative point is your missing doc about your wrapper function. Sincerely Patmaba Include "newton.bb" ; Author : patmaba ; email : patmaba@... ; date : 2010 Jul 19 Const k_APP_NAME$ = "Blitz3d And Newton Physic Engine : Example Follow Waypoint Smoothly" Const K_SCRWIDTH=800 Const K_SCRHEIGHT=600 Const K_MAX_WAYPOINT = 6 Global g_TCAR_TEMPLATE = 0 Global g_Cam = 0 Global g_TCar_Player.TCar = Null Global g_bWireFrame = False Dim gd_wp(K_MAX_WAYPOINT) ; waitpoint App_Init() App_Main() App_End() End ; main loop Function App_Main() While Not(KeyHit(1)) ; update physics by 0.01 second phWorldStep(0.01) TCar_Update() RenderWorld Color 255,255,255 Text 1,1, "WireFrame( 'W' ) RenderContacts( g_TCar_Player\body , 255,0,0,g_Cam) Color 255,255,255 For i=0 To K_MAX_WAYPOINT-1 If EntityInView( gd_wp(i), g_Cam ) CameraProject g_Cam,EntityX(gd_wp(i)),EntityY(gd_wp(i)),EntityZ(gd_wp(i)) Text ProjectedX()-22, ProjectedY()+10, EntityName(gd_wp(i)) EndIf Next Color 255,255,255 CameraProject g_Cam,EntityX(g_TCar_Player\entity),EntityY(g_TCar_Player\entity),EntityZ(g_TCar_Player\entity) Text ProjectedX()-25, ProjectedY()+25, "Player" If KeyHit(44) Or KeyHit(17) Then g_bWireFrame = 1-g_bWireFrame WireFrame g_bWireFrame EndIf Flip Wend End Function Function App_End() TCar_DeleteAll() ClearWorld True,True,True EndGraphics End Function Function App_Init() ; Initialize Graphics And window title Graphics3D K_SCRWIDTH,K_SCRHEIGHT,16,2 AppTitle k_APP_NAME$ SeedRnd MilliSecs() ; Create camera and position it Local cam = CreateCamera() PositionEntity cam,0,3,-10 ; Initialize physics ;<NWT> phWorldCreate(True,"your license key") ;<NWT> ; if parameter is set to True, a horizontal plane at (0,0,0) will be created phWorldSetGravity(0,-40,0) ;<NWT> ; Create plane and texturize it Local plane = CreatePlane() EntityColor plane,50,200,255 ; Create texture of size 256x256 Local tex=CreateTexture( 256,256 ) ; Set buffer - texture buffer SetBuffer TextureBuffer( tex ) ; Clear texture buffer with background white color ClsColor 255,255,0 Cls Color 0,0,0 Rect 10,10,236,236 EntityTexture plane,tex FreeTexture tex SetBuffer FrontBuffer() ; Create light and rotate it Local light = CreateLight(1) RotateEntity light,20,30,40 AmbientLight 255,255,255 g_TCAR_TEMPLATE = TCar_MeshTemplate() g_TCar_Player = TCar_Create( 0,0,-15, 0, 0, 0 ) EntityColor g_TCar_Player\entity,255,255,250 phBodySetMass( g_TCar_Player\body, 1000 );<NWT> For i=0 To K_MAX_WAYPOINT-1 gd_wp(i) = CreateSphere(12) ScaleEntity gd_wp(i), 2,2,2 EntityColor gd_wp(i), 255,0,0 EntityAlpha gd_wp(i),0.5 NameEntity gd_wp(i), "WayPoint " + i Next PositionEntity gd_wp(0), 0,1,0 PositionEntity gd_wp(1),-10,1,15 PositionEntity gd_wp(2), 0,1,30 PositionEntity gd_wp(3), 30,1,0 PositionEntity gd_wp(4), 15,1,45 PositionEntity gd_wp(5), 30,1,30 ; Buil 50 random wall Local c.phx=Null Local x#,y#,z#,yaw#,n For n=0 To 100 c = phxCreateBox( 1,1,1,10) x#=Rand(-15,45) : y#=10 : z#=Rand(-15,45) yaw#=Rnd(0,360) PositionEntity (c\mesh,x#, y#, z#) RotateEntity (c\mesh,yaw#, yaw#, yaw#) EntityColor( c\mesh, Rand(0,255),Rand(0,255),Rand(0,255) ) ScaleMesh c\mesh, Rand(1,2), Rand(1,2), Rand(1,2) phBodySetEntity(c\body,c\mesh);<NWT> phBodySetPos(c\body,x#, y#, z#);<NWT> ; body,x#,y#,z# phBodySetRot(c\body,0,yaw#,0);<NWT> ; body,pitch#,yaw#,roll# phBodySetMass( c\body, 100 );<NWT> Next g_Cam = cam End Function Type TCar Field entity Field body Field CurrentWpIndex End Type Function TCar_MeshTemplate() ; Build a car Template Local l_MDL = CreateCube() HideEntity(l_MDL) ScaleMesh (l_MDL,1,.35,2) PositionMesh (l_MDL,0,.5,0) Local cabine%=CreateCube() ScaleMesh (cabine,.9,.5,1) PositionMesh (cabine,0,1,-.3) AddMesh (cabine,l_MDL) FreeEntity (cabine) Return l_MDL End Function Function TCar_Create.TCar( pX#=0, pY#=0, pZ#=0, pPitch#=0,pYaw#=0,pRoll#=0 ) Local o.TCar = New TCar o\entity = CopyEntity(g_TCAR_TEMPLATE) o\body = BodyCreateHull(o\entity,1);<NWT> o\CurrentWpIndex=0 ; Set the position of the body phBodySetPos(o\body,pX#, pY#, pZ#) ; body,x#,y#,z# ; Set the rotation of the body phBodySetRot(o\body,pPitch#,pYaw#,pRoll#);<NWT> ; body,pitch#,yaw#,roll# EntityColor o\entity, Rnd(0,255), Rnd(0,255), Rnd(0,255) phBodySetMass( o\body, 10000 );<NWT> Return o End Function Function TCar_DeleteAll() Local c.TCar = Null For c.TCar = Each TCar TCar_Delete( c ) Next End Function Function TCar_Delete( c.TCar ) phBodyDestroy(c\body) FreeEntity c\entity Delete c End Function Function TCar_Position( c.TCar) ; Set the position of the body PositionEntity c\entity,phBodyGetX(c\body),phBodyGetY(c\body),phBodyGetZ(c\body) End Function Function TCar_Rotate( c.TCar) ; Set the rotation of the body RotateEntity c\entity, phBodyGetPitch(c\body),phBodyGetYaw(c\body),phBodyGetRoll(c\body) End Function Function TCar_Update() TCar_FollowWayPoint( g_TCar_Player ) Cam_3rd_Pers( g_TCar_Player ) End Function Function SmoothPoint(source%,dest%,rate#=1) Dx#=EntityX(dest,1)-EntityX(source,1) Dy#=EntityY(dest,1)-EntityY(source,1) Dz#=EntityZ(dest,1)-EntityZ(source,1) AlignToVector source,dx#,dy#,dz#,3,rate End Function Function TCar_FollowWayPoint( c.TCar ) If EntityDistance( gd_wp( c\CurrentWpIndex), c\entity ) < 2 Then c\CurrentWpIndex = c\CurrentWpIndex + 1; If c\CurrentWpIndex > K_MAX_WAYPOINT-1 Then c\CurrentWpIndex = 0 EndIf TCar_SmoothMoveToWayPoint( c.TCar,0,0,15,0.03 ) ; Apply Physics Position and rotation To Blitz Entity TCar_Position( c) TCar_Rotate( c ) End Function Function TCar_SmoothMoveToWayPoint( c.TCar, pf_Mvx#=0.0, pf_Mvy#=0.0, pf_Mvz#=0.0, pf_Rate#=1.0 ) SmoothPoint(c\entity, gd_wp( c\CurrentWpIndex),pf_Rate#) ;PointEntity c\entity, gd_wp( c\CurrentWpIndex) Local oldx#=EntityX(c\entity) Local oldy#=EntityY(c\entity) Local oldz#=EntityZ(c\entity) MoveEntity c\entity, pf_Mvx#, pf_Mvy#, pf_Mvz# Local newx#=EntityX(c\entity) Local newy#=EntityY(c\entity) Local newz#=EntityZ(c\entity) Local vx#=newx#-oldx# Local vy#=newy#-oldy# Local vz#=newz#-oldz# phBodySetVel( c\body, vx# , vy#, vz# ) Local p=0 Local yw=EntityYaw(g_TCar_Player\entity,True) Local r=0 phBodySetRot(g_TCar_Player\body,p, yw, r ) End Function Function Cam_3rd_Pers( c.TCar ) TFormPoint 0,4,-10,c\entity,0 Local dx#, dy#, dz# dx#=(TFormedX()-EntityX(g_Cam))*.1 dy#=(TFormedY()-EntityY(g_Cam))*.1 dz#=(TFormedZ()-EntityZ(g_Cam))*.1 TranslateEntity g_Cam,dx,dy,dz PointEntity g_Cam,c\entity End Function Function RenderContacts(body,r%,g%,b%,cam) Local ncoll = phBodyGetCollNum(body) Local i,x#,y#,z#,sx#,sy#,sx2#,sy2# For i = 0 To ncoll-1 Color r,g,b x# = phBodyGetCollX(body,i) y# = phBodyGetCollY(body,i) z# = phBodyGetCollZ(body,i) If y# > 0.0 CameraProject cam,x,y,z sx# =ProjectedX():sy# =ProjectedY() Oval sx-2,sy-2,4,4 x# = x# + phBodyGetCollNX(body,i) y# = y# + phBodyGetCollNY(body,i) z# = z# + phBodyGetCollNZ(body,i) CameraProject cam,x,y,z sx2# =ProjectedX():sy2# =ProjectedY() Line sx,sy,sx2,sy2 Color 255,255,255 EndIf Next End Function |
| ||
Cool, I'm using newton too but the support is weak enough |
| ||
The zip provide a lib file newton.bb I have had for me 2 essential functions. The wrapper newton forum is dead. So, I put my 2 new function into newton.bb here. ;================================================================================================ ;Name: phSetMeshByBody( p_iMesh, p_iBody, p_bGlobal ) ;Parameters : ;p_iMesh - Handle of Blitz3d mesh to be positionned and rotated ;p_iBody - Handle of Newton Physic Engine use for applying position and rotation on Blitz3d Mesh ;p_bGlobal (optional) - True If the position should be relative To 0,0,0 rather ; than a parent entity's position. False by Default. ; ;Description ; Apply newton physics body positions and rotation on Blitz3d mesh. ; ;version date who what ;------- ---------- ------------- -------------------------------------------------------- ; 1.0 2010/07/29 patmaba creation ;================================================================================================ Function phSetMeshByBody( p_iMesh, p_iBody, p_bGlobal=False ) ; Set mesh position Local l_fx#=phBodyGetX(p_iBody) Local l_fy#=phBodyGetY(p_iBody) Local l_fz#=phBodyGetZ(p_iBody) PositionEntity p_iMesh, l_fx#, l_fy#, l_fz#, p_bGlobal ; Set mesh rotation Local l_fPitch#=phBodyGetPitch(p_iBody) Local l_fYaw#=phBodyGetYaw(p_iBody) Local l_fRoll#=phBodyGetRoll(p_iBody) RotateEntity p_iMesh, l_fPitch#, l_fYaw#, l_fRoll#, p_bGlobal End Function ;================================================================================================ ;Name: phSetBodyByMesh( p_iBody, p_iMesh, p_bGlobal ) ; ;Parameters : ;p_iBody - Handle of Newton Physic Engine use for applying position and rotation on Blitz3d Mesh ;p_iMesh - Handle of Blitz3d mesh to be positionned and rotated ;p_bGlobal (optional) - True For Global coordinates, False For Local. Optional, defaults To False. ; ;Description ; Apply Blitz3d mesh positions and rotation on newton physics body. ; ; If the Global flag is set To False Then the parent's Local coordinate system is used. ; NOTE: If the entity has no parent Then Local and Global coordinates are the same. ; In this Case you can think of the 3d world as the parent. ; ;version date who what ;------- ---------- ------------- -------------------------------------------------------- ; 1.0 2010/07/29 patmaba creation ;================================================================================================ Function phSetBodyByMesh( p_iBody, p_iMesh, p_bGlobal=True ) ; Set body position Local l_fx#=EntityX(p_iMesh,p_bGlobal) Local l_fy#=EntityY(p_iMesh,p_bGlobal) Local l_fz#=EntityZ(p_iMesh,p_bGlobal) phBodySetPos(p_iBody, l_fx#, l_fy#, l_fz#) ; Set body rotation Local l_fPitch#=EntityPitch(p_iMesh,p_bGlobal) Local l_fYaw#=EntityYaw(p_iMesh,p_bGlobal) Local l_fRoll#=EntityRoll(p_iMesh,p_bGlobal) phBodySetRot(p_iBody, l_fPitch#, l_fYaw#, l_fRoll#) End Function patmaba |
| ||
Would be grateful if someone would email me the zip. I have a license key, just no files (both links are now dead). Thanks. |
| ||
I've mailed you the zip, stayne. If you don't receive it, then let me know and I'll re-send it. |
| ||
Got it thanks a ton Bill. |
| ||
No worries. ;-) |
| ||
Can I too have the zip, Bill? Plz & thx. :) As a matter of fact, can you please post it up on the forums as an upload so everyone who needs it can download it? Thank you! :) |
| ||
Is there an active download link for newton anywhere? |
| ||
Here : http://www.filesonic.com/file/xHYsOSZ/newton.zip |
| ||
Zethrax, would you mind mailing me the link thing too? Last edited 2012 |
| ||
where link? |