Questions around tS SDK API

About Truespace Archives

These pages are a copy of the official truespace forums prior to their removal somewhere around 2011.

They are retained here for archive purposes only.

Questions around tS SDK API // Archive: Tech Forum

1  |  

Post by Johny // Feb 28, 2006, 4:05am

Johny
Total Posts: 672
pic
I created a new scene, deleted all scene light and fill it with 10 new cube. So there're only 10 cube on the scene.


1. Then used ts SDK API's tsxSceneGetFirstNode to get the first top level GNode.

Got "tsxPOLYHEDRON" (the first cube).


2. Then call tsxSobjGetNext to get the second object.

Got "tsxPOLYHEDRON" (the second cube).


3. Then call again tsxSobjGetNext to get the third object.

Got "tsxOBJSCRIPT" (not the third cube).


4. Then call again tsxSobjGetNext to get the fourth object.

got "tsxUNDEFINED" (where're the other eight cubes:confused: )


5. Others next call to tsxSobjGetNext still return "tsxUNDEFINED".




I also already tried with tsxGNodeGetNode but got only the first and the second cube.


Is there any suggestion about how to get the list of all object in tS scene?:confused:

Post by Johny // Mar 21, 2006, 4:40am

Johny
Total Posts: 672
pic
I tried to buil a NURBS curve from scratch (use tS SDK API).


Searching from example that come with SDK, but not found any example about code NURBS curve. :(


Tried every tsxNCURVE function, but also can not get any result. :(


Can anyone give me some suggestion or may be some info about what steps are require to do to create a simple NURBS curve from scratch?:rolleyes:

Post by stan // Mar 21, 2006, 5:27am

stan
Total Posts: 1240
pic
hey Johny..here is partially repaired source code [vc 7] for the scene explorer sample..it found all my cubes in a test just now..

no idea on the nurbs curves

Post by Johny // Mar 21, 2006, 5:48am

Johny
Total Posts: 672
pic
Stan, thanks for the code :banana:


Stan, your code work well on tS7.0. :)


It crash on my ts6.6. (Run well after I removed GetMaterial code)



// Material information ...

file << "Material\n";

tsxMATERIAL Material;



/* if(tsxPolyhGetMaterial(pPolyhedron, pFace->materialIdx, &Material) == e_tsxTRUE)

WriteMaterialInfo(file, &Material);

else

file << "undefined";


*/ file << "\n";



Just let you know :jumpy:

Post by stan // Mar 21, 2006, 10:28am

stan
Total Posts: 1240
pic
johny..glad it worked..

here is some source code ..I figured out the ncurve..this will make a straight line ..it opens draw panel too..cool .but I don't really understand how to setup a fancy curve too well :confused:
it's the patch example converted..:D

Post by Johny // Mar 21, 2006, 9:20pm

Johny
Total Posts: 672
pic
Stan, thank again for the code :jumpy:


I make add some code to your code, and now it can draw out spiral curve like you can see on below image :)


And here is the spiral code :D

Post by Johny // Mar 26, 2006, 4:07pm

Johny
Total Posts: 672
pic
Dear Caligari Customer Support Service and All,


I have 320x200 window view port.


If I use "tsxRenderAViewToFile"

with:

tsxRenderToFileData.width= & 1024,

tsxRenderToFileData.height=756.

It can render out an image file with size 1024x756pixel. (like my wish)


Problem come when I use "tsxRenderAViewRectangleToFile"

with:

tsxRenderToFileData.width= 1024,

tsxRenderToFileData.height=756,

CtsxRect = {10,10,160,150}.

It render out an image file with resolution 151x141pixels. (I want to render out view port rectangle area to image file with resolution 1024x756pixels).

And if I changed values of tsxRenderToFileData.width and tsxRenderToFileData.height, it still render out 151x141 image file.


My question is: "Are the "tsxRenderToFileData.widtht value" and "tsxRenderToFileData.height value" not use or not effect on "tsxRenderAViewRectangleToFile" function?


If the answer is support. Where the problem come from?


Thanks

Johny

Post by chamaeleon // Mar 27, 2006, 4:24am

chamaeleon
Total Posts: 74
Problem come when I use "tsxRenderAViewRectangleToFile"

with:

tsxRenderToFileData.width= 1024,

tsxRenderToFileData.height=756,

CtsxRect = {10,10,160,150}.

It render out an image file with resolution 151x141pixels. (I want to render out view port rectangle area to image file with resolution 1024x756pixels).

And if I changed values of tsxRenderToFileData.width and tsxRenderToFileData.height, it still render out 151x141 image file.


The idea behind tsxRenderAViewRectangleToFile is to, working with the sizes above, to imagine that you have a 1024x756 view, and you save 151x141 pixels from that view at a 10,10 offset.


For instance, lets say you want to render a 16000x16000 image, currently impossible using Ligthworks. You could then use this function and call it 4 times with width and height set to 16000 and have four rectangles of size 8000, at the offsets (0,0), (0,8000), (8000, 0) and (8000, 8000) and put them together if needed in a program like Photoshop.


The rectangle is simply which area in the imagined complete image you wish to render, out of the width and height pixels given.


Hope this helps.

Post by Johny // Mar 27, 2006, 4:47am

Johny
Total Posts: 672
pic
Chamaeleon, thanks for the usefull information :jumpy:

Post by Johny // Mar 27, 2006, 5:03am

Johny
Total Posts: 672
pic
Stan, if you interesting about NURB knot vector, you can download a paper (How to use Knot Vector) Written by: John W.Peterson.
at this link :
http://www.saccade.com/writing/graphics/

Found it when searching about NURB curve.

Look like above spiral curve code need some fix on control poins value :rolleyes:

Post by Johny // Mar 30, 2006, 1:48pm

Johny
Total Posts: 672
pic
I use "in run time dynamic linking" to load tsxapi.dll file.

And then use GetProcAddress function get address of tsxRenderAViewRectangleToFile.


here is my code:

1: CtsxRect j_renderRect;

2: tsxRenderToFileData j_renderToFileParams;

3: tsxERR error_code;


4: typedef tsxERR (CALLBACK* tsxRenderAViewRectangleToFileX)(tsxRenderToFileDat a* data, CtsxRect* rectangle);


5: HINSTANCE dllHandle = NULL;

6: tsxRenderAViewRectangleToFileX tsxRenderAViewRectangleToFileXPtr = NULL;


7: dllHandle = LoadLibrary("tsxapi.dll");



8: tsxRenderAViewRectangleToFileXPtr = (tsxRenderAViewRectangleToFileX)GetProcAddress(dll Handle,"tsxRenderAViewRectangleToFile");



9: error_code = tsxRenderAViewRectangleToFileXPtr(&j_renderToFileParams,&j_renderRect);


Problem is when code line 9 is execute, I got a run time error message. If I ignore this error message, the plugin continue running and save good render result to file.


My question is how to disable this run time error message? or maybe can anyone tell me is there any error on my code?

Post by chamaeleon // Mar 30, 2006, 2:07pm

chamaeleon
Total Posts: 74
Try "HMODULE dllInstance = GetModuleHandle("tsxapi");" instead of LoadLibrary(), hopefully that will work.

Post by GraySho // Mar 30, 2006, 2:48pm

GraySho
Total Posts: 695
pic
I don't understand anything you guys are talking about, but good to see that someone is capale of doing this stuff. Hope to see many useful plugins :D

Post by Johny // Mar 30, 2006, 2:55pm

Johny
Total Posts: 672
pic
Thanks again Chamaeleon, it's worked. :jumpy:


<EDIT>

Sorry I think it's worked but I wrong (ops I run it's on tS5.2).


