Crystal Space
Welcome, Guest. Please login or register.
July 30, 2014, 10:18:58 pm

Login with username, password and session length
Search:     Advanced search
9005 Posts in 2043 Topics by 8260 Members
Latest Member: Lovelymae39
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Support
| | |-+  Is this python code equivalent to this c++ code?
« previous next »
Pages: [1] Print
Author Topic: Is this python code equivalent to this c++ code?  (Read 1420 times)
didu
Newbie
*
Posts: 5


View Profile Email
« on: November 17, 2007, 03:21:59 pm »

Hi guys,

I've been following the user's manual and there is something I don't get.

The online user's manual for creating an iThing mesh (http://www.crystalspace3d.org/docs/online/manual-1.0/cs_4.10.4.php#4.10.4)
has the following example code:

Code:
csRef<iMeshWrapper> walls = engine->CreateThingMesh (room, "cube"));
csRef<iThingState> ws =  scfQueryInterface<iThingState> (walls->GetMeshObject ());
iMeshObject* walls_object = walls->GetMeshObject ();
iMeshObjectFactory* walls_factory = walls->GetFactory();
csRef<iThingFactoryState> walls_state =  scfQueryInterface<iThingFactoryState> (walls_factory);
walls_state->AddQuad (
  csVector3 (-.5, .5, -.5),
  csVector3 (.5, .5, -.5),
  csVector3 (.5, .5, .5),
  csVector3 (-.5, .5, .5));

Now, could someone please tell me whether the above c++ code should do the same thing as the following
python code:

Code:
walls = engine.CreateThingMesh(room, "cube")
ws = cspace.SCF_QUERY_INTERFACE_SAFE(walls.GetMeshObject(), cspace.iThingState)
walls_object = walls.GetMeshObject()
walls_factory = walls.GetFactory()
walls_state = cspace.SCF_QUERY_INTERFACE_SAFE(walls_factory, cspace.iThingFactoryState)
walls_state.AddQuad(cspace.csVector3(-0.5, 0.5, -0.5),
cspace.csVector3(0.5, 0.5, -0.5),
cspace.csVector3(0.5, 0.5, 0.5),
cspace.csVector3(-0.5, 0.5, 0.5))

I'm asking here because that the 5th line of the python code:

walls_state = cspace.SCF_QUERY_INTERFACE_SAFE(walls_factory, cspace.iThingFactoryState)

would return a None object.

Furthermore, if the function cspace.SCF_QUERY_INTERFACE was used instead of
cspace.SCF_QUERY_INTERFACE_SAFE, I would get an immediate segfault.

So ... what am I doing wrong?

Any help would be greatly appreciated.

Thanks a lot.

-D
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 4.221 seconds with 15 queries.