Not logged inOpenClonk Forum
Up Topic Development / Developer's Corner / A little help: Drawing pictures of definitions / objects
- - By Newton [de] Date 2011-08-05 02:26 Edited 2011-08-05 02:29
Hey there.

I have a C4PropList PictureDef which can only be either a C4Def or a C4Object. Now, I want to draw the picture of the definition or object onto a given facet (and draw that at the specified position). For the lack of understanding and/or documentation of how all the drawing stuff with facets, surfaces, facetsurfaces, facettargets etc works, I naively used that code:

  C4FacetSurface fctPicture;
  if (PictureDef->GetDef())
    PictureDef->GetDef()->Draw(fctPicture);
  else if(PictureDef->GetObject())
    PictureDef->GetObject()->DrawPicture(fctPicture);

  C4Facet facet(cgo.Surface, iDrawX, iDrawY, PictureWidth, PictureWidth);
  fctPicture.Draw(facet);


but that doesn't work at all. (No errors, just it doesn't draw anything).
So, what would be the correct way to do this?
Parent - - By Sven2 [de] Date 2011-08-05 09:48
I'm pretty sure you have to Create the actual facet in the correct size first before drawing onto it.

Anyway, drawing on an external surface and then onto the main is a) slow and b) kills drawing modes like additive drawing. Just apply a clipper and draw onto the cgo directly if you can.
Parent - - By Newton [de] Date 2011-08-05 10:50
Can you give an example? As I said, I am not into the drawing system at all. Isn't there a ready-made method of the def/object to simply draw their picture at X,Y,Wdt,Hgt on the screen applying all color modifications and transformations?
Parent - - By Sven2 [de] Date 2011-08-05 11:26
You want C4Object::DrawPicture?
Parent - - By Newton [de] Date 2011-08-05 11:50
Yes. But I already used that, see above. (And what would it be for C4Def? Draw is correct?)
Parent - - By Sven2 [de] Date 2011-08-05 12:22
C4Object::DrawPicture just calls C4Def::Draw with an object parameter. C4Def::Draw draws the def picture and, if it gets an object parameter, applies modifications specific to that object (overlays, picture rect changes, modulations, etc.).
Parent - - By Newton [de] Date 2011-08-05 12:54
ok,...sooo... as you see I already used the right functions. But how to use the facets now to draw?
Parent - - By Sven2 [de] Date 2011-08-05 13:02
Why don't you just do:

C4Facet facet(cgo.Surface, iDrawX, iDrawY, PictureWidth, PictureWidth);
  if (PictureDef->GetDef())
    PictureDef->GetDef()->Draw(facet);
  else if(PictureDef->GetObject())
    PictureDef->GetObject()->DrawPicture(facet);


Also, what is this for? I cannot imagine a case where an assigned def overrides the more specific object.
Parent - - By Newton [de] Date 2011-08-05 13:08 Edited 2011-08-05 13:13
PictureDef is a proplist which has been given as a parameter to the CustomMessage function and may either be a def or an object. If it is an object, the current picture of the object should be drawn, otherwise just the definition picture. I am replacing the only usage that was left for portraits with the possibility to display normal object/def graphics.

Edit: Also - thats it? Oh, thats easier than I thought.
Parent - - By Sven2 [de] Date 2011-08-05 13:11
Why don't you just pass one C4Value, which can be either an object or a def?

Edit: Oh right, I understand. Both def and objects are proplists now. But wouldn't an object proplist also return a valid def for GetDef()?
Parent - By Newton [de] Date 2011-08-05 15:15
Right, switched it around
Up Topic Development / Developer's Corner / A little help: Drawing pictures of definitions / objects

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill