Page Loading... please wait!


This message not going away?
Ensure Javascript is on and click the box
Sep 24, 2017 - 06:19 AM  
Realsoft.org  
 
 

Realsoft.org FAQs (frequently-asked questions)

Category: Main -> SDK -> sdk-list

Question

Answer

Where is the linux SDK?

Realsoft 3D SDK is platform independent. You can download it from http://www.realsoft.com/sdk page.

Juha Meskanen
Realsoft Graphics

Back to top
When motion blur is enable a single frame actually consists of multiple internal frames. Is there a way to find out when all the samples for a certain frame are ready?

You can study the current frame parameter (p2) for R3TTM_TIME method.

Juha Meskanen,
Realsoft Graphics

Back to top
I have implemented a special purpose lattice object. However, the attached targe tobjects don't get updated when my lattice object changes. Which message i can send to the lattice mapped object to get it updated?

Every model object should call R3MM_CHANGED whenever their state is changed. I believe your special purpose lattice object don't do this and therefore the attached target objects are not updated.

Regards,
Juha Meskanen,
Realsoft Graphics

Back to top
I'm trying to find a way to use the status bar control to manage
canceling operations during time consuming operations. Can you explain how to use it?

Don't call time consuming method directly. Instead, call it via R3IAM_DOASYNC
method, as follows:

/* call mym_doheavystuff'through an async thread */
R3Do3(interactor, R3IAM_DOASYNC, mym, MYM_DOHEAVYSTUFF,
R3RA_P1, p1,
R3RA_P2, p2,
R3RA_P3, p3,
R3TAG_END);

In the doheavystuff method, study the progress indicator to
see if the user has clicked the cancel button.

static void *mym_doheavystuff(R3CLASS *cl, R3OBJ *obj, void *p1, void =
*p2, void *p3)
{
....
R3DoA(progind, R3PROGREM_BEGIN, (void*)to);
for(i =3D 0; i < to; i++) {
.....

/* see if the user has canceled the operation */
if(R3DoA(progid, R3PROGREM_PROGRESSTO, (void*)i))
break;
}
R3DoA(uvmsg->progress, R3PROGREM_END, (void*)to);
..
}


For example, the UV Image tool uses this approach.

Regards,
Juha


Back to top
How can I scan through all the VSL objects in a VSL material and study their attributes?

The following recursive code demonstrates this:

static void ReadShader(R3OBJ *o)
{
char *name;
R3CLID clid;
R3INT op;
R3CLID out_channel;
...

// fetch attributes common to all shaders
R3GetAttrs(o,=20
R3RA_ClassId, &clid,=20
R3RA_Name, &name,
R3MATPRPA_Operation, &op,=20
R3MATPRPA_OutputChannel, &out_channel,
R3MATPRPA_Disabled, &disabled,
.....
R3TAG_END);

// fetch shader specific attributes=20
switch(clid) {
case R3CLID_MPTEXTURE:
{ R3BOOL tilex, tiley, gradex, gradey, flipx, flipy,....;
char *imagename;
R3GetAttrs(o,=20
R3MPBMA_ImageName, &imagename,
R3MPTA_TileX, &tilex,
R3MPTA_TileY, &tiley,
R3MPTA_GradeX, &gradex,=20
....
R3TAG_END);


// handle attributes, for example, export them to a file (?) = .....
fwrite(file, "Material: %s\n", name);
fwrite(file, "tilex: %d\n", tilex);
fwrite(file, "tiley: %d\n", tiley);
...
break;
}

case R3CLID_...
....
break;
}

// recursively handle sub shaders
if(R3ObjectIsOfKind(o, R3CLID_MPLEVEL)) {
R3LIST *sub;
R3NODE *n;

R3GetAttrs(o, R3MPLEVA_Children, &sub, R3TAG_END); =20
for(n =3D sub->head; n->next; n=3Dn->next)=20
ReadShader((R3OBJ *)n);
}
}


Kind regards,
Juha Meskanen, Realsoft

Back to top
How can i create and show a separator gadget in a control gadget?

To create a separator gadget (oops/r3separg.h):=20

separator =3D R3New(R3CLID_SEPARATORGADGET,
R3WGA_Parent, window,
R3WGA_Orientation, orientation,
R3TAG_END);

where 'orientation' is:
- R3WGORIENTATION_VERTICAL or R3WGORIENTATION_HORIZONTAL,
as defined in 'oops/r3widget.h'

