Newton 2 wrapper

Posted By: VeT

Newton 2 wrapper - 07/30/08 14:22

[this post is updated]
This is Newton topic and here you would be able to find latest update links and all info about Wrapper and Newton



Latest Litec+Newton version(23): here
First Newton manual (launching Newton with your project): Source, Source v2, English manual, Russian manual

Current Newton version: 2.10
Current Wrapper version: 23

Some info about "PhysX vs Newton" :
Here is my PMs with Julio, the creator of Newton:

Quote:

Julio:

Plus I am also adding eth CUDA support so the next Beta will come with Hardware simulation on GPU.
Therefore it will provide the same level of mass physics simulation as other commercial engine but with a real newtonian base physics engine like ODE, as opposed to a Impulse base Physics engine like all the others.

There are many, many reasons why a force based engine is far superior than a impulse base, although it have to be slower by nature, but as you can see Newton 2.0 is quite competitive.

VeT:

also, can you give me more details about impulse and force-based physical engine?

Julio:

Impulase base for force base p[hysic sare teh tow diffrent metod to make physis simulation.

Impulse was proposed by Brians Mirtich
http://www.kuffner.org/james/software/dynamics/mirtich/index.html

and force base was propose by Davif Baraff
http://www.cs.cmu.edu/~baraff/papers/sig96.pdf

Impulse base very eassy to implement and is the methed used by Physx and Havok, it is also the method used by open source since they are all biproduct of Havov and PhyiX written by ex employee that when they leave the company use and older copy and re write as open source.

the problem with open source is the teh are incorrect since they violate a physics principle that state that and impulse can only be appliyed at and infinitesimal small period of time.
They apply impulse an dintegrate then as if tehey where forces, theyfor tehy are unstable and thsi si whay you see hundere of paore teh try to sov eteh problems.

Force base implementation are base on rigurose law of physics call the method of the virtual work, they are harder to solve but the are more stable and have the ability that the same solver solve all know rigid body problems.

Posted By: VeT

Re: Newton 2 wrapper - 07/30/08 15:24

Screenshots:
1) First level

2) Restitution demo

3) Friction demo

4) Cone demo

5) Scale demo

6) Grabbing demo

Posted By: BigM

Re: Newton 2 wrapper - 07/30/08 16:53

Bigm, sorry, but forum doesnt allow more that 6 pics in one post

7) Step-by-step creation

8) Explosion

9) Static bodies

10) Power mouse

11) Crash test

12) Impulse weapon demo

Posted By: VeT

Re: Newton 2 wrapper - 07/30/08 17:00

13) Collisions and sound

14) Byouancy

15) Compound collision demo

16) Simple joints, rope

Posted By: VeT

Re: Newton 2 wrapper - 07/31/08 07:45

here is first version, just a ball falling on ground
http://hosted.filefront.com/NeArGa/

i'm working on second version, trying to enable debug display
Posted By: VeT

Re: Newton 2 wrapper - 07/31/08 10:04

Second version is uploaded: here i include newton_debug.c and update newton_debugdisplay();
Posted By: msl_manni

Re: Newton 2 wrapper - 07/31/08 10:48

Cant download from filefront. Please give a rapidshare or other link.
Posted By: VeT

Re: Newton 2 wrapper - 07/31/08 10:52

here it is, v2
http://www.rapidshare.ru/744419
Posted By: msl_manni

Re: Newton 2 wrapper - 07/31/08 11:21

Thanks for the link.
Posted By: VeT

Re: Newton 2 wrapper - 07/31/08 11:33

you're wellcome smile

in v3 i'm going to fix bug in newton_stop - its seems that that function dont realise all memory, because NewtonGetMemoryUsed returns non-zero value
Posted By: VeT

Re: Newton 2 wrapper - 07/31/08 13:21

v3
- added body destructor, onsetdestructor (looking like solve memory problem)
- added AutoSleep, wich set/resets AutoSleep to all bodies
- updated newton_debugdisplay, now dont operate with objects with infinity mass(static) and "sleeping" bodies

finished and uploaded


PS: i'm making so many versions because i'm leaving my city for some weaks, so i want to make as much as possible
Posted By: VeT

Re: Newton 2 wrapper - 08/01/08 11:53

v.4
- added ShowContacts - for contacts debugging
- added map10 with 7 bodies different shapes
- start with materials


Posted By: ventilator

Re: Newton 2 wrapper - 08/01/08 12:00

sounds great! i still had no time to have a look but i am looking forward to it...
Posted By: VeT

Re: Newton 2 wrapper - 08/01/08 12:18

sorry, but i use your models blush
Posted By: VeT

Re: Newton 2 wrapper - 08/01/08 14:34

v.5
- added terrain as model on map10 level
- added Elasticity demo on map11 level - wrapped from Newton's BasicRestitution.cpp
- used skill99 in Elasticity demo


terrain:



Elastisy demo:

Posted By: VeT

Re: Newton 2 wrapper - 08/01/08 14:56

people, nobody needs this wrapper?
where are your comments, wishes and recomendation? smile
Posted By: Quad

Re: Newton 2 wrapper - 08/01/08 15:16

nice progress. keep it up.

v5: crash in quit if you close the window by clicking the x(top right)
Posted By: Spirit

Re: Newton 2 wrapper - 08/01/08 15:18

This is definitly one great wrapper! I also have the close crash but I believe that was version v.2. Do you have a download link already for v.5?
Posted By: JackShephard

Re: Newton 2 wrapper - 08/02/08 17:08

Nice work VeT =)
Posted By: croman

Re: Newton 2 wrapper - 08/02/08 18:12

really great and needed wrapper. keep up the good work and keep us posted as you did so far
Posted By: VeT

Re: Newton 2 wrapper - 08/03/08 06:23

thats better, thanks for answers smile

Spirit, yes, in http://hosted.filefront.com/NeArGa/ v.5 is uploaded, now i'd try to fix crash and add something else in v.6 wink
Posted By: VeT

Re: Newton 2 wrapper - 08/03/08 09:38

ehh.. as usual, not enough time frown
i'd continue this when i'd be back, dont think i abaddon this project - its very importaot for my game, so i'll be back soon wink
Posted By: VeT

Re: Newton 2 wrapper - 08/03/08 10:27

btw, Quadraxas, what about exiting on Esc
Posted By: VeT

Re: Newton 2 wrapper - 08/03/08 10:40

i got a question about how many time i need to finish warpper, so i decided to answer here... so


generaly, main part of wrapper was completed in 1-st demo: i rewrote header for lite-c, so main work is done

i'm going to village till 25-th of august... i planned to take notebook here and work here, but there are some troubles, so i'm going here without it...:(


i'd like to repeat that project isnt abaddoned anyway, because i really need it for my game

about time - i want to wrap 12 levels from originally newton (i already have a list of levels), so it would take about 2 weeks + player phisic(2-3 days) + maybe car(also 2-3 days)... thats for 2.16, if new version would realised, i'd need some days more to implement new features

in summ, there are 3 weeks, + september(institute), so about month to finish
of course, i'd add new versions every day(and would try to add some versions per 1 day) as i'd return
Posted By: croman

Re: Newton 2 wrapper - 08/03/08 10:42

laugh great
Posted By: Quad

Re: Newton 2 wrapper - 08/03/08 11:00

Originally Posted By: VeT
btw, Quadraxas, what about exiting on Esc


it's fine, no crash.
Posted By: VeT

Re: Newton 2 wrapper - 08/03/08 11:06

hmm, interesting...
okay, i have one idea...
Posted By: msl_manni

Re: Newton 2 wrapper - 08/03/08 11:08

Please post rapidshare links too, as filefront links dont work for me. I am unable to download from filefront. Thanks in advance.
Posted By: croman

Re: Newton 2 wrapper - 08/03/08 11:10

you just need to wait on filefront. every 10 seconds filefront retries to download that file. just leave filefront open for few minutes and your download will start
Posted By: VeT

Re: Newton 2 wrapper - 08/03/08 11:20

anyway, here it is smile
http://www.rapidshare.ru/746645
Posted By: picoder

Re: Newton 2 wrapper - 08/17/08 17:11

thanks for Newton 2.16 wrapper.
Posted By: Trooper119

Re: Newton 2 wrapper - 08/18/08 18:03

Wrong forum, needs to go into one of the scripting help forums.

Please move.
Posted By: VeT

Re: Newton 2 wrapper - 08/25/08 10:26

heh, now i'm back, unpacking and starting to work wink

song of the day:
http://tinyurl.com/5mg2bm
smile
Posted By: VeT

Re: Newton 2 wrapper - 08/25/08 11:20

btw, i still didnt deal with custom joints, but i'd do it in future smile
Posted By: ventilator

Re: Newton 2 wrapper - 08/25/08 11:30

i think there is a tutorial about custom joints on the newton wiki. custom joints are very powerful if you know how to use them! smile
Posted By: picoder

Re: Newton 2 wrapper - 08/25/08 14:02

I haven't noticed this tutorials on the newton wiki. I will check them.

Thanks for your response. smile
Posted By: VeT

Re: Newton 2 wrapper - 08/25/08 21:00

http://newtondynamics.com/wiki/index.php5?title=Joints
here it is, as i understand(old wiki is not available)
Posted By: VeT

Re: Newton 2 wrapper - 08/27/08 20:11

okay, while forum was down, i added 2 new versions: 6 and 7

v.7
- added map13 - Cone rotating demo

v.6
- added map12 - Friction demo- wrapped from Newton's BasicFriction.cpp

Screenshots:

map12, Friction


map13, Rotating cones

Posted By: VeT

Re: Newton 2 wrapper - 08/28/08 00:00

now i'm working on Compound shapes, but this would be primary my own code and ideas(how to create easily Compounds in Gamestudio), so this level (map50) is "secret place" laugh , it would be shown on next contest(if contest would take place)

for next public release i have another idea to implement... so just wait a little till tomorrow wink
Posted By: amy

Re: Newton 2 wrapper - 08/28/08 12:50

Nice job! smile This wrapper will be an awesome contribution.
Posted By: VeT

Re: Newton 2 wrapper - 08/29/08 10:59

thanks smile

v.8
- added map14 - Scaled Collision demo - wrapped from ScaledCollision.cpp



i'm waiting for your comments and wishes: i have a to-do list, but i also want to know, what is needed for users (ragdoll, car and custom joints would be a little later wink
Posted By: BigM

Re: Newton 2 wrapper - 08/30/08 10:00

Hi! Great, great work!

I though you were just going to provide the API functions and little else. Extras like pre-made custom joints and the like (compound collision hulls, YES!!) are awesome and will save 3DGS users lots of work and debugging.

I stumbled across a bug, however. You said earlier you had to have a destructor because of memory issues. The problem is that there is a call to NewtonDestroyBody inside the destructor callback. It will recur and crash (stack overflow?).

I'm working with v5 of the wrapper. Sorry if this has been fixed later but I have no time to check it.

Skipping the destructor assignment works well, as well as just commenting out the NewtonDestroyBody call within the destructor. Is it really necessary to have a destructor? In the corrected case it just calls ent_remove; I usually call ent_remove along with the body destruction anyway but if there are performance issues I will keep the destructor.

Cheers!
Posted By: VeT

Re: Newton 2 wrapper - 08/30/08 14:19

greetings

yes, now i'm working now on compounds, but have some problems there...

okay, what about destructor.. i made some tests and must to say that you are right, engine craches if i remove entity
after several tests, i change code to this:

here is new destructor
Code:
void onsetdestructor(NewtonBody *body)
{
	ENTITY *entity = (ENTITY*)NewtonBodyGetUserData(body);
	if (entity) {ent_remove(entity);}
}


here is a process of destruction
Code:
if (key_x)
{
if (my.skill99!=0) {NewtonDestroyBody(nworld,(NewtonBody*) my.skill99);}
}


i think, its the best and simplest way: graphical entity is removed in destructor of newtons body, so we just may delete only NewtonBody
destructor would be changed in v.9

why dont you download the last versions: i added only new levels, but the core of wrapper is unchanged(till now :))

anyway, thanks for gelp in debuging wink
Posted By: BigM

Re: Newton 2 wrapper - 08/30/08 20:33

Glad I could help. I began the transition to newton 2.0 last week and have run into some trouble; as I debug I will post here the wrapper specific problems I find.

I will use the later wrapper versions; however, changing versions is not that simple in my case as I have some custom changes made to newton_main.c (time slicing, for example) and have to copy/paste some code when updating.

Keep up the good work!
Posted By: picoder

Re: Newton 2 wrapper - 08/30/08 21:54

Nice job VeT!

Keep up the good work!
Posted By: VeT

Re: Newton 2 wrapper - 08/31/08 10:54

BigM, try to use Total Commander's "Compare files by content", that could help you... you may just compare old newton_main.c and new one... its looking like this
http://img192.imagevenue.com/img.php?image=32924_1_122_107lo.JPG

i'm going to uplate to 2.0 (17 beta) after wrapping compounds and magnets(black/white hole and buoyansy)

picoder, thanks for comment smile
Posted By: BigM

Re: Newton 2 wrapper - 08/31/08 21:34

Thanks, will do that.

Actually there are not that many changes: mostly I changed the NewtonUpdate call. If you find any of this interesting please add it to the wrapper:

Code:
void newton_start()
{
	newton_running = 1;
	nworld = NewtonCreate(0, 0);
	
	newton_addstaticcollisiongeometry();
	
	while(newton_running) // newton has to update every frame
	{
		advance = time_frame/16;
		slices = integer((advance / MIN_NEWTON_ADVANCE) + 1);

		for (slices_left = slices; slices_left > 0; slices_left--){
			NewtonUpdate(nworld, advance/slices);
		}
		wait(1);
		proc_mode = PROC_LATE;	

	}
}


I implemented time slicing because I wanted precise control over the fineness of the simulation and felt NewtonSetMinimumFrameRate didn't work quite like I expected back in newton 1.53. Maybe this is useless now.

I also set proc_mode to PROC_LATE: this way the simulation is performed right after the main cycle, instead of before. I believe this way to be better as the time_frame value used in calculations in main() (in my case acceleration calculations based on user input) refers to the same frame as the time_frame used to compute the update time.

Hope this are useful 2 cents! Please let me know what you think.
Posted By: VeT

Re: Newton 2 wrapper - 09/02/08 07:44

sorry for silence: i was playing "Stalker: clear sky" for some eveings and nights blush

thanks for help, i'd test your code and would add it to v9
Posted By: VeT

Re: Newton 2 wrapper - 09/02/08 08:39

okay, and what is MIN_NEWTON_ADVANCE ?
Posted By: BigM

Re: Newton 2 wrapper - 09/02/08 21:34

Sorry, I now realize that the name is mischosen: it should be called MAX_NEWTON_ADVANCE! :P

Anyway, this define is a value for the largest step that Newton is allowed to perform.

Setting a minumum rate with NewtonSetMinimumFrameRate should have the same effect but in 1.53 I found it to behave a little different than expected.
Posted By: VeT

Re: Newton 2 wrapper - 09/02/08 21:58

hmmm.. not MAX_NEWTON_ADVANCE nor MIN_NEWTON_ADVANCE declared by default... how do you get it in your code? smile
Posted By: VeT

Re: Newton 2 wrapper - 09/03/08 10:14

sorry, there weren't releases for a long time: now i have some hard work with compound objects wink
Posted By: Christian__A

Re: Newton 2 wrapper - 09/03/08 11:47

Great job, I will test your wrapper later. I have looked over the newton-files and i looks like you didn't implement the vehicle function yet. It would be great if you could face this next.
Posted By: VeT

Re: Newton 2 wrapper - 09/03/08 12:28

no, vechile would be later, now i'm finishing my work on compounds, and working with arcimedian buoyancy.. after them there would be joints and vechile smile
i think, in a week or two, it would be ready wink
Posted By: BigM

Re: Newton 2 wrapper - 09/03/08 21:44

Sorry, I don't have much practice at quoting code...

I'm defining MAX_NEWTON_ADVANCE earlier in the code:

Code:
#define MAX_NEWTON_ADVANCE 0.01


Do you think this kind of time slicing is useful for the wrapper?
Posted By: VeT

Re: Newton 2 wrapper - 09/03/08 23:22

heh, i send you pm and didnt see your message smile

i'd try to test ever time slicing wich i could find: in my previous demo, boxes falled like in water, too slow... maybe this could help, i'd see..
Posted By: VeT

Re: Newton 2 wrapper - 09/04/08 08:35

fitst, can you tell one more time, why you are using proc_mode = PROC_LATE; ?
in this way all grapfical entities are moving a little bit "after" then physical bodies, where is the "plus" of this method? smile

second, using "slices" would be good for "slow-mo", i think smile
i tried another variables(not 0.01, but 1 or 1000), but i dont see any difference between this, so i'll think about your formula
Code:
int advance = time_frame/16;
		int slices = integer((advance / MAX_NEWTON_ADVANCE) + 1);
		int slices_left;

		for (slices_left = slices; slices_left > 0; slices_left--){
			NewtonUpdate(nworld, advance/slices);
		}

Posted By: VeT

Re: Newton 2 wrapper - 09/04/08 08:38

okay, what about my part of work - i had a lot of troubles with compounds, but i'm still work hard on them...
Posted By: BigM

Re: Newton 2 wrapper - 09/04/08 09:41

Ok, regarding proc_mode = PROC_LATE:

The way I understand the engine processes stuff normally (without setting proc_mode) is by processing each loop that is waiting in the order in which they appear. So the first is the newton update loop and second the loop in main. Afterwards the engine will update the screen.

1- newton update loop
2- main loop
3- update screen

I understand that the time variables are relative to the period between screen updates, so, at any given point in the code execution, time_frame will always refer to the time between the previous two screen updates.

A (usually small) problem arises when you use the loop in main to calculate something that will be used in the newton simulation. Take, for example, a reaction to a mouse displacement that I want to convert into a target velocity and a required acceleration:

Code:
target_velocity = mickey.y/(time_frame/16)
acceleration = (target_velocity - actual_velocity)/(time_frame/16)

I then apply the required acceleration in a newton callback. However, because the NewtonUpdate loop is updated first, it will have access to a brand new time_frame value, which differs from the one used to calculate the desired acceleration. The result is that the body will be accelerated for a different time period and have a final velocity different from what is expected.

By moving the newton update loop to last you can be sure that not only it is more in sync with what is processed in main, but you also get a marginally faster response to input (user moves mouse and sees result in the following screen update instead of having to wait for two screen updates). Of course I could move the whole calculation process inside the callback and it would be ok then, but I think that is besides the point as other kinds of calculations might not be feasible in the callback, especially if it is something heavy and you donīt want to repeat it for all sub updates newton may have to perform.

This is how I interpret the flow of the engine, and indeed, in my case, the differences between desired velocities and resultant velocities did get smaller. Maybe someone has something to add/correct.
Posted By: VeT

Re: Newton 2 wrapper - 09/04/08 19:18

Quote:

I then apply the required acceleration in a newton callback.

damned, so you again put not all code? laugh can you give me all code to see, how youe slicing works, because i like your idea, but code that you wrote dont works for me..
Posted By: BigM

Re: Newton 2 wrapper - 09/04/08 23:31

I am using the user input to move a corkscrew joint. This worked in 1.53; I'm not sure it works with 2.0 - a lot other bugs popped first and I haven't been able to properly test this part.

I haven't looked up whether joint specific functions like NewtonCorkscrewGetJointVeloc are the same in 2.0 or if the callback is still passed a NewtonHingeSliderUpdateDesc argument.

Initialization of the corkscrew joint elements:
Code:
thing = ent_create("model.mdl", vector(0, 1, 1), NULL);
nthing = newton_addentity(thing, .05, NEWTON_CONVEXHULL, NULL);

joint = NewtonConstraintCreateCorkscrew (nworld, vectorf(0, QUANTTOMETER*1, QUANTTOMETER*1), vectorf(1, 0, 0), nthing, NULL); //no need for an actual second body
NewtonCorkscrewSetUserCallback(joint, movement_callback);

In the user input loop in main:
Code:
sensitivity = 0.005; //this is used to scale the mouse movement to acceptable velocities.
actual_velocity = NewtonCorkscrewGetJointVeloc(joint);
target_velocity = mickey.y * sensitivity /(time_frame/16) //mickey.y is given by the engine
acceleration = (target_velocity - actual_velocity)/(time_frame/16)

In callback:
Code:
movement_callback (const NewtonJoint* joint, NewtonHingeSliderUpdateDesc* desc){
  desc[0].m_accel = acceleration; //the NewtonHingeSliderUpdateDesc struct was provided, as is, by the wrapper in 1.53
  retCode |= 1; //or with 0x01 to tell newton this axis is active. Don't know if it is still required in 2.0
}


Hope this clears things up! Anyway, the concept of using PROC_LATE does not depend on any actual implementation of user input processing or callback code: time_frame values used in main and in callbacks will be different if there is a screen update in between.

The slicing woks exactly as you re-wrote, but don't cast advance as an 'int'; it must be a 'float'. The objective is that you gain control of how many times Newton is updated and how long the slices are. The NewtonSetMinimumFrameRate function let you set the same limit; however, in my case, it turned out that the several sub-splittings automatically made by the newton engine would not add up to the passed update time, and so I created my own slicing.
Posted By: Christian__A

Re: Newton 2 wrapper - 09/06/08 14:32

I have seen you are using "ent_getmatrix" in the script, but i have no idea where this function is defined?
Posted By: VeT

Re: Newton 2 wrapper - 09/06/08 21:05

Christian__A, in matrix.c, try to use Ctrl+Shift+F to search in folder wink

BigM, i'd try this in nearly half of hour smile
Posted By: VeT

Re: Newton 2 wrapper - 09/07/08 00:10

v.9
- updated to Newton 2.17
- updated onsetdestructor
- added example of safely removing of body on level map10(if you press X, sphere deletes)
- added pause of Newton on key_P
- found and fixed error in NewtonAPI2.16.c (after converting to NewtonAPI2.17.c, fixed in both)
- working on compound collition(map50)
- working on magnets(map15)


BTW, there were 12 template versions (8.1 - 8.12)
Posted By: VeT

Re: Newton 2 wrapper - 09/07/08 09:59

BigM, your example crashes in callback... (retCode is commented as no need),but i understood your idea smile
i'd try to add "force mouse" that would allow user to move physical bodies
Posted By: VeT

Re: Newton 2 wrapper - 09/07/08 11:14

oops, i found bug in v.9, so i decide to wrap quickly one of the simplest examples, but with comments in every step


v.10
- found bug in map11 with uncorrect action name, fixed
- added map16 - Customizing Sphere(step-by-step creation of body) - espeshially for beginners wink

yes, i forgot to say that i wouldn't going to wrap levels like "tower" or "pyramide" as they are usefull only as demonstration of NewtonPlayGround, i dont think that they include nessesary and new info for users... but if somebody wants to see level like this in Gamestudio, you can write to me smile
Posted By: Christian__A

Re: Newton 2 wrapper - 09/07/08 14:28

Great, i'm just downloading the your new version.
Posted By: VeT

Re: Newton 2 wrapper - 09/07/08 20:39

you're wellcome, i'm waiting for bugs report wink
Posted By: Christian__A

Re: Newton 2 wrapper - 09/08/08 07:38

No real bugs found until now smile But i've tried to get the vehicle-functions from the joint-lib working (which should not be a realy problem as the header is Lite-C-friendly). I'm creating a CustomJoint with CreateCustomMultiBodyVehicle, but as soon i try to add wheels with CustomMultiBodyVehicleAddTire, the vehicle body disapears. I've postet this problem also in the newton forums as i don't think it is a problem with the wrapper: http://newtongamedynamics.com/forum/view...8c4620e122e1652
Posted By: VeT

Re: Newton 2 wrapper - 09/08/08 09:42

i'm planing to end with magnet, buoyancy and compounds and would go to joints smile
i answered to your topic

btw, look here, maybe this would help
http://www.newtondynamics.com/forum/viewtopic.php?f=9&t=4612
Posted By: VeT

Re: Newton 2 wrapper - 09/14/08 15:24

i noticed, that i didnt add new versions... so i quickly added crash-test level, it would be interesting to see, how many FPS any of you have


v.11
- added map20 - crash-test, with 100 entities(5*5=25 genetators, each generate 4 ball), i got about 100 fps
- numbers of entities changes in line 72, map20_ents=200; number must divide by 25(for example, 100, 150, 200, 500), or rounded value used


i have 100 fps with 100 objects and 5-6 fps with 500 objects(fps counted while all balls are falled down and mixed like here)

Posted By: Quad

Re: Newton 2 wrapper - 09/14/08 15:58

very nice.

tried with 3k(60 each) ents and got 4 fps laugh
Posted By: VeT

Re: Newton 2 wrapper - 09/14/08 17:33

heh, my dream... smile
http://www.youtube.com/watch?v=6Krndrq4Brk&feature=related
and
http://www.youtube.com/watch?v=EBaFUie70Uo&feature=related
Posted By: VeT

Re: Newton 2 wrapper - 09/18/08 21:55

damned, i have too many work to do not olny with Newton, but i promice that at the contest i'll show you everything :)))
Posted By: Felixsg

Re: Newton 2 wrapper - 09/26/08 23:32

like to see work's
Posted By: VeT

Re: Newton 2 wrapper - 09/28/08 23:12

in 2 or 3 days i'd try to make final build without joints(black/wite hall, buoyancy) and come to joints library wink
Posted By: Chris3D

Re: Newton 2 wrapper - 10/03/08 10:50

Hi Vet! great work! But I got a crash if I close the window, you should use "on_exit = quit;" instead of "on_close" in the main.c .

Greetings

Posted By: VeT

Re: Newton 2 wrapper - 10/08/08 14:30

yeah, thats it :)))
Posted By: VeT

Re: Newton 2 wrapper - 10/10/08 14:10

v.12
- changed include-files in main.c (newton_materials.c and newton_main.c)
- optimised matireals a little: moved them from map11.c and map12.c to newton_materials.c
- added map18 - 2 methods of creation static bodies



i got a lot of troubles with Bouyancy, so, maybe, i'd proceed to more interesting part: joints wink
Posted By: WRobN

Re: Newton 2 wrapper - 10/13/08 19:34

HELP!

When i open main.c it fails to load the level.
2 error messages;

Malfunction W1301
<MAP10.WMB>: Can't open file

Error E1100
<map10.wmb>: Can't open level

All other maps give the same errors
Posted By: Quad

Re: Newton 2 wrapper - 10/13/08 20:48

you have to compile the maps.
Posted By: VeT

Re: Newton 2 wrapper - 10/13/08 23:07

Chesk paths: all maps are compiled and are in "levels" folder. Or try to move map10.wmb directly to the work folder
Posted By: WRobN

Re: Newton 2 wrapper - 10/17/08 07:57

I have problems with the workshop 20 (lite-c) as well, so maybe a reinstall will sort things out.
At least i hope so.

link to post

Its weird that its only me having those problems...

The stupid part is that other examples/workshops/etc simply load and do their thing while workshop; script20.c and these Newton 2 wrapper cause me trouble.
Posted By: VeT

Re: Newton 2 wrapper - 10/20/08 22:09

looking like offtopic
Posted By: VeT

Re: Newton 2 wrapper - 11/02/08 11:49

okay, here i am... there are 2 weeks to the end of contest, so i may to start this work more active wink
Posted By: Felixsg

Re: Newton 2 wrapper - 11/04/08 11:22

I like to see more fuctions (like car)
Posted By: VeT

Re: Newton 2 wrapper - 11/05/08 11:11

vechiles are already at my "todo" list wink
Posted By: VeT

Re: Newton 2 wrapper - 11/07/08 16:05






- added map19.c with pyramid of boxes
- added "power mouse", it would be used for moving objects
- added visualisation of normals, when "power mouse" is active
- added visualisation of direction
- commented a part of visualistion

i managed with moving target point of model with it, but i cant finish moving point with rotating body, so now i commented the largest part



PS: while testing, i noticed some "prototype" error.. it appears to be only at first launch, but i dont know how to deal with it

Posted By: VeT

Re: Newton 2 wrapper - 11/09/08 18:11

nobody likes this?
Posted By: Felixsg

Re: Newton 2 wrapper - 11/10/08 09:09

I have 7.50 pro but for me not work not reconigse
the funtions of the mouse
Posted By: Sajeth

Re: Newton 2 wrapper - 11/10/08 16:27

Thank you, good sir.
This is true epicness.
Posted By: Anonymous

Re: Newton 2 wrapper - 11/10/08 18:45

This is great, but mouse control also doesn't work for me.
Posted By: VeT

Re: Newton 2 wrapper - 11/11/08 08:34

thats good to see that somebody need this smile
i wrote that version on lite-c free, but its seems that i i'd reinstall windows and inatall trial version again
Posted By: RyuMaster

Re: Newton 2 wrapper - 11/11/08 13:59

Thanks a lot, I'll try using this wrapper in my game and see how it works!
Posted By: VeT

Re: Newton 2 wrapper - 11/11/08 21:51

i'd like to know, how sucsessful you use it and what do you whant to get smile
Posted By: Sajeth

Re: Newton 2 wrapper - 11/12/08 10:49

Cant get mouse control to work, also map 16 doesnt work.
Posted By: VeT

Re: Newton 2 wrapper - 11/12/08 23:33



v.14
- added menu.c, its menu on the left side, from it you can load level that you need
- made some changes in the structure of main functions of newton wrapper, so now it supports loading different levels one after another in runtime
- fixed map16.c



friends, dont forget about new controls:
Controls

F11 - GS debud mode
F12 - Newton Debug mode
P - pause
M - show/hide "sleep" objects in Newton Debud mode
Space - enable/disable "power mouse"
Left Mouse - grab entity

Menu:
R,F or cursorUp/Dn - select levels
Enter - load level
Posted By: VeT

Re: Newton 2 wrapper - 11/13/08 12:01

i tested all levels on lite-c free, they are working good for me... exept one "empty prototype" error, wich apperas only first time
Posted By: Uhrwerk

Re: Newton 2 wrapper - 11/13/08 14:26

It's getting better and better, VeT. Greate work!! :-)
Posted By: VeT

Re: Newton 2 wrapper - 11/13/08 19:00

thank you smile
i have some surprises for contest and now hardly work on them wink
Posted By: VeT

Re: Newton 2 wrapper - 11/14/08 20:35

okay, the final version is out smile



here are the changes wink

v.15
- added some scripts from my project, newton_explosion.c. they are show how to use Newton closely with GameStudio
- changed map17.c, from magnet to grenade
- different bodies get different forces after explosion(this consists of the second parameter of EnableExplosion() function )
- found and fixed bugs on map17.c, the map is also changed
- menu disabled, instead of it changelist is made
- made again some changes in the structure of main funtions
- fixed map18.c, trying to avoid "prototype" error
- added text on 2 boxes in map18.c
- added map21, here you can see demo of the impulse weapon (just look at any moveable entity and press left mouse key)
- added some new models, made by the artist from our project
- added detail info to the every level
- added one of the mainest features: map50.c - this contains fully worked compounds
- added newton_compound.c - helper of the map50.c
- fixed newton_debugdisplay for multilevels
- hide debug panel
- tested a lot smile
Posted By: Quad

Re: Newton 2 wrapper - 11/14/08 21:13

wow lots of improvement laugh im checkin them out.
Posted By: VeT

Re: Newton 2 wrapper - 11/14/08 21:22

yeah, i worked hardly last days wink
also, i added some scripts from my project, so ready for action smile laugh
Posted By: Vadim647

Re: Newton 2 wrapper - 11/14/08 21:25

Nice work.
I bet you are entering something containing both Newton and explosions :P
Posted By: VeT

Re: Newton 2 wrapper - 11/14/08 21:29

download and watch it by yourself wink
Posted By: Quad

Re: Newton 2 wrapper - 11/14/08 22:24

explosions are awesome laugh nice asd always.


p.s. it crashes if i click after loading 12. impulse weapon.

(acknex.exe stopped working)
Posted By: VeT

Re: Newton 2 wrapper - 11/14/08 23:14

looking like i found, why its crashes.. i'd try to reload release before it goes to contest smile
Posted By: Anonymous

Re: Newton 2 wrapper - 11/14/08 23:16

yeah map 12 also crashes for me.
This is really great.
I will maybe use it in my project.
Do you also plan to implent a function so the newton bodies are also saved by gamestudio's savesystem...?
Posted By: VeT

Re: Newton 2 wrapper - 11/14/08 23:29

cuted down map12(as it still crash, after some changes), reuploaded new version

for the nearest future i plan to work on joints(for a little) and on person's physic. After that i'd look, what i can do with the savegames, so i dont think its too far wink
Posted By: Quad

Re: Newton 2 wrapper - 11/14/08 23:32

yes joints,vehicles,ragdolss laugh yaaaaaaay.

thanks for,Great effort
Posted By: VeT

Re: Newton 2 wrapper - 11/14/08 23:36

yes, thats possible wink

also, maybe, some cloth and soft bodies.. theoretically i know, how to do that, but... smile


its good to know that people like my work smile



decided to copy topic about release on the new page



here are the changes wink

v.15
- added some scripts from my project, newton_explosion.c. they are show how to use Newton closely with GameStudio
- changed map17.c, from magnet to grenade
- different bodies get different forces after explosion(this consists of the second parameter of EnableExplosion() function )
- found and fixed bugs on map17.c, the map is also changed
- menu disabled, instead of it changelist is made
- made again some changes in the structure of main funtions
- fixed map18.c, trying to avoid "prototype" error
- added text on 2 boxes in map18.c
- added map21, here you can see demo of the impulse weapon (just look at any moveable entity and press left mouse key)
- added some new models, made by the artist from our project
- added detail info to the every level
- added one of the mainest features: map50.c - this contains fully worked compounds
- added newton_compound.c - helper of the map50.c
- fixed newton_debugdisplay for multilevels
- hide debug panel
- tested a lot smile
Posted By: TechMuc

Re: Newton 2 wrapper - 11/15/08 17:06

i like it very much, thank you!

The impulse weapon demo is crashing for me, when click on an entity frown
Posted By: VeT

Re: Newton 2 wrapper - 11/16/08 14:28

in the last demo there isnt impulse weapon because of crashes wink
Posted By: MattyTheG

Re: Newton 2 wrapper - 11/16/08 19:17

Do I need to install Newton to a certain directory to make this work? I downloaded Newton and installed to the default directory but when I run your scripts I get a "crash in ball_newt()" for every shape really.

I am trying to use Newton instead of the ODE since it isn't working the way I want it to, so any help is greatly appreciated.
Posted By: VeT

Re: Newton 2 wrapper - 11/16/08 19:35

No, all what you need is included. Is EXE-file from my wrapper launched normal?

Maybe you use another, old version of Newton dll, as they are not capable with each other.
Posted By: MattyTheG

Re: Newton 2 wrapper - 11/16/08 21:46

Haha wow, I didn't realize there was a main.exe I was just trying to launch the main.c, thanks for the help.
Posted By: VeT

Re: Newton 2 wrapper - 11/16/08 22:13

you're wellcome wink

but this sont solve trouble, what edition do you use? i compile under lite-c... i'd check this with A7-trial version (and, maybe, with pro in future laugh )
Posted By: flits

Re: Newton 2 wrapper - 12/05/08 14:33

i have the same trouble but tryed out why it dint work and it was this line

NewtonBodySetAutoFreeze(body, 1);

hoop you can find the problem
Posted By: croman

Re: Newton 2 wrapper - 12/06/08 18:07

hey VeT, your wrapper looks and works great.

do you have any plans on creating a vehicle example, vehicle map? and when? smile
keep up the good work!
Posted By: VeT

Re: Newton 2 wrapper - 12/06/08 18:23

of cource wink
for now i'm planning to spent some time in Institute, as exams are not far laugh , after that, i'd try to fix some known bugs, that people send me in PMs... i'd be glad to get as much reports as possible from you, dear users smile
Posted By: VeT

Re: Newton 2 wrapper - 12/06/08 21:50

flits, what type of problem do you have, repeat one more time, please smile
Posted By: flits

Re: Newton 2 wrapper - 12/06/08 22:04

if i run your exe the game runs fine

if i run the main.c the game crashes

if i remove this line:
NewtonBodySetAutoFreeze(body, 1);
the game runs fine again

so i dont know the exact problem but there is somthing that is in conflict white my comp / gs version / windows version
Posted By: VeT

Re: Newton 2 wrapper - 12/06/08 22:17

okay, thanks for details, i'd try to fix this

Quote:

if i remove this line:
NewtonBodySetAutoFreeze(body, 1);
the game runs fine again

this one is in newton_main.c ?
Posted By: Andreas C

Re: Newton 2 wrapper - 12/06/08 23:24

VeT,
I downloaded your demo ... very nice work !

And THANK YOU for providing a wrapper for the new Newton version !

Cheers,
Andreas
Posted By: VeT

Re: Newton 2 wrapper - 12/07/08 09:21

good to see that people like my work smile
Posted By: flits

Re: Newton 2 wrapper - 12/07/08 10:47

yes in the function
NewtonBody *newton_addentity(ENTITY* entity, float mass, int collisiontype, void* forceandtorquecallback)
Posted By: VeT

Re: Newton 2 wrapper - 12/07/08 11:22

hmm.. first, make sure that you use dll that goes in last wrapper version... this sound silly, but i dont have any idea, why function from DLL dont load correctly

i think that i'd try to make this wrapper for c-script and test that variant
Posted By: VeT

Re: Newton 2 wrapper - 12/07/08 20:43

yes, and one more thing: try to use Ventilator's first edition of wrapper, would you have the same error or not...
and dont forget about versions of dll: he used Newton 1.53, i use Newton 2.17

here it is, first version
http://www.coniserver.net/coni_users/web_users/pirvu/au/demo/zips/litecnewton.zip
Posted By: flits

Re: Newton 2 wrapper - 12/07/08 21:47

i use the same newton.dll that is inside the zip

the one from ventilator did work
Posted By: Cowabanga

Re: Newton 2 wrapper - 12/08/08 18:45

