changing the nFaces paramter leading to trueSpace crash, why

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.

changing the nFaces paramter leading to trueSpace crash, why // Scriptorium

1  |  

Post by Emma // Nov 15, 2006, 11:41am

Emma
Total Posts: 344
pic
WOrking on a tutorial for simple basic object creation, defining the vertices, edges and faces ts crashes, why ? Used the WavyPillar object as basics for changing to a simplified script.

Post by Norm // Nov 15, 2006, 8:41pm

Norm
Total Posts: 862
pic
I would suggest you over simplify creation process. From what I see you trying to do, you are trying to create latitudes, where none are accounted for.


Longitude handles the number of exterior faces and latitude handles the "floors" of the object (like in WavyPillarMesh). I see no indication of you taking latitude into account so I wanted to point this out.


I suspect you are crashing because you build bad geometry in scripting.

Post by tomasb // Nov 19, 2006, 1:08pm

tomasb
Total Posts: 261
Nice tutorial.


just want to add: to define faces you need to fill

Face Edges Stream Data stream and add it to triangles group.


Face edges stream contains one dword for each triangle - one bit for triangle edge. It says whether triangle edge is also face edge (bit set to 1) or it is internal edge (set to 0).

example:


assume you want to create a quad. it's vertices are 0,1,2,3. triangles are

0,1,2; 0,2,3.

edge stream would be: 3 (= 1+2 = 011b), 6 (= 2+4 = 110b)...


hth

Post by Norm // Nov 20, 2006, 8:19am

Norm
Total Posts: 862
pic
I am reading through the tutorial. I see inconsistency at beginning, where you are adding two values and getting a result. You show in tutorial "red" text for the result, which in ts7 signifies an input connector. Blue on the other hand signifies an export connector. If you rewrite the first portion of script and show blue text, it will be less confusing to your readers. On page 3 of tutorial, you are doing it right and it shows properly.


On page 6, you use red text again, where you should highlight instead to blue if you are talking about an output connector:


params.conValue("Ergebnis") =


You could pick a blue color you like but should differentiate between input connector color and output connector color so reader can not be confused. As the tutorial progresses I see this some more so careful of text color, to be clear and concise.



You may wish to think of an object like so:


Object has axis location, which is the distance in x, y and z from the location 000 in scene (scene origin is location x=0, y=0 and z=0). Every vertex has its own location, which is based on the object's axis location. Vertex x,y and z describes distance from axis location. Is important to understand that x, y and z are not width, length and height, but rather location location location. :) page 7 could be explained this way I believe.


The tutorial is coming along nicely though Emma. You are good to take steps to learn how it all works. You have good start here and is rewarding to see you take this on and understand it as you progress.


I have not taken time to explore this area much yet myself, so you are teaching me too :)


You should also save / export the script object from ts7 and upload it here as well. That way we can download it and check it out and offer some advice too.


Nice work Emma.

Post by Norm // Nov 20, 2006, 9:09am

Norm
Total Posts: 862
pic
I figured that if you copy/paste, the color of text is confusing. But on outside of node, where attributes' connector is showing blue or red, if we maintain this color in script examples, we would not confuse even ourselves :)


Is good you see it as more complex now. I would like to first see you create just a polygon. Say an octagon. When you figure how to create octagon, you move up to a solid octagon, then one with two or three floors, and you can end up creating a script with some sliders, to control the number of sides in the polygon and then number of sides and floors in the solid. When you do this, you can understand the basic concept of vertices, edges and faces. That would be good tutorial for a new user to begin to understand how the geometry is actually generated.

Post by trueBlue // Nov 20, 2006, 10:43am

trueBlue
Total Posts: 1761
pic
;)ctagon...? You know you want to do a Diamond! Please make a "Hearts on fire", the worlds most perfectly cut diamond.

Post by tomasb // Nov 24, 2006, 4:08am

tomasb
Total Posts: 261
I'm jhaving an effect which I can't explain. When I set the numbers for the faces their appearance seems to correspond to the order they are set. There are the three variables

dF.i()

dF.j()

dF.k()



What you encountered is called back face culling - faces with their normals pointing in view direction are not rendered. This is an optimization that is commonly used to reduce number of rendered faces by half...

You can hide this problem by allowing double sided rendering, but you SHOULD keep orientation correct otherwise you will generate meshes with bad topology which will cause problems with SDS and other tools... - for edge connecting points A,B there does not exist edge connecting B,A; but instead you have two edges A,B.

Post by tomasb // Nov 29, 2006, 5:55am

tomasb
Total Posts: 261
SOS:(

Sorry, but I just am getting desperate. Get an error which I just can't find. no matter how much I try.

Did put in a system alert giving me the values that are used in the script line that is shown to me as wrong. The two values of 71/35 are correct.

Solution:

1) someone tells me what is wrong and what I don't see

2) someone tells me how I get that VBScript to work (see reply above)


picture shows part of code, A) system alert message and B) jscript error message


If you run the script the error message will appear in english.


Thank you very much for any help, please


Check size of triangle array when you allocate it. triangle count is 70... that means you are trying to overflow triangle buffer.

Post by tomasb // Nov 30, 2006, 10:25am

tomasb
Total Posts: 261
Normals are defined very similar to vertices, you define indices to normals... to get faceted appearing, set all normal indices to equal value (let's say i) and calculate triangle normal and put it to normals[i].xyz...

something like:


for (i = 0; i<triangle_count;i++)

{

normal_index[i].i = i;

normal_index[i].j = i;

normal_index[i].k = i;


normal_vector[i] = (triangle_vertices[ triangle_indices[i].i ] - triangle_vertices[ triangle_indices[i].j ]) cross (triangle_vertices[ triangle_indices[i].j ] - triangle_vertices[ triangle_indices[i].k ]);

}


if normal streams are not defined, tS generates default smooth normals (averages triangle normals for each vertex)

Post by tomasb // Nov 30, 2006, 8:13pm

tomasb
Total Posts: 261
what i postet was just an idea written in a simple script; what you really need is create Triangle Normals Stream Data and Vertex Normal Stream Data. Fill them in proposed way (cross i mentitioned was cross product; it may be not in a math., i'm not sure ..) and attach streams to triangle group and to custom group. Vertex Normal Stream is a bit "wrong" name - as it belongs to custom stream group; but it was used a lot so renaming was not possible at the later stage...

Post by tomasb // Dec 1, 2006, 10:27am

tomasb
Total Posts: 261
Oh boy, where are you leading me to with that cross product. Best explanation which I hope I understood is in wikipedia ( http://wiki.delphigl.com/index.php/Tutorial_Lineare_Algebra ) (look at: Kreuzprodukt (Vektorprodukt = CrossProduct) )


So do I understand it correct that you calculate the face (size) by two vectors, which then results as "flat" if it is exactly the size of the third vector that represents in crossproduct the correct area or face size and which will bend or bow up when it is larger than the calculated face from the two vectors ?

At least now I know that besides clickin on the mouse or typing on the keyboard I can "cross produkt" with three fingers :D


cross product: it has much more exact mathematical definition; but cross product name came from X operator - a x b ; cross product returns vector that is perpendicular to both a and b and it's length is equal to size of area of a parallelogram with sides a and b. (on the other side there is a DOT product - a . b - which is cosine between a and b mutliplied by lengths of a and b.


because normal vector is unit length vector that is perpendicular to triangle, you can use cross product to calculate it but make sure you normalize the result to get unit length vector.

Post by tomasb // Dec 4, 2006, 9:32am

tomasb
Total Posts: 261
Searching around to get this solved without developing the wheel again I found some functions in the LE librarys but the Rtfloat in/out make problems as I didn't find correct function to feed it.

Playing then around with the "Create Normalmap" (page 506 in AG) it works fine when switching over to Player window. But as soon as I change anything like height or number of facetes the object gets smootheged again. For some reason the normals info seems to get lost.

Tried different settings of the bridge sync function, no help, as soon as I change something in the Player window sharp edges and faces are gone.:(

can you upload or PM here the obj for inspection?

Post by tomasb // Dec 5, 2006, 12:04am

tomasb
Total Posts: 261
No problem, I understood this part of the forum for learning from each other, and honestly, I hoped somebody would ask this question:) because that gives hope getting help for a solution:D . I'm writing tutorial parallel to development of my work and so I'm stuck at the moment trying to understand cross mathematics:(


first picture shows one important thing, the connection line of the Mesh disappears when click on "Flip All Normals" in the modeler window.

When changing to Player everything stays ok until I connect the Mesh lines

(second picture)


Sorry forgot to add , setting Sync to ON / OFF / AUTO also gets into this as when you set OFF to ON the facetes get lost


Script is still beta.


first note about a bridge:

when you open modeler and change the obj, bridge tries to update rS geometry - it finds out that there is no suitabne node where to store results so it creates Shape node and reconnects everything. Because part of mesh conversion is calculation of normal streams, mesh in player will get normals according to material settings in Modeler. When you start editing in player, mesh editor checks if node that contains mesh is editable; if no, it adds Mesh modifier node and editor starts. All changes are then stored to editable mesh modifier node. Also bridge resembles mesh modifier as a valid mesh storage, so when you combine point editing in modeler and player, it should work.


second note about meshes and materials in player:

materials in player no more contain smoothing angle and smoothing is performed completly different. It uses even faster and more general approach as smoothing groups that are commonly used.


third note about normals in player:

For each triangle corner, there is index into normal table. When two corners contain the same normal index, the triangle vertices will get the same normal... then if you want smooth edge, you need to use same indices for each vertex pair. for example you have edge with vertex indices 10,11 and (oposite edge) 11,10. You use normal indices 0,1 and 1,0; then each corner will get the same normal as it's pair so when interpolating normals result will be smooth.


fourth note about cross product:

lets say you have two 3D vectors a and b and want to find perpendiculat vector c to both a and b. You can write a set of equations a . c = 0 (c is perpendicular to a) and b . c = 0 (c is perpendicular to b). You can see that you have 2 equations and 3 unknowns; that means infinite number of solutions. but... when this homogenous equation you can use a help of determinant: you know that det (a b c) should be non-zero


(ax ay az)

(bx by bz)

(cx cy cz)


you get:

(ay*bz - az*by)*cx +

(az*bx - ax*bz)*cy +

(ax*by - ay*bx)*cz = k

which is 3rd equation you need to get... when you think of it - you have a dot product with some vector which is non-zero (equals to k) and you can check that dotting it with a or b will get 0...


so you can take

(ay*bz - az*by) = cx

(az*bx - ax*bz) = cy

(ax*by - ay*bx) = cz

which is vector perpendicular to both a and b... from other properties you will get that |c| is surface of parallelogram defined by a and b but that is not so important
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