Regards,
Juha Meskanen,
Realsoft Graphics

Back to top
I am trying to create a bitmapped button (i use R3NewPrimgadButton
function). When I insert it into a control gadget it always fill the
entire space in the x direction. How can I control the fillx, filly and expand parameters?

R3NewPrimgadButton() function is a simple shield function, which allows one to create certain type of buttons easily. Don't call the function if you want control ove the layout. Instead, implement a shiled function which does what you want:

// create a button with an icon
icon =3D R3New(R3CLID_ICON,
R3ICONA_Data, myicon_bits,
R3ICONA_Width, myicon_width,
R3ICONA_Height, myicon_height,
R3ICONA_Depth, myicon_depth,
R3TAG_END);=20

button =3D R3New(R3CLID_BUTTON,
R3WGA_Parent, window,
R3GA_Icon, icon,
R3GA_Text, "My button"
R3GA_ToolTip, "My tooltip....",
R3TAG_END);=20

// make the button talk to you=20
R3Do(button, R3WGM_MAPCHANGES,
R3WGA_MapToObj, myobj,
R3WGA_MapToMethod, mymth,
R3TAG_END);

// layout=20
R3Do(mypacker, R3GMM_INSERT,=20
R3GMA_Slave, button,
R3PA_PackFlags, 0, // R3PAPF_...
R3TAG_END);

Regards,
Juha

Back to top
I'm doing a quick test with java script and i found that I can't find an object by its name

primlayer = new Object;
rsobj = new Object;

primlayer = GetJS("CurrentProject.Geometrics");
rsobj =primlayer.FINDBYNAME("test");

The function FINDBYNAME do not find the object. Where i'm wrong?

You have to specify a complete path:

For example:

rsobj = primlayer.FINDBYNAME("/root/test");


You may also use wildcards, such as:

rsobj = primlayer.FINDBYNAME("*test");

Regads,
Juha

Back to top
It is possible by using scripting getting choreography weights for an
object? I've tried with 'Choreography Weight(chor_name)' attribute but scripting system tells me that this attribute do not exist.

This is a bug. Parentheses in the attribute name:

Set("myobj.Weight(chor_name)", 0.5);

confuse the interpreter.

We need to change the naming convention for the weight attributes to fix the problem.

Regards,
Juha

Back to top
Is there a way to load an object saved in an .r3d file and put it in the
current project? Also, after loaded this object must be inserted into a level so I need to know its address. Is there a way to do this?

The easiest way to do this is by calling:

/* make the desired level the current working level */
R3SetAttrs(primlayer, R3PLAYA_CurrentLevel, my_insert_to_level,
R3TAG_END);

/* read geom. objects into the current level */
int bit = (int)R3DoA(filer, R3FIRM_FETCHSECTIONBIT, (void
*)R3IFFID_PRIMITIVE);
R3Do(filer, R3FIRM_LOAD,
R3FIRA_FileName, filename,
R3FIRA_Sections, 1< R3FIRA_Replace, FALSE, /* insert */
R3TAG_END);

Which does the same as 'Paste from file' menu in the select window.

If more control is needed, you might want to let the program to read geometric into a temp. project buffer. Then you can study the loaded
objects and move them to the actual project buffer.

Here is the code:

To create a temp. project list with one project buffer:

#include <real></real>r3layer/r3laylis.h>

projectlist = R3New(R3CLID_LAYERLIST,
R3OLAYA_NoLocking, TRUE,
R3TAG_END);
project = R3DoA(projectlist, R3OLAYM_NEWOBJECT, NULL);
R3SetAttrs(projectlist, R3LAYLA_CurrentLayer, project, R3TAG_END);


To read read geom. objects to the created temp buffer.

#include <real></real>code/r3filer.h>

R3OBJ *filer;
R3GetAttrs(project, R3LAYLA_Filer, &filer, R3TAG_END);
int bit = (int)R3DoA(filer, R3FIRM_FETCHSECTIONBIT, (void
*)R3IFFID_PRIMITIVE);
R3Do(filer, R3FIRM_LOAD,
R3FIRA_FileName, filename,
R3FIRA_Sections, 1< R3FIRA_Replace, TRUE,
R3TAG_END);

Now you can access objects in the temp project the same
way you already manage objects in the actual project.

Regards,
Juha

