Fractal surface
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/05/2010 at 18:06, xxxxxxxx wrote:
I am only find this about Current State To Object:
Current State To Object (CSTO)
CSTO has to be executed on a duplicate of an object because CSTO modifies the existing caches. In some cases you have to use a temporary document as well (GetVirtualObjects()).Is there more in the SDK about it? Should I use a CallCommand() to do CSTO?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 31/05/2010 at 19:21, xxxxxxxx wrote:
Okay so after doing some more digging in the SDK and some searches here at the cafe, I have found two ways to do the current State To Object.
BaseObject *SpaceRock::GetVirtualObjects(BaseObject* op, HierarchyHelp* hh) { Bool dirty = op->CheckCache(hh) || op->IsDirty(DIRTY_DATA); if (!dirty) return op->GetCache(hh); ModelingCommandData mcd; BaseObject *cube = BaseObject::Alloc(Ocube); if(!cube) goto Error; cube->SetParameter(PRIM_CUBE_SUBX, GeData(4),0); cube->SetParameter(PRIM_CUBE_SUBY, GeData(4),0); cube->SetParameter(PRIM_CUBE_SUBZ, GeData(4),0); PolygonObject *polyCube = ToPoly(cube); if(!polyCube) goto Error; Vector * points = polyCube->GetPointW(); LONG pointCount = polyCube->GetPointCount(); //mcd.op = polyCube; //mcd.mode = MODIFY_ALL; //SendModelingCommand(MCOMMAND_CURRENTSTATETOOBJECT, mcd); Real arr[20]; InitFbm(arr,10,2.0,0.5); for (int i = 0; i < pointCount; i++) { Real rmf = RidgedMultifractal(arr, points[i], 10, 3, 7) * 5.0; Real turb = Turbulence(points[i],10, TRUE) * 5.0; Real snoise = SNoise(points[i]) * 5.0; Real fbm = Fbm(arr, points[i], 10) * 5.0; points[i] = points[i] * turb; points[i] = points[i] * rmf; points[i] = points[i] * snoise; points[i] = points[i] * fbm; } //CallCommand(12233); //Current State To Object cube->Message(MSG_UPDATE); return polyCube; Error: return NULL; }
I have commented both ways out but you can see that I do it with the CallCommand() and I also do it with a SendModelingCommand(). Is there a particularly more effective way to do it? Also, I still must not be doing it correctly, because nothing is happening to my cube. I believe that given the changes I made to the loop that at least something should happen to the points _but nothing is which leads me to believe that it is still not correctly doing the CSTO.
Do you notice anything in particular that I am doing wrong? I will keep looking for more info here and in the SDK as well. Thanks,
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 01/06/2010 at 00:43, xxxxxxxx wrote:
You need to use SendModelingCommand(), then get the result.
Also remember that you sometimes have to clone your original object, and use the modeling command on the clone, as it's shown in some threads here in the forum.The ToPoly cast can be removed, since it does not change the object. Rather cast the modeling command result to a PolygonObject, that would make more sense
Also, if you would have taken a close look into the SDK, as I advised you, you would have found some nice demo code for exactly this modeling command in the documentation. It also shows you how to get the result.
Cheers,
Jack -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 01/06/2010 at 16:11, xxxxxxxx wrote:
Well after some blood, sweat, and SDK searching I finally figured it out. When you're right you're right Jack,,, I learned much more by combing through the SDK...
Thanks for the pep talk.. LOL
~Shawn -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 03/06/2010 at 18:26, xxxxxxxx wrote:
If I want to subdivide the rock using the SendModelingCOmmand() is this okay to do from within GetVirtualObjects or is that unsafe? I know it says you can't chan ge the scene from within GVO but if the object hasn't been added to the scene yet, is it safe to subdivide it?
Thanks,
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 05/06/2010 at 21:38, xxxxxxxx wrote:
Hey Jack,
So I have successfully created an object and am using noise functions to alter the look of the object.
Here is the code I am using.
Real arr[20]; InitFbm(arr,20,7,0.5); for (int i = 0; i < pointCount; i++) { Real rmf = RidgedMultifractal(arr, points[i], octaves, offset, gain) * .8; Real turb = Turbulence(points[i],octaves, abs) * .8; Real wavturb = WavyTurbulence(points[i],time, octaves, 1) * .8; Real noise = Noise(points[i]) * .8; //RIDGED MULTIFRACTAL if (bc->GetLong(SPACEROCK_NOISE_TYPE) == SPACEROCK_RIDGEDMULTIFRACTAL) { points[i] = Mix(points[i] * rmf, points[i], amt); } //Turbulence if (bc->GetLong(SPACEROCK_NOISE_TYPE) == SPACEROCK_TURBULENCE) { points[i] = Mix(points[i] * turb, points[i], amt); } //Wavy Turbulence if (bc->GetLong(SPACEROCK_NOISE_TYPE) == SPACEROCK_WAVY_TURBULENCE) { points[i] = Mix(points[i] * wavturb, points[i], amt); } //Noise if (bc->GetLong(SPACEROCK_NOISE_TYPE) == SPACEROCK_NOISE) { points[i] = Mix(points[i] * noise, points[i], amt); } } //SUBDIVISION Real subAmount = bc->GetReal(SPACEROCK_SUBDIVISIONS); bc2.SetBool(MDATA_SUBDIVIDE_HYPER, TRUE); bc2.SetLong(MDATA_SUBDIVIDE_SUB, subAmount); bc2.SetReal(MDATA_SUBDIVIDE_ANGLE, pi); mcd2.bc = &bc2; mcd2.op = polyCube; mcd2.mode = MODIFY_ALL; mcd2.doc = hh->GetDocument(); if(SendModelingCommand(MCOMMAND_SUBDIVIDE, mcd2)) { GePrint("done"); } else { GePrint("failed"); }
My results are okay but I would like to get a more detailed and fine noise look. Do you have any tips on how to improve the way I am affecting the object with the noise functions. This is how my object looks right now with noise applied.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/06/2010 at 10:57, xxxxxxxx wrote:
well, i guess you first need to create more faces to get more details. than you could apply more layers of noise at different scales and coordinates.. or you simply add the detail using a nice mix of noises in the relief channel
cheers,
Ello -
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/06/2010 at 11:04, xxxxxxxx wrote:
Hi ello,
even when I subdivide the rock the noise still follows this broad pattern. as if it's not fully affecting each point. I would like the ripples and bumps to be on a smaller scale. Hopefully that makes sense.
Can you provide an example of layering the noise functions? I have tried to do this but don't seem to be getting success.
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/06/2010 at 11:08, xxxxxxxx wrote:
does using the subdivide command actually add more polygons to the image?
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/06/2010 at 19:50, xxxxxxxx wrote:
okay so I'm getting some good results now but I want to add some bulges throughout the rock. Take a look at this image.
you can see that this particular spacerock is a bit too perfect. I want to use the noise functions to create som random buldges to the overall shape of the rock. Is it possible to apply noise to the whole rock? Does anyone have any thoughts on how I could accomplish these random bulges?
Would it work to create a random function and then iterate through the rock's points again and only apply noise to random points this time?
Thanks in advance.
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 06/06/2010 at 21:46, xxxxxxxx wrote:
you could use another noise and do something like if (noise>0.8) add certain ammount to point offset
plus, you should add different results to the x, y and z part of the points.. likeReal rmf1 = RidgedMultifractal(arr, 1 + points[i]*factor.x, 20, 0, 1)*strength.x; Real rmf2 = RidgedMultifractal(arr, 2 + points[i]*factor.y, 20, 0, 1)*strength.y; Real rmf3 = RidgedMultifractal(arr, 3 + points[i]*factor.z, 20, 0, 1)*strength.z; points[i] += Vector(rmf1,rmf2,rmf3);
hope this helps
edit: plus you really should use bools for the noise types so to make a mix off all of them
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/06/2010 at 05:14, xxxxxxxx wrote:
I'm not sure what you mean by factor.x is factor a vector? and is strength a vector? or should the .x .y and .z be on the points _?
Thanks,
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 07/06/2010 at 05:30, xxxxxxxx wrote:
those are vectors you can let the user change, to adjust the size (factor) and the strength of the noise..
btw, i could think that it would be a good idea to take the normal direction into account. i'd share my normal calculation code with you, but its only for faces and point normals are not really working.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 08/06/2010 at 17:56, xxxxxxxx wrote:
can someone provide me an example of layering noise functions. many resources mention that it is important to layer noise functions. I am not entirely sure what is exactly meant by that. Could someone elaborate?
Thanks,
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 08/06/2010 at 21:42, xxxxxxxx wrote:
there are many ways how you can mix some noises. for example:
Vector someNoise = 0; someNoise.x = RidgedMultifractal(arr, 1 + points[i]*factor.x, 20, 0, 1)*strength.x; someNoise.y = RidgedMultifractal(arr, 2 + points[i]*factor.y, 20, 0, 1)*strength.y; someNoise.z = RidgedMultifractal(arr, 3 + points[i]*factor.z, 20, 0, 1)*strength.z; Vector anotherNoise = 0; anotherNoise.x = Turbulence(points[i]*anotherFactor.x,20, false) * anotherStrength.x; anotherNoise.y = Turbulence(points[i]*anotherFactor.y,20, false) * anotherStrength.y; anotherNoise.z = Turbulence(points[i]*anotherFactor.z,20, false) * anotherStrength.z; Vector myNoise = Mix (someNoise,anotherNoise,mix);
where mix is a user value or jet another noise...
or you could multiply
Vector myNoise = someNoise * anotherNoise;or add
Vector myNoise = someNoise + anotherNoise;or just try anything out.. there are just too many things you can do
hope it helps..
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 09/06/2010 at 15:51, xxxxxxxx wrote:
Okay that's easy enough.,. thanks a lot. ello!
~Shawn
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/06/2010 at 04:16, xxxxxxxx wrote:
Originally posted by xxxxxxxx
..btw, i could think that it would be a good idea to take the normal direction into account. i'd share my normal calculation code with you, but its only for faces and point normals are not really working.
As an aside, here is some Normal info...
For faces, you can simply do:
Vector *padr = ToPoly(op)->GetPointW(); CPolygon *polys = ToPoly(op)->GetPolygonW(); Vector vNorm = CalcFaceNormal(padr, polys[poly_of_interest]);
For Point Normals, I created a helper structure, similar to how the UVWStruct is used...
struct NormalStruct { NormalStruct(_DONTCONSTRUCT dc) : a(DC), b(DC), c(DC), d(DC) { } NormalStruct(void) {} NormalStruct(const Vector &t;_a, const Vector &t;_b, const Vector &t;_c, const Vector &t;_d) { a=t_a; b=t_b; c=t_c; d=t_d; } NormalStruct(const Vector &t;_a, const Vector &t;_b, const Vector &t;_c) { a=t_a; b=t_b; c=t_c; } Vector a,b,c,d; };
...for Point Normals, you want "a normal for every vertex/point of every polygon" (ie. not just one per point) - this allows for Phong Edge-Breaks in the shading. So, assuming that the mesh _has_ a Phong Tag, you can just do:
NormalStruct *pNorms = (NormalStruct * )ToPoly(op)->CreatePhongNormals();
...the CreatePhongNormals() routine will return a pointer to an array of Point Normals - **4** normals for every polygon in the mesh (just like the UVW Tag returns 4 uv coordinates per polygon). This is the same as the NormalStruct I list above, so you can use that structure to access the (a,b,c,d) normals.
If the mesh doesn't have a Phong Tag (ie. CreatePhongNormals() returns a Null), you can either skip it, or generate normals based on averaging the face normals (I'd suggest writing your own routine that does this, allocating, filling in and returning the same NormalStruct pointer/array).
Be sure to GeFree(pNorms) when done.
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/06/2010 at 04:36, xxxxxxxx wrote:
thanks giblet for your input.. at the moment i am averaging the neighbouring polygon normals and it works like this on a standard sphere for example:
this is how i calculate it:
neighbor.GetPointPolys(i, &dadr, &dcnt); polyNormal=0; for (int j=0;j<dcnt;j++) { if (dadr[j]<maxcount) { polyNormal += polygonNormal(nCalc1,nCalc2,padr,pol,dadr[j]); } } polyNormal /= dcnt;
where polygonNormal(...) is returning the correct mormal for each polygon as it is working in my plugin.
it seems to me that there is an invisible cut going thru the mesh which results in wrong or no neighbour
any ideas?
cheers,
ellobtw: sorry for the hijacking here...
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/06/2010 at 05:01, xxxxxxxx wrote:
Hmmm.. not sure. Are you calling neighbor.Init() before trying to use it?
Here's some code I've been using (several class member variables are set up elsewhere, but it should be self-explanitory)...
Bool MeshMap::GetSrcVertexNormals(void) { LONG i, j, faceCnt, *pFaces = NULL; Vector vNorm, *pNorm; // initialize neighbor class... this is used to compute m_SrcvNorms if( !m_Neighbor.Init(m_numSrcVerts, m_SrcPolys, m_numSrcPolys, NULL) ) return false; StatusSetText("Computing Vertex Normals..."); pNorm = &m;_pSrcvNorms[0]; for(i=0; i<m_numSrcVerts; i++) { vNorm = Vector(); // (re)intitialize m_Neighbor.GetPointPolys(i, &pFaces;, &faceCnt;); if( faceCnt ) { for(j=0; j<faceCnt; j++) { Vector n = CalcFaceNormal(m_pxfSrcVerts, m_SrcPolys[pFaces[j]]); vNorm += !n; } vNorm /= faceCnt; // average the normal(s) *pNorm = !vNorm; // normalize and store } else *pNorm = Vector(0.0,1.0,0.0); pNorm++; } return true; }
EDIT: Note... this code only generates a normal-per-vertex, which is contrary to my suggestion in my previous reply (this particular implementation didn't need to concern itself with phong-edge-breaks).
-
THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 11/06/2010 at 05:59, xxxxxxxx wrote:
thank you very much. i'll see if i can fix it with this input. i remember i didnt normalize it so maybe that coul cause it...