FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

some suggestions
Goto page 1, 2, 3, 4  Next
 
Post new topic   Reply to topic     Forum Index -> Claytek 3D
View previous topic :: View next topic  
Author Message
h3r3tic



Joined: 30 Mar 2004
Posts: 261
Location: Torun, Poland

PostPosted: Mon Sep 13, 2004 9:22 am    Post subject: some suggestions Reply with quote

Hi there !

Congrats with your engine :) I'll be starting to work on another one in some time (dnow, 1-2 months maybe). If you allow me, I'd have a couple of suggestions for your engine:

- You might want to write a loader for 3dsmax files, the best idea for you would probably be to use the .ASE format. The .3DS format is not that good and it carries less info than ASE
- If you don't have any access to 3dsmax, another idea would be to use a CSG based world editing, like in Quake. Or just use Quake tools and load .BSP.
- I don't know how you're doing your collisions (sorry, no time to browse your code), but I'd suggest using ellipsoids as described in this paper: http://www.peroxide.dk/papers/collision/collision.pdf


That's all for now. I can provide you some C++ code from my old engine. I had .ASE and .3DS loading, as well as CSG, automatic portal generation and portal rendering based on a simple scene graph. Heh, also an extremely precise polygon splitting code if you needed that :)

I'll watch your progress and I could give you some feedback if you wish :)

Tom
Back to top
View user's profile Send private message MSN Messenger
clayasaurus



Joined: 21 May 2004
Posts: 857

PostPosted: Mon Sep 13, 2004 1:25 pm    Post subject: thanks Reply with quote

Thanks for the suggestions!

First of all, part of my goal for this project is to create a 3D level editor that works on both linux and windows Smile Unconventional? ... Maybe. But hey, everyone has their dreams. I kinda want to use my own formats for now because, umm.. they're easier for me and i'm new at this stuff, plus i don't have access to 3DS max and don't want to use tools that are way too complicated for me.

About the collision physics, yes i need something better (i'll read up on ellipsoid thanks)
I used some tutorial code for my polygon collision detection.
edit: my only problem with collision detection is that when i set the player to greater speeds, the player moves right through walls!
edit: have you gotten good collision detection before? this pdf will take a bit to understand!

Source code is always welcome, although I have no clue about portal rendering using a scenegraph, i think that's where you only draw what the user sees?

Also, what is polygon splitting? Is that for LOD?


Last edited by clayasaurus on Mon Sep 13, 2004 1:39 pm; edited 1 time in total
Back to top
View user's profile Send private message AIM Address
h3r3tic



Joined: 30 Mar 2004
Posts: 261
Location: Torun, Poland

PostPosted: Mon Sep 13, 2004 1:37 pm    Post subject: Reply with quote

> although I have no clue about portal rendering using a scenegraph, i think that's where you only draw what the user sees?

exactly :) so you do have some idea ;)

> my only problem with collision detection is that when i set the player to greater speeds, the player moves right through walls!

and this paper avoids this problem :]

> Also, what is polygon splitting? Is that for LOD?

could be used, but mostly it would be used for BSP, k-DTree or OCTree construction as well as portalization or CSG :]

hehe, i also like using my own formats and making my tools, but 3dsmax gives me too much power not to use it :)
I suggest that you take a look @ CSG for lever construction. but you dont have to use it, it all depends on the kind of scenes you want to draw with the engine
Back to top
View user's profile Send private message MSN Messenger
clayasaurus



Joined: 21 May 2004
Posts: 857

PostPosted: Mon Sep 13, 2004 1:59 pm    Post subject: ok Reply with quote

ok, i'll take a look at CSG for level construction.

Now that I think about it, for level editing I might allow users to load a combination of different things (ASE, md2) and use the editor to add entities and arrange everything nicely, then save it all together.
Back to top
View user's profile Send private message AIM Address
h3r3tic



Joined: 30 Mar 2004
Posts: 261
Location: Torun, Poland

PostPosted: Mon Sep 13, 2004 2:02 pm    Post subject: Reply with quote

from my experience it's very comfortable to have everything in nice data structures in the memory and then just serialize them. that file format is quite nice, you just call unserialize and watch how everything works automagically :] of course you'd have to write some cool serialization routines, again i could help you with that :>
Back to top
View user's profile Send private message MSN Messenger
clayasaurus



Joined: 21 May 2004
Posts: 857

PostPosted: Mon Sep 13, 2004 2:22 pm    Post subject: Reply with quote

