Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/shaders/node_vector_rotate.osl
- This file was added.
| /* | |||||
| * Copyright 2011-2013 Blender Foundation | |||||
| * | |||||
| * Licensed under the Apache License, Version 2.0 (the "License"); | |||||
| * you may not use this file except in compliance with the License. | |||||
| * You may obtain a copy of the License at | |||||
| * | |||||
| * http://www.apache.org/licenses/LICENSE-2.0 | |||||
| * | |||||
| * Unless required by applicable law or agreed to in writing, software | |||||
| * distributed under the License is distributed on an "AS IS" BASIS, | |||||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
| * See the License for the specific language governing permissions and | |||||
| * limitations under the License. | |||||
| */ | |||||
| #include "stdosl.h" | |||||
| /* XYZ order */ | |||||
| void eul_to_mat(output matrix mat, point eul) | |||||
| { | |||||
| float ci, cj, ch, si, sj, sh, cc, cs, sc, ss; | |||||
| ci = cos(eul[0]); | |||||
| cj = cos(eul[1]); | |||||
| ch = cos(eul[2]); | |||||
| si = sin(eul[0]); | |||||
| sj = sin(eul[1]); | |||||
| sh = sin(eul[2]); | |||||
| cc = ci * ch; | |||||
| cs = ci * sh; | |||||
| sc = si * ch; | |||||
| ss = si * sh; | |||||
| mat[0][0] = (cj * ch); | |||||
| mat[1][0] = (sj * sc - cs); | |||||
| mat[2][0] = (sj * cc + ss); | |||||
| mat[0][1] = (cj * sh); | |||||
| mat[1][1] = (sj * ss + cc); | |||||
| mat[2][1] = (sj * cs - sc); | |||||
| mat[0][2] = -sj; | |||||
| mat[1][2] = (cj * si); | |||||
| mat[2][2] = (cj * ci); | |||||
| mat[3][0] = mat[3][1] = mat[3][2] = mat[0][3] = mat[1][3] = mat[2][3] = 0.0; | |||||
| mat[3][3] = 1.0; | |||||
| } | |||||
| shader node_vector_rotate( | |||||
| float X = 0.0, | |||||
| float Y = 0.0, | |||||
| float Z = 0.0, | |||||
| point Origin = point(0.0, 0.0, 0.0), | |||||
| vector VectorIn = vector(0.0, 0.0, 0.0), | |||||
| output vector VectorOut = vector(0.0, 0.0, 0.0)) | |||||
| { | |||||
| point in = VectorIn; | |||||
| matrix rmat; | |||||
| eul_to_mat(rmat, point(X,Y,Z)); | |||||
| in = in - Origin; | |||||
| in = transform(rmat, in); | |||||
| in = in + Origin; | |||||
| VectorOut = in; | |||||
| } | |||||