Start a new topic

Creator Plugin

Original Post by: Sat Oct 25 06:57:56 2014


Hi,


I want to create a plugin in creator with customised attribute searches. can someone direct me how can i do it. like major steps. just like other tool boxes it should have a tool box.


Original Post by: Sat Nov 22 17:56:57 2014


Hi Steve,

I wanted a button to apply Effect Data 8 to layer 1 of polygons which has a texture on fltLayerTexture1,

the code i wrote is not seems to be correct because when i click the particular button its applying Effect Data 8 to all polygons (even to the polygons whose fltLayerTexture1 is -1)

Following is the code, please have a look.


static mgbool eDataApply (mgrec* db, mgrec* parent, mgrec* rec, void* edata)

{

toolrec* toolRec = (toolrec*)edata;

int edata8;

if (mgGetCode(rec) == fltPolygon)

{

edata8 = fltLayerTexture1;

if (edata8 >=0)

{

mgSetAttList(rec,fltLayerData1,8);

mgSetModelingMode(db, fltPolygon);

}

}

return MG_TRUE;

}

Original Post by: SteveThompson Mon Nov 24 16:54:32 2014


let's go line by line...


edata8 = fltLayerTexture1;

if (edata8 >=0)


This "if" will always evaluate to "true" because edata8 is the "code" for fltLayerTexture1 not the "value" for this attribute. This explains why all polygons are being affected. Perhaps what you meant here is to check if the "value" of this attribute was not -1. To do that, consider this code:


short indexOnLayer1;

mgGetAttList(rec, fltLayerTexture1, & indexOnLayer1, MG_NULL);

if (indexOnLayer1 >= 0)

{

...

}


mgSetAttList(rec,fltLayerData1,8);

First, in this statement you forgot the trailing MG_NULL. You MUST ALWAYS terminate the parameter list (in C) for mgSetAttList and mgGetAttList with MG_NULL. i.e.

mgSetAttList(rec,fltLayerData1,8, MG_NULL);

These functions are variable argument style so the MG_NULL is very important.



mgSetModelingMode(db, fltPolygon);


I am not sure why this here but if you really meant for your tool to set the modeling mode to polygon, so be it.

Original Post by: Mon Nov 24 19:33:23 2014


Thank you Steve.. I'm learning a lot of things now..

My next doubt is regarding fltxmTranslateDelta. How can I set the z value to zero with a button. As usual I tried my own coding n it's crashing ;).

Is this accessible only via fltCoord3d?

Original Post by: Mon Nov 24 19:58:32 2014


One more doubt is that in Python we can search inside strings for example if attList is assigned to get mgGetComment(rec).

I can search like

If ("something" in attList):

mgSetAttList()


Is this logo applies in C??

I had written a script for applying SMC code depending on the comment applied for a polygon. I would like to add that function also in my tool. But I don't know how to convert that to C.

Original Post by: SteveThompson Mon Nov 24 20:47:23 2014


My next doubt is regarding fltxmTranslateDelta. How can I set the z value to zero with a button. As usual I tried my own coding n it’s crashing wink.

Is this accessible only via fltCoord3d?


There are different ways to do this.


All these examples assume you have a record (rec) of type fltXmTranslate:


1) If you want to set all three values (x, y and z) simultaneously:


Given a record rec, and the name of one of its fltCoord3d attribute records, code, mgSetCoord3d sets the x, y, z attribute values in the fltCoord3d attribute record code.


mgSetCoord3d (rec, fltXmTranslateDelta, x, y, z);


2) If you want to set just the z coordinate (without changing x or y). There are a couple of ways to do this.


In this example get all 3 current values and then immediately set all 3 values using two (x and y) the same and changing the 3rd (z).

double x, y, dontCare;

mgGetCoord3d (rec, fltXmTranslateDelta, &x, &y, &dontCare;);

mgSetCoord3d (rec, fltXmTranslateDelta, x, y, z);


In this example, get a pointer to the nested record fltXmTranslateDelta. Once you get that nested record you can use mgSetAttList to set just the z coordinate of that record.

mgrec* nestedDelta;

nestedDelta = mgGetAttRec (rec, fltXmTranslateDelta, MG_NULL);

mgSetAttList (nestedDelta, fltCoord3dZ, z, MG_NULL);

Original Post by: SteveThompson Mon Nov 24 20:51:23 2014


One more doubt is that in Python we can search inside strings for example if attList is assigned to get mgGetComment(rec).

I can search like

If (“something” in attList):

mgSetAttList()

This is a C language question. You should investigate the C runtime library documentation for string manipulation functions. This is easily found with a web search. I'll point you toward the C functions strstr, strchr, strrchr etc. I'll leave it to you to do the rest ;-)

Original Post by: Thu Nov 27 16:55:15 2014


Hi Steve,


I found string manipulations and everything just works fine thank you so much... i would like to ad this feature which can set a specific value to vertex color. lets take eg: if i want the vertices to have 127 as their fltVColor (color index). and also i want to make vertices alpha to be 255. i tried with

mgSetAttList(rec, fltVColor,0,MG_NULL); as a test but vertices colors are not changing.

Original Post by: SteveThompson Sat Nov 29 18:28:03 2014


First thing is to check the Vertex Attribute page in Creator to see if your change is reflected there. Next, and I suspect this is the real problem (the vertex color was changed but you just can't see it in the Creator Graphics view) make sure the draw mode of the polygon is set to gouraud. Vertex colors are ignored when rendering flat or lit polygons. To check if this is your problem, change the draw mode on the polygon to gouraud and see if the face draws using the vertex color you set.


The polygon draw mode attribute, by the way, is fltGcLightMode. The values are:

0 = None (Flat)

1 = Gouraud

2 = Dynamic (Lit)

3 = Dynamic Gouraud (Lit Gouraud)


Also in your example you are only setting the vertex color index. For Creator color index 127 you must make sure fltVColor is 0 and fltVIntensity is 1.0. Setting fltVColor to 0 (by itself) may not necessarily be enough. For example fltVColor = 0 and fltVIntensity = 0.5 makes Creator color index 64. To say another way, if you only set fltVColor you leave fltVIntensity to what it was before.

Original Post by: SteveThompson Sun Nov 30 23:49:55 2014


and also i want to make vertices alpha to be 255.

The vertex attribute for this is fltVAlpha.


Note that if you are going to be setting a lot of OpenFlight attributes on nodes in the scene, it would be worth your time to become familiar with the OpenFlight Data Dictionary Reference. It lists all the node types and field codes for each node types. This is an invaluable reference if you need to get/set attribute values on nodes in the OpenFlight Scene Graph.

Original Post by: Mon Dec 1 18:12:06 2014


Thank you Steve.. i'm going to demo this plugin tomorrow to my team. I'm really thankful to you for your support. I have gone through the API references but still i might need your support in this.

Original Post by: SteveThompson Mon Dec 1 18:20:57 2014


No problem, we are very happy to help no matter the question!

Good luck during your demo.

Original Post by: Mon Dec 1 18:24:45 2014


I want to know this thing regarding texture mapping. is it possible to add mapping like for example i have applied Tex01.rgb to a polygon, i want to lock the mapping(add mapping of same texture) to all polygons with same texture with a button. is it possible?

Original Post by: SteveThompson Mon Dec 1 19:18:39 2014


I want to know this thing regarding texture mapping. is it possible to add mapping like for example i have applied Tex01.rgb to a polygon, i want to lock the mapping(add mapping of same texture) to all polygons with same texture with a button. is it possible?


There are two parts to applying textures to polygons in the scene. The first is the texture index applied to the polygon. The second is the UVs applied to the vertices on the polygon.


To "apply" a texture to a polygon in Creator you typically use the Put Texture (or other tool in the Texture Toolbox) to set both the texture index on the polygon and make the UVs for its vertices.


So your question is a bit ambigous:


i want to lock the mapping(add mapping of same texture) to all polygons with same texture with a button. is it possible?


If you want the same texture index applied to the "other" polygons, that is easy:

1) Select the face that already has the texture applied

2) In the Properties Toolbox, do Texture From Face - this "selects" this texture in the texture palette

3) Select the "other faces"

4) In the Properties Toolbox, do Insert Texture - this sets the texture index of the selected faces to the index of the texture selected in the palette.


The problem with this method is that the UVs on the "other" faces are not affected. If you want the UVs on the "other" faces to be calculated the same way the UVs are on the original faces, you have several choices:


1) Create a Texture Mapping in the Texture Mapping Palette

a) Select the face that already has the texture applied

b) In the Properties Toolbox, do Texture From Face - but this time hold down the CTRL key when you click the tool icon. This "selects" this texture in the texture palette and creates a Texture Mapping from the UVs on the selected face.

c) Select the "other faces"

d) In the Properties Toolbox, do Insert Texture - but this time hold down the CTRL key when you click the tool icon. This sets the texture index of the selected faces to the index of the texture selected in the palette and sets the Texture Mapping index on the faces to that created in step b) above.


2) Use the Texture Follow or Texture Flow tools in the Texture Toolbox. To use these, select (first) the face that has texture applied. Then "Add to Select" the other faces. Then run the tools. They both "copy" the texture index and UV mapping from the "first" face to the others using different UV mapping techniques. See the Creator help for more information.

Original Post by: Tue Dec 2 17:13:18 2014


Hi Steve,


I am facing an issue with selecting polygons which are subfaces. I'll explaing in what way ..

I added a button which can select polygons that have missing comments and it works fine. The issue is if a parent polygon and its subfaced polygon both have missing comment then only the parent polygon is getting selected, and if the subfaced polygon has comment missing and if the parent has comment then only its selecting subface. I want all the polygons to be selected if comment is missing whether its a nested polygon or not. Is it polssible?

Original Post by: SteveThompson Tue Dec 2 17:15:39 2014


The issue is if a parent polygon and its subfaced polygon both have missing comment then only the parent polygon is getting selected, and if the subfaced polygon has comment missing and if the parent has comment then only its selecting subface. I want all the polygons to be selected if comment is missing whether its a nested polygon or not. Is it possible?

In Creator, you are not allowed to select items recursively. Put another way a node can only be selected if no ancestors or descendants are selected. A subface is a descendant of its superface. Only one of them can be selected simultaneously. So no, it is not possible.

Login to post a comment