The same error still exits. :(

</EDIT>


problem solved after I changed code line 4 from:

typedef tsxERR (CALLBACK* tsxRenderAViewRectangleToFileX)(tsxRenderToFileDat a* data, CtsxRect* rectangle);

to

typedef tsxERR (*CALLBACK tsxRenderAViewRectangleToFileX)(tsxRenderToFileDat a* data, CtsxRect* rectangle);

:)

Post by stan // Apr 4, 2006, 11:29am

stan
Total Posts: 1240
pic
Im looking for any info on getting the size of a selection of vertices, faces, or edges..
this doesn't seem to work tsxGNodeGetSize (mk:@MSITStore:C:\Documents%20and%20Settings\gordo n\My%20Documents\mytsw\tsw\doc\ts\ts66api.chm::/tsxGNode_8h.html#a29) (tsxGNODE (mk:@MSITStore:C:\Documents%20and%20Settings\gordo n\My%20Documents\mytsw\tsw\doc\ts\ts66api.chm::/structtsxGNODE.html) *pGNode, CtsxVector3f (mk:@MSITStore:C:\Documents%20and%20Settings\gordo n\My%20Documents\mytsw\tsw\doc\ts\ts66api.chm::/structCtsxVector3f.html) *size)

thought using the boundingbox minbounds maxbounds on an VXarray might work tsxPolyhGetVxArray (mk:@MSITStore:C:\Documents%20and%20Settings\gordo n\My%20Documents\mytsw\tsw\doc\ts\ts66api.chm::/tsxPolyh_8h.html#a13) (tsxPOLYHEDRON (mk:@MSITStore:C:\Documents%20and%20Settings\gordo n\My%20Documents\mytsw\tsw\doc\ts\ts66api.chm::/structtsxPOLYHEDRON.html) *pPolyh)
but can't figure out how to set it up..:confused:

Post by chamaeleon // Apr 4, 2006, 11:56am

chamaeleon
Total Posts: 74
I don't think there's a "size" function available for selected parts of an object, only the object as a whole. Perhaps the following workflow will work..


1. Use tsxPolyhGetUserSelectedFaces()/Edges()/Vertices() to get the set of interest, using the return value for the count.

2. Populate a CtsxVector3f array with the points for the selection, pulling out the data from the selection using the vertex array from tsxPolyhVxGetArray(), and using the indices available through the selection in step 1.

3. Transform, optionally, the populated array using tsxTransformVecs3f(), if you desire a different orientation than along world axes.

4. Iterate over the result and collect max/min coordinates and you should have your bounding box (I think).


I don't think there's a way to have trueSpace construct a CtsxBBox3f object for you based on a set of points, you can only do that for a GNode, if I read the API correctly.

Post by stan // Apr 4, 2006, 12:02pm

stan
Total Posts: 1240
pic
thanks chamaeleon..in the sdk custom widget sample it has a boundingbox for face vxs using the tsxPolyhGetVxArray (mk:@MSITStore:C:\Documents%20and%20Settings\gordo n\My%20Documents\mytsw\tsw\doc\ts\ts66api.chm::/tsxPolyh_8h.html#a13) (tsxPOLYHEDRON (mk:@MSITStore:C:\Documents%20and%20Settings\gordo n\My%20Documents\mytsw\tsw\doc\ts\ts66api.chm::/structtsxPOLYHEDRON.html) *pPolyh)..thought of using it, but can't figure out how to get it to give size....

Post by chamaeleon // Apr 4, 2006, 12:08pm

chamaeleon
Total Posts: 74
It seems to me that the sample uses more or less the strategy I outlined, only it does it for all points on the object, rather than a selection (so no need for the extra step of looking up the points for a selection, but just using all points in the array). The creation of the bounding box is done in the GetBoundingBox() function in the sample, looping over the points for the wdgsparent object in the call to the function.

Post by stan // Apr 4, 2006, 12:20pm

stan
Total Posts: 1240
pic
thanks chamaeleon..so I was on the right track..then it's just a matter of getting the distance between minbounds and maxbounds of the boundingbox that GetBoundingBox() creates..
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn