[WIP] Unity: Newton Model Format

Share with us how are you using the powerrrr of the force

Moderator: Alain

[WIP] Unity: Newton Model Format

Postby Stucuk » Mon Jul 04, 2005 11:19 pm

The goal of the project is to create a model format which is like any other 'static' (no animation... bad term rearly, since it isn't rearly static) but has the advantages of newton. (Joints, Collisions, etc)

The model format supports surface groups so u can join several surfaces to make up one object in the model. i.e a cupboard body(made of serveral surfaces) for one object, and the door for another. Or a bookcase with books (each book being a seperate 'object' but belonging to the same model. Like a Prefab).

Jointwise only the hinge is currently supported.

Supported collision types for the surfaces and surface groups are: Square, Sphere and Convex Hull.

Images:

Image
Chest/Box with books inside

Image
Table that can fold in on its self to save space in the room

Image
A screen of the folding table in the editor, showing the joints

Demo:

- UNM_Demo 967kb (approx)

2 test levels are included. (BookcaseTest and UNM_Test) NM Editor not included.

Note: Textures for the models are not included since i used Return To Castle Wolfensteine textures.

Demo Usage:

W,S,A,D - Forward, Back, Strafe Left, Strafe Right
Space - Action (won't do anything with this demo)
Left mouse + drag - Move view
Right mouse + drag - move object (i.e the models, or there joints. Try to close the folding table fully)
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Postby Julio Jerez » Tue Jul 05, 2005 9:11 am

Very nice editor.
I like teh folding table, very nice touch.
I think you are using spherical inercial for the objects. I can tell because the books in the bock shell have a very large resistance to rotate.
I think this is why when you move the shell the book move with it.
try making a box inercial and see if it better.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Postby Stucuk » Tue Jul 05, 2005 9:47 am

i have found the prob with the Inertia... was taking the size from the entire model rather than its own surfacegroup. Tho i can't see a very noticable difference in how the books react. (tho its hard to tell since they fall differently each time)

Code: Select all
Size := GetModelSurfaceGroupSize(Model,SG);
     // Calculate real moment of inertia
Mass    := Model.SurfaceGroups[SG].NewtonObject.Mass;
Inertia := V3(Mass * (Size.Y * Size.Y + Size.Z * Size.Z) / 12,
              Mass * (Size.X * Size.X + Size.Z * Size.Z) / 12,
              Mass * (Size.X * Size.X + Size.Y * Size.Y) / 12);

Model.SurfaceGroups[SG].NewtonObject.Inertia := Inertia;
NewtonBodySetMassMatrix(Model.SurfaceGroups[SG].NewtonObject.Body, Mass, Inertia.X, Inertia.Y, Inertia.Z);


Im still amazed the folding table acts like the real ones.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Postby Stucuk » Fri Jul 08, 2005 4:05 pm

Basic model scriping and slider joint added. In the following pics the DVD Drive moves out and an error message appears on the screen.

Image

Image

scripts look like the following:
Code: Select all
ModelStart
{
SurfaceHide 13
SurfaceShow 12
LockJoint 0
}

DVDShowError sliderposabove 0 1
{
SurfaceHide 12
SurfaceShow 13
}

DVDEnd sliderposat 0 8
{
LockJoint 0
}

DVDStart sliderposat 0 0
{
SurfaceHide 13
SurfaceShow 12
LockJoint 0
}

OpenDvd
{
UnLockJoint 0
SetSpeed 0 10
}

CloseDvd
{
UnLockJoint 0
SetSpeed 0 -10
}

UseDVD
{
TriggerIf sliderposat 0 0 OpenDvd
TriggerIf sliderposat 0 8 CloseDvd
}


The names of the sections that have parameters are considered as events. I.E sliderposabove 0 1 means if joint 0's position is above 1 then do the following.

New demo:

Demo (1.3 MB approx)

Usage:

Same as above but to open and close the dvd drive press the spacebar when you are looking at the dvd drive. a badly made icon will appear at the bottom showing a dvd drive when u are in range of the dvd and looking at it.
Last edited by Stucuk on Fri Jul 08, 2005 5:00 pm, edited 1 time in total.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Postby martinw » Fri Jul 08, 2005 4:26 pm

I can only seem to run the pctest, the other two I get a Range Check Error :?: It looks pretty good with the pctest though, I like the pulsating icon, the dvd in there must be very heavy though as the PC rocks when it goes in and out :wink: Pretty cool though 8)
User avatar
martinw
 
Posts: 30
Joined: Wed Jun 01, 2005 1:19 pm
Location: Aberdeenshire

Postby Stucuk » Fri Jul 08, 2005 5:59 pm

Forgot to update the models (added new fields which don't exist in the old models so it trys to read further than it can).

Updated the pc model. DVD drive has a mass of 1 now, Some texture alignments fixed. (the pc front needs to be redone and the PCGamer case needs a back)

Link updated.

Demo (1.3 MB approx)
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Postby martinw » Fri Jul 08, 2005 7:34 pm

Tool cool 8) Very impressive :shock:

Did I see once the bookcase and books had materials associated with them :?: they don't seem to in this :?: FYI
User avatar
martinw
 
Posts: 30
Joined: Wed Jun 01, 2005 1:19 pm
Location: Aberdeenshire

Postby Stucuk » Fri Jul 08, 2005 7:41 pm

If by materials u mean textures then they wern't included since they were Return To Castle Wolfenstein (URL) textures.

Currently Newton materials havn't been implemented(tho are planned), the models currently use a default material.

:) Next task, the plug..
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Postby Julio Jerez » Fri Jul 08, 2005 7:42 pm

