Crystal Space
Welcome, Guest. Please login or register.
April 18, 2014, 05:17:54 pm

Login with username, password and session length
Search:     Advanced search
8990 Posts in 2037 Topics by 7595 Members
Latest Member: Rejestruj1989
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  General Crystal Space Discussion
| | |-+  Migrating from Truevision3D to Crystal Space
« previous next »
Pages: [1] Print
Author Topic: Migrating from Truevision3D to Crystal Space  (Read 3141 times)
eventhorizon5
Jr. Member
**
Posts: 53


View Profile WWW
« on: July 13, 2005, 08:00:48 am »

My project (Skyscraper) was originally written in Visual Basic 6 along with the TrueVision3D graphics engine www.truevision3d.com, and I'm in the process of rewriting it in C++/Crystal Space.  Since Truevision is a very high-level 3d object-oriented engine, I'm trying to figure out what the CS equivalents would be (I've got some very simple things working, but I'm having major issues).  In the Skyscraper app, a 138-story building is generated in realtime (mostly at startup) using Truevision calls in VB code, and the only 3D models are minor things like windows.  I'm wondering if CEL provides similar functionality, since I've read some stuff about it, but don't fully understand what it does.

Here's my main thread for my project: http://community.crystalspace3d.org/forum/index.php/topic,155.0.html

Here I'll explain Truevision stuff so that you'll understand what I'm talking about, because if I can get CS to do the same stuff, development will start flying (right now it's crawling haha).

Here's the current C++/CS code for Skyscraper in CVS:
http://www.tliquest.net/cgi-bin/viewcvs.cgi/skyscraper/

And here's the last build of the abandoned VB/TrueVision rewrite (this is 1.1 alpha code - the 1.0 stable code is very messy and 1.1 is much much cleaner):
http://www.tliquest.net/cgi-bin/viewcvs.cgi/skyscraper/?only_with_tag=build_177

I would recommend looking at this VB file (this is the floor class):
http://www.tliquest.net/cgi-bin/viewcvs.cgi/skyscraper/src/Attic/Floor.cls?rev=1.1.1.6&only_with_tag=build_177&view=markup

So for example, this is how you would create a mesh and add some walls in it, using Truevision (this is just the mesh code, and not the rendering, etc code):

Code:
Dim Level As TVMesh
Set Level = Scene.CreateMeshBuilder("Level")
Level.AddWall GetTex("stone"), x1, z1, x2, z2, height, altitude, tw, th
Level.AddFloor GetTex("stone"), x1, z1, x2, z2, altitude, tw, th

where x1, z1, etc are the coordinates; altitude is the base Y coordinate, height is the top Y coordinate, tw and th are the horizontal and vertical texture resolution parameters (the CS equivalent of that seems to be SetPolygonTextureMapping, where the last value would be both the tw and th combined).

I've tried making CS versions of those, but with bad results.
I also am trying to figure out what the equivalent of this would be:

Code:
Level.Enable False

That command entirely disables a mesh from rendering, collision detection, etc.

So those are just some examples.  I code like mad in VB with Truevision, but I'm still building up my C++ skills (took classes on it before, but never could fully jump off of VB).  I mainly want my stuff to be fully cross-platform, and to not be limited by proprietary MS crap haha.

-eventhorizon
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1704


View Profile
« Reply #1 on: July 13, 2005, 08:23:07 am »

Code:
Dim Level As TVMesh
Set Level = Scene.CreateMeshBuilder("Level")
Level.AddWall GetTex("stone"), x1, z1, x2, z2, height, altitude, tw, th
Level.AddFloor GetTex("stone"), x1, z1, x2, z2, altitude, tw, th

where x1, z1, etc are the coordinates; altitude is the base Y coordinate, height is the top Y coordinate, tw and th are the horizontal and vertical texture resolution parameters (the CS equivalent of that seems to be SetPolygonTextureMapping, where the last value would be both the tw and th combined).

I've tried making CS versions of those, but with bad results.
I also am trying to figure out what the equivalent of this would be:

Code:
Level.Enable False

That command entirely disables a mesh from rendering, collision detection, etc.

For the first question take a look at the simple1 tutorial. That code looks like this:

Code:
  // Creating the walls for our room.
  csRef<iMeshWrapper> walls (engine->CreateSectorWallsMesh (room, "walls"));
  csRef<iThingState> ws =
    SCF_QUERY_INTERFACE (walls->GetMeshObject (), iThingState);
  csRef<iThingFactoryState> walls_state = ws->GetFactory ();
  walls_state->AddInsideBox (csVector3 (-5, 0, -5), csVector3 (5, 20, 5));
  walls_state->SetPolygonMaterial (CS_POLYRANGE_LAST, tm);
  walls_state->SetPolygonTextureMapping (CS_POLYRANGE_LAST, 3);

This will create a box that you can see from the inside. However iThingFactoryState has other functions where you can create individual polygons to make any shape you want. Check out the API ref of iThingFactoryState. Let me know if you still have problems.

For the second question there are various flags you can set on the mesh wrapper like this:

Code:
iMeshWrapper* mesh = ...;
mesh->GetFlags ().Set (CS_ENTITY_INVISIBLEMESH); // To make a mesh invisible.

Greetings,
Logged
eventhorizon5
Jr. Member
**
Posts: 53


View Profile WWW
« Reply #2 on: July 13, 2005, 08:29:54 am »

For the first question take a look at the simple1 tutorial. That code looks like this:

Code:
  // Creating the walls for our room.
  csRef<iMeshWrapper> walls (engine->CreateSectorWallsMesh (room, "walls"));
  csRef<iThingState> ws =
    SCF_QUERY_INTERFACE (walls->GetMeshObject (), iThingState);
  csRef<iThingFactoryState> walls_state = ws->GetFactory ();
  walls_state->AddInsideBox (csVector3 (-5, 0, -5), csVector3 (5, 20, 5));
  walls_state->SetPolygonMaterial (CS_POLYRANGE_LAST, tm);
  walls_state->SetPolygonTextureMapping (CS_POLYRANGE_LAST, 3);

This will create a box that you can see from the inside. However iThingFactoryState has other functions where you can create individual polygons to make any shape you want. Check out the API ref of iThingFactoryState. Let me know if you still have problems.

For the second question there are various flags you can set on the mesh wrapper like this:

Code:
iMeshWrapper* mesh = ...;
mesh->GetFlags ().Set (CS_ENTITY_INVISIBLEMESH); // To make a mesh invisible.

Greetings,

Currently Skyscraper's code has come mostly from the Simple1 tutorial, and I have made wall/floor polygon code; I'll have to see how the CVS version works, because the stable version of CS was behaving really strange (I created an insidebox and outside box, but they had visibility issues).
Also thanks for that info on the mesh flags - when I was going through the CS source before, I was wondering if that stuff was done by setting flags.  Also (this one's not really in any tutorial) how do you easily create a skybox/moving sky? (unless there's a new tutorial in the CVS version, since I just built it).

-eventhorizon
Logged
jorrit
Administrator
Hero Member
*****
Posts: 1704


View Profile
« Reply #3 on: July 13, 2005, 08:36:42 am »

Currently Skyscraper's code has come mostly from the Simple1 tutorial, and I have made wall/floor polygon code; I'll have to see how the CVS version works, because the stable version of CS was behaving really strange (I created an insidebox and outside box, but they had visibility issues).
Also thanks for that info on the mesh flags - when I was going through the CS source before, I was wondering if that stuff was done by setting flags.  Also (this one's not really in any tutorial) how do you easily create a skybox/moving sky? (unless there's a new tutorial in the CVS version, since I just built it).

-eventhorizon


I think the visibility issues might be caused by you not calling UpdateMove() on the movable after setting up the geometry. That call is needed for the visibility culler to do its job.

I recommend migrating to the CVS version of CS. Lots of bugs have been fixed in the CVS version.

Greetings,
Logged
Pages: [1] Print 
« previous next »
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.2 | SMF © 2006-2007, Simple Machines LLC Valid XHTML 1.0! Valid CSS!
Page created in 6.221 seconds with 14 queries.