good work smile , congrats for winning the contest!
Posted By: VeT

Re: Newton 2 wrapper - 12/08/08 23:08

Cowabanga, thanks smile

flits, okay, can you send me physic part of your work? maybe i'd manage with that
Posted By: Omicron_NEGA

Re: Newton 2 wrapper - 12/16/08 13:24

hi Vet!
i love your wrapper,and i also fond there is a file called
"main.wdl"
you know,my project written in c-script,and could you please
tell me what does "main.wdl"do?
Posted By: VeT

Re: Newton 2 wrapper - 12/18/08 08:35

Hi, Omicron
just open and see :)))

PLUGINDIR = "GS\\acknex_plugins";
PATH "include";
PATH "levels";


in lite-c, paths are (or, maybe, was) stored in *.wld files with the same name as main file... i dont remember if it is needed in last version, but it works smile
Posted By: Omicron_NEGA

Re: Newton 2 wrapper - 12/18/08 08:53

so, your wrapper wont work with c-script? frown
but nevermind..
my next project will written in lite-c
and thanks for your help wink
Posted By: VeT

Re: Newton 2 wrapper - 12/18/08 18:26

i'm thinking about c-script version of wrapper as i got pro-version of GS smile
Posted By: PlaystationThree

Re: Newton 2 wrapper - 12/30/08 04:01

I cant remember if I posted this before, but could you please write some sort of user guide for this? A workshop would be very helpful.
Posted By: GMS0012

Re: Newton 2 wrapper - 12/30/08 13:58

what is newton 2.0 ?

on the newton page there is only version 1.53??
Posted By: croman

Re: Newton 2 wrapper - 01/02/09 15:25

VeT - i know you said that you'll add ragdolls later but i'd like to know when do you plan on doing that?

and is it possible to create ragdolls now on our own or do you need to put some special code in the wrapper? smile
Posted By: VeT

Re: Newton 2 wrapper - 01/03/09 00:23

2 PlaystationThree
hm... wrapper consists of code that you can use.. okay, i'd make some tutorial for adding it to your project

2 GMS0012
just write a pm to Julio, he would send you the latest beta-version
as there is no stable version, wrapper is desighned to be able simply modified for any new version

2 cerberi_croman
i didnt look at the original of ragdoll code blush, but if you're so asking, i would look and say tomorrow how many time it would cost wink
Posted By: BigM

Re: Newton 2 wrapper - 01/04/09 02:56

VeT,

I have had some time to try and get my simulation running and finally worked out some problems:

1- I too have had to comment out the 'NewtonBodySetAutoFreeze (body, 1);' instruction, otherwise I will get a (non-fatal) 'Empty prototype called in ###', where ### stands for ASCII garbage. From here I checked found out that there is no longer any NewtonBodySetAutoFreeze function exported by newton.dll; that explains the bug. There is a NewtonBodySetAutoSleep; does it do the same thing?

2- I got my corkscrew joint back up again (I hadn't been able to do so since migrating to newton 2.0). I could only do this by changing NewtonMain2.17.c and cast *NewtonCorkscrewCallBack as a void instead of a DWORD.
I don't understand why the cast type was changed from the previous wrapper (it was void back then). Other joint callbacks have had the same change: are they also causing trouble? Was I the only one having trouble with the new wrapper and corkscrew joints?

I hope to have more time now to dedicate to this. Hope you find these fixes useful.

Cheers
Posted By: VeT

Re: Newton 2 wrapper - 01/04/09 11:32

hi, BigM

1 - you're absolutely right: i used code from newton 2.16 and forgot that in 2.17 there are some changes like
Quote:

- function NewtonBodyGetAutoFreeze is changed to NewtonBodyGetAutoSleep
- function NewtonBodySetAutoFreeze is changed to NewtonBodySetAutoSleep

i changed them in main wrapper function, but forget to change in other scripts

your remark is really very helpfull wink


2 - what about corkscrew
interesting... i looked through original Newton.h from v 2.16 and 2.17 and they are both voids... and in wrapper they are dwords... interesting, why i changed this

anyway, thank you for help and for your time that you spend for my wrapper
Posted By: VeT

Re: Newton 2 wrapper - 01/04/09 13:50

hm... newton beta 2.18 is realesed... looking like its a time for new wrapper's version, that include all corrects and new features smile
Posted By: VeT

Re: Newton 2 wrapper - 01/04/09 14:31

i still dont know what to do with lite-c or c-script... maybe i'd update lite-c version to 2.18 and then manage with c-script version
Posted By: picoder

Re: Newton 2 wrapper - 01/04/09 15:41


Keep up the good work!
Posted By: VeT

Re: Newton 2 wrapper - 01/04/09 16:04

2 picoder
thank you, i'd look that demo... but raycast vehicle was in 2.17... i see just new level Scene Collection and shaders - that all i think smile
Posted By: VeT

Re: Newton 2 wrapper - 01/04/09 16:30





v.16
- updated dll to newton 2.18 (its a pitty, but in 2.18 almost no new features)
- fixed 'Empty prototype' error with the help of BigM, all NewtonBodySetAutoFreeze is changed to NewtonBodySetAutoSleep
- added map21.c - impluse weapon demo, that was excluded before the contest because of errors and craches, now works fine
- added map50.c with compounds, i worked a lot with it, it must be the one of main feature of wrapper but, i forget about it frown also now works fine
Posted By: VeT

Re: Newton 2 wrapper - 01/04/09 16:45

okay, looking like with lite-c i managed for a little... next step is to add joints, from simple doors to player's upvector and vechiles

looking like its a good moment to make c-script version, before i add next dll

this dont mean that lite-c version would be abaddoned: every new feature i plan to add first to lite-c version and then to c-script
Posted By: croman

Re: Newton 2 wrapper - 01/04/09 18:11

finally! the joints smile
Posted By: VeT

Re: Newton 2 wrapper - 01/05/09 22:58



i decided to manage with c-script later, so... wink

v.17
- added and initialised library JointLibrary.dll
- added map100.c, where simple function CreateSimpleRope() creates fully physical rope. Just use Space to activate mouse and check it.
- minor bugs are fixed.

thats quite simple, right? smile
Posted By: Anonymous

Re: Newton 2 wrapper - 01/06/09 11:14

looks really cool, but if i grap one piece of the rope ithen it looks weird. between the piece and the other pieces is a big space.
Posted By: VeT

Re: Newton 2 wrapper - 01/06/09 12:38

thats because of unfinished power_mouse.
In 3d space coordinates of pointer defines by tracing from camera behind to next obstacle(to the wall).
So if you grap one piece, you move it to the wall, wich is far from rope... i'd work on it
Posted By: Anonymous

Re: Newton 2 wrapper - 01/06/09 12:45

ok cool thank you
Posted By: flits

Re: Newton 2 wrapper - 01/06/09 19:45

thx vet the old problems are gone and it looks like this version is much smoother (maby because i edited the files else it didnt work)

great work
Posted By: HoopyDerFrood

Re: Newton 2 wrapper - 01/07/09 21:48

Hi,
first of all, realy great contibution.

But on my computer the demo-programm always throws out "Error E2512 Empty prototype called in Event". I can click it anway an the progamm runs without restrictions. I figured out that this is due to the "NewtonBodySetAutoFreeze (body_temp, 0);" command. Its in the Power-Mouse code and in the "newton_addentity" function. When I comment this lines out everything works fine without errors. So why is it necessary?

I know that I needet and used it in the old wrapper from thomas oppel. Now it throws errors but also it seems to be unnecessary.

My actual question is how I can implement sounds with this wrapper. My code I used with die old wrapper dont work anymore. Has anyone implemented sound, yet? I just want my cans chatter when thy hit each other or fall on the ground.
Posted By: VeT

Re: Newton 2 wrapper - 01/08/09 21:27

2flits
thanks for comments smile


2HoopyDerFrood

those errors are appeared beacuse in 2.17 version Julio made changes
Code:
- function NewtonBodyGetAutoFreeze is changed to NewtonBodyGetAutoSleep
- function NewtonBodySetAutoFreeze is changed to NewtonBodySetAutoSleep

i dont know why he do this, but i think there is a reason why smile

in last version of wrapper this bug is fixed(i used new function)

sound is played in material's properties(why 2 materials collides, in 1.53 it was like that)
i'd add sound effects in nearest updates wink
Posted By: kasimir

Re: Newton 2 wrapper - 01/29/09 19:34

ohhh, i hope you will include sounds soon!

i've heard about a function called "CustomPickBodyJoint" - is it possible to include this in next update?!

Thx for your Newton 2- script - very usefull laugh
Posted By: VeT

Re: Newton 2 wrapper - 02/03/09 18:42

yes, i'd try to add sounds next time wink
i'm starting to add joints to wrapper, now i'm working on player's controls, "CustomPickBodyJoint" is not far from it, i think smile

i'm glad that you like my work smile
Posted By: Felixsg

Re: Newton 2 wrapper - 02/06/09 17:13

Is in the way car physics?
thanks and great work
Posted By: Quad

Re: Newton 2 wrapper - 02/07/09 13:17

i tried a car with newton vehicle joint(not the custom multipartcar thingy.),

with both newton 1.53(ventilators wrapper) and newton 2 open beta(with Vet's wrapper), both working but has a problem(both has same problem):

tried with diffrent mass/size/hulltypes, but when i release car from a hill like this:


car goes down with CONSTANT speed, where it should get faster(because it goes down from a hill laugh )

i can only suspect this line, but i am not sure how to solve it:
Code:
void onforceandtorque(NewtonBody* body)
{
	float mass, ixx, iyy, izz;
	NewtonBodyGetMassMatrix(body, &mass, &ixx, &iyy, &izz);
	NewtonBodySetForce(body, vectorf(0, 0, -9.8 * mass));
}


this is the forceandtorquecallback of the car body.

any suggestions?
Posted By: VeT

Re: Newton 2 wrapper - 02/08/09 11:29

hm... what is the mass of car body and car wheels?
Posted By: Quad

Re: Newton 2 wrapper - 02/08/09 15:36

i tried with

car(200) wheels(20)
car(200) wheels(25)
car(200) wheels(50)
car(20) wheels(3)
Posted By: Cowabanga

Re: Newton 2 wrapper - 02/08/09 18:28

Hey VeT! Maybe you can make a PhysX wrapper wink
Posted By: VeT

Re: Newton 2 wrapper - 02/09/09 13:25

2 Quadraxas
i didnt worked with cars yet, but i think you can try to make wheel's mass larger than car body...

2 Cowabanga maybe))) but i like Newton more smile and somedoy worked on PhysX, as i remember smile
Posted By: Cowabanga

Re: Newton 2 wrapper - 02/09/09 13:32

Originally Posted By: VeT
2 Cowabanga maybe))) but i like Newton more smile and somedoy worked on PhysX, as i remember smile


Really? Who?
Posted By: VeT

Re: Newton 2 wrapper - 02/09/09 16:07

try to look here smile

http://www.opserver.de/ubb7/ubbthreads.p...true#Post211659
or
http://www.coniserver.net/ubb7/ubbthreads.php?ubb=showflat&Number=200504&nt=10&page=1
Posted By: Cowabanga

Re: Newton 2 wrapper - 02/09/09 16:24

Great! smile
Posted By: Quad

Re: Newton 2 wrapper - 02/10/09 13:33

Originally Posted By: VeT
2 Quadraxas
i didnt worked with cars yet, but i think you can try to make wheel's mass larger than car body...


car starts to fly when it touches the ground.


Posted By: VeT

Re: Newton 2 wrapper - 02/12/09 21:12

what? car is flying with wheel's mass larger than car?
very interesting indeed... can you show your code? i'd try to correct it and add to next version of wrapper(and add a speshial thanks for you:))
Posted By: Quad

Re: Newton 2 wrapper - 02/12/09 21:29

Code:
ENTITY* car;
var camerapanmodifier = 0;
void tireUpdate(const NewtonJoint* vehicle)
{
	int tireId;
	float m[16];
	ENTITY* tireModel;
	for (tireId = NewtonVehicleGetFirstTireID (vehicle); tireId!=NULL; tireId = NewtonVehicleGetNextTireID (vehicle, tireId)) 
	{
		tireModel = NewtonVehicleGetTireUserData (vehicle, tireId);
		NewtonVehicleGetTireMatrix( vehicle,tireId, m);
		ent_setmatrix_rb(tireModel,m);
	}
}



action Visual_Car(){
	while(car!=NULL){
		vec_set(my.x,car.x);
		vec_set(my.pan,car.pan);
		wait(1);
	}
}

action Newton_Car()
{
	car = me;
	set(my,INVISIBLE);//hide the physical proxy

	while(!newton_running){wait(1);}
	
	NewtonBody* car_body=newton_addentity(me, 100, NEWTON_CONVEXHULL, onforceandtorque);
	NewtonBodySetAutoFreeze( car_body, 0);
	NewtonBodySetLinearDamping(car_body,0.03);
	ent_create("kasa1.mdl",nullvector,Visual_Car);//car model


	float upDirection[] = {0.0, 0.0, 1.0};
	NewtonJoint* car_joint = NewtonConstraintCreateVehicle(nworld, upDirection[0], car_body);
	NewtonVehicleSetTireCallback(car_joint, tireUpdate); 
	
	int tireMass = 10;
	float suspensionLength = 0.1;
	float suspensionSpring =3000.0;
	float suspensionShock = 10.0;
	float wheelradius = 0.5;
	float tirePin[] = {0.0, 1.0, 0.0};
	

	
	D3DXMATRIX tire_offset;
	VECTOR tirepos;
	
	
	vec_for_bone(tirepos,me,"osol");//f left
	vec_sub(tirepos,my.x);
	D3DXMatrixTranslation(&tire_offset, tirepos.x * QUANTTOMETER,tirepos.y * QUANTTOMETER,tirepos.z * QUANTTOMETER);												
	NewtonVehicleAddTire(car_joint, &tire_offset, tirePin[0], tireMass, wheelradius, wheelradius, suspensionShock,suspensionSpring,suspensionLength, ent_create("teker1.mdl",nullvector,NULL), 0);
	
	
	vec_for_bone(tirepos,me,"osag");//f right
	vec_sub(tirepos,my.x);
	D3DXMatrixTranslation(&tire_offset, tirepos.x * QUANTTOMETER,tirepos.y * QUANTTOMETER,tirepos.z * QUANTTOMETER);		
	NewtonVehicleAddTire(car_joint, &tire_offset, tirePin[0], tireMass, wheelradius, wheelradius, suspensionShock,suspensionSpring,suspensionLength, ent_create("teker1.mdl",nullvector,NULL), 1);
	
	vec_for_bone(tirepos,me,"asol");//r left
	vec_sub(tirepos,my.x);
	D3DXMatrixTranslation(&tire_offset, tirepos.x * QUANTTOMETER,tirepos.y * QUANTTOMETER,tirepos.z * QUANTTOMETER);		
	NewtonVehicleAddTire(car_joint, &tire_offset, tirePin[0], tireMass, wheelradius, wheelradius, suspensionShock,suspensionSpring,suspensionLength, ent_create("teker1.mdl",nullvector,NULL), 2);
	
	vec_for_bone(tirepos,me,"asag");//r left
	vec_sub(tirepos,my.x);
	D3DXMatrixTranslation(&tire_offset, tirepos.x * QUANTTOMETER,tirepos.y * QUANTTOMETER,tirepos.z * QUANTTOMETER);		
	NewtonVehicleAddTire(car_joint, &tire_offset, tirePin[0], tireMass, wheelradius, wheelradius, suspensionShock,suspensionSpring,suspensionLength, ent_create("teker1.mdl",nullvector,NULL), 3);
	
	
	while(1){
		wait(1);
		camera.pan = my.pan + camerapanmodifier;
		camerapanmodifier += mouse_force.x*time_step*10;
		camera.x = my.x - 700*cosv(camera.pan);
		camera.y = my.y - sinv(camera.pan)*700;
		camera.z = my.z + 200;
		camera.tilt =-15;
	}
}


my car setup (both works with your and ventilator's wrapper.both same result)

and this is the ent_create i use

ent_create("kasa1fiz.mdl",vector(100,0,350),Newton_Car);//create car

i use diffrent models for visual and physical models:
car,physics proxy and tire models:
http://rapidshare.com/files/197359812/carmodelparts.zip.html
Posted By: VeT

Re: Newton 2 wrapper - 02/15/09 21:37

okay, car is initiated in wrapper, now i'd look closer at it...
Posted By: VeT

Re: Newton 2 wrapper - 02/15/09 22:06

hm.. it creates wheels down( looking like in the (0,0,0))
Posted By: Quad

Re: Newton 2 wrapper - 02/15/09 22:15

you need to use my models, it uses bones for placing wheels. (i think you already use them but just in case.)

edit: btw, i was expirementing with code, you may delete this line
NewtonBodySetLinearDamping(car_body,0.03);

Posted By: Vulder

Re: Newton 2 wrapper - 02/16/09 09:19

I have a problem with the function:
NEWTON_API void NewtonBodySetFreezeState (const NewtonBody* body, int state);

When I use this function to freeze a body, it freezes all bodies. I think, it only should affect the body that I select. Is it a bug or am I using wrong that function?
Is there any function, like NewtonWorldFreezeBody, to remove a body from the active simulation list?
Posted By: VeT

Re: Newton 2 wrapper - 02/16/09 17:25

2 Vulder :
- function NewtonWorldFreezeBody is changed to NewtonBodyGetFreezeState
i dont know, why Julio make this changes, but we have what we have...
(its from changeList.txt, from original Newton)

also look through
- function NewtonBodyGetAutoFreeze is changed to NewtonBodyGetAutoSleep
- function NewtonBodySetAutoFreeze is changed to NewtonBodySetAutoSleep

in addition, maybe this could help you: http://www.newtondynamics.com/forum/viewtopic.php?f=9&t=4675

Quote:

In pre-V2 Newton you can use NewtonBodySetFreezeTreshold.

Posted By: VeT

Re: Newton 2 wrapper - 02/16/09 17:36

2 Quadraxas: i mean something like this... its right after initialisation


okay, tonight i'd try to deal with this smile

btw, camera is in the floor box
Posted By: Quad

Re: Newton 2 wrapper - 02/16/09 19:31

can you send this version to me, i guess i can figure this out.
Posted By: VeT

Re: Newton 2 wrapper - 02/16/09 22:35

hm... i send my level at your mail, hope you'd find, where is a bug

when i commented vec_sub after vec_for_bone, wheel stands where it may be.. also i tried vec_for_vertex

but connection between car and wheel don't word at all...
Posted By: Quad

Re: Newton 2 wrapper - 02/17/09 21:14

i got the mail, il check this as soon as i can.
Posted By: VeT

Re: Newton 2 wrapper - 02/17/09 22:40

i'd be waiting your answer... now i'm going back to player's physic, sounds and simple joints smile
Posted By: Quad

Re: Newton 2 wrapper - 02/22/09 00:56

i looked in to that, there seems to be some changes(from old newton to newton2) effecting the code.

(it says it crashed in ent_getmatrix_rb, which is never used. problem is not there.)

i'll rebuild the car from scratch, after getting this working, will try with new carjoint thing.
Posted By: VeT

Re: Newton 2 wrapper - 02/22/09 10:44

interesting... i didnt had any crashes, just got, what you see on the picture...
Posted By: Quad

Re: Newton 2 wrapper - 02/22/09 11:01

i get the crash, and car starts to fall down(like a convexhull), no wheels.
Posted By: VeT

Re: Newton 2 wrapper - 02/22/09 12:59

wtf... now and i have crash.... laugh laugh laugh
heh... okay, i'd try to fix it...
Posted By: Vulder

Re: Newton 2 wrapper - 02/24/09 14:34

Hello!

I'm using
NewtonMaterialSetCollisionCallback(nworld, G_Group1, G_Group2, NULL, contact, collision);
to make a callback when 2 objects collision.
Functions "contact" and "collison" are:
int contact(NewtonMaterial* Nmaterial, NewtonBody* body0, NewtonBody* body1, int threadIndex)
{
...
return 1;
}

function collision(NewtonMaterial* Nmaterial, NewtonContact* contact)
{
...
return 1;
}

When an object from G_Group1 collision with other from G_Group2, I obtain the error E1513-> Crash in vectorf.

I need to know which objects collision to remove them. Am I using right this function?

The problem is in NewtonOnAABBOverlap, because if I use

NewtonMaterialSetCollisionCallback(nworld, G_Group1, G_Group2, NULL, NULL, collision);
that error doesn't show. But I need to know which objects have collisioned, thats why I need to use the NewtonOnAABBOverlap callback.

Thanks for LiteC+Newton2

Sorry for my English wink
Posted By: VeT

Re: Newton 2 wrapper - 02/24/09 15:01

thank you for posting about this error, i'd look for it in the evening wink
Posted By: VeT

Re: Newton 2 wrapper - 02/28/09 16:15

okay... espeshially for HoopyDerFrood, kasimir i added sound, for Vulder i added collisions... just take a look:



v.18
- some minor bugs found
- map22.c added, based on map11.c, but now it highligts point of collision(with draw_point3d) and emit partivcles in normal diretcion
- map22.c updated, 3d sounds added


not too many updates for this release, but... smile
Posted By: VeT

Re: Newton 2 wrapper - 03/02/09 20:33

okay, friends, today i found (at least) some time to write a little manual about adding Newton to your project
here is manual
and here is sources
Posted By: Felixsg

Re: Newton 2 wrapper - 03/03/09 10:26

Thanks, by your work and please not forgot the car physics
Posted By: VeT

Re: Newton 2 wrapper - 03/03/09 15:44

I'm working on this now.

Anyway, i think you may go to Newton's official forum, as there are a lot of race-makers wink
Posted By: Vulder

Re: Newton 2 wrapper - 03/03/09 16:21

Thank you very much VeT smile
Posted By: VeT

Re: Newton 2 wrapper - 03/05/09 22:03

moving straight ahead to car's physics wink
seeking for volunteers to help me to deal with character controls and buoyancy
Posted By: VeT

Re: Newton 2 wrapper - 03/15/09 11:36

Hey, guys... nobody wants to help me? I have some troubles.
Now i'm working in 3 direction: DG car(times faster than usual raycast car), buoyancy(physic of the bodies that falls in the water) and character controler(we would be able to create person control physic).
Next steps would be different examples of cars(after basic DG car) and ragdoll (after character controler).

I really want to finish this as fast as possible, but i haven't enough time (and, sometimes, knowledges).

So, if somebody would have some time and desire to improve Wrapper, write here or PM me.
Posted By: YNG

Re: Newton 2 wrapper - 03/15/09 15:17

I have a working car physic with Newton but it uses 1.53. I dunno what are the diffrences between 1.53 and 2.16 so the code i gave is working at 1.53. I have shown simply how to use torque, how to set the car etc. Making better steering formulas, rpm-torque formulas or similar things can be made as you wish. Hope it will be useful for the community. And btw, nice contribution and great work by you VET smile

Code:
var temp_var;
float temp_float;

ENTITY* car;
ENTITY* FLwheelPtr;
ENTITY* FRwheelPtr;
ENTITY* BLwheelPtr;
ENTITY* BRwheelPtr;
ENTITY* tireId;
ENTITY* tireModel;
D3DXMATRIX m;

void tireUpdate(NewtonJoint* vehicle)
{
	// FOR EACH TIRE APPLY THESE VALUES
	for (tireId = NewtonVehicleGetFirstTireID (vehicle); tireId!=NULL; tireId = NewtonVehicleGetNextTireID (vehicle, tireId)) 
	{
		NewtonVehicleSetTireSideSleepCoeficient(vehicle,tireId,0.0);
		NewtonVehicleSetTireMaxSideSleepSpeed (vehicle,tireId,999.0);
		NewtonVehicleSetTireLongitudinalSlideCoeficient(vehicle,tireId,0.0);
		NewtonVehicleSetTireMaxLongitudinalSlideSpeed (vehicle,tireId,999.0);
	}
	
	
	// CALCULATE AVERAGE TIRE SPEED
	tireId = NewtonVehicleGetFirstTireID(vehicle);
	temp_var = NewtonVehicleGetTireLongitudinalSpeed(vehicle,tireId);
	tireId = NewtonVehicleGetNextTireID(vehicle, tireId);
	temp_var += NewtonVehicleGetTireLongitudinalSpeed(vehicle,tireId);
	tireId = NewtonVehicleGetNextTireID(vehicle, tireId);
	temp_var += NewtonVehicleGetTireLongitudinalSpeed(vehicle,tireId);
	tireId = NewtonVehicleGetNextTireID(vehicle, tireId);
	temp_var += NewtonVehicleGetTireLongitudinalSpeed(vehicle,tireId);
	temp_var *= 0.25;
	
	
	if(key_w)
	{
		if(temp_var<-2) //if tires average speed is smaller than -2 and key W pressed  >>>>>> APPLY BRAKE TO ALL TIRES
		{
			tireId = NewtonVehicleGetFirstTireID(vehicle);        //tireId 0   //Front Left
			temp_float = NewtonVehicleTireCalculateMaxBrakeAcceleration(vehicle,tireId) * 0.7;
			NewtonVehicleTireSetBrakeAcceleration(vehicle,tireId,temp_float,temp_float);
			
			tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 1   //Front Right
			temp_float = NewtonVehicleTireCalculateMaxBrakeAcceleration(vehicle,tireId) * 0.7;
			NewtonVehicleTireSetBrakeAcceleration(vehicle,tireId,temp_float,temp_float);
			
			tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 2   //Back Left
			temp_float = NewtonVehicleTireCalculateMaxBrakeAcceleration(vehicle,tireId) * 0.7;
			NewtonVehicleTireSetBrakeAcceleration(vehicle,tireId,temp_float,temp_float);
			
			tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 3   //Back Right
			temp_float = NewtonVehicleTireCalculateMaxBrakeAcceleration(vehicle,tireId) * 0.7;
			NewtonVehicleTireSetBrakeAcceleration(vehicle,tireId,temp_float,temp_float);
		}
		else //else >>>>>> APPLY 1500 TORQUE FORWARD TO REAR TIRES 
		{
			tireId = NewtonVehicleGetFirstTireID(vehicle);        //tireId 0   //Front Left	
			tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 1   //Front Right
			
			tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 2   //Back Left
			NewtonVehicleSetTireTorque(vehicle,tireId,1500);
			
			tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 3   //Back Right
			NewtonVehicleSetTireTorque(vehicle,tireId,1500);
		}
	}
	else if(key_s)
	{
		if(temp_var<2) //if tires average speed is smaller than 2 >>>>>> APPLY 1500 TORQUE BACKWARD TO REAR TIRES 
		{
			tireId = NewtonVehicleGetFirstTireID(vehicle);        //tireId 0   //Front Left	
			tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 1   //Front Right
			
			tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 2   //Back Left
			NewtonVehicleSetTireTorque(vehicle,tireId,-1500);
			
			tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 3   //Back Right
			NewtonVehicleSetTireTorque(vehicle,tireId,-1500);
		}
		else //else >>>>>> APPLY BRAKE TO ALL TIRES
		{
			tireId = NewtonVehicleGetFirstTireID(vehicle);        //tireId 0   //Front Left
			temp_float = NewtonVehicleTireCalculateMaxBrakeAcceleration(vehicle,tireId) * 0.7;
			NewtonVehicleTireSetBrakeAcceleration(vehicle,tireId,temp_float,temp_float);
			
			tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 1   //Front Right
			temp_float = NewtonVehicleTireCalculateMaxBrakeAcceleration(vehicle,tireId) * 0.7;
			NewtonVehicleTireSetBrakeAcceleration(vehicle,tireId,temp_float,temp_float);
			
			tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 2   //Back Left
			temp_float = NewtonVehicleTireCalculateMaxBrakeAcceleration(vehicle,tireId) * 0.7;
			NewtonVehicleTireSetBrakeAcceleration(vehicle,tireId,temp_float,temp_float);
			
			tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 3   //Back Right
			temp_float = NewtonVehicleTireCalculateMaxBrakeAcceleration(vehicle,tireId) * 0.7;
			NewtonVehicleTireSetBrakeAcceleration(vehicle,tireId,temp_float,temp_float);
		}
	}
	
	
	
	if(key_a) //if key A >>>>>> SET FRONT TIRES ANGLE TO 0.35 RADIAN
	{
		tireId = NewtonVehicleGetFirstTireID(vehicle);        //tireId 0   //Front Left
		NewtonVehicleSetTireSteerAngle(vehicle,tireId,0.35);
		
		tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 1   //Front Right
		NewtonVehicleSetTireSteerAngle(vehicle,tireId,0.35);
	}
	else if(key_d) //if key D >>>>>> SET FRONT TIRES ANGLE TO -0.35 RADIAN
	{
		tireId = NewtonVehicleGetFirstTireID(vehicle);        //tireId 0   //Front Left
		NewtonVehicleSetTireSteerAngle(vehicle,tireId,-0.35);
		
		tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 1   //Front Right
		NewtonVehicleSetTireSteerAngle(vehicle,tireId,-0.35);
	}
	else //else >>>>>> SET FRONT TIRES ANGLE TO 0.0 RADIAN
	{
		tireId = NewtonVehicleGetFirstTireID(vehicle);        //tireId 0   //Front Left
		NewtonVehicleSetTireSteerAngle(vehicle,tireId,0.0);
		
		tireId = NewtonVehicleGetNextTireID(vehicle, tireId); //tireId 1   //Front Right
		NewtonVehicleSetTireSteerAngle(vehicle,tireId,0.0);
	}
	
}

action Newton_Car()
{	
	car = me;
	while(!newton_running){wait(1);}
	
	NewtonBody* car_body = newton_addentity(me, 1000, NEWTON_CONVEXHULL, tireRubberID, onforceandtorque);
	NewtonBodySetAutoFreeze( car_body, 0);
	NewtonBodySetLinearDamping(car_body,0.005);
//	NewtonBodySetAngularDamping(car_body,vectorf(0.5,0.5,0.5));


	float upDir[3] = {0.0, 0.0, 1.0};
	NewtonJoint* car_joint = NewtonConstraintCreateVehicle(nworld, upDir[0], car_body);
	
	
	int tireMass = 30;
	float suspensionLength = 0.25;
	float suspensionSpring =700.0;
	float suspensionShock = 60.0;
	float wheelradius = 0.4;
	float tirePin[3] = {0.0, 1.0, 0.0};
	D3DXMATRIX tire_offset;
	VECTOR tirepos;
	
	vec_for_bone(tirepos,me,"FLBone");
	vec_sub(tirepos,my.x);
	D3DXMatrixTranslation(&tire_offset, tirepos.x * QUANTTOMETER,tirepos.y * QUANTTOMETER,tirepos.z * QUANTTOMETER);												
	NewtonVehicleAddTire(car_joint, &tire_offset, tirePin[0], tireMass, wheelradius, wheelradius, suspensionShock,suspensionSpring,suspensionLength, FLwheelPtr, 5);
	
	vec_for_bone(tirepos,me,"FRBone");
	vec_sub(tirepos,my.x);
	D3DXMatrixTranslation(&tire_offset, tirepos.x * QUANTTOMETER,tirepos.y * QUANTTOMETER,tirepos.z * QUANTTOMETER);		
	NewtonVehicleAddTire(car_joint, &tire_offset, tirePin[0], tireMass, wheelradius, wheelradius, suspensionShock,suspensionSpring,suspensionLength, FRwheelPtr, 5);
	
	vec_for_bone(tirepos,me,"BLBone");
	vec_sub(tirepos,my.x);
	D3DXMatrixTranslation(&tire_offset, tirepos.x * QUANTTOMETER,tirepos.y * QUANTTOMETER,tirepos.z * QUANTTOMETER);		
	NewtonVehicleAddTire(car_joint, &tire_offset, tirePin[0], tireMass, wheelradius, wheelradius, suspensionShock,suspensionSpring,suspensionLength, BLwheelPtr, 5);
	
	vec_for_bone(tirepos,me,"BRBone");
	vec_sub(tirepos,my.x);
	D3DXMatrixTranslation(&tire_offset, tirepos.x * QUANTTOMETER,tirepos.y * QUANTTOMETER,tirepos.z * QUANTTOMETER);		
	NewtonVehicleAddTire(car_joint, &tire_offset, tirePin[0], tireMass, wheelradius, wheelradius, suspensionShock,suspensionSpring,suspensionLength, BRwheelPtr, 5);
	
	NewtonVehicleSetTireCallback(car_joint, tireUpdate); 
	

	while(me!=NULL)
	{
		// SET ALL TIRES POSITION AND ANGLE [ THESE LINES ARE NOT AT TIRE CALLBACK FUNC. BECAUSE MAKING THAT CAUSES VISUAL TIRES TO UPDATE 1 FRAME LATER THAN NEWTON TIRES ]
		for (tireId = NewtonVehicleGetFirstTireID (car_joint); tireId!=NULL; tireId = NewtonVehicleGetNextTireID (car_joint, tireId)) 
		{
			tireModel = NewtonVehicleGetTireUserData (car_joint, tireId);
			NewtonVehicleGetTireMatrix(car_joint,tireId, m);
			ent_setmatrix_rb(tireModel,m);
		}
		
		wait(1);
	}

}

For the creation of models:
Code:
	FLwheelPtr = ent_create("tekerlekL.mdl",nullvector,NULL);
	FRwheelPtr = ent_create("tekerlekR.mdl",nullvector,NULL);
	BLwheelPtr = ent_create("tekerlekL.mdl",nullvector,NULL);
	BRwheelPtr = ent_create("tekerlekR.mdl",nullvector,NULL);
	
	you = ent_create("350z.mdl",vector(6500,-1200,1100),Newton_Car);




PS:
Code:
// FOR EACH TIRE APPLY THESE VALUES
	for (tireId = NewtonVehicleGetFirstTireID (vehicle); tireId!=NULL; tireId = NewtonVehicleGetNextTireID (vehicle, tireId)) 
	{
		NewtonVehicleSetTireSideSleepCoeficient(vehicle,tireId,0.0);
		NewtonVehicleSetTireMaxSideSleepSpeed (vehicle,tireId,999.0);
		NewtonVehicleSetTireLongitudinalSlideCoeficient(vehicle,tireId,0.0);
		NewtonVehicleSetTireMaxLongitudinalSlideSpeed (vehicle,tireId,999.0);
	}

I don't exactly know how the values should be or their min,max values at these lines of tire Callback. But it just works fine with these also.
Posted By: VeT

Re: Newton 2 wrapper - 03/15/09 22:33

Thank you smile
I'm working on the new and another type of car.. but i hope your code would help to finish that smile
Hmm... maybe i'd make one level with your car and then go on.

Btw, still seeking for volunteers to help
Posted By: HoopyDerFrood

Re: Newton 2 wrapper - 03/22/09 17:57

Thank you very much VeT.

But thehe is still a small Problem in both, your map and in mine. The object dont come to rest and moving on an on forever. Even if they just jitter a little, they are playing a sound.

Is there a way to adjust the volume of the sound dependent from the "energy" of the collision?
I've played araound with the BodyFreezeThreshold but without success. My Objects never come to rest completely.
Posted By: VeT

Re: Newton 2 wrapper - 03/23/09 19:27

as i remember, NewtonBodySetFreezeTreshold needed to be used in this case... i'd make a demo wink
Posted By: VeT

Re: Newton 2 wrapper - 03/25/09 12:27

Damned, there is about 20K views in this topic and nobody wants to improve wrapper? I really almost have no time, as i may finish my diplom work
Posted By: Felixsg

Re: Newton 2 wrapper - 03/25/09 21:03

Appear is the world crisis (the economy)
I only can help with models and probably
with worlds

but I need to wait to endweek for take part
Posted By: VeT

Re: Newton 2 wrapper - 03/26/09 14:23

Our 3d artist already helped me with models, thank you smile
I need just scripting help
Posted By: HoopyDerFrood

Re: Newton 2 wrapper - 04/05/09 10:04

Can you specify this? What do you want to be coded. Maybe there is a small task I'm able to do.
Posted By: VeT

Re: Newton 2 wrapper - 04/05/09 10:15

Quote:
Now i'm working in 3 direction: DG car(times faster than usual raycast car), buoyancy(physic of the bodies that falls in the water) and character controler(we would be able to create person control physic).
Next steps would be different examples of cars(after basic DG car) and ragdoll (after character controler).

I really want to finish this as fast as possible, but i haven't enough time (and, sometimes, knowledges).


here it is smile i'd be very happy, if you would be able to help me with this
Posted By: Anonymous

Re: Newton 2 wrapper - 04/06/09 22:02

Hi VeT!

You definitly did a great job with this wrapper!
I like it very much!

Is there a way to adjust the elasticity/friction/.. per entity also?

mercuryus
Posted By: VeT

Re: Newton 2 wrapper - 04/06/09 22:06

work with bodies, not entities... look at the one of the first levels, there is a demo of using friction.. elasticy changes in the same way smile
Posted By: VeT

Re: Newton 2 wrapper - 04/22/09 20:15

I heard from peoples, that sometimes manual doesnt work... Here is second version: Source, v2
Posted By: jweb

Re: Newton 2 wrapper - 05/02/09 18:27

Greate Work!!!
someone have a working CAR DEMO with WMP? What is the FPS Rate with Newton ?

THX
Posted By: VeT

Re: Newton 2 wrapper - 05/02/09 20:05

fps is very good: i got about 200 with 200 entities

wait a little, i'm finishing my work with car wink
Posted By: flits

Re: Newton 2 wrapper - 05/02/09 20:26

maby you can make a var to change the gravety


now i did it like this
Code:
void onforceandtorque(NewtonBody* body)
{
	float mass, ixx, iyy, izz;
	NewtonBodyGetMassMatrix(body, &mass, &ixx, &iyy, &izz);
	ENTITY *entity = (ENTITY*)NewtonBodyGetUserData(body);
	NewtonBodySetForce(body, vectorf(0,0,gravity_z * mass));
}


overal i cant seem to find any bugs accept that i dont understand the joints parts sometimes

thx flits
Posted By: VeT

Re: Newton 2 wrapper - 05/03/09 01:26

yes, there are almost no documentation, it made my work harder...

about your code: why you use
Code:
ENTITY *entity = (ENTITY*)NewtonBodyGetUserData(body);

?

Seems that you dont need entity in this function at all
Posted By: flits

Re: Newton 2 wrapper - 05/03/09 14:42

i modifed it inside the forum
i dont seem to able to add foce inside a function so i use skills tat add the force inside the loop onforceandtorque en therefore i need the entity pointer
Posted By: VeT

Re: Newton 2 wrapper - 05/03/09 20:06

http://www.newtondynamics.com/wiki/index.php5?title=NewtonBodyAddForce
Quote:

NewtonBodyAddForce
void NewtonBodyAddForce( const NewtonBody* bodyPtr, const dFloat* forcePtr)
Usage

Add the net force applied to a rigid body.
Parameters
const NewtonBody *bodyPtr - pointer to the body to be destroyed.
const dFloat *forcePtr - pointer to an array of 3 floats containing the net force to be applied to the body.

Return
Nothing.

Remarks
This function is only effective when called from NewtonApplyForceAndTorque callback


last string wink
Posted By: Felixsg

Re: Newton 2 wrapper - 05/03/09 20:20

how are the car sample?
Posted By: VeT

Re: Newton 2 wrapper - 05/03/09 23:01

in progress wink
i have working version of car for Newton 1.53, now i may convert it to newest version as there is no old car in Newton 2.0
Posted By: VeT

Re: Newton 2 wrapper - 05/12/09 13:34

Here is my PMs with Julio(creator of Newton):

Originally Posted By: Julio

*****

Plus I am also adding eth CUDA support so the next Beta will come with Hardware simulation on GPU.
Therefore it will provide the same level of mass physics simulation as other commercial engine but with a real newtonian base physics engine like ODE, as opposed to a Impulse base Physics engine like all the others.

There are many, many reasons why a force based engine is far superior than a impulse base, although it have to be slower by nature, but as you can see Newton 2.0 is quite competitive.


Originally Posted By: VeT

******

also, can you give me more details about impulse and force-based physical engine?


Originally Posted By: Julio

Impulase base for force base p[hysic sare teh tow diffrent metod to make physis simulation.

Impulse was proposed by Brians Mirtich
http://www.kuffner.org/james/software/dynamics/mirtich/index.html

and force base was propose by Davif Baraff
http://www.cs.cmu.edu/~baraff/papers/sig96.pdf

Impulse base very eassy to implement and is the methed used by Physx and Havok, it is also the method used by open source since they are all biproduct of Havov and PhyiX written by ex employee that when they leave the company use and older copy and re write as open source.

the problem with open source is the teh are incorrect since they violate a physics principle that state that and impulse can only be appliyed at and infinitesimal small period of time.
They apply impulse an dintegrate then as if tehey where forces, theyfor tehy are unstable and thsi si whay you see hundere of paore teh try to sov eteh problems.

Force base implementation are base on rigurose law of physics call the method of the virtual work, they are harder to solve but the are more stable and have the ability that the same solver solve all know rigid body problems.

Posted By: Felixsg

Re: Newton 2 wrapper - 05/12/09 15:14

you see the beta page?
I think not really importan but can be
and why you no talk with JCL to try
to implement de newton inside gamestudio
Posted By: Hitsch

Re: Newton 2 wrapper - 05/12/09 15:36

Very interesting to read up on the different physics systems.

I don't get why the 'Newton-Way' is actually better for the end user? Is it in general more accurate?
Posted By: VeT

Re: Newton 2 wrapper - 05/12/09 17:54

2 Felixsg
I talked to jcl, he promised to implement... i think, he waits for the full version of Newton, not for betas.
Anyway, all functionality of Newton is enabled in first version of wrapper: 2-18 versions just show, how to use Newton for different effects.. If you know, how to create car using Newton, you can make it with the LiteCNewton2.16.v1.rar
(well, in the latest versions there are fixed some minor bugs in header, but i hope you got the idea)

2 Hitsch
Yes, more accurate and stable.. try those links, if you want additional information smile
Posted By: Quad

Re: Newton 2 wrapper - 05/12/09 19:19

hey vet, i started to play with your wrapper again, and just to let you know:

the ent_setmatrix_rb function needs to be changed to work with 7.77, or entites have a wrong tilt value(random?)

this is the updated version:
Code:
void ent_setmatrix_rb(ENTITY *entity, float *m)
{
	float pan, tilt, roll;
	
	if(fabs(m[2]) > 0.9999) // looking straight up or down -> gimbal lock
	{
		pan = atan2(-m[4], m[5]); // -m[4]?
		tilt = 1.570796 * sign(m[2]);
		roll = 0;
	}
	else
	{
		pan = atan2(m[1], m[0]); // swap?
		tilt = atan2(m[2],sqrt(m[1]*m[1] + m[0]*m[0]));
		roll = atan2(m[6], m[10]);
	}
	
	entity->pan = pan * RAD2DEG;
	entity->tilt = tilt * RAD2DEG;
	entity->roll = roll * RAD2DEG;
	
	entity->x = m[12] * METERTOQUANT;
	entity->y = m[13] * METERTOQUANT;
	entity->z = m[14] * METERTOQUANT;
}


just to let you know.
Posted By: VeT

Re: Newton 2 wrapper - 05/12/09 19:31

yes-yes, thank you, i got that smile
Posted By: Rackscha

Re: Newton 2 wrapper - 05/13/09 12:22

Hi
How can i set up constraints? i dont get it. In ODE i had to use
Vectors to set the anglepoint and the axis the constraint rotates around. But what are dfloats?

Can someone give me an example?

I used vectors(of course wrong) and the second body disapeared:
Code:
vec_for_bone(temp,my,"Bone9");	ent=ent_create("box_a.mdl",vector(temp.x,temp.y,temp.z+20),bone);	bone_t=newton_addentity(ent,0,NEWTON_BOX,onforceandtorque);
you=ent_create("box_a.mdl",vector(temp.x,temp.y10,temp.z20),bone);
ragdoll_ent=newton_addentity(you,70,NEWTON_BOX,onforceandtorque);
NewtonConstraintCreateHinge(nworld,ent.x,vector(0,1,0),bone_t,ragdoll_ent);



Greets
Rackscha
Posted By: Quad

Re: Newton 2 wrapper - 05/13/09 13:02

dfloats are just floats,

you can try using dfloat mypoint[3]; instead of a vector

also there was a rope example in the Vet's wrapper that utilizes joints if i recall correctly.
Posted By: VeT

Re: Newton 2 wrapper - 05/13/09 14:01

yep, rope and Power Mouse smile

Quadraxas is absloutely right: Newton use floats, not vars
Posted By: Rackscha

Re: Newton 2 wrapper - 05/13/09 16:39

ok, so ill try the dfloat my_pos[3] example

I#ll report it it worked :)(oh and where is the example? its not in your current download o.O?

GREETS
Rackscha
Posted By: VeT

Re: Newton 2 wrapper - 05/13/09 16:51

Level 16

Damned, tomorrow i'd release new version of Newton for A7.7.. i launched old Newton and got bugs with matrixes, that Quadraxas mentioned on the prevoius page
Posted By: Rackscha

Re: Newton 2 wrapper - 05/13/09 17:21

Ah thats a good news, because i have still a problem.
It worked, but not the way i expected:
In my first picture you can see the bone in Med. Its offset on the z axis.
In the second pic you can see the same bone in red. The circle is the center and the square the visible box. Want i want, is that the box rotates about its center but it doesnt work. When rotating around the y-axis, you can see what happens(the green thing). the circle is the point the box is rotating around. the line shows the path(i have drawn the wrong axis wink ).
And the square is the bone. That shouldnt bee. It seems that i cant change the point of the angular position. And when i trie to rotate around the x axis, the rotation point is somewhere near NULLVECTOR(weird).

Code:
dFloat ang_point[3];
   dFloat ang_rotation[3];
vec_for_bone(temp.x,my,"Bone9");
ent=ent_create("box_a.mdl",vector(temp.x,temp.y,temp.z+10),bone);
bone_t = newton_addentity(ent,0,NEWTON_BOX,onforceandtorque);
you=ent_create("box_a.mdl",vector(temp.x,temp.y,temp.z),bone);
	ragdoll_ent=newton_addentity(you,70,NEWTON_BOX,onforceandtorque);
ang_point[0] = temp.x;
ang_point[1] = temp.y;
ang_point[2] = temp.z;
ang_rotation[0] = 0;
ang_rotation[1] = 1;
ang_rotation[2] = 0;	NewtonConstraintCreateHinge(nworld,ang_point[3],ang_rotation,bone_t,ragdoll_ent);



Greets Rackscha
and Good luck VeT wink


Attached picture pic_a.jpg
Attached picture pic_c.jpg
Posted By: Quad

Re: Newton 2 wrapper - 05/13/09 18:33

multiply coordinates when you are passing them to newton functions

*QUANTTOMETER

and when readinf from newton use METERTOQUANT
Posted By: Rackscha

Re: Newton 2 wrapper - 05/13/09 20:12

OMG, what an empic fail laugh
Ok i'll try it
Posted By: Rackscha

Re: Newton 2 wrapper - 05/13/09 20:14

YES EMPIC FAIL(for me v.v)
It didnt change anything.
Oh and you should know: passing 0 for every coordinate as angle vector doesnt change anything to, and when using the x instead of the y axis to rotate around the point changes again. completely weird.
Give me an example if it works for you


EDIT: sorry for my angry words, but iam completely STRESSED(with school, 12 clath of gym)
Posted By: croman

Re: Newton 2 wrapper - 06/05/09 05:24

is this still alive? smile
Posted By: VeT

Re: Newton 2 wrapper - 06/09/09 12:28

yes smile
i'm finishing my diploma project and i'd be ressurect laugh
Posted By: Anonymous

Re: Newton 2 wrapper - 06/14/09 19:07

how can i use the Gamestudio savegames with newton? The positions of the Objects are not saved.

Is there a function like:
NewtonSetToPosition.

Because then i could save all positions of physic entities in a text file and when the game is loaded i can set all objects to their positions
Posted By: jweb

Re: Newton 2 wrapper - 06/16/09 09:24

hi
sorry i'm not up to date! have you release the car demo?

thx for you wrapper

Jweb
Posted By: flits

Re: Newton 2 wrapper - 06/16/09 18:16

i try to make a conveyer
now if they come in contact with the conveyer the get some force added
now my question is how to get both entity's pointers because the first one does work but not the second entity pointer

this is my try

Code:


ENTITY* test_unit;

void UserContactRestitution22 (const NewtonJoint* contactJoint, dFloat timestep, int threadIndex)
{
	dFloat Ixx;
	dFloat Iyy;
	dFloat Izz;
	dFloat mass;
	
	const NewtonBody* body;
	const NewtonBody* body0;
	const NewtonBody* body1;

	GenericContactProcess (contactJoint, timestep, threadIndex);

	body0 = NewtonJointGetBody0(contactJoint);
	body1 = NewtonJointGetBody1(contactJoint);

	body = body0;
	NewtonBodyGetMassMatrix (body, &mass, &Ixx, &Iyy, &Izz);
	if (mass == (float)0.0) {
		body = body1;
	}
	
	void* contact;
	for (contact = NewtonContactJointGetFirstContact (contactJoint); contact; contact = NewtonContactJointGetNextContact (contactJoint, contact)) {
		NewtonMaterial* nmaterial;
		nmaterial = NewtonContactGetMaterial (contact);
		
		you = (ENTITY*)NewtonBodyGetUserData(body);
		test_unit = (ENTITY*)NewtonBodyGetUserData(NewtonJointGetBody1(contactJoint));
		//NewtonMaterialSetContactElasticity (nmaterial, (float)you.skill98);
		
		if(test_unit != NULL)
		{
		if(you.skill10 == 1 && test_unit.skill10 == 2)// i have set both you en test_unit to the correct value
		{
		float pos[3], n[3];
		NewtonMaterialGetContactPositionAndNormal(nmaterial, pos, n);
		
		you.skill8 = 8; // add force on a other func else force get duplicated
		
		VECTOR pos_vec;
		VECTOR n_vec;
		vec_set(pos_vec,_vec(pos[0],pos[1],pos[2]));
		vec_scale(pos_vec,METERTOQUANT);
		draw_point3d(pos_vec,vector(0,0,255),100,5);
		}
		}
	}
}



thx flits
Posted By: VeT

Re: Newton 2 wrapper - 06/18/09 13:57

no, you cant set positions... well, i'd try to work with matrixes, maybe there is a solution smile

btw: i defend my diploma with 5 balls laugh so, i'm back after some days of drinking beer laugh
Posted By: EnjoMitch

Re: Newton 2 wrapper - 06/19/09 09:43

Congratulations on defending your diploma, and welcome to the club smile

I'm very grateful for your wrapper and I admire your dedication. I need only very small parts of the Newton's features and although your wrapper uses many advanced features, it unfortunately lacks the ability to add WED blocks collision tree (from my experience). I read your comment above newton_treecollisionaddentity():

Quote:
(note: if you would like to add WED blocks as static collision geometry then you have to pass NULL to ent_getmesh and loop through all blocks! the transformation to world space isn't necessary then.)


so I've done the following:

WARNING! THE FOLLOWING CODE IS INCORRECT!

1) I've changed the
void newton_treecollisionaddentity(NewtonCollision* treecollision, ENTITY* entity)
to
void newton_treecollisionaddentity(NewtonCollision* treecollision, ENTITY* entity, var argnum)

2) Inside the newton_addstaticcollisiongeometry(), after building collision tree for models, I've addded this loop:
Code:
var num = 0;
while ( (ent_getmesh(NULL, num, 0) != NULL) )
{
   newton_treecollisionaddentity(treecollision, NULL, num);
   num ++;
}



3) I've modified newton_treecollisionaddentity() to the following:

Code:
void newton_treecollisionaddentity(NewtonCollision* treecollision, ENTITY* entity, var argnum)
{
   var num = 0; 
   if(!entity) 
   {
      num = argnum;
   }
	
   LPD3DXMESH pmesh = (LPD3DXMESH)ent_getmesh(entity, num, 0);
   /* ... */

   if (entity)
   {
   //transform
   }
   else
   {
    // don't transform? 
     // add triangles to collision tree
      for(i = 0; i < numfaces; i++)
      {	
         float v[9];
         v[0] = pvertices[pindices[(i*3)+2]].x * QUANTTOMETER;
         v[1] = pvertices[pindices[(i*3)+2]].y * QUANTTOMETER;
         v[2] = pvertices[pindices[(i*3)+2]].z * QUANTTOMETER;
         v[3] = pvertices[pindices[(i*3)+1]].x * QUANTTOMETER;
         v[4] = pvertices[pindices[(i*3)+1]].y * QUANTTOMETER;
         v[5] = pvertices[pindices[(i*3)+1]].z * QUANTTOMETER;
         v[6] = pvertices[pindices[(i*3)+0]].x * QUANTTOMETER;
         v[7] = pvertices[pindices[(i*3)+0]].y * QUANTTOMETER;
         v[8] = pvertices[pindices[(i*3)+0]].z * QUANTTOMETER;
         NewtonTreeCollisionAddFace(treecollision, 3, v,12,   pattributes[i]);
         }
   }
/* ... */
}



Unfortunately it doesn't work, and the blocks are passable, as if a transformation was needed after all. The problem is that I need a transformation matrix (ent_getmatrix), but of course it only accepts ENTITY*. I could create my own transformation matrix, by setting pan, tilt and roll to 0, but what about x,y,z ? Can I get it somehow for the static blocks?
Could I ask you (or anybody else) for some help with this?
Posted By: VeT

Re: Newton 2 wrapper - 06/19/09 11:19

yes, blocks are still unavaivable for Newton... i'd ask Jcl for this
Posted By: EnjoMitch

Re: Newton 2 wrapper - 06/19/09 11:39

Thank you for your quick reply.
Happy sobering smile
Posted By: VeT

Re: Newton 2 wrapper - 06/19/09 11:44

thansk smile
This evening or tomorrow i'd release next version smile

btw, there is next Newton version is avaivable 2.02
http://www.newtondynamics.com/forum/viewtopic.php?f=9&t=4922&start=0
Posted By: EnjoMitch

Re: Newton 2 wrapper - 06/20/09 12:07

Unfortunately the new Newton version crashes some times with the wrapper.
OK, anyway, I've prepared a test case for v. 2.00:
Testcase link
The archive includes all sources and a release version
Z pushes the ball

My expectations are that the ball rolls normally on those adjacent models, without bouncing on their edges, and doesn't tunnel through the final model - lifted a bit to act as a wall. The latter is achievable by enabling continuous collision mode, but still is not 100% secure (and probably will never be exactly 100% as far as I understand physics engines, but let's say I'd like it "even more secure").

From what I've read on Newton forum, to increase the engine's precision, you have to call its Update function as often as possible. Some students reported that their collision problems were solved after calling the NewtonUpdate() 10 times of their graphics engine framerate. Supposing that this would solve my bouncing-on-egdes problem (I have to ask on Newton forum to make sure), here's the show stopper - in GS you can't wait for shorter time than one frame (graphical frame as far as I understand). From help, subject - wait():

Quote:
"The shortest wait time is one frame cycle, the longest wait time is (...)"


This means that we can't call your newton_update() function inside for example while(1) { wait(-0.001); } loop, because the time may be less than the frame cycle and won't work this way.

My idea is to write a C++ plugin which would be passed the newtonWorld pointer, then it would spawn a thread (f.e. Boost::Thread). Inside the thread we could have this loop:

double prevTime = 0;
while (!quit)
{

double time = timer.GetTime() - prevTime;
NewtonUpdate(newtonWorld, time);
Sleep(10); // sleep for as shortest time as possible
prevTime = timer.GetTime();
}

I already have a working plugin using Boost::Thread, but I'm not doing the most important thing there - I'm not calling the NewtonUpdate() function, heh.

What could also help could be using the double newton.dll instead of float. If the Newton's author confirms this, I could spend some time on reworking the wrapper to make it support doubles instead of floats. I think it should be a matter of some replacements in the wrapper's code and typedefing dFloat as double. What do you think?

Also check this reply from Julio:
http://www.newtondynamics.com/forum/viewtopic.php?f=9&t=4631&p=33329&hilit=edges#p33329

I think that we should update the wrapper to make it support version 2.02 of Newton. Any ideas where to begin?
Posted By: VeT

Re: Newton 2 wrapper - 06/20/09 12:21

I had already updated wrapper to v 2.02 and had finished with blocks.. now i'm going to add car physic and release Newton Wrapper v.20

What about timestep - i still have one idea about it... anyway, if you'll create a plugin, that would be able to work in different thread and call NewtonUpdate, you're wellcome...
but i still dont understand, where this problem comes: at my comp and notebook the original version of calling NewtonUpdate() once per frame works fine, but in your example ball moves really laggy
Posted By: EnjoMitch

Re: Newton 2 wrapper - 06/20/09 12:44

