Crystal Space
Welcome, Guest. Please login or register.
April 25, 2014, 10:15:13 am

Login with username, password and session length
Search:     Advanced search
8990 Posts in 2037 Topics by 7635 Members
Latest Member: Separat1989
* Home Help Search Login Register
+  Crystal Space
|-+  Crystal Space Development
| |-+  Support
| | |-+  Create a Billboard
« previous next »
Pages: [1] Print
Author Topic: Create a Billboard  (Read 1097 times)
Taz
Newbie
*
Posts: 3


View Profile Email
« on: August 23, 2011, 10:45:17 pm »

Hello I want to create a simple Billboard on a specific Position like on the Map flarge(the Crystal space logo) but how i do this.I only found this http://www.crystalspace3d.org/docs/online/1.4/manual/Mazing-Game-Class.html#0 but this create a lot of Billboards and they are spreading around and I don't want that.I hope you understand what i mean Smiley.
Logged
kickvb
Global Moderator
Jr. Member
*****
Posts: 79


View Profile
« Reply #1 on: August 25, 2011, 05:25:10 pm »

If you are talking about the CS logo in the walktest application, then it is a 2D image which is displayed after the 3D view. This is made using csPixmap::Draw(), see the code in CS/apps/walktest/walktest.cpp, in the method WalkTest::DrawFrame2D().

If you are talking about 2D objects that are placed inside the 3D scene (therefore occluded like any other 3D object), then you may use eg a csPen.
Logged
Taz
Newbie
*
Posts: 3


View Profile Email
« Reply #2 on: August 25, 2011, 09:41:59 pm »

@kickvb thanks for your reply.But how I draw a texture with csPen ? I can't find a tutorial about it.
Logged
kickvb
Global Moderator
Jr. Member
*****
Posts: 79


View Profile
« Reply #3 on: September 02, 2011, 03:36:36 pm »

But how I draw a texture with csPen ? I can't find a tutorial about it.

There is effectively no demo about that in CS, but you may find an example of usage in the Ares Project, see eg here.

Basically, you would need:
- create a iPen. This can be made eg through:
Code:
csPen* pen = new csPen (...);
- setup the pen's properties, by calling eg SetColor, SetMixMode, SetPenWidth
- at each frame, after having drawn the 3D scene (using iView::Draw ()), draw something using the pen's DrawLine/DrawPoint/etc
Logged
kickvb
Global Moderator
Jr. Member
*****
Posts: 79


View Profile
« Reply #4 on: September 02, 2011, 03:41:46 pm »

Basically, you would need:
- create a iPen.
- setup the pen's properties, by calling eg SetColor, SetMixMode, SetPenWidth
- at each frame, after having drawn the 3D scene (using iView::Draw ()), draw something using the pen's DrawLine/DrawPoint/etc

And of course, don't forget to delete your pen when you don't need it anymore.

You can do this:
- either by using an explicit delete on your csPen*
- or by using a CS smart pointer to keep a reference to your object (which is the recommended way):
Code:
csRef<iPen> pen; pen.AttachNew (new csPen (...));
Logged
Taz
Newbie
*
Posts: 3


View Profile Email
« Reply #5 on: September 04, 2011, 09:51:59 pm »

@kickvb thanks now it works but this is not really that what I'm searching for cause the lines etc are only in the view and they can't be drawn behind an other mesh.But I've found this http://www.crystalspace3d.org/docs/online/1.4/manual/MeshObject-Spr2D.html#0 and it seems to be that what Im searching for but the documentation show's only how to implemented it in a map file and not with Cs and C++.Could you explain me how to do it ?
Logged
kickvb
Global Moderator
Jr. Member
*****
Posts: 79


View Profile
« Reply #6 on: September 09, 2011, 04:44:24 pm »

You can find a concrete example of code in the XML loader of the sprite 2D mesh, ie in plugins/mesh/spr2d/persist/standard/spr2dldr.cpp, in csSprite2DFactoryLoader::Parse().

The process is basically the same for all type of meshes in CS:

You must first get an access to the plugin of the sprite 2D mesh:

Code:
csRef<iMeshObjectType> type = csLoadPluginCheck<iMeshObjectType>
   (object_reg, "crystalspace.mesh.object.sprite.2d", false);

Then you create a factory for the mesh:

Code:
csRef<iMeshObjectFactory> factory (type->NewFactory ());

In order to setup the factory, you get an access to the iSprite2DFactoryState interface:

Code:
csRef<iSprite2DFactoryState> spr2dLook
   (scfQueryInterface<iSprite2DFactoryState> (factory));

Then you setup the vertices and other parameters of your factory through that last interface. The sprite 2D mesh implements also the iParticle interface, you can grab a pointer to this interface and setup its parameters in the same way.

Once this is done, you can now create instances of meshes, and personalize them if needed:

Code:
csRef<iMeshObject> mesh = factory->NewInstance ();
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 7.636 seconds with 16 queries.