JV-ODE Physics Thread 12

Blitz3D Forums/Blitz3D Userlibs/JV-ODE Physics Thread 12

VIP3R(Posted 2009) [#1]
Now available for Blitz3D & BlitzMax (Win32)

The JV-ODE Physics Wrapper is an advanced user library supporting almost all of the Open Dynamics Engine functions wrapped inside a DLL (Dynamic Link Library).

The library can be used with any programming language that supports DLL's, including Blitz3D and BlitzMax (Win32). The Euler rotation system in JV-ODE has been adapted to match the left-handed Euler rotation used in Blitz3D, however functions for accessing Quaternion and Axis Angle rotation systems are also included. The full versions contain all of the necessary files to get you started, including over 40 demos showing the various features found in ODE and a complete Function Reference document.

The BlitzMax (Win32) version also features a built-in 'bare-bones' OpenGL 3D engine module and B3D mesh loader module for demo purposes.

To view more information and screenshots click here.

Options are now available to purchase the wrapper using either PayPal or Share*it.

The Blitz3D restricted demo version is now available for download here (207KB)

The BlitzMax (Win32) restricted demo version is now available for download here (376KB)

The JV-ODE Leadwerks Engine Demo Pack is now available for download here (60KB)

Have Fun :)

Previous JV-ODE Blitz3D Threads: 1 2 3 4 5 6 7 8 9 10 11

Useful Links: ODE.org Website - ODE Wiki - ODE User Guide (PDF) - ODE User Guide (HTML)