Originally Posted By: VeT
but i still dont understand, where this problem comes: at my comp and notebook the original version of calling NewtonUpdate() once per frame works fine, but in your example ball moves really laggy


Now that's something REALLY weird. Could you elaborate "laggy"? As in low frames per second? What's the FPS rate? (F11). If it's high then you say that the ball's movement is updated a lot slower than it should be for that FPS?
In this test case I'm really doing nothing in particular. I'm calling NewtonUpdate() every frame normally, just as you do - I haven't touched this part in this test case. Could you check if in sources there's fps_max = 10; in main() ? A stupid question maybe - as if I didn't know what I'm uploading but I suspect that there may have been a network cache problem.

The idea of calling Update more often is increasing the physics engine's precision - avoiding unwanted reactions such as tunnelling through walls. Once per frame is enough for slow speeds and games not demanding high precision, but for a simulation this may not be enough.
Posted By: VeT

Re: Newton 2 wrapper - 06/20/09 13:14

debug panel (F11) shows 180-200 fps, but it refresh once per second...
looking like its a computer problem: in the notebook everything fine with 500 fps.

//Once per frame is enough for slow speeds and games not demanding high precision, but for a simulation this may not be enough.
Hm, looking like you're right... on the other hand play with parameter of NewtonUpdate(), for example try NewtonUpdate(nworld, time_step / 64);
Posted By: EnjoMitch

Re: Newton 2 wrapper - 06/20/09 13:19

I've just received information from Dave Gravel at Newton forum, that the blocking on edges problem with rolling objects has been solved in version 2.02. Yeeehow!

Quote:
on the other hand play with parameter of NewtonUpdate(), for example try NewtonUpdate(nworld, time_step / 64);


Then, to achieve the same velocity impression, I'd have to multiply it by 4 ( 64 / 16 = 4 ), Because inaccuracies in physics engines are higher if the velocities are higher, the effect then would be exactly the same smile
Posted By: VeT

Re: Newton 2 wrapper - 06/20/09 15:16



List of updates:
v.20
- tested with Windows 7, build 7100
- newton_addstaticcollisiongeometry is updated for using with GameStudio A7.77 and later
- [!!!] at least added level geometry, now Newton can work with BLOCKS... demo with blocks is in the first level, map1.c
- Newton is updated to Newton 2.02
- JointLibrary is updated to Newton 2.02
- sky added
- multibody car started
Posted By: VeT

Re: Newton 2 wrapper - 06/20/09 15:17

//I've just received information from Dave Gravel at Newton forum, that the blocking on edges problem with rolling objects has been solved in version 2.02. Yeeehow!

What that for? smile

Cars are still in progress, but i decided not to run your time, dear users, who awaits compatibility with A7.77 and update to Newton 2.02 smile
Posted By: Quad

Re: Newton 2 wrapper - 06/20/09 18:11

oh yeah blocks.. thanks for the update.
Posted By: VeT

Re: Newton 2 wrapper - 06/20/09 18:26

i'm waiting for bug-reports smile
i think it can be a little slow on a huge levels, but its only my supposition
Posted By: the_mehmaster

Re: Newton 2 wrapper - 06/21/09 07:26

Thank you for making such a fantastic wrapper! smile. The only issue is that when i load the cone level, they fall down immediatly and shoot around randomly, or is this supposed to happen?
Posted By: VeT

Re: Newton 2 wrapper - 06/21/09 07:55

yes, they may fall on the floor, then they may rotate for a little time and finally fall down

Posted By: the_mehmaster

Re: Newton 2 wrapper - 06/21/09 08:05

what I mean is that they don't stay up at all. as soon as they hit the floor they shoot around randomly. Would having Physx acceleration on effect this? (i know it shouldn't) because i use nvidia physx in a lot of my games that i play...
Posted By: VeT

Re: Newton 2 wrapper - 06/21/09 08:38

in the nearest time smile
http://www.newtondynamics.com/forum/viewtopic.php?f=9&t=5003

what about your cones - are they rotate fro the very begining?
Posted By: the_mehmaster

Re: Newton 2 wrapper - 06/21/09 10:20

Yes, the cones are rotating, but it's very hard to explain what their doing.. i'll upload a video soon.
Posted By: VeT

Re: Newton 2 wrapper - 06/21/09 10:33

thats the best variant smile
Posted By: EnjoMitch

Re: Newton 2 wrapper - 06/21/09 11:15

I got some help from Julio and Delfi on Newton forum.
Problems with rolling objects, bouncing from edges can be solved by greatly increasing NewtonUpdate call frequency. So if the problem of GS is that it doesn't allow you to call a function in a while loop more often than once per frame, you can use a for loop in that while loop, which slices the current (time_frame / 16) into time intervals (subDt) so little, that when calling NewtonUpdate as many times as the count of slices, you get the necessary NewtonUpdate call frequency. Of course, you also you have to pass NewtonUpdate the correct sub delta time.

Here's the code, adapted to your wrapper, for super precision required in simulations:
Code:
void newton_update()
{
  var newtonFPS = 1000;
  if ((newton_running) && (nworld!=0))
  {
			
  float dt = time_frame / 16;
  var vratio = (dt * newtonFPS);
  var n = integer(vratio) + 1;
  float subDt = dt / n;
  int i;
  for ( i = 0; i < n; i++ )
    NewtonUpdate(nworld, subDt);
    //  proc_mode = PROC_LATE;	
  }	
}



You could pass the desired Newton FPS with newton_start() for example.


Another problem is that while boosting Newton FPS to solve bouncing on edges problem solves it in case of models, it doesn't work for blocks. What do you suspect? Vertices set not precisely enough maybe?
I'll investigate this myself after I fully integrate Newton into my game. Finally I have at least one firm solution. Thanks so far.
Posted By: VeT

Re: Newton 2 wrapper - 06/21/09 12:06

Wow, looking like this works :))
i tried some examples of time slicing, but looking like this really works, thank you smile

I don't think, that its because of vertices... Maybe try to increase frequency.
Posted By: EnjoMitch

Re: Newton 2 wrapper - 06/21/09 12:54

No problem. I wanted to give something back.

I tried increasing the frequency up to 10000, but even that didn't help.
Fortunately, the blocks work perfectly as walls with continuous collision mode on, and I can build floor with a set of 2^n x 2^n models easily.
Posted By: VeT

Re: Newton 2 wrapper - 06/21/09 13:08

Try to increase to 1000000.. you'll see the difference wink
I think, you may make newtonFPS lower.
Posted By: EnjoMitch

Re: Newton 2 wrapper - 06/21/09 13:14

Than 1000? No, I don't think so. Notice that my test case works with about 400 - 500 FPS, which gives 400 - 500 FPS for Newton. Setting it to 1000 gives two or three times that much FPS (three times because of that +1. It's AT LEAST 1000). It's suspicious that you need at least 1000 FPS, but it does make the difference. You can try lowering it for the test case below GS FPS and you'll see the ball bouncing then.

[EDIT]
Lines
var vratio = (dt * newtonFPS);
var n = integer(vratio) + 1;

can be merged into one line
var n = integer(dt * newtonFPS) + 1;
of course.


Posted By: VeT

Re: Newton 2 wrapper - 06/21/09 13:26

Real difference i see only with newtonFPS = 100000, then it works very laggy. Anyway, there is a little difference between 1000 and 1: car bounce in different ways... I'll check it in your level
Posted By: EnjoMitch

Re: Newton 2 wrapper - 06/21/09 13:28

If you've already boosted the Newton's FPS, which is what would satisfy Newton guys, maybe it's about time to report a bug at their forum
Posted By: VeT

Re: Newton 2 wrapper - 06/21/09 13:31

Ah, i see... with your update function, ball doesn't move through the wall smile
Posted By: EnjoMitch

Re: Newton 2 wrapper - 06/21/09 13:37

That's also because I set continuous collisions:

Code:
action ball_newt()
{
  wait(3);
  gnBall = newton_addentity(me, 75, NEWTON_SPHERE, onforceandtorque);
  NewtonBodySetContinuousCollisionMode(gnBall, 1); // avoid tunnelling
}



btw, are you sure that you need to wait for 3 frames before doing anything, or it is just for safety reasons?
Posted By: VeT

Re: Newton 2 wrapper - 06/21/09 13:42

I tried to set wait(1); in my "first newton manual" and i got a lot of bug-reports from users: ball falls down through the floor, so i return wait(3); and now its looking to work good.

You can try this: first level (with wait(1) )
http://files.filefront.com/WrapperLitecTutorial1rar/;13398911;/fileinfo.html
and second(with wait(3))
http://files.filefront.com/WrapperLitecDemo1v2rar/;13641005;/fileinfo.html

I think, DLL needs 3 frames to load... GameStudio doesn't have a function to show if DLL is loaded.
Posted By: VeT

Re: Newton 2 wrapper - 06/22/09 20:40

okay, buoyancy is almost ready... car is still at work wink

Posted By: the_mehmaster

Re: Newton 2 wrapper - 06/24/09 07:45

Here's the video as promised... Download!

Btw, buoyancy looks awesome!
Posted By: VeT

Re: Newton 2 wrapper - 06/24/09 11:11

Got it (why not youtube? smile )
Do you have the same problem with bodies on another levels?

Looking like its because of new version of A7.77... Try the latest wrapper demo
Posted By: the_mehmaster

Re: Newton 2 wrapper - 06/24/09 20:21

Quote:
(why not youtube? smile )

forgot my password... blush

About the wrapper...
Yes, this happens with all the bodys. In the joint(rope) demo, all the different segments rotate randomly.
Posted By: VeT

Re: Newton 2 wrapper - 06/24/09 21:50

Try the latest version of wrapper. smile
Posted By: the_mehmaster

Re: Newton 2 wrapper - 06/25/09 20:36

Yay!

Updating to the latest wrapper version works... Thanks!!

The reason i downloaded the old version was because it had more downloads... made me assume it was correct.
Posted By: VeT

Re: Newton 2 wrapper - 06/25/09 20:52

Quote:

List of updates:
v.20
****
- newton_addstaticcollisiongeometry is updated for using with GameStudio A7.77 and later
****


just a little attention, my friend smile
Posted By: VeT

Re: Newton 2 wrapper - 07/05/09 16:49

New video thread was added on the Newton forum, there you can see videos with Newton: http://www.newtondynamics.com/forum/viewtopic.php?f=14&t=5260
Posted By: the_mehmaster

Re: Newton 2 wrapper - 07/06/09 06:38

will buoyancy be finished soon? i'm quite looking forward to that..
Posted By: VeT

Re: Newton 2 wrapper - 07/06/09 06:56

Yes, i see that car cant be finished in the nearest time, so i'll publish buoyancy this evening
Posted By: the_mehmaster

Re: Newton 2 wrapper - 07/06/09 08:10

Cool. This will make a nice addition to the 'fluid dynamics for .hmp' script i am developing with evilSOB.
Posted By: VeT

Re: Newton 2 wrapper - 07/06/09 10:09

I saw that... in the evening i'll look at your project smile
Posted By: VeT

Re: Newton 2 wrapper - 07/06/09 17:08


here you are, v21

- newton_update() is updated smile now you can set the frequency of Newton updates with the help of newtonFPS variable
- finished newton buoyancy, map23.c. Also trigger example is avaivable there, it can be usefull

looking like filefromt is down, as he is "Validating Data ............" about half of hour... so i decided to move to DepositFiles, if anybody would have some problems with it, just let me know

http://depositfiles.com/files/9x1svcbe4
Posted By: VeT

Re: Newton 2 wrapper - 07/07/09 15:19

Damned, all pictures are gone... i hate filefront frown
Posted By: the_mehmaster

Re: Newton 2 wrapper - 07/07/09 21:09

Where's all the encouragement?

Great work VeT, as always.
Posted By: VeT

Re: Newton 2 wrapper - 07/07/09 23:17

//Where's all the encouragement?
emm? smile
Posted By: EnjoMitch

Re: Newton 2 wrapper - 07/19/09 06:09

VeT, do you know what's wrong woth rotations of bodies in the new Newton? No matter what angular damping or friction I set, the objects rotate like crazy.
Posted By: VeT

Re: Newton 2 wrapper - 07/19/09 13:12

I know, also this problem was described here: for Gamestudio versions after A7.77, you need to use updated ewton_addstaticcollisiongeometry() function, look for Newton wrapper versions after v20.
Posted By: EnjoMitch

Re: Newton 2 wrapper - 07/20/09 06:41

Thank you, it helped. I was sure that I had the latest version...
Posted By: VeT

Re: Newton 2 wrapper - 07/20/09 07:24

Thats great smile
I'm planing to re-upload all pictures before next version, so it would be a little easier to note latest versions.
Posted By: VeT

Re: Newton 2 wrapper - 07/24/09 14:35

Some minor upgrades are done, still waiting for Raycast car in Newton.
Posted By: Felixsg

Re: Newton 2 wrapper - 07/25/09 07:53

thanks. Not abandon the car support please
Posted By: FBL

Re: Newton 2 wrapper - 09/06/09 22:17

First of all thanks for all the hard work.

I have some weird problem and the obvious reason most likely is me.

I use some test level consisting of a mixture of blocks and models. The models have flag8 turned on.

I drop a physics sphere in there with a small change to the gravity vector:

void onforceandtorque2(NewtonBody* body)
{
float mass, ixx, iyy, izz;
NewtonBodyGetMassMatrix(body, &mass, &ixx, &iyy, &izz);
NewtonBodySetForce(body, vectorf(0, -1.024 * mass, -9.755 * mass));
}

This way I simulate a 6° slope without actually working with a slope.
Ball behaviour is fine, the only problem is, it does not collide with walls - it just passes through them. Regardless whether we're talking about blocks or models
Floor is not passed. What is going on!?

I modified the newton_debug.c to see whether the collision geometry was transfered correctly to Newton and everything looks fine.

I don't really understand what is wrong. I have worked with Newton before in Dark Basic, so I know Newton can do it.
I haven't done any change to the newton_main file, but couldn't see an obvious error with the collision tree generation either...

edit: I possible found it. Seems like my scale in A7 is too huge and the factor I need for transforming to meters is getting inaccurate.
Posted By: Rei_Ayanami

Re: Newton 2 wrapper - 09/07/09 14:50

Iīve got a question: Is there a list or a manual where are all the newton functions? I canīt find it!
Posted By: FBL

Re: Newton 2 wrapper - 09/07/09 16:01

You have to download the Newton SDK from the Newton hoempage.
Posted By: jweb

Re: Newton 2 wrapper - 09/13/09 09:33

hi
is car physik in the laste Version implemented ?
Posted By: Rei_Ayanami

Re: Newton 2 wrapper - 09/13/09 09:54

Okay, i download the sdk, maybe i can see find it out^^ - i like Newton more than PhysX because itīs free^^
Posted By: FBL

Re: Newton 2 wrapper - 09/13/09 19:54

I did so too. But there seems to be no manual included in the beta version...
Posted By: VeT

Re: Newton 2 wrapper - 09/13/09 20:08

There is no manual at all laugh
Okay, is somebody is still interested in Newton, i'll continue developing and publishing of a wrapper.
Posted By: VeT

Re: Newton 2 wrapper - 09/13/09 20:22

2Firoball sorry for a large delay, is yor problem is still actual?
Posted By: FBL

Re: Newton 2 wrapper - 09/13/09 20:50

I managed to get this fixed by changing the scale of my Level in A7.

I had a scale of 670 quants being 62cm which made my quant2meter factor extremely small. This probably resulted in inaccuracies and caused the collision problem.


Currently I'm trying to get a hinge accelerated on key press and stop it at a certain max/min angle. This does not work yet properly and I'm trying to get it done.
While trying around with the Jointlibrary I found out that the NewtonUserJoint typedef is not yet added to your import files.
Posted By: VeT

Re: Newton 2 wrapper - 09/13/09 22:00

yep, i got latest v 9 beta of Newton and waiting for beta 10... There may be a CharacterController and RaycastCar... also, i'll look into NewtonUserJoint
Posted By: FBL

Re: Newton 2 wrapper - 09/14/09 08:37

One thing I'd like to see:

Instead of having to define the quant2meter and meter2quant, and having to define the newtonworld struct instance I'd like to see a proper get/set function interface.

Meaning newtonworld is defined inside the wrapper files, and I have some sort of Newton_getWorld() function to return the pointer.
Same goes for the conversion factors, maybe a function like Newton_setMetertoquant() or so...

I'm currently trying to get some proper hinge setup working. If I end up with something useful I maybe post the code here and you can decide whether you want to take it over to the wrapper or not.

Depends on how generic it will get...


Also maybe it makes sense to dd a function which generates an ANGLE from a matrix and converts an ANGLE back to a matrix, without being tied to an entity.
Currently I have the problem that Newton expects a quaternion, I still have to look up how it is defined and how this has to be set in order to get the correct behaviour.
Posted By: Rei_Ayanami

Re: Newton 2 wrapper - 09/14/09 16:17

Iīm still interested!!! -I like it!
Posted By: sebbi91

Re: Newton 2 wrapper - 09/14/09 16:40

I agree with Rei_Ayanami
Posted By: Felixsg

Re: Newton 2 wrapper - 09/14/09 21:59

also I interesting
Posted By: Carloos

Re: Newton 2 wrapper - 09/22/09 21:24

Iīm terribly interested laugh

Keep up the great work.
Posted By: VeT

Re: Newton 2 wrapper - 09/22/09 22:19

Roger that laugh
Now i'm working on wrapping latest 2.09 version and also i believe that 2.10 would be published in the nearest time laugh
Posted By: darkinferno

Re: Newton 2 wrapper - 09/23/09 00:01

the reason why this isnt used as much as it could be is its ease of use, like how the physX plugin maintains some similarites to the native gs plugin in terms of function calls, its rather hard for me to make any progress if i have to keep learning new systems, with that said... keep up the work, i for one prefer newton over physX, just that learning to use it properly isnt on my todo list atm
Posted By: gri

Re: Newton 2 wrapper - 09/24/09 09:08

hi VET,

please keep up your process on that.

Because of at least 2 Reasons:

1. You put already much energy and time in your Wrapper.

2. Its good for us all to have an Alternative to the PhysX Plugin(of course its great).


The A8 version somedays comes with PhysX only because ODE is outdated.

So if one of us needs Physics in his game but dont want to forcing the customers to install the PhysX Drivers, then is the Use of your wrapper the right Decision.

And I think NOT a lot uf us needs Physics for Clothing in our games in near future.
(Even with PhysX its only a Gadget without practical Use in Moment - it only decreasing the Framerate )


So keep up your good work.

greetings,
maik
Posted By: jweb

Re: Newton 2 wrapper - 09/27/09 20:06

sorry for my repeated the question, but I can coding with the wrapper a car?

THX
Posted By: VeT

Re: Newton 2 wrapper - 09/28/09 18:13

jweb, you can code everything you want: files for using DLL are ready... now i'm working only on examples (so, if programmer knows Newton good, he can create car even with v.1 of wrapper laugh )

Thatks for good words, guys, Newton beta 10 is out, i'll continue my wrapper wink
Posted By: gri

Re: Newton 2 wrapper - 09/29/09 09:51