I am a bit lost. What do you mean by "nice data structures"? I have data structures, I think (my rectangle one, player, texture). But i'm not sure if they're so nice ... do you mean using ASE for loading the geometry as one thing... as opposed to a bunch of little seperate rectangles?

is unserialization level loading? (never heard the term before)
and what type of cool serialization routines would i need? Would i need ones to convert map data into ASE data? *confused*

thanks Smile
Back to top
View user's profile Send private message AIM Address
h3r3tic



Joined: 30 Mar 2004
Posts: 261
Location: Torun, Poland

PostPosted: Mon Sep 13, 2004 2:36 pm    Post subject: Reply with quote

heh, nice data structures == any data structures that you like to have in your engine. in my i had e.g. Geode classes which contained vertex and index lists.

serialization = process of saving data structures to some static representation (binary file, some static buffer, like an array).

when you serialize, you literally save your objects. you can then unserialize them and you have almost the same object structure as before serialization. almost because memory addresses will be different.
unserialization may be thought of as Loading

just google for serialization :)
Back to top
View user's profile Send private message MSN Messenger
clayasaurus



Joined: 21 May 2004
Posts: 857

PostPosted: Mon Sep 13, 2004 3:57 pm    Post subject: Reply with quote

ok Smile

I already have serialization implemented.
I use std.stream and save the data as a binary file, which i can load up in my engine to play or load up in my editor to edit Smile
Back to top
View user's profile Send private message AIM Address
h3r3tic



Joined: 30 Mar 2004
Posts: 261
Location: Torun, Poland

PostPosted: Mon Sep 13, 2004 4:32 pm    Post subject: Reply with quote

Code:

rectangleManager.read(file);
player.read(file);
textureManager.read(file); // generates textures too


heh, yeah, that actually is a simple form of serialization. However I was talking about a little bit different thing :> the serialization method I'm talking about is literally saving object structures to a file. Let's say that you have 3 classes: Foo, Bar and Baz. Foo contains an object of Type Bar and Bar contains an object of type Baz. What happens at the serialization time is that you call e.g. foo.serialize(file); Foo then saves its class name (e.g. from classinfo) and calls serialize upon all of its members, in this case, Bar, Bar does a similar thing as Foo.

The nicest thing about serialization is probably unserialization :> you could just do sth like:

Code:

Unserializer u = new Unserializer(file);
Object myObj = u.unserialize();


and you get any object that was saved into this file created in a nice OO fashion. It's created automatically by a factory that reads the class name from the input and creates the appropriate object.

this way you can do e.g.

Code:


class Car {
    Tire tire;
    // ...
}

class Tire {
    int weight;
    // ...
}

class ToyoTire : Tire {
    // ...
}

class MichelinTire : Tire {
    // ...
}

// let's have a car with just one tire
Car car = new Car;
car.tire = new ToyoTire;

// you create some serializer obj
Serializer s = new Serializer(file);

// and serialize that newly created object (car)
s ~= car;



in the unserializer you can do just:

Code:


Unserializer u = new Unserializer(file);
Car car = cast(Car) u.unserialize();



and you get the complete object with a ToyoTire because the unserializer knows which tire it should create.


Another thing is that:
Let's say you have 3 objects again: Foo, Bar and Baz
this time however Foo is referenced by both Bar and Baz. You want to save Bar and Baz. The most trivial approach would be to save Bar and Baz and for each of them copies of Foo:

s ~= bar;
// bar calls serialize on its foo

s ~= baz;
// baz calls serialize on its foo

so you have two foo objects, and you should only save it once

Serialization can deal with this problem really nicely Smile


Arrow How does it look like ?

There may be various approaches to do it in code, back in the DMD 0.83 though i've written a simple serialization lib. An interesting feature of it was really nice code reuse. In your engine you perform almost the same operations for loading and saving objects... this was always pissing me off, so i've united that functions.

Take a look at how my lib worked:

Code:

// I hope the www formatting gets it right
class Foo : Serializable
{
   Foo    another;
   char[] text1;
   float  flt;
   
   ClassDescriptor describe()
   {
      with (new ClassDescriptor)
      {
         add(new obj!(Foo)   (&another));
         add(new ptr!(char[])(&text1));
         add(new ptr!(float)   (&flt));
         return that;
      }
   }

   // Implement the Serializable interface -------------------------------------------------------------------
   
   void   serialize   (Serializer s)      { describe().serialize   (s);  }
   void   unserialize   (UnSerializer s)   { describe().unserialize(s);  }
   Object   getObject   ()               { return this;                }
}


where Serializable is just an interface (and it should be called ISerializable... ;] )

that's it. it would make a special class descriptor that would know how to load and save instances of this class.

also, to let the unserializer know what types it can load, its factory had to be initialized like:

Code:

// register the types in the factory
static this()
{
   new factory.type!(Foo);
   new factory.type!(Bar)("main.bar"); // optionally different name
   new factory.type!(Baz);
}


in the module's constructor (there were also Bar and Baz classes in this module)

Idea I don't think I can describe serialization well to you however I know an excellent link that can tell you something about it:
http://www.parashift.com/c++-faq-lite/serialization.html

A nice thing about serialization is that it doesn't impose too much about the file structure. You can literally make your scene load itself.

Just random thoughts :} you don't have to like this kind of serialization, though I love it Smile

Tom
Back to top
View user's profile Send private message MSN Messenger
clayasaurus



Joined: 21 May 2004
Posts: 857

PostPosted: Mon Sep 13, 2004 5:53 pm    Post subject: cool. Reply with quote

wow that is a lot for me to digest all at once.

I think I get the basic idea of what you're saying, when you serialize you save the class name to the file, and when you unserialize you look for the class name and then load up all its members.

Even though you give code, I'm still a little lost at how to implement this Embarassed
It looks like you need to use templates, interfaces, a ClassDescriptor class, an add function.
What's "return that" ?

If it's not too much trouble, could you give some simple compileable D or c++ code that shows how this works?

If not, then I could try to experiment with it myself and post questions here Cool
Back to top
View user's profile Send private message AIM Address
h3r3tic



Joined: 30 Mar 2004
Posts: 261
Location: Torun, Poland

PostPosted: Mon Sep 13, 2004 6:03 pm    Post subject: Reply with quote

> What's "return that" ?

LOL... that's just a shorthand to return the class descriptor quickly from within the with statement... dnow if it can be done in a different way now, that was for 0.83 and had some workarounds :>

uh.... i'll try to make that code compile with dmd 101... I can also give you some C++ source (yeah, that archaic ;] ) if u like... atm i'll only try to port the D code into 101.
Back to top
View user's profile Send private message MSN Messenger
clayasaurus



Joined: 21 May 2004
Posts: 857

PostPosted: Mon Sep 13, 2004 6:47 pm    Post subject: sweet Reply with quote

ok cool. you can send it to clayasaurus@gmail.com if you want.
Thanks a lot for your time and energy. It is greatly appreciated Very Happy
Back to top
View user's profile Send private message AIM Address
h3r3tic



Joined: 30 Mar 2004
Posts: 261
Location: Torun, Poland

PostPosted: Mon Sep 13, 2004 6:55 pm    Post subject: Reply with quote

sent :]

oh, would have forgotten to tell you. that serialization I'm talking about (and that I've sent you) also goes around the problem of circular dependiences (a references b, b references a) that would normally produce infinite loops by just saving every object once

also, a very nice feature of serialization that i've forgotten to tell you is that you can nicely save inheritance trees, the base class saves its data, derived classes save only their own.

right now serialization can probably be done even nicer in D thanks to mixins and due to typeof(this).classinfo.name, factory registration can be done automatically by the class' static constructor :]

Tom
Back to top
View user's profile Send private message MSN Messenger
clayasaurus



Joined: 21 May 2004
Posts: 857

PostPosted: Tue Sep 14, 2004 10:01 pm    Post subject: Reply with quote

i'm trying to get the code to work with my engine but I get a really annoying compiler error with no file name or line number and i'm stuck Sad

Code:

code      objfactory
generating code for function 'nameOf'
generating code for function 'make'
make: *** [engine] Error 1


if i can't figure out how to get it to compile so I am thinking this..... maybe for now I should just leave my serialization alone, and in the future when I'm smarter (or the compiler is), try to implement this again.

I have something that just works now, and I have other goals/things in Claytek that i'd like to take care of. thanks for all your time and help bye
Back to top
View user's profile Send private message AIM Address
h3r3tic



Joined: 30 Mar 2004
Posts: 261
Location: Torun, Poland

PostPosted: Wed Sep 15, 2004 4:58 am    Post subject: Reply with quote

Damn! I have no idea what this means... It works just fine on WinXP :/ maybe you should experiment with this (might be related to statics in structs) and post a bug report ?

As for writing your own when you/compiler gets smarter: why not :) this was just to show you how serialization might be done :] I think it can be done far better using some mixins and in the future - introspection :)

Good Luck !
Back to top
View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Claytek 3D All times are GMT - 6 Hours
Goto page 1, 2, 3, 4  Next
Page 1 of 4

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group