Hi Michael
good news that you want to update to newton dynamics v3.1 and to add more functions
my wish if it is possible in newton dynamics to implement Gears, so the teeth of every one can go inside the other like the old clock, it is not possible to do this in bullet physics used in purebasic engine unless we choose its preperty as static and we want the gear to be dynamic. look here for the gear in ogre bullet, it is impossible to go inside between two tooths.

so since you are going to newton dynamics 3.1 in the future, if you can make the 2 Gears tangled and the second gear rotate by the effect of the first gear, then will be great. there is one thread in newton dynamics forum
http://newtondynamics.com/forum/viewtop ... ars#p50537 in which someone was trying to simulate gears and he ask what collision hull should he use for this purpose? and someone replied him: You want a
compound collider -->
http://newtondynamics.com/wiki/index.ph ... s#Compound
so if you can implement that
compound collider then may be we can make Gears
the following is a Gear 3D for MP3D based on a formula from matheworld
http://mathworld.wolfram.com/GearCurve.html
it is useless in the context of my wish , i just want to celebrate your good news about newton 3.1 . use arrow keys and space to rotate.
save this texture to the same folder as the code
Code: Select all
#BUTTON = 6
Quit.b = #False
rot.l=1 :stopFlag = 1 : wireFrame.b = 0
xs.f = 1:ys.f = 1:zs.f = 1
x.f: y.f :z.f: x0.f: y0.f=1 :z0.f
rotx.f:roty.f=0.5:rotz.f :rotx0.f: roty0.f: rotz0.f
up.f = 1.8: depth.f=0
ExamineDesktops()
MP_Graphics3D (DesktopWidth(0),DesktopHeight(0),0,2) ; Erstelle ein WindowsFenster #Window = 0
SetWindowTitle(0, "PgUp PgD scale mesh..Arrows for rotation, space: stop/rotate, QA far/near, key_pad R/L/U/D")
MP_DrawText (1,1,"press W _wireFrame, D _ delete triangles")
ButtonGadget(#BUTTON, 0, DesktopHeight(0)-60, 60, 30, "rotate/stop")
MP_Viewport(0,0,DesktopWidth(0),DesktopHeight(0)-60)
light=MP_CreateLight(1)
MP_PositionEntity (light,-6,0,0)
MP_EntityLookAt(light,0,0,3)
MP_LightSetColor(light,RGB(255,255,255))
InitKeyboard()
camera=MP_CreateCamera() ; Kamera erstellen
MP_PositionCamera(camera, 0, 0.5, -10)
Mesh = MP_CreateMesh() ; Erzeuge leeres Mesh
SetActiveGadget(#BUTTON)
;WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
x.f: y.f :z.f : u.f: r.f
i.l: j.l
u.f=0 :txu.f : txv.f
;;;;;;;
x.f: y.f :z.f : u.f=0 :txu.f : txv.f
rMajor.f = 2 : rMinor.f = 0.5
majorRadius.f = 2: minorRadius.f = 1.5: numMajor.l = 50: numMinor.l = 25
majorStep.f = 2 * #PI / (numMajor+0);
minorStep.f = 2 * #PI / (numMinor+0)
i.l: j.l
x.f: y.f :z.f :r.f :t.f
a.f=1:b.f=10:
For i = 0 To numMajor
t.f = i * majorStep;
For j = 0 To numMinor
r = 1+1/b*TanH(b*Sin(12*t))
u.f = j * minorStep;
x = r*Cos(t) * (majorRadius + minorRadius * Cos(u))
y = r*Sin(t) * (majorRadius + minorRadius * Cos(u))
z.f = minorRadius * Sin(u)
tt+1
MP_AddVertex (Mesh, x, y,z,0,txu,txv)
txv = txv + 1/numMinor ; texture coordinates
Next
txv = 0
txu = txu + 1/numMajor ;texture coordinates
Next
v.l=0
;;;;;ppppppppppppppppppppppppppppppppppppppppppppppppppppppp
For i = 0 To numMajor
For j = 0 To numMinor-1
MP_AddTriangle(Mesh,v,v+1,v + numMinor+1)
MP_AddTriangle(Mesh,v + numMinor+1,v + numMinor+2,v+1 )
If i=numMajor-1 And j=numMinor-1 ;bypass the last triangle
EndIf
v + 1
Next
Next
;ppppppppppppppppppppppppppppppppppppppppppppppppppppppppppp
;last vertex to connect:
lastV = (numMinor+1)*(numMajor+1)-1-(numMinor+1)
s = lastv - numMinor
For v = 0 To numMinor
MP_AddTriangle(Mesh,s,s+1, v)
MP_AddTriangle(Mesh,v,v+1,s+1 )
If i=numMajor-1 And j=numMinor-1 ;bypass the last triangle
;numMinor-1
EndIf
s+1
Next
MP_EntitySetNormals(Mesh)
;WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
Texture = MP_LoadTexture("Rusty_Steel.jpg")
MP_EntitySetTexture (Mesh, Texture )
MP_MaterialEmissiveColor (Texture,0,255,255,255)
MP_PositionEntity (Mesh,0,0.1,3) ; Position des Meshs
h.f=0:up.f=0.1:depth.f=3
x=90: y=0: z=0 :indx = 126
Repeat
Event = WindowEvent()
If Event = #PB_Event_Gadget
Select EventGadget()
Case #BUTTON
If rot = 0
rot = 1
rotx= rotx0:roty=roty0:rotz=rotz0 ; restore rotation status
stopFlag = 1
Else
rot = 0
rotx0= rotx:roty0=roty:rotz0=rotz ;back up rotation status
rotx=0:roty=0:rotz=0
stopFlag = 0
EndIf
EndSelect
EndIf
If stopFlag=1
x + rotx
y + roty
z + rotz
EndIf
MP_DrawText (1,1,"press W _wireFrame, D _ delete triangles")
MP_DrawText (1,15,"keyPad keys: up.down.left.right")
MP_RotateEntity(Mesh, x, y, z)
MP_RenderWorld() ; Erstelle die Welt
MP_Flip ()
If MP_KeyDown(#PB_Key_Up) ; rotate left
rotx=1:roty=0:rotz=0
rotx0 = rotx: roty0 = roty :rotz0 = rotz
x + rotx
y + roty
z + rotz
stopFlag=0
rot = 0
ElseIf MP_KeyDown(#PB_Key_Down) ; rotate right
rotx=-1:roty=0:rotz=0
rotx0 = rotx: roty0 = roty :rotz0 = rotz
x + rotx
y + roty
z + rotz
stopFlag=0
rot = 0
ElseIf MP_KeyDown(#PB_Key_Right) ; rotate up
rotx=0:roty=1:rotz=0
rotx0 = rotx: roty0 = roty :rotz0 = rotz
x + rotx
y + roty
z + rotz
stopFlag=0
rot = 0
ElseIf MP_KeyDown(#PB_Key_Left) ; rotate down
rotx=0:roty=-1:rotz=0
rotx0 = rotx: roty0 = roty :rotz0 = rotz
x + rotx
y + roty
z + rotz
stopFlag=0
rot = 0
EndIf
If MP_KeyDown(#PB_Key_PageUp) ; scale up model
xs.f + 0.01:ys.f + 0.01:zs.f + 0.01
MP_ScaleEntity(Mesh,xs,ys,zs)
ElseIf MP_KeyDown(#PB_Key_PageDown) ; scale down model
xs -0.01:ys -0.01:zs- 0.01
If xs<0 :xs=0:ys=0:zs=0:EndIf
MP_ScaleEntity(Mesh,xs,ys,zs)
EndIf
If MP_KeyDown(#PB_Key_Pad8) ; up move
up + 0.01
MP_PositionEntity(Mesh,h,up,depth)
ElseIf MP_KeyDown(#PB_Key_Pad2) ; down move
up - 0.01
MP_PositionEntity(Mesh,h,up,depth)
ElseIf MP_KeyDown(#PB_Key_Pad6)
h + 0.01
MP_PositionEntity(Mesh,h,up,depth)
ElseIf MP_KeyDown(#PB_Key_Pad4)
h - 0.01
MP_PositionEntity(Mesh,h,up,depth)
ElseIf MP_KeyDown(#PB_Key_Q) ; forward move
depth - 0.01
MP_PositionEntity(Mesh,h,up,depth)
ElseIf MP_KeyDown(#PB_Key_A) ; inward move
depth + 0.01
MP_PositionEntity(Mesh,h,up,depth)
ElseIf MP_KeyHit(#PB_Key_W) ; display wire frame for the material
If wireFrame=0
MP_Wireframe (1)
wireFrame ! 1
ElseIf wireFrame=1
MP_Wireframe (0)
wireFrame ! 1
EndIf
ElseIf MP_KeyDown(#PB_Key_D)
MP_FreeTriangle(Mesh, 1)
;indx -1: MP_FreeVertex(Mesh ,indx)
EndIf
If MP_KeyDown(#PB_Key_Escape)
Quit = #True
EndIf
Until Quit = #True Or Event = #PB_Event_CloseWindow
the same for purebasic ogre
Code: Select all
Enumeration
#MESH
#LIGHT
#CAMERA_ONE
#BUTTON
#mainwin
EndEnumeration
Quit.b = #False
rot.l=1 :stopFlag = 1
xs.f = 0.3:ys.f = 0.3:zs.f = 0.3
x.f: y.f :z.f: x0.f: y0.f=1 :z0.f
rotx.f:roty.f=0.5:rotz.f :rotx0.f: roty0.f: rotz0.f
up.f = 1.8: depth.f=0: wireFrame.b=0
ExamineDesktops()
If OpenWindow(#mainwin, 0, 0, DesktopWidth(0), DesktopHeight(0), "PgUp PgD scale mesh..Arrows for rotation, space: stop/rotate, QA far/near, key_pad R/L/U/D", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ButtonGadget(#BUTTON, 0, DesktopHeight(0)-60, 60, 30, "rotate/stop")
;Initialize environment
InitEngine3D()
InitSprite()
OpenWindowedScreen(WindowID(#mainwin), 0, 0, DesktopWidth(0), DesktopHeight(0)-60, 0, 0, 0)
InitKeyboard()
SetFrameRate(60)
Add3DArchive("/", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/3D/Data/Textures", #PB_3DArchive_FileSystem)
Add3DArchive(#PB_Compiler_Home + "Examples/Sources\Data", #PB_3DArchive_FileSystem)
CreateLight(0,RGB(255,255,255),-100,40,30)
AmbientColor(RGB(100,100,100))
CreateCamera(#CAMERA_ONE, 0, 0, 400, 400)
MoveCamera(#CAMERA_ONE, 0, 4, 15)
CameraLookAt(#CAMERA_ONE, 0, 2, 0)
EndIf
SetActiveGadget(#BUTTON)
CreateMaterial(0, LoadTexture(0, "RustySteel.jpg"))
;MaterialShadingMode(0, #PB_Material_Wireframe)
MaterialCullingMode(0, #PB_Material_NoCulling)
DisableMaterialLighting(0, #True)
CreateMesh(1, #PB_Mesh_TriangleList , #PB_Mesh_Static )
SetMeshMaterial(1, MaterialID(0))
x.f: y.f :z.f : u.f=0 :txu.f : txv.f
rMajor.f = 2 : rMinor.f = 0.5
majorRadius.f = 2: minorRadius.f = 1.5: numMajor.l = 50: numMinor.l = 25
majorStep.f = 2 * #PI / (numMajor+0);
minorStep.f = 2 * #PI / (numMinor+0)
i.l: j.l
x.f: y.f :z.f :r.f :t.f
a.f=1:b.f=10:
For i = 0 To numMajor
t.f = i * majorStep;
For j = 0 To numMinor
r = 1+1/b*TanH(b*Sin(12*t))
u.f = j * minorStep;
x = r*Cos(t) * (majorRadius + minorRadius * Cos(u))
y = r*Sin(t) * (majorRadius + minorRadius * Cos(u))
z.f = minorRadius * Sin(u)
tt+1
MeshVertexPosition(x, y, z);
MeshVertexTextureCoordinate(txu, txv)
MeshVertexNormal(x, y, z)
txv = txv + 1/numMinor ; texture coordinates
Next
txv = 0
txu = txu + 1/numMajor ;texture coordinates
Next
v.l=0
For i = 0 To numMajor
For j = 0 To numMinor-1
MeshFace(v,v+1,v + numMinor+1)
MeshFace(v + numMinor+1,v + numMinor+2,v+1 )
If i=numMajor-1 And j=numMinor-1 ;bypass the last triangle
EndIf
v + 1
Next
Next
;last vertex to connect:
lastV = (numMinor+1)*(numMajor+1)-1-(numMinor+1)
s = lastv - numMinor
For v = 0 To numMinor
MeshFace(s,s+1, v)
MeshFace(v,v+1,s+1 )
If i=numMajor-1 And j=numMinor-1 ;bypass the last triangle
;numMinor-1
EndIf
s+1
Next
NormalizeMesh(1)
FinishMesh(#True)
CreateEntity(1, MeshID(1), MaterialID(0))
ScaleEntity(1,1.5, 1.5, 1.5)
;Main loop
MoveEntity(1,0,up,depth,#PB_Absolute)
x = 180: y=0: z=0 : h.f
EntityPhysicBody(1, #PB_Entity_ConvexHullBody , 1.0)
WorldGravity(0)
;WorldDebug(#PB_World_DebugBody)
Repeat
Event = WindowEvent()
If Event = #PB_Event_Gadget
Select EventGadget()
Case #BUTTON
If rot = 0
rot = 1
rotx= rotx0:roty=roty0:rotz=rotz0 ; restore rotation status
stopFlag = 1
Else
rot = 0
rotx0= rotx:roty0=roty:rotz0=rotz ;back up rotation status
rotx=0:roty=0:rotz=0
stopFlag = 0
EndIf
EndSelect
EndIf
If stopFlag=1
x + rotx
y + roty
z + rotz
EndIf
RotateEntity(1, x, y, z)
RenderWorld()
FlipBuffers()
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Up) ; rotate left
rotx=1:roty=0:rotz=0
rotx0 = rotx: roty0 = roty :rotz0 = rotz
x + rotx
y + roty
z + rotz
stopFlag=0
rot = 0
ElseIf KeyboardPushed(#PB_Key_Down) ; rotate right
rotx=-1:roty=0:rotz=0
rotx0 = rotx: roty0 = roty :rotz0 = rotz
x + rotx
y + roty
z + rotz
stopFlag=0
rot = 0
ElseIf KeyboardPushed(#PB_Key_Right) ; rotate up
rotx=0:roty=1:rotz=0
rotx0 = rotx: roty0 = roty :rotz0 = rotz
x + rotx
y + roty
z + rotz
stopFlag=0
rot = 0
ElseIf KeyboardPushed(#PB_Key_Left) ; rotate down
rotx=0:roty=-1:rotz=0
rotx0 = rotx: roty0 = roty :rotz0 = rotz
x + rotx
y + roty
z + rotz
stopFlag=0
rot = 0
EndIf
If KeyboardPushed(#PB_Key_PageUp) ; scale up model
xs.f = 1.1:ys.f = 1.1:zs.f = 1.1
ScaleEntity(1,xs,ys,zs)
ElseIf KeyboardPushed(#PB_Key_PageDown) ; scale down model
xs = 0.9:ys = 0.9:zs= 0.9
ScaleEntity(1,xs,ys,zs)
EndIf
If KeyboardPushed(#PB_Key_Pad8) ; up move
up + 0.1
MoveEntity(1,h,up,depth,#PB_Absolute)
ElseIf KeyboardPushed(#PB_Key_Pad2) ; down move
up - 0.1
MoveEntity(1,h,up,depth,#PB_Absolute)
ElseIf KeyboardPushed(#PB_Key_Pad6)
h + 0.1
MoveEntity(1,h,up,depth,#PB_Absolute)
ElseIf KeyboardPushed(#PB_Key_Pad4)
h - 0.1
MoveEntity(1,h,up,depth,#PB_Absolute)
ElseIf KeyboardPushed(#PB_Key_Q) ; forward move
depth - 0.1
MoveEntity(1,h,up,depth,#PB_Absolute)
ElseIf KeyboardPushed(#PB_Key_A) ; inward move
depth + 0.1
MoveEntity(1,h,up,depth,#PB_Absolute)
ElseIf KeyboardReleased(#PB_Key_W) ; display wire frame for the material
If wireFrame=0
MaterialShadingMode(0, #PB_Material_Wireframe)
wireFrame ! 1
ElseIf wireFrame=1
MaterialShadingMode(0, #PB_Material_Solid)
wireFrame ! 1
EndIf
EndIf
If KeyboardPushed(#PB_Key_Escape)
Quit = #True
EndIf
Until Quit = #True Or Event = #PB_Event_CloseWindow