Santiworld(Posted 2009) [#2]
hi vip, thanks for see the game...

im very happy with the ode physics..

the bounce is a big bounce, all cars bounce when touch something, like if the value of collision force is to high...
if that bounce happen, on the menu, the car is desapiers, in the race, the cars jump to the sky...

if i use more cars, 10, 20 30, the posibility of this bounce, increase...


the smmal bounce on the side of the track, is becouse the mesh of the track, that is ok...

i can send you by mail something so you can see in wireframe...

thanks vip3r


Blitzplotter(Posted 2009) [#3]
hi VIP3R,

I have tried adding a hinged door to the back of my trailer with the following code, however my door is elevating in the vertical sense about 1/6th of the height of the trailer - it does not seem to be hinged along the 'bottom' of the door - it is more like the whole door is solidly fixed at being perpendicular to the back of the trailer - like all four corners of the door are on invisible springs of the same strength causing the door to 'bounce' up and down as the trailer drives along. I suspect I am having problems idebtifying the anchor point on the 'bottom' of the door.I appear to be struggling to hinge the edge of the door to a fixed point on the back of the trailer.




VIP3R(Posted 2009) [#4]
@Latatoy: If the cars jump into the sky, it means your simulation has exploded. Try removing the track mesh and replacing it with a plane to see if the TriMesh collisions are causing it. Are you using sphere geoms for the wheels?

@Blitzplotter: Here's a modified version of the TruckTrailer demo with a door...



The door starts in the 'free' state, use the F1, F2 and F3 keys to raise, lower or free the door.


Santiworld(Posted 2009) [#5]
in the main menu, i have a dplane and one ode car...
and the car jump crazy too, sometimes..

is like the system is overflow.

i use the same concept car of the ode samples...
a cube with spheres for wheels.

this is part of the code i use to create the cars..
is cut in some part,


ode\body=dBodyCreate(World)
	Car\body=ode\body
	dBodySetPosition(ode\body,t_CarStartx,t_CarStartY,t_CarStartz)
	dBodySetRotation(ode\body,0,0,0)
	mass=dMassCreate()
	dMassSetBoxTotal(mass,CMass,c_ancho#,c_alto#,c_largo#)
	dBodySetMass(ode\body,mass)
	dMassDestroy(mass)
	ode\geom=dCreateBox(Space,c_ancho#,c_alto#,c_largo#)
	CGeom=ode\geom
	car\geom = ode\geom
	dGeomSetBody(ode\geom,ode\body)
	dGeomContactSetMu(ode\geom,100)
	dGeomContactSetBounce(ode\geom,0)
	
	ode\mesh=CreateCube()


For count=1 To 4
			
		ode.ODEGeom=New ODEGeom
		ode\id = i
		ode\body=dBodyCreate(World)
		car\Wheel[count]=ode\body
		dBodySetPosition(ode\body,0,0,0)
		dBodySetRotation(ode\body,0,0,90)
		mass=dMassCreate()
		dMassSetSphereTotal(mass,WMass,diametro_rueda#)
		dBodySetMass(ode\body,mass)
		dMassDestroy(mass)
		ode\geom=dCreateSphere(Space,diametro_rueda#)
		car\WGeom[count]=ode\geom
		dGeomSetBody(ode\geom,ode\body)
		ode\mesh=  CreateCylinder()

next...

For count=1 To 4
		
		car\joint[count]=dJointCreateHinge2(World,0)
		
		dJointAttach(car\joint[count],Car\body,car\Wheel[count])
		
		dJointSetHinge2Anchor(car\joint[count],dBodyGetPositionX(car\Wheel[count]),dBodyGetPositionY(car\Wheel[count]),dBodyGetPositionZ(car\Wheel[count]))
		dJointSetHinge2Axis1(car\joint[count],0,1,0)
		dJointSetHinge2Axis2(car\joint[count],-1,0,0)
		dJointSetHinge2Param(car\joint[count],dParamSuspensionERP,0.8)
		dJointSetHinge2Param(car\joint[count],dParamSuspensionCFM,SuspensionHS)
		
		If count>2
			dJointSetHinge2Param(car\joint[count],dParamLoStop,0)
			dJointSetHinge2Param(car\joint[count],dParamHiStop,0)
		End If
	Next





you have that jumps vip3r?

sometimes happend when i go to race, menu race menu, many times.

thanks!...

i think is a fail in my code... the problem is find where?


VIP3R(Posted 2009) [#6]
The code you've posted looks ok, but there's many more possible causes, for example the mass/gravity values used etc.

The only sure way to debug this issue is by re-creating it, try to modify one of the demos with the same simulation setup until the problem appears.

I haven't seen it happen yet, but from your description it's clear that the simulation is exploding.


Blitzplotter(Posted 2009) [#7]
@Thankyou very much VIP3R, I will compare your code with mine to try and see where I was going wrong - I had thought about playing with the Radio controlled car (a car with an antenna demo) to fathom the anchor point co-ords, I am loading up protean now to excercise your code, I like the free door example you've incorporated, once the trailer gets so much damage I can invoke the free door and the contents of my trailer will spill out (;-)

Your support and demos never cease to amaze, have a good weekend!


GIB3D(Posted 2009) [#8]
I just bought JV-ODE and I'm excited knowing I can now do some physics stuff in blitz3D... I just have to figure out what it is that I want to do. There's so many possibilities now.


Blitzplotter(Posted 2009) [#9]
Hi VIP3R, I have been trying to create a prototype flatbed which will 'tip-upwards' and will lie along the top of the trailer. However it keeps falling through the trailer....

I've applied forces to the new 'lid ontop of the trailer which is going to be a ramp for the contents to slip down.... it appears I've hinged it at slightly the wrong place. This wasn't evident until I started applying forces to the lidded section. I,m tweaking it now, and have got it so the lid is hinged, just got to try and make the trailer solid.


I have tried turning off the entityalpha for the trailer to no avail - please help ?


[EDIT - removed - see code further down thread]
######################################################################################################################################################################################################################################################################



VIP3R(Posted 2009) [#10]
Any objects that are 'directly' jointed will not collide with each other, that's why it falls through the trailer. You need to attach a small block at the front end of the trailer to act as a stop.

The trailer is completely opaque here, I've noticed the alpha behave strangely in Blitz3D before. Might be something to do with the flatbed section being slightly transparent and located inside the trailer body. Also depends on your graphics card / drivers.


Blitzplotter(Posted 2009) [#11]
Oh, okay will attempt to attach a small block to the front end, cheers. Well, have had limited success with that so far. Initially tried to create a separate box and join it to the front of the trailer in the same vein as the Cab top, I believe the fundamental problem with this was the physics lib still perceived the new front end (for all I put it in a different colour) as still for all purposes the trailer.

Okay, so I got around to referencing the commands avaialable for connecting two separate cubes, after much battling with syntax problems I refewrred to the Wiki for ODE where I found the following quote:

Fixed

The fixed joint maintains a fixed relative position and orientation between two bodies, or between a body and the static environment. Using this joint is almost never a good idea in practice, except when debugging. If you need two bodies to be glued together it is better to represent that as a single body.

void dJointSetFixed (dJointID);

Call this on the fixed joint after it has been attached to remember the current desired relative offset and desired relative rotation between the bodies.

The contact joint prevents body 1 and body 2 from inter-penetrating at the contact point. It does this by only allowing the bodies to have an "outgoing" velocity in the direction of the contact normal. Contact joints typically have a lifetime of one time step. They are created and deleted in response to collision detection.

Which has led me to believe I am attacking this from the wrong angle. My last attempt for the time being is to add a vertical block to the back of the cab - this will not interfere with the trailer as that is hinged (directly) to the cab - however it is not hinged to the 'lid' so I hope the vertical block I add to the back of the cab will at least stop the lid from falling through - it is crude however it works although I'd have liked to have known how to glue a remote cube onto another.


Blitzplotter(Posted 2009) [#12]
I've experienced some problems with the way I have implemented the work around - as you can see in the image below the tipping part of the flatbed has fell through the block on the cab, this does not happen all the time, only on occasion will it 'blast' through the block on the cab which is supposed to prevent it from falling below the trailer's floor - when this happens it fails to 'raise' again, it is stuck beneath the block that was supposed to prevent it from going through the trailer floor, I've a breif suspicion it may be happening because the block on the cab is slighlty 'merged' with the trailer floor. Will try making the cab block thinner and higher so that JV-ODE is able discerning the two all the time, well it works 6 out of 7 times, but on the odd occasion the internal tipping floor gets stuck beneath the block that is meant to stop it from falling beneath trailer floor.

I've attached the code that has brought it this far - hopefully something will jump out to you as being an 'easy fix'. Thanks in advance - BP.

[edit]




VIP3R(Posted 2009) [#13]
Hmm, where do I begin? :)

When adding additional geometry to a body, use Geom Offsets like you are doing now, not fixed joints.

Don't add stops to the cab to limit the trailer ramp, they need to be on the trailer only.

You won't need to work out the horizontal plane in radians, it's in relation to its starting position. 0.0 radians is its starting position, the hi/lo stops define the limit of movement in radians from the starting position.

Your anchor wasn't aligned properly, it was pivoting inside the ramp section instead of the edge of the ramp.

Now you've changed the geometry of the trailer, there's nothing stopping the cab geometry from colliding with the ramp section when turning. This is likely the cause of the ramp getting unstable/jammed.

Tips:

Get your alignment correct before anything else. You can pause the ODE simulation by commenting out the stepping functions in the main loop. It can help when setting up the geometry initially.

Work out the anchor point from the dimensions of the geometry. If you want the joint anchor at the edge of a box, it's the start position (box center) + half an ODE box width (don't confuse it with the Blitz cube dimensions which are 2x ODE).

Work out the maximum rotation in radians you want the joint to be limited to and set the hi/lo stops accordingly. 0.0 is the starting point, for example if you set both stops to 0.0 it won't rotate in either direction.

Here's a working version of your code...



I've used the joint hi/lo stops to limit the cab and the long trailer ramp (see '<<<< HERE' in code). The trailer ramp may still need a stop block attaching to the front end of the trailer if the ramp gets unstable under heavy loads. Or even better two slider joints to simulate hydraulic pistons. So you have a 'free' hinge at the rear of the ramp and two sliders at the front, then apply force to the sliders to raise/lower the ramp.

Keep referring to the joints section on the ODE wiki until you understand how they work a little better. Your main problem is diving in without understanding the basics, which you will need when fixing problems like these.


Blitzplotter(Posted 2009) [#14]
Thankyou VIP3R, I will keep referring to the ODE WIKI to help develop my understanding as well as your very helpful guidance. Thanks again (;-)

The hydraulic pistons do sound intriguing..... of to try the modified code - thanks for this also just tried it its so great!


Santiworld(Posted 2009) [#15]
hi, i have a problem in a new code i wrote...

i have 1 car, and loadmesh scenary.

if i add this, the program say error on end:

piso = LoadMesh("scenary\hills.b3d")
track_ode = CreateTriMesh(Space,piso)

edit : now i try with this code to replace the loadmesh and createtrimesh
dCreatePlane(Space,0,1,0,0)
Global Plane=CreatePlane()
EntityAlpha Plane,0.5
CreateMirror()
the same problem..., i going to check the globals, etc..


the program run perfectly
but allways, when i exit, end, say error, abnormal program termination
MAV, if i run without debug..

maibe i forget something in ode code... any tip?

this error on the end, only exist if i have the scenary.

thanks..


VIP3R(Posted 2009) [#16]
Are you closing ODE properly before ending the program with dCloseODE()?

Other than that I have no idea, that error can occur in Blitz3D without using ODE. Like here for example.


Santiworld(Posted 2009) [#17]
vip3r, thanks, you are a genius...!!
my problem is solved...
i need to practice more :p
thanks!!

ups, i don't know why, the problem persist...
sometimes have MAV, sometimes no, i going to work and find the error..

anyway, thanks...

this is the game, the physics works perfectly like the video shows, but sometimes have the mavs in the start, or in the end. specialy if i compile the game to a .exe file

http://www.youtube.com/latatoy#play/all/uploads-all/1/tY_-Jr85dsU


Santiworld(Posted 2009) [#18]
hi,
i use this game loop to have 60 fps of game update, and renderworld fps depending of each computer...

sometimes have 10 fps of renderworld and allways 60 of calculations..
can be this code be a problem for ode?
regars!
	While Not KeyHit(1)
		
		Repeat
			frameElapsed = MilliSecs () - frameTime
		Until frameElapsed
		
		frameTicks = frameElapsed / framePeriod
		frameTween# = Float (frameElapsed Mod framePeriod) / Float (framePeriod)
		
		For frameLimit = 1 To frameTicks
			
			If frameLimit = frameTicks Then CaptureWorld
			frameTime = frameTime + framePeriod
			
			tTemp = MilliSecs()		
			
			
			key_check()
			game_keys()
			car_keys()
			updategame()
			game_update_rules()
			UpdateCar()
			UpdateGeoms()
			car_velocity()
			smoke_car()
			car_collision()
			rutina_helicoptero()
			
			PTime=MilliSecs()
			dSpaceCollide(Space,World,ContactGroup)
			dWorldQuickStep(World,0.1)
			dJointGroupEmpty(ContactGroup)
			PhysicsTime#=MilliSecs()-PTime
			
			vistas()
			UpdateWorld
			
			tug_ = tug_ + MilliSecs() - tTemp		
			ups_ = ups_ + 1							
			tTemp = MilliSecs()						
			
		Next
		
		tTemp = MilliSecs()
		tuw_ = tuw_ + MilliSecs() - tTemp	
		
		RenderWorld frameTween
		
		car.car = First car
		
		Text gancho-80,galto-67,Int(car\vel*100),0,0
		
		trw_ = trw_ + MilliSecs() - tTemp			
		fps_=fps_+1		
		BarGraph()	
		msg_point()
		game_2d()
		Flip True
		
	Wend
	
	dJointGroupDestroy(ContactGroup)
	dSpaceDestroy(Space)
	dWorldDestroy(World)
	dCloseODE()
	
	End



VIP3R(Posted 2009) [#19]
It should be ok, if you notice any stutters you can separate the physics timing from the render timing completely. What you should aim for with ODE is a constant timing rate (60 fps) and a fixed step time (0.1 steps), regardless of the render timing.

Make sure you test it at different refresh rates to be sure it's ok.


Blitzplotter(Posted 2009) [#20]
VIP3R, please help, I am trying to incorporate a car into my truck demo, I believe I have original vars for my car, however I am getting the error a joint must be connected to more than one object, as far as I can see in my setupcar I am attaching it to 2 bodies. I Invoked a CarMesh in the belief that the code cannot have 2 CMesh vars - this did not resolve my compile error.

[EDIT] following code modified to encapsulate Global Car




VIP3R(Posted 2009) [#21]
You haven't declared the 'Car' variable as global, so it doesn't exist when you try to attach the joint to it.

Add 'Global Car' to the list of globals.


Blitzplotter(Posted 2009) [#22]
thanks VIP3R, going to try it now. That solved it - thankyou.


Blitzplotter(Posted 2009) [#23]
VIP3R, I am attempting to add a height map to a version of the car demo. I've read in some previous posts that it maybe necessary to add trimeshes the same shape as the 'terrain' you are adding in order for vehicles etc to be able to drive 'on' the imported heightmap.

Is there simply one or two lines of code that I am missing or do I have to use a 3d scenery trimesh creation utility from the heightmap I want to use to create land to drive on? I am quite excited about developing the method to incorporate Digital Elevation Files - I created some in a paint application on an older computer some years ago, and fancied a drive around them.

I've included my current version of my demo, which uses a 64x64 bitmap made in paint for a texture to paint the heightmap. The heightmap I am using is a 1024x1024 jpeg which is as close to black as possible giving 1 pixel of height - hence the wheels 'sinking' into the terrain slightly.





VIP3R(Posted 2009) [#24]
Hi BP,

You need to convert the heightmap into a mesh (.B3D) for the ODE collision geometry. There might be some code or small app that can convert heightmaps to meshes if I recall correctly. Check the code archives and toolbox sections.

Once converted, use your heightmap terrain for rendering and the mesh for the ODE geometry.


Blitzplotter(Posted 2009) [#25]
Thanks VIP3R, of to do some digging - I've found the following function, I've just to figure out how to call it & how it becomes associated with a heightmap, or will I need to use the F.L.E editor to create a static mesh from the heightmap & create the trimesh from the static mesh. A quick look at the tools available makes EG Heightmap companion look pretty appealing.

Apologies if there is an obvious answer to my next query, however I am attempting to attach a cars wheels to a body, the following two mages display the problem I am experiencing:

[EDIT]

I am offsetting the wheels so that they appear under the car, when I tried this the mesh of the car was lopsided. In order to try and establish the problem I reverted to the cube and unsurprisingly the cube was off to the right. but it would appear the car mesh appears offset to the left of where B3D thinks it is. The carmesh itself was converted from a 3ds format with Ultimate Unwrap 3D - I am suspecting there 'maybe' something I need to tweak within that with regards to the car mesh. If you have a simple solution in code that can manipulate the mesh to behave I'd apprecaite it. I know this may be more of a modelling issue than a JV-ODE issue, but if you've encountered this before I'd appreciate your feedback, thanks.

[EDIT]

I tried modifying the code as follows, but I beleive I'm on the worng track with this:

[EDIT]


I'm also attempting to incorporate RifRaf's recent particle engine into my game, the lightning effect is working well.


Chroma(Posted 2009) [#26]
VIP3R, where do I download the latest version of JV-ODE?


VIP3R(Posted 2009) [#27]
@BP: You haven't posted the important bit so I'm guessing you missed it. The code that positions the wheels in the demos is as follows...
dBodySetPosition(Wheel(1),-2,CarStartY-0.5,+2)
dBodySetPosition(Wheel(2),+2,CarStartY-0.5,+2)
dBodySetPosition(Wheel(3),-2,CarStartY-0.5,-2)
dBodySetPosition(Wheel(4),+2,CarStartY-0.5,-2)
You'll need to add the CarStartX/Z vars if you haven't done so already. If you're finding the initial positioning difficult, comment out the stepping function in the main loop to pause the physics.


@Chroma: I'm still waiting for you to confirm your registered details as I don't have your name/email from your Blitz profile as a registered user.

See here

Let me know and I'll update your info and send a new download link for you.


Santiworld(Posted 2009) [#28]
hi.. i have a new doubt about ode.

if i create a ode-cube, in a space without gravity, and i won to control that cube like it was a spaceship...

how can i rotate the ode-cube using your own axis?

there is a function to aplly dBodySetAngularVel or something like that? using own axis?

this using one objetct, without joins...

i can aplly forces correctly, but not rotate..

i aplly some forces in this way

fx# = afx# + Sin(yaw) * -pitch * obj\pot * vh
afy# = afy# + Sin(pitch+90) * obj\pot * 600
afz# = afz# + -Sin(yaw+90) * -pitch * obj\pot * vh

dbodyaddforce obj\body, afx,afy,afz

regards...


santiago - latatoy programmer


Santiworld(Posted 2009) [#29]
i`m going to answer my self..

dBodyAddForce
dBodyAddrelForce

i found that function to rotate and move in relative axis, excelent function's


VIP3R(Posted 2009) [#30]
There are also functions for applying forces at a specific point on a body too, like a spaceship thruster...

dBodyAddForceAtPos(body,fx#,fy#,fz#,px#,py#,pz#)
dBodyAddForceAtRelPos(body,fx#,fy#,fz#,px#,py#,pz#)
dBodyAddRelForceAtPos(body,fx#,fy#,fz#,px#,py#,pz#)
dBodyAddRelForceAtRelPos(body,fx#,fy#,fz#,px#,py#,pz#)



Blitzplotter(Posted 2009) [#31]
@VIP3R, I've edited out the codebox above and re-posted my current code here - omitting the x,y & z co-ords of the wheels wasn't very useful from a code diagnosis perspective - sorry. I've been playing with the wheels position in relation to the car mesh to see what co-ordinates allows the car mesh to balance on top of the wheels without the car body lilting to the left or right. The following is the code that makes the car physics stop tilting to the left or right for all the mesh is off centre. I can't quite see the point of stopping the physics from updating, don't the physics need to be working in order to see if the car body will tilt left or right ? I've also uploaded my potentially problematic car mesh to the following link:

[edit]

The car is somewhat of a gargantuan 0.82MBytes - not very low poly!
note you cannot see the left two wheels of the car (they are under the middle of the car) however the right two are offset to the right of the car mesh.

[edit]




I thought I'd try moving the wheels to the left by modifying the codebox above to read:


If use_block_car=1
	;note following good for cube not car body
	dBodySetPosition(CWheel(1),-1.25+CarStartX,CarStartY-1.1,CarStartZ+2)
	dBodySetPosition(CWheel(2),+1.25+CarStartX,CarStartY-1.1,CarStartZ+2)
	dBodySetPosition(CWheel(3),-1.25+CarStartX,CarStartY-1.1,CarStartZ-2)
	dBodySetPosition(CWheel(4),+1.25+CarStartX,CarStartY-1.1,CarStartZ-2)
Else
	;note these co-ordinates make the car mesh balance evenly on the wheels,
	;despite the fact the car mesh appears to be off set to the left during execution
	;am now beginning to suspect that the car mesh is wider than the model appears on
	;the screen
;	dBodySetPosition(CWheel(1),-3.25+CarStartX,CarStartY-1.1,CarStartZ+3)
;	dBodySetPosition(CWheel(2),-0.75+CarStartX,CarStartY-1.1,CarStartZ+3)
;	dBodySetPosition(CWheel(3),-3.25+CarStartX,CarStartY-1.1,CarStartZ-2)
;	dBodySetPosition(CWheel(4),-0.75+CarStartX,CarStartY-1.1,CarStartZ-2)
	
	dBodySetPosition(CWheel(1),-5.25+CarStartX,CarStartY-1.1,CarStartZ+3)
	dBodySetPosition(CWheel(2),-1.75+CarStartX,CarStartY-1.1,CarStartZ+3)
	dBodySetPosition(CWheel(3),-5.25+CarStartX,CarStartY-1.1,CarStartZ-2)
	dBodySetPosition(CWheel(4),-1.75+CarStartX,CarStartY-1.1,CarStartZ-2)
EndIf




However this resulted in the car tipping over to one side straight away, despite the wheels looking like they are directly beneath the 'visible' car, makes me suspect I may need to analyse the mesh of the car:
[edit]


Santiworld(Posted 2009) [#32]
Thanks Vip3r. :)


VIP3R(Posted 2009) [#33]
No problem ;)

@BP: Ok, I think it would be best if you revert back to the cube before doing the following, as the changes you've already made could make things even more confusing.

The car is tipping because the body is still in the center, but the geometry is offset to one side. This indicates that the car mesh isn't centered, the origin (center) should be in the center of the mesh. You can fix this in an editor or in code.

First, replace the cube in your reverted code with the mesh. If you've centered it in the editor it will be more or less in line with the wheels. If you want to adjust the position of the mesh in code, just use PositionMesh(). ( Note: Not PositionEntity()! )

Next, to line the wheels up, pause the physics by commenting out the stepping function. It makes it easier when initially positioning objects like the wheels, re-read my post above. Now you can adjust the coords of the wheels until they're in the correct place.

Once everything is lined up, allow the physics to step again. Now you just need to tweak it ;)


Blitzplotter(Posted 2009) [#34]
Thanks for the quick feedback VIP3R, I've just made an astounding breakthrough (as far as I'm concerned anyway) with threading in one of the most excellent particle systems available on the forums - The Devil Particle System. I've threaded it into one of the simple car demos. This is a significant step towards smoke emanating from the exhaust on my artic rig within JV-ODE, I did spend some time threading RifRaf particle system into my somewhat more complex Artic Rig Code & had the lighnting working, however the smoke compatibility between RifRaf's & JV-ODE eluded me. Not so with Devilish - to be fair I have not tried threading RifRaf's excellent particle generator into a simpler version of the JV-ODE code.

PositionMesh - you little beauty! I do not want to 'litter' the thread with too many images, so I've removed a few images from above.




VIP3R(Posted 2009) [#35]
Hmm, any particle system should work fine with JV-ODE. I haven't used either one that you've mentioned but there isn't anything that would cause incompatibility between them.

Just make sure you're referencing the Blitz3D entities with the particle system and not the ODE objects.


Blitzplotter(Posted 2009) [#36]
I'm sure that with a little more perseverance RifRaf's will work, in fact the lightning effect is already working in tandem with my JV-ODE code. I did not mean to suggest that it would not - it is just that I found the Devil Particle system so much easier to thread into code containing JV-ODE. It may simply be the case that the Devil Particle system needs less fathoming in how to use it with other engines due to the simple code examples you have the option to use.

Not to take anything at all away from RifRafs particle system, I'm still very impressed with it and it has plus points in other areas compared to the Devil Particle system. RifRaf's code is well commented however the Devil Particle system breaks down the different elements of his particle system into separate code listings which makes it easier to marry up to other code.

The positionmesh command is working great, thanks again.


Santiworld(Posted 2009) [#37]
i have some questions, conceptual questions..

how can i create a infinite ode ocean water ?..

i saw the water demo, and iceberg demo of ode, the two samples, the water is a cube. i need a very big ocean, something like 100x100 km, maibe 1000x1000km., only water...

i want to put some naval ship, on the water, and other shings, like icebergs, plataforms, etc..

i think to made one function like this.

if entityY(ode\mesh) < 0 then (the mesh is under the water)?

maibe i can put some big cube, but 1000x1000 km, is very large for a ode obj.


have you some advice to how can i do that?...


VIP3R(Posted 2009) [#38]
@BP: You're welcome :)

@Latatoy: You could try a very large cube or a plane for the water, but I've no idea how well it would work. If you don't want a flat water surface then it's going to be very difficult as ODE is designed for rigid body physics only, water is best simulated with soft body physics engines.

There's also this article on simulating buoyancy in ODE which might help...
http://opende.sourceforge.net/wiki/index.php/HOWTO_simulate_buoyant_objects


Santiworld(Posted 2009) [#39]
i create a realy big cube, to use like ocean water.

the cube dimmension are : 100000x1000x100000 (bliz units)

100000 = 100km in my game...

ode work perfectly :)...


Santiworld(Posted 2009) [#40]
hi. i have a ROPE question...

i use the demo sample rope to make a rope..

but if i attach to the end of the rope a heavy object, the rope don't maintain the large, is like elastic rope if i load it.

how can i config the joints to get a rope without elasticity?

i try with thhis parameters, but nothing..


dJointSetuniversalParam(obj\joint,dParamSuspensionERP,0.0)
				dJointSetuniversalParam(obj\joint,dParamSuspensionCFM,0.0)
				dJointSetuniversalParam(obj\joint,dParamBounce,0.0)
				dJointSetuniversalParam(obj\joint,dParamStopERP,0.1)
				dJointSetuniversalParam(obj\joint,dParamStopCFM,0.0)
				dJointSetuniversalParam(obj\joint,dParamFMax,0.01)
				dJointSetuniversalParam(obj\joint,dParamFudgeFactor,0.1)
						dJointSetuniversalParam(obj\joint,dParamHiStop,0.1)



regads!..


VIP3R(Posted 2009) [#41]
The two parameters needed would be...

dParamSuspensionERP
dParamSuspensionCFM


But, these are only implemented on the Hinge2 joint.

You could try using a maximum ERP and very low CFM with dWorldSetERP/CFM(), this will affect everything in the simulation though.

If the joints are coming apart (or elastic) then the weight is probably much too heavy, I'm not sure if there's a solution to this other than using a lower weight.


Happy Sammy(Posted 2009) [#42]
Hi VIP3R,

I sent an email requesting changed email and a discount code.
Could you receive it? (using "@wtt-mail.com")

Thanks in advance


VIP3R(Posted 2009) [#43]
Hi Sammy,

I haven't received your email, can you resend it?

I've sent a discount code to your registered email address anyway (to the @wtt-mail.com address).


Happy Sammy(Posted 2009) [#44]
Thanks a lot, VIP3R.


Blitzplotter(Posted 2009) [#45]
Hi VIP3R,

Is it possible to add a variable to a capsule/sphere, increment the variable when the object is static (i.e. stops moving) then remove that object after the variable reaches a certain amount - for example 30 seconds ?

Regards,

BP


VIP3R(Posted 2009) [#46]
Yes, make sure the capsule/sphere has auto-disable mode activated with dBodySetAutoDisableFlag(body,1), then check the status of the object with dBodyIsEnabled(body) and increment the variable when it's disabled (returns zero). Now remove the object when the variable reaches whatever amount you choose.


Blitzplotter(Posted 2009) [#47]
Thanks VIP3R, will implement it tonight. I presume the dBodyIsEnabled function will be executed
within the UpdateGeoms function ? I'm thinking of using
a single dimension array to track each 3D item in the
world. Coding with beer goggle makes for slow progress... progress nonetheless.


VIP3R(Posted 2009) [#48]
You can use dBodyIsEnabled(body) anywhere, it doesn't need to be in the UpdateGeoms() function.


Blitzplotter(Posted 2009) [#49]
Morning VIP3R, I have successfully idenitifed spheres or cylinders that are up for deletion using the following code:



I've inserted the following piece of code to attempt to delete an item once it has been detected as not moving, however I receive a memory access violation - I've refered to the function instructions to source the following command however I believe I need to perform the object deletion in some other manner. I was hoping that the memory reference to each cylinder that'd been created would be in some kind of linked list allowing for deletion of an item from that list without affecting the position in memory of the items before and after it. Maybe not though?


If cyls_body_array(amt_cyls,2)>=140 
	Text 400,400,"Attempting Destroy"+amt_cyls
	dGeomDestroy(cyls_body_array(amt_cyls,1))
EndIf


;the array is defined at the top of the code with the following:

Dim cyls_body_array(500,2)   ;max of 500 cyls with 2nd element being
                             ;a count of how long since last moved




I (attempt to) identify the cylinder's place in memeory by populating an array within the following code:

Function AddObjectcapsule(xpos,zed)

xp#=Rand(-10,10)
zp#=Rand(-10,10)

ode.ODEGeom=New ODEGeom
ode\body=dBodyCreate(World)
dBodySetPosition(ode\body,(xp+120+(xpos*10)),90,(70+zp)+zed)
dBodySetRotation(ode\body,90,0,0)
dBodySetAutoDisableFlag(ode\body,1)
ode\geom=dCreateCapsule(Space,1,8)
dGeomSetBody(ode\geom,ode\body)
cyls_count=cyls_count+1
cyls_body_array(cyls_count,1)=ode\body ;use this array to contain the position in memory
                                       ;of each of the cylinders in the world


ode\mesh=CreateCylinder()
ScaleMesh ode\mesh,1,5,1
RotateMesh ode\mesh,90,0,0	; ### Align Blitz3D Cylinder To ODE Capsule
EntityColor ode\mesh,Rand(0,255),Rand(0,255),Rand(0,255)
EntityShininess ode\mesh,0.7

End Function




VIP3R(Posted 2009) [#50]
The error is due to the wrong type of object being deleted, you're calling dGeomDestroy() to delete a body...

dGeomDestroy(cyls_body_array(amt_cyls,1))

You need to destroy objects in the reverse order that they were created, first destroy the geom of the object, then the body...

dGeomDestroy(cyls_GEOM_array(amt_cyls,1))
dBodyDestroy(cyls_BODY_array(amt_cyls,1))



Blitzplotter(Posted 2009) [#51]
thanks, I modified my function to incorporate storage of the memory position of the GEOM first [EDIT](just mod'd the code slightly, executing now to see if resolved):-

[EDIT] I was trying to remove the object twice, so I needed a flag to set when an object has been removed to stop it from being removed twice, which was causing the MAV, my logic error - I should have consulted my design (;-)


Al Meyer(Posted 2009) [#52]
VIP3R, can you send me the email for version 1.32? Thank you


VIP3R(Posted 2009) [#53]
Sure, email sent :)


Al Meyer(Posted 2009) [#54]
Thank you. This is the best lib for Blitz3D :)


Blitzplotter(Posted 2009) [#55]
VIP3R, is it possible to load an animated model created with Pacemaker without any conflicts with JV-ODE?


VIP3R(Posted 2009) [#56]
Sure, as long as you don't try to animate the model and apply physics to it simultaneously ;)


Blitzplotter(Posted 2009) [#57]
I am trying to animate the model without applying physics to it - I think. The following is the 'virgin code' that successfully animates the zombie (i.e. no JV-ODE within it)

[EDIT] Its okay I've sussed it.


Blitzplotter(Posted 2009) [#58]
Hi VIP3R, I've created a cylinder, got it to appear above the cab of my truck within my game. My ultimate goal is to have it point at a specific entity (i.e. the car in the image below). The code I am using is detailed below, the variable carnum is a global which is assigned to CarMesh higher up the code:



For now I am attampting to point it towards the car in the image below, however the cylinder stays in alignment with the cab of the truck - is there anything obvious I am doing wrong ?

[EDIT]


VIP3R(Posted 2009) [#59]
The problem there is you're using the physics to control the pointer object and at the same time move it manually with the PointEntity function. One is overriding the other.

If the pointer doesn't need any physics response (I can't see why it would), you should just use a Blitz3D entity without the physics, then you will be able to point it at the car with PointEntity.


Blitzplotter(Posted 2009) [#60]
Thanks VIP3R, I suspected this might have been the case, and I've just managed to detect which side of my dice/cubes are 'up' by attaching pivots to each side of a cube, happy days indeed. Thankyou again for providing such an excellent physics lib for the community.


EmerGki(Posted 2009) [#61]
Hi Vip3r,

Are some "limitation" in the whell radius? I'm trying to use a wheel with the radius minor than 0.7 (default value of your demos) but, my car always stops...


Play(Posted 2009) [#62]
Hello!
How can I easily check whether the car from the demo is moving or standing still? Check this by differences in function entityX(), entityZ(), or is there any faster way ?


VIP3R(Posted 2009) [#63]
@EmerGki: No limitation, are you sure the chassis isn't touching the ground and causing the 'stop'?

@Play: You can check the EntityX/Z() differences, that will be fast, I'm not sure there's a faster way.


EmerGki(Posted 2009) [#64]
Yes Vip3r, I have tested it, and, one time, I have created the chassis body a bit far from the ground to test...


VIP3R(Posted 2009) [#65]
I've tested it too and it works fine for me :)

Here's the car demo with a wheel radius of 0.1 instead of 0.7 ...



Chroma(Posted 2009) [#66]
VIP3R, I bought your ODE awhile back. How do I get the latest updates?


VIP3R(Posted 2009) [#67]
Chroma, do you ever read my responses?

I've already answered this question 3 times, once via email, once above and once here.

Like I said in the previous post above...

I'm still waiting for you to confirm your registered details as I don't have your name/email from your Blitz profile as a registered user.

See here

Let me know and I'll update your info and send a new download link for you.



Wayne(Posted 2009) [#68]
The see here link returns: ERROR:Internal error

8)


VIP3R(Posted 2009) [#69]
[edit] Wayne, the BlitzMax Module Tweaks forum is hidden, do you have access to it?

[edit] Removed domain from link above (thanks Hotcakes)


Play(Posted 2009) [#70]
Hi,
I have another question:
I have a car from Cardemo example and suppose that it moves. I would like to move a car in another place after some key hit. Something like this:
If KeyHit(57)
	Steer=0
	Force=0.0
	dBodySetRotation(car,0,0,0)
	dBodySetPosition(Car,0,5,0)
End If

Unfortunately, when I use this command abd push a spacebar button, car starts to rotate, and generally behave in unexpected way..
What do I do that, car simply moved to another place, without rotation and no other things are not needed ?

#edit
ok after searching I found something like this:
If KeyHit(57)=1
	Force=0
	Torque=1000

	dBodySetAngularVel(Car,0,0,0)
	dBodySetLinearVel(Car,0,0,0)
	For count=1 To 4
		dBodySetAngularVel(Wheel(count),0,0,0)
		dBodySetLinearVel(Wheel(count),0,0,0)
	Next
	dBodySetPosition(Car,dBodyGetPositionX(car),5,dBodyGetPositionZ(car))
	dBodySetRotation(Car,0,0,0)
Else
	torque=24
End If


This works ok, but only when I use:dBodyGetPositionx/y/z

but I depend on me to be able to provide a parameter value:Entityx/y/z
but unfortunately when I do it, again begins to rotate etc..

2#edit
dammit it's even worst-
I thought that I can use dBodySetPosition() with any dbodyGetPosition, but this only works when i'm using the same body to set and get pos..
I'm Waiting for any help..
thanks

3#edit

I found a topic about this that in order to move the car, I have to reset the torque, force and velo. But despite the fact that I'm doing it for both cars and the wheels, after calling the command dbodysetposition car flies off somewhere far far away ..


VIP3R(Posted 2009) [#71]
You're almost there, in your example code the force and torque still get re-applied once the body is moved, causing it to catapult off into the distance.

You need to zero the force, torque and velocity on each body before moving them...

dBodySetForce(body,0,0,0)
dBodySetTorque(body,0,0,0)
dBodySetAngularVel(body,0,0,0)
dBodySetLinearVel(body,0,0,0)



Chroma(Posted 2009) [#72]
Can you send an email to the email in my profile again. No idea what happened to the first one.

OMG it shouldn't be this hard...

Update or refund...your choice.


Wayne(Posted 2009) [#73]
..


Blitzplotter(Posted 2009) [#74]
@Chroma, I agree, JV-ODE rocks.



VIP3R,I've been trying to opt for manipulating my dice shaker so that it is at an angle of say 45 degrees, with the opended end (note there is not one at the moment but this is easy to resolve) and rotating it along it along its 'long' axis.

My goal is for when the player is ready to throw the dice, the shaker will tip through say 50 to 80 degress allowing the dice which are bouncing about inside the shaker to be 'thrown' from the shaker.

My feeble attempts at connecting an anchor to the shaker have only resulted in compile errors. I even contemplated simply adding to large wheels, the diameter of which would be bigger than the ends of the shaker - rolling the shaker along its long axis (basically like an axle) then removing a wheel to let the dice spill out - maybe.

I even briefly toyed with the rope demo with the goal of tying a chain to the shaker, allowing the user to grab the chain to tip the shaker over.

Any suggestions you have greatfully appreciated - BP.


The code is listed below for a little throw a couple of dice program I've been developing:

Note the dice model used in the code is available from here:

http://www.wishingwellsoftware.co.uk/nicedice1.b3d





[/codebox]


VIP3R(Posted 2009) [#75]

OMG it shouldn't be this hard...


My sentiments exactly. I've responded every single time you've asked for the JV-ODE update, to tell you I DO NOT have your Blitz profile details listed as a registered user. Yet you have not acknowledged it ONCE.

The email address in your Blitz profile is not registered and 'noel' isn't much help, hence the CONSTANT requests for you to confirm who you are.

So, as you couldn't be bothered to tell me who you are, I decided to find out for you.

After going through the 'noel' users, I found an entry that had been delisted due to several email errors (Error: 451 - Temporary local problem - please try later), then I searched for the email address domain on the Blitz website and I find this...

Search Results

And there you are.

Your JV-ODE update email has been sent to the address in your Blitz profile and I've updated your records.

Thanks for telling me you had changed your email address and for the assistance confirming your purchase details :/


@Blitzplotter: I'll look into it and get back to you.

Thanks both for the kind words.


VIP3R(Posted 2009) [#76]
@Blitzplotter: Ok, I've tried the dice code. There were a few problems, setting the mass with dMassSetBoxTotal() twice for each dice causing an ODE error and adding a ball joint to the dice instead of the container(?).

Here's a version of your code with a ball joint attached between the shaker container and ODE world (modifications marked with '<<<<')...


I would suggest making a much smaller container/dice and give them a much lighter mass. You're going to need a good understanding of how the ODE joints and forces work to get this working well. The reason you're having problems adding force to the shaker is because at the moment the shaker, dice and car probably weigh several tons. Raising the force to about 100000 might move it, but it will behave like an extremely heavy shaker with two huge heavy dice and a car(!) inside it ;)

Scale it down, then experiment with the joints and forces a bit more.


Blitzplotter(Posted 2009) [#77]
I would suggest making a much smaller container/dice and give them a much lighter mass. You're going to need a good understanding of how the ODE joints and forces work to get this working well. The reason you're having problems adding force to the shaker is because at the moment the shaker, dice and car probably weigh several tons. Raising the force to about 100000 might move it, but it will behave like an extremely heavy shaker with two huge heavy dice and a car(!) inside it ;)

Scale it down, then experiment with the joints and forces a bit more.


thanks very much for the prompt feedback, I agree I need to invest more time in absorbing the fundamentals of ODE, the reason for the anchor on one of the dice was some dev I was attempting a while back where I was attempting to manipulate the dice with forces - it raised a smile when you mentioned the weight of my shaker and dice!


Blitzplotter(Posted 2009) [#78]
@VIP3R, just tried it, the tilt angle that it rests at will help me a lot with analysing my way forwards, thanks again.

Should you use primitives for dynamic objects and trimeshes for static objects? I'm only asking because I created a cup in UU3D, brought it in successfully into the world, assigned some trimeshes to it successfully and the dice would fall into the cup made up of trimeshes.

I can rotate my the mesh associated with the cup(which you can just see the top of below, keeps the image small though!), but the trimesh associated with the cup stays in the same place. I used the following code to rotate the trimesh:

I have added a couple of more anchor points to my cuboid and I can see a way forward with the cuboid shaker.







VIP3R(Posted 2009) [#79]
Hi BP,

Don't edit your older posts with new questions, I might miss them (nearly missed this one). It's fine to just create a new post :)

TriMeshes are best used as static meshes, they can be used dynamically but they're slow/unreliable compared to primitives. The cup rotation issue is due to the fact you're only rotating the visible Blitz Entity (ode\mesh) and not the actual TriMesh (ode\geom).

Remember, the ode\geom is the invisible ODE collision geometry and ode\mesh is the actual visible representation of the geom (Blitz Entity).

To move an ODE object you need to apply force to the body (or joint) only, not move/rotate the collision geometry (geom) or visible geometry (mesh). The geom and mesh will automatically move/rotate with the body.


Charrua(Posted 2009) [#80]
Hi
I'm working on some "utility cars" on blitz3d and ode, having fun an learning some (and having headaches too). Plus I'm workin on a World Creator that will have some ode support in the near future (hope so), i plan to create this and other machines with the editor and include some general purpose code to handle the machines in the way i do in the .exe in the nex line. Basically a state machine for the joints with 3 stops and a pair of key to move (aply forces to the joint) from one stop to the next.

Link:
Click here!

screenshot:


try it and givme some feedback

best regards

Juan


ZJP(Posted 2009) [#81]
Nice and fun. ;)
Thx


JP


EmerGki(Posted 2009) [#82]
Hi Jim,

I'm with a problem (I talked about it in the past), but, unfortunatelly, I can't get it working correctly.

I need to reposition a truck and trailer, but, I can't, the vehicles always go "flying", I tried to make what you said in the previous JV-Ode topic, but, without success...

Can you help me again? (making a demo version of your truck and trailer with reposition and rotation?)

Thank you.


Blitzplotter(Posted 2009) [#83]
@Charrua, you have a lot of potential with this, great fun.

@Vip3R, thanks for the advice.


VIP3R(Posted 2009) [#84]
You're welcome BP :)

@Charrua: Excellent work so far. The two middle wheels are snagging on the ground a bit when steering full lock, maybe the turning circle is too tight? Not a major issue, so don't worry about it too much. It's worth posting it in the Showcase forum, you might get some good feedback there too.

@EmerGki: I don't know why you're struggling with this, you must be overlooking something in your code somewhere. Anyway, here's the Truck & Trailer demo with a reset option (F1). The reset code is all contained within the UpdateKeys() function...



EmerGki(Posted 2009) [#85]
Thank you Viper, I'll try...


Charrua(Posted 2009) [#86]
thank's for your comment's and suggestions!

i worked on it some month's ago and for many reasosns i have to stop and go in another direction (and other not programming thing's). I have to work on it some more and probably i'll continue wiht it very soon.

That's my idea of learn something..., try to do one thing with it.

thank's again

Juan


Damien Sturdy(Posted 2009) [#87]
Eyup Vip3r.

Sorry about this! I've changed my email again (I fell out with my old ISP :/)
(It's in my profile.. :-) )
Any chance you could change your records and drop me a line? I know i've downloaded this but where on earth I saved it I will never now! X-D

Cheers bud!


VIP3R(Posted 2009) [#88]
Hey Cygnus, good to hear from you :)

Your email records are up-to-date and I've sent the latest download links for you.


Damien Sturdy(Posted 2009) [#89]
Lol, cheers Vip3r! However, I just found out that the site details did not update correctly (as in, 2 minutes ago they were back at their old settings, but I changed them this morning before posting! I think I did something daft.

My current Gmail account is now in there. Damiensturdy@... X-)

Sorry to keep messing you around, I feel like a pillock!


Damien Sturdy(Posted 2009) [#90]
...No worries, I found my old download. Woop!

Can anyone help with regard to "injecting" collisions? trimesh collisions seem a little flakey but the blitz collisions work well, i'd like to pass blitz collisions to ODE instead of getting ODE to do that work, if possible.


VIP3R(Posted 2009) [#91]
No problem, I've updated your email addresses :)

It's not possible to pass the Blitz collision data to JV-ODE, if it were possible it would be slower and have an increased chance of penetration issues.

However, ODE has changed a lot with the more recent builds and this has directly affected the old dGeomTriMeshDataBuildSimple() method of creating TriMeshes which were previously used in JV-ODE. Using the old build simple function is now not recommended in JV-ODE as the TriMesh collisions are not working very well at all (this might be what you're experiencing).

The new functions for building TriMeshes are dGeomTriMeshDataBuildSingle() or dGeomTriMeshDataBuildSingle1() (if you want to define the normals). These have much more reliable collisions than the older builds. The JV-ODE demos use the dGeomTriMeshDataBuildSingle() function now.

If you're already using the new functions, it may be an issue with the mesh itself. Note that TriMesh>TriMesh collisions although better, are still slow and unreliable in comparison to TriMesh>primitive collisions.


Damien Sturdy(Posted 2009) [#92]
AH! I didn't see the new functions, i just saw my old code and figured that was still in use. (In fact, they are buggy if the mesh is offset. that was part of the issue)

I'll try the new funcs now! 8-D

[edit]

Actually, i was using the new functions. The old ODE wrapper for B3D required injecting collisions, not sure how it did it behind the scenes but I think it was simple. I've worked around it now and got my old desired behavior.

The mesh issue is ongoing however, one mesh is generated at runtime but the second third of the track just doesnt appear to be used by ODE. the cars fall off. Is there a limit to the size of mesh/vertex count?


VIP3R(Posted 2009) [#93]
If you mean Vordermans ODE wrapper then the collision detection would have only been accessible in Blitz IIRC. In JV-ODE the collision detection is enclosed within the DLL using a callback, so you don't have direct access to the geom structs, contact joints/functions externally. Doing that in Blitz and passing it to and from the DLL would be much slower.

There's no limit to the vert/indice counts, whenever there has been problems like this it's always due to either the mesh construction itself (wrong vert/indice ordering) so the TriMesh isn't created correctly, or in the case of multiple meshes, incorrect positioning of the TriMeshes.

If you're generating the mesh at runtime, make sure you create the verts/indices in the same order as a standard .B3D mesh. Even some .B3D meshes have been known to display normally in Blitz but don't convert to a TriMesh correctly, because they were saved using the wrong .B3D format specs. The only one that worked for me was this one (2007a version) and it required some hacking. Why Blitz3D doesn't have a native SaveB3D function is beyond me.


Damien Sturdy(Posted 2009) [#94]
Hm, i guess I could try spitting out then reloading it. I'll toy with it a bit.

YEah, the old vorderman wrapper! I could never be arsed to move the racer code over to a new ODE wrapper, i've started rewriting it several times. For the sake of the original and how it felt, I decided to try to bring that one up to speed so people could play it. Seemed like less work, and indeed I was right.

I simply removed the calls to the old ODE wrapper dll, and replaced them with JVODE calls. Works a treat, much much MUCH faster. :-) and no more crashes when 12 cars crash.

though, JV-ode has introduced another problem, after 5 mins of playing around the camera starts to zoom out and eventually crashes. there's no code in my racer to zoom the camera though (well there is, in some camera handling code, but that code is not touched at all in normal view.) so it's odd, like somethings corrupting. Hmph.


[edit]

Screw it.

Copymesh, flipmesh, addmesh. Job done. Not so efficient, but its low enough poly not to matter these days!
Anyhoo, cheers for your help, this is going nicely!


KronosUK(Posted 2009) [#95]
Hi,

Is there anyway to duplicate trimeshes other than reading them in from a mesh everytime you want to create one. Something like a copymesh command except for trimeshes is what Im thinking of.

I want to make a terrain made up of tiles but loading the same tile from scratch everytime seems like it might be slow.


VIP3R(Posted 2009) [#96]
@Cygnus: The camera issue sounds like the simulation has exploded and the camera is focused on an object that has shot off into the distance. If that's the case, it might be a collision penetration or dodgy collision contact somewhere. JV-ODE won't directly affect the camera.

@KronosUK: Good question, ODE doesn't provide a copy TriMesh function as such but there is a way to do it. If you examine the CreateTriMesh() function located inside the 'JV-ODE.bb' file, you will see two banks of data are created for the TriMesh (VertBank and TriBank), then the TriMesh is created with those banks using the last three lines...
TriMeshData=dGeomTriMeshDataCreate()

dGeomTriMeshDataBuildSingle(TriMeshData,VertBank,4,VertCount,TriBank,TriCount*3,4)

Return dCreateTriMesh(trispace,TriMeshData)
What you need to do is create those two banks of data for each tile you want to make duplicates of, then whenever you want to make a copy, create a new TriMesh using the last three lines (above) with the banks you have previously created and stored. This will eliminate the need to iterate through the meshes to build the bank data every time you create the duplicate TriMesh tile.


Damien Sturdy(Posted 2009) [#97]
Hmm, I initially thought so Vip3r, but it actually happens over a slow period of time, and appears to be from repeatedly adding torque to an object. the camera will very very slowly start zooming out (only along one axis- so the image stretches) until it eventually crashes hard.

It's very very odd and doesn't happen with ye olde ODE wrapper. I'd have thought an incorrect memory access would show itself in a bit of a better way- like DEP?

Anyway it appears that it doesnt happen when the cars stay stable, so i think getting a good sim will resolve it :-)


Chroma(Posted 2009) [#98]
Jim, I checked my email and also the spam folder. Didn't see it. Can you resend or tell me another way we can do this?

@Wayne: You have a great attitude and I hope you never have to go through something like this...or it might change.


Blitzplotter(Posted 2009) [#99]
VIP3R, I've stuck a little function in the code archives that will allow the generation of a 'game board' , or steps if you like, purely with static cubes. The function is here & can be pasted into any of the demos.

http://www.blitzbasic.com/codearcs/codearcs.php?code=2615

A little snapshot of calling the function with 3,3 being passed with 25 madsteps being set within the function:-



As someone said recently your lib is the dogs danglies, well thats my interpretation. I've just updated the function so that if people wanna mess with the width & depth of the cubes it'll auto re-position the cubes to accomodate that.




Blitzplotter(Posted 2009) [#100]
Here is a slope to drive down, jim, let me know if you want me to remove the code.




VIP3R(Posted 2009) [#101]
@Chroma: Sure, I've resent the email to the address in your Blitz profile (...@yahoo.com). If you don't receive it again, can you email me and I'll reply with the download link. If that fails, do you have another email address we can try? Please also let me know if you do receive it.

@Blitzplotter: Nice snippet. No need to remove the code, it's helpful and fun :)


Oiduts Studios(Posted 2009) [#102]
I am having a problem, I put a ramp in the spheres demo (without the car) and it is .b3d. But when the spheres roll down the ramp they only go for a certain distance and then they fall through. Is this because of the mesh, or is there a certain variable i need to put in the tell jv-ode how big the object is?


VIP3R(Posted 2009) [#103]
You need to set the ODE geom size (ode\geom) as well as the visible Blitz3D entity size (ode\mesh), for example...
ode\geom=dCreateBox(Space,3,1,4) ; ### 2x Blitz cube dimensions for ODE box
...
ScaleMesh ode\mesh,1.5,0.5,2
The dimensions for ODE boxes are 2x the size of the Blitz cubes.

ODE spheres are the same size as the Blitz sphere.

ODE cylinders have the same radius but need 2x the length of a Blitz cylinder.


Oiduts Studios(Posted 2009) [#104]
Opps i stated that incorrectly, i am using CreateTriMesh...

Global track1=LoadMesh("ramp.b3d")
Global track=CreateTriMesh(Space,track1)
RotateEntity track1,0,90,0
PositionEntity track1,-85,30,0
dGeomSetPosition(track,-85,30,0)
dGeomSetRotation(track,0,90,0)


VIP3R(Posted 2009) [#105]
You can scale a mesh before creating a TriMesh from it if needed, then to scale the visible geometry you would scale the entity...
Global track1=LoadMesh("ramp.b3d")

ScaleMesh track1,1,1,1 ; ### Scale MESH before creating TriMesh from it

Global track=CreateTriMesh(Space,track1)

ScaleEntity track1,2,2,2 ; ### Scale ENTITY to resize visible geometry only

RotateEntity track1,0,90,0
PositionEntity track1,-85,30,0
dGeomSetPosition(track,-85,30,0)
dGeomSetRotation(track,0,90,0)



Oiduts Studios(Posted 2009) [#106]
Well I didnt think it mattered but i guess it does so... my B3D is just two rectangular prisms that are curved in a smooth downward slope and then a upward slope. So would this mean that i can not make this kind of mesh to work in jv-ODE, or is this corrupted?


The red circle marks the place where the ball falls through at.


Oiduts Studios(Posted 2009) [#107]
Also how do you emit a sound from multiple falling objects when they hit the ground. As in rock hitting earth (clunk)


VIP3R(Posted 2009) [#108]
It's difficult to say without access to the mesh or code, it doesn't look right, the left sphere is sinking into the ramp. You can email me the mesh for testing if you wish.

For the second question you need to detect a collision has occurred, see the collision example (CarDemo-CCount), then play the sound and emit it from the associated entity (ode\mesh).


Oiduts Studios(Posted 2009) [#109]
That would be great and also i think i know of something that could be affecting it... i am using pacemaker to convert 3ds to b3d, could this be why?


VIP3R(Posted 2009) [#110]
Yes, it's possible the vertice and indice ordering of the mesh has been exported incorrectly. It will still display normally in Blitz3D, but the TriMesh will be corrupted.


Oiduts Studios(Posted 2009) [#111]
Well then thats helpful, but what can i use to export my 3ds files? I use anim8or


VIP3R(Posted 2009) [#112]
Don't assume the mesh is at fault, like I said it's a possibility but without seeing the mesh/code it's difficult to determine the exact cause.

It should be possible to load the 3DS meshes and use those to create a TriMesh from instead of the B3D meshes.


Oiduts Studios(Posted 2009) [#113]
Wow, i thought that i read somewhere that B3ds were the only mesh types you could use in jv-ode. Well i put in the 3ds version and it did the same thing. I think i will email you the mesh.

Edit: I'm sorry but i am having trouble emailing you... Your email in your sig will not go through aol, i tried taking out the [no spam] thing but it didn't work... :D Can i have a new email please?

Edit #2:I have tried different techniques and still, half of the mesh seems to work find and the other doesn't... i need to make a working "roller coaster" by Monday. Here is the code, it is basically the sphere demo but just tweaked a little. *note that i also had FastExt processes in the code too but took them out to make it cleaner.




VIP3R(Posted 2009) [#114]
Send the mesh to the email address in my profile, but change [no-spam] to @

When I've received the mesh I'll take a look for you.


Oiduts Studios(Posted 2009) [#115]
lol, that was the only thing i had left to try...


VIP3R(Posted 2009) [#116]
Well it looks like the meshes are the problem, I've got no idea why though, maybe an export setting incorrect? or the mesh construction is incomplete/bad? It's almost like the mesh is inside-out.

I don't know what to suggest, other than try a different mesh editor or experiment with the mesh and export settings.


Oiduts Studios(Posted 2009) [#117]
I have no other editor sadly so could someone please do me a big favor and export this C4D from turbosquid to 3ds or b3d format and send it to the email in my sig. I would be a very happy person!
http://www.turbosquid.com/FullPreview/Index.cfm/ID/345239


Blitzplotter(Posted 2009) [#118]
@Blitzmonkey, i tried man but UU3D does not open C4d files. You might wanna look here:-

http://www.blitzbasic.com/Community/posts.php?topic=71084

I do not have C4d therefore cannot export it as a .obj file which uu3d can use.


VIP3R, been having some fun with textures and stuff, came to the realisation that if you use a texture & then modify it after applying it to a cube(or anything for that matter) it is dynamically updated no matter where you have applied it before. I've supplied the code below that demonstrates how to apply text to them:-






Oiduts Studios(Posted 2009) [#119]
Thanks but before I do all that does anyone own c4d?


VIP3R(Posted 2009) [#120]
@Blitzplotter: Dynamically updated indeed :)

@Blitz Monkey: The Content Creation Tools forum would probably be the best place to find help on those mesh issues.


semar(Posted 2009) [#121]
Hi all, I'm completely new about JV-ODE, and I'm using the Blitz3D demo version right now.

I have some questions:
1) I have an animated 3D character which should throw a grenade. At a particular frame of the models throw animation, the grenade - which is on the hand of the model - should get an impulse and travel through the 3D level. Of course, the walls and the ground of the 3D level should act as an obstacle for the grenade, which should bounce on the ground and eventually on all the walls of the level. How can I accomplish this task ?

2) Also, when a bomb explodes near a 3D animated character, he should behave as a ragdoll - or, at least, behave as a phisyc object - and be 'throwed' away by the explosion. How can I do it ?

3) Last but not least, are there some B3D + JV-ODE tutorials to read ?

Thanks in advance,
Sergio.


VIP3R(Posted 2009) [#122]
The grenade can be simulated using an ODE object like a sphere for example, you would need to work out the correct throwing angle and then apply a force to the object to throw it. The ground and walls would also need to be represented in the form of collision geometry, the ground could use a plane geom if it were completely flat. Once the grenade is thrown, you don't need to do anything else, it will fly/roll/bounce around by itself until you remove it.

The ragdoll is quite tough for someone new to ODE. There are two stages involved, the JV-ODE ragdoll demo only shows the second stage which is where the character would switch to a ragdoll. The first stage would involve animating the character and updating the ODE position and rotation of every component of the body, this is to ensure the ODE ragdoll is in the same position as the animated model at the point you switch from animated to physics controlled.

There's an old tutorial made by Shifty Geezer available here, to run the example the code will need to be modified. For instance the example uses the old include file name 'ode.bb' in places, it needs to be 'JV-ODE.bb'.

I would strongly recommend reading the older JV-ODE threads to get an idea on how to implement the above and have some fun experimenting with the ragdoll demo. All of the above can be simulated using the demo version of JV-ODE, so no need to buy it until you've got to grips with it.


Vorderman(Posted 2009) [#123]
When I made a ragdoll program (using Tokamak but the principle is the same) I made sure my 3d human mesh had the right number of bones in it that would represent the ragdoll's physics objects, then I named each bone so it could be identified.

At runtime the mesh moves and animates as normal, once I needed to change it to a ragdoll I cycled through all the bones, transformed their position and rotation into world coords, then setup the physics objects at those positions and orientations, then create and orient the joints between the objects. This saves having a whole load of physics objects being hauled around when they're not needed.

I think I used extra markers in the 3d mesh to represent the joints, so I could correctly orient them to the world.

Once in ragdoll mode the process would occur in reverse every frame so the 3d mesh's bones would be positioned and oriented to their relevant physics objects so they would tumble around.

Once the ragdoll objects had come to rest (or exceeded a life timer I had set for each ragdoll) they were all deleted leaving the 3d mesh behind in its crumpled state.


Mike0101(Posted 2009) [#124]
I'm using newton engine but I'm fucking envious for the support of VIP3R.
This is one of the best support in Blitz community. Sadly I'm lazy to rewrite my project for JV-ODE. I see right now this is the best physics solution for blitz3d.


Blitzplotter(Posted 2009) [#125]
@VIP3R, I've added a little functionality to your Duo code & incorporated a bit of a two player game - admittedly it is quite hard, but hey nothing ever worth doing is easy. Think I managed to get to the fifth row of cubes, in the fifties before I fell of!

Covers some concepts like texturing different cubes with different numbers.... Please note you need JV-ODE to compile this - I think it'll work with the demo version.

Code is below the image






VIP3R(Posted 2009) [#126]
@Mike0101: Thank you, might be best to censor the f-bomb though ;)

@BP: How about braking the car automatically before the transfer? I found it continues moving once the switch occurs leading to the car driving off the ledge, maybe I was driving it too fast :)


Blitzplotter(Posted 2009) [#127]
@Mike0101, yeah I agree with VIP3R on the f-bomb note, there are some young posters here no need mate (;-) But your point on VIP3R's support is bang on with regards to the level of support he provides.

@VIP3R, good point, I was considering making this one of the more 'difficult' levels within the game - was considering adding 'bumpers' to the edges of the rows to compensate for the (only textual warning at the moment) that control is switching soon.

Auto retardation would be good, just one thing though if someone is flying and you attempt to apply the brakes manually, you can get a right tail slide on - which if you are still in control you may be lucky enough not to drop of the edge - but the limited AI control that I'd implement could not compensate for a tail slide on reverse thrust/brake application. So I might opt for bumpers first. Gonna implement joypad support next - its easier to pass a controller backwards and forwards than swapping seats at the keyboard. I like the idea of implementin my array of cars, so each player has a choice of 1 to 5 cars to race to the top with.

Still the best Physics Lib and by FAR the best supported lib. I know someone was along way towards a Stunt Car Racer remake a while back, kinda fancy a stab at it myself. A while off yet though! Seasons Greets Everyone - happy holidays!


Charrua(Posted 2009) [#128]
i don´t read all the thread, why you don't split the screen and keep 2 players on all the time?

Juan


Blitzplotter(Posted 2009) [#129]
@Charrua, that is an aspiration, if you know how to do it please feel free to modify my code provided above for all to benefit from, it may be a simple modification and if you know how to do it I would appreciate the benefit of your knowledge. I admit my current skills in B3D/JV-
ODE do not come up to:

http://www.blitzbasic.com/Community/posts.php?topic=88220#1001649

However, Charrua, if you can implement the serial comms you are referring to in the thread I have slapped here, I'm sure the JV-ODE users would be very appreciative(me included!), regards, BP.

However, I do have some concerns regarding your speed issues:

but for testing i implement all 3 in the same computer.
not very fast,


I do confess that the code I have posted above does not run super smooth on my system @ 1920 x 1200, and if you as you are suggesting, running three separate instances doing comms over and above the processing for one app, I fear most processors would understandably sweat.


Charrua(Posted 2009) [#130]
for the serial comms i use a lib posted by Niegel (i think) on this forums some time ago

serialio.bb

that other thread speaks about other thing: 2 windows at the same time.

to split the screen basically to split the screen you have to create 2 cameras and define the viewport of each to a half screen (horizontally or vertically) say:
x,y,with,height
0,0,512,768 for the first and 512,0,512,768 for the second (if you use
1024x768)
then one camera follow one car, the secon the second

of course you have to define a new set of keys to hadle the second car

let me try to do that, givme some time

juan


Charrua(Posted 2009) [#131]
just 2 cameras, the rest is up to you!



you have to add a new set of controls for the second car

the new function SplitScreen should split vertically or horizontally, and that should be changed by a key press if you call it again toggling the third parameter.

juan


Blitzplotter(Posted 2009) [#132]
Charrua, thank you for the feedback, my I'm gonna have some fun now. The codebox below allows one player to use the keyboard and the other to use a USB joypad. Please note you will need a joypad.cfg file, details of where to source this within the code. Incorporated some barriers now as well so it is not so easy to fall off the rows.

Interestingly, my desktop displays the numbers applied to the cubes, however, when the executable is transferred to the laptop, the numbers do not appear on the textures. Must be something to do with the lack of a dedicated graphics card on the laptop.




Ian Caio(Posted 2009) [#133]
Bought JV ODE recently, Im really liking it, still learning though. if someone can indicate some nice tutorials :).
Just a question to VIP3R, I bought the JV ODE without the cd option. If I lose it, is there a way to download again? (just asking because if not, Im gonna record it in CD as soon as possible, even if not anyways)

cya


VIP3R(Posted 2009) [#134]
There's a link to the only tutorial available in post #122 above ^ (read the paragraph too)

Sure, if you need to download it again just contact me via email and I'll send you a new download link, you will need to provide proof of purchase. JV-ODE has a small filesize so you could backup to a USB memory stick if preferred.


Blitzplotter(Posted 2009) [#135]
@VIP3R, just gotta say I've added a van type mesh (of the postman pat variety) to the car instead of the basic cube - and I am amazed at how the physics engine seems to intuitively compensate for the physics of a higher centre of gravity. Merry Christmas VIP3R.


VIP3R(Posted 2009) [#136]
Merry Christmas :)


Ian Caio(Posted 2009) [#137]
Merry Christmas for all,

Thanks for the feedback VIP3R, I checked this tutorial :)
Now Im gonna check some Examples to try to learn more about Joints.
Btw, I saw a C Include file in the misc directory, it means I can use it for programs with C/C++ also? Sorry if its a stupid question, I just saw some stuff related to the DLL in the include and for making sure I wanted to ask you.

Cya


VIP3R(Posted 2009) [#138]
You're welcome :)

Yes, the C include can be used to access JV-ODE from C/C++.


Damien Sturdy(Posted 2009) [#139]
Hmmm

How can I disable collisions for one body/geom?

DGeomDisable and DBodyDisable both seem to fail. I call them but immediately the relevant Get functions return true, and the objects continue to collide!?


Ian Caio(Posted 2009) [#140]
Hey Cygnus,
I have tryied to do some Code with DBodyDisable and DGeomDisable, and what I get is the following:
The problem happens when AutoDisable is True. For example, Cube1 falls on Cube2, then you Disable Cube2. If AutoDisable is true it looks like it puts Cube1 on Idle mode, and it just falls in the place of Cube2 when some other force acts over it. If AutoDisable is False, it works ok, because the Body is not set to the Idle mode. I dont know if you get what Im saying, but the code is down here:
Graphics3D 1024,768,32,1
SetBuffer BackBuffer()

Include "JV-ODE.bb"

Type Obj
	Field Geom
	Field Body
	Field Mesh
End Type

cam=CreateCamera()
PositionEntity cam,0,20,-20
RotateEntity cam,45,0,0

light=CreateLight()
PositionEntity light,0,10,0

dInitODE()
Global World=dWorldCreate()
Global Space=dHashSpaceCreate(0)
Global ContactGroup=dJointGroupCreate(0)

;dWorldSetAutoDisableFlag(World,1)	;<<< CHANGE FOR TRUE/FALSE TO CHECK WHAT HAPPENS
dWorldSetGravity(World,0,-0.98,0)
dContactSetMu(2)
dContactSetBounce(0.1)

dCreatePlane(Space,0,1,0,0)

Plane=CreatePlane()
EntityTexture Plane,PlaneTexture()

CreateBoxes()

DelayTime=MilliSecs()

While Not KeyHit(1)
	If KeyHit(57) Then
		A.Obj=First Obj
			dGeomDisable(A\Geom)
			dBodyDisable(A\Body)
	EndIf
	
	If KeyHit(28) Then
		CreateBoxes()
	EndIf
	
	UpdateGeoms()
	
	dSpaceCollide(Space,World,ContactGroup)
	dWorldQuickStep(World,0.1)
	dJointGroupEmpty(ContactGroup)
	UpdateWorld()
	RenderWorld()
	Text 0,0,"Press ENTER to add Boxes"
	Text 0,30,"Press SPACE to Disable the Bottom Box"
	Flip
Wend

dJointGroupDestroy(ContactGroup)
dSpaceDestroy(Space)
dWorldDestroy(World)
dCloseODE()
End

Function CreateBoxes()
	A.Obj=New Obj
		A\Mesh=CreateCube()
			EntityColor A\Mesh,Rnd(255),Rnd(255),Rnd(255)
		A\Body=dBodyCreate(World)
			dBodySetPosition(A\Body,0,10,0)
			dBodySetRotation(A\Body,0,0,0)
;			dBodySetAutoDisableFlag(A\Body,1)  ;<<< CHANGE FOR TRUE/FALSE TO CHECK WHAT HAPPENS
		A\Geom=dCreateBox(Space,2,2,2)
			dGeomSetBody(A\Geom,A\Body)
End Function

Function UpdateGeoms()
	For A.Obj=Each Obj
		PositionEntity A\Mesh,dGeomGetPositionX(A\Geom),dGeomGetPositionY(A\Geom),dGeomGetPositionZ(A\Geom)
		RotateEntity A\Mesh,dGeomGetPitch(A\Geom),dGeomGetYaw(A\Geom),dGeomGetRoll(A\Geom)
	Next
End Function


But I gotta say Im really new to JV-ODE, so I cant say much. Thats what I think over what I saw. But maybe you can configure something, to make AutoDisable "works" with this.

Cya

EDIT:
Edited the code, its better to use now. The commands are now also printed on the screen. Note that in this code the AutoDisableFlag is false, but you can (and should) change it to true to check what happens.


Damien Sturdy(Posted 2009) [#141]
Interesting test there, however I don't use autodisable. For me the objects simply do not disable at all.

I've worked around it by moving the objects into a non colliding space for the period of the disability. :-) Cheers though!


VIP3R(Posted 2009) [#142]
dBodyEnable(body) and dBodyDisable(body) are used to effectively 'play or pause' the forces acting on a body and will have no effect on collisions, not to be confused with the geom equivalent. A new collision with any disabled body will re-enable it. The auto-disable feature in ODE is used exclusively on a body.

dGeomEnable(geom) and dGeomDisable(geom) will enable or disable collisions on a geom and will have no effect on the associated body. I'm not sure what you mean by 'relevant Get functions', you should be using dGeomIsEnabled(geom) to return its state.

Here's a quick demo showing the dGeomEnable()/dGeomDisable() functions working...


@ian caio: The reason your boxes don't fall when disabling collisions on the lowest box with the auto-disable feature active is because the bodies of all boxes have come to a rest and have auto-disabled, thus are not affected by forces like gravity etc, so that's normal behaviour.


Santiworld(Posted 2009) [#143]
i only wanted to let you know that I'm the former Latatoy user, I'm no longer working for Latatoy SRL, so, i changed my username in blitz because I'm going to program games on my own.

how can i change my email adreess to recive the future ode updates?

regards, Santiago.


Ian Caio(Posted 2009) [#144]
@Cygnus

Yeah, that works too, but I guess using dGeomDisable() is better because if you have a function that updates the mesh to the geometry it would be more complicated to make it work with this method (you would have to check if its unabled, to then put the mesh in position)

@VIP3R

Thats was what I though. But is there a way to make it stop resting manually? (is it using dbodyenable, dgeomenable?)

EDIT:
Forgot to tell you about it. I dont know if its my documentation only, but the internal links inside it doesnt look to work (except for external ones).


VIP3R(Posted 2009) [#145]
@Santiworld: You can email me to update your address, if you're emailing from a different email account to the one you have registered for JV-ODE, you will need to provide some proof of purchase.

@ian caio: If a body is disabled you can call dBodyEnable() to re-enable it. It will re-disable though if auto-disable is active and no further collisions have occurred. To make it stay enabled, either disable the auto-disable on the body with dBodySetAutoDisableFlag(body,0), or call dBodyEnable() on the body every iteration.

The doc links work fine here and it passes W3C validation, what browser are you using?


Damien Sturdy(Posted 2009) [#146]
~Vip3r, yeah, but for me even using geomdisable fails to disable collisions. The way i've written the code though, simply changing the space of the object works fine. I won't worry about how i've managed to break the above function for now ;-)

Racer demo here- uses JVODE now. I finally, FINALLY moved it over. http://damiensturdy.servegame.org/downloads/RACER_29_12_09.rar

See how there are WAY more than 8 cars now ;-)


Ian Caio(Posted 2009) [#147]
VIP3R,
I use Mozilla Firefox 3.0.16.
Wierd is that now that I readed your answer, I tried it on Internet Explorer, it worked.
Maybe I will update Firefox and test again (because I had a few troubles with the latest Firefox update, so I came back to a older version), but its still wierd ^^. At least I found out it was not any problems with the file.

Cygnus,
Have tested your game, it looks good, just lags a little bit here (maybe because Im testing in a notebook).


Damien Sturdy(Posted 2009) [#148]
ian-

Yep, I've pushed my laptop to its limits running the game. Eventually I'll be porting it to the iPhone but I just want my algos down first. It's the rendering that does it, turn off rendering and I get upwards of 200fps where I was getting 30 when rendering. Shame that B3D has some bottlenecks at the rendering side of things!

Cheers for testing. If you have any thoughts on it let me know :-)


Kev(Posted 2009) [#149]
im thinking of buying but before i do is there any tutorials on how to use it as the demo version is very basic

kev


VIP3R(Posted 2009) [#150]
The ODE Wiki and official user guide are good sources of information, but not quite tutorials, you can find links in the top post of this thread.

There's an old tutorial made by Shifty Geezer available here, to run the example the code will need to be modified. For instance the example uses the old include file name 'ode.bb' in places, it needs to be 'JV-ODE.bb'.

Lots of useful info is contained within the JV-ODE threads here too, so a quick search of those can help with anything specific.


Kev(Posted 2009) [#151]
thanks VIP3R, Shifty Geezer tutorial is just what i was looking for now time to do some reading and seaching the JV-ODE threads.

thanks
kev


Chroma(Posted 2010) [#152]
Yeah I bought this over a year ago I believe and still haven't used it. I didn't know about that Shifty Geezer tutorial. That's really what this was lacking. Thanks Kev for the link.


Damien Sturdy(Posted 2010) [#153]
OK, it's really winding me up now.

Any clues on how best to manually generate meshes suited to trimesh use?

I've got an awesome dirt track gen but the meshes just won't work with ODE at all, i've tried flipping tris etc, but even if I clone the mesh, flip it and re-add the clone to the original (thus duplicating triangles to remove non colliding sides) the objects will still pass through.

I'm scratching my head bigtime, My bald patch is coming back ;-)


Wayne(Posted 2010) [#154]
Would you post a link to your mesh so we may see it?


VIP3R(Posted 2010) [#155]
Yep, post a link or send the mesh via email and I'll take a look too.

It's most likely incorrect vert/indice ordering. Can you post/send the mesh generation code too?


Damien Sturdy(Posted 2010) [#156]
OK- I will portablise the generation code. It's a BIG mess mind. i was getting wound up last night as the Monster Truck mode relies on this mesh generation and it's a bug big enough to cause problems in porting.

I've tried re-ordering the indices (ensuring every poly is clockwise) to no avail whatsoever, so i'm scratching my head as to what the rules are.

Hell, for the sake of trying to remove the issue I overrid the blitz addtri function and made it add the same tri every which way possible. Obviously that introduced a few other glitches and slowdowns but at the same point in the track it still causes the sim to explode.

Anyway, cheers- I'll get the code over. As I say it's old and untidy, so I'm not sure if it'll be clear how it's working anymore.


VIP3R(Posted 2010) [#157]
Hmm, strange. Something else you can try, create a bank containing the normals and add it to the CreateTriMesh() function with...

dGeomTriMeshDataBuildSingle1(trimeshdata,vertices*,vtxstride,vtxcount,indices*,idxcount,tristride,normals*)

It's identical to the existing function except for the normals parameter.


Damien Sturdy(Posted 2010) [#158]
Tried that :-)

I've taken a break from that bug for now, there were more pressing issues, however I will try to get the code up for you to take a look at so I can get it resolved quickly. i hope i don't have to rewrite the gen function! ;-)


Kev(Posted 2010) [#159]
got this now and just started playing with it just checking the latest version is V132 can anyone confirm.


VIP3R(Posted 2010) [#160]
Yep, V1.32 is the latest version.


Kev(Posted 2010) [#161]
thanks VIP3R

quick question as im here, ive created some very small example to learn how everything is setup. right now i have 2 boxes falling onto a ledge and then of the legde onto the floor.

this works great so i added bounce to the legde using its geom like so

dGeomContactSetBounce shelf\geom,3

now this does not work on its own i needed to add the following

dContactSetMode dContactBounce
dContactSetMu(WorldFriction)

now the question is why? say for example i wanted to have multi geom affects like bounce and slide but dContactSetMode is set to bounce

anyway it realy is a great library and im only just beging with it, im looking forward to the coming week with this

kev


VIP3R(Posted 2010) [#162]
Thanks for the kind compliments Kev :)

Here's some info about the contact settings...

The standard contact functions (dContactSetMode(mode) etc) are global so they will affect all geoms in the simulation (unless they have geom contacts applied). You need to apply the standard contact settings regardless of whether you use the geom contact functions.

The geom contact functions (dGeomContactSetMode(geom,mode) etc) are for use on individual geoms. If the geom contact settings are not used, JV-ODE will apply the standard contact settings to the geom.

When using geom contacts, you need to specify the contact mode with dGeomContactSetMode(geom,mode) rather than dContactSetMode(mode). This will allow you to apply any mode to any geom.

The contact values behave like a bit flag. You need to add the contact modes together like so...

dGeomContactSetMode(geom,dContactBounce+dContactSlip1+dContactSoftERP)

To see geom contacts in action, have a look at the 'Demo-GeomBounce' and 'Demo-GeomFriction' demos, they show geom contacts being used to apply different bounce and friction values to individual objects.


Kev(Posted 2010) [#163]
thanks for that VIP3R, its all becoming clearer. i just missed that command from the docs after more playing i decoverd just what you said and that then lead me to look at the dbody functions and now i can fire a projectile.

it realy is starting to fit together much more now, one thing im un-sure about would be the best method to create JV-ODE objects either before hand and have them disabled or on the fly to be used and then destroyed, this is somthing i shall look at soon.

kev


Aussie(Posted 2010) [#164]
Gday all i have been playing around with JV-ODE & have set up a world where the level moves & a ball rolls around the level.

I have run into problems with the ball falling through a trimesh (the level) when the level is moved quickly. I am not sure if i have set the trimesh up properly. If someone could take a look at the code & see whats happening it would be much apreciated.

Cheers. :)



VIP3R(Posted 2010) [#165]
Hmm, the problem there is you're manually rotating the TriMesh geom. As you've discovered, the result is collision penetration. In ODE you can't position or rotate an object manually once the simulation has started, you can only apply forces to the object.

The correct method would be to add a body to the TriMesh object, disable gravity on the body, attach a static ball joint between the body and the ODE world, then apply a force at the edges of the TriMesh body to move it up/down. Using a composite object made up from several primitives (cubes etc) instead of a TriMesh would be best if possible.

Adding a body and disabling the gravity (dBodySetGravityMode(body,0)) is easy enough. The rope and iceberg demos show how to attach a ball joint between a body and the world. Then you just need to decide how you want to add force to the platform, there are various force functions available...

dBodyAddForce(body,fx#,fy#,fz#)
dBodyAddTorque(body,fx#,fy#,fz#)
dBodyAddRelForce(body,fx#,fy#,fz#)
dBodyAddRelTorque(body,fx#,fy#,fz#)
dBodyAddForceAtPos(body,fx#,fy#,fz#,px#,py#,pz#)
dBodyAddForceAtRelPos(body,fx#,fy#,fz#,px#,py#,pz#)
dBodyAddRelForceAtPos(body,fx#,fy#,fz#,px#,py#,pz#)
dBodyAddRelForceAtRelPos(body,fx#,fy#,fz#,px#,py#,pz#)

If you get stuck let me know.


Aussie(Posted 2010) [#166]
Cheers VIP3R

I think i have set up the level & joint correctly.
level.ODEGeom = New ODEGeom
	level\body = dBodyCreate(ODE_World)
		dBodySetRotation(level\body,0,0,0)
		dBodySetPosition(level\body,0,0,0)
		dBodySetGravityMode(level\body,0)
	level\geom = createtrimesh(ODE_Space,lev)
		dGeomSetBody(level\geom,level\body)
	level\mesh = CopyEntity(lev)
	
	joint = dJointCreateBall(ODE_World,0)
		dJointAttach(joint,0,level\body)
		dJointSetBallAnchor(joint),0,0,0 

However now if i position the ball on the level, the level reacts to where the ball is & i am trying to make it so the ball reacts to the rotation of the level.

I am having a bit of trouble with applying force to the level & i end up with the level spinning around. Is there a way to limit the rotation of a joint?


VIP3R(Posted 2010) [#167]

However now if i position the ball on the level, the level reacts to where the ball is & i am trying to make it so the ball reacts to the rotation of the level.


The mass of the platform is too small compared to the mass of the ball, adding plenty of mass to the platform will correct it.


I am having a bit of trouble with applying force to the level & i end up with the level spinning around. Is there a way to limit the rotation of a joint?


It's odd but there isn't a way to lock an axis on the ball joint. In most of the other joints you can lock an axis. However, in this case we can cheat and do something I just told you not to do ;)

You can force the platform Y-Axis to stay at zero rotation. It won't matter here because we're still keeping the axis at its starting position, rather than moving it.

Here's some code showing a tilting platform with spheres using the above methods...



Aussie(Posted 2010) [#168]
Cool!!!!

That was exactly what i was trying to achive.

Thanks heaps. The help is much apreciated. :)

P.S cheers for the email to let me know.


Blitzplotter(Posted 2010) [#169]
So, when we jumping to thread 14 then VIP3R?

lovely platform tilt demo by the way!


VIP3R(Posted 2010) [#170]
Thanks BP :)

Maybe when the post count is 180+ I'll create the next thread (unless a mod requests it early). It'll be thread 13 though, this one is 12.

@Aussie: You're welcome :)


Wayne(Posted 2010) [#171]
Dang, don't have latest version. I'd better go double check.


Wayne(Posted 2010) [#172]
Large timer value causes balls not to drop !!

Worked at home after reboot, but failed at work with machine that runs 24x7.

Timer value when it fails is like: -1309763702

The following corrected it:

If Abs(Abs(MilliSecs())-Abs(Timer))>700

AddObject()
Timer=MilliSecs()

End If


VIP3R(Posted 2010) [#173]
It's not a bug it's a feature, to intentionally confuse those who waste precious energy resources by leaving their computers on 24/7 :P

It is interesting though, thanks for providing a fix Wayne.


Blitzplotter(Posted 2010) [#174]
Textured the wheels on my Postman Plat (a bit like the original but he has plats) racer. I want to invoke an analogue style gauge reflecting the speed on a HUD kind of principle next with respect to each of the postman plat vans. I don't think postman plat had missile launchers though...


OJay(Posted 2010) [#175]
It's not a bug it's a feature, to intentionally confuse those who waste precious energy resources by leaving their computers on 24/7 :P

OT: just as a side note: if you use hibernate, the system up timer also never resets... ;)


Ian Caio(Posted 2010) [#176]
Hey all,

These days I have tryied to do a little demo, that basic one, that builds a tower with cubes. It has a input that asks for the height of the Tower (higher > more cubes), and the problem was that when the number was too high there was a StackOverflow on the dWorldQuickStep command. I have tested it more now, and the number of cubes for that happen is not really a constant. Right now I could make a 200 height tower. But before I had overflows with only 70. I have searched a little bit on google but the only thing I found was that if I was having stack overflow problems with dWorldStep I should use dWorldQuickStep (which Im already using). Is there a way to solve this problem?

Here is the code:

Include "JV-ODE.bb"

Graphics3D 1024,768,32,1
SetBuffer BackBuffer()

dInitODE()

Global World=dWorldCreate()
Global Space=dHashSpaceCreate(0)
Global ContactGroup=dJointGroupCreate(0)

dWorldSetAutoDisableFlag(World,True)

dWorldSetGravity(World,0,-1,0)
dContactSetMu(80)

Cam=CreateCamera()
PositionEntity Cam,0,5,-20

light=CreateLight()
PositionEntity light,0,10,0

Global Height

Height=Input("Tower Height:")

Dim Cubo(Height*4)
Dim CuboGeom(Height*4)
Dim CuboBody(Height*4)

Plane=CreatePlane()

dCreatePlane(Space,0,1,0,0)
EntityTexture Plane,PlaneTexture()

Counter=0	

For x=1 To Height*4 Step 4
	Cubo(x)=CreateCube()
		ScaleEntity Cubo(x),0.5,0.5,5	
	CuboBody(x)=dBodyCreate(World)	
	CuboGeom(x)=dCreateBox(Space,1,1,10)	
	dGeomSetBody(CuboGeom(x),CuboBody(x))
		dBodySetPosition(CuboBody(x),-3,0.5+(Counter*2),0)
	dGeomContactSetMu(CuboGeom(x),100)
	
	Cubo(x+1)=CreateCube()
		ScaleEntity Cubo(x+1),0.5,0.5,5	
	CuboBody(x+1)=dBodyCreate(World)	
	CuboGeom(x+1)=dCreateBox(Space,1,1,10)	
	dGeomSetBody(CuboGeom(x+1),CuboBody(x+1))
		dBodySetPosition(CuboBody(x+1),3,0.5+(Counter*2),0)
	dGeomContactSetMu(CuboGeom(x+1),100)
	
	Cubo(x+2)=CreateCube()
		ScaleEntity Cubo(x+2),5,0.5,0.5	
	CuboBody(x+2)=dBodyCreate(World)	
	CuboGeom(x+2)=dCreateBox(Space,10,1,1)	
	dGeomSetBody(CuboGeom(x+2),CuboBody(x+2))
		dBodySetPosition(CuboBody(x+2),0,2+(Counter*2),-3)
	dGeomContactSetMu(CuboGeom(x+2),100)

	Cubo(x+3)=CreateCube()
		ScaleEntity Cubo(x+3),5,0.5,0.5	
	CuboBody(x+3)=dBodyCreate(World)	
	CuboGeom(x+3)=dCreateBox(Space,10,1,1)	
	dGeomSetBody(CuboGeom(x+3),CuboBody(x+3))
		dBodySetPosition(CuboBody(x+3),0,2+(Counter*2),3)
	dGeomContactSetMu(CuboGeom(x+3),100)
	
	Counter=Counter+1
Next

	UpdateCubes()
	
While Not KeyHit(1)
	
	If KeyHit(57) Then
		For x=1 To Height*4
			dBodyAddForce(CuboBody(x),Rnd(-50,50),Rnd(-50,50),Rnd(-50,50))
		Next
	EndIf
	
	If KeyDown(200) Then
	MoveEntity cam,0,0,1
	EndIf
	If KeyDown(208) Then
	MoveEntity cam,0,0,-1
	EndIf
	If KeyDown(203) Then
	MoveEntity cam,-1,0,0
	EndIf
	If KeyDown(205) Then
	MoveEntity cam,1,0,0
	EndIf
	If KeyDown(30) Then
	MoveEntity cam,0,1,0
	EndIf
	If KeyDown(44) Then
	MoveEntity cam,0,-1,0
	EndIf
	
	dSpaceCollide(Space,World,ContactGroup)
	dWorldQuickStep(World,0.1)
	dJointGroupEmpty(ContactGroup)
	
	UpdateCubes()
	
	UpdateWorld()
	RenderWorld()
	Flip
Wend

dSpaceDestroy(Space)
dWorldDestroy(World)
dCloseODE()
End

Function UpdateCubes()
	For x=1 To Height*4
		PositionEntity Cubo(x),dGeomGetPositionX(CuboGeom(x)),dGeomGetPositionY(CuboGeom(x)),dGeomGetPositionZ(CuboGeom(x))
		RotateEntity Cubo(x),dGeomGetPitch(CuboGeom(x)),dGeomGetYaw(CuboGeom(x)),dGeomGetRoll(CuboGeom(x))
	Next
End Function


Seens like the problem happens when there are many collisions.

Cya


Wayne(Posted 2010) [#177]
..


VIP3R(Posted 2010) [#178]
The stack overflow is usually caused by too many objects overlapping when they are created or added, resulting in too many collision contacts being generated. You can recreate the error in many of the JV-ODE demos by increasing frequency of the AddObject() calls.

The solution is too make sure the objects don't overlap any other objects when creating or adding them. For stacked objects, make sure to leave a very tiny gap between them.


Ian Caio(Posted 2010) [#179]
Thanks for the answers (:

Wayne,
Have tryied your code, with 130 it seens to work fine, over it the stack overflow happens again. What exactly did you do to make it work with higher values? I have seen the AutoDisable configuration you did there, but I didnt really understood why it all worked.

VIP3R,
I have tryied to make a gap between the cubes, I can do until 500 Height towers (about 600/700 the program closes before it starts ^^), the problem is that when they start falling, they start overlapping each other and then the Stack Overflow happens again. Is there a way to avoid this? I have thought about ERP, but I dont really know how to use it well.

Heres the code with the little gap between the objects:



Oiduts Studios(Posted 2010) [#180]
The reason JV-Ode doesn't support 600 to 700 objects touching each other is because there are no games that should have 600 to 700 physic objects in them. I guess you would need more for fluid dynamics but thats a different story. :)


Wayne(Posted 2010) [#181]
This does 150, that better ?

Include "JV-ODE.bb"

Graphics3D 1024,768,32,1

SetBuffer BackBuffer()

dInitODE()

Global World=dWorldCreate()
Global Space=dHashSpaceCreate(0)
Global ContactGroup=dJointGroupCreate(0)

dWorldSetAutoDisableFlag(World,True)

dWorldSetGravity(World,0,-1,0)
dContactSetMu(5)

; Causes objects to settle down and sleep faster
dWorldSetAutoDisableLinearThreshold (World, .1)
dWorldSetAutoDisableAngularThreshold (World, .1)
dWorldSetAutoDisableSteps (World,32)
dContactSetMaxContacts(16)
dWorldSetQuickStepNumIterations (World,16) ; default 20


Cam=CreateCamera()
PositionEntity Cam,0,5,-20

light=CreateLight()
PositionEntity light,0,10,0

Global Height

Height=Input("Tower Height:")

Dim Cubo(Height*4)
Dim CuboGeom(Height*4)
Dim CuboBody(Height*4)

Plane=CreatePlane()

dCreatePlane(Space,0,1,0,0)
EntityTexture Plane,PlaneTexture()

Counter=0	

For x=1 To Height*4 Step 4
	Cubo(x)=CreateCube()
		ScaleEntity Cubo(x),0.5,0.5,5	
	CuboBody(x)=dBodyCreate(World)	
	CuboGeom(x)=dCreateBox(Space,1,1,10)	
	dGeomSetBody(CuboGeom(x),CuboBody(x))
		dBodySetPosition(CuboBody(x),-3,0.5+(Counter*3),0)
	dGeomContactSetMu(CuboGeom(x),5)
	
	Cubo(x+1)=CreateCube()
		ScaleEntity Cubo(x+1),0.5,0.5,5	
	CuboBody(x+1)=dBodyCreate(World)	
	CuboGeom(x+1)=dCreateBox(Space,1,1,5)	
	dGeomSetBody(CuboGeom(x+1),CuboBody(x+1))
		dBodySetPosition(CuboBody(x+1),3,0.5+(Counter*3),0)
	dGeomContactSetMu(CuboGeom(x+1),5)
	
	Cubo(x+2)=CreateCube()
		ScaleEntity Cubo(x+2),5,0.5,0.5	
	CuboBody(x+2)=dBodyCreate(World)	
	CuboGeom(x+2)=dCreateBox(Space,10,1,1)	
	dGeomSetBody(CuboGeom(x+2),CuboBody(x+2))
		dBodySetPosition(CuboBody(x+2),0,3+(Counter*3),-3)
	dGeomContactSetMu(CuboGeom(x+2),5)

	Cubo(x+3)=CreateCube()
		ScaleEntity Cubo(x+3),5,0.5,0.5	
	CuboBody(x+3)=dBodyCreate(World)	
	CuboGeom(x+3)=dCreateBox(Space,10,1,1)	
	dGeomSetBody(CuboGeom(x+3),CuboBody(x+3))
		dBodySetPosition(CuboBody(x+3),0,3+(Counter*3),3)
	dGeomContactSetMu(CuboGeom(x+3),5)
	
	Counter=Counter+1
Next

	UpdateCubes()
	
While Not KeyHit(1)
	
	If KeyHit(57) Then
		For x=1 To Height*4
			dBodyAddForce(CuboBody(x),Rnd(-50,50),Rnd(-50,50),Rnd(-50,50))
		Next
	EndIf
	
	If KeyDown(200) Then
	MoveEntity cam,0,0,1
	EndIf
	If KeyDown(208) Then
	MoveEntity cam,0,0,-1
	EndIf
	If KeyDown(203) Then
	MoveEntity cam,-1,0,0
	EndIf
	If KeyDown(205) Then
	MoveEntity cam,1,0,0
	EndIf
	If KeyDown(30) Then
	MoveEntity cam,0,1,0
	EndIf
	If KeyDown(44) Then
	MoveEntity cam,0,-1,0
	EndIf
	
	dSpaceCollide(Space,World,ContactGroup)
	dWorldQuickStep(World,0.05)
	dWorldQuickStep(World,0.05)

	dJointGroupEmpty(ContactGroup)
	
	UpdateCubes()
	
	UpdateWorld()
	RenderWorld()
	Flip
Wend

dSpaceDestroy(Space)
dWorldDestroy(World)
dCloseODE()
End

Function UpdateCubes()
	For x=1 To Height*4
		PositionEntity Cubo(x),dGeomGetPositionX(CuboGeom(x)),dGeomGetPositionY(CuboGeom(x)),dGeomGetPositionZ(CuboGeom(x))
		RotateEntity Cubo(x),dGeomGetPitch(CuboGeom(x)),dGeomGetYaw(CuboGeom(x)),dGeomGetRoll(CuboGeom(x))
	Next
End Function



Wayne(Posted 2010) [#182]
Here is 500 objects !!
Had to tweek the settings some to make it interesting and run.
8)

Include "JV-ODE.bb"

;Graphics3D 1024,768,32,1
Graphics3D 640,480,32,3

SetBuffer BackBuffer()

dInitODE()

Global World=dWorldCreate()
Global Space=dHashSpaceCreate(0)
Global ContactGroup=dJointGroupCreate(0)

dWorldSetAutoDisableFlag(World,True)

dWorldSetGravity(World,0,-2,0)
dContactSetMu(5)

; Causes objects to settle down and sleep faster
dWorldSetAutoDisableLinearThreshold (World, .04)
dWorldSetAutoDisableAngularThreshold (World, .04)
dWorldSetAutoDisableSteps (World,16)
dContactSetMaxContacts(4)
dWorldSetQuickStepNumIterations (World,16) ; default 20


Cam=CreateCamera()
PositionEntity Cam,0,5,-20

light=CreateLight()
PositionEntity light,0,10,0

Global Height

Height=Input("Tower Height:")

Dim Cubo(Height*4)
Dim CuboGeom(Height*4)
Dim CuboBody(Height*4)

Plane=CreatePlane()

dCreatePlane(Space,0,1,0,0)
EntityTexture Plane,PlaneTexture()

Counter=0	

For x=1 To Height*4 Step 4
	Cubo(x)=CreateCube()
		ScaleEntity Cubo(x),0.5,0.5,5	
	CuboBody(x)=dBodyCreate(World)	
	CuboGeom(x)=dCreateBox(Space,1,1,10)	
	dGeomSetBody(CuboGeom(x),CuboBody(x))
		dBodySetPosition(CuboBody(x),-3,0.5+(Counter*3),0)
	dGeomContactSetMu(CuboGeom(x),5)
	
	Cubo(x+1)=CreateCube()
		ScaleEntity Cubo(x+1),0.5,0.5,5	
	CuboBody(x+1)=dBodyCreate(World)	
	CuboGeom(x+1)=dCreateBox(Space,1,1,5)	
	dGeomSetBody(CuboGeom(x+1),CuboBody(x+1))
		dBodySetPosition(CuboBody(x+1),3,0.5+(Counter*3),0)
	dGeomContactSetMu(CuboGeom(x+1),5)
	
	Cubo(x+2)=CreateCube()
		ScaleEntity Cubo(x+2),5,0.5,0.5	
	CuboBody(x+2)=dBodyCreate(World)	
	CuboGeom(x+2)=dCreateBox(Space,10,1,1)	
	dGeomSetBody(CuboGeom(x+2),CuboBody(x+2))
		dBodySetPosition(CuboBody(x+2),0,3+(Counter*3),-3)
	dGeomContactSetMu(CuboGeom(x+2),5)

	Cubo(x+3)=CreateCube()
		ScaleEntity Cubo(x+3),5,0.5,0.5	
	CuboBody(x+3)=dBodyCreate(World)	
	CuboGeom(x+3)=dCreateBox(Space,10,1,1)	
	dGeomSetBody(CuboGeom(x+3),CuboBody(x+3))
		dBodySetPosition(CuboBody(x+3),0,3+(Counter*3),3)
	dGeomContactSetMu(CuboGeom(x+3),5)
	
	Counter=Counter+1
Next

	UpdateCubes()
	
While Not KeyHit(1)
	
	If KeyHit(57) Then
		For x=1 To Height*4
			dBodyAddForce(CuboBody(x),Rnd(-50,50),Rnd(-50,50),Rnd(-50,50))
		Next
	EndIf
	
	If KeyDown(200) Then
	MoveEntity cam,0,0,1
	EndIf
	If KeyDown(208) Then
	MoveEntity cam,0,0,-1
	EndIf
	If KeyDown(203) Then
	MoveEntity cam,-1,0,0
	EndIf
	If KeyDown(205) Then
	MoveEntity cam,1,0,0
	EndIf
	If KeyDown(30) Then
	MoveEntity cam,0,1,0
	EndIf
	If KeyDown(44) Then
	MoveEntity cam,0,-1,0
	EndIf
	
	dSpaceCollide(Space,World,ContactGroup)
	dWorldQuickStep(World,0.02)
	dWorldQuickStep(World,0.02)
	
	dJointGroupEmpty(ContactGroup)
	
	UpdateCubes()
	
	UpdateWorld()
	RenderWorld()
	Flip
Wend

dSpaceDestroy(Space)
dWorldDestroy(World)
dCloseODE()
End

Function UpdateCubes()
	For x=1 To Height*4
		PositionEntity Cubo(x),dGeomGetPositionX(CuboGeom(x)),dGeomGetPositionY(CuboGeom(x)),dGeomGetPositionZ(CuboGeom(x))
		RotateEntity Cubo(x),dGeomGetPitch(CuboGeom(x)),dGeomGetYaw(CuboGeom(x)),dGeomGetRoll(CuboGeom(x))
	Next
End Function



Ian Caio(Posted 2010) [#183]
Thanks for the answers,

BlitzMonkey,
I agree with you, no game would need such quantity of objects, and it supported even more boxes if you think. Because for example, with a tower height of 130 there would actually be 520 cubes, because for each unit of height there are 4 boxes. But Im not actually aiming to use all of this, I was making some tests, and that happened so I was just wondering why and if there was a way to solve it.

Wayne,
Thanks a lot for the codes Wayne, and nice work, it seens to be working pretty well (:
How did you made it? I mean, I saw changes in the code, but I didnt really understand how they solved the problem.

Cya


VIP3R(Posted 2010) [#184]
Hmm, I did a little testing and it appears to be related to the type of space you use. For example, with dHashSpaceCreate(0) the tower can't be much more than a height of 500 (with Wayne's last code). However, using dSimpleSpaceCreate(0) instead will allow a tower height of 3000. Although with that many objects it's so slow it's like a slideshow. Go too far over 3000 and it crashes, I'm not sure whether it's Blitz3D or ODE crashing as there's probably a limit on Blitz entities too. It doesn't give a stack overflow though.

BTW, this code is wrong in the example above...
	dSpaceCollide(Space,World,ContactGroup)
	dWorldQuickStep(World,0.02)
	dWorldQuickStep(World,0.02)

	dJointGroupEmpty(ContactGroup)

You're missing potential collision responses between quicksteps, even though you gain accuracy by splitting them.

You have to call dSpaceCollide() and dJointGroupEmpty() for every quickstep call, like this...
	dSpaceCollide(Space,World,ContactGroup)
	dWorldQuickStep(World,0.02)
	dJointGroupEmpty(ContactGroup)

	dSpaceCollide(Space,World,ContactGroup)
	dWorldQuickStep(World,0.02)
	dJointGroupEmpty(ContactGroup)



Wayne(Posted 2010) [#185]
oh yeah, I knew I was forgetting something. 8)

3000! gads that be near earth orbit wouldn't it ?

Have to try that as I like watching the tower fall.
Thanks for building the tower caio.

I just looked, the tower build is defective, dad gum it!!
comment out the quick step and you can see it.


Wayne(Posted 2010) [#186]
Try this with 50
Added damping, and disabled bodies at set up.
Include "JV-ODE.bb"

Graphics3D 1024,768,32,1
;Graphics3D 640,480,32,3

SetBuffer BackBuffer()

dInitODE()

Global World=dWorldCreate()
Global Space=dHashSpaceCreate(0)
Global ContactGroup=dJointGroupCreate(0)

dWorldSetAutoDisableFlag(World,True)

dWorldSetGravity(World,0,-2,0)
dContactSetMu(5)

; damping this some
dWorldSetDamping(world,.05,.05)

; Causes objects to settle down and sleep faster
dWorldSetAutoDisableLinearThreshold (World, .5)
dWorldSetAutoDisableAngularThreshold (World, .5)
dWorldSetAutoDisableSteps (World,6)
dContactSetMaxContacts(10)
dWorldSetQuickStepNumIterations (World,16) ; default 20


Cam=CreateCamera()
PositionEntity Cam,0,5,-20

light=CreateLight()
PositionEntity light,0,10,0

Global Height

Height=Input("Tower Height:")

Dim Cubo(Height*4)
Dim CuboGeom(Height*4)
Dim CuboBody(Height*4)

Plane=CreatePlane()

dCreatePlane(Space,0,1,0,0)
EntityTexture Plane,PlaneTexture()

Counter=1	

For x=1 To Height*4 Step 4
	Cubo(x)=CreateCube()
	ScaleEntity Cubo(x),0.5,0.5,5	
	CuboBody(x)=dBodyCreate(World)	
	CuboGeom(x)=dCreateBox(Space,1,1,10)	;
	dGeomSetBody(CuboGeom(x),CuboBody(x))
	dBodySetPosition(CuboBody(x),-3,counter,0)
	dGeomContactSetMu(CuboGeom(x),5)
	dBodyDisable(CuboBody(x))
	
	Cubo(x+1)=CreateCube()
	ScaleEntity Cubo(x+1),0.5,0.5,5	
	CuboBody(x+1)=dBodyCreate(World)	
	CuboGeom(x+1)=dCreateBox(Space,1,1,10)	
	dGeomSetBody(CuboGeom(x+1),CuboBody(x+1))
	dBodySetPosition(CuboBody(x+1),3,counter,0)
	dGeomContactSetMu(CuboGeom(x+1),5)
	dBodyDisable(CuboBody(x+1))
	
	Cubo(x+2)=CreateCube()
	ScaleEntity Cubo(x+2),5,0.5,0.5	
	CuboBody(x+2)=dBodyCreate(World)	
	CuboGeom(x+2)=dCreateBox(Space,10,1,1)	
	dGeomSetBody(CuboGeom(x+2),CuboBody(x+2))
	dBodySetPosition(CuboBody(x+2),0,counter+1,-3)
	dGeomContactSetMu(CuboGeom(x+2),5)
	dBodyDisable(CuboBody(x+2))
	
	Cubo(x+3)=CreateCube()
	ScaleEntity Cubo(x+3),5,0.5,0.5	
	CuboBody(x+3)=dBodyCreate(World)	
	CuboGeom(x+3)=dCreateBox(Space,10,1,1)	
	dGeomSetBody(CuboGeom(x+3),CuboBody(x+3))
	dBodySetPosition(CuboBody(x+3),0,counter+1,3)
	dGeomContactSetMu(CuboGeom(x+3),5)
	dBodyDisable(CuboBody(x+3))
	
	Counter=Counter+2
Next

	UpdateCubes()
	
While Not KeyHit(1)
	
	If KeyHit(57) Then
		For x=1 To Height*4
			dBodyEnable(CuboBody(x)); Enable body so we can push it
			dBodyAddForce(CuboBody(x),Rnd(-50,50),Rnd(-50,50),Rnd(-50,50))
		Next
	EndIf
	
	If KeyDown(200) Then
	MoveEntity cam,0,0,1
	EndIf
	If KeyDown(208) Then
	MoveEntity cam,0,0,-1
	EndIf
	If KeyDown(203) Then
	MoveEntity cam,-1,0,0
	EndIf
	If KeyDown(205) Then
	MoveEntity cam,1,0,0
	EndIf
	If KeyDown(30) Then
	MoveEntity cam,0,1,0
	EndIf
	If KeyDown(44) Then
	MoveEntity cam,0,-1,0
	EndIf
	
	dSpaceCollide(Space,World,ContactGroup)
	dWorldQuickStep(World,0.1)


	dJointGroupEmpty(ContactGroup)
	
	UpdateCubes()
	
	UpdateWorld()
	RenderWorld()
	Flip
Wend

dSpaceDestroy(Space)
dWorldDestroy(World)
dCloseODE()
End

Function UpdateCubes()
	For x=1 To Height*4
		PositionEntity Cubo(x),dGeomGetPositionX(CuboGeom(x)),dGeomGetPositionY(CuboGeom(x)),dGeomGetPositionZ(CuboGeom(x))
		RotateEntity Cubo(x),dGeomGetPitch(CuboGeom(x)),dGeomGetYaw(CuboGeom(x)),dGeomGetRoll(CuboGeom(x))
	Next
End Function



Wayne(Posted 2010) [#187]
Try this at height 60

Include "JV-ODE.bb"

Graphics3D 1024,768,32,1
;Graphics3D 640,480,32,3

SetBuffer BackBuffer()

dInitODE()

Global World=dWorldCreate()
Global Space=dHashSpaceCreate(0)
Global ContactGroup=dJointGroupCreate(0)

dWorldSetAutoDisableFlag(World,True)

dWorldSetGravity(World,0,-1,0)
dContactSetMu(2)

; damping this some
dWorldSetDamping(world,.01,.01)

; Causes objects to settle down and sleep faster
dWorldSetAutoDisableLinearThreshold (World, .2)
dWorldSetAutoDisableAngularThreshold (World, .2)
dWorldSetAutoDisableSteps (World,8)
dContactSetMaxContacts(12)
dWorldSetQuickStepNumIterations (World,10) ; default 20


Cam=CreateCamera()
PositionEntity Cam,0,5,-20

light=CreateLight()
PositionEntity light,0,10,0

Global Height

Height=Input("Tower Height:")

Dim Cubo(Height*4)
Dim CuboGeom(Height*4)
Dim CuboBody(Height*4)

Plane=CreatePlane()

dCreatePlane(Space,0,1,0,0)
EntityTexture Plane,PlaneTexture()

Counter=1	

For x=1 To Height*4 Step 4
	Cubo(x)=CreateCube()
	ScaleEntity Cubo(x),0.5,0.5,5	
	CuboBody(x)=dBodyCreate(World)	
	CuboGeom(x)=dCreateBox(Space,1,1,10)	;
	dGeomSetBody(CuboGeom(x),CuboBody(x))
	dBodySetPosition(CuboBody(x),-3,counter,0)
	dGeomContactSetMu(CuboGeom(x),2)
	dBodyDisable(CuboBody(x))
	
	Cubo(x+1)=CreateCube()
	ScaleEntity Cubo(x+1),0.5,0.5,5	
	CuboBody(x+1)=dBodyCreate(World)	
	CuboGeom(x+1)=dCreateBox(Space,1,1,10)	
	dGeomSetBody(CuboGeom(x+1),CuboBody(x+1))
	dBodySetPosition(CuboBody(x+1),3,counter,0)
	dGeomContactSetMu(CuboGeom(x+1),2)
	dBodyDisable(CuboBody(x+1))
	
	Cubo(x+2)=CreateCube()
	ScaleEntity Cubo(x+2),5,0.5,0.5	
	CuboBody(x+2)=dBodyCreate(World)	
	CuboGeom(x+2)=dCreateBox(Space,10,1,1)	
	dGeomSetBody(CuboGeom(x+2),CuboBody(x+2))
	dBodySetPosition(CuboBody(x+2),0,counter+1,-3)
	dGeomContactSetMu(CuboGeom(x+2),2)
	dBodyDisable(CuboBody(x+2))
	
	Cubo(x+3)=CreateCube()
	ScaleEntity Cubo(x+3),5,0.5,0.5	
	CuboBody(x+3)=dBodyCreate(World)	
	CuboGeom(x+3)=dCreateBox(Space,10,1,1)	
	dGeomSetBody(CuboGeom(x+3),CuboBody(x+3))
	dBodySetPosition(CuboBody(x+3),0,counter+1,3)
	dGeomContactSetMu(CuboGeom(x+3),2)
	dBodyDisable(CuboBody(x+3))
	
	Counter=Counter+2
Next

	UpdateCubes()
	
While Not KeyHit(1)
	
	If KeyHit(57) Then
		For x=1 To Height*4
			dBodyEnable(CuboBody(x)); Enable body so we can push it
			dBodyAddForce(CuboBody(x),Rnd(-50,50),Rnd(-50,50),Rnd(-50,50))
		Next
	EndIf
	
	If KeyDown(200) Then
	MoveEntity cam,0,0,1
	EndIf
	If KeyDown(208) Then
	MoveEntity cam,0,0,-1
	EndIf
	If KeyDown(203) Then
	MoveEntity cam,-1,0,0
	EndIf
	If KeyDown(205) Then
	MoveEntity cam,1,0,0
	EndIf
	If KeyDown(30) Then
	MoveEntity cam,0,1,0
	EndIf
	If KeyDown(44) Then
	MoveEntity cam,0,-1,0
	EndIf
	
	dSpaceCollide(Space,World,ContactGroup)
	dWorldQuickStep(World,0.04)
	dWorldQuickStep(World,0.04)
;	dWorldQuickStep(World,0.03)

	dJointGroupEmpty(ContactGroup)
	
	UpdateCubes()
	
	UpdateWorld()
	RenderWorld()
	Flip
Wend

dSpaceDestroy(Space)
dWorldDestroy(World)
dCloseODE()
End

Function UpdateCubes()
	For x=1 To Height*4
		PositionEntity Cubo(x),dGeomGetPositionX(CuboGeom(x)),dGeomGetPositionY(CuboGeom(x)),dGeomGetPositionZ(CuboGeom(x))
		RotateEntity Cubo(x),dGeomGetPitch(CuboGeom(x)),dGeomGetYaw(CuboGeom(x)),dGeomGetRoll(CuboGeom(x))
	Next
End Function



Ian Caio(Posted 2010) [#188]
VIP3R,
I have changed the Hash space with the Simple space, looks like the hash space is faster but have this limitation, with Simple space I could create until 3000 cubes as you said (didnt tryied more than that ^^). I had a stack overflow after running for a while (with 500 cubes I guess), but I guess it was because of too much overlapping between the boxes when they were falling. I will still learn to configure the physics like you and Wayne! (:

Wayne,
My bad in the tower construction code, I knew there was something wrong ^^
Im testing and studying all the codes you are showing here, you made that little demo grows a lot. With the body disable, the damping, and the improvements in the code, its just looking great (:


Blitzplotter(Posted 2010) [#189]
Hi, wanted to try the demo but my compiler cannot find the dWorldSetDamping function - is this in a recent release of JV-ODE ? I looked at the decls and bb file and the date stamp was oct 08 despite the readme suggesting I'd v1.32 in - so I downloaded v1.32 again however the date stamps were Oct 08.


VIP3R(Posted 2010) [#190]
It was added in V1.32 (Oct 08) which is the latest version. You can view the decls using notepad, double check whether the function is listed under World Functions.

Note: The current version number of JV-ODE is always displayed at the top of the active JV-ODE thread ^ and in my sig.


Blitzplotter(Posted 2010) [#191]
Thanks for the tip, I'd the latest .decls file within the same directory as my .bb files Instead of within the Blitz3D userlibs directory. Fixed! Just crashed into the tower with my car...carnage!




Charrua(Posted 2010) [#192]
Hi

i added ode support to my AWC (a small and free world creator)
it's in an experimental phase, say: wiht bug's as always

There are 2 ode demos, will be more (hope some one send me one)
and a little lib to create the ode objects (box, sphere and cylinder at this time) and joints (hinge, hinge2, slider and Socket&Ball) from the data defined from the editor.

probably in a near future the editor has some dialog box to set/modify the joints/bodies parameters, at this stage all is very experimental and the variables are predefined to some default values, edit the awc_ode_lib.bb to meet your needs.

this is the thread for AWC
http://blitzbasic.com/Community/posts.php?topic=88756

enjoy

Juan


Blitzplotter(Posted 2010) [#193]
@Charrua, excellent world creator, Great work - movement of the lights alone is very intuitive.


Charrua(Posted 2010) [#194]
i have to confess that iim surprised whit some effects i readed but never intended to use.
In one of the demos i use a negative range for Light_Point_001 ("2 Dos.awc"), i readed about negative ranges for light but, with the editor i have the chance to see it changing dinamically. The same you can move wiht the mouse, you can Scale, in the case of a light it modifies the range.

As awc is made with blitz3d, you have a chance to see what really will happen.

I updated the awc1.zip with some bug fixed and with a new demo that has 2 doors implemented with Hinge joints.

best regards

Juan


VIP3R(Posted 2010) [#195]
I like the carnage BP :)

Thanks for posting the world creator info Juan, it's great to see it now includes ODE support.


Charrua(Posted 2010) [#196]
sorry but my english isn't good enough to understand some terms

carnage BP ?

Juan


VIP3R(Posted 2010) [#197]
Carnage = In the context of the above image it means total destruction "Just crashed into the tower with my car...carnage!"

BP = Blitzplotter

I was responding to both of you, sorry for the confusion ;)


Charrua(Posted 2010) [#198]
i didn'r read the previous post, i'm sorry!
my bad

Juan


Blitzplotter(Posted 2010) [#199]
I was looking for some code to see how fast the car was going, my kids wanted to see an indication of their speed on the 2 player postmanplat I've been working on. Found exactly what I needed in thread 11, there is some fantastic resources within the JV-ODE threads.


VIP3R(Posted 2010) [#200]
They are indeed ;)

THREAD 12 IS ABOUT TO CLOSE

Please continue on the new thread located here

Thanks :)