Very cool, in the first demo I was trying to put the cd indise the cd player shell, but it does not seems to open anymore.
One thing I notice. you either have a fix uptate timestep that is too small, or the gravity setting is too low. What are your units, meters or
centimiters.
Maybe increasing the gravity will remove the slow motion effect.
Julio Jerez
Moderator
Moderator
 
Posts: 12249
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Postby Stucuk » Fri Jul 08, 2005 7:50 pm

Very cool, in the first demo I was trying to put the cd indise the cd player shell, but it does not seems to open anymore.


Putting the PCGamer case inside the dvd drive then closing it? Just tryed it.... ill need to fix that.

Im assuming the slow motion ur on about is the bookcase. The books have a mass of 1, the bookcase has a mass of 100 and the gravity is -19.8. The units are normaly in 1's (i.e 6, 56, 333, whole numbers)

I tryed doing a timestep a while back which seemed to improve performance when the fps is low (the bookcase test seems to stay at 60fps on my pc).

Code: Select all
Procedure UpdateNewton;
Var
AccumlativeTimeSlice,
T : Single;
I : Integer;
begin
ManagePicking;

T := 1/60;

I := 0;

If Engine.Timer.FrameTime <= T then
NewtonUpdate(Engine.Newton.NewtonWorld, Engine.Timer.FrameTime)
else
begin

AccumlativeTimeSlice := Engine.Timer.FrameTime;

Repeat

If AccumlativeTimeSlice <= T then
//NewtonUpdate(Engine.Newton.NewtonWorld, AccumlativeTimeSlice)
else
NewtonUpdate(Engine.Newton.NewtonWorld, T);

AccumlativeTimeSlice := AccumlativeTimeSlice - T;

Inc(I);
Until (AccumlativeTimeSlice <= 0) or (I = 2);

end;

end;
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Postby Electron » Thu Jul 14, 2005 8:16 am

very cool. Are you planning to release the editor soon?
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.

Crucible of Stars
User avatar
Electron
 
Posts: 10
Joined: Sat Apr 03, 2004 8:09 pm
Location: Massachusetts USA

Postby Stucuk » Thu Jul 14, 2005 1:22 pm

I don't know when a 'final' version will be released. The source code to the NM Format will be released when i make a open source viewer. Currently it has dependancys on Unity files.

The editors source won't be released since it is dependant on unity. Tho i have planned to add DLL 'support' to it so dlls could be made for say importing a new format, exporting, etc.

Demo

Current non newton changes are: Updated PC Front texture, updated PC Gamer DVD Case. Shader rendering added. (PC Monitors screen is now animated)

Newton changes: Ball joint added (tho not used in any models so far), breakable joint option added. Blocked script event (so when a joint is blocked u can script the model to do something, i.e open the dvd drive when its blocked), misc script additions. Parent Child Collision state, collisions between parents n children is now an option for each joint.

Model Changes: Swing now has 4 hinge joints, which gives it the odd(imo) side effect of 'wiggleing' like real swings do. The chest is defaultly 'locked' so u need to use the lid of it to open it. When the folding table is used its joints all break. Pc's dvd drive no longer gets stuck when blocked. It can also be broken tho alot of force is needed. Since the DVD drive is now more realistic (whole drive no longer pops out) the dvd case normaly can't blocked it. Tho in the pctest map a 'bar' has been included so u can block it.

The NM editor has been included as well as a .map file (which can be edited by GtkRadient so new models can be added to the map). The NM editor is a WIP and as such compleatly undocumented. Tho it should be straight forward.

- Demo 3 (2MB Approx)
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland

Postby Stucuk » Fri Aug 19, 2005 12:32 am

Image of Crane model with Physics Enabled
Image

Update on the 'Unity Newton Model' format. The Editor has been improved alot. Models can be tested in the editor its self (tho picking doesn't always work, im assuming its the camera type). Model Scripts can also be made and debugged.

- Download (1.8mb Approx)

Included are all the previous models and a new one. A crane. Only the editor is included.

Usage
Once the program has fully loaded click on 'Model list', expand the 'misc' category and click on 'crane'. The crane should now be in the 3d view. Next press F9 or the button with the crane pic with arrows and the model's script will be ran.


Currently the model scripts lack commands like WaitUntil (so u can make it wait until the position is at say 30 b4 it continues), tho they will be added. Each Event/Procedure is independant(if 2 are triggered they will run at the same time, not one after the other).

Note: the red and blue lines are the joints, blue is the currently selected joint. Also note the model scripts will cause exceptions if parameters are missing (never got round to checking param's exist b4 accessing them, heh)

Thoughts and suggestions welcomed.
User avatar
Stucuk
 
Posts: 801
Joined: Sat Mar 12, 2005 3:54 pm
Location: Scotland


Return to User Gallery

Who is online

Users browsing this forum: No registered users and 4 guests

cron