hi VET,

one question:

First I thought I have to install something because I couldnt control the camera in your examples.

Then I put in some code for camera movement & rotating and it works.
Did you just forget it in the last version?

,gri
Posted By: FBL

Re: Newton 2 wrapper - 10/01/09 13:49

The start function which automatically creates the collision data from the level for Newton should return a NewtonBody pointer. Why?
this way the whole level can be used with other materials than just the default one.

Yes, I can modify the function on my own, just wanted to share that for a future improvement.
Posted By: FBL

Re: Newton 2 wrapper - 10/04/09 15:33

more things:

I'd like to have an interface for newtonFPS so I can modify it without having to change your script.

Also I have added two useful functions, maybe you want to include them in the wrapper:

Code:
NewtonJoint* newton_getjoint(ENTITY* entBody)
{
	NewtonJoint* psJoint = NULL;
	
	if (entBody->skill98 != 0)
	{
		psJoint = entBody->skill98;
	}
	return psJoint;
}

NewtonBody* newton_getbody(ENTITY* entBody)
{
	NewtonBody* psBody = NULL;
	
	if (entBody->skill99 != 0)
	{
		psBody = entBody->skill99;
	}
	return psBody;
}



I store the joint pointer in skill98 of the object.


Next thing:

newton_materials_init() should not be included in newton_start() as it seems to be a definition for special physics samples.

Quant2meter and meter2quant should already be included in newton_main.c like this:
#ifndef QUANTTOMETER
#define QUANTTOMETER (float)0.03125
#endif

#ifndef METERTOQUANT
#define METERTOQUANT (float)32
#endif
This allows redefining them before inclusion of the wrapper in the own project


I also added this simple thing to newton_main.c:

Code:
NewtonWorld* nworld = NULL;



NewtonWorld* newton_getworld()
{
	return nworld;
}


Now nworld doesn't have to be defined in own scripts. If it's needed, it can be retrieved via this access function.

The goal of all my requests: I can just drop the latest release in my project folder, without having to adjust a single line laugh
Maybe you want to include some of this stuff in the next version of the wrapper.

Thanks for reading
Posted By: FBL

Re: Newton 2 wrapper - 10/04/09 15:40

Oh, right.
I created a simple hinge setup function.
Maybe you're interested:

Code:
NewtonJoint* newton_createhinge(VECTOR* vecPivot, VECTOR* vecAxis, ENTITY* entBody1, ENTITY* entBody2, void* fpCallback)
{
	NewtonBody* psBody1 = NULL;
	NewtonBody* psBody2 = NULL;
	NewtonJoint* psJoint;
	float* fpPivot;
	float* fpAxis;
	
	/* get Newton bodies */
	if (entBody1 != NULL)
	{
		psBody1 = entBody1->skill99;
	}
	
	if (entBody2 != NULL)
	{
		psBody2 = entBody2->skill99;
	}

	fpPivot = vectorf(vecPivot);
	fpPivot[0] *= QUANTTOMETER;
	fpPivot[1] *= QUANTTOMETER;
	fpPivot[2] *= QUANTTOMETER;

	fpAxis = vectorf(vecAxis);

	psJoint = NewtonConstraintCreateHinge (psWorld, fpPivot, fpAxis, psBody1, psBody2);
	if (fpCallback != NULL)
	{
		NewtonHingeSetUserCallback (psJoint, fpCallback);
	}


	/* store joint pointers in related objects */
	if (entBody1 != NULL)
	{
		entBody1->skill98 = psJoint;
	}
	
	if (entBody2 != NULL)
	{
		entBody2->skill98 = psJoint;
	}
}


Posted By: VeT

Re: Newton 2 wrapper - 10/04/09 17:58

Originally Posted By: gri
Then I put in some code for camera movement & rotating and it works.
Did you just forget it in the last version?

Hm, really, i confirmed this bug... Maybe, this is beacuse of new version of GS, as i never get this before and nobody told me about this.

Now i'll add camera code, make and upload pictures, re-read your posts and release new version. wink

2Firoball thanks for code, i'll look into it and add it to next version, if everything would be okay wink thanks for your code, looking like usefull
Posted By: FBL

Re: Newton 2 wrapper - 10/04/09 19:55

How about a slider hinge?

Code:
NewtonJoint* newton_createslider(VECTOR* vecPivot, VECTOR* vecDir, ENTITY* entBody1, ENTITY* entBody2, void* fpCallback)
{
	NewtonBody* psBody1 = NULL;
	NewtonBody* psBody2 = NULL;
	NewtonJoint* psJoint;
	float* fpPivot;
	float* fpDir;
	
	/* get Newton bodies */
	if (entBody1 != NULL)
	{
		psBody1 = entBody1->skill99;
	}
	
	if (entBody2 != NULL)
	{
		psBody2 = entBody2->skill99;
	}

	fpPivot = vectorf(vecPivot);
	fpPivot[0] *= QUANTTOMETER;
	fpPivot[1] *= QUANTTOMETER;
	fpPivot[2] *= QUANTTOMETER;

	fpDir = vectorf(vecDir);

	psJoint = NewtonConstraintCreateSlider(psWorld, fpPivot, fpDir, psBody1, psBody2); 
	if (fpCallback != NULL)
	{
		NewtonSliderSetUserCallback (psJoint, fpCallback);
	}
	
	/* store joint pointers in related objects */
	if (entBody1 != NULL)
	{
		entBody1->skill98 = psJoint;
	}
	
	if (entBody2 != NULL)
	{
		entBody2->skill98 = psJoint;
	}
}



Thought I might share this. Almost the same code like for a hinge though.

Posted By: FBL

Re: Newton 2 wrapper - 10/04/09 20:03

Originally Posted By: darkinferno
the reason why this isnt used as much as it could be is its ease of use, like how the physX plugin maintains some similarites to the native gs plugin in terms of function calls, its rather hard for me to make any progress if i have to keep learning new systems, with that said... keep up the work, i for one prefer newton over physX, just that learning to use it properly isnt on my todo list atm


I think that's not entirely possible, as Newton offers more stuff than ODE, like materials.

The wrapper is working pretty good, imho just the wrapper interface needs some more minor cleanup to make it ready for plug and play without having to edit the wrapper code.
But I'm sure that vet will further improve it.
Posted By: VeT

Re: Newton 2 wrapper - 10/12/09 22:57

Headers are updated to latest Newton version, beta 10 (http://newtondynamics.com/forum/downloads.php)... planned to improve Joint library with firoball's code and new features of Newton
Posted By: FBL

Re: Newton 2 wrapper - 10/13/09 15:46

Thanks.

Where can I get the wrapper files? Guess I'm blind... laugh
Posted By: VeT

Re: Newton 2 wrapper - 10/13/09 20:57

Nope, i just want to add at least one interesting feature (character controller, ragdoll, car, or brekeable entities) and then publish new version laugh
Posted By: Felixsg

Re: Newton 2 wrapper - 10/14/09 01:26

really great
I like to test the new version
Posted By: DarkSoul

Re: Newton 2 wrapper - 10/19/09 15:31

Hi, is there a document or help file with the commands for physics newton?
Posted By: FBL

Re: Newton 2 wrapper - 10/19/09 21:07

The Newton Wiki
Posted By: DarkSoul

Re: Newton 2 wrapper - 10/20/09 09:23

Yes, but I dont can access some commands, said me that:

Permission error
From Newton Wiki
Jump to: navigation, search

Quote:
You do not have permission to do that, for the following reason:
The action you have requested is limited to users in the group user.


This occurs with the following commands:

Quote:
NewtonMeshAddFace
NewtonMeshApplyBoxMapping
NewtonMeshApplyCylindricalMapping
NewtonMeshApplySphericalMapping
NewtonMeshBeginFace
NewtonMeshCalculateVertexNormals
NewtonMeshCreate
NewtonMeshCreateFromCollision
NewtonMeshDestroy
NewtonMeshEndFace
NewtonMeshFirstMaterial
NewtonMeshGetIndirectVertexStreams
NewtonMeshGetVertexCount
NewtonMeshGetVertexStreams
NewtonMeshMaterialGetIndexCount
NewtonMeshMaterialGetIndexStream
NewtonMeshMaterialGetIndexStreamShort
NewtonMeshMaterialGetMaterial
NewtonMeshNextMaterial
NewtonMeshPlaneClip


How can I access them?
Posted By: FBL

Re: Newton 2 wrapper - 10/20/09 10:19

I guess you need to register at the forum or sth like that.
Posted By: DarkSoul

Re: Newton 2 wrapper - 10/20/09 11:29

Ah, thanks!, that was my problem.
Posted By: VeT

Re: Newton 2 wrapper - 10/22/09 23:50

2DarkSoul, You may see my example levels, wiki, headers and ChangeList.txt to find what you want laugh

I spend too mush time on Character controller, i even launched it one time, but now it crash again... Tomorrow i'll try to finish it.

Also, i added Newton Visual Studio's project to work with lite-c, so now i even can debug JointLibrary.dll in runtime. Hope that would help.
Posted By: VeT

Re: Newton 2 wrapper - 10/29/09 11:01

http://depositfiles.com/files/ae1l0tpro

v.23
- tested with Windows 7, build 7600. Found bug on Power Mouse map.
- Newton is updated to Newton 2.10
- JointLibrary is updated to Newton 2.10
- updated map10.c, physic object position changings demo, just press Space button

Firoball, i remember about your joints, but for now i must finish with character controller and car
Posted By: flits

Re: Newton 2 wrapper - 10/31/09 19:32

thx for the update

the demo works oke (except power mouse)

now i got a strange problem
i got a very old game with newton (wich is old to)
no i try to include the new one

the problem is that my block is valing trowh a entity with the flag8 attached(didnt try geomtry)
if i use the old dll it doesnt

is there any explanation fore this?

flits
Posted By: VeT

Re: Newton 2 wrapper - 11/01/09 14:02

Hi, flits
try to increase wait() time in actions

also, can you send me that level? some function changed, look at the Changelist.txt of Newton
Posted By: flits

Re: Newton 2 wrapper - 11/01/09 16:31

i checked all of my code in the script that replaced your main.c opend old headers

it works again

thx anyway
Posted By: painkiller

Re: Newton 2 wrapper - 11/02/09 16:48

can I desactivate gravity in the newton engine? I need to desactivate it for creating a spaceship simulator
Posted By: flits

Re: Newton 2 wrapper - 11/02/09 17:11

in the newton_main.c you will find void onforceandtorque(...

change the -9.8 to 0 that makes zero grav

hop this helps you
Posted By: FBL

Re: Newton 2 wrapper - 11/02/09 17:56

Or create your own onfordeandtorque function and then assign this one with newton_addentity.

Then you don't have to touch the wrapper code.
Posted By: painkiller

Re: Newton 2 wrapper - 11/02/09 18:41

ok, thanks. Where i can find a tutorial with the functions of the engine? like adding forces, torques, etc.
Posted By: flits

Re: Newton 2 wrapper - 11/02/09 19:02


Code:
void my_onforceandtorque(NewtonBody* body)
{
	float mass, ixx, iyy, izz;
	NewtonBodyGetMassMatrix(body, &mass, &ixx, &iyy, &izz);
	NewtonBodySetForce(body, vectorf(0, 0, 0));
}

function player()
{
wait(2);
newton_addentity(me, (float)(9), NEWTON_BOX,my_onforceandtorque);

...



ore

Code:
function player()
{
wait(2);
newton_addentity(me, (float)(9), NEWTON_BOX,NULL);
...



didnt test it but should work
Posted By: painkiller

Re: Newton 2 wrapper - 11/02/09 19:12

thanks
Posted By: VeT

Re: Newton 2 wrapper - 11/03/09 09:48

Originally Posted By: flits
i checked all of my code in the script that replaced your main.c opend old headers

it works again

thx anyway


flits, wait-wait... what did you done?
Posted By: flits

Re: Newton 2 wrapper - 11/03/09 13:12

srry for my bad english

i implent your script bij putting your project into my folder (and replace the .dl en delete stuff i dont need)

to insert your wrapper into my game, i got a script that replaces the things that are needed (only stuff inside the main.c).

now my script used old headers that are still in your wrapper directory(so no syntax error)

i hope you know now what i mean else i while upload the script that replaces the main.c
Posted By: VeT

Re: Newton 2 wrapper - 11/03/09 14:13

so...
with old headers all objects collide as its expected
with new version some objects ignores other?
Posted By: flits

Re: Newton 2 wrapper - 11/03/09 15:06

with the old headers they ignore each other

new header all objects collide as its expected
Posted By: VeT

Re: Newton 2 wrapper - 11/03/09 19:56

Ah, thats good... I was afraid i missed something important laugh
Posted By: VeT

Re: Newton 2 wrapper - 11/16/09 02:04

By the request of users, added manual "add Newton to your project in 10 steps": main.c is cleaned and commented wink
Posted By: jweb

Re: Newton 2 wrapper - 11/16/09 18:30

hi Vet
great Work !!!
Ask a question about Newton 1.0. I have some old source code of Newton 1.0 Sampels, can I convert them into the new wrapper?
Posted By: VeT

Re: Newton 2 wrapper - 11/16/09 22:28

Hi
You have version 1.0 of Newton Wrapper or Newton SDK?
Posted By: jweb

Re: Newton 2 wrapper - 11/17/09 15:37

hi
no I have a newton.dll from 22.02.2004 and wdl code named newton.wdl, newtonfriction.wdl, NewtonHiges.wdl, newtonparticle.wdl and newtonvehicle.wdl.
In the newton.wdl the first Line
// Newton Game Dynmaics 1.0 (NGD)
//Game Studio Plugin interface to NGD : by Julio Jerez 08/05/2003

Sampels named NGD_Tutorial (an rover sampel) forklift, and a Car Sample.

THX


Posted By: FBL

Re: Newton 2 wrapper - 11/17/09 17:22

Wow that's old stuff.
Didn't know Julio was involved in GS stuff
Posted By: VeT

Re: Newton 2 wrapper - 11/18/09 01:05

Yep, too old... dll, wrapper and whole system is another now (as i remember, there were used speshial file with physic geometry)
Posted By: Felixsg

Re: Newton 2 wrapper - 11/18/09 09:37

Are any progress in the car physics?
Great work
Posted By: goanna

Re: Newton 2 wrapper - 11/18/09 10:57

I checked out the videos and I'm just blown away, truely awesome!!
Posted By: yorisimo

Re: Newton 2 wrapper - 12/02/09 19:34

Does anyone have a good example of custom joints? I would like to use the CreateCustomHinge function along with HingeEnableLimits and HingeSetLimits because I use many hinges that have limits. I am very confused about what pinsAndPivoChildFrame is supposed to be. I've looked at the Newton documentation but there isn't much help on the JointLibrary yet.

I'm also wondering what exactly the CustomKinematicController is used for. My game/simulator requires a combination of both kinematic (actual recorded movements from a human) and physics simulation of objects that the user manipulates.
Posted By: VeT

Re: Newton 2 wrapper - 12/03/09 10:18

http://newtondynamics.com/forum/viewtopic.php?f=9&t=4922&start=0

Newton 2.12 is out, updating wrapper...

yorisimo, try to ask Firoball or on Newton's forum.
Posted By: FBL

Re: Newton 2 wrapper - 12/03/09 11:11

I only used the old customhinge, not custom joint.
The code for using the hinge is somewhere in this thread.
Posted By: VeT

Re: Newton 2 wrapper - 12/03/09 11:19

http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=292550&#Post292550
Here it is laugh
Posted By: Felixsg

Re: Newton 2 wrapper - 12/04/09 21:42

I think I understand destruction physics objects
in the new version of newton (by the moment only beta)
but appear that is the next release
Posted By: yorisimo

Re: Newton 2 wrapper - 12/07/09 22:16

I believe that link is only regarding the internal hinge joint. From the Newton Wiki Newton Wiki: "The internal Hinge joint is a legacy join form previous version that we do not recommend continue using."

I am interested in using the CustomHingeJoint from the new joint library in Newton 2 (especially because it has built in joint limits).

I had trouble figuring out what the pinsAndPivoChildFrame matrix was supposed to be but I figured it out...here's an example

Code:
//about x axis
	float pinPivotMatrix[16] = {1, 0, 0, 0,   0, 1, 0, 0,   0, 0, 1, 0,   0, 0, 0, 1};
		//about y axis
	//float pinPivotMatrix[16] = {0, 1, 0, 0,   1, 0, 0, 0,   0, 0, 1, 0,   0, 0, 0, 1};
		//about z axis
	//float pinPivotMatrix[16] = {0, 0, 1, 0,   1, 0, 0, 0,   0, 1, 0, 0,   0, 0, 0, 1};
	
//Set the position of the pivot point
	pinPivotMatrix[12] = 160*QUANTTOMETER;
	pinPivotMatrix[13] = 147*QUANTTOMETER;
	pinPivotMatrix[14] = 400*QUANTTOMETER;
	
	NewtonUserJoint* nujoint = CreateCustomHinge(pinPivotMatrix, nbodyChild, nbodyParent); 

	HingeEnableLimits (nujoint, 1);
	float ub = 45*DEG2RAD;
	float lb = -45*DEG2RAD;
	HingeSetLimis (nujoint, lb, ub);


Posted By: FBL

Re: Newton 2 wrapper - 12/08/09 07:57

Yes the hinge joint is legacy only, but it worked quick and fine for me, so I just use it and eeryhting is fine. laugh
Posted By: Tai

Re: Newton 2 wrapper - 12/12/09 16:05

Just wanted to say thanks for this; I'm currently using it in my project, and it works great.
Posted By: yorisimo

Re: Newton 2 wrapper - 12/14/09 15:55

VeT,

I noticed you had a post on the NGD forum about this. Post

In NewtonJointLibraryMain.c, i believe you should replace the commented out lines with the uncommented lines. That works for me.

Code:
//typedef void NewtonUserJointDestructorCallback;
//typedef long NewtonUserJointSubmitConstraintCallback;
typedef void *NewtonUserJointDestructorCallback; 
typedef void *NewtonUserJointSubmitConstraintCallback;



Also, Julio has added some functions for the CustomHinge in the latest version 2.13. I made the following additions in your wrapper:

in NewtonJointLibraryMain.c:
Code:
// generic joint functions
...
JOINTLIBRARY_API NewtonJoint* CustomGetNewtonJoint (const NewtonUserJoint *joint); 
...
// Interface for a custom Hinge joint with Limits
JOINTLIBRARY_API dFloat HingeGetJointAngle (const NewtonUserJoint* hingeJoint);  
JOINTLIBRARY_API void HingeGetPinAxis (const NewtonUserJoint* hingeJoint, dFloat* pin); 
JOINTLIBRARY_API dFloat HingeCalculateJointOmega (const NewtonUserJoint* hingeJoint);



and in NewtonJointLibraryAPI.c:
Code:
// genetic joint functions
...
API (CustomGetNewtonJoint, jointlibrary)
...
// Interface for a custom Hinge joint with Limits
...
API (HingeGetJointAngle, jointlibrary) 
API (HingeGetPinAxis, jointlibrary) 
API (HingeCalculateJointOmega, jointlibrary)



I'd also like to say thanks for all your work on this! I find this wrapper very useful.
Posted By: Rackscha

Re: Newton 2 wrapper - 12/29/09 18:20

Great improvements to your plugin.

I noticed that the movement is faster than the movement of older versions. The older versions always seems to look like slowmo(my pc is fast enough^^). This now looks realtime and is an eye-candy.

Hey someone already found the "vote for Vet as god" button grin?

Ok to be serious again: I really like your contribution and that you put so much time into it.

Keep it up, i count on you wink

Greets
Rackscha
Posted By: VeT

Re: Newton 2 wrapper - 01/06/10 16:14

yorisimo, thanks, so you make character controller works?

Tai, Rackscha, thanks for good words laugh

Firoball, thanks in general grin
Posted By: Rackscha

Re: Newton 2 wrapper - 03/22/10 17:23

Question about joints: Static joints are working?
If YES i could try to make some Bad Company 2 Building with collapse effect
(hey it's using just joints nothing special in BC2, no realtime breakdown like Readfaction Guerilla and still neds a hell of a CPU o.O)


Greets
Rackscha
Posted By: BigM

Re: Newton 2 wrapper - 04/26/10 22:29

Hi VeT,

I'm back to messing with lite-c and Newton. It's good to see you kept up the great work!

As I was adapting my code to fit the newest version of the wrapper I noticed that *NewtonCorkscrewCallBack was being cast as a DWORD instead of a void. This had already been corrected in earlier versions. Is there a reason for re-introducing the DWORD cast? I have to change it to void in order not to break my code.

I also noticed that there is now a NewtonMain2.18.c and a NewtonMain.c, a NewtonAPI2.18.c and a NewtonAPI.c (and likewise for the JointLibrary files). What are the differences between the two and which one should we use?

Cheers
Posted By: FBL

Re: Newton 2 wrapper - 04/27/10 18:44

I did some tests with the Newton wrapper and A8.

The changes to get it to run are not so difficult and quickly done.

1.) open newton_main.c
2.) drop the _VERTEX_ struct and whenever it is used in the code, use D3DVERTEX instead.
3.) in your main script, currently you need to use #define A8 before including acknex.h. This won't be necessary with future A8 releases

4.) if you remove the #define A8 from your code, it should work with A7 again.

Have fun laugh
Posted By: VeT

Re: Newton 2 wrapper - 05/18/10 00:33

Thanks laugh

Hi all, sorry for delays, but i have a good news: in some days i'm planing to return to work on wrapper laugh
Posted By: 3run

Re: Newton 2 wrapper - 05/18/10 03:17

Thats just great!!! laugh Waiting for your rag-dolls dude wink
Posted By: Felixsg

Re: Newton 2 wrapper - 05/19/10 09:42

great thanks
Posted By: Rackscha

Re: Newton 2 wrapper - 05/19/10 11:18

OH YEAR grin



GReets
Rackscha
Posted By: flits

Re: Newton 2 wrapper - 05/19/10 13:18

wats the next thing you are going to insert?

i hope ragdol
Posted By: Timothy

Re: Newton 2 wrapper - 09/19/10 16:15

Does anyone know where to download a manual for the wrapper? confused
The links (first page) are dead.
Posted By: garv3

Re: Newton 2 wrapper - 09/20/10 01:54

I agree! A manual would be great!!!
Posted By: flits

Re: Newton 2 wrapper - 09/20/10 10:24

http://newtondynamics.com/wiki/index.php5?title=Main_Page

for the rest just chek the demo's
Posted By: garv3

Re: Newton 2 wrapper - 09/20/10 11:12

Well, I need a step by step introduction how to integrate newton to my project. I tried it on my own but always get a "EMPTY PROTOTYPE CALLED IN NEWTON_ADDENTITY" error!
Posted By: Timothy

Re: Newton 2 wrapper - 09/20/10 13:37

I also have problems integrating the wrapper into my project.

I included:
NewtonMain.c
NewtonAPI.c
NewtonJointLibraryMain.c
NewtonJointLibraryAPI.c
matrix.c
newton_materials.c
newton_main.c
newton_debug.c

Also I defined "NewtonWorld* nworld;"
like in the examples and loaded the "Newton.dll" and
the "JointLibrary.dll".
I don't get errors so far but I don't know how to start or use Newton. What am I supposed to do?
Posted By: FBL

Re: Newton 2 wrapper - 09/20/10 18:17

Code:
#include <d3d9.h>

/* Newton includes */
#define PRAGMA_PATH "newton"
#define PRAGMA_PLUGIN "newton.dll"

/* 
   1 meter = 32 quants
*/
float QUANTTOMETER = 0.03125;
float METERTOQUANT = 32;




#include "NewtonMain2.18.c"
#include "NewtonAPI2.18.c"

NewtonWorld* nworld = NULL;

#include "matrix.c"
#include "newton_materials.c"
#include "newton_main.c"
#include "newton_debug.c"



...is what I do. I copied the whole wrapper to a "Newton" subfolder and moved the newton.dll to my plugin dir.

Use newton_start() and newton_stop() to create and destroy the Newton world.
Each frame newton_update() has to be called.
Use newton_addentity() (check wrapper examples) to add dynamic entities to the physics world.
Static Entities can be added to the level geometry by setting flag8 in WED, level blocks are added automatically.

Removing dynamic entities has to be done via Newton command (don't know it right now). ent_remove() will be performed automatically afterwards.
Posted By: Timothy

Re: Newton 2 wrapper - 09/21/10 14:36

Thank you very much, now it works but only using the
NewtonMain.c
NewtonAPI.c
(NewtonMain2.18.c and NewtonAPI2.18.c
= error message)

There is still one big problem:
The newton objects fall down but they ignore level blocks and
objects with flag8 like they are passable.
What can I do? frown
Posted By: FBL

Re: Newton 2 wrapper - 09/21/10 17:02

float QUANTTOMETER = 0.03125;
float METERTOQUANT = 32;


If you choose a too small factor for QUANTTOMETER Newton will get problems with inaccuracies and then collision does not work reliably anymore.
Posted By: Timothy

Re: Newton 2 wrapper - 09/22/10 12:20

I know what the problem was now:
I used newton_start() before loading the level which obviously is wrong.
@Firoball Thank you very much for your help!
Posted By: garv3

Re: Newton 2 wrapper - 09/23/10 11:27

Thank you for the answer!
But if I try it this way, I get an error in "...include\windows.h" in line 6519: syntax error <RECT rcPaint;>!

frown

EDIT: Fixed this by changing order of lines...
But now I get an error after starting the level: EMPTY PROTOTYPE CALLED IN NEWTON_START

What I do in main() is:
Code:
//set some level preferences
//load the level
newton_start();
wait(3);
ENTITY* ball = ent_create("kugel.mdl", nullvector, NULL);
newton_addentity(ball, 75, NEWTON_SPHERE, onforceandtorque);
	
while(1){
	newton_update();
	wait(1);
}


Posted By: ventilator

Re: Newton 2 wrapper - 02/15/11 13:58

newton will go open source under the zlib license in a few days.
edit: http://newtondynamics.com/forum/viewtopic.php?f=9&p=45765#p45765 it already happened.

i think this is a good step since julio will have more time to concentrate on the core then. others can help with stuff like mac and linux builds and so on.

i wonder how all the people who prefered bullet just because it is open source will react to this. laugh
Posted By: VeT

Re: Newton 2 wrapper - 02/21/11 08:20

Greetings, ventilator laugh

I also wanted to print news about Newton 3.0 here, but you mke it faster, as i was out of town laugh


I didnt visit forum for a really long time, but now i have some free time to improve Wrapper. Idk if it is actual laugh
Posted By: 3run

Re: Newton 2 wrapper - 02/21/11 15:34

Haha!! laugh Privet Vet. Happy to see u back here laugh
Waiting for a new great wrapper (with car, rag-dolls) as well laugh
Posted By: VeT

Re: Newton 2 wrapper - 03/02/11 10:36

Zdarova, 3run laugh
I think, that now i'll back to my last stumbling block: to character controller.
Anyway, first step would be updating to Newton 3.0 version.
Posted By: 3run

Re: Newton 2 wrapper - 03/02/11 13:54

Would be great to have some player movement made with newtone laugh
Posted By: snake67

Re: Newton 2 wrapper - 10/17/11 17:50

Hi VeT

I tried Newton 2 wrapper with A8. In a small test level i have some boxes (mdl) falling to the floor (block). But they are falling through the floor! Sometimes they get stucked, struggle, eventually they all fall through. What to do?

I want to build the level with "create meshes" as "simple map".

Some help would be great...
Posted By: Anonymous

Re: Newton 2 wrapper - 10/20/11 12:47

I believe last time I tried Newton, I realized that blocks and Models needed their FLAG8 set to ON.
Posted By: snake67

Re: Newton 2 wrapper - 10/20/11 15:01

Hi

Thanks. I tried this allready, no result... Could the reason be an incompatibility with A8?
Posted By: Superku

Re: Newton 2 wrapper - 10/20/11 23:43

I've never used Newton before, but I guess it could be that you have to register level_ent as a static, polygonal object.
Posted By: 3run

Re: Newton 2 wrapper - 10/21/11 09:31

I think Newtone 2 wrapper doesn't support A8 at the moment, cause I couldn't get demo samples to work properly with it, objects were falling throw the ground, but with A7 they worked fine.
Posted By: snake67

Re: Newton 2 wrapper - 10/21/11 14:37

Thats bad news. It would be nice to use Newton with A8, because i (we?) got so many problems integrating PhysiX into my projects...
Posted By: 3run

Re: Newton 2 wrapper - 10/21/11 15:27

Abs agree with you dude! At the moment I prefer to stay with A7.
Posted By: FBL

Re: Newton 2 wrapper - 10/22/11 16:07

You need to fix the vertex struct, I think.

Go to newton_main.c and comment the _VERTEX_ struct:

/*
typedef struct
{
float x, y, z;
float nx, ny, nz;
float tu1, tv1;
float tu2, tv2;
float tx3, ty3, tz3, tw3;
} _VERTEX_;
*/


And whereever it is used, use D3DVERTEX instead.
Posted By: snake67

Re: Newton 2 wrapper - 10/22/11 16:32

Hi Firoball

Wow!!! Thats it. No more fall through anymore. Thank you very much!
Posted By: darkinferno

Re: Newton 2 wrapper - 11/14/11 12:32

Is this deterministic? and what could be done to make it that way? [needed for multiplayer/replay purposes]
Posted By: Ch40zzC0d3r

Re: Newton 2 wrapper - 02/27/12 14:42

No sry works now^^
Posted By: yorisimo

Re: Newton 2 wrapper - 02/27/12 14:51

Did you make Firoball's fix (find and replace all VERTEX to D3DVERTEX...up 4 posts in this thread)?
Worked for me.
Posted By: Ch40zzC0d3r

Re: Newton 2 wrapper - 02/27/12 15:27

Hey me again.
I added this to my project to the bullet:

Code:
ent_create("shells/9mm.mdl", player.x, bullet_phys);

action bullet_phys()
{
	wait(3);
	newton_addentity(me, (float)75, NEWTON_CYLINDER, onforceandtorque);
	//set(me, PASSABLE);
	//pXent_settype(me,PH_RIGID,PH_CAPSULE );
	//pXent_setccdskeleton( me, vector(0, 0, 0), 0 );
	//pXent_setelasticity(my, 10);
}



Now its crashing with this message:
Empty function called in newton_addentity

What im doing wrong?
Posted By: yorisimo

Re: Newton 2 wrapper - 02/27/12 16:27

Did you include all the necessary files in your project:
newton.dll, newton_main.c, newton_debug.c, matrix.c, etc.

Make sure you read howtouse.doc that comes with the Newton 2 wrapper stuff.
Posted By: Ch40zzC0d3r

Re: Newton 2 wrapper - 02/27/12 17:40

I fixed it. Problem was I put all in another folder then my script idk why it doesnt work then but now it works...
Posted By: gameplan

Re: Newton 2 wrapper - 02/27/12 18:40

Does anyone know how to connect two entities with a Hinge (code?) ?
Posted By: Ch40zzC0d3r

Re: Newton 2 wrapper - 02/27/12 20:38

Look at the website for 3dgs codes. You can download them.
They are made with A6 but i dint think thats the problem laugh
Posted By: gameplan

Re: Newton 2 wrapper - 02/27/12 21:15

Yes, but I need the codes for Newton Dynamics, which arent in the official codelist. Or did I missunderstood something?
Posted By: Heri

Re: Newton 2 wrapper - 04/18/12 09:44

whether we can simulate the newton dredging of soil?
like this : http://www.youtube.com/watch?v=wrYa4JPXoAA&feature=fvwrel
Posted By: wrekWIRED

Re: Newton 2 wrapper - 04/20/12 14:25

I was also looking for a hinge code. can't find it or i just pass by it. By the way. Already got the grab code working but i wasn't the one i needed. It was the power mouse but i still have to figure out how to pick stuffs while in FP view and apply weight to objects. If someone can help me regarding this one i would be thankfull.
Posted By: Pappenheimer

Re: Newton 2 wrapper - 04/20/12 19:47

Originally Posted By: Heri
whether we can simulate the newton dredging of soil?
like this : http://www.youtube.com/watch?v=wrYa4JPXoAA&feature=fvwrel

What you see in the video isn't anything with the physics engine, it is fake. Means, it is by moving the vertices of the model where the shovel touchs the soil and moving the vertices of a hidden mdl within the shovel to make the soil appear in the shovel. The rest are particles.
Posted By: wrekWIRED

Re: Newton 2 wrapper - 04/21/12 03:53

Anyone can help in converting or intigrating this newton code to lite-c? http://newtondynamics.com/forum/viewtopic.php?f=9&t=6706

Code:
/*
Containing class vars:
handOrn = target orientation quaternion
hand pos = target position
... interpolated values to follow point in front player camera somewhat smoothly
*/

void AccumulateForce (float timestep)
   {
      //position... (code from older newton demos)

      if (!pickedBody) return;
      float MOUSE_PICK_DAMP = 20.0f;
      float MOUSE_PICK_STIFFNESS = 150.0f;
      float ANGULAR_STIFFNESS = 0.1f;

      float mass;
      float Ixx;
      float Iyy;
      float Izz;
      sVec3 com;
      sVec3 veloc;
      sMat4 matrix;
      BodyGetMatrix(pickedBody, matrix);

      BodyGetVelocity (pickedBody, veloc);
      BodyGetMassMatrix (pickedBody, mass, Ixx, Iyy, Izz);

                sVec3 pickedForce = handPos - matrix[3]; // body position
      float mag2 = pickedForce.SqL();
      if (mag2 > 20.0f * 20.0f) pickedForce *= 20.0f / sqrt (mag2);
      sVec3 force (pickedForce * mass * MOUSE_PICK_STIFFNESS);
      sVec3 dampForce (veloc * mass * MOUSE_PICK_DAMP);
      force -= dampForce;
      sVec3 grav (0.0f, mass * GRAVITY_Y, 0.0f);
      force -= grav;

            
      BodyData *data = (BodyData*) BodyGetUserData (pickedBody); // containing force and torque vectors, which are the applied in the callback
      
      data->force += force;

      // orientation...
      sQuat q;
      BodyGetRotation (pickedBody, q);

      sVec3 curAngVel;
      BodyGetAngVel (pickedBody, curAngVel); // == NewtonBodyGetOmega
      
      sVec3 targetAngVel = AngVelFromAToB (q, handOrn) * (1 / timestep * ANGULAR_STIFFNESS);
      sVec3 torque = ConvertAngVelToTorque (targetAngVel, curAngVel, matrix, timestep, mass, Ixx, Iyy, Izz);
      data->torque += torque;

      BodyActivate (pickedBody);
   }



// utilitys...


// convert rotational offset to angular velocity (divide by time afterwards)
inline sVec3 AngVelFromAToB (const sQuat &qA, const sQuat &qB)
{

   const float matchTolerance = 0.01f;
   const float faultTolerance = 0.05f;

   sQuat q = QuatFromAToB (qA, qB);
   sVec3 *omegaDir = (sVec3*)&q;
   float sql = omegaDir->SqL();
   if (sql   < (matchTolerance * matchTolerance))
      return sVec3 (0, 0, 0);

   float length = sqrt (sql);
   if (q[3] < -1) q[3] = -1;
   if (q[3] >  1) q[3] =  1;
   sVec3 angVel = (*omegaDir / length) * (2.0 * acos(q[3]));
   if (length   < faultTolerance) angVel *= (length - matchTolerance) / (faultTolerance - matchTolerance);
   return angVel;

}

// choose shortest rotation between 2 orientations
inline sQuat QuatFromAToB (const sQuat &qA, const sQuat &qB)
{
   sQuat q;
   if (qA.Dot(qB) < 0.0f)
   {
      q[0] = qA[0]; q[1] = qA[1]; q[2] = qA[2];
      q[3] = -qA[3];
   }
   else
   {
      q[0] = -qA[0]; q[1] = -qA[1]; q[2] = -qA[2];
      q[3] = qA[3];
   }
         
   return qB * q;
}

inline sVec3 ConvertAngVelToTorque (   sVec3 &targetAngVel, sVec3 &currentAngVel, sMat4 &matrix,
                        float timestep, float mass, float Ixx, float Iyy, float Izz)
{
   sVec3 torque = (targetAngVel - currentAngVel) / timestep;
   torque = matrix.Unrotate (torque);
   torque[0] *= Ixx;
   torque[1] *= Iyy;
   torque[2] *= Izz;
   torque = matrix.Rotate (torque);
   return torque;
}



I understand some of newton dynamic's function but don't understand the variables thats why i use 3dgs to make my game. Wish i can translate the code my self but been working for weeks now just to get my game physics working and can't go on without it.
Thanks guys.
Posted By: wrekWIRED

Re: Newton 2 wrapper - 04/24/12 17:44

How do i add a mesh collision for entities? I tried to edit newton_main.c and the following code.

Code:
#define NEWTON_MESH 8

//add this code to newton_addentity switch

case NEWTON_MESH:
		
collision = NewtonCreateTreeCollision(nworld, 0);
NewtonTreeCollisionBeginBuild(collision);
//newton_treecollisionaddblocks(collision);
newton_treecollisionaddentity(collision, entity);
NewtonTreeCollisionEndBuild(collision, 0);

break;



attach this action to a chair model
Code:
action new_mesh_obj()
{
wait(10);
newton_addentity(me, 100, NEWTON_MESH, onforceandtorque);
}



object collide to it according to it's mesh alright but it stays in mid air or stays in fix position. how do i fix this?
Posted By: wrekWIRED

Re: Newton 2 wrapper - 05/12/12 14:53

is it me or these thread is dead? i was able to solv some of my problem like pick objects using joints which leaves me with one last problem which is collision according to it's shape like a chair and other objects. I checked the compound collision code but i made a funny physic as a whole object. Not shure if it's juect the mass i set. I don't even know what unit that mas is set. I just set the mass on newton_addentity according to size like small objects starts with 10 mass and add more as i add bigger object.
© 2024 lite-C Forums