Back to top
I am trying to use VSL objects - specifically raytrace & texture - within
Realman but without much success.

My approach is the create the object at rendertime (on first use),
evaluate it as demanded by the script and then destroy it when rendering
completes. However, I cannot work out what attributes are required when
creating the objects.

For raytrace I'm using R3CLID_RMPRAYTRACER class and passing R3RMPRAYA_
attributes. Presumably some R3RMPA_ attributes are required too but which
ones?

This approach may work, but you have to make sure the objects you create get some important initialization messages which are usually send to all VSL
objects before rendering. If you create them later, make sure same
initialization steps happen.

For a texture VSL object, the method R3FRBOM_CHANNELLINK is the main
initialization method. Calling it after delayed object creation is necessary. The parameters for the method are:

p1: R3INT, link counter (incerements whenever channel setup changes.
Probably irrelevant for you.)

p2: char **, address of an error message pointer. You can use here address
of a dummy null initialized string pointer.

p3: R3OBJ *, address of a raysample object for dynamic channel linking. You
can store the address which your host material object gets from this method
at render initialization time and pass it forward to sub (VLS) objects when
you create them later.

Another important issue is making sure that enumeration etc. methods which
ask about channel usage take into account those objects which do not exist
yet. For example, render engine may examine which materials include custom
illumination shading, and perform or skip some shading steps accordingly.

Raytracer VSL objects needs the address of the host render engine object for
making trace callbacks. Usually this is passed as

R3FRLOA_RenderEngine, frengine, ...

in the tag list for every VSL object and material object creation. You may
store the address when your realman material object is created and pass it l
ater to the created raytrace object.

Also, the usual input and output channel attributes of R3RMPA_ super class
must be defined.

I hope this helps!

Best regards,
Vesa

Back to top
I've heard rumors in the past of a C++ SDK in the works. Is there any ETA on when it may be available? Will it work with RS3D 4.5, or will it be aimed entirely at RS3D V5?

Just curious..

There is no native C++ interface available yet, because calling 'C' from a C++ code shouldn't be a problem.

Back to top
Suppose i want to override for example the drawing method of an object that
alredy exist in Realsoft3D, e.g. for the skeleton, is there a way to override the original wireframe drawing function (Or the wireframe class) with one of my own?

Also, it is possible to add new functionality to some object without the
need to implement a 'derived' version of it? For example i want to add a new
method to the skeleton that let me setup a personal weight for points?

The same question goes for the properties gadget, interactors, tools and so on.

I used the following approach for an experimental plugin some time ago.
The SDK has changed a lot since then so this code may not be up-to-date
:-)

richard.



static R3CLASS *macro_class;
static R3DISPATCHER macro_dispatch;
...

static void *my_macro_dispatch(R3CLASS *cl, R3OBJ *obj,
int mth, void *p1, void *p2,
void *msg)
// Replacement dispatcher for macro class
{
void *result;

switch(mth)
{
case R3MCM_READMACROS:
case R3MCM_IMPORTMACROS:
case R3MM_CHANGED:
... // do my special processing then pass message to
// original dispatcher
result = (macro_dispatch)(cl, obj, mth, p1, p2, msg);
... // then do more stuff
break;
default:
// just pass message on
result = (macro_dispatch)(cl, obj, mth, p1, p2, msg);
break;
}
return result;
}


int RegisterMyClass(R3APP *apphnd)
{
...

if(R3ClassCreate(R3CLID_ROOT, R3CLID_MYCLASS, ...

macro_class = R3ClassFind(R3CLID_MACCL);
if (macro_class)
{
// Get current dispatcher address
R3SendMsg(macro_class, R3RM_GETCLATTR,
R3RCA_Dispatcher, &macro_dispatch, R3TAG_END);
// plug in my dispatcher
R3SendMsg(macro_class, R3RM_SETCLATTR,
R3RCA_Dispatcher, my_macro_dispatch, R3TAG_END);
}
return(TRUE);
}

Regards,
Richard


You can also add so called 'extension methods' to a class.

static void *carlosSetWeight(R3OBJ *skel, void *p1, void *p2, void *p3)
{
R3JOINT *joints;
R3INT count;

R3GetAttrs(skel,
R3SKA_Joints, &joints,
R3SKA_JointCount, &count,
R3TAG_END);

....
return (void *)TRUE;
}


Then register the method to the class by calling:

R3ClassAddExtensionMethod(R3CLID_SKELETON, "carlosSetWeight",
setweight);


Now you, or anyone can call your method using R3DoE() functions:

R3DoEA3(skel, "carlosSetWeight", p1, p2, p3);

Regards,
Juha

Back to top
Given a skeleton and a joint (of the skeleton) by index or pointer, how can
i get wich objects are bounded to it and wich points?

Here is the code It selects all points which are bound to the specified bone (skeleton + bone index).

struct mycontext {
R3FLOAT minbone;
R3FLOAT maxbone;
R3INT mapid;
R3BINDINGATTR *mapattrs;
R3OBJ *prevobj;
};

static int select_target_points(struct mycontext *d, R3OBJ *obj, R3VECTOR
*p, int index, int type)
{
if((d->prevobj != obj) || !d->mapattrs) {
if(!(d->mapattrs = R3DoA2(obj, R3PRIMM_FINDVARATTR, (void
*)d->mapid, (void *)R3SKA_BoneIndexes)))
return TRUE;
d->prevobj = obj;
}

if(d->mapattrs[index].bone >= d->minbone && d->mapattrs[index].bone <
d->maxbone)
if(d->mapattrs[index].weight > 0)
R3DoA2(obj, R3PRIMM_SELECTHANDLE, (void *)index, 0);
return TRUE;
}

/* select 'target' points if they are bound to the given skel and boneindex
*/

void selecttargetpoint(R3OBJ *skel, R3OBJ *target, R3INT boneindex)
{
struct mycontext d;
R3LIST *sub;
R3NODE *n;

d.mapid = 0; /* 0 ... R3SKA_MapCount-1 */
d.prevobj = d.mapattrs = NULL; /* just to optimize FINDVARATTR so that
we don't need to call it for every point */

/* convert bone index to min max param values specifying the bone */
R3DoA2(skel, R3SKM_BONEINDEXTOPARAM, (void *)boneindex, &d.minbone);
R3DoA2(skel, R3SKM_BONEINDEXTOPARAM, (void *)(boneindex+1), &d.maxbone);

/* enumerate points from the target object */
R3Do(target, R3PRIMM_ENUMHANDLES,
R3RA_Hook, select_target_points,
R3RA_HookData, &d,
R3TAG_END);
}
}

Regards,
Juha

Back to top
is it possible to transform the Coordinates channel from camera space to world space and back inside a vsl plugin ?

Usually all geometry information comes from the geometry objects, =
including
the material map objects. Shaders (=3DMaterials) themselves do not =
contain 3D
point data. This policy is chosen in order to make materials more =
flexible
and reusable.

If a material needs camera space coordinates, it should be mapped using
pyramid or camera mapping. Then, both 'Coordinates' and 'Map coords' of =
the
camera space are available simultaneously.

I have improved the flexibility of this system in V5 by assing a new =
'Map'
VSL object which recomputes the Map coords at any given point. With that
object, you will be able to, for example, sample random points around =
the
original examined point and get a consistent map coords channel value =
for
each sample.

If for some reason this is not appropriate for your goal, you can do as
follows:

In the R3RM_CREATE method of a VSL object or material object, store the
address of the actual raytracer as follows:

static void *R3Create(R3CLASS *cl, R3OBJ *obj, R3TAG *tags)
{
R3IDATA *self =3D R3CL_IADDR(cl, obj);
R3OBJ *frengine;

R3TagGet(tags, R3FRLOA_RenderEngine, &frengine, R3TAG_END);
R3GetAttrs(frengine, R3FRA_RayTracer, &self->raytracer, R3RA_Done);
...

Later, in R3FROM_ALLREADY method, which is called at the beginning of =
every
render, you can fetch the camera data. Note that create is called only =
once,
after which the camera orientation may change several times because of =
scene
cache use etc. The _ALLREADY method is the right place for fetching the
data.

static void *R3AllReady(R3CLASS *cl, R3OBJ *obj)
{
R3IDATA *self =3D R3CL_IADDR(cl, obj);

R3FLOAT box_x, box_y, box_w, box_h, img_x, img_y, img_w, img_h;
R3INT projection;
R3VECTOR hor, vert, norm;

R3GetAttrs(self->raytracer, /* see real/raytr/r3rensys.h for R3REA_
attribute information */
R3REA_BoxX, &box_x,
R3REA_BoxY, &box_y,
R3REA_BoxW, &box_w,
R3REA_BoxH, &box_h,
R3REA_ImgX, &img_x,
R3REA_ImgY, &img_y,
R3REA_ImgW, &img_w,
R3REA_ImgH, &img_h,
R3REA_Hor, &hor, /* cam axis directions */
R3REA_Vert, &vert,
R3REA_Norm, &dir,
R3REA_Projection, self->projection, /*
perspective/orthogonal */
R3TAG_END);

With this data, you can map points to camera space yourself.

Important note: rendering space is not the same as the world space in
modelling phase. Rendering space origin is always camera origin. That's =
why
it is not fecthed in the code above. All rendering objects, including =
VSL
objects, receive a R3RM_TRANSFORM method which puts the coordinates into
rendering space. This system is usually totally invisible to material
objects, thanks to the geometry separation idea I presented above.


Kind regards,

Vesa Meskanen
Realsoft Graphics

Back to top
I'm not sure, maybe i've to call a different updating function, but I
tryed to change the R3GA_Text attribute of a compound gadget like the float gadget, vector gadget, but without success.

It seem that one can define the attribute only at creation time. I found instead that other gadget (like the integer gadget) allow this change.

You are right. Vector, float and a few other gadgets handle R3GA_Text attribute only in the create method. I'll fix the problem for the next v5 release.

Kind regards,
Juha Meskanen,
Realsoft Graphics

Back to top
I've implemented a custom seelction helper for selecting custom handles
(points, lines, triangles etc..) but i got into a problem. I derived it from R3CLID_SELECTHELPERBASE class.All ok, i can test for hits, and my custom way to do hit testing work ok, but i've a problem when i need to refresh a particular object when one of this handle are selected.

Particularly i cannot find a way to redraw an object when a selection occurred. For example when the interactor click on a point handle i sent to the object a message informing that this point are selected (R3PRIMM_SELECTHANDLE), all ok, selection are added, but at this point
the object in question must redraw itself so in the R3WIREM_RENDEREDITHANDLES i can draw the new state.

You should not try to call any rendering method directly. Instead, just tell the layer object that you have played with object selection. To do this, call:

R3Do(layer, R3MM_CHANGED,
R3OLAYM_SELECTOBJ, NULL,
R3TAG_END);

and appropriate rendering methods will be generated automatically.

Kind regards,
Juha Meskanen,
Realsoft Graphics

Back to top
How I can create a skeleton and define joints for it?

You have two options: either define joint coordinate systems directly, or define bone angles and lenghts and let the skeleton to compute joint positions for you.

The following code demonstrates the first approach:

#include <real></real>objects/r3skel.h>

R3JOINT joints[..];

for(i = 0; i < count; i++) {
memset(&joints[i], 0, sizeof(R3JOINT));

joints[i].cs.origin = ... // position of the joint
joints[i].cs.hor = ... // vector pointing towards the next joint
joints[i].cs.norm = ... // axis for the 'a' angle 'a' angle
joints[i].cs.vert = ... // cross product of the norm & hor.

// remember to initialize also the constraints
joints[i].ca_min = 0;
joints[i].ca_max = 2*PI;
....

// name
sprintf(joints[i].name, "my joint %d", i);
}

skel = R3New(R3CLID_SKELETON,
R3SKA_Joints, joints,
R3SKA_JointCount, count,
R3SKA_AxisCA, &nativecs.hor,
R3SKA_AxisCB, &nativecs.vert,
R3SKA_AxisCC, &nativecs.norm,
R3TAG_END);

R3DoA(skel, R3SKM_UPDATEANGLES, NULL);

---

Here is the code demonstrating the second approach:

for(i = 0; i < count; i++) {
memset(&joints[i], 0, sizeof(R3JOINT));

joints[i].ca_curr = ... // heading angle;
joints[i].cb_curr = .. // pitching angle
joints[i].cb_min = .. // banking angle
joints[i].len = .... // distance to the next bone

....
}

skel = R3New(R3CLID_SKELETON, ....

R3DoA(skel, R3SKM_UPDATEPOSITIONS, NULL);

Kind regards,
Juha


Back to top
The problem I have, is to create a skeleton from joint absolute position
and a quaternion orientation. Here is a little snip of the joint data I want to parse and create a skeleton from.
----
name | parent | joint position x y z(left handed cs) | joint orientation (normalized quaternion qx qy qz, joint joint index
qw component is calculated from)
...
"Lupleg" 3 ( 0.6002340317 5.5054349899 47.553604126 ) ( 0.6286746264
-0.113572225 0.1401890218 ) // Hips
"Lloleg" 4 ( -1.0567989349 8.4965229034 25.1324481964 ) ( 0.53992939
0.3191007674 -0.3878624737 ) // Lupleg
"Lankle_r" 5 ( -4.6853141785 10.8447065353 5.3701858521 ) ( 0.351169765
-0.074638769 0.446950227 ) // Lloleg
...
---

Convert quaternions to HPB or HPT angles with one of the following
two functions:

R3QToHPT(R3VECTOR4 *q, R3VECTOR *hpt);
R3QToHPB(R3VECTOR4 *q, R3VECTOR *hpb);

Note that realsoft uses 4d vector for representing quaternions.

Or, you can use:

R3QToMatrix(R3VECTOR4 *q, R3MATRIX mat);

to convert quaternions to 4x4 transformation matrix. Then compute the actual bone cs by transforming an identity cs:

R3MxTransform(&joint[i].cs.hor, mat, VIdentityX());
R3MxTransform(&joint[i].cs.vert, mat, VIdentityY());
R3MxTransform(&joint[i].cs.norm, mat, VIdentityZ());

If you find any problems, let me know.

Kind Regards,
Juha Meskanen, Realsoft Graphics

Back to top
How can I get the number of a specific object (like SDS or something else) the object tree in the select window contains? I there an easy way without parsing the whole object tree to get the count of specific objects?

Use R3OLAYM_ENUMOBJECTS method to enumerate the contents of the geometric primitives layer, as follows:

---
static myhook(R3OBJ *obj, int *count)
{
if(R3ObjectIsOfKind(obj, R3CLID_SUBDIVISION))
(*count)++;
return 1;
}

int sdscount = 0;
R3DoA(primlayer, R3OLAYM_LOCKSHARED, NULL);
R3Do(primlayer, R3OLAYM_ENUMOBJECTS,
R3PLAYA_Recursive, TRUE,
R3RA_Hook, myhook,
R3RA_HookData, &sdscount,
R3TAG_END);
R3DoA(primlayer, R3OLAYM_RELEASE, NULL);

if(sdscount >1) {
....
}

--

Kind regards,
Juha Meskanen,
Realsoft Graphics



Back to top
Juha already suggested to Carlo to do the following:

#ifdef R3V5
R3DoA(obj, R3TTM_GETENDTIME, &total_seconds);
currseconds = local_time * total_seconds;
#else
currseconds = local_time;
#endif

This may be enough, but the conditional compilation means that you must have TWO versions of your plugin, one for v4 and one for v5. It would be better to use the same piece of code for both v5 and v4.5. I mean, is it possible to check the version in runtime ?

Yes, you should study the class version of the inc/real/coder3ttag.h class. This new time system was introduced in version 13.

R3INT version;
R3GetClassAttrs(R3CLID_TTAG,
R3RCA_Version, &version,
R3TAG_END);
if(version < 13) {
// v4.5
...
} else {
// v5
...
}

Kind Regards,
Juha

Back to top
I'm trying to create a material mapping object.

object = R3New(R3CLID_DEFAULTMAPPING,
R3RA_Name, "my map",
R3DEFMAPA_Type, R3DEFMAPTYPE_SURFACE,
R3MAPA_Name, "my material",
R3TAG_END);

When I render the scene, I get "Mapping cannot be bound" error. What am I doing wrong?

Just one attribute is missing: R3MAPA_SourceBaseClid. This tells the mapping object whether R3MAPA_Name refers to a material object or to a post effect object.

#include <real></real>code/r3matbas.h>

object = R3New(R3CLID_DEFAULTMAPPING,
R3RA_Name, "my map",
R3MAPA_Name, "my material",
R3DEFMAPA_Type, R3DEFMAPTYPE_SURFACE,
R3MAPA_SourceBaseClid, R3CLID_MATERIALBASE,
R3TAG_END);

Back to top
I wonder what RS3D-API calls provide me with the nice non-modal dialog-windows (Info, Warning, Error) that have the colourful images embedded.

To shown an error to the user, call:

R3Error(char *, ...);

Information can be shown by calling:

R3Info(char *, ...);

These write the message also the the program log as well as the info window.

Both calls use 'inc/real/gadget/r3request.h' class. You can use it as follows:

win = R3New(R3CLID_REQUEST,
R3WGA_Parent, mainwin,
R3REQUESTA_Type, R3REQT_WARNING,
R3REQUESTA_Text, "Have a nice day",
R3REQUESTA_EscapeMth, ...,
R3TAG_END);

The EscapeMth is the method to be sent to you when the user
closes the dialog by hitting 'Esc' key or by closing it from the
close gadget.

You can add any number of buttons to the dialog. For example,
if you want to ask the user whether he/she wants to save
the project, cancel the operation or just exit without saving, call:


R3Do2(win, R3REQUESTM_SETMETHODS, yourobj,
yoursavemthid, "Yes",
yourclosemthid, "No",
yourcancelmthid, "Cancel",
R3TAG_END);

Then, just like with any window you create in realsoft, you must also ask
the program to update the layout and make the window visible
to the user:

R3DoA(win, R3WGM_FIT, (void *)R3WFP_BESTFIT);
R3DoA(win, R3WGM_REALIZE, NULL);


When the user clicks one of the buttons, the dialog will call 'yourobj'
with the corresponding method.

You may also set short cut keys for the buttons. For example,
to ask the dialog to apply 'Yes' button whenever the user hits 'y'
key, call:

R3A2(win, R3REQUESTM_SETKEYFORBUTTON, (void*)0, "y");

The default button can be set by calling:

R3DoA(win, R3REQUESTM_SETDEFAULTBUTTON, (void*)0);

where the parameter refers to the ordnum of the button.


When you don't need the window anymore, just call:

R3DoA(win, R3WM_CLOSEWINDOW, NULL);


Juha


Back to top
I have searched through the scripts directory and have not been able to find any way to set a group of points as selected.

The base class for geometric objects (real/objects/r3prim.h) defines five methods for managing selected status.

You can set points as selected using the following methods:


SELECTHANDLE(index, type)


To unselect handles, call:

UNSELECTHANDLE(index, type)
UNSELECTALLHANDLES(type)


To toggle the selected state of a point:


TOGGLEHANDLE(index, type);


To find out if a handle is selected:


selected = HANDLESELECTED(index, type);


The 'index' parameter refers to the ordnum of the point to be selected/unselected. The 'Type' parameter must 0 for geometric point handles (a geometric object may additional handles: rotation handles, translation handles etc. which can be identified with the type parameter).

A few examples:


// unselect all handles
myobj.UNSELECTALLHANDLES(0);

// then select the first and the last points:
count = myobj.GetPointCount();
myobj.SELECTHANDLE(0, 0);
myobj.SELECTHANDLE(count-1, 0);

// Or, if you have an array of selection states:

count = myobj.GetPointCount();
for(i = 0; i < count; i++) {
myobj.SELECTHANDLE(selectarray[i], 0);
}





Back to top
I have a question about the particle class, please can you help? I need the position of the particles. Now my question. Is R3PAA_Origin a pointer to an array of particles with the length R3VECTOR * number_of_particles? Or do I need a function call to fetch the whole particles.

Use R3PRIMA_Points and R3PRIMA_PointCount to fetch the pointer to geometric points and the number of them. Works for any geometric object.

Examples for 1d, 2d and 3d particles below:

// 1d particles
#include <real></real>objects/r3part1d.h>

R3INT count;
R3VECTOR *points;

R3GetAttrs(obj,
R3PRIMA_Points, &points,
R3PRIMA_PointCount, &count,
R3TAG_END);

// loop through the particles
for(i = 0; i < count; i++) {
....



#include <real></real>objects/r3part2d.h>

R3INT count
R3AXIS *axes;

R3GetAttrs(obj,
R3PRIMA_Points, &axes,
R3PRIMA_PointCount, &count,
R3TAG_END);

#include <real></real>objects/r3part3d.h>

R3INT count
R3COORDSYS *cs;

R3GetAttrs(obj,
R3PRIMA_Points, &cs,
R3PRIMA_PointCount, &count,
R3TAG_END);




Regards
Juha Meskanen
Realsoft

Back to top

Login





 


 Log in Problems?
 New User? Sign Up!

Realsoft Graphics
Copyright © 1989 ... 2012
Realsoft Graphics